@tinycloud/web-sdk 2.11.0 → 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 +18 -2
- package/dist/credentials/element.d.ts +42 -0
- package/dist/credentials/index.d.ts +1 -0
- package/dist/credentials/interpreter.d.ts +6 -1
- package/dist/credentials/service.d.ts +2 -1
- package/dist/credentials/types.d.ts +92 -9
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +1 -1
- package/dist/modules/tcw.d.ts +15 -5
- 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 +3 -8
- 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";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { CredentialFlowDescriptor } from "@tinycloud/sdk-core";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CredentialBrowserInteractionAdapter, CredentialInlineInteractionAdapter, CredentialInteractionSurface, CredentialRedirectResumeState, CredentialRedirectStore } from "./types";
|
|
3
3
|
interface BrowserSurface {
|
|
4
4
|
readonly opener: Window;
|
|
5
5
|
open(url: string): Window | null;
|
|
6
6
|
redirect(url: string): void;
|
|
7
7
|
}
|
|
8
8
|
/** Exact-origin, locator-only browser interaction. Messages are non-secret wake signals. */
|
|
9
|
-
export declare class BrowserCredentialInteraction implements
|
|
9
|
+
export declare class BrowserCredentialInteraction implements CredentialBrowserInteractionAdapter {
|
|
10
10
|
private readonly surface;
|
|
11
11
|
readonly kind: "popup" | "redirect";
|
|
12
12
|
constructor(kind?: "popup" | "redirect", surface?: BrowserSurface);
|
|
@@ -20,6 +20,22 @@ export declare class BrowserCredentialInteraction implements CredentialInteracti
|
|
|
20
20
|
closed: () => boolean;
|
|
21
21
|
}>;
|
|
22
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
|
+
}
|
|
23
39
|
/** Request-scoped redirect continuation. It stores no TinyCloud session or key material. */
|
|
24
40
|
export declare class BrowserCredentialRedirectStore implements CredentialRedirectStore {
|
|
25
41
|
private readonly storage;
|
|
@@ -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
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type CredentialFlowDescriptor, type CredentialProgressEvent, type CredentialRequirement } from "@tinycloud/sdk-core";
|
|
2
|
-
import type { CredentialAcquisitionTransport, CredentialSigningAdapter, PrimitiveStepHandler } from "./types";
|
|
2
|
+
import type { CredentialAcquisitionTransport, CredentialSigningAdapter, InlineCredentialProofHandler, PrimitiveStepHandler } from "./types";
|
|
3
3
|
/** Finite step interpreter. Dispatch is exclusively by registered primitive and version. */
|
|
4
4
|
export declare function interpretCredentialFlow(input: {
|
|
5
5
|
readonly descriptor: CredentialFlowDescriptor;
|
|
@@ -12,6 +12,11 @@ export declare function interpretCredentialFlow(input: {
|
|
|
12
12
|
readonly openerOrigin: string;
|
|
13
13
|
readonly transport: CredentialAcquisitionTransport;
|
|
14
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;
|
|
15
20
|
readonly handlers?: Partial<Record<"collect_input" | "mailbox_otp", PrimitiveStepHandler>>;
|
|
16
21
|
readonly signal?: AbortSignal;
|
|
17
22
|
readonly onProgress?: (event: CredentialProgressEvent) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type CredentialFlowDescriptor, type CredentialIssuerMetadata, type CredentialRequirement, type IssuedCredentialEnvelope, type StoredCredentialRecord, type VerifiedCredential } from "@tinycloud/sdk-core";
|
|
2
2
|
import { OpenCredentialsHttpTransport } from "./transport";
|
|
3
|
-
import type { CredentialClient, CredentialsAcquireOptions, CredentialsEnsureOptions, CredentialsEnsureResult, CredentialsOperationOptions } from "./types";
|
|
3
|
+
import type { CredentialClient, CredentialsAcquireOptions, CredentialsEnsureOptions, CredentialsEnsureResult, CredentialsOperationOptions, CredentialsPolicyAdmissionOptions, CredentialsPolicyAdmissionResult } from "./types";
|
|
4
4
|
export declare class CredentialsService {
|
|
5
5
|
private readonly client;
|
|
6
6
|
constructor(client: CredentialClient);
|
|
@@ -21,5 +21,6 @@ export declare class CredentialsService {
|
|
|
21
21
|
}>;
|
|
22
22
|
acquire(requirementValue: CredentialRequirement, options: CredentialsAcquireOptions): Promise<VerifiedCredential>;
|
|
23
23
|
ensure(requirementValue: CredentialRequirement, options: CredentialsEnsureOptions): Promise<CredentialsEnsureResult>;
|
|
24
|
+
admitPolicy(options: CredentialsPolicyAdmissionOptions): Promise<CredentialsPolicyAdmissionResult>;
|
|
24
25
|
}
|
|
25
26
|
//# sourceMappingURL=service.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ClientSession, CredentialFlowDescriptor, CredentialHolderBinding, CredentialIssuerMetadata, CredentialProgressEvent, CredentialRequirement, CredentialStorageReceipt, IssuedCredentialEnvelope, IKVService, StoredCredentialRecord, VerifiedCredential } from "@tinycloud/sdk-core";
|
|
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";
|
|
2
3
|
export interface CredentialClient {
|
|
3
4
|
readonly sessionDid: string;
|
|
4
5
|
readonly credentialHolderDid: string;
|
|
@@ -7,9 +8,19 @@ export interface CredentialClient {
|
|
|
7
8
|
signSessionBytes(bytes: Uint8Array): Promise<Uint8Array>;
|
|
8
9
|
autoSignCredentialBytes?(bytes: Uint8Array): Promise<Uint8Array | undefined>;
|
|
9
10
|
approveCredentialBytes?(bytes: Uint8Array): Promise<Uint8Array>;
|
|
11
|
+
activateCompactRuntimeDelegation?(input: {
|
|
12
|
+
readonly authorization: string;
|
|
13
|
+
readonly cid: string;
|
|
14
|
+
readonly host: string;
|
|
15
|
+
}): Promise<ValidatedRuntimeDelegation>;
|
|
10
16
|
ensureOwnedSpaceHosted(name: string): Promise<string>;
|
|
11
17
|
credentialSpaceOwnerDid(spaceId: string): string;
|
|
12
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;
|
|
13
24
|
}
|
|
14
25
|
export interface CredentialSigningAdapter {
|
|
15
26
|
/** Return undefined when the existing exact-request auto-sign policy does not apply. */
|
|
@@ -25,18 +36,61 @@ export type PrimitiveStepHandler = (input: {
|
|
|
25
36
|
readonly constraints: Readonly<Record<string, unknown>>;
|
|
26
37
|
readonly signal?: AbortSignal;
|
|
27
38
|
}) => Promise<PrimitiveStepResult>;
|
|
28
|
-
|
|
29
|
-
|
|
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">;
|
|
30
76
|
start(input: {
|
|
31
77
|
readonly interaction: CredentialFlowDescriptor["interaction"];
|
|
32
78
|
readonly locator: string;
|
|
33
79
|
readonly signal?: AbortSignal;
|
|
34
|
-
}): Promise<
|
|
35
|
-
readonly wake: () => Promise<void>;
|
|
36
|
-
readonly close: () => void;
|
|
37
|
-
readonly closed: () => boolean;
|
|
38
|
-
}>;
|
|
80
|
+
}): Promise<CredentialInteractionSurface>;
|
|
39
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;
|
|
40
94
|
export interface CredentialRedirectResumeState {
|
|
41
95
|
readonly type: "TinyCloudCredentialRedirectResume";
|
|
42
96
|
readonly version: 1;
|
|
@@ -106,8 +160,16 @@ export interface CredentialsOperationOptions {
|
|
|
106
160
|
readonly now?: () => Date;
|
|
107
161
|
}
|
|
108
162
|
export interface CredentialsAcquireOptions extends CredentialsOperationOptions {
|
|
109
|
-
|
|
163
|
+
/**
|
|
164
|
+
* `inline` mounts the first-party TinyCloud element unless a bounded local
|
|
165
|
+
* proof adapter is explicitly supplied.
|
|
166
|
+
*/
|
|
167
|
+
readonly interaction?: CredentialInteractionKind;
|
|
110
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;
|
|
111
173
|
readonly transport?: CredentialAcquisitionTransport;
|
|
112
174
|
readonly signing?: CredentialSigningAdapter;
|
|
113
175
|
readonly stepHandlers?: Partial<Record<"collect_input" | "mailbox_otp", PrimitiveStepHandler>>;
|
|
@@ -115,6 +177,11 @@ export interface CredentialsAcquireOptions extends CredentialsOperationOptions {
|
|
|
115
177
|
/** Same-origin, request-scoped persistence used to resume a full-page redirect. */
|
|
116
178
|
readonly redirectStore?: CredentialRedirectStore;
|
|
117
179
|
}
|
|
180
|
+
export interface CredentialAcquisitionTheme {
|
|
181
|
+
readonly accentColor?: string;
|
|
182
|
+
readonly backgroundColor?: string;
|
|
183
|
+
readonly textColor?: string;
|
|
184
|
+
}
|
|
118
185
|
export interface CredentialsEnsureOptions extends CredentialsAcquireOptions {
|
|
119
186
|
}
|
|
120
187
|
export interface CredentialsEnsureResult {
|
|
@@ -123,4 +190,20 @@ export interface CredentialsEnsureResult {
|
|
|
123
190
|
readonly record: StoredCredentialRecord;
|
|
124
191
|
readonly receipt?: CredentialStorageReceipt;
|
|
125
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
|
+
}
|
|
126
209
|
//# sourceMappingURL=types.d.ts.map
|