@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
package/dist/modules/tcw.d.ts
CHANGED
|
@@ -9,12 +9,13 @@
|
|
|
9
9
|
*
|
|
10
10
|
* @packageDocumentation
|
|
11
11
|
*/
|
|
12
|
-
import { TinyCloudNode, type BootstrapWarning, type DelegateToOptions, type DelegateToResult, type ISessionStorage, type SignStrategy } from "@tinycloud/node-sdk/core";
|
|
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
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 RegisterOwnerSharePolicyParams, type OwnerSharePolicyRegistrationReceipt, type LocalNodeIdentityStore, SignInOptions } from "@tinycloud/sdk-core";
|
|
14
|
-
import type
|
|
14
|
+
import { type BrowserProvider, type BrowserWalletProvider } from "../adapters/browserProvider";
|
|
15
15
|
import { RPCProviders, ClientConfig } from "../providers";
|
|
16
16
|
import type { NotificationConfig } from "../notifications/types";
|
|
17
17
|
import type { PortableDelegation, DelegatedAccess } from "@tinycloud/node-sdk/core";
|
|
18
|
+
import { CredentialsService } from "../credentials";
|
|
18
19
|
declare global {
|
|
19
20
|
interface Window {
|
|
20
21
|
ethereum?: any;
|
|
@@ -78,6 +79,8 @@ export interface Config extends ClientConfig {
|
|
|
78
79
|
persistSession?: boolean;
|
|
79
80
|
/** Custom session storage implementation. */
|
|
80
81
|
sessionStorage?: ISessionStorage;
|
|
82
|
+
/** Whether to run node-sdk's canonical first-account bootstrap after sign-in. */
|
|
83
|
+
autoBootstrapAccount?: boolean;
|
|
81
84
|
/** Browser storage key prefix for isolating apps/environments. */
|
|
82
85
|
sessionStorageKeyPrefix?: string;
|
|
83
86
|
/** SIWE domain (default: window.location.hostname in browser, app.tinycloud.xyz otherwise) */
|
|
@@ -102,7 +105,7 @@ export interface Config extends ClientConfig {
|
|
|
102
105
|
capabilityRequest?: ComposedManifestRequest;
|
|
103
106
|
/** Strategy for TinyCloud root signature requests. */
|
|
104
107
|
signStrategy?: SignStrategy;
|
|
105
|
-
/** Include
|
|
108
|
+
/** Include canonical account registry read/create-update/list permissions in plain sessions and composed manifests. Default true. */
|
|
106
109
|
includeAccountRegistryPermissions?: boolean;
|
|
107
110
|
/** Default-off service telemetry. */
|
|
108
111
|
telemetry?: TelemetryConfig;
|
|
@@ -133,8 +136,10 @@ export interface ShareReceiveResult<T = unknown> {
|
|
|
133
136
|
spaceId: string;
|
|
134
137
|
}
|
|
135
138
|
export declare class TinyCloudWeb {
|
|
136
|
-
/** The
|
|
137
|
-
provider:
|
|
139
|
+
/** The connected wallet's raw EIP-1193 provider. */
|
|
140
|
+
provider: BrowserProvider;
|
|
141
|
+
/** The normalized EIP-1193 provider used by the SDK. */
|
|
142
|
+
eip1193Provider: BrowserProvider;
|
|
138
143
|
/** Supported RPC Providers */
|
|
139
144
|
static RPCProviders: typeof RPCProviders;
|
|
140
145
|
/** Underlying TinyCloudNode (created after WASM init) */
|
|
@@ -148,6 +153,7 @@ export declare class TinyCloudWeb {
|
|
|
148
153
|
private sessionStorage?;
|
|
149
154
|
private _sessionRestoreStatus;
|
|
150
155
|
private _secrets;
|
|
156
|
+
private _credentialsService?;
|
|
151
157
|
/** Promise that resolves when WASM + node are ready */
|
|
152
158
|
private _initPromise;
|
|
153
159
|
/** User config */
|
|
@@ -224,6 +230,8 @@ export declare class TinyCloudWeb {
|
|
|
224
230
|
get account(): AccountService;
|
|
225
231
|
get hosts(): string[];
|
|
226
232
|
get sessionRestoreStatus(): SessionRestoreStatus;
|
|
233
|
+
/** Holder-bound OpenCredentials issuance using the active TinyCloud session. */
|
|
234
|
+
get credentials(): CredentialsService;
|
|
227
235
|
space(nameOrUri: string): ISpace;
|
|
228
236
|
get kvPrefix(): string;
|
|
229
237
|
getEncryptionNetwork(nameOrNetworkId?: string): Promise<NetworkDescriptor | null>;
|
|
@@ -263,13 +271,26 @@ export declare class TinyCloudWeb {
|
|
|
263
271
|
chainId: () => number | undefined;
|
|
264
272
|
get did(): string;
|
|
265
273
|
get sessionDid(): string;
|
|
274
|
+
get credentialHolderDid(): string;
|
|
275
|
+
get credentialHolderKid(): string;
|
|
266
276
|
get isSessionOnly(): boolean;
|
|
267
277
|
get isWalletConnected(): boolean;
|
|
268
278
|
/** Sign protocol bytes with the established session key without exposing key material. */
|
|
269
279
|
signSessionBytes(bytes: Uint8Array): Promise<Uint8Array>;
|
|
280
|
+
createUnifiedOwnerRoot(input: UnifiedOwnerRootInput): Promise<UnifiedOwnerRootReceipt>;
|
|
281
|
+
autoSignCredentialBytes(bytes: Uint8Array): Promise<Uint8Array | undefined>;
|
|
282
|
+
approveCredentialBytes(bytes: Uint8Array): Promise<Uint8Array>;
|
|
283
|
+
activateCompactRuntimeDelegation(input: {
|
|
284
|
+
readonly authorization: string;
|
|
285
|
+
readonly cid: string;
|
|
286
|
+
readonly host: string;
|
|
287
|
+
}): Promise<ValidatedRuntimeDelegation>;
|
|
288
|
+
credentialSpaceOwnerDid(spaceId: string): string;
|
|
289
|
+
/** Root authorization CID of the active session, which {@link session} omits. */
|
|
290
|
+
accountAuthorizationCid(): string;
|
|
270
291
|
extend(_extension: Extension): void;
|
|
271
292
|
cleanup(): void;
|
|
272
|
-
connectWallet(provider:
|
|
293
|
+
connectWallet(provider: BrowserWalletProvider, options?: {
|
|
273
294
|
spacePrefix?: string;
|
|
274
295
|
}): void;
|
|
275
296
|
createDelegation(params: {
|
|
@@ -345,6 +366,12 @@ export declare class TinyCloudWeb {
|
|
|
345
366
|
delegateDID: string;
|
|
346
367
|
disableSubDelegation?: boolean;
|
|
347
368
|
expiryMs?: number;
|
|
369
|
+
resources?: Array<{
|
|
370
|
+
service: string;
|
|
371
|
+
space?: string;
|
|
372
|
+
path: string;
|
|
373
|
+
actions: string[];
|
|
374
|
+
}>;
|
|
348
375
|
}): Promise<PortableDelegation>;
|
|
349
376
|
delegate(params: CreateDelegationParams): Promise<Result<Delegation, DelegationError>>;
|
|
350
377
|
revokeDelegation(cid: string): Promise<Result<DelegationRevocationReceipt, DelegationError>>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ClientSession, Manifest } from "@tinycloud/sdk-core";
|
|
1
|
+
import type { ClientSession, Manifest, SignCallback } from "@tinycloud/sdk-core";
|
|
2
2
|
import { TinyCloudWeb, type Config } from "./modules/tcw";
|
|
3
3
|
declare const SESSION_EXPIRATION_MS: 3600000;
|
|
4
4
|
declare const SESSION_STORAGE_KEY_PREFIX: "coordinationos:tinycloud:session:v1:";
|
|
5
|
-
type CoordinationOsControlledConfig = "provider" | "providers" | "signStrategy" | "manifest" | "capabilityRequest" | "siweConfig" | "nonce" | "domain" | "persistSession" | "sessionStorage" | "sessionExpirationMs" | "sessionStorageKeyPrefix" | "includeAccountRegistryPermissions" | "autoCreateSpace" | "spaceCreationHandler" | "spacePrefix" | "kvPrefix";
|
|
5
|
+
type CoordinationOsControlledConfig = "provider" | "providers" | "signStrategy" | "manifest" | "capabilityRequest" | "siweConfig" | "nonce" | "domain" | "persistSession" | "sessionStorage" | "sessionExpirationMs" | "sessionStorageKeyPrefix" | "includeAccountRegistryPermissions" | "autoCreateSpace" | "autoBootstrapAccount" | "spaceCreationHandler" | "spacePrefix" | "kvPrefix";
|
|
6
6
|
export type EstablishOpenKeySessionStatus = "established" | "restored" | "missing" | "expired" | "corrupt" | "storage-unavailable" | "restore-failed" | "stale" | "disabled";
|
|
7
7
|
export interface EstablishOpenKeySessionOptions {
|
|
8
8
|
providerToken?: string;
|
|
@@ -18,6 +18,8 @@ export interface EstablishOpenKeySessionOptions {
|
|
|
18
18
|
sessionStorageKeyPrefix: typeof SESSION_STORAGE_KEY_PREFIX;
|
|
19
19
|
tinycloud?: Omit<Config, CoordinationOsControlledConfig>;
|
|
20
20
|
fetch?: typeof fetch;
|
|
21
|
+
/** Normal OpenKey consent surface for credential bindings outside Auto-Sign policy. */
|
|
22
|
+
requestCredentialApproval?: SignCallback;
|
|
21
23
|
}
|
|
22
24
|
export interface EstablishOpenKeySessionResult {
|
|
23
25
|
client: TinyCloudWeb;
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* Browser-coupled extension types.
|
|
3
3
|
*
|
|
4
4
|
* These types stay in web-sdk because they depend on browser-specific
|
|
5
|
-
* APIs (@tinycloud/web-sdk-wasm,
|
|
5
|
+
* APIs (@tinycloud/web-sdk-wasm, EIP-1193 provider, axios).
|
|
6
6
|
*
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
9
|
import { tcwSession } from "@tinycloud/web-sdk-wasm";
|
|
10
10
|
import { AxiosInstance } from "axios";
|
|
11
|
-
import {
|
|
11
|
+
import type { BrowserProvider } from "../adapters/browserProvider";
|
|
12
12
|
import type { ClientSession, SiweConfig } from "@tinycloud/sdk-core";
|
|
13
13
|
import type { ClientConfig } from "./config";
|
|
14
14
|
/** Extra SIWE fields. */
|
|
@@ -26,7 +26,7 @@ export interface IConnected {
|
|
|
26
26
|
/** List of enabled extensions. */
|
|
27
27
|
extensions: Extension[];
|
|
28
28
|
/** Web3 provider. */
|
|
29
|
-
provider:
|
|
29
|
+
provider: BrowserProvider;
|
|
30
30
|
/** Promise that is initialized on construction to run the "afterConnect" methods of extensions. */
|
|
31
31
|
afterConnectHooksPromise: Promise<void>;
|
|
32
32
|
/** Method to verify if extension is enabled. */
|
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
6
|
import { z } from "zod";
|
|
7
|
-
import { providers } from "ethers";
|
|
8
|
-
import { ConnectionInfo } from "ethers/lib/utils";
|
|
9
7
|
import type { AxiosRequestConfig } from "axios";
|
|
10
8
|
import type { ClientSession } from "@tinycloud/sdk-core";
|
|
9
|
+
export type ConnectionInfo = Record<string, unknown>;
|
|
10
|
+
export type Networkish = string | number | {
|
|
11
|
+
chainId: number | string;
|
|
12
|
+
name?: string;
|
|
13
|
+
};
|
|
11
14
|
/** Enum of supported EthersJS providers. */
|
|
12
15
|
export declare enum RPCProviders {
|
|
13
16
|
AlchemyProvider = "alchemy",
|
|
@@ -110,13 +113,13 @@ export type AnkrProvider = {
|
|
|
110
113
|
export type CustomProvider = {
|
|
111
114
|
service: RPCProviders.CustomProvider;
|
|
112
115
|
url?: string | ConnectionInfo;
|
|
113
|
-
network?:
|
|
116
|
+
network?: Networkish;
|
|
114
117
|
};
|
|
115
118
|
/** Generic provider settings. */
|
|
116
119
|
export type GenericProvider = {
|
|
117
120
|
service: RPCProviders;
|
|
118
121
|
url?: string | ConnectionInfo;
|
|
119
|
-
network?:
|
|
122
|
+
network?: Networkish;
|
|
120
123
|
apiKey?: string | InfuraProviderProjectSettings;
|
|
121
124
|
};
|
|
122
125
|
/** Supported provider types. */
|
|
@@ -385,7 +388,7 @@ export declare const GenericProviderSchema: z.ZodObject<{
|
|
|
385
388
|
projectSecret?: string;
|
|
386
389
|
}>]>>;
|
|
387
390
|
}, "strip", z.ZodTypeAny, {
|
|
388
|
-
service?: "
|
|
391
|
+
service?: "custom" | "alchemy" | "ankr" | "cloudflare" | "etherscan" | "infura" | "pocket";
|
|
389
392
|
apiKey?: string | {
|
|
390
393
|
projectId?: string;
|
|
391
394
|
projectSecret?: string;
|
|
@@ -393,7 +396,7 @@ export declare const GenericProviderSchema: z.ZodObject<{
|
|
|
393
396
|
network?: unknown;
|
|
394
397
|
url?: unknown;
|
|
395
398
|
}, {
|
|
396
|
-
service?: "
|
|
399
|
+
service?: "custom" | "alchemy" | "ankr" | "cloudflare" | "etherscan" | "infura" | "pocket";
|
|
397
400
|
apiKey?: string | {
|
|
398
401
|
projectId?: string;
|
|
399
402
|
projectSecret?: string;
|
|
@@ -3,18 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
/**
|
|
9
|
-
* @param rpc - RPCProvider
|
|
10
|
-
* @returns an ethers provider based on the RPC configuration.
|
|
11
|
-
*/
|
|
12
|
-
export declare const getProvider: (rpc?: RPCProvider) => ethers.providers.BaseProvider;
|
|
6
|
+
import type { EnsData } from "./types";
|
|
7
|
+
import type { BrowserProvider } from "../adapters/browserProvider";
|
|
13
8
|
/**
|
|
14
9
|
* Resolves ENS data supported by TCW.
|
|
15
|
-
* @param provider -
|
|
10
|
+
* @param provider - EIP-1193 RPC provider.
|
|
16
11
|
* @param address - User address.
|
|
17
12
|
* @returns Object containing ENS data.
|
|
18
13
|
*/
|
|
19
|
-
export declare const resolveEns: (provider:
|
|
14
|
+
export declare const resolveEns: (provider: BrowserProvider, address: string) => Promise<EnsData>;
|
|
20
15
|
//# sourceMappingURL=utils.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinycloud/web-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.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",
|
|
@@ -41,16 +41,12 @@
|
|
|
41
41
|
"test": "jest"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@metamask/detect-provider": "^1.2.0",
|
|
45
44
|
"@multiformats/multiaddr": "^13.0.1",
|
|
46
45
|
"@multiformats/multiaddr-to-uri": "^12.0.0",
|
|
47
|
-
"@tinycloud/node-sdk": "
|
|
48
|
-
"@tinycloud/sdk-core": "
|
|
49
|
-
"@tinycloud/web-sdk-wasm": "1.7.6
|
|
46
|
+
"@tinycloud/node-sdk": "3.0.0-beta.0",
|
|
47
|
+
"@tinycloud/sdk-core": "3.0.0-beta.0",
|
|
48
|
+
"@tinycloud/web-sdk-wasm": "1.7.6",
|
|
50
49
|
"axios": "^1.7.9",
|
|
51
|
-
"ethers": "^5.7.2",
|
|
52
|
-
"lodash.merge": "^4.6.2",
|
|
53
|
-
"siwe": "^3.0.0",
|
|
54
50
|
"viem": "^2.45.0",
|
|
55
51
|
"zod": "^3.22.0"
|
|
56
52
|
},
|
|
@@ -59,7 +55,6 @@
|
|
|
59
55
|
"@microsoft/api-documenter": "^7.26.5",
|
|
60
56
|
"@microsoft/api-extractor": "^7.49.1",
|
|
61
57
|
"@types/jest": "^30.0.0",
|
|
62
|
-
"@types/lodash.merge": "^4.6.9",
|
|
63
58
|
"@types/node": "^18.19.74",
|
|
64
59
|
"@types/webpack": "^5.28.5",
|
|
65
60
|
"@typescript-eslint/eslint-plugin": "^8.57.1",
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { type Address } from "viem";
|
|
2
|
-
import { providers } from "ethers";
|
|
3
|
-
export declare const REGISTRY_CONTRACT_ADDRESS: {
|
|
4
|
-
1: string;
|
|
5
|
-
11155111: string;
|
|
6
|
-
};
|
|
7
|
-
export interface RegistryConfig {
|
|
8
|
-
provider: providers.Web3Provider;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Registry provides access to the TinyCloud Registry contract for resolving
|
|
12
|
-
* account addresses to their associated node identifiers.
|
|
13
|
-
*/
|
|
14
|
-
export declare class Registry {
|
|
15
|
-
provider: providers.Web3Provider;
|
|
16
|
-
/**
|
|
17
|
-
* Creates a new instance of the Registry class.
|
|
18
|
-
*
|
|
19
|
-
* @param config - Configuration options for the Registry
|
|
20
|
-
* @param config.rpcUrl - The RPC URL to connect to the blockchain
|
|
21
|
-
* @param config.contractAddress - The address of the Registry contract
|
|
22
|
-
*/
|
|
23
|
-
constructor(config: RegistryConfig);
|
|
24
|
-
/**
|
|
25
|
-
* Gets the node identifier associated with an account address.
|
|
26
|
-
*
|
|
27
|
-
* @param account - The account address to look up
|
|
28
|
-
* @returns A Promise containing the node identifier string
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```ts
|
|
32
|
-
* const registry = new Registry({
|
|
33
|
-
* rpcUrl: 'https://mainnet.base.org',
|
|
34
|
-
* contractAddress: '0x...'
|
|
35
|
-
* });
|
|
36
|
-
* const node = await registry.getNode('0x1234...');
|
|
37
|
-
* console.log(node); // 'my-node-id'
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
getNode(account: Address): Promise<string>;
|
|
41
|
-
addressNode(): Promise<string>;
|
|
42
|
-
/**
|
|
43
|
-
* Checks if an account has a registered node.
|
|
44
|
-
*
|
|
45
|
-
* @param account - The account address to check
|
|
46
|
-
* @returns A Promise containing a boolean indicating if the account has a node
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```ts
|
|
50
|
-
* const hasNode = await registry.hasNode('0x1234...');
|
|
51
|
-
* if (hasNode) {
|
|
52
|
-
* const node = await registry.getNode('0x1234...');
|
|
53
|
-
* }
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
hasNode(account: Address): Promise<boolean>;
|
|
57
|
-
}
|
|
58
|
-
export default Registry;
|
|
59
|
-
//# sourceMappingURL=Registry.d.ts.map
|