@kya-os/consent 0.2.1 → 0.2.3
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 +128 -0
- package/dist/bundle/index.d.ts +38 -36
- package/dist/bundle/index.d.ts.map +1 -1
- package/dist/bundle/index.js +35 -33
- package/dist/bundle/index.js.map +1 -1
- package/dist/bundle/inline.d.ts.map +1 -1
- package/dist/bundle/inline.js +4 -4
- package/dist/bundle/inline.js.map +1 -1
- package/dist/bundle/shell.d.ts +7 -0
- package/dist/bundle/shell.d.ts.map +1 -1
- package/dist/bundle/shell.js +5 -0
- package/dist/bundle/shell.js.map +1 -1
- package/dist/cjs/bundle/index.js +4 -1
- package/dist/cjs/bundle/index.js.map +1 -1
- package/dist/cjs/bundle/inline.js +4 -4
- package/dist/cjs/bundle/inline.js.map +1 -1
- package/dist/cjs/bundle/shell.js +5 -0
- package/dist/cjs/bundle/shell.js.map +1 -1
- package/dist/cjs/components/consent-agent-header.js +15 -9
- package/dist/cjs/components/consent-agent-header.js.map +1 -1
- package/dist/cjs/components/consent-capabilities-screen.js +40 -78
- package/dist/cjs/components/consent-capabilities-screen.js.map +1 -1
- package/dist/cjs/components/consent-headline.js +138 -0
- package/dist/cjs/components/consent-headline.js.map +1 -0
- package/dist/cjs/components/consent-otp-input.js +35 -18
- package/dist/cjs/components/consent-otp-input.js.map +1 -1
- package/dist/cjs/components/index.js +3 -1
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/cjs/components/mcp-consent.js +42 -1
- package/dist/cjs/components/mcp-consent.js.map +1 -1
- package/dist/cjs/copy/tokens.js +16 -1
- package/dist/cjs/copy/tokens.js.map +1 -1
- package/dist/cjs/identity/agent-identity.js +314 -0
- package/dist/cjs/identity/agent-identity.js.map +1 -0
- package/dist/cjs/identity/documents.js +212 -0
- package/dist/cjs/identity/documents.js.map +1 -0
- package/dist/cjs/identity/entity-card.js +128 -0
- package/dist/cjs/identity/entity-card.js.map +1 -0
- package/dist/cjs/identity/index.js +31 -0
- package/dist/cjs/identity/index.js.map +1 -0
- package/dist/cjs/identity/resolve.js +122 -0
- package/dist/cjs/identity/resolve.js.map +1 -0
- package/dist/cjs/identity/schemas.js +88 -0
- package/dist/cjs/identity/schemas.js.map +1 -0
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/mcp-app/inline.js +2 -2
- package/dist/cjs/mcp-app/inline.js.map +1 -1
- package/dist/cjs/mcp-app/types.js +1 -1
- package/dist/cjs/popup/launcher.js +3 -3
- package/dist/cjs/react/index.js +141 -25
- package/dist/cjs/react/index.js.map +1 -1
- package/dist/cjs/templates/index.js +1 -1
- package/dist/cjs/types/index.js +1 -1
- package/dist/components/consent-agent-header.d.ts +3 -1
- package/dist/components/consent-agent-header.d.ts.map +1 -1
- package/dist/components/consent-agent-header.js +15 -9
- package/dist/components/consent-agent-header.js.map +1 -1
- package/dist/components/consent-capabilities-screen.d.ts +13 -3
- package/dist/components/consent-capabilities-screen.d.ts.map +1 -1
- package/dist/components/consent-capabilities-screen.js +40 -78
- package/dist/components/consent-capabilities-screen.js.map +1 -1
- package/dist/components/consent-headline.d.ts +42 -0
- package/dist/components/consent-headline.d.ts.map +1 -0
- package/dist/components/consent-headline.js +135 -0
- package/dist/components/consent-headline.js.map +1 -0
- package/dist/components/consent-otp-input.d.ts +7 -2
- package/dist/components/consent-otp-input.d.ts.map +1 -1
- package/dist/components/consent-otp-input.js +35 -18
- package/dist/components/consent-otp-input.js.map +1 -1
- package/dist/components/index.d.ts +18 -17
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +18 -17
- package/dist/components/index.js.map +1 -1
- package/dist/components/mcp-consent.d.ts +16 -0
- package/dist/components/mcp-consent.d.ts.map +1 -1
- package/dist/components/mcp-consent.js +42 -1
- package/dist/components/mcp-consent.js.map +1 -1
- package/dist/consent.js +493 -100
- package/dist/consent.min.js +244 -232
- package/dist/copy/tokens.d.ts +16 -1
- package/dist/copy/tokens.d.ts.map +1 -1
- package/dist/copy/tokens.js +16 -1
- package/dist/copy/tokens.js.map +1 -1
- package/dist/identity/agent-identity.d.ts +199 -0
- package/dist/identity/agent-identity.d.ts.map +1 -0
- package/dist/identity/agent-identity.js +305 -0
- package/dist/identity/agent-identity.js.map +1 -0
- package/dist/identity/documents.d.ts +63 -0
- package/dist/identity/documents.d.ts.map +1 -0
- package/dist/identity/documents.js +206 -0
- package/dist/identity/documents.js.map +1 -0
- package/dist/identity/entity-card.d.ts +80 -0
- package/dist/identity/entity-card.d.ts.map +1 -0
- package/dist/identity/entity-card.js +119 -0
- package/dist/identity/entity-card.js.map +1 -0
- package/dist/identity/index.d.ts +15 -0
- package/dist/identity/index.d.ts.map +1 -0
- package/dist/identity/index.js +15 -0
- package/dist/identity/index.js.map +1 -0
- package/dist/identity/resolve.d.ts +31 -0
- package/dist/identity/resolve.d.ts.map +1 -0
- package/dist/identity/resolve.js +119 -0
- package/dist/identity/resolve.js.map +1 -0
- package/dist/identity/schemas.d.ts +404 -0
- package/dist/identity/schemas.d.ts.map +1 -0
- package/dist/identity/schemas.js +84 -0
- package/dist/identity/schemas.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/kya-os/index.d.ts +55 -0
- package/dist/kya-os/index.d.ts.map +1 -0
- package/dist/kya-os/index.js +235 -0
- package/dist/kya-os/index.js.map +1 -0
- package/dist/mcp-app/inline.d.ts.map +1 -1
- package/dist/mcp-app/inline.js +2 -2
- package/dist/mcp-app/inline.js.map +1 -1
- package/dist/mcp-app/types.d.ts +1 -1
- package/dist/mcp-app/types.js +1 -1
- package/dist/popup/launcher.d.ts +3 -3
- package/dist/popup/launcher.js +3 -3
- package/dist/react/index.d.ts +108 -22
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +151 -35
- package/dist/react/index.js.map +1 -1
- package/dist/templates/index.d.ts +1 -1
- package/dist/templates/index.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +1 -1
- package/package.json +41 -6
package/dist/copy/tokens.d.ts
CHANGED
|
@@ -40,7 +40,22 @@ export declare const CONSENT_COPY_TOKENS: {
|
|
|
40
40
|
* names the client, it does not verify it.
|
|
41
41
|
*/
|
|
42
42
|
readonly domainPillPrefix: "Identified by";
|
|
43
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* The meta line under the agent's name is built from the parts that are
|
|
45
|
+
* known, joined by `metaSeparator`: an unknown vendor or surface is left
|
|
46
|
+
* out rather than filled with a placeholder.
|
|
47
|
+
*
|
|
48
|
+
* `{Vendor}` → vendor name.
|
|
49
|
+
*/
|
|
50
|
+
readonly madeBy: "Made by {Vendor}";
|
|
51
|
+
/** `{Surface}` → surface label, e.g. "Mac". */
|
|
52
|
+
readonly askingFrom: "Asking from your {Surface}";
|
|
53
|
+
readonly metaSeparator: " · ";
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated The header no longer uses this: it can't leave out an
|
|
56
|
+
* unknown vendor or surface. Use `madeBy`, `askingFrom` and
|
|
57
|
+
* `metaSeparator`.
|
|
58
|
+
*/
|
|
44
59
|
readonly metaTemplate: "Made by {Vendor} · Asking from your {Surface} · {Connected}";
|
|
45
60
|
readonly connectedJustNow: "Connected just now";
|
|
46
61
|
/** `{Minutes}` → minutes since connection. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/copy/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,mBAAmB;;QAE5B,oCAAoC;;QAEpC,iEAAiE;;;;QAIjE;;;;WAIG;;;;;QAKH,sCAAsC;;;;;;QAOtC;;;;WAIG;;QAEH
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../../src/copy/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,eAAO,MAAM,mBAAmB;;QAE5B,oCAAoC;;QAEpC,iEAAiE;;;;QAIjE;;;;WAIG;;;;;QAKH,sCAAsC;;;;;;QAOtC;;;;WAIG;;QAEH;;;;;;WAMG;;QAEH,+CAA+C;;;QAG/C;;;;WAIG;;;QAGH,8CAA8C;;;;QAI9C,kEAAkE;;;QAGlE,sCAAsC;;;;;;QAMtC,4CAA4C;;QAE5C,uDAAuD;;QAEvD,yDAAyD;;;;QAIzD;;;WAGG;;QAGH,8CAA8C;;QAG9C,sEAAsE;;QAGtE;;;WAGG;;;;QAKH,2DAA2D;;QAE3D,0BAA0B;;QAE1B,6BAA6B;;QAE7B,4BAA4B;;;;QAI5B,mBAAmB;;QAEnB,kBAAkB;;;;IAIpB;;;OAGG;;;;;;;;;;;;;;;;;;;QAuBD,6EAA6E;;;;;;;;;;CAavE,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,OAAO,mBAAmB,CAAC;AAE3D;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,GAClD,MAAM,CAKR"}
|
package/dist/copy/tokens.js
CHANGED
|
@@ -40,7 +40,22 @@ export const CONSENT_COPY_TOKENS = {
|
|
|
40
40
|
* names the client, it does not verify it.
|
|
41
41
|
*/
|
|
42
42
|
domainPillPrefix: "Identified by",
|
|
43
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* The meta line under the agent's name is built from the parts that are
|
|
45
|
+
* known, joined by `metaSeparator`: an unknown vendor or surface is left
|
|
46
|
+
* out rather than filled with a placeholder.
|
|
47
|
+
*
|
|
48
|
+
* `{Vendor}` → vendor name.
|
|
49
|
+
*/
|
|
50
|
+
madeBy: "Made by {Vendor}",
|
|
51
|
+
/** `{Surface}` → surface label, e.g. "Mac". */
|
|
52
|
+
askingFrom: "Asking from your {Surface}",
|
|
53
|
+
metaSeparator: " · ",
|
|
54
|
+
/**
|
|
55
|
+
* @deprecated The header no longer uses this: it can't leave out an
|
|
56
|
+
* unknown vendor or surface. Use `madeBy`, `askingFrom` and
|
|
57
|
+
* `metaSeparator`.
|
|
58
|
+
*/
|
|
44
59
|
metaTemplate: "Made by {Vendor} · Asking from your {Surface} · {Connected}",
|
|
45
60
|
connectedJustNow: "Connected just now",
|
|
46
61
|
/** `{Minutes}` → minutes since connection. */
|
package/dist/copy/tokens.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/copy/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,OAAO,EAAE;QACP,oCAAoC;QACpC,iBAAiB,EAAE,oBAAoB;QACvC,iEAAiE;QACjE,YAAY,EAAE,iBAAiB;KAChC;IACD,QAAQ,EAAE;QACR;;;;WAIG;QACH,QAAQ,EAAE,gDAAgD;QAC1D,gBAAgB,EAAE,4CAA4C;KAC/D;IACD,OAAO,EAAE;QACP,sCAAsC;QACtC,QAAQ,EACN,kGAAkG;KACrG;IACD,SAAS,EAAE;QACT,YAAY,EAAE,UAAU;QACxB,cAAc,EAAE,YAAY;QAC5B;;;;WAIG;QACH,gBAAgB,EAAE,eAAe;QACjC,
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../../src/copy/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,OAAO,EAAE;QACP,oCAAoC;QACpC,iBAAiB,EAAE,oBAAoB;QACvC,iEAAiE;QACjE,YAAY,EAAE,iBAAiB;KAChC;IACD,QAAQ,EAAE;QACR;;;;WAIG;QACH,QAAQ,EAAE,gDAAgD;QAC1D,gBAAgB,EAAE,4CAA4C;KAC/D;IACD,OAAO,EAAE;QACP,sCAAsC;QACtC,QAAQ,EACN,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Q,EAAE;YACR,KAAK,EAAE,kBAAkB;YACzB,YAAY,EACV,+FAA+F;YACjG,MAAM,EAAE,kBAAkB;YAC1B,IAAI,EAAE,iBAAiB;SACxB;QACD,YAAY,EAAE;YACZ,KAAK,EAAE,kBAAkB;YACzB,YAAY,EACV,6EAA6E;YAC/E,MAAM,EAAE,kBAAkB;YAC1B,IAAI,EAAE,mBAAmB;SAC1B;QACD,QAAQ,EAAE,0CAA0C;QACpD,OAAO,EAAE,yBAAyB;QAClC,gBAAgB,EAAE,iCAAiC;QACnD,eAAe,EACb,6IAA6I;QAC/I,iBAAiB,EACf,uGAAuG;QACzG,6EAA6E;QAC7E,MAAM,EAAE;YACN,WAAW,EACT,mFAAmF;YACrF,aAAa,EACX,iFAAiF;YACnF,aAAa,EACX,sEAAsE;YACxE,QAAQ,EAAE,sCAAsC;YAChD,OAAO,EAAE,iDAAiD;YAC1D,OAAO,EAAE,sCAAsC;SAChD;KACF;CACO,CAAC;AAIX;;;;GAIG;AACH,MAAM,UAAU,WAAW,CACzB,QAAgB,EAChB,MAAmD;IAEnD,OAAO,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,GAAW,EAAE,EAAE;QAC3D,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;QAC1B,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An agent's identity for the consent screen: an Entity Card and what the
|
|
3
|
+
* host's verifier established about it.
|
|
4
|
+
*
|
|
5
|
+
* The card is a claim. The verification is the fact, and it is bound to the
|
|
6
|
+
* card: a `verified` result counts only when it names the card's own DID, and
|
|
7
|
+
* a `domain` result only when it names the card's own domain. Anything else
|
|
8
|
+
* reads as unverified, so a result can't be moved onto another card.
|
|
9
|
+
*
|
|
10
|
+
* Verification happens in the host, never in the component: the host reads
|
|
11
|
+
* the agent's document, runs a verifier (`createKyaOsAgentVerifier` from
|
|
12
|
+
* `@kya-os/consent/kya-os` for KYA-OS, or any `AgentIdentityVerifier`), and
|
|
13
|
+
* hands the screen the result (`resolveAgentIdentity`).
|
|
14
|
+
*
|
|
15
|
+
* No zod here: the components import this module, and the browser bundle
|
|
16
|
+
* stays free of it. Hosts validate with the schemas in `./schemas.ts`.
|
|
17
|
+
*
|
|
18
|
+
* @module identity/agent-identity
|
|
19
|
+
*/
|
|
20
|
+
import type { AgentMetadata } from "../types/capabilities.types.js";
|
|
21
|
+
import { type ConsentEntityCard } from "./entity-card.js";
|
|
22
|
+
import type { AgentDocument } from "./documents.js";
|
|
23
|
+
export declare const CONFORMANCE_LEVELS: readonly ["L1", "L2", "L3"];
|
|
24
|
+
/** A KYA-OS conformance level, as a verifier recomputes it. */
|
|
25
|
+
export type AgentConformanceLevel = (typeof CONFORMANCE_LEVELS)[number];
|
|
26
|
+
export declare const KEY_PROOF_METHODS: readonly ["holder-proof", "cimd-key"];
|
|
27
|
+
/**
|
|
28
|
+
* How the agent proved it holds the card's key for this request:
|
|
29
|
+
*
|
|
30
|
+
* - `holder-proof`: a per-request holder-of-key proof signed by a key the
|
|
31
|
+
* card's DID publishes.
|
|
32
|
+
* - `cimd-key`: the authorization server checked the client's
|
|
33
|
+
* `private_key_jwt` against the `jwks_uri` its CIMD document binds to the
|
|
34
|
+
* DID.
|
|
35
|
+
*/
|
|
36
|
+
export type AgentKeyProofMethod = (typeof KEY_PROOF_METHODS)[number];
|
|
37
|
+
/** The longest `reason` an `unverified` result carries. */
|
|
38
|
+
export declare const MAX_VERIFICATION_REASON = 300;
|
|
39
|
+
/** The longest DID an identity names, as in `AgentMetadata`. */
|
|
40
|
+
export declare const MAX_DID_LENGTH = 500;
|
|
41
|
+
interface VerificationMeta {
|
|
42
|
+
/** Names the verifier that produced the result. */
|
|
43
|
+
verifier?: string;
|
|
44
|
+
/** When the verifier checked, as an ISO timestamp. */
|
|
45
|
+
checkedAt?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* What a verifier established about a card.
|
|
49
|
+
*
|
|
50
|
+
* - `verified`: the card resolved from its DID's own home, its claims held,
|
|
51
|
+
* and the requester proved it holds the card's key. `did` must be the
|
|
52
|
+
* card's DID.
|
|
53
|
+
* - `domain`: the document came from the card's own domain, but nothing
|
|
54
|
+
* proved the requester holds the card's key. `domain` must be the card's
|
|
55
|
+
* domain.
|
|
56
|
+
* - `unverified`: neither.
|
|
57
|
+
*/
|
|
58
|
+
export type AgentIdentityVerification = (VerificationMeta & {
|
|
59
|
+
status: "verified";
|
|
60
|
+
did: string;
|
|
61
|
+
method: AgentKeyProofMethod;
|
|
62
|
+
conformanceLevel?: AgentConformanceLevel;
|
|
63
|
+
}) | (VerificationMeta & {
|
|
64
|
+
status: "domain";
|
|
65
|
+
domain: string;
|
|
66
|
+
}) | (VerificationMeta & {
|
|
67
|
+
status: "unverified";
|
|
68
|
+
reason?: string;
|
|
69
|
+
});
|
|
70
|
+
/** An agent's identity, as the consent screen takes it. */
|
|
71
|
+
export interface AgentIdentity {
|
|
72
|
+
/** The agent's Entity Card: what it claims to be. */
|
|
73
|
+
card: ConsentEntityCard;
|
|
74
|
+
/** What the host's verifier established. Absent means unverified. */
|
|
75
|
+
verification?: AgentIdentityVerification;
|
|
76
|
+
/** "Made by" label (e.g. "Anthropic"). */
|
|
77
|
+
vendor?: string;
|
|
78
|
+
/** Surface label (e.g. "Mac"). */
|
|
79
|
+
surfaceLabel?: string;
|
|
80
|
+
/** Logo URL for the agent tile. */
|
|
81
|
+
logoUrl?: string;
|
|
82
|
+
/** When the agent first connected, as an ISO timestamp. */
|
|
83
|
+
connectedAt?: string;
|
|
84
|
+
}
|
|
85
|
+
/** Thrown when an `AgentIdentity` doesn't validate. */
|
|
86
|
+
export declare class AgentIdentityError extends Error {
|
|
87
|
+
constructor(message: string);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Keep a verification only if it describes this card: a `verified` result
|
|
91
|
+
* must name the card's DID, a `domain` result the card's domain. Anything
|
|
92
|
+
* else becomes `unverified`, with the reason.
|
|
93
|
+
*/
|
|
94
|
+
export declare function bindVerification(card: ConsentEntityCard, verification: AgentIdentityVerification | undefined): AgentIdentityVerification;
|
|
95
|
+
/**
|
|
96
|
+
* The agent tile data for an identity, with the verification bound to the
|
|
97
|
+
* card. Feeds `<consent-agent-header>`, and works as the
|
|
98
|
+
* `RelationshipContext` for `isCappedAtProbe` and
|
|
99
|
+
* `compileCapabilitiesToCedar`, so the probe cap lifts only for an identity
|
|
100
|
+
* a verifier proved.
|
|
101
|
+
*
|
|
102
|
+
* Reads the identity the way the screen does (`readAgentIdentity`).
|
|
103
|
+
*
|
|
104
|
+
* @throws {AgentIdentityError} when the card or the verification is
|
|
105
|
+
* malformed.
|
|
106
|
+
*/
|
|
107
|
+
export declare function agentMetadataFromIdentity(identity: AgentIdentity): AgentMetadata;
|
|
108
|
+
/**
|
|
109
|
+
* An identity as the screen reads it, without zod.
|
|
110
|
+
*
|
|
111
|
+
* What decides the pill is checked strictly: the card's DID, type, name and
|
|
112
|
+
* CIMD coordinates, and the verification's shape. Any of those malformed
|
|
113
|
+
* throws, and the screen shows no tile. Display extras (vendor, surface,
|
|
114
|
+
* logo, connected time) are kept only when they are strings, and text is cut
|
|
115
|
+
* to fit the tile.
|
|
116
|
+
*
|
|
117
|
+
* Hosts check the whole identity, limits included, with `parseAgentIdentity`
|
|
118
|
+
* (or get a checked one from `resolveAgentIdentity`).
|
|
119
|
+
*
|
|
120
|
+
* @throws {AgentIdentityError}
|
|
121
|
+
*/
|
|
122
|
+
export declare function readAgentIdentity(value: unknown): AgentIdentity;
|
|
123
|
+
/** What the host knows about the request the agent's document came with. */
|
|
124
|
+
export interface AgentVerificationContext {
|
|
125
|
+
/** The per-request holder-of-key proof the agent sent. */
|
|
126
|
+
proof?: unknown;
|
|
127
|
+
/** The request that proof binds: its method and params. */
|
|
128
|
+
request?: {
|
|
129
|
+
method: string;
|
|
130
|
+
params?: unknown;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Set when the host's authorization server authenticated the client for
|
|
134
|
+
* this request with `private_key_jwt`: the client it authenticated and
|
|
135
|
+
* where it took the key from. A bare "the key checked out" can't be bound
|
|
136
|
+
* to a card, so the verifier needs both.
|
|
137
|
+
*/
|
|
138
|
+
cimdClientAuth?: CimdClientAuth;
|
|
139
|
+
/**
|
|
140
|
+
* The `https:` URL the host fetched the document from, such as a CIMD
|
|
141
|
+
* `client_id`. Binds the card to that domain when it is the card's own.
|
|
142
|
+
*/
|
|
143
|
+
fetchedFrom?: string;
|
|
144
|
+
}
|
|
145
|
+
/** A CIMD client the authorization server authenticated with `private_key_jwt`. */
|
|
146
|
+
export interface CimdClientAuth {
|
|
147
|
+
/** The `client_id` it authenticated. */
|
|
148
|
+
clientId: string;
|
|
149
|
+
/**
|
|
150
|
+
* The `jwks_uri` it took the client's key from, as written in the CIMD
|
|
151
|
+
* document it fetched from that `client_id`.
|
|
152
|
+
*/
|
|
153
|
+
jwksUri: string;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* What a verifier returns. A `verified` result vouches for a card, so it
|
|
157
|
+
* carries the card: the identity shows that card, and the name next to
|
|
158
|
+
* Verified is one the verifier checked.
|
|
159
|
+
*/
|
|
160
|
+
export type AgentVerifierResult = {
|
|
161
|
+
verification: Extract<AgentIdentityVerification, {
|
|
162
|
+
status: "verified";
|
|
163
|
+
}>;
|
|
164
|
+
/**
|
|
165
|
+
* The canonical card the verifier vouches for, naming the document's
|
|
166
|
+
* DID. Without a valid one, `resolveAgentIdentity` turns the result
|
|
167
|
+
* into `unverified`.
|
|
168
|
+
*/
|
|
169
|
+
card: ConsentEntityCard;
|
|
170
|
+
} | {
|
|
171
|
+
verification: Exclude<AgentIdentityVerification, {
|
|
172
|
+
status: "verified";
|
|
173
|
+
}>;
|
|
174
|
+
/**
|
|
175
|
+
* The canonical card the verifier resolved, when it resolved one. It
|
|
176
|
+
* replaces the document's card only if both name the same DID.
|
|
177
|
+
*/
|
|
178
|
+
card?: ConsentEntityCard;
|
|
179
|
+
};
|
|
180
|
+
/** Checks an agent document. Runs in the host, never in the component. */
|
|
181
|
+
export interface AgentIdentityVerifier {
|
|
182
|
+
verify(document: AgentDocument, context: AgentVerificationContext): Promise<AgentVerifierResult>;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* `domain` when `fetchedFrom` is an `https:` URL on the card's own domain,
|
|
186
|
+
* else `unverified`.
|
|
187
|
+
*/
|
|
188
|
+
export declare function domainVerification(card: ConsentEntityCard, fetchedFrom: string | undefined): Exclude<AgentIdentityVerification, {
|
|
189
|
+
status: "verified";
|
|
190
|
+
}>;
|
|
191
|
+
/**
|
|
192
|
+
* The verifier for hosts with no KYA-OS: binds a card to the domain the host
|
|
193
|
+
* fetched its document from, and never says verified.
|
|
194
|
+
*/
|
|
195
|
+
export declare const domainVerifier: AgentIdentityVerifier;
|
|
196
|
+
/** `reason`, cut to fit an `unverified` result. */
|
|
197
|
+
export declare function limitReason(reason: string): string;
|
|
198
|
+
export {};
|
|
199
|
+
//# sourceMappingURL=agent-identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-identity.d.ts","sourceRoot":"","sources":["../../src/identity/agent-identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EACV,aAAa,EAEd,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAML,KAAK,iBAAiB,EACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,eAAO,MAAM,kBAAkB,6BAA8B,CAAC;AAE9D,+DAA+D;AAC/D,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,kBAAkB,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Aa,EACvB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,mBAAmB,CAAC,CAAC;CACjC;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,iBAAiB,EACvB,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B,OAAO,CAAC,yBAAyB,EAAE;IAAE,MAAM,EAAE,UAAU,CAAA;CAAE,CAAC,CAiB5D;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,qBAS5B,CAAC;AAIF,mDAAmD;AACnD,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAElD"}
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An agent's identity for the consent screen: an Entity Card and what the
|
|
3
|
+
* host's verifier established about it.
|
|
4
|
+
*
|
|
5
|
+
* The card is a claim. The verification is the fact, and it is bound to the
|
|
6
|
+
* card: a `verified` result counts only when it names the card's own DID, and
|
|
7
|
+
* a `domain` result only when it names the card's own domain. Anything else
|
|
8
|
+
* reads as unverified, so a result can't be moved onto another card.
|
|
9
|
+
*
|
|
10
|
+
* Verification happens in the host, never in the component: the host reads
|
|
11
|
+
* the agent's document, runs a verifier (`createKyaOsAgentVerifier` from
|
|
12
|
+
* `@kya-os/consent/kya-os` for KYA-OS, or any `AgentIdentityVerifier`), and
|
|
13
|
+
* hands the screen the result (`resolveAgentIdentity`).
|
|
14
|
+
*
|
|
15
|
+
* No zod here: the components import this module, and the browser bundle
|
|
16
|
+
* stays free of it. Hosts validate with the schemas in `./schemas.ts`.
|
|
17
|
+
*
|
|
18
|
+
* @module identity/agent-identity
|
|
19
|
+
*/
|
|
20
|
+
import { ENTITY_DID_PATTERN, ENTITY_TYPES, cardDomain, httpsHost, sameDid, } from "./entity-card.js";
|
|
21
|
+
export const CONFORMANCE_LEVELS = ["L1", "L2", "L3"];
|
|
22
|
+
export const KEY_PROOF_METHODS = ["holder-proof", "cimd-key"];
|
|
23
|
+
/** The longest `reason` an `unverified` result carries. */
|
|
24
|
+
export const MAX_VERIFICATION_REASON = 300;
|
|
25
|
+
/** The longest DID an identity names, as in `AgentMetadata`. */
|
|
26
|
+
export const MAX_DID_LENGTH = 500;
|
|
27
|
+
/** The tile's text limits, as in `AgentMetadata`. */
|
|
28
|
+
const TILE_LIMITS = { name: 80, vendor: 80, surfaceLabel: 40 };
|
|
29
|
+
/** Thrown when an `AgentIdentity` doesn't validate. */
|
|
30
|
+
export class AgentIdentityError extends Error {
|
|
31
|
+
constructor(message) {
|
|
32
|
+
super(message);
|
|
33
|
+
this.name = "AgentIdentityError";
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Keep a verification only if it describes this card: a `verified` result
|
|
38
|
+
* must name the card's DID, a `domain` result the card's domain. Anything
|
|
39
|
+
* else becomes `unverified`, with the reason.
|
|
40
|
+
*/
|
|
41
|
+
export function bindVerification(card, verification) {
|
|
42
|
+
if (verification === undefined) {
|
|
43
|
+
return { status: "unverified", reason: "not_checked" };
|
|
44
|
+
}
|
|
45
|
+
const meta = verificationMeta(verification);
|
|
46
|
+
if (verification.status === "verified") {
|
|
47
|
+
if (sameDid(verification.did, card.id))
|
|
48
|
+
return verification;
|
|
49
|
+
return {
|
|
50
|
+
status: "unverified",
|
|
51
|
+
reason: limitReason(`verified ${verification.did}, not this card's ${card.id}`),
|
|
52
|
+
...meta,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (verification.status === "domain") {
|
|
56
|
+
const domain = cardDomain(card);
|
|
57
|
+
if (domain !== null &&
|
|
58
|
+
verification.domain.trim().toLowerCase() === domain) {
|
|
59
|
+
return { status: "domain", domain, ...meta };
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
status: "unverified",
|
|
63
|
+
reason: limitReason(`${verification.domain} is not this card's domain`),
|
|
64
|
+
...meta,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return verification;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The agent tile data for an identity, with the verification bound to the
|
|
71
|
+
* card. Feeds `<consent-agent-header>`, and works as the
|
|
72
|
+
* `RelationshipContext` for `isCappedAtProbe` and
|
|
73
|
+
* `compileCapabilitiesToCedar`, so the probe cap lifts only for an identity
|
|
74
|
+
* a verifier proved.
|
|
75
|
+
*
|
|
76
|
+
* Reads the identity the way the screen does (`readAgentIdentity`).
|
|
77
|
+
*
|
|
78
|
+
* @throws {AgentIdentityError} when the card or the verification is
|
|
79
|
+
* malformed.
|
|
80
|
+
*/
|
|
81
|
+
export function agentMetadataFromIdentity(identity) {
|
|
82
|
+
const read = readAgentIdentity(identity);
|
|
83
|
+
const bound = bindVerification(read.card, read.verification);
|
|
84
|
+
const verification = bound.status;
|
|
85
|
+
const metadata = {
|
|
86
|
+
name: read.card.name,
|
|
87
|
+
did: read.card.id,
|
|
88
|
+
verification,
|
|
89
|
+
};
|
|
90
|
+
if (bound.status === "domain")
|
|
91
|
+
metadata.domain = bound.domain;
|
|
92
|
+
if (read.vendor !== undefined)
|
|
93
|
+
metadata.vendor = read.vendor;
|
|
94
|
+
if (read.surfaceLabel !== undefined)
|
|
95
|
+
metadata.surfaceLabel = read.surfaceLabel;
|
|
96
|
+
if (read.logoUrl !== undefined)
|
|
97
|
+
metadata.logoUrl = read.logoUrl;
|
|
98
|
+
if (read.connectedAt !== undefined)
|
|
99
|
+
metadata.connectedAt = read.connectedAt;
|
|
100
|
+
return metadata;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* An identity as the screen reads it, without zod.
|
|
104
|
+
*
|
|
105
|
+
* What decides the pill is checked strictly: the card's DID, type, name and
|
|
106
|
+
* CIMD coordinates, and the verification's shape. Any of those malformed
|
|
107
|
+
* throws, and the screen shows no tile. Display extras (vendor, surface,
|
|
108
|
+
* logo, connected time) are kept only when they are strings, and text is cut
|
|
109
|
+
* to fit the tile.
|
|
110
|
+
*
|
|
111
|
+
* Hosts check the whole identity, limits included, with `parseAgentIdentity`
|
|
112
|
+
* (or get a checked one from `resolveAgentIdentity`).
|
|
113
|
+
*
|
|
114
|
+
* @throws {AgentIdentityError}
|
|
115
|
+
*/
|
|
116
|
+
export function readAgentIdentity(value) {
|
|
117
|
+
if (!isRecord(value))
|
|
118
|
+
fail("", "An agent identity is an object");
|
|
119
|
+
const card = readCard(value.card);
|
|
120
|
+
const identity = { card };
|
|
121
|
+
if (value.verification !== undefined) {
|
|
122
|
+
identity.verification = readVerification(value.verification);
|
|
123
|
+
}
|
|
124
|
+
if (typeof value.vendor === "string") {
|
|
125
|
+
identity.vendor = fit(value.vendor, TILE_LIMITS.vendor);
|
|
126
|
+
}
|
|
127
|
+
if (typeof value.surfaceLabel === "string") {
|
|
128
|
+
identity.surfaceLabel = fit(value.surfaceLabel, TILE_LIMITS.surfaceLabel);
|
|
129
|
+
}
|
|
130
|
+
if (typeof value.logoUrl === "string" && isUrl(value.logoUrl)) {
|
|
131
|
+
identity.logoUrl = value.logoUrl;
|
|
132
|
+
}
|
|
133
|
+
if (typeof value.connectedAt === "string") {
|
|
134
|
+
identity.connectedAt = value.connectedAt;
|
|
135
|
+
}
|
|
136
|
+
return identity;
|
|
137
|
+
}
|
|
138
|
+
function readCard(value) {
|
|
139
|
+
if (!isRecord(value))
|
|
140
|
+
fail("card", "Required");
|
|
141
|
+
if (!isEntityDid(value.id)) {
|
|
142
|
+
fail("card.id", `Must be a did:key or did:web DID of at most ${MAX_DID_LENGTH} characters`);
|
|
143
|
+
}
|
|
144
|
+
if (!ENTITY_TYPES.includes(value.entityType)) {
|
|
145
|
+
fail("card.entityType", `Must be one of ${ENTITY_TYPES.join(", ")}`);
|
|
146
|
+
}
|
|
147
|
+
if (typeof value.name !== "string" || value.name.trim() === "") {
|
|
148
|
+
fail("card.name", "Required");
|
|
149
|
+
}
|
|
150
|
+
if (value.cimd !== undefined) {
|
|
151
|
+
const cimd = value.cimd;
|
|
152
|
+
if (!isRecord(cimd) ||
|
|
153
|
+
!isFilled(cimd.clientId) ||
|
|
154
|
+
!isFilled(cimd.jwksUri)) {
|
|
155
|
+
fail("card.cimd", "Must name a clientId and a jwksUri");
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
// The card keeps every field it came with; only the name is cut to fit.
|
|
159
|
+
return {
|
|
160
|
+
...value,
|
|
161
|
+
name: fit(value.name, TILE_LIMITS.name),
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function readVerification(value) {
|
|
165
|
+
if (!isRecord(value))
|
|
166
|
+
fail("verification", "Must be an object");
|
|
167
|
+
const meta = {};
|
|
168
|
+
if (value.verifier !== undefined) {
|
|
169
|
+
if (!isFilled(value.verifier))
|
|
170
|
+
fail("verification.verifier", "Must be a string");
|
|
171
|
+
meta.verifier = value.verifier;
|
|
172
|
+
}
|
|
173
|
+
if (value.checkedAt !== undefined) {
|
|
174
|
+
if (!isFilled(value.checkedAt))
|
|
175
|
+
fail("verification.checkedAt", "Must be a string");
|
|
176
|
+
meta.checkedAt = value.checkedAt;
|
|
177
|
+
}
|
|
178
|
+
switch (value.status) {
|
|
179
|
+
case "verified": {
|
|
180
|
+
if (!isEntityDid(value.did)) {
|
|
181
|
+
fail("verification.did", "Must be a did:key or did:web DID");
|
|
182
|
+
}
|
|
183
|
+
if (!KEY_PROOF_METHODS.includes(value.method)) {
|
|
184
|
+
fail("verification.method", `Must be one of ${KEY_PROOF_METHODS.join(", ")}`);
|
|
185
|
+
}
|
|
186
|
+
const level = value.conformanceLevel;
|
|
187
|
+
if (level !== undefined &&
|
|
188
|
+
!CONFORMANCE_LEVELS.includes(level)) {
|
|
189
|
+
fail("verification.conformanceLevel", `Must be one of ${CONFORMANCE_LEVELS.join(", ")}`);
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
status: "verified",
|
|
193
|
+
did: value.did,
|
|
194
|
+
method: value.method,
|
|
195
|
+
...(level !== undefined
|
|
196
|
+
? { conformanceLevel: level }
|
|
197
|
+
: {}),
|
|
198
|
+
...meta,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
case "domain":
|
|
202
|
+
if (!isFilled(value.domain))
|
|
203
|
+
fail("verification.domain", "Required");
|
|
204
|
+
return { status: "domain", domain: value.domain, ...meta };
|
|
205
|
+
case "unverified":
|
|
206
|
+
if (value.reason !== undefined && typeof value.reason !== "string") {
|
|
207
|
+
fail("verification.reason", "Must be a string");
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
status: "unverified",
|
|
211
|
+
...(typeof value.reason === "string"
|
|
212
|
+
? { reason: limitReason(value.reason) }
|
|
213
|
+
: {}),
|
|
214
|
+
...meta,
|
|
215
|
+
};
|
|
216
|
+
default:
|
|
217
|
+
return fail("verification.status", "Must be verified, domain or unverified");
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* `domain` when `fetchedFrom` is an `https:` URL on the card's own domain,
|
|
222
|
+
* else `unverified`.
|
|
223
|
+
*/
|
|
224
|
+
export function domainVerification(card, fetchedFrom) {
|
|
225
|
+
const domain = cardDomain(card);
|
|
226
|
+
if (domain === null) {
|
|
227
|
+
return { status: "unverified", reason: "the card has no domain" };
|
|
228
|
+
}
|
|
229
|
+
if (fetchedFrom === undefined) {
|
|
230
|
+
return { status: "unverified", reason: "no fetchedFrom to bind a domain" };
|
|
231
|
+
}
|
|
232
|
+
if (httpsHost(fetchedFrom) !== domain) {
|
|
233
|
+
return {
|
|
234
|
+
status: "unverified",
|
|
235
|
+
reason: limitReason(`fetched from ${fetchedFrom}, not the card's domain ${domain}`),
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
return { status: "domain", domain };
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* The verifier for hosts with no KYA-OS: binds a card to the domain the host
|
|
242
|
+
* fetched its document from, and never says verified.
|
|
243
|
+
*/
|
|
244
|
+
export const domainVerifier = {
|
|
245
|
+
async verify(document, context) {
|
|
246
|
+
return {
|
|
247
|
+
verification: {
|
|
248
|
+
...domainVerification(document.card, context.fetchedFrom),
|
|
249
|
+
verifier: "domain",
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
},
|
|
253
|
+
};
|
|
254
|
+
/* ------------------------------------------------------------ helpers */
|
|
255
|
+
/** `reason`, cut to fit an `unverified` result. */
|
|
256
|
+
export function limitReason(reason) {
|
|
257
|
+
return fit(reason, MAX_VERIFICATION_REASON);
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* `text` in at most `max` UTF-16 code units (the length zod checks), ending
|
|
261
|
+
* in an ellipsis when cut, and never splitting a character.
|
|
262
|
+
*/
|
|
263
|
+
function fit(text, max) {
|
|
264
|
+
if (text.length <= max)
|
|
265
|
+
return text;
|
|
266
|
+
let cut = "";
|
|
267
|
+
for (const char of text) {
|
|
268
|
+
if (cut.length + char.length + 1 > max)
|
|
269
|
+
break;
|
|
270
|
+
cut += char;
|
|
271
|
+
}
|
|
272
|
+
return `${cut}…`;
|
|
273
|
+
}
|
|
274
|
+
function fail(path, message) {
|
|
275
|
+
throw new AgentIdentityError(`agentIdentity: ${path ? `${path}: ` : ""}${message}`);
|
|
276
|
+
}
|
|
277
|
+
function isEntityDid(value) {
|
|
278
|
+
return (typeof value === "string" &&
|
|
279
|
+
value.length <= MAX_DID_LENGTH &&
|
|
280
|
+
ENTITY_DID_PATTERN.test(value));
|
|
281
|
+
}
|
|
282
|
+
function isFilled(value) {
|
|
283
|
+
return typeof value === "string" && value.length > 0;
|
|
284
|
+
}
|
|
285
|
+
function isUrl(value) {
|
|
286
|
+
try {
|
|
287
|
+
new URL(value);
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
catch {
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function isRecord(value) {
|
|
295
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
296
|
+
}
|
|
297
|
+
function verificationMeta(verification) {
|
|
298
|
+
const meta = {};
|
|
299
|
+
if (verification.verifier !== undefined)
|
|
300
|
+
meta.verifier = verification.verifier;
|
|
301
|
+
if (verification.checkedAt !== undefined)
|
|
302
|
+
meta.checkedAt = verification.checkedAt;
|
|
303
|
+
return meta;
|
|
304
|
+
}
|
|
305
|
+
//# sourceMappingURL=agent-identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-identity.js","sourceRoot":"","sources":["../../src/identity/agent-identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,UAAU,EACV,SAAS,EACT,OAAO,GAER,MAAM,kBAAkB,CAAC;AAG1B,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAC;AAK9D,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,cAAc,EAAE,UAAU,CAAU,CAAC;AAavE,2DAA2D;AAC3D,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAE3C,gEAAgE;AAChE,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAC;AAElC,qDAAqD;AACrD,MAAM,WAAW,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAW,CAAC;AA8CxE,uDAAuD;AACvD,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAuB,EACvB,YAAmD;IAEnD,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;IACzD,CAAC;IACD,MAAM,IAAI,GAAG,gBAAgB,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,KAAK,SAAS;QACrC,IAAI,CAAC,QAAQ,GAAG,YAAY,CAAC,QAAQ,CAAC;IACxC,IAAI,YAAY,CAAC,SAAS,KAAK,SAAS;QACtC,IAAI,CAAC,SAAS,GAAG,YAAY,CAAC,SAAS,CAAC;IAC1C,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read the documents agents already publish into the Entity Card shape.
|
|
3
|
+
*
|
|
4
|
+
* Four kinds are recognized:
|
|
5
|
+
*
|
|
6
|
+
* - a KYA-OS Entity Card;
|
|
7
|
+
* - CIMD client metadata (the OAuth `client_id` document), read the way
|
|
8
|
+
* `cardFromClientMetadata` in `@kya-os/mcp/card` reads it;
|
|
9
|
+
* - an A2A AgentCard carrying the KYA-OS entity-card extension, or that
|
|
10
|
+
* extension on its own;
|
|
11
|
+
* - a NANDA AgentFacts document whose `id` is a DID.
|
|
12
|
+
*
|
|
13
|
+
* Reading is not verifying. The card that comes back is what the document
|
|
14
|
+
* claims; `ref` says where a verifier finds the canonical card, the same
|
|
15
|
+
* reference forms `resolveCard` in `@kya-os/mcp/card` takes.
|
|
16
|
+
*
|
|
17
|
+
* @module identity/documents
|
|
18
|
+
*/
|
|
19
|
+
import { type ConsentEntityCard } from "./entity-card.js";
|
|
20
|
+
/** The URI of the KYA-OS entity-card extension on an A2A AgentCard. */
|
|
21
|
+
export declare const A2A_ENTITY_CARD_EXTENSION_URI = "https://kya-os.org/a2a/ext/entity-card/v1";
|
|
22
|
+
/** The JSON-LD context KYA-OS terms use inside a NANDA AgentFacts document. */
|
|
23
|
+
export declare const AGENTFACTS_KYA_CONTEXT = "https://kya-os.org/ns/agentfacts/v1#";
|
|
24
|
+
/** The `_meta` key a CIMD document declares its DID under. */
|
|
25
|
+
export declare const KYA_OS_DID_META_KEY = "org.kya-os/did";
|
|
26
|
+
export type AgentDocumentKind = "entity-card" | "cimd" | "a2a" | "agentfacts";
|
|
27
|
+
/**
|
|
28
|
+
* Where a verifier fetches the canonical card: by its `did:web`, or from the
|
|
29
|
+
* card URL an A2A extension names.
|
|
30
|
+
*/
|
|
31
|
+
export type AgentCardRef = {
|
|
32
|
+
did: string;
|
|
33
|
+
} | {
|
|
34
|
+
cardUrl: string;
|
|
35
|
+
};
|
|
36
|
+
export interface AgentDocument {
|
|
37
|
+
kind: AgentDocumentKind;
|
|
38
|
+
/** What the document claims, in the Entity Card shape. Not yet verified. */
|
|
39
|
+
card: ConsentEntityCard;
|
|
40
|
+
/**
|
|
41
|
+
* Where the canonical card lives. Absent for a `did:key` with no card URL:
|
|
42
|
+
* a `did:key` has no home to resolve.
|
|
43
|
+
*/
|
|
44
|
+
ref?: AgentCardRef;
|
|
45
|
+
}
|
|
46
|
+
export type AgentDocumentErrorCode = "unrecognized" | "no_did" | "invalid";
|
|
47
|
+
/** Thrown when a document can't be read into an Entity Card. */
|
|
48
|
+
export declare class AgentDocumentError extends Error {
|
|
49
|
+
readonly code: AgentDocumentErrorCode;
|
|
50
|
+
constructor(code: AgentDocumentErrorCode, message: string);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Read an agent document into the Entity Card shape.
|
|
54
|
+
*
|
|
55
|
+
* @throws {AgentDocumentError} `unrecognized` for anything that isn't one of
|
|
56
|
+
* the four kinds, `no_did` for a document that names no DID (an A2A
|
|
57
|
+
* AgentCard without the KYA-OS extension, AgentFacts whose `id` isn't a
|
|
58
|
+
* DID), and `invalid` for one that breaks its own rules.
|
|
59
|
+
*/
|
|
60
|
+
export declare function readAgentDocument(doc: unknown): AgentDocument;
|
|
61
|
+
/** The `did:web` an `https:` CIMD `client_id` names, as `@kya-os/mcp` mints it. */
|
|
62
|
+
export declare function didFromClientId(clientId: string): string;
|
|
63
|
+
//# sourceMappingURL=documents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../../src/identity/documents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAKL,KAAK,iBAAiB,EAEvB,MAAM,kBAAkB,CAAC;AAE1B,uEAAuE;AACvE,eAAO,MAAM,6BAA6B,8CACG,CAAC;AAE9C,+EAA+E;AAC/E,eAAO,MAAM,sBAAsB,yCAAyC,CAAC;AAE7E,8DAA8D;AAC9D,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AAEpD,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG,MAAM,GAAG,KAAK,GAAG,YAAY,CAAC;AAE9E;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEjE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,iBAAiB,CAAC;IACxB,4EAA4E;IAC5E,IAAI,EAAE,iBAAiB,CAAC;IACxB;;;OAGG;IACH,GAAG,CAAC,EAAE,YAAY,CAAC;CACpB;AAED,MAAM,MAAM,sBAAsB,GAAG,cAAc,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE3E,gEAAgE;AAChE,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAC;gBAE1B,IAAI,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM;CAK1D;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,aAAa,CAkB7D;AAED,mFAAmF;AACnF,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAsBxD"}
|