@tinycloud/node-sdk 3.6.0-beta.3 → 3.6.0-beta.5
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 +6 -0
- package/dist/{TinyCloudNode-N4mfZI_k.d.cts → TinyCloudNode-B5WCe_ps.d.ts} +3 -250
- package/dist/{TinyCloudNode-N4mfZI_k.d.ts → TinyCloudNode-CIGurdHw.d.cts} +3 -250
- package/dist/{authority-BgZpUFss.d.cts → authority-Beg1WM2U.d.cts} +1 -1
- package/dist/{authority-C670-9su.d.ts → authority-Vh7ike0I.d.ts} +1 -1
- package/dist/core.d.cts +3 -2
- package/dist/core.d.ts +3 -2
- package/dist/credential-pending-store.cjs +401 -0
- package/dist/credential-pending-store.cjs.map +1 -0
- package/dist/credential-pending-store.d.cts +42 -0
- package/dist/credential-pending-store.d.ts +42 -0
- package/dist/credential-pending-store.js +389 -0
- package/dist/credential-pending-store.js.map +1 -0
- package/dist/credentials-core.cjs +309 -0
- package/dist/credentials-core.cjs.map +1 -0
- package/dist/credentials-core.d.cts +337 -0
- package/dist/credentials-core.d.ts +337 -0
- package/dist/credentials-core.js +294 -0
- package/dist/credentials-core.js.map +1 -0
- package/dist/credentials.cjs +746 -0
- package/dist/credentials.cjs.map +1 -0
- package/dist/credentials.d.cts +4 -0
- package/dist/credentials.d.ts +4 -0
- package/dist/credentials.js +732 -0
- package/dist/credentials.js.map +1 -0
- package/dist/delegation-0LKZkmP2.d.cts +251 -0
- package/dist/delegation-0LKZkmP2.d.ts +251 -0
- package/dist/email-proof-Blhdm4ox.d.cts +155 -0
- package/dist/email-proof-Blhdm4ox.d.ts +155 -0
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/replication/authority.d.cts +3 -2
- package/dist/replication/authority.d.ts +3 -2
- package/package.json +18 -2
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { CredentialFlowDescriptor, CredentialRequirement, CredentialHolderBinding, IssuedCredentialEnvelope, CredentialIssuerMetadata, ClientSession, IKVService, StoredCredentialRecord, VerifiedCredential, CredentialProgressEvent, CredentialStorageReceipt, UnifiedPolicyV2, UnifiedPolicyCapability, PolicyCredentialAdmissionV3 } from '@tinycloud/sdk-core';
|
|
2
|
+
import { V as ValidatedRuntimeDelegation } from './delegation-0LKZkmP2.cjs';
|
|
3
|
+
|
|
4
|
+
interface CredentialClient {
|
|
5
|
+
readonly sessionDid: string;
|
|
6
|
+
readonly credentialHolderDid: string;
|
|
7
|
+
readonly credentialHolderKid: string;
|
|
8
|
+
session(): ClientSession | undefined;
|
|
9
|
+
signSessionBytes(bytes: Uint8Array): Promise<Uint8Array>;
|
|
10
|
+
autoSignCredentialBytes?(bytes: Uint8Array): Promise<Uint8Array | undefined>;
|
|
11
|
+
approveCredentialBytes?(bytes: Uint8Array): Promise<Uint8Array>;
|
|
12
|
+
activateCompactRuntimeDelegation?(input: {
|
|
13
|
+
readonly authorization: string;
|
|
14
|
+
readonly cid: string;
|
|
15
|
+
readonly host: string;
|
|
16
|
+
}): Promise<ValidatedRuntimeDelegation>;
|
|
17
|
+
ensureOwnedSpaceHosted(name: string): Promise<string>;
|
|
18
|
+
credentialSpaceOwnerDid(spaceId: string): string;
|
|
19
|
+
kvForSpace(spaceId: string): IKVService;
|
|
20
|
+
/**
|
|
21
|
+
* Root authorization CID of the active account session. Exposed here rather
|
|
22
|
+
* than on {@link ClientSession} so the CID stays out of the public session.
|
|
23
|
+
*/
|
|
24
|
+
accountAuthorizationCid(): string;
|
|
25
|
+
/** Receiver-local credential custody. Its presence selects accountless mode. */
|
|
26
|
+
readonly receiverCredentialCustody?: ReceiverCredentialCustody;
|
|
27
|
+
}
|
|
28
|
+
interface ReceiverCredentialCustody {
|
|
29
|
+
find(input: {
|
|
30
|
+
readonly requirement: CredentialRequirement;
|
|
31
|
+
readonly requirementDigest: string;
|
|
32
|
+
readonly holderDid: string;
|
|
33
|
+
readonly now?: Date;
|
|
34
|
+
}): Promise<StoredCredentialRecord | undefined>;
|
|
35
|
+
store(input: {
|
|
36
|
+
readonly verified: VerifiedCredential;
|
|
37
|
+
readonly requirement: CredentialRequirement;
|
|
38
|
+
readonly requirementDigest: string;
|
|
39
|
+
readonly holderDid: string;
|
|
40
|
+
readonly now?: Date;
|
|
41
|
+
}): Promise<StoredCredentialRecord>;
|
|
42
|
+
}
|
|
43
|
+
/** Holder key the witness verifies against. Sent on the wire with the holder signature. */
|
|
44
|
+
interface HolderSignatureKey {
|
|
45
|
+
readonly alg: "EdDSA";
|
|
46
|
+
readonly kid: string;
|
|
47
|
+
}
|
|
48
|
+
interface CredentialSigningAdapter {
|
|
49
|
+
/** Return undefined when the existing exact-request auto-sign policy does not apply. */
|
|
50
|
+
readonly autoSign?: (binding: CredentialHolderBinding, bytes: Uint8Array, signal?: AbortSignal) => Promise<Uint8Array | undefined>;
|
|
51
|
+
/** Invoke the normal OpenKey approval surface. */
|
|
52
|
+
readonly requestApproval?: (binding: CredentialHolderBinding, bytes: Uint8Array, signal?: AbortSignal) => Promise<Uint8Array>;
|
|
53
|
+
/** Wire identity for the holder signature. Omitted by root callers: the transport then sends EdDSA with the did:key kid. */
|
|
54
|
+
readonly holderKey?: HolderSignatureKey;
|
|
55
|
+
}
|
|
56
|
+
type PrimitiveStepResult = Readonly<Record<string, string | boolean>>;
|
|
57
|
+
type PrimitiveStepHandler = (input: {
|
|
58
|
+
readonly descriptor: CredentialFlowDescriptor;
|
|
59
|
+
readonly requirement: CredentialRequirement;
|
|
60
|
+
readonly stepId: string;
|
|
61
|
+
readonly constraints: Readonly<Record<string, unknown>>;
|
|
62
|
+
readonly signal?: AbortSignal;
|
|
63
|
+
}) => Promise<PrimitiveStepResult>;
|
|
64
|
+
/**
|
|
65
|
+
* The bounded view a host-owned inline surface may receive. It deliberately
|
|
66
|
+
* excludes requirement values, which can contain private policy inputs.
|
|
67
|
+
*/
|
|
68
|
+
interface InlineCredentialProofRequest {
|
|
69
|
+
readonly stepId: string;
|
|
70
|
+
readonly constraints: Readonly<Record<string, unknown>>;
|
|
71
|
+
readonly display: {
|
|
72
|
+
readonly title: string;
|
|
73
|
+
readonly description: string;
|
|
74
|
+
readonly consent: string;
|
|
75
|
+
readonly progressLabel: string;
|
|
76
|
+
readonly errorLiveRegion: "assertive";
|
|
77
|
+
};
|
|
78
|
+
readonly inputs: readonly {
|
|
79
|
+
readonly id: string;
|
|
80
|
+
readonly label: string;
|
|
81
|
+
readonly schema: CredentialFlowDescriptor["inputs"][number]["schema"];
|
|
82
|
+
}[];
|
|
83
|
+
/** Present when this step's previous proof was rejected and may be retried. */
|
|
84
|
+
readonly feedback?: {
|
|
85
|
+
readonly kind: "rejected";
|
|
86
|
+
readonly attemptsRemaining: number;
|
|
87
|
+
};
|
|
88
|
+
readonly signal?: AbortSignal;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The mailbox a `mailbox_otp` code is sent to, copied from the digest-bound
|
|
92
|
+
* credential requirement. Only the SDK-owned inline view receives it; host
|
|
93
|
+
* proof handlers never see requirement values.
|
|
94
|
+
*/
|
|
95
|
+
interface CredentialProofSubject {
|
|
96
|
+
readonly kind: "email";
|
|
97
|
+
readonly value: string;
|
|
98
|
+
}
|
|
99
|
+
type InlineCredentialProofHandler = (input: InlineCredentialProofRequest) => Promise<PrimitiveStepResult>;
|
|
100
|
+
type CredentialInteractionKind = "popup" | "redirect" | "headless" | "inline";
|
|
101
|
+
interface CredentialInteractionSurface {
|
|
102
|
+
readonly wake: () => Promise<void>;
|
|
103
|
+
readonly close: () => void;
|
|
104
|
+
readonly closed: () => boolean;
|
|
105
|
+
/**
|
|
106
|
+
* A bounded, local UI callback for a declared primitive step. The adapter
|
|
107
|
+
* returns user-entered proof bytes to the SDK; it never receives an
|
|
108
|
+
* acquisition locator, request verifier, or transport capability.
|
|
109
|
+
*/
|
|
110
|
+
readonly requestProof?: InlineCredentialProofHandler;
|
|
111
|
+
/**
|
|
112
|
+
* Collects descriptor inputs the requirement does not already supply, such
|
|
113
|
+
* as the recipient's own mailbox for an email-domain requirement. It
|
|
114
|
+
* receives only the input schema and the public domain constraint.
|
|
115
|
+
*/
|
|
116
|
+
readonly requestInputs?: (request: CredentialInputRequest) => Promise<Readonly<Record<string, string>>>;
|
|
117
|
+
}
|
|
118
|
+
interface CredentialInputRequest {
|
|
119
|
+
readonly inputs: readonly {
|
|
120
|
+
readonly id: string;
|
|
121
|
+
readonly label: string;
|
|
122
|
+
readonly schema: CredentialFlowDescriptor["inputs"][number]["schema"];
|
|
123
|
+
}[];
|
|
124
|
+
/** The exact canonical domain the entered mailbox must belong to. */
|
|
125
|
+
readonly mailboxDomain?: string;
|
|
126
|
+
readonly signal?: AbortSignal;
|
|
127
|
+
}
|
|
128
|
+
/** A browser-owned interaction that navigates to the OpenCredentials locator. */
|
|
129
|
+
interface CredentialBrowserInteractionAdapter {
|
|
130
|
+
readonly kind: Exclude<CredentialInteractionKind, "inline">;
|
|
131
|
+
start(input: {
|
|
132
|
+
readonly interaction: CredentialFlowDescriptor["interaction"];
|
|
133
|
+
readonly locator: string;
|
|
134
|
+
readonly signal?: AbortSignal;
|
|
135
|
+
}): Promise<CredentialInteractionSurface>;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* A host-owned, in-page acquisition surface. It intentionally receives no
|
|
139
|
+
* OpenCredentials locator, request verifier, or transport capability. The SDK
|
|
140
|
+
* owns every OpenCredentials request, including submission of returned proof.
|
|
141
|
+
*/
|
|
142
|
+
interface CredentialInlineInteractionAdapter {
|
|
143
|
+
readonly kind: "inline";
|
|
144
|
+
start(input: {
|
|
145
|
+
readonly signal?: AbortSignal;
|
|
146
|
+
}): Promise<CredentialInteractionSurface>;
|
|
147
|
+
}
|
|
148
|
+
type CredentialInteractionAdapter = CredentialBrowserInteractionAdapter | CredentialInlineInteractionAdapter;
|
|
149
|
+
interface CredentialRedirectResumeState {
|
|
150
|
+
readonly type: "TinyCloudCredentialRedirectResume";
|
|
151
|
+
readonly version: 1;
|
|
152
|
+
readonly requestId: string;
|
|
153
|
+
readonly locator: string;
|
|
154
|
+
readonly verifier: string;
|
|
155
|
+
readonly expiresAt: string;
|
|
156
|
+
readonly correlationId: string;
|
|
157
|
+
readonly holderDid: string;
|
|
158
|
+
readonly descriptorDigest: string;
|
|
159
|
+
readonly requirementDigest: string;
|
|
160
|
+
readonly openerOrigin: string;
|
|
161
|
+
}
|
|
162
|
+
interface CredentialRedirectStore {
|
|
163
|
+
load(): Promise<CredentialRedirectResumeState | undefined>;
|
|
164
|
+
save(state: CredentialRedirectResumeState): Promise<void>;
|
|
165
|
+
clear(): Promise<void>;
|
|
166
|
+
}
|
|
167
|
+
interface CredentialRequestState {
|
|
168
|
+
readonly type: "OpenCredentialsAcquisitionState";
|
|
169
|
+
readonly version: 1;
|
|
170
|
+
readonly requestId: string;
|
|
171
|
+
readonly transitionId: string;
|
|
172
|
+
readonly state: "pending" | "ready_to_issue" | "issued" | "complete" | "expired" | "canceled" | "issuer_unready";
|
|
173
|
+
readonly nextStep?: {
|
|
174
|
+
readonly id: string;
|
|
175
|
+
readonly type: "collect_input" | "mailbox_otp" | "holder_signature";
|
|
176
|
+
readonly version: 1;
|
|
177
|
+
readonly constraints: Readonly<Record<string, unknown>>;
|
|
178
|
+
};
|
|
179
|
+
readonly retryAfterMs?: number;
|
|
180
|
+
readonly correlationId: string;
|
|
181
|
+
}
|
|
182
|
+
interface CredentialAcquisitionTransport {
|
|
183
|
+
create(input: {
|
|
184
|
+
readonly descriptor: CredentialFlowDescriptor;
|
|
185
|
+
readonly descriptorDigest: string;
|
|
186
|
+
readonly requirement: CredentialRequirement;
|
|
187
|
+
readonly requirementDigest: string;
|
|
188
|
+
readonly holderDid: string;
|
|
189
|
+
readonly openerOrigin: string;
|
|
190
|
+
readonly completionVerifierChallenge: string;
|
|
191
|
+
readonly inputs?: Readonly<Record<string, string>>;
|
|
192
|
+
readonly signal?: AbortSignal;
|
|
193
|
+
}): Promise<{
|
|
194
|
+
readonly requestId: string;
|
|
195
|
+
readonly locator: string;
|
|
196
|
+
readonly expiresAt: string;
|
|
197
|
+
readonly correlationId: string;
|
|
198
|
+
}>;
|
|
199
|
+
state(requestId: string, verifier: string, signal?: AbortSignal): Promise<CredentialRequestState>;
|
|
200
|
+
beginStep(requestId: string, verifier: string, stepId: "collect_input" | "mailbox_otp", signal?: AbortSignal): Promise<void>;
|
|
201
|
+
submitStep(requestId: string, verifier: string, stepId: string, proof: PrimitiveStepResult, signal?: AbortSignal): Promise<void>;
|
|
202
|
+
holderBinding(requestId: string, verifier: string, signal?: AbortSignal): Promise<CredentialHolderBinding>;
|
|
203
|
+
submitHolderSignature(requestId: string, verifier: string, signature: string, signal?: AbortSignal, key?: HolderSignatureKey): Promise<void>;
|
|
204
|
+
issue(requestId: string, verifier: string, signal?: AbortSignal): Promise<void>;
|
|
205
|
+
result(requestId: string, verifier: string, signal?: AbortSignal): Promise<IssuedCredentialEnvelope>;
|
|
206
|
+
issuerMetadata(signal?: AbortSignal): Promise<CredentialIssuerMetadata>;
|
|
207
|
+
checkStatus(status: IssuedCredentialEnvelope["status"], signal?: AbortSignal): Promise<boolean>;
|
|
208
|
+
}
|
|
209
|
+
interface CredentialsOperationOptions {
|
|
210
|
+
readonly descriptor?: CredentialFlowDescriptor;
|
|
211
|
+
readonly discoveryUrl?: string;
|
|
212
|
+
readonly fetch?: typeof fetch;
|
|
213
|
+
readonly signal?: AbortSignal;
|
|
214
|
+
readonly timeoutMs?: number;
|
|
215
|
+
readonly onProgress?: (event: CredentialProgressEvent) => void;
|
|
216
|
+
readonly now?: () => Date;
|
|
217
|
+
}
|
|
218
|
+
interface CredentialsAcquireOptions extends CredentialsOperationOptions {
|
|
219
|
+
/**
|
|
220
|
+
* `inline` mounts the first-party TinyCloud element unless a bounded local
|
|
221
|
+
* proof adapter is explicitly supplied.
|
|
222
|
+
*/
|
|
223
|
+
readonly interaction?: CredentialInteractionKind;
|
|
224
|
+
readonly browser?: CredentialInteractionAdapter;
|
|
225
|
+
/** Presentation-only tokens. Security-critical copy and proof order are fixed by the descriptor. */
|
|
226
|
+
readonly theme?: CredentialAcquisitionTheme;
|
|
227
|
+
readonly transport?: CredentialAcquisitionTransport;
|
|
228
|
+
readonly signing?: CredentialSigningAdapter;
|
|
229
|
+
readonly stepHandlers?: Partial<Record<"collect_input" | "mailbox_otp", PrimitiveStepHandler>>;
|
|
230
|
+
readonly openerOrigin?: string;
|
|
231
|
+
/** Same-origin, request-scoped persistence used to resume a full-page redirect. */
|
|
232
|
+
readonly redirectStore?: CredentialRedirectStore;
|
|
233
|
+
/**
|
|
234
|
+
* Acquisition inputs the requirement does not carry (for example a
|
|
235
|
+
* recipient-chosen mailbox for an email-domain requirement). When omitted,
|
|
236
|
+
* an inline surface collects them.
|
|
237
|
+
*/
|
|
238
|
+
readonly inputs?: Readonly<Record<string, string>>;
|
|
239
|
+
}
|
|
240
|
+
interface CredentialAcquisitionTheme {
|
|
241
|
+
readonly accentColor?: string;
|
|
242
|
+
readonly backgroundColor?: string;
|
|
243
|
+
readonly textColor?: string;
|
|
244
|
+
}
|
|
245
|
+
interface CredentialsEnsureOptions extends CredentialsAcquireOptions {
|
|
246
|
+
}
|
|
247
|
+
interface CredentialsEnsureResult {
|
|
248
|
+
readonly status: "reused" | "acquired";
|
|
249
|
+
readonly credential: VerifiedCredential;
|
|
250
|
+
readonly record: StoredCredentialRecord;
|
|
251
|
+
readonly receipt?: CredentialStorageReceipt;
|
|
252
|
+
}
|
|
253
|
+
interface CredentialsPolicyAdmissionOptions {
|
|
254
|
+
readonly ensured: CredentialsEnsureResult;
|
|
255
|
+
readonly policy: UnifiedPolicyV2;
|
|
256
|
+
readonly policyCid: string;
|
|
257
|
+
readonly policyRootCid: string;
|
|
258
|
+
readonly enforcementRootCid: string;
|
|
259
|
+
readonly requirement: CredentialRequirement;
|
|
260
|
+
readonly requestedCapabilities: readonly UnifiedPolicyCapability[];
|
|
261
|
+
readonly nodeOrigin: string;
|
|
262
|
+
/** How long the minted session should last; see `admitPolicyCredentialV3`. */
|
|
263
|
+
readonly requestedExpiresAt?: string | null;
|
|
264
|
+
readonly fetch?: typeof fetch;
|
|
265
|
+
readonly signal?: AbortSignal;
|
|
266
|
+
readonly now?: Date;
|
|
267
|
+
readonly jti?: string;
|
|
268
|
+
}
|
|
269
|
+
interface CredentialsPolicyAdmissionResult extends PolicyCredentialAdmissionV3 {
|
|
270
|
+
readonly installed: ValidatedRuntimeDelegation;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** The mailbox named by an email requirement, which the issuer delivers the code to. */
|
|
274
|
+
declare function mailboxSubject(requirement: CredentialRequirement): CredentialProofSubject | undefined;
|
|
275
|
+
/** Finite step interpreter. Dispatch is exclusively by registered primitive and version. */
|
|
276
|
+
declare function interpretCredentialFlow(input: {
|
|
277
|
+
readonly descriptor: CredentialFlowDescriptor;
|
|
278
|
+
readonly requirement: CredentialRequirement;
|
|
279
|
+
readonly requestId: string;
|
|
280
|
+
readonly verifier: string;
|
|
281
|
+
readonly holderDid: string;
|
|
282
|
+
readonly descriptorDigest: string;
|
|
283
|
+
readonly requirementDigest: string;
|
|
284
|
+
readonly openerOrigin: string;
|
|
285
|
+
readonly transport: CredentialAcquisitionTransport;
|
|
286
|
+
readonly signing: CredentialSigningAdapter;
|
|
287
|
+
/**
|
|
288
|
+
* Fallback for a host-owned surface. It receives every declared proof step,
|
|
289
|
+
* including primitives added by a later protocol version.
|
|
290
|
+
*/
|
|
291
|
+
readonly proofHandler?: InlineCredentialProofHandler;
|
|
292
|
+
readonly handlers?: Partial<Record<"collect_input" | "mailbox_otp", PrimitiveStepHandler>>;
|
|
293
|
+
readonly signal?: AbortSignal;
|
|
294
|
+
readonly onProgress?: (event: CredentialProgressEvent) => void;
|
|
295
|
+
readonly onWait?: () => Promise<void>;
|
|
296
|
+
}): Promise<void>;
|
|
297
|
+
|
|
298
|
+
declare class OpenCredentialsHttpTransport implements CredentialAcquisitionTransport {
|
|
299
|
+
private readonly descriptor;
|
|
300
|
+
private readonly fetchFn;
|
|
301
|
+
private readonly options;
|
|
302
|
+
private readonly nonces;
|
|
303
|
+
private readonly bindings;
|
|
304
|
+
constructor(descriptor: CredentialFlowDescriptor, fetchFn?: typeof fetch, options?: {
|
|
305
|
+
readonly honorServerRecoverable?: boolean;
|
|
306
|
+
});
|
|
307
|
+
private url;
|
|
308
|
+
private request;
|
|
309
|
+
create(input: {
|
|
310
|
+
descriptor: CredentialFlowDescriptor;
|
|
311
|
+
descriptorDigest: string;
|
|
312
|
+
requirement: CredentialRequirement;
|
|
313
|
+
requirementDigest: string;
|
|
314
|
+
holderDid: string;
|
|
315
|
+
openerOrigin: string;
|
|
316
|
+
completionVerifierChallenge: string;
|
|
317
|
+
inputs?: Readonly<Record<string, string>>;
|
|
318
|
+
signal?: AbortSignal;
|
|
319
|
+
}): Promise<{
|
|
320
|
+
requestId: string;
|
|
321
|
+
locator: string;
|
|
322
|
+
expiresAt: string;
|
|
323
|
+
correlationId: string;
|
|
324
|
+
}>;
|
|
325
|
+
private proofStep;
|
|
326
|
+
state(id: string, verifier: string, signal?: AbortSignal): Promise<CredentialRequestState>;
|
|
327
|
+
beginStep(id: string, verifier: string, stepId: "collect_input" | "mailbox_otp", signal?: AbortSignal): Promise<void>;
|
|
328
|
+
submitStep(id: string, verifier: string, stepId: string, proof: PrimitiveStepResult, signal?: AbortSignal): Promise<void>;
|
|
329
|
+
holderBinding(id: string, verifier: string, signal?: AbortSignal): Promise<CredentialHolderBinding>;
|
|
330
|
+
submitHolderSignature(id: string, verifier: string, signature: string, signal?: AbortSignal, key?: HolderSignatureKey): Promise<void>;
|
|
331
|
+
issue(id: string, verifier: string, signal?: AbortSignal): Promise<void>;
|
|
332
|
+
result(id: string, verifier: string, signal?: AbortSignal): Promise<IssuedCredentialEnvelope>;
|
|
333
|
+
issuerMetadata(signal?: AbortSignal): Promise<CredentialIssuerMetadata>;
|
|
334
|
+
checkStatus(status: IssuedCredentialEnvelope["status"], _signal?: AbortSignal): Promise<boolean>;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export { type CredentialAcquisitionTheme, type CredentialAcquisitionTransport, type CredentialBrowserInteractionAdapter, type CredentialClient, type CredentialInlineInteractionAdapter, type CredentialInputRequest, type CredentialInteractionAdapter, type CredentialInteractionKind, type CredentialInteractionSurface, type CredentialProofSubject, type CredentialRedirectResumeState, type CredentialRedirectStore, type CredentialRequestState, type CredentialSigningAdapter, type CredentialsAcquireOptions, type CredentialsEnsureOptions, type CredentialsEnsureResult, type CredentialsOperationOptions, type CredentialsPolicyAdmissionOptions, type CredentialsPolicyAdmissionResult, type HolderSignatureKey, type InlineCredentialProofHandler, type InlineCredentialProofRequest, OpenCredentialsHttpTransport, type PrimitiveStepHandler, type PrimitiveStepResult, type ReceiverCredentialCustody, interpretCredentialFlow, mailboxSubject };
|
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
import { CredentialFlowDescriptor, CredentialRequirement, CredentialHolderBinding, IssuedCredentialEnvelope, CredentialIssuerMetadata, ClientSession, IKVService, StoredCredentialRecord, VerifiedCredential, CredentialProgressEvent, CredentialStorageReceipt, UnifiedPolicyV2, UnifiedPolicyCapability, PolicyCredentialAdmissionV3 } from '@tinycloud/sdk-core';
|
|
2
|
+
import { V as ValidatedRuntimeDelegation } from './delegation-0LKZkmP2.js';
|
|
3
|
+
|
|
4
|
+
interface CredentialClient {
|
|
5
|
+
readonly sessionDid: string;
|
|
6
|
+
readonly credentialHolderDid: string;
|
|
7
|
+
readonly credentialHolderKid: string;
|
|
8
|
+
session(): ClientSession | undefined;
|
|
9
|
+
signSessionBytes(bytes: Uint8Array): Promise<Uint8Array>;
|
|
10
|
+
autoSignCredentialBytes?(bytes: Uint8Array): Promise<Uint8Array | undefined>;
|
|
11
|
+
approveCredentialBytes?(bytes: Uint8Array): Promise<Uint8Array>;
|
|
12
|
+
activateCompactRuntimeDelegation?(input: {
|
|
13
|
+
readonly authorization: string;
|
|
14
|
+
readonly cid: string;
|
|
15
|
+
readonly host: string;
|
|
16
|
+
}): Promise<ValidatedRuntimeDelegation>;
|
|
17
|
+
ensureOwnedSpaceHosted(name: string): Promise<string>;
|
|
18
|
+
credentialSpaceOwnerDid(spaceId: string): string;
|
|
19
|
+
kvForSpace(spaceId: string): IKVService;
|
|
20
|
+
/**
|
|
21
|
+
* Root authorization CID of the active account session. Exposed here rather
|
|
22
|
+
* than on {@link ClientSession} so the CID stays out of the public session.
|
|
23
|
+
*/
|
|
24
|
+
accountAuthorizationCid(): string;
|
|
25
|
+
/** Receiver-local credential custody. Its presence selects accountless mode. */
|
|
26
|
+
readonly receiverCredentialCustody?: ReceiverCredentialCustody;
|
|
27
|
+
}
|
|
28
|
+
interface ReceiverCredentialCustody {
|
|
29
|
+
find(input: {
|
|
30
|
+
readonly requirement: CredentialRequirement;
|
|
31
|
+
readonly requirementDigest: string;
|
|
32
|
+
readonly holderDid: string;
|
|
33
|
+
readonly now?: Date;
|
|
34
|
+
}): Promise<StoredCredentialRecord | undefined>;
|
|
35
|
+
store(input: {
|
|
36
|
+
readonly verified: VerifiedCredential;
|
|
37
|
+
readonly requirement: CredentialRequirement;
|
|
38
|
+
readonly requirementDigest: string;
|
|
39
|
+
readonly holderDid: string;
|
|
40
|
+
readonly now?: Date;
|
|
41
|
+
}): Promise<StoredCredentialRecord>;
|
|
42
|
+
}
|
|
43
|
+
/** Holder key the witness verifies against. Sent on the wire with the holder signature. */
|
|
44
|
+
interface HolderSignatureKey {
|
|
45
|
+
readonly alg: "EdDSA";
|
|
46
|
+
readonly kid: string;
|
|
47
|
+
}
|
|
48
|
+
interface CredentialSigningAdapter {
|
|
49
|
+
/** Return undefined when the existing exact-request auto-sign policy does not apply. */
|
|
50
|
+
readonly autoSign?: (binding: CredentialHolderBinding, bytes: Uint8Array, signal?: AbortSignal) => Promise<Uint8Array | undefined>;
|
|
51
|
+
/** Invoke the normal OpenKey approval surface. */
|
|
52
|
+
readonly requestApproval?: (binding: CredentialHolderBinding, bytes: Uint8Array, signal?: AbortSignal) => Promise<Uint8Array>;
|
|
53
|
+
/** Wire identity for the holder signature. Omitted by root callers: the transport then sends EdDSA with the did:key kid. */
|
|
54
|
+
readonly holderKey?: HolderSignatureKey;
|
|
55
|
+
}
|
|
56
|
+
type PrimitiveStepResult = Readonly<Record<string, string | boolean>>;
|
|
57
|
+
type PrimitiveStepHandler = (input: {
|
|
58
|
+
readonly descriptor: CredentialFlowDescriptor;
|
|
59
|
+
readonly requirement: CredentialRequirement;
|
|
60
|
+
readonly stepId: string;
|
|
61
|
+
readonly constraints: Readonly<Record<string, unknown>>;
|
|
62
|
+
readonly signal?: AbortSignal;
|
|
63
|
+
}) => Promise<PrimitiveStepResult>;
|
|
64
|
+
/**
|
|
65
|
+
* The bounded view a host-owned inline surface may receive. It deliberately
|
|
66
|
+
* excludes requirement values, which can contain private policy inputs.
|
|
67
|
+
*/
|
|
68
|
+
interface InlineCredentialProofRequest {
|
|
69
|
+
readonly stepId: string;
|
|
70
|
+
readonly constraints: Readonly<Record<string, unknown>>;
|
|
71
|
+
readonly display: {
|
|
72
|
+
readonly title: string;
|
|
73
|
+
readonly description: string;
|
|
74
|
+
readonly consent: string;
|
|
75
|
+
readonly progressLabel: string;
|
|
76
|
+
readonly errorLiveRegion: "assertive";
|
|
77
|
+
};
|
|
78
|
+
readonly inputs: readonly {
|
|
79
|
+
readonly id: string;
|
|
80
|
+
readonly label: string;
|
|
81
|
+
readonly schema: CredentialFlowDescriptor["inputs"][number]["schema"];
|
|
82
|
+
}[];
|
|
83
|
+
/** Present when this step's previous proof was rejected and may be retried. */
|
|
84
|
+
readonly feedback?: {
|
|
85
|
+
readonly kind: "rejected";
|
|
86
|
+
readonly attemptsRemaining: number;
|
|
87
|
+
};
|
|
88
|
+
readonly signal?: AbortSignal;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The mailbox a `mailbox_otp` code is sent to, copied from the digest-bound
|
|
92
|
+
* credential requirement. Only the SDK-owned inline view receives it; host
|
|
93
|
+
* proof handlers never see requirement values.
|
|
94
|
+
*/
|
|
95
|
+
interface CredentialProofSubject {
|
|
96
|
+
readonly kind: "email";
|
|
97
|
+
readonly value: string;
|
|
98
|
+
}
|
|
99
|
+
type InlineCredentialProofHandler = (input: InlineCredentialProofRequest) => Promise<PrimitiveStepResult>;
|
|
100
|
+
type CredentialInteractionKind = "popup" | "redirect" | "headless" | "inline";
|
|
101
|
+
interface CredentialInteractionSurface {
|
|
102
|
+
readonly wake: () => Promise<void>;
|
|
103
|
+
readonly close: () => void;
|
|
104
|
+
readonly closed: () => boolean;
|
|
105
|
+
/**
|
|
106
|
+
* A bounded, local UI callback for a declared primitive step. The adapter
|
|
107
|
+
* returns user-entered proof bytes to the SDK; it never receives an
|
|
108
|
+
* acquisition locator, request verifier, or transport capability.
|
|
109
|
+
*/
|
|
110
|
+
readonly requestProof?: InlineCredentialProofHandler;
|
|
111
|
+
/**
|
|
112
|
+
* Collects descriptor inputs the requirement does not already supply, such
|
|
113
|
+
* as the recipient's own mailbox for an email-domain requirement. It
|
|
114
|
+
* receives only the input schema and the public domain constraint.
|
|
115
|
+
*/
|
|
116
|
+
readonly requestInputs?: (request: CredentialInputRequest) => Promise<Readonly<Record<string, string>>>;
|
|
117
|
+
}
|
|
118
|
+
interface CredentialInputRequest {
|
|
119
|
+
readonly inputs: readonly {
|
|
120
|
+
readonly id: string;
|
|
121
|
+
readonly label: string;
|
|
122
|
+
readonly schema: CredentialFlowDescriptor["inputs"][number]["schema"];
|
|
123
|
+
}[];
|
|
124
|
+
/** The exact canonical domain the entered mailbox must belong to. */
|
|
125
|
+
readonly mailboxDomain?: string;
|
|
126
|
+
readonly signal?: AbortSignal;
|
|
127
|
+
}
|
|
128
|
+
/** A browser-owned interaction that navigates to the OpenCredentials locator. */
|
|
129
|
+
interface CredentialBrowserInteractionAdapter {
|
|
130
|
+
readonly kind: Exclude<CredentialInteractionKind, "inline">;
|
|
131
|
+
start(input: {
|
|
132
|
+
readonly interaction: CredentialFlowDescriptor["interaction"];
|
|
133
|
+
readonly locator: string;
|
|
134
|
+
readonly signal?: AbortSignal;
|
|
135
|
+
}): Promise<CredentialInteractionSurface>;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* A host-owned, in-page acquisition surface. It intentionally receives no
|
|
139
|
+
* OpenCredentials locator, request verifier, or transport capability. The SDK
|
|
140
|
+
* owns every OpenCredentials request, including submission of returned proof.
|
|
141
|
+
*/
|
|
142
|
+
interface CredentialInlineInteractionAdapter {
|
|
143
|
+
readonly kind: "inline";
|
|
144
|
+
start(input: {
|
|
145
|
+
readonly signal?: AbortSignal;
|
|
146
|
+
}): Promise<CredentialInteractionSurface>;
|
|
147
|
+
}
|
|
148
|
+
type CredentialInteractionAdapter = CredentialBrowserInteractionAdapter | CredentialInlineInteractionAdapter;
|
|
149
|
+
interface CredentialRedirectResumeState {
|
|
150
|
+
readonly type: "TinyCloudCredentialRedirectResume";
|
|
151
|
+
readonly version: 1;
|
|
152
|
+
readonly requestId: string;
|
|
153
|
+
readonly locator: string;
|
|
154
|
+
readonly verifier: string;
|
|
155
|
+
readonly expiresAt: string;
|
|
156
|
+
readonly correlationId: string;
|
|
157
|
+
readonly holderDid: string;
|
|
158
|
+
readonly descriptorDigest: string;
|
|
159
|
+
readonly requirementDigest: string;
|
|
160
|
+
readonly openerOrigin: string;
|
|
161
|
+
}
|
|
162
|
+
interface CredentialRedirectStore {
|
|
163
|
+
load(): Promise<CredentialRedirectResumeState | undefined>;
|
|
164
|
+
save(state: CredentialRedirectResumeState): Promise<void>;
|
|
165
|
+
clear(): Promise<void>;
|
|
166
|
+
}
|
|
167
|
+
interface CredentialRequestState {
|
|
168
|
+
readonly type: "OpenCredentialsAcquisitionState";
|
|
169
|
+
readonly version: 1;
|
|
170
|
+
readonly requestId: string;
|
|
171
|
+
readonly transitionId: string;
|
|
172
|
+
readonly state: "pending" | "ready_to_issue" | "issued" | "complete" | "expired" | "canceled" | "issuer_unready";
|
|
173
|
+
readonly nextStep?: {
|
|
174
|
+
readonly id: string;
|
|
175
|
+
readonly type: "collect_input" | "mailbox_otp" | "holder_signature";
|
|
176
|
+
readonly version: 1;
|
|
177
|
+
readonly constraints: Readonly<Record<string, unknown>>;
|
|
178
|
+
};
|
|
179
|
+
readonly retryAfterMs?: number;
|
|
180
|
+
readonly correlationId: string;
|
|
181
|
+
}
|
|
182
|
+
interface CredentialAcquisitionTransport {
|
|
183
|
+
create(input: {
|
|
184
|
+
readonly descriptor: CredentialFlowDescriptor;
|
|
185
|
+
readonly descriptorDigest: string;
|
|
186
|
+
readonly requirement: CredentialRequirement;
|
|
187
|
+
readonly requirementDigest: string;
|
|
188
|
+
readonly holderDid: string;
|
|
189
|
+
readonly openerOrigin: string;
|
|
190
|
+
readonly completionVerifierChallenge: string;
|
|
191
|
+
readonly inputs?: Readonly<Record<string, string>>;
|
|
192
|
+
readonly signal?: AbortSignal;
|
|
193
|
+
}): Promise<{
|
|
194
|
+
readonly requestId: string;
|
|
195
|
+
readonly locator: string;
|
|
196
|
+
readonly expiresAt: string;
|
|
197
|
+
readonly correlationId: string;
|
|
198
|
+
}>;
|
|
199
|
+
state(requestId: string, verifier: string, signal?: AbortSignal): Promise<CredentialRequestState>;
|
|
200
|
+
beginStep(requestId: string, verifier: string, stepId: "collect_input" | "mailbox_otp", signal?: AbortSignal): Promise<void>;
|
|
201
|
+
submitStep(requestId: string, verifier: string, stepId: string, proof: PrimitiveStepResult, signal?: AbortSignal): Promise<void>;
|
|
202
|
+
holderBinding(requestId: string, verifier: string, signal?: AbortSignal): Promise<CredentialHolderBinding>;
|
|
203
|
+
submitHolderSignature(requestId: string, verifier: string, signature: string, signal?: AbortSignal, key?: HolderSignatureKey): Promise<void>;
|
|
204
|
+
issue(requestId: string, verifier: string, signal?: AbortSignal): Promise<void>;
|
|
205
|
+
result(requestId: string, verifier: string, signal?: AbortSignal): Promise<IssuedCredentialEnvelope>;
|
|
206
|
+
issuerMetadata(signal?: AbortSignal): Promise<CredentialIssuerMetadata>;
|
|
207
|
+
checkStatus(status: IssuedCredentialEnvelope["status"], signal?: AbortSignal): Promise<boolean>;
|
|
208
|
+
}
|
|
209
|
+
interface CredentialsOperationOptions {
|
|
210
|
+
readonly descriptor?: CredentialFlowDescriptor;
|
|
211
|
+
readonly discoveryUrl?: string;
|
|
212
|
+
readonly fetch?: typeof fetch;
|
|
213
|
+
readonly signal?: AbortSignal;
|
|
214
|
+
readonly timeoutMs?: number;
|
|
215
|
+
readonly onProgress?: (event: CredentialProgressEvent) => void;
|
|
216
|
+
readonly now?: () => Date;
|
|
217
|
+
}
|
|
218
|
+
interface CredentialsAcquireOptions extends CredentialsOperationOptions {
|
|
219
|
+
/**
|
|
220
|
+
* `inline` mounts the first-party TinyCloud element unless a bounded local
|
|
221
|
+
* proof adapter is explicitly supplied.
|
|
222
|
+
*/
|
|
223
|
+
readonly interaction?: CredentialInteractionKind;
|
|
224
|
+
readonly browser?: CredentialInteractionAdapter;
|
|
225
|
+
/** Presentation-only tokens. Security-critical copy and proof order are fixed by the descriptor. */
|
|
226
|
+
readonly theme?: CredentialAcquisitionTheme;
|
|
227
|
+
readonly transport?: CredentialAcquisitionTransport;
|
|
228
|
+
readonly signing?: CredentialSigningAdapter;
|
|
229
|
+
readonly stepHandlers?: Partial<Record<"collect_input" | "mailbox_otp", PrimitiveStepHandler>>;
|
|
230
|
+
readonly openerOrigin?: string;
|
|
231
|
+
/** Same-origin, request-scoped persistence used to resume a full-page redirect. */
|
|
232
|
+
readonly redirectStore?: CredentialRedirectStore;
|
|
233
|
+
/**
|
|
234
|
+
* Acquisition inputs the requirement does not carry (for example a
|
|
235
|
+
* recipient-chosen mailbox for an email-domain requirement). When omitted,
|
|
236
|
+
* an inline surface collects them.
|
|
237
|
+
*/
|
|
238
|
+
readonly inputs?: Readonly<Record<string, string>>;
|
|
239
|
+
}
|
|
240
|
+
interface CredentialAcquisitionTheme {
|
|
241
|
+
readonly accentColor?: string;
|
|
242
|
+
readonly backgroundColor?: string;
|
|
243
|
+
readonly textColor?: string;
|
|
244
|
+
}
|
|
245
|
+
interface CredentialsEnsureOptions extends CredentialsAcquireOptions {
|
|
246
|
+
}
|
|
247
|
+
interface CredentialsEnsureResult {
|
|
248
|
+
readonly status: "reused" | "acquired";
|
|
249
|
+
readonly credential: VerifiedCredential;
|
|
250
|
+
readonly record: StoredCredentialRecord;
|
|
251
|
+
readonly receipt?: CredentialStorageReceipt;
|
|
252
|
+
}
|
|
253
|
+
interface CredentialsPolicyAdmissionOptions {
|
|
254
|
+
readonly ensured: CredentialsEnsureResult;
|
|
255
|
+
readonly policy: UnifiedPolicyV2;
|
|
256
|
+
readonly policyCid: string;
|
|
257
|
+
readonly policyRootCid: string;
|
|
258
|
+
readonly enforcementRootCid: string;
|
|
259
|
+
readonly requirement: CredentialRequirement;
|
|
260
|
+
readonly requestedCapabilities: readonly UnifiedPolicyCapability[];
|
|
261
|
+
readonly nodeOrigin: string;
|
|
262
|
+
/** How long the minted session should last; see `admitPolicyCredentialV3`. */
|
|
263
|
+
readonly requestedExpiresAt?: string | null;
|
|
264
|
+
readonly fetch?: typeof fetch;
|
|
265
|
+
readonly signal?: AbortSignal;
|
|
266
|
+
readonly now?: Date;
|
|
267
|
+
readonly jti?: string;
|
|
268
|
+
}
|
|
269
|
+
interface CredentialsPolicyAdmissionResult extends PolicyCredentialAdmissionV3 {
|
|
270
|
+
readonly installed: ValidatedRuntimeDelegation;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/** The mailbox named by an email requirement, which the issuer delivers the code to. */
|
|
274
|
+
declare function mailboxSubject(requirement: CredentialRequirement): CredentialProofSubject | undefined;
|
|
275
|
+
/** Finite step interpreter. Dispatch is exclusively by registered primitive and version. */
|
|
276
|
+
declare function interpretCredentialFlow(input: {
|
|
277
|
+
readonly descriptor: CredentialFlowDescriptor;
|
|
278
|
+
readonly requirement: CredentialRequirement;
|
|
279
|
+
readonly requestId: string;
|
|
280
|
+
readonly verifier: string;
|
|
281
|
+
readonly holderDid: string;
|
|
282
|
+
readonly descriptorDigest: string;
|
|
283
|
+
readonly requirementDigest: string;
|
|
284
|
+
readonly openerOrigin: string;
|
|
285
|
+
readonly transport: CredentialAcquisitionTransport;
|
|
286
|
+
readonly signing: CredentialSigningAdapter;
|
|
287
|
+
/**
|
|
288
|
+
* Fallback for a host-owned surface. It receives every declared proof step,
|
|
289
|
+
* including primitives added by a later protocol version.
|
|
290
|
+
*/
|
|
291
|
+
readonly proofHandler?: InlineCredentialProofHandler;
|
|
292
|
+
readonly handlers?: Partial<Record<"collect_input" | "mailbox_otp", PrimitiveStepHandler>>;
|
|
293
|
+
readonly signal?: AbortSignal;
|
|
294
|
+
readonly onProgress?: (event: CredentialProgressEvent) => void;
|
|
295
|
+
readonly onWait?: () => Promise<void>;
|
|
296
|
+
}): Promise<void>;
|
|
297
|
+
|
|
298
|
+
declare class OpenCredentialsHttpTransport implements CredentialAcquisitionTransport {
|
|
299
|
+
private readonly descriptor;
|
|
300
|
+
private readonly fetchFn;
|
|
301
|
+
private readonly options;
|
|
302
|
+
private readonly nonces;
|
|
303
|
+
private readonly bindings;
|
|
304
|
+
constructor(descriptor: CredentialFlowDescriptor, fetchFn?: typeof fetch, options?: {
|
|
305
|
+
readonly honorServerRecoverable?: boolean;
|
|
306
|
+
});
|
|
307
|
+
private url;
|
|
308
|
+
private request;
|
|
309
|
+
create(input: {
|
|
310
|
+
descriptor: CredentialFlowDescriptor;
|
|
311
|
+
descriptorDigest: string;
|
|
312
|
+
requirement: CredentialRequirement;
|
|
313
|
+
requirementDigest: string;
|
|
314
|
+
holderDid: string;
|
|
315
|
+
openerOrigin: string;
|
|
316
|
+
completionVerifierChallenge: string;
|
|
317
|
+
inputs?: Readonly<Record<string, string>>;
|
|
318
|
+
signal?: AbortSignal;
|
|
319
|
+
}): Promise<{
|
|
320
|
+
requestId: string;
|
|
321
|
+
locator: string;
|
|
322
|
+
expiresAt: string;
|
|
323
|
+
correlationId: string;
|
|
324
|
+
}>;
|
|
325
|
+
private proofStep;
|
|
326
|
+
state(id: string, verifier: string, signal?: AbortSignal): Promise<CredentialRequestState>;
|
|
327
|
+
beginStep(id: string, verifier: string, stepId: "collect_input" | "mailbox_otp", signal?: AbortSignal): Promise<void>;
|
|
328
|
+
submitStep(id: string, verifier: string, stepId: string, proof: PrimitiveStepResult, signal?: AbortSignal): Promise<void>;
|
|
329
|
+
holderBinding(id: string, verifier: string, signal?: AbortSignal): Promise<CredentialHolderBinding>;
|
|
330
|
+
submitHolderSignature(id: string, verifier: string, signature: string, signal?: AbortSignal, key?: HolderSignatureKey): Promise<void>;
|
|
331
|
+
issue(id: string, verifier: string, signal?: AbortSignal): Promise<void>;
|
|
332
|
+
result(id: string, verifier: string, signal?: AbortSignal): Promise<IssuedCredentialEnvelope>;
|
|
333
|
+
issuerMetadata(signal?: AbortSignal): Promise<CredentialIssuerMetadata>;
|
|
334
|
+
checkStatus(status: IssuedCredentialEnvelope["status"], _signal?: AbortSignal): Promise<boolean>;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
export { type CredentialAcquisitionTheme, type CredentialAcquisitionTransport, type CredentialBrowserInteractionAdapter, type CredentialClient, type CredentialInlineInteractionAdapter, type CredentialInputRequest, type CredentialInteractionAdapter, type CredentialInteractionKind, type CredentialInteractionSurface, type CredentialProofSubject, type CredentialRedirectResumeState, type CredentialRedirectStore, type CredentialRequestState, type CredentialSigningAdapter, type CredentialsAcquireOptions, type CredentialsEnsureOptions, type CredentialsEnsureResult, type CredentialsOperationOptions, type CredentialsPolicyAdmissionOptions, type CredentialsPolicyAdmissionResult, type HolderSignatureKey, type InlineCredentialProofHandler, type InlineCredentialProofRequest, OpenCredentialsHttpTransport, type PrimitiveStepHandler, type PrimitiveStepResult, type ReceiverCredentialCustody, interpretCredentialFlow, mailboxSubject };
|