@sourcey/catalog-verifier 1.1.22 → 1.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/SOURCEY-CLOSURE.json +277 -133
- package/dist/contracts/admission-results/src/index.d.ts +31 -0
- package/dist/contracts/admission-results/src/index.d.ts.map +1 -1
- package/dist/contracts/admission-results/src/index.js +29 -0
- package/dist/contracts/admission-results/src/index.js.map +1 -1
- package/dist/contracts/agent-readiness/src/binding.d.ts +28 -1
- package/dist/contracts/agent-readiness/src/binding.d.ts.map +1 -1
- package/dist/contracts/agent-readiness/src/binding.js +75 -16
- package/dist/contracts/agent-readiness/src/binding.js.map +1 -1
- package/dist/contracts/agent-readiness/src/client.d.ts +30 -0
- package/dist/contracts/agent-readiness/src/client.d.ts.map +1 -0
- package/dist/contracts/agent-readiness/src/client.js +25 -0
- package/dist/contracts/agent-readiness/src/client.js.map +1 -0
- package/dist/contracts/agent-readiness/src/declaration-acquisition.d.ts +91 -0
- package/dist/contracts/agent-readiness/src/declaration-acquisition.d.ts.map +1 -1
- package/dist/contracts/agent-readiness/src/declaration-acquisition.js +6 -0
- package/dist/contracts/agent-readiness/src/declaration-acquisition.js.map +1 -1
- package/dist/contracts/agent-readiness/src/declaration.d.ts +362 -0
- package/dist/contracts/agent-readiness/src/declaration.d.ts.map +1 -1
- package/dist/contracts/agent-readiness/src/declaration.js +47 -80
- package/dist/contracts/agent-readiness/src/declaration.js.map +1 -1
- package/dist/contracts/agent-readiness/src/{operate-policy.d.ts → grade-policy.d.ts} +31 -79
- package/dist/contracts/agent-readiness/src/grade-policy.d.ts.map +1 -0
- package/dist/contracts/agent-readiness/src/grade-policy.js +93 -0
- package/dist/contracts/agent-readiness/src/grade-policy.js.map +1 -0
- package/dist/contracts/agent-readiness/src/index.d.ts +3 -1
- package/dist/contracts/agent-readiness/src/index.d.ts.map +1 -1
- package/dist/contracts/agent-readiness/src/index.js +3 -1
- package/dist/contracts/agent-readiness/src/index.js.map +1 -1
- package/dist/contracts/agent-readiness/src/jobs.d.ts +12 -3
- package/dist/contracts/agent-readiness/src/jobs.d.ts.map +1 -1
- package/dist/contracts/agent-readiness/src/jobs.js +8 -1
- package/dist/contracts/agent-readiness/src/jobs.js.map +1 -1
- package/dist/contracts/agent-readiness/src/offer-relations.d.ts +89 -0
- package/dist/contracts/agent-readiness/src/offer-relations.d.ts.map +1 -1
- package/dist/contracts/agent-readiness/src/operation.d.ts +106 -0
- package/dist/contracts/agent-readiness/src/operation.d.ts.map +1 -0
- package/dist/contracts/agent-readiness/src/operation.js +228 -0
- package/dist/contracts/agent-readiness/src/operation.js.map +1 -0
- package/dist/contracts/agent-readiness/src/release-index.d.ts +277 -89
- package/dist/contracts/agent-readiness/src/release-index.d.ts.map +1 -1
- package/dist/contracts/agent-readiness/src/revision.d.ts +500 -166
- package/dist/contracts/agent-readiness/src/revision.d.ts.map +1 -1
- package/dist/contracts/agent-readiness/src/revision.js +100 -37
- package/dist/contracts/agent-readiness/src/revision.js.map +1 -1
- package/dist/contracts/agent-readiness/src/run.d.ts +386 -98
- package/dist/contracts/agent-readiness/src/run.d.ts.map +1 -1
- package/dist/contracts/agent-readiness/src/run.js +333 -52
- package/dist/contracts/agent-readiness/src/run.js.map +1 -1
- package/dist/contracts/agent-readiness/src/shared.d.ts +51 -17
- package/dist/contracts/agent-readiness/src/shared.d.ts.map +1 -1
- package/dist/contracts/agent-readiness/src/shared.js +52 -23
- package/dist/contracts/agent-readiness/src/shared.js.map +1 -1
- package/dist/contracts/agent-readiness/src/surfaces.d.ts +25 -0
- package/dist/contracts/agent-readiness/src/surfaces.d.ts.map +1 -0
- package/dist/contracts/agent-readiness/src/surfaces.js +76 -0
- package/dist/contracts/agent-readiness/src/surfaces.js.map +1 -0
- package/dist/contracts/api/src/endpoints.d.ts +895 -254
- package/dist/contracts/api/src/endpoints.d.ts.map +1 -1
- package/dist/contracts/api/src/read.d.ts +354 -109
- package/dist/contracts/api/src/read.d.ts.map +1 -1
- package/dist/contracts/api/src/read.js +1 -1
- package/dist/contracts/api/src/read.js.map +1 -1
- package/dist/contracts/api/src/routes.d.ts +27 -23
- package/dist/contracts/api/src/routes.d.ts.map +1 -1
- package/dist/contracts/api/src/routes.js +2 -3
- package/dist/contracts/api/src/routes.js.map +1 -1
- package/dist/contracts/api/src/submissions.d.ts +141 -0
- package/dist/contracts/api/src/submissions.d.ts.map +1 -1
- package/dist/contracts/api/src/submissions.js +28 -4
- package/dist/contracts/api/src/submissions.js.map +1 -1
- package/dist/contracts/datasets/src/index.d.ts +13 -10
- package/dist/contracts/datasets/src/index.d.ts.map +1 -1
- package/dist/contracts/publication/src/index.d.ts +64 -0
- package/dist/contracts/publication/src/index.d.ts.map +1 -1
- package/dist/contracts/publication/src/index.js +20 -0
- package/dist/contracts/publication/src/index.js.map +1 -1
- package/dist/contracts/startup-credits-commercial/src/requests.d.ts +2 -0
- package/dist/contracts/startup-credits-commercial/src/requests.d.ts.map +1 -1
- package/dist/modules/agent-readiness-engine/src/assertions.d.ts.map +1 -1
- package/dist/modules/agent-readiness-engine/src/assertions.js +25 -0
- package/dist/modules/agent-readiness-engine/src/assertions.js.map +1 -1
- package/dist/modules/agent-readiness-engine/src/authority.d.ts +81 -0
- package/dist/modules/agent-readiness-engine/src/authority.d.ts.map +1 -0
- package/dist/modules/agent-readiness-engine/src/authority.js +189 -0
- package/dist/modules/agent-readiness-engine/src/authority.js.map +1 -0
- package/dist/modules/agent-readiness-engine/src/challenges.d.ts +13 -0
- package/dist/modules/agent-readiness-engine/src/challenges.d.ts.map +1 -0
- package/dist/modules/agent-readiness-engine/src/challenges.js +67 -0
- package/dist/modules/agent-readiness-engine/src/challenges.js.map +1 -0
- package/dist/modules/agent-readiness-engine/src/documents.d.ts +21 -0
- package/dist/modules/agent-readiness-engine/src/documents.d.ts.map +1 -0
- package/dist/modules/agent-readiness-engine/src/documents.js +69 -0
- package/dist/modules/agent-readiness-engine/src/documents.js.map +1 -0
- package/dist/modules/agent-readiness-engine/src/naming.d.ts +19 -0
- package/dist/modules/agent-readiness-engine/src/naming.d.ts.map +1 -0
- package/dist/modules/agent-readiness-engine/src/naming.js +28 -0
- package/dist/modules/agent-readiness-engine/src/naming.js.map +1 -0
- package/dist/modules/agent-readiness-engine/src/path.d.ts +68 -15
- package/dist/modules/agent-readiness-engine/src/path.d.ts.map +1 -1
- package/dist/modules/agent-readiness-engine/src/path.js +467 -153
- package/dist/modules/agent-readiness-engine/src/path.js.map +1 -1
- package/dist/modules/agent-readiness-engine/src/profile.d.ts +85 -0
- package/dist/modules/agent-readiness-engine/src/profile.d.ts.map +1 -0
- package/dist/modules/agent-readiness-engine/src/profile.js +176 -0
- package/dist/modules/agent-readiness-engine/src/profile.js.map +1 -0
- package/dist/modules/agent-readiness-engine/src/rate.d.ts +10 -20
- package/dist/modules/agent-readiness-engine/src/rate.d.ts.map +1 -1
- package/dist/modules/agent-readiness-engine/src/rate.js +29 -47
- package/dist/modules/agent-readiness-engine/src/rate.js.map +1 -1
- package/dist/modules/agent-readiness-engine/src/records.d.ts +30 -0
- package/dist/modules/agent-readiness-engine/src/records.d.ts.map +1 -0
- package/dist/modules/agent-readiness-engine/src/records.js +59 -0
- package/dist/modules/agent-readiness-engine/src/records.js.map +1 -0
- package/dist/modules/agent-readiness-jobs/src/index.d.ts +16 -8
- package/dist/modules/agent-readiness-jobs/src/index.d.ts.map +1 -1
- package/dist/modules/agent-readiness-jobs/src/index.js +12 -7
- package/dist/modules/agent-readiness-jobs/src/index.js.map +1 -1
- package/dist/modules/agent-readiness-policy/src/current-policy.d.ts +13 -17
- package/dist/modules/agent-readiness-policy/src/current-policy.d.ts.map +1 -1
- package/dist/modules/agent-readiness-policy/src/current-policy.js +1 -1
- package/dist/modules/agent-readiness-policy/src/current-policy.js.map +1 -1
- package/dist/modules/agent-readiness-policy/src/{operate-policy.d.ts → grade-policy.d.ts} +3 -3
- package/dist/modules/agent-readiness-policy/src/grade-policy.d.ts.map +1 -0
- package/dist/modules/agent-readiness-policy/src/grade-policy.js +82 -0
- package/dist/modules/agent-readiness-policy/src/grade-policy.js.map +1 -0
- package/dist/modules/agent-readiness-policy/src/index.d.ts +4 -4
- package/dist/modules/agent-readiness-policy/src/index.d.ts.map +1 -1
- package/dist/modules/agent-readiness-policy/src/index.js +35 -22
- package/dist/modules/agent-readiness-policy/src/index.js.map +1 -1
- package/dist/modules/agent-readiness-policy/src/revision.d.ts +3 -3
- package/dist/modules/agent-readiness-policy/src/revision.d.ts.map +1 -1
- package/dist/modules/agent-readiness-policy/src/revision.js +40 -32
- package/dist/modules/agent-readiness-policy/src/revision.js.map +1 -1
- package/dist/modules/artifact/src/policy-closure.js +1 -1
- package/dist/modules/artifact/src/policy-closure.js.map +1 -1
- package/dist/modules/catalog-admission/src/index.d.ts +13 -0
- package/dist/modules/catalog-admission/src/index.d.ts.map +1 -1
- package/dist/modules/catalog-admission/src/submission-input.d.ts.map +1 -1
- package/dist/modules/catalog-admission/src/submission-input.js +1 -1
- package/dist/modules/catalog-admission/src/submission-input.js.map +1 -1
- package/dist/modules/catalog-admission/src/submission.d.ts +30 -0
- package/dist/modules/catalog-admission/src/submission.d.ts.map +1 -1
- package/dist/modules/catalog-admission/src/submission.js +29 -16
- package/dist/modules/catalog-admission/src/submission.js.map +1 -1
- package/dist/modules/release/src/verification-policies.d.ts +13 -17
- package/dist/modules/release/src/verification-policies.d.ts.map +1 -1
- package/dist/modules/release/src/verification-policies.js +1 -1
- package/dist/modules/release/src/verification-policies.js.map +1 -1
- package/dist/modules/sourcey-publication/src/verifier.d.ts +5 -0
- package/dist/modules/sourcey-publication/src/verifier.d.ts.map +1 -1
- package/dist/modules/sourcey-publication/src/verifier.js +13 -0
- package/dist/modules/sourcey-publication/src/verifier.js.map +1 -1
- package/package.json +1 -1
- package/dist/contracts/agent-readiness/src/operate-policy.d.ts.map +0 -1
- package/dist/contracts/agent-readiness/src/operate-policy.js +0 -86
- package/dist/contracts/agent-readiness/src/operate-policy.js.map +0 -1
- package/dist/modules/agent-readiness-policy/src/operate-policy.d.ts.map +0 -1
- package/dist/modules/agent-readiness-policy/src/operate-policy.js +0 -110
- package/dist/modules/agent-readiness-policy/src/operate-policy.js.map +0 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { ExchangeRecord } from "provenry/exchange/records";
|
|
2
|
+
import { type Challenge } from "./challenges.js";
|
|
3
|
+
/**
|
|
4
|
+
* The authority chain an *authority* answer, or an error before authority,
|
|
5
|
+
* points to (north star §5.5): RFC 9728 protected-resource metadata, then the
|
|
6
|
+
* authorization server's RFC 8414 or OpenID metadata, then its auth.md agent
|
|
7
|
+
* registration or how Sourcey's agent can identify itself as an OAuth client,
|
|
8
|
+
* then whether a PKCE authorization request with that client reaches consent.
|
|
9
|
+
* These are the pure readings; the probe suite performs the exchanges.
|
|
10
|
+
*/
|
|
11
|
+
/** The Bearer challenge's parameters an agent follows: where the metadata is, and what scope. */
|
|
12
|
+
export declare function bearerChallenge(record: ExchangeRecord): Challenge | null;
|
|
13
|
+
/**
|
|
14
|
+
* Where the protected-resource metadata for a resource is: the challenge's
|
|
15
|
+
* `resource_metadata`, else RFC 9728 §3.1's well-known location with the
|
|
16
|
+
* resource's path inserted, then at the root.
|
|
17
|
+
*/
|
|
18
|
+
export declare function protectedResourceMetadataUrls(resource: string, challenge: Challenge | null): readonly string[];
|
|
19
|
+
/** RFC 9728 metadata as published: the resource, its authorization servers and its scopes. */
|
|
20
|
+
export declare function protectedResourceMetadata(document: unknown): {
|
|
21
|
+
readonly resource: string;
|
|
22
|
+
readonly authorizationServers: readonly string[];
|
|
23
|
+
readonly scopes: readonly string[];
|
|
24
|
+
} | null;
|
|
25
|
+
/** RFC 9728 metadata for a resource on the operation's origin: its first authorization server. */
|
|
26
|
+
export declare function readProtectedResource(document: unknown, operationUrl: string): {
|
|
27
|
+
readonly authorizationServer: string;
|
|
28
|
+
readonly scopes: readonly string[];
|
|
29
|
+
} | null;
|
|
30
|
+
/**
|
|
31
|
+
* Where an authorization server's metadata is, in the order MCP clients try:
|
|
32
|
+
* RFC 8414 with the issuer's path inserted, OpenID with it inserted, OpenID
|
|
33
|
+
* with it appended; or, for an issuer without a path, RFC 8414 then OpenID.
|
|
34
|
+
*/
|
|
35
|
+
export declare function authorizationServerMetadataUrls(issuer: string): readonly string[];
|
|
36
|
+
export interface AuthorizationServerMetadata {
|
|
37
|
+
readonly issuer: string;
|
|
38
|
+
/** Null for a server that only registers agents (auth.md) and runs no authorization flow. */
|
|
39
|
+
readonly authorizationEndpoint: string | null;
|
|
40
|
+
readonly registrationEndpoint: string | null;
|
|
41
|
+
readonly clientIdMetadataDocument: boolean;
|
|
42
|
+
/** S256 is listed: an MCP client refuses a server that does not list it. */
|
|
43
|
+
readonly pkce: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* The server's auth.md agent registration (`agent_auth` with an
|
|
46
|
+
* `identity_endpoint`): `agent` when it offers `anonymous`, which needs no
|
|
47
|
+
* person; `claimable` when it offers only `service_auth` or
|
|
48
|
+
* `identity_assertion`, which a person claims or confirms once.
|
|
49
|
+
*/
|
|
50
|
+
readonly registration: "agent" | "claimable" | null;
|
|
51
|
+
/** A renewal grant is offered: refresh, or with auth.md the JWT-bearer exchange of its assertion. */
|
|
52
|
+
readonly renewal: boolean;
|
|
53
|
+
/** A revocation endpoint is named. */
|
|
54
|
+
readonly revocation: boolean;
|
|
55
|
+
}
|
|
56
|
+
/** Server metadata for exactly this issuer (RFC 8414 §3.3), or null. */
|
|
57
|
+
export declare function readAuthorizationServer(document: unknown, issuer: string): AuthorizationServerMetadata | null;
|
|
58
|
+
/** The client id a dynamic registration returned, or null. */
|
|
59
|
+
export declare function registeredClientId(document: unknown): string | null;
|
|
60
|
+
/**
|
|
61
|
+
* The PKCE authorization request a probe sends: Sourcey's client, its redirect
|
|
62
|
+
* URI, a challenge derived from the run's nonce, and the resource and scope the
|
|
63
|
+
* chain named. Sourcey never redeems a code, so the verifier is never sent.
|
|
64
|
+
*/
|
|
65
|
+
export declare function authorizationRequestUrl(input: {
|
|
66
|
+
readonly authorizationEndpoint: string;
|
|
67
|
+
readonly clientId: string;
|
|
68
|
+
readonly resource: string;
|
|
69
|
+
readonly scopes: readonly string[];
|
|
70
|
+
readonly nonce: string;
|
|
71
|
+
}): string;
|
|
72
|
+
/**
|
|
73
|
+
* Whether an answered authorization request reached consent: the server
|
|
74
|
+
* accepted it and moved to the person's sign-in or consent, answering with a
|
|
75
|
+
* page (2xx HTML) or redirecting, with no `error`, anywhere but back to
|
|
76
|
+
* Sourcey. A redirect back carries an error or a code Sourcey discards; a
|
|
77
|
+
* redirect carrying `error` refused the client; any other answer refused it
|
|
78
|
+
* too. An unanswered request is residue (`probeUnanswered`) and never read here.
|
|
79
|
+
*/
|
|
80
|
+
export declare function consentReached(record: ExchangeRecord): boolean;
|
|
81
|
+
//# sourceMappingURL=authority.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authority.d.ts","sourceRoot":"","sources":["../../../../modules/agent-readiness-engine/src/authority.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EAAE,KAAK,SAAS,EAAmB,MAAM,iBAAiB,CAAC;AAIlE;;;;;;;GAOG;AAEH,iGAAiG;AACjG,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,SAAS,GAAG,IAAI,CAIxE;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,SAAS,GAAG,IAAI,GAC1B,SAAS,MAAM,EAAE,CASnB;AAED,8FAA8F;AAC9F,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,OAAO,GAAG;IAC5D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,oBAAoB,EAAE,SAAS,MAAM,EAAE,CAAC;IACjD,QAAQ,CAAC,MAAM,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,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,GAAG,MAAM,CAYT;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAoB9D"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { AGENT_READINESS_REDIRECT_URI } from "../../../contracts/agent-readiness/src/index.js";
|
|
3
|
+
import { parseChallenges } from "./challenges.js";
|
|
4
|
+
import { httpsUrl, record } from "./documents.js";
|
|
5
|
+
import { responseHeader, unansweredRecord } from "./records.js";
|
|
6
|
+
/**
|
|
7
|
+
* The authority chain an *authority* answer, or an error before authority,
|
|
8
|
+
* points to (north star §5.5): RFC 9728 protected-resource metadata, then the
|
|
9
|
+
* authorization server's RFC 8414 or OpenID metadata, then its auth.md agent
|
|
10
|
+
* registration or how Sourcey's agent can identify itself as an OAuth client,
|
|
11
|
+
* then whether a PKCE authorization request with that client reaches consent.
|
|
12
|
+
* These are the pure readings; the probe suite performs the exchanges.
|
|
13
|
+
*/
|
|
14
|
+
/** The Bearer challenge's parameters an agent follows: where the metadata is, and what scope. */
|
|
15
|
+
export function bearerChallenge(record) {
|
|
16
|
+
const header = responseHeader(record, "www-authenticate");
|
|
17
|
+
if (header === null)
|
|
18
|
+
return null;
|
|
19
|
+
return parseChallenges(header).find(({ scheme }) => scheme === "bearer") ?? null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Where the protected-resource metadata for a resource is: the challenge's
|
|
23
|
+
* `resource_metadata`, else RFC 9728 §3.1's well-known location with the
|
|
24
|
+
* resource's path inserted, then at the root.
|
|
25
|
+
*/
|
|
26
|
+
export function protectedResourceMetadataUrls(resource, challenge) {
|
|
27
|
+
const named = oauthUrl(challenge?.params.resource_metadata);
|
|
28
|
+
if (named)
|
|
29
|
+
return [named];
|
|
30
|
+
const url = new URL(resource);
|
|
31
|
+
const path = url.pathname.replace(/\/+$/u, "");
|
|
32
|
+
return [
|
|
33
|
+
...(path ? [`${url.origin}/.well-known/oauth-protected-resource${path}`] : []),
|
|
34
|
+
`${url.origin}/.well-known/oauth-protected-resource`,
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
/** RFC 9728 metadata as published: the resource, its authorization servers and its scopes. */
|
|
38
|
+
export function protectedResourceMetadata(document) {
|
|
39
|
+
const metadata = record(document);
|
|
40
|
+
const resource = oauthUrl(metadata?.resource);
|
|
41
|
+
if (!resource)
|
|
42
|
+
return null;
|
|
43
|
+
return {
|
|
44
|
+
resource,
|
|
45
|
+
authorizationServers: Array.isArray(metadata?.authorization_servers)
|
|
46
|
+
? metadata.authorization_servers.flatMap((server) => oauthUrl(server) ?? [])
|
|
47
|
+
: [],
|
|
48
|
+
scopes: Array.isArray(metadata?.scopes_supported)
|
|
49
|
+
? metadata.scopes_supported.filter((scope) => typeof scope === "string")
|
|
50
|
+
: [],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** RFC 9728 metadata for a resource on the operation's origin: its first authorization server. */
|
|
54
|
+
export function readProtectedResource(document, operationUrl) {
|
|
55
|
+
const metadata = protectedResourceMetadata(document);
|
|
56
|
+
if (!metadata || new URL(metadata.resource).origin !== new URL(operationUrl).origin)
|
|
57
|
+
return null;
|
|
58
|
+
const [authorizationServer] = metadata.authorizationServers;
|
|
59
|
+
return authorizationServer ? { authorizationServer, scopes: metadata.scopes } : null;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Where an authorization server's metadata is, in the order MCP clients try:
|
|
63
|
+
* RFC 8414 with the issuer's path inserted, OpenID with it inserted, OpenID
|
|
64
|
+
* with it appended; or, for an issuer without a path, RFC 8414 then OpenID.
|
|
65
|
+
*/
|
|
66
|
+
export function authorizationServerMetadataUrls(issuer) {
|
|
67
|
+
const url = new URL(issuer);
|
|
68
|
+
const path = url.pathname.replace(/\/+$/u, "");
|
|
69
|
+
return path
|
|
70
|
+
? [
|
|
71
|
+
`${url.origin}/.well-known/oauth-authorization-server${path}`,
|
|
72
|
+
`${url.origin}/.well-known/openid-configuration${path}`,
|
|
73
|
+
`${url.origin}${path}/.well-known/openid-configuration`,
|
|
74
|
+
]
|
|
75
|
+
: [
|
|
76
|
+
`${url.origin}/.well-known/oauth-authorization-server`,
|
|
77
|
+
`${url.origin}/.well-known/openid-configuration`,
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
const JWT_BEARER_GRANT = "urn:ietf:params:oauth:grant-type:jwt-bearer";
|
|
81
|
+
/** Server metadata for exactly this issuer (RFC 8414 §3.3), or null. */
|
|
82
|
+
export function readAuthorizationServer(document, issuer) {
|
|
83
|
+
const metadata = record(document);
|
|
84
|
+
const stated = oauthUrl(metadata?.issuer);
|
|
85
|
+
const authorizationEndpoint = oauthUrl(metadata?.authorization_endpoint);
|
|
86
|
+
const registration = agentRegistration(metadata?.agent_auth);
|
|
87
|
+
if (!stated || trimmed(stated) !== trimmed(issuer))
|
|
88
|
+
return null;
|
|
89
|
+
if (!authorizationEndpoint && !registration)
|
|
90
|
+
return null;
|
|
91
|
+
const strings = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
92
|
+
const grants = strings(metadata?.grant_types_supported);
|
|
93
|
+
return {
|
|
94
|
+
issuer: stated,
|
|
95
|
+
authorizationEndpoint,
|
|
96
|
+
registrationEndpoint: oauthUrl(metadata?.registration_endpoint),
|
|
97
|
+
clientIdMetadataDocument: metadata?.client_id_metadata_document_supported === true,
|
|
98
|
+
pkce: strings(metadata?.code_challenge_methods_supported).includes("S256"),
|
|
99
|
+
registration,
|
|
100
|
+
renewal: grants.includes("refresh_token") ||
|
|
101
|
+
(registration !== null && grants.includes(JWT_BEARER_GRANT)),
|
|
102
|
+
revocation: oauthUrl(metadata?.revocation_endpoint) !== null,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* auth.md's `agent_auth` block: an `identity_endpoint` the agent registers at,
|
|
107
|
+
* and the registration types it accepts (`identity_types_supported`).
|
|
108
|
+
*/
|
|
109
|
+
function agentRegistration(value) {
|
|
110
|
+
const block = record(value);
|
|
111
|
+
if (!block || !oauthUrl(block.identity_endpoint))
|
|
112
|
+
return null;
|
|
113
|
+
const types = Array.isArray(block.identity_types_supported) ? block.identity_types_supported : [];
|
|
114
|
+
if (types.includes("anonymous"))
|
|
115
|
+
return "agent";
|
|
116
|
+
return types.includes("service_auth") || types.includes("identity_assertion")
|
|
117
|
+
? "claimable"
|
|
118
|
+
: null;
|
|
119
|
+
}
|
|
120
|
+
/** The client id a dynamic registration returned, or null. */
|
|
121
|
+
export function registeredClientId(document) {
|
|
122
|
+
const id = record(document)?.client_id;
|
|
123
|
+
return typeof id === "string" && id.length > 0 && id.length <= 512 ? id : null;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The PKCE authorization request a probe sends: Sourcey's client, its redirect
|
|
127
|
+
* URI, a challenge derived from the run's nonce, and the resource and scope the
|
|
128
|
+
* chain named. Sourcey never redeems a code, so the verifier is never sent.
|
|
129
|
+
*/
|
|
130
|
+
export function authorizationRequestUrl(input) {
|
|
131
|
+
const url = new URL(input.authorizationEndpoint);
|
|
132
|
+
const verifier = base64url(sha256(`sourcey.agent-readiness-pkce:${input.nonce}`));
|
|
133
|
+
url.searchParams.set("response_type", "code");
|
|
134
|
+
url.searchParams.set("client_id", input.clientId);
|
|
135
|
+
url.searchParams.set("redirect_uri", AGENT_READINESS_REDIRECT_URI);
|
|
136
|
+
url.searchParams.set("state", input.nonce);
|
|
137
|
+
url.searchParams.set("code_challenge", base64url(sha256(verifier)));
|
|
138
|
+
url.searchParams.set("code_challenge_method", "S256");
|
|
139
|
+
url.searchParams.set("resource", input.resource);
|
|
140
|
+
if (input.scopes.length > 0)
|
|
141
|
+
url.searchParams.set("scope", input.scopes.join(" "));
|
|
142
|
+
return url.href;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Whether an answered authorization request reached consent: the server
|
|
146
|
+
* accepted it and moved to the person's sign-in or consent, answering with a
|
|
147
|
+
* page (2xx HTML) or redirecting, with no `error`, anywhere but back to
|
|
148
|
+
* Sourcey. A redirect back carries an error or a code Sourcey discards; a
|
|
149
|
+
* redirect carrying `error` refused the client; any other answer refused it
|
|
150
|
+
* too. An unanswered request is residue (`probeUnanswered`) and never read here.
|
|
151
|
+
*/
|
|
152
|
+
export function consentReached(record) {
|
|
153
|
+
if (unansweredRecord(record) || record.outcome !== "responded")
|
|
154
|
+
return false;
|
|
155
|
+
const { status, body } = record.response;
|
|
156
|
+
if (status >= 200 && status <= 299)
|
|
157
|
+
return body.media_type === "text/html";
|
|
158
|
+
if (status >= 300 && status <= 399) {
|
|
159
|
+
const location = responseHeader(record, "location");
|
|
160
|
+
if (location === null)
|
|
161
|
+
return false;
|
|
162
|
+
let target;
|
|
163
|
+
try {
|
|
164
|
+
target = new URL(location, record.request.url);
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
const back = new URL(AGENT_READINESS_REDIRECT_URI);
|
|
170
|
+
return (!target.searchParams.has("error") &&
|
|
171
|
+
!(target.origin === back.origin && target.pathname === back.pathname));
|
|
172
|
+
}
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
function sha256(text) {
|
|
176
|
+
return createHash("sha256").update(text, "utf8").digest();
|
|
177
|
+
}
|
|
178
|
+
function base64url(bytes) {
|
|
179
|
+
return bytes.toString("base64url");
|
|
180
|
+
}
|
|
181
|
+
function trimmed(url) {
|
|
182
|
+
return url.replace(/\/+$/u, "");
|
|
183
|
+
}
|
|
184
|
+
/** An OAuth URL (RFC 8414, RFC 9728): HTTPS, with no credentials and no fragment. */
|
|
185
|
+
function oauthUrl(value) {
|
|
186
|
+
const url = httpsUrl(value);
|
|
187
|
+
return url !== null && new URL(url).hash === "" ? url : null;
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=authority.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authority.js","sourceRoot":"","sources":["../../../../modules/agent-readiness-engine/src/authority.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,4BAA4B,EAAE,MAAM,iDAAiD,CAAC;AAC/F,OAAO,EAAkB,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhE;;;;;;;GAOG;AAEH,iGAAiG;AACjG,MAAM,UAAU,eAAe,CAAC,MAAsB;IACpD,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC1D,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IACjC,OAAO,eAAe,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,KAAK,QAAQ,CAAC,IAAI,IAAI,CAAC;AACnF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,6BAA6B,CAC3C,QAAgB,EAChB,SAA2B;IAE3B,MAAM,KAAK,GAAG,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAC5D,IAAI,KAAK;QAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAC1B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC9B,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC/C,OAAO;QACL,GAA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AC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,MAAM,CAAC,IAAY;IAC1B,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;AAC5D,CAAC;AAED,SAAS,SAAS,CAAC,KAAa;IAC9B,OAAO,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,OAAO,CAAC,GAAW;IAC1B,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAClC,CAAC;AAED,qFAAqF;AACrF,SAAS,QAAQ,CAAC,KAAc;IAC9B,MAAM,GAAG,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5B,OAAO,GAAG,KAAK,IAAI,IAAI,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** One authentication challenge: its scheme, lower-cased, and its parameters by lower-cased name. */
|
|
2
|
+
export interface Challenge {
|
|
3
|
+
readonly scheme: string;
|
|
4
|
+
readonly params: Readonly<Record<string, string>>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The challenges a `WWW-Authenticate` value carries, as RFC 9110 §11.6.1
|
|
8
|
+
* writes them: comma-separated, each a scheme followed by `name=value`
|
|
9
|
+
* parameters (a value a token or a quoted string) or a token68. A parameter
|
|
10
|
+
* before any scheme belongs to no challenge and is dropped.
|
|
11
|
+
*/
|
|
12
|
+
export declare function parseChallenges(header: string): readonly Challenge[];
|
|
13
|
+
//# sourceMappingURL=challenges.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"challenges.d.ts","sourceRoot":"","sources":["../../../../modules/agent-readiness-engine/src/challenges.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACnD;AAID;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,SAAS,EAAE,CAwDpE"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const TOKEN = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+/u;
|
|
2
|
+
/**
|
|
3
|
+
* The challenges a `WWW-Authenticate` value carries, as RFC 9110 §11.6.1
|
|
4
|
+
* writes them: comma-separated, each a scheme followed by `name=value`
|
|
5
|
+
* parameters (a value a token or a quoted string) or a token68. A parameter
|
|
6
|
+
* before any scheme belongs to no challenge and is dropped.
|
|
7
|
+
*/
|
|
8
|
+
export function parseChallenges(header) {
|
|
9
|
+
const challenges = [];
|
|
10
|
+
let rest = header;
|
|
11
|
+
const skip = (pattern) => {
|
|
12
|
+
rest = rest.replace(pattern, "");
|
|
13
|
+
};
|
|
14
|
+
while (rest.length > 0) {
|
|
15
|
+
skip(/^[\s,]+/u);
|
|
16
|
+
const token = TOKEN.exec(rest)?.[0];
|
|
17
|
+
if (!token)
|
|
18
|
+
break;
|
|
19
|
+
rest = rest.slice(token.length);
|
|
20
|
+
skip(/^\s*/u);
|
|
21
|
+
if (rest.startsWith("=") && !rest.startsWith("==")) {
|
|
22
|
+
// A parameter: of the challenge open now, or of none.
|
|
23
|
+
rest = rest.slice(1);
|
|
24
|
+
skip(/^\s*/u);
|
|
25
|
+
const value = readValue();
|
|
26
|
+
const open = challenges.at(-1);
|
|
27
|
+
if (open && value !== null)
|
|
28
|
+
open.params[token.toLowerCase()] = value;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
const challenge = { scheme: token.toLowerCase(), params: {} };
|
|
32
|
+
challenges.push(challenge);
|
|
33
|
+
// A token68 directly after the scheme, such as `Basic dXNlcjpwYXNz`.
|
|
34
|
+
const token68 = /^[A-Za-z0-9._~+/-]+=*(?=\s*(?:,|$))/u.exec(rest)?.[0];
|
|
35
|
+
if (token68 && !/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\s*=[^=]/u.test(rest)) {
|
|
36
|
+
rest = rest.slice(token68.length);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return challenges;
|
|
40
|
+
function readValue() {
|
|
41
|
+
if (rest.startsWith('"')) {
|
|
42
|
+
let value = "";
|
|
43
|
+
let index = 1;
|
|
44
|
+
while (index < rest.length) {
|
|
45
|
+
const char = rest[index];
|
|
46
|
+
if (char === "\\" && index + 1 < rest.length) {
|
|
47
|
+
value += rest[index + 1];
|
|
48
|
+
index += 2;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (char === '"') {
|
|
52
|
+
rest = rest.slice(index + 1);
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
value += char;
|
|
56
|
+
index += 1;
|
|
57
|
+
}
|
|
58
|
+
rest = "";
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
const token = TOKEN.exec(rest)?.[0] ?? null;
|
|
62
|
+
if (token)
|
|
63
|
+
rest = rest.slice(token.length);
|
|
64
|
+
return token;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=challenges.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"challenges.js","sourceRoot":"","sources":["../../../../modules/agent-readiness-engine/src/challenges.ts"],"names":[],"mappings":"AAMA,MAAM,KAAK,GAAG,+BAA+B,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,MAAM,UAAU,GAAyD,EAAE,CAAC;IAC5E,IAAI,IAAI,GAAG,MAAM,CAAC;IAClB,MAAM,IAAI,GAAG,CAAC,OAAe,EA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AE,CAAC;YACnE,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IACD,OAAO,UAAU,CAAC;IAElB,SAAS,SAAS;QAChB,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACzB,IAAI,KAAK,GAAG,EAAE,CAAC;YACf,IAAI,KAAK,GAAG,CAAC,CAAC;YACd,OAAO,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;gBAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAW,CAAC;gBACnC,IAAI,IAAI,KAAK,IAAI,IAAI,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;oBAC7C,KAAK,IAAI,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;oBACzB,KAAK,IAAI,CAAC,CAAC;oBACX,SAAS;gBACX,CAAC;gBACD,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;oBACjB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;oBAC7B,OAAO,KAAK,CAAC;gBACf,CAAC;gBACD,KAAK,IAAI,IAAI,CAAC;gBACd,KAAK,IAAI,CAAC,CAAC;YACb,CAAC;YACD,IAAI,GAAG,EAAE,CAAC;YACV,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;QAC5C,IAAI,KAAK;YAAE,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC3C,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Reading the documents a service publishes: their shape only, never their prose. */
|
|
2
|
+
/** A JSON object, or null for anything else. */
|
|
3
|
+
export declare function record(value: unknown): Record<string, unknown> | null;
|
|
4
|
+
/** An HTTPS URL carrying no credentials, normalised, or null. */
|
|
5
|
+
export declare function httpsUrl(value: unknown): string | null;
|
|
6
|
+
/** Strict UTF-8, or null for bytes that are not. */
|
|
7
|
+
export declare function utf8(bytes: Uint8Array): string | null;
|
|
8
|
+
/** Parsed JSON, or undefined for text that is not. */
|
|
9
|
+
export declare function json(text: string): unknown;
|
|
10
|
+
/**
|
|
11
|
+
* The OpenAPI 3.x version a document states, when it is one: its `openapi`
|
|
12
|
+
* version and the `info` object (a title and a version) OpenAPI requires.
|
|
13
|
+
*/
|
|
14
|
+
export declare function openApiVersion(document: Record<string, unknown> | null): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* A JSON or YAML document parsed, or undefined for text that is neither:
|
|
17
|
+
* vendors publish OpenAPI documents in both. Aliases are bounded, so a small
|
|
18
|
+
* document cannot expand into a large one.
|
|
19
|
+
*/
|
|
20
|
+
export declare function jsonOrYaml(text: string): unknown;
|
|
21
|
+
//# sourceMappingURL=documents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../../../../modules/agent-readiness-engine/src/documents.ts"],"names":[],"mappings":"AAEA,sFAAsF;AAEtF,gDAAgD;AAChD,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAIrE;AAED,iEAAiE;AACjE,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAQtD;AAED,oDAAoD;AACpD,wBAAgB,IAAI,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAMrD;AAED,sDAAsD;AACtD,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAM1C;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAStF;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAQhD"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { parse as parseYaml } from "yaml";
|
|
2
|
+
/** Reading the documents a service publishes: their shape only, never their prose. */
|
|
3
|
+
/** A JSON object, or null for anything else. */
|
|
4
|
+
export function record(value) {
|
|
5
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
6
|
+
? value
|
|
7
|
+
: null;
|
|
8
|
+
}
|
|
9
|
+
/** An HTTPS URL carrying no credentials, normalised, or null. */
|
|
10
|
+
export function httpsUrl(value) {
|
|
11
|
+
if (typeof value !== "string")
|
|
12
|
+
return null;
|
|
13
|
+
try {
|
|
14
|
+
const url = new URL(value);
|
|
15
|
+
return url.protocol === "https:" && !url.username && !url.password ? url.href : null;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** Strict UTF-8, or null for bytes that are not. */
|
|
22
|
+
export function utf8(bytes) {
|
|
23
|
+
try {
|
|
24
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** Parsed JSON, or undefined for text that is not. */
|
|
31
|
+
export function json(text) {
|
|
32
|
+
try {
|
|
33
|
+
return JSON.parse(text);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The OpenAPI 3.x version a document states, when it is one: its `openapi`
|
|
41
|
+
* version and the `info` object (a title and a version) OpenAPI requires.
|
|
42
|
+
*/
|
|
43
|
+
export function openApiVersion(document) {
|
|
44
|
+
const version = document?.openapi;
|
|
45
|
+
const info = record(document?.info);
|
|
46
|
+
return typeof version === "string" &&
|
|
47
|
+
/^3\.\d+\.\d+$/u.test(version) &&
|
|
48
|
+
typeof info?.title === "string" &&
|
|
49
|
+
typeof info.version === "string"
|
|
50
|
+
? version
|
|
51
|
+
: null;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A JSON or YAML document parsed, or undefined for text that is neither:
|
|
55
|
+
* vendors publish OpenAPI documents in both. Aliases are bounded, so a small
|
|
56
|
+
* document cannot expand into a large one.
|
|
57
|
+
*/
|
|
58
|
+
export function jsonOrYaml(text) {
|
|
59
|
+
const parsed = json(text);
|
|
60
|
+
if (parsed !== undefined)
|
|
61
|
+
return parsed;
|
|
62
|
+
try {
|
|
63
|
+
return parseYaml(text, { maxAliasCount: 100 });
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=documents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documents.js","sourceRoot":"","sources":["../../../../modules/agent-readiness-engine/src/documents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAE1C,sFAAsF;AAEtF,gDAAgD;AAChD,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACzE,CAAC,CAAE,KAAiC;QACpC,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;QAC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S;QAAE,OAAO,MAAM,CAAC;IACxC,IAAI,CAAC;QACH,OAAO,SAAS,CAAC,IAAI,EAAE,EAAE,aAAa,EAAE,GAAG,EAAE,CAAY,CAAC;IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When a discovery fact names a job's endpoint (north star §5.2, Discover).
|
|
3
|
+
* The engine rates Discover by this rule, and a card marks the surface the
|
|
4
|
+
* job's request reached by the same one.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Facts that name an interface an agent can call; others (metadata,
|
|
8
|
+
* registration) do not. An API catalog names an API through the OpenAPI it
|
|
9
|
+
* links to, whose servers are `openapi_server` facts; its anchor alone does not.
|
|
10
|
+
*/
|
|
11
|
+
export declare const AGENT_READINESS_NAMING_FACTS: ReadonlySet<string>;
|
|
12
|
+
/** A URL names an endpoint when it gives its exact URI or a base the URI sits under. */
|
|
13
|
+
export declare function agentReadinessNamesEndpoint(value: string, uri: string): boolean;
|
|
14
|
+
/** A discovery fact that names the endpoint: one of the naming facts, naming it. */
|
|
15
|
+
export declare function agentReadinessFactNamesEndpoint(fact: {
|
|
16
|
+
readonly fact: string;
|
|
17
|
+
readonly value: string;
|
|
18
|
+
}, uri: string): boolean;
|
|
19
|
+
//# sourceMappingURL=naming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming.d.ts","sourceRoot":"","sources":["../../../../modules/agent-readiness-engine/src/naming.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,EAAE,WAAW,CAAC,MAAM,CAM3D,CAAC;AAEH,wFAAwF;AACxF,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAI/E;AAED,oFAAoF;AACpF,wBAAgB,+BAA+B,CAC7C,IAAI,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EACvD,GAAG,EAAE,MAAM,GACV,OAAO,CAIT"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When a discovery fact names a job's endpoint (north star §5.2, Discover).
|
|
3
|
+
* The engine rates Discover by this rule, and a card marks the surface the
|
|
4
|
+
* job's request reached by the same one.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Facts that name an interface an agent can call; others (metadata,
|
|
8
|
+
* registration) do not. An API catalog names an API through the OpenAPI it
|
|
9
|
+
* links to, whose servers are `openapi_server` facts; its anchor alone does not.
|
|
10
|
+
*/
|
|
11
|
+
export const AGENT_READINESS_NAMING_FACTS = new Set([
|
|
12
|
+
"mcp_endpoint",
|
|
13
|
+
"ard_entry",
|
|
14
|
+
"openapi_server",
|
|
15
|
+
"oauth_protected_resource",
|
|
16
|
+
"documentation_route",
|
|
17
|
+
]);
|
|
18
|
+
/** A URL names an endpoint when it gives its exact URI or a base the URI sits under. */
|
|
19
|
+
export function agentReadinessNamesEndpoint(value, uri) {
|
|
20
|
+
const base = value.replace(/[?#].*$/u, "").replace(/\/+$/u, "");
|
|
21
|
+
const endpoint = uri.replace(/[?#].*$/u, "").replace(/\/+$/u, "");
|
|
22
|
+
return endpoint === base || endpoint.startsWith(`${base}/`);
|
|
23
|
+
}
|
|
24
|
+
/** A discovery fact that names the endpoint: one of the naming facts, naming it. */
|
|
25
|
+
export function agentReadinessFactNamesEndpoint(fact, uri) {
|
|
26
|
+
return (AGENT_READINESS_NAMING_FACTS.has(fact.fact) && agentReadinessNamesEndpoint(fact.value, uri));
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=naming.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming.js","sourceRoot":"","sources":["../../../../modules/agent-readiness-engine/src/naming.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAwB,IAAI,GAAG,CAAC;IACvE,cAAc;IACd,WAAW;IACX,gBAAgB;IAChB,0BAA0B;IAC1B,qBAAqB;CACtB,CAAC,CAAC;AAEH,wFAAwF;AACxF,MAAM,UAAU,2BAA2B,CAAC,KAAa,EAAE,GAAW;IACpE,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAChE,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAClE,OAAO,QAAQ,KAAK,IAAI,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC;AAC9D,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,+BAA+B,CAC7C,IAAuD,EACvD,GAAW;IAEX,OAAO,CACL,4BAA4B,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,2BAA2B,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAC5F,CAAC;AACJ,CAAC"}
|
|
@@ -1,24 +1,77 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type AgentReadinessJob, type AgentReadinessJobBinding, type AgentReadinessRunRecord, type AgentReadinessStepResult } from "../../../contracts/agent-readiness/src/index.js";
|
|
3
|
-
|
|
1
|
+
import type { AgentReadinessPolicy } from "../../../contracts/agent-readiness/src/grade-policy.js";
|
|
2
|
+
import { type AgentReadinessJob, type AgentReadinessJobBinding, type AgentReadinessJobOperation, type AgentReadinessJobResult, type AgentReadinessRunRecord, type AgentReadinessStep, type AgentReadinessStepResult } from "../../../contracts/agent-readiness/src/index.js";
|
|
3
|
+
/** One interface's path, and whether a later run is due soon to settle or reproduce it. */
|
|
4
|
+
export interface EvaluatedPath {
|
|
5
|
+
readonly steps: readonly AgentReadinessStepResult[];
|
|
6
|
+
/** The job itself, beside the steps (north star §5.6, the job). */
|
|
7
|
+
readonly job: AgentReadinessJobResult;
|
|
8
|
+
/**
|
|
9
|
+
* A later run can settle what this path leaves open: a page answer not yet
|
|
10
|
+
* reproduced, or a failure of the job not yet reproduced.
|
|
11
|
+
*/
|
|
12
|
+
readonly reproducible: boolean;
|
|
13
|
+
/** The probe run whose discovery decided Discover; null when none did. */
|
|
14
|
+
readonly discoveryRun: AgentReadinessRunRecord | null;
|
|
15
|
+
/** The binding's run that decided its outcomes, assessed or not; null for a probed path. */
|
|
16
|
+
readonly verifiedRun: AgentReadinessRunRecord | null;
|
|
17
|
+
/** The probe runs that reproduce a read's standing answer: unanswered on each, since it last answered. */
|
|
18
|
+
readonly standingRuns: readonly AgentReadinessRunRecord[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The probed path of one interface (north star §5.6). The latest probe run that
|
|
22
|
+
* answered the operation decides its steps; a run that left its request, its
|
|
23
|
+
* malformed request, its spec, its authority chain or a declared page
|
|
24
|
+
* unanswered decides nothing, since residue is never a fact. Discovery's
|
|
25
|
+
* latest run decides Discover and the payment manifests, unless an unanswered
|
|
26
|
+
* read could change them: then the latest run whose reads were all answered,
|
|
27
|
+
* or left unanswered only the service's standing answers, does. Earlier runs
|
|
28
|
+
* count only to reproduce a page answer or a standing answer.
|
|
29
|
+
*/
|
|
30
|
+
export declare function evaluateProbePath(input: {
|
|
31
|
+
readonly operation: AgentReadinessJobOperation;
|
|
32
|
+
/** The operation's declared endpoint URI; null for a spec operation. */
|
|
33
|
+
readonly endpoint: string | null;
|
|
34
|
+
readonly policy: Pick<AgentReadinessPolicy, "reproduction">;
|
|
35
|
+
/** The vendor's sales or approval pages that gate this interface, by page id. */
|
|
36
|
+
readonly accessGates: readonly string[];
|
|
37
|
+
/** The settings a person turns on once before an agent can use this interface, by page id. */
|
|
38
|
+
readonly accessSettings: readonly string[];
|
|
39
|
+
/** The listing rules out a checkout: the job is free, or paid per call by its request's offer. */
|
|
40
|
+
readonly checkoutRuledOut: boolean;
|
|
41
|
+
/** Probe runs of the profile's current declaration revision, any order. */
|
|
42
|
+
readonly runs: readonly AgentReadinessRunRecord[];
|
|
43
|
+
}): EvaluatedPath;
|
|
4
44
|
/**
|
|
5
|
-
* The
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
45
|
+
* The verified path of one binding: what performing the job with its authority
|
|
46
|
+
* establishes (north star §5.6, precedence). Only the vendor's own runs can
|
|
47
|
+
* lower a letter: a refusal of authority a vendor run proved valid counts when
|
|
48
|
+
* the vendor's latest run holds it and its earlier runs reproduce it (the
|
|
49
|
+
* job's refusal makes the job `unavailable`, Authority's makes that step
|
|
50
|
+
* `gated`, and a 402 is a balance a person tops up: Pay's recurring
|
|
51
|
+
* `workaround`), and so do failed assertions reproduced the same way (the job
|
|
52
|
+
* `unavailable`). Otherwise the latest run that did the job decides while it
|
|
53
|
+
* is fresh; a failing run from anyone else never lowers a letter.
|
|
10
54
|
*/
|
|
11
55
|
export declare function evaluatePath(input: {
|
|
12
56
|
readonly job: AgentReadinessJob;
|
|
13
57
|
readonly binding: AgentReadinessJobBinding;
|
|
14
|
-
readonly policy: Pick<AgentReadinessPolicy, "
|
|
58
|
+
readonly policy: Pick<AgentReadinessPolicy, "reproduction" | "fresh_for_days">;
|
|
59
|
+
/** This binding's verified runs, any order. */
|
|
15
60
|
readonly runs: readonly AgentReadinessRunRecord[];
|
|
16
61
|
/** Declared endpoint URIs by id. */
|
|
17
62
|
readonly endpoints: ReadonlyMap<string, string>;
|
|
18
|
-
|
|
19
|
-
readonly
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
63
|
+
/** When freshness is judged: the refresh's own probe run. */
|
|
64
|
+
readonly asOf: string;
|
|
65
|
+
}): EvaluatedPath;
|
|
66
|
+
/**
|
|
67
|
+
* Verified outcomes replace probed ones for the steps the verified run
|
|
68
|
+
* assessed, and for the job (north star §5.6, precedence); a step it left
|
|
69
|
+
* unassessed keeps its probed outcome.
|
|
70
|
+
*/
|
|
71
|
+
export declare function combinePaths(probed: EvaluatedPath, verified: EvaluatedPath): EvaluatedPath;
|
|
72
|
+
export declare function notAssessed(step: AgentReadinessStep): AgentReadinessStepResult;
|
|
73
|
+
/** The job not yet settled by any run. */
|
|
74
|
+
export declare const NOT_ASSESSED_JOB: AgentReadinessJobResult;
|
|
75
|
+
/** The job unavailable on the run's declaration revision alone: it names no interface for the job. */
|
|
76
|
+
export declare function declaredUnavailable(run: AgentReadinessRunRecord): AgentReadinessJobResult;
|
|
24
77
|
//# sourceMappingURL=path.d.ts.map
|