packages/@git/url_897efafd565158fc4908/0.0.0-git.a39fc582565d4fca40be4f75fa304d71adc69301/contracts.aug
OpenID Connect login application · Dependency source and specification
This is the exact dependency version used by this example.
Code
// Generated by aug spec. This is a copy of the installed dependency source.
/** Immutable identity returned by an explicitly injected authentication adapter. */
record Principal(string subject, List<string> permissions)
/** Verify the request's credentials. null means unauthenticated; adapter failures raise HttpError. */
capability Authentication:
authenticate(HttpRequest request) returns optional Principal uses Authentication.authenticate unless HttpError
/** Decide whether a verified identity has one named permission. */
capability Authorization:
authorize(Principal identity, string permission) returns bool uses Authorization.authorize unless HttpError
/** Observe a completed HTTP exchange, including failures and disconnects. */
capability RequestLogger:
complete(string method, string path, int status, int milliseconds) uses RequestLogger.complete
extern C value _aug_http_log(string method, string path, int status, int milliseconds) uses RequestLogger.complete
/** Emit escaped JSON request metadata to standard error. Credentials and query strings are excluded. */
WebRequestLogger() implements RequestLogger:
complete(string method, string path, int status, int milliseconds):
unsafe:
_aug_http_log(method, path, status, milliseconds)
/** An explicit outbound network capability. TLS verifies the peer and redirects are returned to the caller. */
capability HttpClient:
/** Perform an HTTP request with bounded bytes. Inside a task, waiting suspends the task's C stack. */
request(string method, string url, optional Headers headers, optional Bytes body) returns HttpResponse<Bytes> uses HttpClient.request unless HttpError
extern C value _aug_http_request(string method, string url, optional Headers headers, optional Bytes body) returns HttpResponse<Bytes> uses HttpClient.request unless HttpError
/** Native libwebsockets transport. No socket is opened by construction. */
WebHttpClient() implements HttpClient:
request(string method, string url, optional Headers headers, optional Bytes body) returns HttpResponse<Bytes> unless HttpError:
unsafe:
return _aug_http_request(
method=method,
url=url,
headers=headers,
body=body
)
/** Return a redirect with an explicit status. Location is checked as a header value. */
redirect(string location, optional int status) returns HttpResponse<string> unless HttpError:
code = 303
match status:
when null:
pass
when some value:
code = value
headers = Headers().with(name="location", value=location)
return HttpResponse(body="", status=code, headers=headers)
extern C value pure _aug_http_url_encode(string input) returns string unless HttpError
/** Encode a UTF-8 value as one URL query or form component using RFC 3986 unreserved characters. */
urlEncode(string input) returns string unless HttpError:
unsafe:
return _aug_http_url_encode(input)
extern C value pure _aug_http_cookie(string name, string value, string path, int maxAge, bool secure) returns Headers unless HttpError
/** Construct an HttpOnly, SameSite=Lax session cookie. Secure defaults are chosen explicitly at the call site. Values and paths reject delimiters and controls. maxAge=0 clears the cookie. */
cookie(string name, string value, string path, int maxAge, bool secure) returns Headers unless HttpError:
unsafe:
return _aug_http_cookie(name, value, path, maxAge, secure)// Generated by aug spec. This is a copy of the installed dependency source.
/** Immutable identity returned by an explicitly injected authentication adapter. */
record Principal(string subject, List<string> permissions)
/** Verify the request's credentials. null means unauthenticated; adapter failures raise HttpError. */
capability Authentication {
authenticate(HttpRequest request) returns optional Principal uses Authentication.authenticate unless HttpError
}
/** Decide whether a verified identity has one named permission. */
capability Authorization {
authorize(Principal identity, string permission) returns bool uses Authorization.authorize unless HttpError
}
/** Observe a completed HTTP exchange, including failures and disconnects. */
capability RequestLogger {
complete(string method, string path, int status, int milliseconds) uses RequestLogger.complete
}
extern C value _aug_http_log(string method, string path, int status, int milliseconds) uses RequestLogger.complete
/** Emit escaped JSON request metadata to standard error. Credentials and query strings are excluded. */
WebRequestLogger() implements RequestLogger {
complete(string method, string path, int status, int milliseconds) {
unsafe {
_aug_http_log(method, path, status, milliseconds)
}
}
}
/** An explicit outbound network capability. TLS verifies the peer and redirects are returned to the caller. */
capability HttpClient {
/** Perform an HTTP request with bounded bytes. Inside a task, waiting suspends the task's C stack. */
request(string method, string url, optional Headers headers, optional Bytes body) returns HttpResponse<Bytes> uses HttpClient.request unless HttpError
}
extern C value _aug_http_request(string method, string url, optional Headers headers, optional Bytes body) returns HttpResponse<Bytes> uses HttpClient.request unless HttpError
/** Native libwebsockets transport. No socket is opened by construction. */
WebHttpClient() implements HttpClient {
request(string method, string url, optional Headers headers, optional Bytes body) returns HttpResponse<Bytes> unless HttpError {
unsafe {
return _aug_http_request(
method=method,
url=url,
headers=headers,
body=body
)
}
}
}
/** Return a redirect with an explicit status. Location is checked as a header value. */
redirect(string location, optional int status) returns HttpResponse<string> unless HttpError {
code = 303
match status {
when null {
pass
}
when some value {
code = value
}
}
headers = Headers().with(name="location", value=location)
return HttpResponse(body="", status=code, headers=headers)
}
extern C value pure _aug_http_url_encode(string input) returns string unless HttpError
/** Encode a UTF-8 value as one URL query or form component using RFC 3986 unreserved characters. */
urlEncode(string input) returns string unless HttpError {
unsafe {
return _aug_http_url_encode(input)
}
}
extern C value pure _aug_http_cookie(string name, string value, string path, int maxAge, bool secure) returns Headers unless HttpError
/** Construct an HttpOnly, SameSite=Lax session cookie. Secure defaults are chosen explicitly at the call site. Values and paths reject delimiters and controls. maxAge=0 clears the cookie. */
cookie(string name, string value, string path, int maxAge, bool secure) returns Headers unless HttpError {
unsafe {
return _aug_http_cookie(name, value, path, maxAge, secure)
}
}Compiled specification
Principal · immutable record · source
Immutable identity returned by an explicitly injected authentication adapter. It takes subject as a string, kept read-only and permissions as List<string>, kept read-only.
Authentication · capability interface · source
Verify the request's credentials. null means unauthenticated; adapter failures raise HttpError.
Authentication.authenticate · source
It takes request as HttpRequest. It returns optional Principal. It can call Authentication.authenticate. Failures can raise HttpError.
Authorization · capability interface · source
Decide whether a verified identity has one named permission.
Authorization.authorize · source
It takes identity as Principal and permission as a string. It returns bool. It can call Authorization.authorize. Failures can raise HttpError.
RequestLogger · capability interface · source
Observe a completed HTTP exchange, including failures and disconnects.
RequestLogger.complete · source
It takes method and path as strings and status and milliseconds as integers. It can call RequestLogger.complete.
WebRequestLogger · class · source
Emit escaped JSON request metadata to standard error. Credentials and query strings are excluded. It implements RequestLogger.
WebRequestLogger.complete · source
It takes method and path as strings and status and milliseconds as integers. It can call RequestLogger.complete. Within an unsafe block, it calls _aug_http_log with method, path, status, and milliseconds. Native operations must satisfy their declared C contracts. source
Checked interface
complete(string method, string path, int status, int milliseconds) returns void uses RequestLogger.completeIt takes method and path as strings and status and milliseconds as integers. It can call RequestLogger.complete.
HttpClient · capability interface · source
An explicit outbound network capability. TLS verifies the peer and redirects are returned to the caller.
HttpClient.request · source
Perform an HTTP request with bounded bytes. Inside a task, waiting suspends the task's C stack. It takes method and url as strings, headers as optional Headers, and body as optional Bytes. Omitted optional inputs are null.
It returns HttpResponse<Bytes>. It can call HttpClient.request. Failures can raise HttpError.
WebHttpClient · class · source
Native libwebsockets transport. No socket is opened by construction. It implements HttpClient.
WebHttpClient.request · source
Perform an HTTP request with bounded bytes. Inside a task, waiting suspends the task's C stack. It takes method and url as strings, headers as optional Headers, and body as optional Bytes. Omitted optional inputs are null.
It can call HttpClient.request. Failures can raise HttpError. Within an unsafe block, it returns _aug_http_request with method, url, headers, and body. Native operations must satisfy their declared C contracts. source
Checked interface
request(string method, string url, optional Headers headers, optional Bytes body) returns HttpResponse<Bytes> unless HttpError uses HttpClient.requestIt takes method and url as strings, headers as optional Headers, and body as optional Bytes. Omitted optional inputs are null. It can call HttpClient.request. Failures can raise HttpError.
redirect · source
Return a redirect with an explicit status. Location is checked as a header value. It takes location as a string and status as optional int. Omitted optional inputs are null.
Failures can raise HttpError.
It sets code to 303. If status is null, it continues without an operation. If status is not null, using value for it sets code to value. It sets headers to a Headers with the header "location" set to location. source
It returns HTTP code with "" and headers headers. source
Checked interface
redirect(string location, optional int status) returns HttpResponse<string> unless HttpErrorIt takes location as a string and status as optional int. Omitted optional inputs are null. Failures can raise HttpError.
urlEncode · source
Encode a UTF-8 value as one URL query or form component using RFC 3986 unreserved characters. It takes input as a string. Failures can raise HttpError.
Within an unsafe block, it returns _aug_http_url_encode with input. Native operations must satisfy their declared C contracts. source
Checked interface
urlEncode(string input) returns string unless HttpErrorIt takes input as a string. Failures can raise HttpError.
cookie · source
Construct an HttpOnly, SameSite=Lax session cookie. Secure defaults are chosen explicitly at the call site. Values and paths reject delimiters and controls. maxAge=0 clears the cookie.
It takes name, value, and path as strings, maxAge as an integer, and secure as a boolean. Failures can raise HttpError. Within an unsafe block, it returns _aug_http_cookie with name, value, path, maxAge, and secure. Native operations must satisfy their declared C contracts. source
Checked interface
cookie(string name, string value, string path, int maxAge, bool secure) returns Headers unless HttpErrorIt takes name, value, and path as strings, maxAge as an integer, and secure as a boolean. Failures can raise HttpError.
_aug_http_log · source
It is private to its defining scope. It takes method and path as strings and status and milliseconds as integers. It can call RequestLogger.complete. Native C implementation; only its declared contract is visible here.
_aug_http_request · source
It is private to its defining scope. It takes method and url as strings, headers as optional Headers, and body as optional Bytes. Omitted optional inputs are null.
It returns HttpResponse<Bytes>. It can call HttpClient.request. Failures can raise HttpError. Native C implementation; only its declared contract is visible here.
_aug_http_url_encode · source
It is private to its defining scope. It takes input as a string. It returns string. Failures can raise HttpError.
Native C implementation; only its declared contract is visible here.
_aug_http_cookie · source
It is private to its defining scope. It takes name, value, and path as strings, maxAge as an integer, and secure as a boolean. It returns Headers. Failures can raise HttpError.
Native C implementation; only its declared contract is visible here.
Built-in operations follow the language reference.