@tinycloud/web-sdk 2.11.0-beta.9 → 3.0.0-beta.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/dist/adapters/BrowserENSResolver.d.ts +3 -3
- package/dist/adapters/BrowserWalletSigner.d.ts +7 -8
- package/dist/adapters/browserProvider.d.ts +6 -0
- package/dist/adapters/index.d.ts +1 -0
- package/dist/credentials/browser.d.ts +49 -0
- package/dist/credentials/element.d.ts +42 -0
- package/dist/credentials/index.d.ts +9 -0
- package/dist/credentials/interpreter.d.ts +25 -0
- package/dist/credentials/renderer.d.ts +23 -0
- package/dist/credentials/service.d.ts +26 -0
- package/dist/credentials/storage.d.ts +21 -0
- package/dist/credentials/transport.d.ts +37 -0
- package/dist/credentials/types.d.ts +209 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.mjs +1 -1
- package/dist/modules/tcw.d.ts +33 -6
- package/dist/openkey-session.d.ts +4 -2
- package/dist/providers/extension.d.ts +3 -3
- package/dist/providers/types.d.ts +9 -6
- package/dist/providers/utils.d.ts +4 -9
- package/package.json +4 -9
- package/dist/modules/registry/Registry.d.ts +0 -59
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IENSResolver } from "@tinycloud/sdk-core";
|
|
2
|
-
import {
|
|
2
|
+
import type { BrowserWalletProvider } from "./browserProvider";
|
|
3
3
|
export declare class BrowserENSResolver implements IENSResolver {
|
|
4
|
-
private provider;
|
|
5
|
-
constructor(provider:
|
|
4
|
+
private readonly provider;
|
|
5
|
+
constructor(provider: BrowserWalletProvider);
|
|
6
6
|
resolveAddress(ensName: string): Promise<string | null>;
|
|
7
7
|
resolveName(address: string): Promise<string | null>;
|
|
8
8
|
resolveAvatar(ensName: string): Promise<string | null>;
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import { ISigner, Bytes } from "@tinycloud/sdk-core";
|
|
2
|
-
import {
|
|
2
|
+
import { type BrowserProvider, type BrowserWalletProvider } from "./browserProvider";
|
|
3
3
|
/**
|
|
4
|
-
* Browser wallet signer that wraps
|
|
4
|
+
* Browser wallet signer that wraps an EIP-1193 provider.
|
|
5
5
|
* Supports MetaMask, WalletConnect, and any EIP-1193 provider.
|
|
6
6
|
*
|
|
7
|
-
* The wallet popup is triggered
|
|
8
|
-
*
|
|
7
|
+
* The wallet popup is triggered by eth_requestAccounts when getAddress() is
|
|
8
|
+
* called -- no separate "strategy" type needed.
|
|
9
9
|
*/
|
|
10
10
|
export declare class BrowserWalletSigner implements ISigner {
|
|
11
11
|
private provider;
|
|
12
|
-
private signer;
|
|
13
12
|
private cachedAddress?;
|
|
14
13
|
private cachedChainId?;
|
|
15
|
-
constructor(
|
|
14
|
+
constructor(provider: BrowserWalletProvider);
|
|
16
15
|
getAddress(): Promise<string>;
|
|
17
16
|
getConnectedAddress(): Promise<string | undefined>;
|
|
18
17
|
getChainId(): Promise<number>;
|
|
19
18
|
signMessage(message: Bytes | string): Promise<string>;
|
|
20
|
-
/** Get the underlying
|
|
21
|
-
getProvider():
|
|
19
|
+
/** Get the underlying EIP-1193 provider (for advanced use). */
|
|
20
|
+
getProvider(): BrowserProvider;
|
|
22
21
|
}
|
|
23
22
|
//# sourceMappingURL=BrowserWalletSigner.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { EIP1193Provider } from "viem";
|
|
2
|
+
/** The EIP-1193 provider supplied by an injected wallet. */
|
|
3
|
+
export type BrowserWalletProvider = EIP1193Provider;
|
|
4
|
+
/** The EIP-1193 provider used by the browser-facing SDK. */
|
|
5
|
+
export type BrowserProvider = EIP1193Provider;
|
|
6
|
+
//# sourceMappingURL=browserProvider.d.ts.map
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { BrowserWalletSigner } from "./BrowserWalletSigner";
|
|
2
|
+
export { type BrowserProvider, type BrowserWalletProvider, } from "./browserProvider";
|
|
2
3
|
export { BrowserSessionStorage } from "./BrowserSessionStorage";
|
|
3
4
|
export type { BrowserSessionLoadResult, BrowserSessionLoadStatus, BrowserSessionStorageOptions, } from "./BrowserSessionStorage";
|
|
4
5
|
export { BrowserENSResolver } from "./BrowserENSResolver";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { CredentialFlowDescriptor } from "@tinycloud/sdk-core";
|
|
2
|
+
import type { CredentialBrowserInteractionAdapter, CredentialInlineInteractionAdapter, CredentialInteractionSurface, CredentialRedirectResumeState, CredentialRedirectStore } from "./types";
|
|
3
|
+
interface BrowserSurface {
|
|
4
|
+
readonly opener: Window;
|
|
5
|
+
open(url: string): Window | null;
|
|
6
|
+
redirect(url: string): void;
|
|
7
|
+
}
|
|
8
|
+
/** Exact-origin, locator-only browser interaction. Messages are non-secret wake signals. */
|
|
9
|
+
export declare class BrowserCredentialInteraction implements CredentialBrowserInteractionAdapter {
|
|
10
|
+
private readonly surface;
|
|
11
|
+
readonly kind: "popup" | "redirect";
|
|
12
|
+
constructor(kind?: "popup" | "redirect", surface?: BrowserSurface);
|
|
13
|
+
start(input: {
|
|
14
|
+
interaction: CredentialFlowDescriptor["interaction"];
|
|
15
|
+
locator: string;
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
}): Promise<{
|
|
18
|
+
wake: () => Promise<any>;
|
|
19
|
+
close: () => any;
|
|
20
|
+
closed: () => boolean;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Adapter for a host application's in-page acquisition view. It intentionally
|
|
25
|
+
* exposes no OpenCredentials locator or verifier to the host: the host can
|
|
26
|
+
* render an accessible local proof form, but only the SDK may submit that
|
|
27
|
+
* proof to OpenCredentials.
|
|
28
|
+
*/
|
|
29
|
+
export declare class InlineCredentialInteraction implements CredentialInlineInteractionAdapter {
|
|
30
|
+
private readonly present;
|
|
31
|
+
readonly kind: "inline";
|
|
32
|
+
constructor(present: (input: {
|
|
33
|
+
readonly signal?: AbortSignal;
|
|
34
|
+
}) => Promise<CredentialInteractionSurface>);
|
|
35
|
+
start(input: {
|
|
36
|
+
signal?: AbortSignal;
|
|
37
|
+
}): Promise<CredentialInteractionSurface>;
|
|
38
|
+
}
|
|
39
|
+
/** Request-scoped redirect continuation. It stores no TinyCloud session or key material. */
|
|
40
|
+
export declare class BrowserCredentialRedirectStore implements CredentialRedirectStore {
|
|
41
|
+
private readonly storage;
|
|
42
|
+
private readonly key;
|
|
43
|
+
constructor(storage?: Pick<Storage, "getItem" | "setItem" | "removeItem">, key?: string);
|
|
44
|
+
load(): Promise<CredentialRedirectResumeState | undefined>;
|
|
45
|
+
save(state: CredentialRedirectResumeState): Promise<void>;
|
|
46
|
+
clear(): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type CredentialFlowDescriptor } from "@tinycloud/sdk-core";
|
|
2
|
+
import type { CredentialAcquisitionTheme, CredentialInteractionSurface, InlineCredentialProofRequest, PrimitiveStepResult } from "./types";
|
|
3
|
+
export declare const TINYCLOUD_CREDENTIAL_ACQUISITION_TAG = "tinycloud-credential-acquisition";
|
|
4
|
+
declare const ElementBase: typeof HTMLElement;
|
|
5
|
+
/** SDK-owned Shadow-DOM view. It is deliberately unaware of locators, verifiers, sessions, and transport. */
|
|
6
|
+
export declare class TinyCloudCredentialAcquisitionElement extends ElementBase {
|
|
7
|
+
private root?;
|
|
8
|
+
private resolver?;
|
|
9
|
+
private rejecter?;
|
|
10
|
+
private closed;
|
|
11
|
+
connectedCallback(): void;
|
|
12
|
+
disconnectedCallback(): void;
|
|
13
|
+
configure(theme?: CredentialAcquisitionTheme): void;
|
|
14
|
+
requestProof(request: InlineCredentialProofRequest): Promise<PrimitiveStepResult>;
|
|
15
|
+
report(state: "signing" | "verifying" | "saving" | "success" | "recovery", message?: string): void;
|
|
16
|
+
finish(): void;
|
|
17
|
+
cancel(): void;
|
|
18
|
+
isClosed(): boolean;
|
|
19
|
+
private renderShell;
|
|
20
|
+
private renderPrompt;
|
|
21
|
+
}
|
|
22
|
+
/** Registers the element once in a browser document. */
|
|
23
|
+
export declare function defineTinyCloudCredentialAcquisitionElement(): void;
|
|
24
|
+
/** Controller that turns the SDK element into the safe low-level inline interaction surface. */
|
|
25
|
+
export declare class CredentialAcquisitionController {
|
|
26
|
+
private readonly options;
|
|
27
|
+
private element?;
|
|
28
|
+
constructor(options: {
|
|
29
|
+
readonly descriptor: CredentialFlowDescriptor;
|
|
30
|
+
readonly mountTarget?: Element | string;
|
|
31
|
+
readonly theme?: CredentialAcquisitionTheme;
|
|
32
|
+
});
|
|
33
|
+
start(input: {
|
|
34
|
+
readonly signal?: AbortSignal;
|
|
35
|
+
}): Promise<CredentialInteractionSurface>;
|
|
36
|
+
progress(state: "signing" | "verifying" | "saving" | "success" | "recovery"): void;
|
|
37
|
+
finish(): void;
|
|
38
|
+
fail(): void;
|
|
39
|
+
private target;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=element.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./browser";
|
|
2
|
+
export * from "./element";
|
|
3
|
+
export * from "./interpreter";
|
|
4
|
+
export * from "./renderer";
|
|
5
|
+
export * from "./service";
|
|
6
|
+
export * from "./storage";
|
|
7
|
+
export * from "./transport";
|
|
8
|
+
export * from "./types";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type CredentialFlowDescriptor, type CredentialProgressEvent, type CredentialRequirement } from "@tinycloud/sdk-core";
|
|
2
|
+
import type { CredentialAcquisitionTransport, CredentialSigningAdapter, InlineCredentialProofHandler, PrimitiveStepHandler } from "./types";
|
|
3
|
+
/** Finite step interpreter. Dispatch is exclusively by registered primitive and version. */
|
|
4
|
+
export declare function interpretCredentialFlow(input: {
|
|
5
|
+
readonly descriptor: CredentialFlowDescriptor;
|
|
6
|
+
readonly requirement: CredentialRequirement;
|
|
7
|
+
readonly requestId: string;
|
|
8
|
+
readonly verifier: string;
|
|
9
|
+
readonly holderDid: string;
|
|
10
|
+
readonly descriptorDigest: string;
|
|
11
|
+
readonly requirementDigest: string;
|
|
12
|
+
readonly openerOrigin: string;
|
|
13
|
+
readonly transport: CredentialAcquisitionTransport;
|
|
14
|
+
readonly signing: CredentialSigningAdapter;
|
|
15
|
+
/**
|
|
16
|
+
* Fallback for a host-owned surface. It receives every declared proof step,
|
|
17
|
+
* including primitives added by a later protocol version.
|
|
18
|
+
*/
|
|
19
|
+
readonly proofHandler?: InlineCredentialProofHandler;
|
|
20
|
+
readonly handlers?: Partial<Record<"collect_input" | "mailbox_otp", PrimitiveStepHandler>>;
|
|
21
|
+
readonly signal?: AbortSignal;
|
|
22
|
+
readonly onProgress?: (event: CredentialProgressEvent) => void;
|
|
23
|
+
readonly onWait?: () => Promise<void>;
|
|
24
|
+
}): Promise<void>;
|
|
25
|
+
//# sourceMappingURL=interpreter.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CredentialFlowDescriptor, CredentialUxState } from "@tinycloud/sdk-core";
|
|
2
|
+
export interface CredentialRendererModel {
|
|
3
|
+
readonly title: string;
|
|
4
|
+
readonly description: string;
|
|
5
|
+
readonly consent: string;
|
|
6
|
+
readonly fields: readonly {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
readonly label: string;
|
|
9
|
+
readonly required: true;
|
|
10
|
+
readonly inputMode: "email" | "text";
|
|
11
|
+
}[];
|
|
12
|
+
readonly steps: readonly {
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly primitive: string;
|
|
15
|
+
readonly title: string;
|
|
16
|
+
readonly description: string;
|
|
17
|
+
}[];
|
|
18
|
+
readonly stateLabels: Readonly<Record<"progress" | "success" | "recovery", string>>;
|
|
19
|
+
readonly state: CredentialUxState;
|
|
20
|
+
}
|
|
21
|
+
/** Shared descriptor-driven UX model. Dispatch is only by the finite primitive registry. */
|
|
22
|
+
export declare function renderCredentialDescriptor(descriptor: CredentialFlowDescriptor, state?: CredentialUxState): CredentialRendererModel;
|
|
23
|
+
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type CredentialFlowDescriptor, type CredentialIssuerMetadata, type CredentialRequirement, type IssuedCredentialEnvelope, type StoredCredentialRecord, type VerifiedCredential } from "@tinycloud/sdk-core";
|
|
2
|
+
import { OpenCredentialsHttpTransport } from "./transport";
|
|
3
|
+
import type { CredentialClient, CredentialsAcquireOptions, CredentialsEnsureOptions, CredentialsEnsureResult, CredentialsOperationOptions, CredentialsPolicyAdmissionOptions, CredentialsPolicyAdmissionResult } from "./types";
|
|
4
|
+
export declare class CredentialsService {
|
|
5
|
+
private readonly client;
|
|
6
|
+
constructor(client: CredentialClient);
|
|
7
|
+
private descriptor;
|
|
8
|
+
find(requirementValue: CredentialRequirement, options?: CredentialsOperationOptions): Promise<StoredCredentialRecord | undefined>;
|
|
9
|
+
verify(envelope: IssuedCredentialEnvelope, input: {
|
|
10
|
+
readonly descriptor: CredentialFlowDescriptor;
|
|
11
|
+
readonly requirement: CredentialRequirement;
|
|
12
|
+
readonly transport?: OpenCredentialsHttpTransport;
|
|
13
|
+
readonly issuerMetadata?: CredentialIssuerMetadata;
|
|
14
|
+
readonly fetch?: typeof fetch;
|
|
15
|
+
readonly signal?: AbortSignal;
|
|
16
|
+
readonly now?: Date;
|
|
17
|
+
}): Promise<VerifiedCredential>;
|
|
18
|
+
store(verified: VerifiedCredential, requirementValue: CredentialRequirement, options?: CredentialsOperationOptions): Promise<{
|
|
19
|
+
readonly record: StoredCredentialRecord;
|
|
20
|
+
readonly receipt: import("@tinycloud/sdk-core").CredentialStorageReceipt;
|
|
21
|
+
}>;
|
|
22
|
+
acquire(requirementValue: CredentialRequirement, options: CredentialsAcquireOptions): Promise<VerifiedCredential>;
|
|
23
|
+
ensure(requirementValue: CredentialRequirement, options: CredentialsEnsureOptions): Promise<CredentialsEnsureResult>;
|
|
24
|
+
admitPolicy(options: CredentialsPolicyAdmissionOptions): Promise<CredentialsPolicyAdmissionResult>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type CredentialRequirement, type CredentialStorageReceipt, type IKVService, type StoredCredentialRecord, type VerifiedCredential } from "@tinycloud/sdk-core";
|
|
2
|
+
export declare function findStoredCredential(input: {
|
|
3
|
+
readonly kv: IKVService;
|
|
4
|
+
readonly requirement: CredentialRequirement;
|
|
5
|
+
readonly holderDid: string;
|
|
6
|
+
readonly ownerDid: string;
|
|
7
|
+
readonly now?: Date;
|
|
8
|
+
}): Promise<StoredCredentialRecord | undefined>;
|
|
9
|
+
export declare function storeCredential(input: {
|
|
10
|
+
readonly kv: IKVService;
|
|
11
|
+
readonly verified: VerifiedCredential;
|
|
12
|
+
readonly requirement: CredentialRequirement;
|
|
13
|
+
readonly requirementDigest: string;
|
|
14
|
+
readonly activeHolderDid: string;
|
|
15
|
+
readonly activeOwnerDid: string;
|
|
16
|
+
readonly now?: Date;
|
|
17
|
+
}): Promise<{
|
|
18
|
+
readonly record: StoredCredentialRecord;
|
|
19
|
+
readonly receipt: CredentialStorageReceipt;
|
|
20
|
+
}>;
|
|
21
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type CredentialFlowDescriptor, type CredentialHolderBinding, type CredentialIssuerMetadata, type CredentialRequirement, type IssuedCredentialEnvelope } from "@tinycloud/sdk-core";
|
|
2
|
+
import type { CredentialAcquisitionTransport, CredentialRequestState, PrimitiveStepResult } from "./types";
|
|
3
|
+
export declare class OpenCredentialsHttpTransport implements CredentialAcquisitionTransport {
|
|
4
|
+
private readonly descriptor;
|
|
5
|
+
private readonly fetchFn;
|
|
6
|
+
private readonly nonces;
|
|
7
|
+
private readonly bindings;
|
|
8
|
+
constructor(descriptor: CredentialFlowDescriptor, fetchFn?: typeof fetch);
|
|
9
|
+
private url;
|
|
10
|
+
private request;
|
|
11
|
+
create(input: {
|
|
12
|
+
descriptor: CredentialFlowDescriptor;
|
|
13
|
+
descriptorDigest: string;
|
|
14
|
+
requirement: CredentialRequirement;
|
|
15
|
+
requirementDigest: string;
|
|
16
|
+
holderDid: string;
|
|
17
|
+
openerOrigin: string;
|
|
18
|
+
completionVerifierChallenge: string;
|
|
19
|
+
signal?: AbortSignal;
|
|
20
|
+
}): Promise<{
|
|
21
|
+
requestId: string;
|
|
22
|
+
locator: string;
|
|
23
|
+
expiresAt: string;
|
|
24
|
+
correlationId: string;
|
|
25
|
+
}>;
|
|
26
|
+
private proofStep;
|
|
27
|
+
state(id: string, verifier: string, signal?: AbortSignal): Promise<CredentialRequestState>;
|
|
28
|
+
beginStep(id: string, verifier: string, stepId: "collect_input" | "mailbox_otp", signal?: AbortSignal): Promise<void>;
|
|
29
|
+
submitStep(id: string, verifier: string, stepId: string, proof: PrimitiveStepResult, signal?: AbortSignal): Promise<void>;
|
|
30
|
+
holderBinding(id: string, verifier: string, signal?: AbortSignal): Promise<CredentialHolderBinding>;
|
|
31
|
+
submitHolderSignature(id: string, verifier: string, signature: string, signal?: AbortSignal): Promise<void>;
|
|
32
|
+
issue(id: string, verifier: string, signal?: AbortSignal): Promise<void>;
|
|
33
|
+
result(id: string, verifier: string, signal?: AbortSignal): Promise<IssuedCredentialEnvelope>;
|
|
34
|
+
issuerMetadata(signal?: AbortSignal): Promise<CredentialIssuerMetadata>;
|
|
35
|
+
checkStatus(status: IssuedCredentialEnvelope["status"], _signal?: AbortSignal): Promise<boolean>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import type { ClientSession, CredentialFlowDescriptor, CredentialHolderBinding, CredentialIssuerMetadata, CredentialProgressEvent, CredentialRequirement, CredentialStorageReceipt, IssuedCredentialEnvelope, IKVService, StoredCredentialRecord, VerifiedCredential, PolicyCredentialAdmissionV3, UnifiedPolicyCapability, UnifiedPolicyV2 } from "@tinycloud/sdk-core";
|
|
2
|
+
import type { ValidatedRuntimeDelegation } from "@tinycloud/node-sdk/core";
|
|
3
|
+
export interface CredentialClient {
|
|
4
|
+
readonly sessionDid: string;
|
|
5
|
+
readonly credentialHolderDid: string;
|
|
6
|
+
readonly credentialHolderKid: string;
|
|
7
|
+
session(): ClientSession | undefined;
|
|
8
|
+
signSessionBytes(bytes: Uint8Array): Promise<Uint8Array>;
|
|
9
|
+
autoSignCredentialBytes?(bytes: Uint8Array): Promise<Uint8Array | undefined>;
|
|
10
|
+
approveCredentialBytes?(bytes: Uint8Array): Promise<Uint8Array>;
|
|
11
|
+
activateCompactRuntimeDelegation?(input: {
|
|
12
|
+
readonly authorization: string;
|
|
13
|
+
readonly cid: string;
|
|
14
|
+
readonly host: string;
|
|
15
|
+
}): Promise<ValidatedRuntimeDelegation>;
|
|
16
|
+
ensureOwnedSpaceHosted(name: string): Promise<string>;
|
|
17
|
+
credentialSpaceOwnerDid(spaceId: string): string;
|
|
18
|
+
kvForSpace(spaceId: string): IKVService;
|
|
19
|
+
/**
|
|
20
|
+
* Root authorization CID of the active account session. Exposed here rather
|
|
21
|
+
* than on {@link ClientSession} so the CID stays out of the public session.
|
|
22
|
+
*/
|
|
23
|
+
accountAuthorizationCid(): string;
|
|
24
|
+
}
|
|
25
|
+
export interface CredentialSigningAdapter {
|
|
26
|
+
/** Return undefined when the existing exact-request auto-sign policy does not apply. */
|
|
27
|
+
readonly autoSign?: (binding: CredentialHolderBinding, bytes: Uint8Array, signal?: AbortSignal) => Promise<Uint8Array | undefined>;
|
|
28
|
+
/** Invoke the normal OpenKey approval surface. */
|
|
29
|
+
readonly requestApproval?: (binding: CredentialHolderBinding, bytes: Uint8Array, signal?: AbortSignal) => Promise<Uint8Array>;
|
|
30
|
+
}
|
|
31
|
+
export type PrimitiveStepResult = Readonly<Record<string, string | boolean>>;
|
|
32
|
+
export type PrimitiveStepHandler = (input: {
|
|
33
|
+
readonly descriptor: CredentialFlowDescriptor;
|
|
34
|
+
readonly requirement: CredentialRequirement;
|
|
35
|
+
readonly stepId: string;
|
|
36
|
+
readonly constraints: Readonly<Record<string, unknown>>;
|
|
37
|
+
readonly signal?: AbortSignal;
|
|
38
|
+
}) => Promise<PrimitiveStepResult>;
|
|
39
|
+
/**
|
|
40
|
+
* The bounded view a host-owned inline surface may receive. It deliberately
|
|
41
|
+
* excludes requirement values, which can contain private policy inputs.
|
|
42
|
+
*/
|
|
43
|
+
export interface InlineCredentialProofRequest {
|
|
44
|
+
readonly stepId: string;
|
|
45
|
+
readonly constraints: Readonly<Record<string, unknown>>;
|
|
46
|
+
readonly display: {
|
|
47
|
+
readonly title: string;
|
|
48
|
+
readonly description: string;
|
|
49
|
+
readonly consent: string;
|
|
50
|
+
readonly progressLabel: string;
|
|
51
|
+
readonly errorLiveRegion: "assertive";
|
|
52
|
+
};
|
|
53
|
+
readonly inputs: readonly {
|
|
54
|
+
readonly id: string;
|
|
55
|
+
readonly label: string;
|
|
56
|
+
readonly schema: CredentialFlowDescriptor["inputs"][number]["schema"];
|
|
57
|
+
}[];
|
|
58
|
+
readonly signal?: AbortSignal;
|
|
59
|
+
}
|
|
60
|
+
export type InlineCredentialProofHandler = (input: InlineCredentialProofRequest) => Promise<PrimitiveStepResult>;
|
|
61
|
+
export type CredentialInteractionKind = "popup" | "redirect" | "headless" | "inline";
|
|
62
|
+
export interface CredentialInteractionSurface {
|
|
63
|
+
readonly wake: () => Promise<void>;
|
|
64
|
+
readonly close: () => void;
|
|
65
|
+
readonly closed: () => boolean;
|
|
66
|
+
/**
|
|
67
|
+
* A bounded, local UI callback for a declared primitive step. The adapter
|
|
68
|
+
* returns user-entered proof bytes to the SDK; it never receives an
|
|
69
|
+
* acquisition locator, request verifier, or transport capability.
|
|
70
|
+
*/
|
|
71
|
+
readonly requestProof?: InlineCredentialProofHandler;
|
|
72
|
+
}
|
|
73
|
+
/** A browser-owned interaction that navigates to the OpenCredentials locator. */
|
|
74
|
+
export interface CredentialBrowserInteractionAdapter {
|
|
75
|
+
readonly kind: Exclude<CredentialInteractionKind, "inline">;
|
|
76
|
+
start(input: {
|
|
77
|
+
readonly interaction: CredentialFlowDescriptor["interaction"];
|
|
78
|
+
readonly locator: string;
|
|
79
|
+
readonly signal?: AbortSignal;
|
|
80
|
+
}): Promise<CredentialInteractionSurface>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* A host-owned, in-page acquisition surface. It intentionally receives no
|
|
84
|
+
* OpenCredentials locator, request verifier, or transport capability. The SDK
|
|
85
|
+
* owns every OpenCredentials request, including submission of returned proof.
|
|
86
|
+
*/
|
|
87
|
+
export interface CredentialInlineInteractionAdapter {
|
|
88
|
+
readonly kind: "inline";
|
|
89
|
+
start(input: {
|
|
90
|
+
readonly signal?: AbortSignal;
|
|
91
|
+
}): Promise<CredentialInteractionSurface>;
|
|
92
|
+
}
|
|
93
|
+
export type CredentialInteractionAdapter = CredentialBrowserInteractionAdapter | CredentialInlineInteractionAdapter;
|
|
94
|
+
export interface CredentialRedirectResumeState {
|
|
95
|
+
readonly type: "TinyCloudCredentialRedirectResume";
|
|
96
|
+
readonly version: 1;
|
|
97
|
+
readonly requestId: string;
|
|
98
|
+
readonly locator: string;
|
|
99
|
+
readonly verifier: string;
|
|
100
|
+
readonly expiresAt: string;
|
|
101
|
+
readonly correlationId: string;
|
|
102
|
+
readonly holderDid: string;
|
|
103
|
+
readonly descriptorDigest: string;
|
|
104
|
+
readonly requirementDigest: string;
|
|
105
|
+
readonly openerOrigin: string;
|
|
106
|
+
}
|
|
107
|
+
export interface CredentialRedirectStore {
|
|
108
|
+
load(): Promise<CredentialRedirectResumeState | undefined>;
|
|
109
|
+
save(state: CredentialRedirectResumeState): Promise<void>;
|
|
110
|
+
clear(): Promise<void>;
|
|
111
|
+
}
|
|
112
|
+
export interface CredentialRequestState {
|
|
113
|
+
readonly type: "OpenCredentialsAcquisitionState";
|
|
114
|
+
readonly version: 1;
|
|
115
|
+
readonly requestId: string;
|
|
116
|
+
readonly transitionId: string;
|
|
117
|
+
readonly state: "pending" | "ready_to_issue" | "issued" | "complete" | "expired" | "canceled" | "issuer_unready";
|
|
118
|
+
readonly nextStep?: {
|
|
119
|
+
readonly id: string;
|
|
120
|
+
readonly type: "collect_input" | "mailbox_otp" | "holder_signature";
|
|
121
|
+
readonly version: 1;
|
|
122
|
+
readonly constraints: Readonly<Record<string, unknown>>;
|
|
123
|
+
};
|
|
124
|
+
readonly retryAfterMs?: number;
|
|
125
|
+
readonly correlationId: string;
|
|
126
|
+
}
|
|
127
|
+
export interface CredentialAcquisitionTransport {
|
|
128
|
+
create(input: {
|
|
129
|
+
readonly descriptor: CredentialFlowDescriptor;
|
|
130
|
+
readonly descriptorDigest: string;
|
|
131
|
+
readonly requirement: CredentialRequirement;
|
|
132
|
+
readonly requirementDigest: string;
|
|
133
|
+
readonly holderDid: string;
|
|
134
|
+
readonly openerOrigin: string;
|
|
135
|
+
readonly completionVerifierChallenge: string;
|
|
136
|
+
readonly signal?: AbortSignal;
|
|
137
|
+
}): Promise<{
|
|
138
|
+
readonly requestId: string;
|
|
139
|
+
readonly locator: string;
|
|
140
|
+
readonly expiresAt: string;
|
|
141
|
+
readonly correlationId: string;
|
|
142
|
+
}>;
|
|
143
|
+
state(requestId: string, verifier: string, signal?: AbortSignal): Promise<CredentialRequestState>;
|
|
144
|
+
beginStep(requestId: string, verifier: string, stepId: "collect_input" | "mailbox_otp", signal?: AbortSignal): Promise<void>;
|
|
145
|
+
submitStep(requestId: string, verifier: string, stepId: string, proof: PrimitiveStepResult, signal?: AbortSignal): Promise<void>;
|
|
146
|
+
holderBinding(requestId: string, verifier: string, signal?: AbortSignal): Promise<CredentialHolderBinding>;
|
|
147
|
+
submitHolderSignature(requestId: string, verifier: string, signature: string, signal?: AbortSignal): Promise<void>;
|
|
148
|
+
issue(requestId: string, verifier: string, signal?: AbortSignal): Promise<void>;
|
|
149
|
+
result(requestId: string, verifier: string, signal?: AbortSignal): Promise<IssuedCredentialEnvelope>;
|
|
150
|
+
issuerMetadata(signal?: AbortSignal): Promise<CredentialIssuerMetadata>;
|
|
151
|
+
checkStatus(status: IssuedCredentialEnvelope["status"], signal?: AbortSignal): Promise<boolean>;
|
|
152
|
+
}
|
|
153
|
+
export interface CredentialsOperationOptions {
|
|
154
|
+
readonly descriptor?: CredentialFlowDescriptor;
|
|
155
|
+
readonly discoveryUrl?: string;
|
|
156
|
+
readonly fetch?: typeof fetch;
|
|
157
|
+
readonly signal?: AbortSignal;
|
|
158
|
+
readonly timeoutMs?: number;
|
|
159
|
+
readonly onProgress?: (event: CredentialProgressEvent) => void;
|
|
160
|
+
readonly now?: () => Date;
|
|
161
|
+
}
|
|
162
|
+
export interface CredentialsAcquireOptions extends CredentialsOperationOptions {
|
|
163
|
+
/**
|
|
164
|
+
* `inline` mounts the first-party TinyCloud element unless a bounded local
|
|
165
|
+
* proof adapter is explicitly supplied.
|
|
166
|
+
*/
|
|
167
|
+
readonly interaction?: CredentialInteractionKind;
|
|
168
|
+
readonly browser?: CredentialInteractionAdapter;
|
|
169
|
+
/** An element or selector inside the current document for the SDK-owned UI. */
|
|
170
|
+
readonly mountTarget?: Element | string;
|
|
171
|
+
/** Presentation-only tokens. Security-critical copy and proof order are fixed by the descriptor. */
|
|
172
|
+
readonly theme?: CredentialAcquisitionTheme;
|
|
173
|
+
readonly transport?: CredentialAcquisitionTransport;
|
|
174
|
+
readonly signing?: CredentialSigningAdapter;
|
|
175
|
+
readonly stepHandlers?: Partial<Record<"collect_input" | "mailbox_otp", PrimitiveStepHandler>>;
|
|
176
|
+
readonly openerOrigin?: string;
|
|
177
|
+
/** Same-origin, request-scoped persistence used to resume a full-page redirect. */
|
|
178
|
+
readonly redirectStore?: CredentialRedirectStore;
|
|
179
|
+
}
|
|
180
|
+
export interface CredentialAcquisitionTheme {
|
|
181
|
+
readonly accentColor?: string;
|
|
182
|
+
readonly backgroundColor?: string;
|
|
183
|
+
readonly textColor?: string;
|
|
184
|
+
}
|
|
185
|
+
export interface CredentialsEnsureOptions extends CredentialsAcquireOptions {
|
|
186
|
+
}
|
|
187
|
+
export interface CredentialsEnsureResult {
|
|
188
|
+
readonly status: "reused" | "acquired";
|
|
189
|
+
readonly credential: VerifiedCredential;
|
|
190
|
+
readonly record: StoredCredentialRecord;
|
|
191
|
+
readonly receipt?: CredentialStorageReceipt;
|
|
192
|
+
}
|
|
193
|
+
export interface CredentialsPolicyAdmissionOptions {
|
|
194
|
+
readonly ensured: CredentialsEnsureResult;
|
|
195
|
+
readonly policy: UnifiedPolicyV2;
|
|
196
|
+
readonly policyCid: string;
|
|
197
|
+
readonly policyRootCid: string;
|
|
198
|
+
readonly enforcementRootCid: string;
|
|
199
|
+
readonly requirement: CredentialRequirement;
|
|
200
|
+
readonly requestedCapabilities: readonly UnifiedPolicyCapability[];
|
|
201
|
+
readonly nodeOrigin: string;
|
|
202
|
+
readonly fetch?: typeof fetch;
|
|
203
|
+
readonly now?: Date;
|
|
204
|
+
readonly jti?: string;
|
|
205
|
+
}
|
|
206
|
+
export interface CredentialsPolicyAdmissionResult extends PolicyCredentialAdmissionV3 {
|
|
207
|
+
readonly installed: ValidatedRuntimeDelegation;
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=types.d.ts.map
|