@tinycloud/web-sdk 3.0.0-beta.8 → 3.0.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/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.mjs +1 -1
- package/dist/modules/Storage/tinycloud/types.schema.d.ts +2 -2
- package/dist/modules/tcw.d.ts +14 -5
- package/dist/share/service.d.ts +22 -22
- package/dist/share/types.d.ts +50 -0
- package/package.json +5 -5
|
@@ -39,8 +39,8 @@ export declare const SessionConfigSchema: z.ZodObject<{
|
|
|
39
39
|
address?: string;
|
|
40
40
|
chainId?: number;
|
|
41
41
|
issuedAt?: string;
|
|
42
|
-
jwk?: Record<string, unknown>;
|
|
43
42
|
notBefore?: string;
|
|
43
|
+
jwk?: Record<string, unknown>;
|
|
44
44
|
expirationTime?: string;
|
|
45
45
|
parents?: string[];
|
|
46
46
|
}, {
|
|
@@ -50,8 +50,8 @@ export declare const SessionConfigSchema: z.ZodObject<{
|
|
|
50
50
|
address?: string;
|
|
51
51
|
chainId?: number;
|
|
52
52
|
issuedAt?: string;
|
|
53
|
-
jwk?: Record<string, unknown>;
|
|
54
53
|
notBefore?: string;
|
|
54
|
+
jwk?: Record<string, unknown>;
|
|
55
55
|
expirationTime?: string;
|
|
56
56
|
parents?: string[];
|
|
57
57
|
}>;
|
package/dist/modules/tcw.d.ts
CHANGED
|
@@ -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;
|
|
@@ -312,8 +321,6 @@ export declare class TinyCloudWeb {
|
|
|
312
321
|
} : never : never): Promise<OwnerDelegationReceipt>;
|
|
313
322
|
/** Register signed policy material through the Node-owned Policy/v3 runtime. */
|
|
314
323
|
registerPolicy(params: Omit<RegisterPolicyV3Input, "nodeOrigin" | "fetch">): Promise<RegisterPolicyV3Receipt>;
|
|
315
|
-
/** @deprecated Policy/v2 delivery transport is retired. Use authorizeShareDeliveryV3. */
|
|
316
|
-
authorizeShareDelivery(input: Parameters<TinyCloudNode["authorizeShareDelivery"]>[0]): ReturnType<TinyCloudNode["authorizeShareDelivery"]>;
|
|
317
324
|
/** Authorize a short-lived, one-use v3 delivery against the signed envelope and roots. */
|
|
318
325
|
authorizeShareDeliveryV3(input: Parameters<TinyCloudNode["authorizeShareDeliveryV3"]>[0]): ReturnType<TinyCloudNode["authorizeShareDeliveryV3"]>;
|
|
319
326
|
/**
|
|
@@ -386,9 +393,11 @@ export declare class TinyCloudWeb {
|
|
|
386
393
|
listDelegations(): Promise<Result<Delegation[], DelegationError>>;
|
|
387
394
|
checkPermission(path: string, action: string): Promise<Result<boolean, DelegationError>>;
|
|
388
395
|
/**
|
|
389
|
-
* Receive and retrieve data from a
|
|
396
|
+
* Receive and retrieve data from a native TinyCloud bearer delegation.
|
|
390
397
|
* Static method — no auth required. Uses browser WASM.
|
|
391
398
|
*/
|
|
392
|
-
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>>;
|
|
393
402
|
}
|
|
394
403
|
//# sourceMappingURL=tcw.d.ts.map
|
package/dist/share/service.d.ts
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
+
import { type CredentialRequirement } from "@tinycloud/sdk-core";
|
|
1
2
|
import { type ShareMetadata } from "@tinycloud/share-sdk";
|
|
2
3
|
import { type ShareEnvelopeV3 } from "@tinycloud/share-envelope";
|
|
3
4
|
import { CredentialsService } from "../credentials";
|
|
4
5
|
import { type ReceiverSessionStorage } from "./receiver-session";
|
|
5
|
-
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";
|
|
6
7
|
export interface ShareReceiverServiceOptions {
|
|
7
8
|
readonly origin?: string;
|
|
8
9
|
readonly sessionStorage?: ReceiverSessionStorage;
|
|
9
10
|
readonly credentialDiscoveryUrl?: string;
|
|
10
11
|
/** Out-of-band Share application origin allowed to supply invitation URLs. */
|
|
11
12
|
readonly expectedShareOrigin: string;
|
|
12
|
-
/**
|
|
13
|
-
readonly
|
|
14
|
-
/** Pinned Node identity used by recipient response verification. */
|
|
15
|
-
readonly trustedNode: {
|
|
16
|
-
readonly invitationKid: string;
|
|
17
|
-
readonly invitationPublicKey: Uint8Array;
|
|
18
|
-
};
|
|
19
|
-
/** Exact Ed25519 enforcer DID committed as the signed envelope target. */
|
|
20
|
-
readonly expectedEnforcerDid: string;
|
|
13
|
+
/** Registry containing the share owner's signed TinyCloud location record. */
|
|
14
|
+
readonly registryOrigin: string;
|
|
21
15
|
readonly fetch?: typeof fetch;
|
|
22
16
|
}
|
|
23
|
-
export declare function validateShareReceiverServiceTrust(envelope: Pick<ShareEnvelopeV3, "target"
|
|
24
|
-
readonly invitationKid: string;
|
|
25
|
-
readonly invitationPublicKey: Uint8Array;
|
|
26
|
-
};
|
|
27
|
-
/** @internal */
|
|
28
|
-
export declare function validateShareReceiverRegistryBaseUrl(value: string): string;
|
|
17
|
+
export declare function validateShareReceiverServiceTrust(envelope: Pick<ShareEnvelopeV3, "target" | "attestedEnforcerBinding">): void;
|
|
29
18
|
/** @internal */
|
|
30
19
|
export declare function validateShareReceiverExpectedOrigin(shareUrl: string, expectedOrigin: string): string;
|
|
31
20
|
/** @internal */
|
|
32
21
|
export declare function selectShareReceiverAccountSession(client: ShareReceiverClient, requestedIdentity: ShareReceiveOptions["identity"]): Promise<ReturnType<ShareReceiverClient["session"]>>;
|
|
33
|
-
/**
|
|
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>;
|
|
34
28
|
export declare class ReceivedShareImpl implements ReceivedShare {
|
|
35
29
|
readonly identity: ShareReceiverIdentity;
|
|
36
30
|
readonly metadata: ShareMetadata;
|
|
37
31
|
private readonly envelope;
|
|
32
|
+
private readonly requirement;
|
|
38
33
|
private readonly credentials;
|
|
39
34
|
private readonly sign;
|
|
40
35
|
private readonly options;
|
|
41
36
|
private readonly fetchFn;
|
|
42
37
|
private readonly credentialDiscoveryUrl;
|
|
43
|
-
private readonly trustedNode;
|
|
44
38
|
private content?;
|
|
45
39
|
private getPromise?;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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);
|
|
50
44
|
get shareId(): string;
|
|
51
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;
|
|
52
51
|
private load;
|
|
52
|
+
delegate(options: ShareDelegateOptions): Promise<ShareDelegation>;
|
|
53
53
|
importInto(accountClient: ShareImportAccountClient, options: ShareImportOptions): Promise<ShareImportResult>;
|
|
54
54
|
}
|
|
55
55
|
export declare class ShareReceiverService {
|
package/dist/share/types.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export type ShareReceiveProgress = {
|
|
|
17
17
|
} | {
|
|
18
18
|
readonly state: "credential-acquisition";
|
|
19
19
|
readonly status: "started" | "completed";
|
|
20
|
+
readonly mailbox?: string;
|
|
20
21
|
} | {
|
|
21
22
|
readonly state: "policy-admission";
|
|
22
23
|
readonly status: "started" | "completed";
|
|
@@ -44,6 +45,34 @@ export interface ShareReceiveOptions {
|
|
|
44
45
|
};
|
|
45
46
|
readonly signal?: AbortSignal;
|
|
46
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;
|
|
47
76
|
}
|
|
48
77
|
export interface ShareReceivedContent {
|
|
49
78
|
readonly bytes: Uint8Array;
|
|
@@ -69,12 +98,33 @@ export interface ShareImportAccountClient {
|
|
|
69
98
|
ensureOwnedSpaceHosted(name: string): Promise<string>;
|
|
70
99
|
kvForSpace(spaceId: string): IKVService;
|
|
71
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
|
+
};
|
|
72
115
|
export interface ReceivedShare {
|
|
73
116
|
readonly identity: ShareReceiverIdentity;
|
|
117
|
+
readonly recipient: ShareReceiverRecipient;
|
|
74
118
|
readonly metadata: ShareMetadata;
|
|
75
119
|
readonly shareId: string;
|
|
76
120
|
get(): Promise<ShareReceivedContent>;
|
|
77
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>;
|
|
78
128
|
}
|
|
79
129
|
export interface ShareReceiverClient extends ShareImportAccountClient {
|
|
80
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
|
|
3
|
+
"version": "3.0.0",
|
|
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
|
|
47
|
-
"@tinycloud/sdk-core": "3.0.0
|
|
48
|
-
"@tinycloud/share-envelope": "0.
|
|
49
|
-
"@tinycloud/share-sdk": "0.
|
|
46
|
+
"@tinycloud/node-sdk": "3.0.0",
|
|
47
|
+
"@tinycloud/sdk-core": "3.0.0",
|
|
48
|
+
"@tinycloud/share-envelope": "1.0.0",
|
|
49
|
+
"@tinycloud/share-sdk": "1.0.0",
|
|
50
50
|
"@tinycloud/web-sdk-wasm": "1.7.6",
|
|
51
51
|
"axios": "^1.7.9",
|
|
52
52
|
"viem": "^2.45.0",
|