@tinycloud/web-sdk 3.0.0-beta.2 → 3.0.0-beta.20
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/BrowserSessionStorage.d.ts +4 -0
- package/dist/credentials/element.d.ts +30 -1
- package/dist/credentials/interpreter.d.ts +3 -1
- package/dist/credentials/transport.d.ts +1 -0
- package/dist/credentials/types.d.ts +39 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/modules/WebSecretsService.d.ts +1 -0
- package/dist/modules/tcw.d.ts +20 -9
- package/dist/notifications/types.schema.d.ts +2 -2
- package/dist/share/service.d.ts +25 -23
- package/dist/share/types.d.ts +52 -0
- package/package.json +5 -5
|
@@ -26,6 +26,7 @@ export declare class WebSecretsService implements ISecretsService {
|
|
|
26
26
|
put(name: string, value: string, options?: SecretScopeOptions): ReturnType<ISecretsService["put"]>;
|
|
27
27
|
delete(name: string, options?: SecretScopeOptions): ReturnType<ISecretsService["delete"]>;
|
|
28
28
|
list(options?: SecretScopeOptions): ReturnType<ISecretsService["list"]>;
|
|
29
|
+
listAll(): ReturnType<ISecretsService["listAll"]>;
|
|
29
30
|
private get service();
|
|
30
31
|
private ensureMutationPermission;
|
|
31
32
|
private restoreUnlockAfterEscalation;
|
package/dist/modules/tcw.d.ts
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @packageDocumentation
|
|
11
11
|
*/
|
|
12
|
-
import { TinyCloudNode, type BootstrapWarning, type DelegateToOptions, type DelegateToResult, type ISessionStorage, type SignStrategy, type ValidatedRuntimeDelegation, type UnifiedOwnerRootInput, type UnifiedOwnerRootReceipt } from "@tinycloud/node-sdk/core";
|
|
13
|
-
import { IKVService, ISQLService, IDuckDbService, IDataVaultService, ISecretsService, ISpaceService, ISpace, ISharingService, ICapabilityKeyRegistry, IHooksService, IEncryptionService, DelegationManager, Delegation, DelegationRevocationReceipt, CreateDelegationParams, Result, DelegationError, ClientSession, Extension, type TelemetryConfig, ISpaceCreationHandler, type Manifest, type ComposedManifestRequest, type AccountService, type ResolvedDelegate, type PermissionEntry, type NetworkDescriptor, type CreateOwnerDelegationParams, type OwnerDelegationReceipt, type
|
|
12
|
+
import { TinyCloudNode, type BootstrapWarning, type DelegateToOptions, type DelegateToResult, type ISessionStorage, type SignStrategy, type ValidatedRuntimeDelegation, type UnifiedOwnerRootInput, type UnifiedOwnerRootReceipt, type RegisterPolicyV3Input, type RegisterPolicyV3Receipt } from "@tinycloud/node-sdk/core";
|
|
13
|
+
import { IKVService, ISQLService, IDuckDbService, IDataVaultService, ISecretsService, ISpaceService, ISpace, ISharingService, ICapabilityKeyRegistry, IHooksService, IEncryptionService, DelegationManager, Delegation, DelegationRevocationReceipt, CreateDelegationParams, Result, DelegationError, ClientSession, Extension, type TelemetryConfig, ISpaceCreationHandler, type Manifest, type ComposedManifestRequest, type AccountService, type ResolvedDelegate, type PermissionEntry, type NetworkDescriptor, type CreateOwnerDelegationParams, type OwnerDelegationReceipt, type LocalNodeIdentityStore, SignInOptions } from "@tinycloud/sdk-core";
|
|
14
14
|
import { type BrowserProvider, type BrowserWalletProvider } from "../adapters/browserProvider";
|
|
15
15
|
import { RPCProviders, ClientConfig } from "../providers";
|
|
16
16
|
import type { NotificationConfig } from "../notifications/types";
|
|
@@ -74,7 +74,7 @@ export interface Config extends ClientConfig {
|
|
|
74
74
|
* modal handler is in use.
|
|
75
75
|
*/
|
|
76
76
|
spaceCreationTimeoutMs?: number;
|
|
77
|
-
/** Session expiration time in milliseconds (default:
|
|
77
|
+
/** Session expiration time in milliseconds (default: 30 days, `EXPIRY.SESSION_MS`) */
|
|
78
78
|
sessionExpirationMs?: number;
|
|
79
79
|
/** Persist browser sessions so signIn() can restore before prompting. Default true. */
|
|
80
80
|
persistSession?: boolean;
|
|
@@ -137,6 +137,8 @@ export interface ShareReceiveResult<T = unknown> {
|
|
|
137
137
|
delegation: Delegation;
|
|
138
138
|
path: string;
|
|
139
139
|
spaceId: string;
|
|
140
|
+
/** Owner Node named by the link; that node independently verifies the accompanying delegation. */
|
|
141
|
+
host: string;
|
|
140
142
|
}
|
|
141
143
|
export declare class TinyCloudWeb {
|
|
142
144
|
/** The connected wallet's raw EIP-1193 provider. */
|
|
@@ -233,6 +235,13 @@ export declare class TinyCloudWeb {
|
|
|
233
235
|
get accountSpaceId(): string | undefined;
|
|
234
236
|
get account(): AccountService;
|
|
235
237
|
get hosts(): string[];
|
|
238
|
+
/** Registry-resolved owner Node identity used to bind native share targets. */
|
|
239
|
+
activeNodeIdentity(): Promise<{
|
|
240
|
+
readonly origin: string;
|
|
241
|
+
readonly nodeDid: string;
|
|
242
|
+
}>;
|
|
243
|
+
/** Publish the active owner Node as a session-signed registry record. */
|
|
244
|
+
publishActiveNodeLocation(registryUrl: string, fetchFn?: typeof fetch): Promise<import("@tinycloud/sdk-core").LocationRecord>;
|
|
236
245
|
get sessionRestoreStatus(): SessionRestoreStatus;
|
|
237
246
|
/** Holder-bound OpenCredentials issuance using the active TinyCloud session. */
|
|
238
247
|
get credentials(): CredentialsService;
|
|
@@ -310,10 +319,10 @@ export declare class TinyCloudWeb {
|
|
|
310
319
|
createOwnerDelegation(params: CreateOwnerDelegationParams extends infer PermissionShape ? PermissionShape extends CreateOwnerDelegationParams ? Omit<PermissionShape, "spaceId"> & {
|
|
311
320
|
readonly spaceId?: string;
|
|
312
321
|
} : never : never): Promise<OwnerDelegationReceipt>;
|
|
313
|
-
/** Register
|
|
314
|
-
|
|
315
|
-
/** Authorize a short-lived, one-use
|
|
316
|
-
|
|
322
|
+
/** Register signed policy material through the Node-owned Policy/v3 runtime. */
|
|
323
|
+
registerPolicy(params: Omit<RegisterPolicyV3Input, "nodeOrigin" | "fetch">): Promise<RegisterPolicyV3Receipt>;
|
|
324
|
+
/** Authorize a short-lived, one-use v3 delivery against the signed envelope and roots. */
|
|
325
|
+
authorizeShareDeliveryV3(input: Parameters<TinyCloudNode["authorizeShareDeliveryV3"]>[0]): ReturnType<TinyCloudNode["authorizeShareDeliveryV3"]>;
|
|
317
326
|
/**
|
|
318
327
|
* Issue a delegation using the capability-chain flow (spec:
|
|
319
328
|
* `.claude/specs/capability-chain.md`). When the requested permissions
|
|
@@ -384,9 +393,11 @@ export declare class TinyCloudWeb {
|
|
|
384
393
|
listDelegations(): Promise<Result<Delegation[], DelegationError>>;
|
|
385
394
|
checkPermission(path: string, action: string): Promise<Result<boolean, DelegationError>>;
|
|
386
395
|
/**
|
|
387
|
-
* Receive and retrieve data from a
|
|
396
|
+
* Receive and retrieve data from a native TinyCloud bearer delegation.
|
|
388
397
|
* Static method — no auth required. Uses browser WASM.
|
|
389
398
|
*/
|
|
390
|
-
static receiveShare<T = unknown>(link: string, key?: string
|
|
399
|
+
static receiveShare<T = unknown>(link: string, key?: string, options?: {
|
|
400
|
+
readonly binary?: boolean;
|
|
401
|
+
}): Promise<Result<ShareReceiveResult<T>, DelegationError>>;
|
|
391
402
|
}
|
|
392
403
|
//# sourceMappingURL=tcw.d.ts.map
|
|
@@ -54,8 +54,8 @@ export declare const ToastSchema: z.ZodObject<{
|
|
|
54
54
|
timestamp: z.ZodNumber;
|
|
55
55
|
}, "strip", z.ZodTypeAny, {
|
|
56
56
|
description?: string;
|
|
57
|
-
type?: "error" | "success" | "warning" | "info" | "loading";
|
|
58
57
|
id?: string;
|
|
58
|
+
type?: "error" | "success" | "warning" | "info" | "loading";
|
|
59
59
|
title?: string;
|
|
60
60
|
duration?: number;
|
|
61
61
|
action?: {
|
|
@@ -65,8 +65,8 @@ export declare const ToastSchema: z.ZodObject<{
|
|
|
65
65
|
timestamp?: number;
|
|
66
66
|
}, {
|
|
67
67
|
description?: string;
|
|
68
|
-
type?: "error" | "success" | "warning" | "info" | "loading";
|
|
69
68
|
id?: string;
|
|
69
|
+
type?: "error" | "success" | "warning" | "info" | "loading";
|
|
70
70
|
title?: string;
|
|
71
71
|
duration?: number;
|
|
72
72
|
action?: {
|
package/dist/share/service.d.ts
CHANGED
|
@@ -1,53 +1,55 @@
|
|
|
1
|
+
import { type CredentialRequirement } from "@tinycloud/sdk-core";
|
|
2
|
+
import { type ShareMetadata } from "@tinycloud/share-sdk";
|
|
1
3
|
import { type ShareEnvelopeV3 } from "@tinycloud/share-envelope";
|
|
2
4
|
import { CredentialsService } from "../credentials";
|
|
3
5
|
import { type ReceiverSessionStorage } from "./receiver-session";
|
|
4
|
-
import type { ReceivedShare, ShareImportAccountClient, ShareImportOptions, ShareImportResult, ShareReceiveOptions, ShareReceivedContent, ShareReceiverClient, ShareReceiverIdentity } from "./types";
|
|
6
|
+
import type { ReceivedShare, ShareDelegateOptions, ShareDelegation, ShareImportAccountClient, ShareImportOptions, ShareImportResult, ShareReceiveOptions, ShareReceivedContent, ShareReceiverClient, ShareReceiverIdentity, ShareReceiverRecipient } from "./types";
|
|
5
7
|
export interface ShareReceiverServiceOptions {
|
|
6
8
|
readonly origin?: string;
|
|
7
9
|
readonly sessionStorage?: ReceiverSessionStorage;
|
|
8
10
|
readonly credentialDiscoveryUrl?: string;
|
|
9
11
|
/** Out-of-band Share application origin allowed to supply invitation URLs. */
|
|
10
12
|
readonly expectedShareOrigin: string;
|
|
11
|
-
/**
|
|
12
|
-
readonly
|
|
13
|
-
/** Pinned Node identity used by recipient response verification. */
|
|
14
|
-
readonly trustedNode: {
|
|
15
|
-
readonly invitationKid: string;
|
|
16
|
-
readonly invitationPublicKey: Uint8Array;
|
|
17
|
-
};
|
|
18
|
-
/** Exact Ed25519 enforcer DID committed as the signed envelope target. */
|
|
19
|
-
readonly expectedEnforcerDid: string;
|
|
13
|
+
/** Registry containing the share owner's signed TinyCloud location record. */
|
|
14
|
+
readonly registryOrigin: string;
|
|
20
15
|
readonly fetch?: typeof fetch;
|
|
21
16
|
}
|
|
22
|
-
export declare function validateShareReceiverServiceTrust(envelope: Pick<ShareEnvelopeV3, "target"
|
|
23
|
-
readonly invitationKid: string;
|
|
24
|
-
readonly invitationPublicKey: Uint8Array;
|
|
25
|
-
};
|
|
26
|
-
/** @internal */
|
|
27
|
-
export declare function validateShareReceiverRegistryBaseUrl(value: string): string;
|
|
17
|
+
export declare function validateShareReceiverServiceTrust(envelope: Pick<ShareEnvelopeV3, "target" | "attestedEnforcerBinding">): void;
|
|
28
18
|
/** @internal */
|
|
29
19
|
export declare function validateShareReceiverExpectedOrigin(shareUrl: string, expectedOrigin: string): string;
|
|
30
20
|
/** @internal */
|
|
31
21
|
export declare function selectShareReceiverAccountSession(client: ShareReceiverClient, requestedIdentity: ShareReceiveOptions["identity"]): Promise<ReturnType<ShareReceiverClient["session"]>>;
|
|
32
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* @internal Binds the invitation's addressed recipient to the owner-signed
|
|
24
|
+
* policy's credential commitment. A matcher that does not hash to the
|
|
25
|
+
* committed requirement is rejected before anything is displayed or sent.
|
|
26
|
+
*/
|
|
27
|
+
export declare function verifiedShareRequirement(envelope: ShareEnvelopeV3): Promise<CredentialRequirement>;
|
|
33
28
|
export declare class ReceivedShareImpl implements ReceivedShare {
|
|
34
29
|
readonly identity: ShareReceiverIdentity;
|
|
35
|
-
readonly
|
|
30
|
+
readonly metadata: ShareMetadata;
|
|
36
31
|
private readonly envelope;
|
|
32
|
+
private readonly requirement;
|
|
37
33
|
private readonly credentials;
|
|
38
34
|
private readonly sign;
|
|
39
35
|
private readonly options;
|
|
40
36
|
private readonly fetchFn;
|
|
41
37
|
private readonly credentialDiscoveryUrl;
|
|
42
|
-
private readonly trustedNode;
|
|
43
38
|
private content?;
|
|
44
39
|
private getPromise?;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
private accessPromise?;
|
|
41
|
+
private stage?;
|
|
42
|
+
readonly recipient: ShareReceiverRecipient;
|
|
43
|
+
constructor(identity: ShareReceiverIdentity, metadata: ShareMetadata, envelope: ShareEnvelopeV3, requirement: CredentialRequirement, credentials: CredentialsService, sign: (bytes: Uint8Array) => Promise<Uint8Array>, options: ShareReceiveOptions, fetchFn: typeof fetch, credentialDiscoveryUrl: string);
|
|
44
|
+
get shareId(): string;
|
|
49
45
|
get(): Promise<ShareReceivedContent>;
|
|
46
|
+
/** The admitted access, admitted again once its chain has expired. */
|
|
47
|
+
private access;
|
|
48
|
+
/** Forget `access` so the next request admits again, unless it was already replaced. */
|
|
49
|
+
private forget;
|
|
50
|
+
private admit;
|
|
50
51
|
private load;
|
|
52
|
+
delegate(options: ShareDelegateOptions): Promise<ShareDelegation>;
|
|
51
53
|
importInto(accountClient: ShareImportAccountClient, options: ShareImportOptions): Promise<ShareImportResult>;
|
|
52
54
|
}
|
|
53
55
|
export declare class ShareReceiverService {
|
package/dist/share/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ClientSession, IKVService } from "@tinycloud/sdk-core";
|
|
2
|
+
import type { ShareMetadata } from "@tinycloud/share-sdk";
|
|
2
3
|
import type { CredentialsService } from "../credentials";
|
|
3
4
|
export type ShareReceiverIdentity = {
|
|
4
5
|
readonly kind: "account";
|
|
@@ -16,6 +17,7 @@ export type ShareReceiveProgress = {
|
|
|
16
17
|
} | {
|
|
17
18
|
readonly state: "credential-acquisition";
|
|
18
19
|
readonly status: "started" | "completed";
|
|
20
|
+
readonly mailbox?: string;
|
|
19
21
|
} | {
|
|
20
22
|
readonly state: "policy-admission";
|
|
21
23
|
readonly status: "started" | "completed";
|
|
@@ -43,6 +45,34 @@ export interface ShareReceiveOptions {
|
|
|
43
45
|
};
|
|
44
46
|
readonly signal?: AbortSignal;
|
|
45
47
|
readonly onProgress?: (event: ShareReceiveProgress) => void;
|
|
48
|
+
/**
|
|
49
|
+
* Open through access another recipient delegated to this identity's key,
|
|
50
|
+
* instead of proving a credential.
|
|
51
|
+
*/
|
|
52
|
+
readonly delegation?: ShareDelegation;
|
|
53
|
+
}
|
|
54
|
+
/** One signed link of a share's delegation chain. The owner's Node holds it too. */
|
|
55
|
+
export interface ShareDelegationLink {
|
|
56
|
+
readonly authorization: string;
|
|
57
|
+
readonly cid: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A share's access re-delegated to another key: the admitted session first,
|
|
61
|
+
* then each re-delegation in order. It holds no secret; only the key it names
|
|
62
|
+
* can use it.
|
|
63
|
+
*/
|
|
64
|
+
export interface ShareDelegation {
|
|
65
|
+
readonly shareId: string;
|
|
66
|
+
readonly delegateDid: string;
|
|
67
|
+
readonly expiresAt: string;
|
|
68
|
+
readonly chain: readonly ShareDelegationLink[];
|
|
69
|
+
}
|
|
70
|
+
export interface ShareDelegateOptions {
|
|
71
|
+
/** DID of the key that should hold this share's access, such as an account session key. */
|
|
72
|
+
readonly to: string;
|
|
73
|
+
/** Defaults to the longest the current access allows. */
|
|
74
|
+
readonly expiresAt?: Date;
|
|
75
|
+
readonly signal?: AbortSignal;
|
|
46
76
|
}
|
|
47
77
|
export interface ShareReceivedContent {
|
|
48
78
|
readonly bytes: Uint8Array;
|
|
@@ -68,11 +98,33 @@ export interface ShareImportAccountClient {
|
|
|
68
98
|
ensureOwnedSpaceHosted(name: string): Promise<string>;
|
|
69
99
|
kvForSpace(spaceId: string): IKVService;
|
|
70
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* The recipient an invitation is addressed to. It comes from the signed,
|
|
103
|
+
* sealed invitation and is checked against the policy's credential
|
|
104
|
+
* requirement commitment before `receive` returns, so a host may display it.
|
|
105
|
+
*/
|
|
106
|
+
export type ShareReceiverRecipient = {
|
|
107
|
+
readonly kind: "exactEmail";
|
|
108
|
+
readonly email: string;
|
|
109
|
+
}
|
|
110
|
+
/** Anyone who proves a mailbox whose issuer-derived domain equals `domain` exactly. */
|
|
111
|
+
| {
|
|
112
|
+
readonly kind: "emailDomain";
|
|
113
|
+
readonly domain: string;
|
|
114
|
+
};
|
|
71
115
|
export interface ReceivedShare {
|
|
72
116
|
readonly identity: ShareReceiverIdentity;
|
|
117
|
+
readonly recipient: ShareReceiverRecipient;
|
|
118
|
+
readonly metadata: ShareMetadata;
|
|
73
119
|
readonly shareId: string;
|
|
74
120
|
get(): Promise<ShareReceivedContent>;
|
|
75
121
|
importInto(accountClient: ShareImportAccountClient, options: ShareImportOptions): Promise<ShareImportResult>;
|
|
122
|
+
/**
|
|
123
|
+
* Re-delegate this share's access, including decryption, to another key.
|
|
124
|
+
* Proves the credential first if this share has not been opened yet. The
|
|
125
|
+
* delegate opens it with `receive(url, { delegation })`.
|
|
126
|
+
*/
|
|
127
|
+
delegate(options: ShareDelegateOptions): Promise<ShareDelegation>;
|
|
76
128
|
}
|
|
77
129
|
export interface ShareReceiverClient extends ShareImportAccountClient {
|
|
78
130
|
readonly credentialHolderDid: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinycloud/web-sdk",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.20",
|
|
4
4
|
"description": "A set of tools and utilities to help you build your app with TinyCloud.",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@multiformats/multiaddr": "^13.0.1",
|
|
45
45
|
"@multiformats/multiaddr-to-uri": "^12.0.0",
|
|
46
|
-
"@tinycloud/node-sdk": "3.0.0-beta.
|
|
47
|
-
"@tinycloud/sdk-core": "3.0.0-beta.
|
|
48
|
-
"@tinycloud/share-envelope": "0.
|
|
49
|
-
"@tinycloud/share-sdk": "0.
|
|
46
|
+
"@tinycloud/node-sdk": "3.0.0-beta.20",
|
|
47
|
+
"@tinycloud/sdk-core": "3.0.0-beta.19",
|
|
48
|
+
"@tinycloud/share-envelope": "1.0.0-beta.5",
|
|
49
|
+
"@tinycloud/share-sdk": "1.0.0-beta.9",
|
|
50
50
|
"@tinycloud/web-sdk-wasm": "1.7.6",
|
|
51
51
|
"axios": "^1.7.9",
|
|
52
52
|
"viem": "^2.45.0",
|