gbz185-sdk 0.1.0
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/CHANGELOG.md +12 -0
- package/LICENSE +21 -0
- package/README.md +192 -0
- package/dist/agent-maintenance.d.ts +35 -0
- package/dist/agent-maintenance.d.ts.map +1 -0
- package/dist/agent-maintenance.js +107 -0
- package/dist/agent-maintenance.js.map +1 -0
- package/dist/authorization.d.ts +32 -0
- package/dist/authorization.d.ts.map +1 -0
- package/dist/authorization.js +37 -0
- package/dist/authorization.js.map +1 -0
- package/dist/client.d.ts +39 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +70 -0
- package/dist/client.js.map +1 -0
- package/dist/conformance.d.ts +11 -0
- package/dist/conformance.d.ts.map +1 -0
- package/dist/conformance.js +195 -0
- package/dist/conformance.js.map +1 -0
- package/dist/credentials.d.ts +124 -0
- package/dist/credentials.d.ts.map +1 -0
- package/dist/credentials.js +209 -0
- package/dist/credentials.js.map +1 -0
- package/dist/description-registry.d.ts +66 -0
- package/dist/description-registry.d.ts.map +1 -0
- package/dist/description-registry.js +137 -0
- package/dist/description-registry.js.map +1 -0
- package/dist/discovery.d.ts +14 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +105 -0
- package/dist/discovery.js.map +1 -0
- package/dist/factory.d.ts +34 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/factory.js +98 -0
- package/dist/factory.js.map +1 -0
- package/dist/functional-architecture.d.ts +18 -0
- package/dist/functional-architecture.d.ts.map +1 -0
- package/dist/functional-architecture.js +159 -0
- package/dist/functional-architecture.js.map +1 -0
- package/dist/identity-code.d.ts +8 -0
- package/dist/identity-code.d.ts.map +1 -0
- package/dist/identity-code.js +76 -0
- package/dist/identity-code.js.map +1 -0
- package/dist/identity-registry.d.ts +68 -0
- package/dist/identity-registry.d.ts.map +1 -0
- package/dist/identity-registry.js +155 -0
- package/dist/identity-registry.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/interaction.d.ts +41 -0
- package/dist/interaction.d.ts.map +1 -0
- package/dist/interaction.js +95 -0
- package/dist/interaction.js.map +1 -0
- package/dist/message-distribution.d.ts +18 -0
- package/dist/message-distribution.d.ts.map +1 -0
- package/dist/message-distribution.js +35 -0
- package/dist/message-distribution.js.map +1 -0
- package/dist/tool-access.d.ts +16 -0
- package/dist/tool-access.d.ts.map +1 -0
- package/dist/tool-access.js +30 -0
- package/dist/tool-access.js.map +1 -0
- package/dist/tools.d.ts +18 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +77 -0
- package/dist/tools.js.map +1 -0
- package/dist/transport.d.ts +21 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +36 -0
- package/dist/transport.js.map +1 -0
- package/dist/types.d.ts +165 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/validation.d.ts +12 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +94 -0
- package/dist/validation.js.map +1 -0
- package/docs/API_REFERENCE.md +116 -0
- package/docs/CONFORMANCE.md +96 -0
- package/docs/GITHUB_PAGES.md +54 -0
- package/docs/NPM_RELEASE.md +107 -0
- package/docs/SDK_GUIDE.md +439 -0
- package/examples/calendar.ts +105 -0
- package/package.json +60 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
export const GBZ185_CONFORMANCE_MATRIX = [
|
|
2
|
+
{
|
|
3
|
+
part: "GB/Z 185.1",
|
|
4
|
+
clause: "5",
|
|
5
|
+
topic: "Concept model domains: user, agent, management service, interconnection service, resource access",
|
|
6
|
+
status: "covered",
|
|
7
|
+
sdkSurface: ["createAgentInterconnectRuntime", "AgentInterconnectRuntime", "GBZ185_FUNCTIONS"],
|
|
8
|
+
notes: "Runtime wires all standard domains except user UI, which is represented by callers using the SDK."
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
part: "GB/Z 185.1",
|
|
12
|
+
clause: "6.2",
|
|
13
|
+
topic: "Functional reference architecture function set",
|
|
14
|
+
status: "covered",
|
|
15
|
+
sdkSurface: ["GBZ185_FUNCTIONS"],
|
|
16
|
+
notes: "All 12 function domains listed in the standard are represented by exported runtime surfaces or interfaces."
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
part: "GB/Z 185.1",
|
|
20
|
+
clause: "6.3",
|
|
21
|
+
topic: "FRAI-01 through FRAI-10 reference interfaces",
|
|
22
|
+
status: "covered",
|
|
23
|
+
sdkSurface: ["GBZ185_FRAI_INTERFACES"],
|
|
24
|
+
notes: "Machine-readable interface coverage map is exported and tested."
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
part: "GB/Z 185.2",
|
|
28
|
+
clause: "5.1-5.6",
|
|
29
|
+
topic: "Identity code OID structure, version, registration service provider, requester, custom serials",
|
|
30
|
+
status: "covered",
|
|
31
|
+
sdkSurface: ["formatIdentityCode", "parseIdentityCode", "validateIdentityCode", "validateIdentityCodeParts"],
|
|
32
|
+
notes: "Uses fixed OID prefix 1.2.156.3088 and current version 1; validates base36 node lengths."
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
part: "GB/Z 185.2",
|
|
36
|
+
clause: "6",
|
|
37
|
+
topic: "Identity code allocation and management rules",
|
|
38
|
+
status: "covered_by_reference_runtime",
|
|
39
|
+
sdkSurface: ["IdentityRegistryRuntime", "AgentIdentityMaintenance"],
|
|
40
|
+
notes: "Reference runtime allocates and preserves identity codes; external registries can replace the store."
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
part: "GB/Z 185.2",
|
|
44
|
+
clause: "Appendix B",
|
|
45
|
+
topic: "International agent identity-code acquisition modes",
|
|
46
|
+
status: "extension_point",
|
|
47
|
+
sdkSurface: ["IdentityAccountStore", "IdentityRegistryRuntime"],
|
|
48
|
+
notes: "The standard describes governance paths; the SDK leaves authority approval and cross-border registry integration to adapters."
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
part: "GB/Z 185.3",
|
|
52
|
+
clause: "5",
|
|
53
|
+
topic: "Identity management framework roles and flows",
|
|
54
|
+
status: "covered",
|
|
55
|
+
sdkSurface: ["IdentityRegistryRuntime", "CredentialIssuer", "CredentialVerifier", "InterconnectionAuthorizationRuntime"],
|
|
56
|
+
notes: "Delegator, agent, issuer, verifier, relying-party flow concepts are represented in types and runtimes."
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
part: "GB/Z 185.3",
|
|
60
|
+
clause: "6",
|
|
61
|
+
topic: "Identity registration and evidence verification",
|
|
62
|
+
status: "covered_by_reference_runtime",
|
|
63
|
+
sdkSurface: ["IdentityRegistryRuntime.register", "RegisterIdentityInput.evidence"],
|
|
64
|
+
notes: "Evidence is accepted and stored; actual legal/risk verification policies are application adapters."
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
part: "GB/Z 185.3",
|
|
68
|
+
clause: "7",
|
|
69
|
+
topic: "Identity account update, lock, unlock, revoke, audit",
|
|
70
|
+
status: "covered_by_reference_runtime",
|
|
71
|
+
sdkSurface: ["IdentityRegistryRuntime.update", "IdentityRegistryRuntime.lock", "IdentityRegistryRuntime.unlock", "IdentityRegistryRuntime.revoke", "IdentityAuditEvent"],
|
|
72
|
+
notes: "Revocation links to credential revocation for credentials issued through the account."
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
part: "GB/Z 185.3",
|
|
76
|
+
clause: "8",
|
|
77
|
+
topic: "Credential issue, update, lock, unlock, revoke and status query",
|
|
78
|
+
status: "covered_by_reference_runtime",
|
|
79
|
+
sdkSurface: ["CredentialIssuer", "DevelopmentCredentialIssuer", "CredentialStatusStore", "InMemoryCredentialStatusStore"],
|
|
80
|
+
notes: "Development implementation provides lifecycle behavior; production CA/status services should implement the same interfaces."
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
part: "GB/Z 185.3",
|
|
84
|
+
clause: "9",
|
|
85
|
+
topic: "Credential presentation, verification, authentication assertion, authorization decision",
|
|
86
|
+
status: "covered_by_reference_runtime",
|
|
87
|
+
sdkSurface: ["createProcessCredentialPackage", "CredentialVerifier", "DevelopmentCredentialVerifier", "InterconnectionAuthorizationRuntime"],
|
|
88
|
+
notes: "Includes audience, scope, validity, status, signature, and tamper checks."
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
part: "GB/Z 185.3",
|
|
92
|
+
clause: "9.2",
|
|
93
|
+
topic: "National CA roots, national algorithms, tamper-proof audit requirements",
|
|
94
|
+
status: "extension_point",
|
|
95
|
+
sdkSurface: ["CertificateChainVerifier", "CredentialStatusStore", "CredentialIssuer", "CredentialVerifier"],
|
|
96
|
+
notes: "The SDK is X.509-first by interface; regulator-approved CA, GM/T algorithms, and immutable audit stores are external implementations."
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
part: "GB/Z 185.4",
|
|
100
|
+
clause: "5",
|
|
101
|
+
topic: "Agent description and skill attributes",
|
|
102
|
+
status: "covered",
|
|
103
|
+
sdkSurface: ["AgentDescription", "SkillDescription", "validateAgentDescription", "validateSkillDescription"],
|
|
104
|
+
notes: "Required description and skill fields are typed and validated."
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
part: "GB/Z 185.4",
|
|
108
|
+
clause: "6-8",
|
|
109
|
+
topic: "Description registration, review, publication certificate, publish, change, unpublish, revoke",
|
|
110
|
+
status: "covered_by_reference_runtime",
|
|
111
|
+
sdkSurface: ["AgentDescriptionRegistry", "AgentDescriptionMaintenance", "PublicationCertificate", "DescriptionReview"],
|
|
112
|
+
notes: "Risk-review details are pluggable policy inputs; lifecycle transitions are implemented."
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
part: "GB/Z 185.5",
|
|
116
|
+
clause: "5-6.1",
|
|
117
|
+
topic: "Discovery through discovery service",
|
|
118
|
+
status: "covered_by_reference_runtime",
|
|
119
|
+
sdkSurface: ["DiscoveryService", "AgentInterconnectClient.discover"],
|
|
120
|
+
notes: "Supports text, identity, name, skill, tag, input/output, discoverability, availability, and limit filters."
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
part: "GB/Z 185.5",
|
|
124
|
+
clause: "6.2",
|
|
125
|
+
topic: "Discovery through preset information and caches",
|
|
126
|
+
status: "covered_by_reference_runtime",
|
|
127
|
+
sdkSurface: ["PresetDiscoverySource", "DiscoveryService"],
|
|
128
|
+
notes: "Preset sources represent provider preset data, cached results, user configuration, and well-known-derived descriptions."
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
part: "GB/Z 185.5",
|
|
132
|
+
clause: "6.1",
|
|
133
|
+
topic: "API, GUI, or LUI discovery interface",
|
|
134
|
+
status: "extension_point",
|
|
135
|
+
sdkSurface: ["JsonTransport", "HttpJsonTransport", "AgentInterconnectClient"],
|
|
136
|
+
notes: "API transport is provided; GUI/LUI are application surfaces built over the same client."
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
part: "GB/Z 185.6",
|
|
140
|
+
clause: "5-6",
|
|
141
|
+
topic: "Interaction requirements and modes: point-to-point, group, hybrid",
|
|
142
|
+
status: "covered_by_reference_runtime",
|
|
143
|
+
sdkSurface: ["InteractionRuntime", "AgentInteractionMode"],
|
|
144
|
+
notes: "All three interaction modes are typed and accepted by session creation."
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
part: "GB/Z 185.6",
|
|
148
|
+
clause: "7",
|
|
149
|
+
topic: "Data, message, task, session structures",
|
|
150
|
+
status: "covered",
|
|
151
|
+
sdkSurface: ["DataItem", "Message", "Task", "Session", "SessionReceiver"],
|
|
152
|
+
notes: "Standard content elements and relationships are modeled."
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
part: "GB/Z 185.6",
|
|
156
|
+
clause: "8",
|
|
157
|
+
topic: "Point-to-point and group interaction flows with message distribution",
|
|
158
|
+
status: "covered_by_reference_runtime",
|
|
159
|
+
sdkSurface: ["InteractionRuntime", "MessageDistributionRuntime"],
|
|
160
|
+
notes: "Group distribution receipts are implemented; point-to-point uses direct runtime messages."
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
part: "GB/Z 185.6",
|
|
164
|
+
clause: "Appendix A-B",
|
|
165
|
+
topic: "Remote call, streaming, notification, master-slave, proxy negotiation, task subscription references",
|
|
166
|
+
status: "extension_point",
|
|
167
|
+
sdkSurface: ["JsonTransport", "HttpJsonTransport", "InteractionRuntime", "MessageDistributionRuntime"],
|
|
168
|
+
notes: "The SDK models messages/chunks/tasks; concrete long-connection, callback, broker, or scheduler protocols are adapters."
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
part: "GB/Z 185.7",
|
|
172
|
+
clause: "4",
|
|
173
|
+
topic: "Tool invocation architecture: agent, tool access, tool service",
|
|
174
|
+
status: "covered",
|
|
175
|
+
sdkSurface: ["ToolAccessRuntime", "ToolRuntime"],
|
|
176
|
+
notes: "Agent-side tool access and resource-side tool service are separate surfaces."
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
part: "GB/Z 185.7",
|
|
180
|
+
clause: "5",
|
|
181
|
+
topic: "Tool list acquisition, tool updates, tool invocation loop",
|
|
182
|
+
status: "covered_by_reference_runtime",
|
|
183
|
+
sdkSurface: ["ToolAccessRuntime.getToolList", "ToolAccessRuntime.syncToolUpdates", "ToolAccessRuntime.invokeUntilComplete", "ToolRuntime"],
|
|
184
|
+
notes: "List, update, batch invocation, error result, and repeated invocation flows are implemented."
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
part: "GB/Z 185.7",
|
|
188
|
+
clause: "6",
|
|
189
|
+
topic: "Tool descriptor, request, sync, update, invoke, result data formats",
|
|
190
|
+
status: "covered",
|
|
191
|
+
sdkSurface: ["ToolDescriptor", "ToolRequestData", "ToolSyncData", "ToolUpdateData", "ToolInvokeRequest", "ToolInvokeResult"],
|
|
192
|
+
notes: "Data fields from the standard tables are represented as TypeScript types and validated where applicable."
|
|
193
|
+
}
|
|
194
|
+
];
|
|
195
|
+
//# sourceMappingURL=conformance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conformance.js","sourceRoot":"","sources":["../src/conformance.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,yBAAyB,GAA4B;IAChE;QACE,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE,GAAG;QACX,KAAK,EAAE,kGAAkG;QACzG,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,CAAC,gCAAgC,EAAE,0BAA0B,EAAE,kBAAkB,CAAC;QAC9F,KAAK,EAAE,mGAAmG;KAC3G;IACD;QACE,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,gDAAgD;QACvD,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,CAAC,kBAAkB,CAAC;QAChC,KAAK,EAAE,4GAA4G;KACpH;IACD;QACE,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,8CAA8C;QACrD,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,CAAC,wBAAwB,CAAC;QACtC,KAAK,EAAE,iEAAiE;KACzE;IACD;QACE,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE,SAAS;QACjB,KAAK,EAAE,gGAAgG;QACvG,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,CAAC,oBAAoB,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,2BAA2B,CAAC;QAC5G,KAAK,EAAE,0FAA0F;KAClG;IACD;QACE,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE,GAAG;QACX,KAAK,EAAE,+CAA+C;QACtD,MAAM,EAAE,8BAA8B;QACtC,UAAU,EAAE,CAAC,yBAAyB,EAAE,0BAA0B,CAAC;QACnE,KAAK,EAAE,sGAAsG;KAC9G;IACD;QACE,IAAI,EAAE,YAAY;QAClB,MAAM,EAAE,YAAY;QACpB,KA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AClB,MAAM,EAAE,GAAG;QACX,KAAK,EAAE,qEAAqE;QAC5E,MAAM,EAAE,SAAS;QACjB,UAAU,EAAE,CAAC,gBAAgB,EAAE,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,kBAAkB,CAAC;QAC5H,KAAK,EAAE,0GAA0G;KAClH;CACF,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { AgentIdentityCode, JsonObject, JsonValue } from "./types.js";
|
|
2
|
+
export type CredentialLifecycleStatus = "active" | "locked" | "revoked";
|
|
3
|
+
export type AuthenticationResult = "success" | "failed" | "needs_more_verification";
|
|
4
|
+
export interface AgentCredential {
|
|
5
|
+
credentialId: string;
|
|
6
|
+
agentId: AgentIdentityCode;
|
|
7
|
+
issuerId: string;
|
|
8
|
+
subject: string;
|
|
9
|
+
publicKeyPem: string;
|
|
10
|
+
certificatePem?: string | undefined;
|
|
11
|
+
certificateChainPem?: string[] | undefined;
|
|
12
|
+
audience?: string[] | undefined;
|
|
13
|
+
scope: string[];
|
|
14
|
+
issuedAt: string;
|
|
15
|
+
expiresAt: string;
|
|
16
|
+
metadata?: JsonObject | undefined;
|
|
17
|
+
}
|
|
18
|
+
export interface IssueCredentialInput {
|
|
19
|
+
agentId: AgentIdentityCode;
|
|
20
|
+
subject: string;
|
|
21
|
+
issuerId?: string | undefined;
|
|
22
|
+
audience?: string[] | undefined;
|
|
23
|
+
scope?: string[] | undefined;
|
|
24
|
+
expiresAt?: string | undefined;
|
|
25
|
+
metadata?: JsonObject | undefined;
|
|
26
|
+
}
|
|
27
|
+
export interface IssuedCredential {
|
|
28
|
+
credential: AgentCredential;
|
|
29
|
+
privateKeyPem: string;
|
|
30
|
+
}
|
|
31
|
+
export interface ProcessCredentialPackage {
|
|
32
|
+
credential: AgentCredential;
|
|
33
|
+
audience: string;
|
|
34
|
+
scope: string[];
|
|
35
|
+
nonce?: string | undefined;
|
|
36
|
+
timestamp: string;
|
|
37
|
+
payload?: JsonValue | undefined;
|
|
38
|
+
signature: string;
|
|
39
|
+
}
|
|
40
|
+
export interface CreatePresentationInput {
|
|
41
|
+
credential: AgentCredential;
|
|
42
|
+
privateKeyPem: string;
|
|
43
|
+
audience: string;
|
|
44
|
+
scope: string[];
|
|
45
|
+
nonce?: string | undefined;
|
|
46
|
+
timestamp?: string | undefined;
|
|
47
|
+
payload?: JsonValue | undefined;
|
|
48
|
+
}
|
|
49
|
+
export interface VerifyPresentationInput {
|
|
50
|
+
package: ProcessCredentialPackage;
|
|
51
|
+
expectedAudience: string;
|
|
52
|
+
requiredScope?: string[] | undefined;
|
|
53
|
+
now?: Date | undefined;
|
|
54
|
+
}
|
|
55
|
+
export interface AuthenticationAssertion {
|
|
56
|
+
assertionId: string;
|
|
57
|
+
result: AuthenticationResult;
|
|
58
|
+
agentId?: AgentIdentityCode | undefined;
|
|
59
|
+
credentialId?: string | undefined;
|
|
60
|
+
verifiedAt: string;
|
|
61
|
+
reason?: string | undefined;
|
|
62
|
+
verifiedAttributes?: JsonObject | undefined;
|
|
63
|
+
policyAdvice?: JsonObject | undefined;
|
|
64
|
+
}
|
|
65
|
+
export interface CredentialStatusStore {
|
|
66
|
+
getStatus(credentialId: string): Promise<CredentialLifecycleStatus | undefined>;
|
|
67
|
+
setStatus(credentialId: string, status: CredentialLifecycleStatus, reason?: string | undefined): Promise<void>;
|
|
68
|
+
}
|
|
69
|
+
export interface CertificateChainVerifier {
|
|
70
|
+
verifyCertificateChain(credential: AgentCredential, now?: Date): Promise<{
|
|
71
|
+
ok: boolean;
|
|
72
|
+
reason?: string | undefined;
|
|
73
|
+
}>;
|
|
74
|
+
}
|
|
75
|
+
export interface CredentialIssuer {
|
|
76
|
+
issueCredential(input: IssueCredentialInput): Promise<IssuedCredential>;
|
|
77
|
+
updateCredential(credentialId: string, patch: Partial<Pick<AgentCredential, "audience" | "scope" | "expiresAt" | "metadata">>): Promise<AgentCredential>;
|
|
78
|
+
lockCredential(credentialId: string, reason?: string | undefined): Promise<void>;
|
|
79
|
+
unlockCredential(credentialId: string, reason?: string | undefined): Promise<void>;
|
|
80
|
+
revokeCredential(credentialId: string, reason?: string | undefined): Promise<void>;
|
|
81
|
+
getCredential(credentialId: string): Promise<AgentCredential | undefined>;
|
|
82
|
+
}
|
|
83
|
+
export interface CredentialVerifier {
|
|
84
|
+
verifyPresentation(input: VerifyPresentationInput): Promise<AuthenticationAssertion>;
|
|
85
|
+
}
|
|
86
|
+
export declare class InMemoryCredentialStatusStore implements CredentialStatusStore {
|
|
87
|
+
private statuses;
|
|
88
|
+
getStatus(credentialId: string): Promise<CredentialLifecycleStatus | undefined>;
|
|
89
|
+
setStatus(credentialId: string, status: CredentialLifecycleStatus, reason?: string | undefined): Promise<void>;
|
|
90
|
+
}
|
|
91
|
+
export declare class InMemoryCredentialRepository {
|
|
92
|
+
private credentials;
|
|
93
|
+
save(credential: AgentCredential): Promise<void>;
|
|
94
|
+
get(credentialId: string): Promise<AgentCredential | undefined>;
|
|
95
|
+
listByAgent(agentId: AgentIdentityCode): Promise<AgentCredential[]>;
|
|
96
|
+
}
|
|
97
|
+
export declare class NodeX509CertificateChainVerifier implements CertificateChainVerifier {
|
|
98
|
+
verifyCertificateChain(credential: AgentCredential, now?: Date): Promise<{
|
|
99
|
+
ok: boolean;
|
|
100
|
+
reason?: string | undefined;
|
|
101
|
+
}>;
|
|
102
|
+
}
|
|
103
|
+
export declare class DevelopmentCredentialIssuer implements CredentialIssuer {
|
|
104
|
+
private readonly repository;
|
|
105
|
+
private readonly statusStore;
|
|
106
|
+
private readonly issuerId;
|
|
107
|
+
constructor(repository?: InMemoryCredentialRepository, statusStore?: CredentialStatusStore, issuerId?: string);
|
|
108
|
+
issueCredential(input: IssueCredentialInput): Promise<IssuedCredential>;
|
|
109
|
+
updateCredential(credentialId: string, patch: Partial<Pick<AgentCredential, "audience" | "scope" | "expiresAt" | "metadata">>): Promise<AgentCredential>;
|
|
110
|
+
lockCredential(credentialId: string, reason?: string | undefined): Promise<void>;
|
|
111
|
+
unlockCredential(credentialId: string, reason?: string | undefined): Promise<void>;
|
|
112
|
+
revokeCredential(credentialId: string, reason?: string | undefined): Promise<void>;
|
|
113
|
+
getCredential(credentialId: string): Promise<AgentCredential | undefined>;
|
|
114
|
+
private requireCredential;
|
|
115
|
+
}
|
|
116
|
+
export declare class DevelopmentCredentialVerifier implements CredentialVerifier {
|
|
117
|
+
private readonly statusStore;
|
|
118
|
+
private readonly chainVerifier;
|
|
119
|
+
constructor(statusStore?: CredentialStatusStore, chainVerifier?: CertificateChainVerifier);
|
|
120
|
+
verifyPresentation(input: VerifyPresentationInput): Promise<AuthenticationAssertion>;
|
|
121
|
+
}
|
|
122
|
+
export declare function createProcessCredentialPackage(input: CreatePresentationInput): ProcessCredentialPackage;
|
|
123
|
+
export declare function canonicalJson(value: JsonValue | JsonObject | unknown): string;
|
|
124
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE3E,MAAM,MAAM,yBAAyB,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AACxE,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,QAAQ,GAAG,yBAAyB,CAAC;AAEpF,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,mBAAmB,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC3C,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,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ACxE,aAAa,GAAE,wBAAiE;IAG7F,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,CAAC;CAkE3F;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,uBAAuB,GAAG,wBAAwB,CAevG;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,CAW7E"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { createHash, generateKeyPairSync, randomUUID, sign, verify, X509Certificate } from "node:crypto";
|
|
2
|
+
export class InMemoryCredentialStatusStore {
|
|
3
|
+
statuses = new Map();
|
|
4
|
+
async getStatus(credentialId) {
|
|
5
|
+
return this.statuses.get(credentialId)?.status;
|
|
6
|
+
}
|
|
7
|
+
async setStatus(credentialId, status, reason) {
|
|
8
|
+
this.statuses.set(credentialId, { status, reason });
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export class InMemoryCredentialRepository {
|
|
12
|
+
credentials = new Map();
|
|
13
|
+
async save(credential) {
|
|
14
|
+
this.credentials.set(credential.credentialId, credential);
|
|
15
|
+
}
|
|
16
|
+
async get(credentialId) {
|
|
17
|
+
return this.credentials.get(credentialId);
|
|
18
|
+
}
|
|
19
|
+
async listByAgent(agentId) {
|
|
20
|
+
return [...this.credentials.values()].filter((credential) => credential.agentId === agentId);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export class NodeX509CertificateChainVerifier {
|
|
24
|
+
async verifyCertificateChain(credential, now = new Date()) {
|
|
25
|
+
if (!credential.certificatePem) {
|
|
26
|
+
return { ok: true, reason: "No X.509 certificate PEM supplied; verified through public-key presentation only" };
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const cert = new X509Certificate(credential.certificatePem);
|
|
30
|
+
const validFrom = new Date(cert.validFrom);
|
|
31
|
+
const validTo = new Date(cert.validTo);
|
|
32
|
+
if (now < validFrom || now > validTo) {
|
|
33
|
+
return { ok: false, reason: "X.509 certificate is outside its validity window" };
|
|
34
|
+
}
|
|
35
|
+
if (cert.publicKey.export({ type: "spki", format: "pem" }).toString() !== credential.publicKeyPem) {
|
|
36
|
+
return { ok: false, reason: "X.509 certificate public key does not match credential public key" };
|
|
37
|
+
}
|
|
38
|
+
return { ok: true };
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
return { ok: false, reason: `Invalid X.509 certificate: ${error.message}` };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export class DevelopmentCredentialIssuer {
|
|
46
|
+
repository;
|
|
47
|
+
statusStore;
|
|
48
|
+
issuerId;
|
|
49
|
+
constructor(repository = new InMemoryCredentialRepository(), statusStore = new InMemoryCredentialStatusStore(), issuerId = "development-x509-issuer") {
|
|
50
|
+
this.repository = repository;
|
|
51
|
+
this.statusStore = statusStore;
|
|
52
|
+
this.issuerId = issuerId;
|
|
53
|
+
}
|
|
54
|
+
async issueCredential(input) {
|
|
55
|
+
const { publicKey, privateKey } = generateKeyPairSync("ed25519");
|
|
56
|
+
const publicKeyPem = publicKey.export({ type: "spki", format: "pem" }).toString();
|
|
57
|
+
const privateKeyPem = privateKey.export({ type: "pkcs8", format: "pem" }).toString();
|
|
58
|
+
const now = new Date();
|
|
59
|
+
const credential = {
|
|
60
|
+
credentialId: randomUUID(),
|
|
61
|
+
agentId: input.agentId,
|
|
62
|
+
issuerId: input.issuerId ?? this.issuerId,
|
|
63
|
+
subject: input.subject,
|
|
64
|
+
publicKeyPem,
|
|
65
|
+
audience: input.audience,
|
|
66
|
+
scope: input.scope ?? ["agent:interact", "tool:invoke"],
|
|
67
|
+
issuedAt: now.toISOString(),
|
|
68
|
+
expiresAt: input.expiresAt ?? new Date(now.getTime() + 1000 * 60 * 60 * 24 * 365).toISOString(),
|
|
69
|
+
metadata: {
|
|
70
|
+
...(input.metadata ?? {}),
|
|
71
|
+
developmentOnly: true,
|
|
72
|
+
certificateProfile: "x509-first-interface-with-ed25519-dev-key"
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
await this.repository.save(credential);
|
|
76
|
+
await this.statusStore.setStatus(credential.credentialId, "active");
|
|
77
|
+
return { credential, privateKeyPem };
|
|
78
|
+
}
|
|
79
|
+
async updateCredential(credentialId, patch) {
|
|
80
|
+
const existing = await this.requireCredential(credentialId);
|
|
81
|
+
const updated = { ...existing, ...patch };
|
|
82
|
+
await this.repository.save(updated);
|
|
83
|
+
return updated;
|
|
84
|
+
}
|
|
85
|
+
async lockCredential(credentialId, reason) {
|
|
86
|
+
await this.requireCredential(credentialId);
|
|
87
|
+
await this.statusStore.setStatus(credentialId, "locked", reason);
|
|
88
|
+
}
|
|
89
|
+
async unlockCredential(credentialId, reason) {
|
|
90
|
+
await this.requireCredential(credentialId);
|
|
91
|
+
await this.statusStore.setStatus(credentialId, "active", reason);
|
|
92
|
+
}
|
|
93
|
+
async revokeCredential(credentialId, reason) {
|
|
94
|
+
await this.requireCredential(credentialId);
|
|
95
|
+
await this.statusStore.setStatus(credentialId, "revoked", reason);
|
|
96
|
+
}
|
|
97
|
+
async getCredential(credentialId) {
|
|
98
|
+
return this.repository.get(credentialId);
|
|
99
|
+
}
|
|
100
|
+
async requireCredential(credentialId) {
|
|
101
|
+
const credential = await this.repository.get(credentialId);
|
|
102
|
+
if (!credential) {
|
|
103
|
+
throw new Error(`Credential not found: ${credentialId}`);
|
|
104
|
+
}
|
|
105
|
+
return credential;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
export class DevelopmentCredentialVerifier {
|
|
109
|
+
statusStore;
|
|
110
|
+
chainVerifier;
|
|
111
|
+
constructor(statusStore = new InMemoryCredentialStatusStore(), chainVerifier = new NodeX509CertificateChainVerifier()) {
|
|
112
|
+
this.statusStore = statusStore;
|
|
113
|
+
this.chainVerifier = chainVerifier;
|
|
114
|
+
}
|
|
115
|
+
async verifyPresentation(input) {
|
|
116
|
+
const verifiedAt = (input.now ?? new Date()).toISOString();
|
|
117
|
+
const credential = input.package.credential;
|
|
118
|
+
const fail = (reason) => ({
|
|
119
|
+
assertionId: randomUUID(),
|
|
120
|
+
result: "failed",
|
|
121
|
+
agentId: credential.agentId,
|
|
122
|
+
credentialId: credential.credentialId,
|
|
123
|
+
verifiedAt,
|
|
124
|
+
reason
|
|
125
|
+
});
|
|
126
|
+
const status = await this.statusStore.getStatus(credential.credentialId);
|
|
127
|
+
if (status === "locked" || status === "revoked") {
|
|
128
|
+
return fail(`Credential is ${status}`);
|
|
129
|
+
}
|
|
130
|
+
const now = input.now ?? new Date();
|
|
131
|
+
if (now < new Date(credential.issuedAt) || now > new Date(credential.expiresAt)) {
|
|
132
|
+
return fail("Credential is outside its validity window");
|
|
133
|
+
}
|
|
134
|
+
const chainResult = await this.chainVerifier.verifyCertificateChain(credential, now);
|
|
135
|
+
if (!chainResult.ok) {
|
|
136
|
+
return fail(chainResult.reason ?? "Certificate chain verification failed");
|
|
137
|
+
}
|
|
138
|
+
if (credential.audience?.length && !credential.audience.includes(input.expectedAudience)) {
|
|
139
|
+
return fail("Credential audience does not include expected audience");
|
|
140
|
+
}
|
|
141
|
+
if (input.package.audience !== input.expectedAudience) {
|
|
142
|
+
return fail("Process credential package audience does not match expected audience");
|
|
143
|
+
}
|
|
144
|
+
const requiredScope = input.requiredScope ?? [];
|
|
145
|
+
if (!requiredScope.every((scope) => credential.scope.includes(scope) && input.package.scope.includes(scope))) {
|
|
146
|
+
return fail("Credential scope does not cover requested operation");
|
|
147
|
+
}
|
|
148
|
+
const expectedPayload = presentationSigningPayload(input.package);
|
|
149
|
+
const signatureOk = verify(null, Buffer.from(canonicalJson(expectedPayload)), credential.publicKeyPem, Buffer.from(input.package.signature, "base64"));
|
|
150
|
+
if (!signatureOk) {
|
|
151
|
+
return fail("Process credential signature verification failed");
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
assertionId: randomUUID(),
|
|
155
|
+
result: "success",
|
|
156
|
+
agentId: credential.agentId,
|
|
157
|
+
credentialId: credential.credentialId,
|
|
158
|
+
verifiedAt,
|
|
159
|
+
verifiedAttributes: {
|
|
160
|
+
issuerId: credential.issuerId,
|
|
161
|
+
subject: credential.subject,
|
|
162
|
+
scope: credential.scope,
|
|
163
|
+
payloadHash: hashJson(input.package.payload ?? null)
|
|
164
|
+
},
|
|
165
|
+
policyAdvice: {
|
|
166
|
+
developmentOnly: credential.metadata?.developmentOnly === true
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
export function createProcessCredentialPackage(input) {
|
|
172
|
+
const pkgWithoutSignature = {
|
|
173
|
+
credential: input.credential,
|
|
174
|
+
audience: input.audience,
|
|
175
|
+
scope: input.scope,
|
|
176
|
+
nonce: input.nonce,
|
|
177
|
+
timestamp: input.timestamp ?? new Date().toISOString(),
|
|
178
|
+
payload: input.payload
|
|
179
|
+
};
|
|
180
|
+
const signature = sign(null, Buffer.from(canonicalJson(presentationSigningPayload(pkgWithoutSignature))), input.privateKeyPem).toString("base64");
|
|
181
|
+
return { ...pkgWithoutSignature, signature };
|
|
182
|
+
}
|
|
183
|
+
export function canonicalJson(value) {
|
|
184
|
+
if (Array.isArray(value)) {
|
|
185
|
+
return `[${value.map((item) => canonicalJson(item)).join(",")}]`;
|
|
186
|
+
}
|
|
187
|
+
if (value && typeof value === "object") {
|
|
188
|
+
const entries = Object.entries(value)
|
|
189
|
+
.filter(([, entryValue]) => entryValue !== undefined)
|
|
190
|
+
.sort(([left], [right]) => left.localeCompare(right));
|
|
191
|
+
return `{${entries.map(([key, entryValue]) => `${JSON.stringify(key)}:${canonicalJson(entryValue)}`).join(",")}}`;
|
|
192
|
+
}
|
|
193
|
+
return JSON.stringify(value);
|
|
194
|
+
}
|
|
195
|
+
function hashJson(value) {
|
|
196
|
+
return createHash("sha256").update(canonicalJson(value)).digest("hex");
|
|
197
|
+
}
|
|
198
|
+
function presentationSigningPayload(pkg) {
|
|
199
|
+
return {
|
|
200
|
+
credentialId: pkg.credential.credentialId,
|
|
201
|
+
agentId: pkg.credential.agentId,
|
|
202
|
+
audience: pkg.audience,
|
|
203
|
+
scope: pkg.scope,
|
|
204
|
+
nonce: pkg.nonce ?? null,
|
|
205
|
+
timestamp: pkg.timestamp,
|
|
206
|
+
payloadHash: hashJson(pkg.payload ?? null)
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAgGzG,MAAM,OAAO,6BAA6B;IAChC,QAAQ,GAAG,IAAI,GAAG,EAA8E,CAAC;IAEzG,KAAK,CAAC,SAAS,CAAC,YAAoB;QAClC,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,YAAoB,EAAE,MAAiC,EAAE,MAA2B;QAClG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACtD,CAAC;CACF;AAED,MAAM,OAAO,4BAA4B;IAC/B,WAAW,GAAG,IAAI,GAAG,EAA2B,CAAC;IAEzD,KAAK,CAAC,IAAI,CAAC,UAA2B;QACpC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IAC5D,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,YAAoB;QAC5B,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAA0B;QAC1C,OAAO,CA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AAQ,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACzE,CAAC;AAED,SAAS,0BAA0B,CAAC,GAAgD;IAClF,OAAO;QACL,YAAY,EAAE,GAAG,CAAC,UAAU,CAAC,YAAY;QACzC,OAAO,EAAE,GAAG,CAAC,UAAU,CAAC,OAAO;QAC/B,QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,KAAK,EAAE,GAAG,CAAC,KAAK,IAAI,IAAI;QACxB,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,WAAW,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,IAAI,IAAI,CAAC;KAC3C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { AgentDescription, AgentIdentityCode } from "./types.js";
|
|
2
|
+
export type DescriptionStatus = "registered" | "published" | "unpublished" | "revoked";
|
|
3
|
+
export interface DescriptionReview {
|
|
4
|
+
reviewId: string;
|
|
5
|
+
reviewerId: string;
|
|
6
|
+
approved: boolean;
|
|
7
|
+
reason?: string | undefined;
|
|
8
|
+
riskLevel?: "low" | "medium" | "high" | undefined;
|
|
9
|
+
createdAt: string;
|
|
10
|
+
}
|
|
11
|
+
export interface PublicationRequestInfo {
|
|
12
|
+
regions?: string[] | undefined;
|
|
13
|
+
openBeta?: boolean | undefined;
|
|
14
|
+
paid?: boolean | undefined;
|
|
15
|
+
permissionRequirements?: string[] | undefined;
|
|
16
|
+
copyrightCertificate?: string | undefined;
|
|
17
|
+
metadata?: Record<string, unknown> | undefined;
|
|
18
|
+
}
|
|
19
|
+
export interface PublicationCertificate {
|
|
20
|
+
certificateId: string;
|
|
21
|
+
agentId: AgentIdentityCode;
|
|
22
|
+
issuer: string;
|
|
23
|
+
issuedAt: string;
|
|
24
|
+
publicKeyDigest?: string | undefined;
|
|
25
|
+
metadata?: Record<string, unknown> | undefined;
|
|
26
|
+
}
|
|
27
|
+
export interface DescriptionRecord {
|
|
28
|
+
description: AgentDescription;
|
|
29
|
+
status: DescriptionStatus;
|
|
30
|
+
published: boolean;
|
|
31
|
+
reviews?: DescriptionReview[] | undefined;
|
|
32
|
+
publication?: PublicationRequestInfo | undefined;
|
|
33
|
+
publicationCertificate?: PublicationCertificate | undefined;
|
|
34
|
+
revokedAt?: string | undefined;
|
|
35
|
+
revokeReason?: string | undefined;
|
|
36
|
+
createdAt: string;
|
|
37
|
+
updatedAt: string;
|
|
38
|
+
}
|
|
39
|
+
export interface DescriptionStore {
|
|
40
|
+
save(record: DescriptionRecord): Promise<void>;
|
|
41
|
+
get(agentId: AgentIdentityCode): Promise<DescriptionRecord | undefined>;
|
|
42
|
+
list(): Promise<DescriptionRecord[]>;
|
|
43
|
+
}
|
|
44
|
+
export declare class InMemoryDescriptionStore implements DescriptionStore {
|
|
45
|
+
private records;
|
|
46
|
+
save(record: DescriptionRecord): Promise<void>;
|
|
47
|
+
get(agentId: AgentIdentityCode): Promise<DescriptionRecord | undefined>;
|
|
48
|
+
list(): Promise<DescriptionRecord[]>;
|
|
49
|
+
}
|
|
50
|
+
export declare class AgentDescriptionRegistry {
|
|
51
|
+
private readonly store;
|
|
52
|
+
constructor(store?: DescriptionStore);
|
|
53
|
+
register(description: AgentDescription): Promise<DescriptionRecord>;
|
|
54
|
+
review(agentId: AgentIdentityCode, review: Omit<DescriptionReview, "reviewId" | "createdAt">): Promise<DescriptionRecord>;
|
|
55
|
+
issuePublicationCertificate(agentId: AgentIdentityCode, input: Omit<PublicationCertificate, "certificateId" | "agentId" | "issuedAt">): Promise<PublicationCertificate>;
|
|
56
|
+
publish(agentId: AgentIdentityCode, publication?: PublicationRequestInfo): Promise<DescriptionRecord>;
|
|
57
|
+
change(agentId: AgentIdentityCode, patch: Partial<AgentDescription>): Promise<DescriptionRecord>;
|
|
58
|
+
unpublish(agentId: AgentIdentityCode): Promise<DescriptionRecord>;
|
|
59
|
+
revoke(agentId: AgentIdentityCode, reason?: string): Promise<DescriptionRecord>;
|
|
60
|
+
get(agentId: AgentIdentityCode): Promise<DescriptionRecord | undefined>;
|
|
61
|
+
list(options?: {
|
|
62
|
+
publishedOnly?: boolean;
|
|
63
|
+
}): Promise<DescriptionRecord[]>;
|
|
64
|
+
private requireRecord;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=description-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"description-registry.d.ts","sourceRoot":"","sources":["../src/description-registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAGtE,MAAM,MAAM,iBAAiB,GAAG,YAAY,GAAG,WAAW,GAAG,aAAa,GAAG,SAAS,CAAC;AAEvF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;IAClD,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC/B,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/B,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3B,sBAAsB,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC9C,oBAAoB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;CAChD;AAED,MAAM,WAAW,sBAAsB;IACrC,aAAa,EAAE,MAAM,C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