@tinycloud/web-sdk 1.0.0 → 1.1.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/authorization/WebUserAuthorization.d.ts.map +1 -1
- package/dist/delegation.d.ts +0 -1
- package/dist/delegation.d.ts.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/modules/index.d.ts +0 -1
- package/dist/modules/index.d.ts.map +1 -1
- package/dist/modules/tcw.d.ts +35 -67
- package/dist/modules/tcw.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/625.index.js +0 -1
- package/dist/modules/UserAuthorization.d.ts +0 -361
- package/dist/modules/UserAuthorization.d.ts.map +0 -1
package/dist/modules/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/modules/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/modules/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAGrC,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,eAAe,EACf,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EACzB,8BAA8B,GAC/B,MAAM,kBAAkB,CAAC"}
|
package/dist/modules/tcw.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { RPCProviders } from '@tinycloud/web-core';
|
|
2
|
-
import { IUserAuthorization } from '.';
|
|
3
2
|
import { WebUserAuthorization, WebSignStrategy } from '../authorization';
|
|
4
3
|
import { ClientConfig, ClientSession, Extension } from '@tinycloud/web-core/client';
|
|
5
4
|
import type { providers } from 'ethers';
|
|
@@ -14,11 +13,10 @@ declare global {
|
|
|
14
13
|
/**
|
|
15
14
|
* Configuration for TinyCloudWeb.
|
|
16
15
|
*
|
|
17
|
-
* Extends ClientConfig with notification options and the
|
|
16
|
+
* Extends ClientConfig with notification options and the unified auth module.
|
|
18
17
|
*
|
|
19
|
-
* ##
|
|
18
|
+
* ## Auth Module Features
|
|
20
19
|
*
|
|
21
|
-
* Set `useNewAuth: true` to enable the new unified auth architecture with:
|
|
22
20
|
* - **SignStrategy pattern**: Control how sign requests are handled
|
|
23
21
|
* - **Session-only mode**: Receive delegations without a wallet
|
|
24
22
|
* - **`did` vs `sessionDid` model**: Clear identity distinction
|
|
@@ -26,20 +24,15 @@ declare global {
|
|
|
26
24
|
*
|
|
27
25
|
* @example
|
|
28
26
|
* ```typescript
|
|
29
|
-
* //
|
|
27
|
+
* // Standard wallet popup flow
|
|
30
28
|
* const tcw = new TinyCloudWeb({
|
|
31
|
-
* providers: { web3: { driver: window.ethereum } }
|
|
32
|
-
* });
|
|
33
|
-
*
|
|
34
|
-
* // New auth mode (recommended for new projects)
|
|
35
|
-
* const tcw = new TinyCloudWeb({
|
|
36
|
-
* useNewAuth: true,
|
|
29
|
+
* providers: { web3: { driver: window.ethereum } },
|
|
37
30
|
* signStrategy: { type: 'wallet-popup' },
|
|
38
31
|
* spaceCreationHandler: new ModalSpaceCreationHandler()
|
|
39
32
|
* });
|
|
40
33
|
*
|
|
41
34
|
* // Session-only mode (no wallet required)
|
|
42
|
-
* const tcw = new TinyCloudWeb(
|
|
35
|
+
* const tcw = new TinyCloudWeb();
|
|
43
36
|
* console.log(tcw.sessionDid); // did:key:z6Mk...
|
|
44
37
|
* ```
|
|
45
38
|
*/
|
|
@@ -63,26 +56,10 @@ export interface Config extends ClientConfig {
|
|
|
63
56
|
* @default true
|
|
64
57
|
*/
|
|
65
58
|
autoCreateSpace?: boolean;
|
|
66
|
-
/**
|
|
67
|
-
* Whether to use the new WebUserAuthorization class.
|
|
68
|
-
*
|
|
69
|
-
* When `true`, uses the new unified auth module architecture featuring:
|
|
70
|
-
* - SignStrategy pattern for controlling sign requests
|
|
71
|
-
* - Session-only mode (receive delegations without wallet)
|
|
72
|
-
* - Clear `did` vs `sessionDid` model
|
|
73
|
-
* - `connectWallet()` upgrade pattern
|
|
74
|
-
*
|
|
75
|
-
* When `false` (default), uses the legacy UserAuthorization for backward compatibility.
|
|
76
|
-
*
|
|
77
|
-
* **Recommended**: Set to `true` for new projects or when migrating to 1.0.0.
|
|
78
|
-
*
|
|
79
|
-
* @default false
|
|
80
|
-
*/
|
|
81
|
-
useNewAuth?: boolean;
|
|
82
59
|
/**
|
|
83
60
|
* Sign strategy for handling sign requests.
|
|
84
61
|
*
|
|
85
|
-
*
|
|
62
|
+
* Determines how SIWE signing is handled:
|
|
86
63
|
* - `'wallet-popup'` (default): Show browser wallet popup
|
|
87
64
|
* - `{ type: 'auto-sign' }`: Automatically sign (requires external signer setup)
|
|
88
65
|
* - `{ type: 'callback', handler: fn }`: Custom callback for sign requests
|
|
@@ -107,7 +84,7 @@ export interface Config extends ClientConfig {
|
|
|
107
84
|
/**
|
|
108
85
|
* Handler for space creation confirmation.
|
|
109
86
|
*
|
|
110
|
-
*
|
|
87
|
+
* Controls how space creation is confirmed:
|
|
111
88
|
* - `ModalSpaceCreationHandler` (default): Shows a modal dialog
|
|
112
89
|
* - `{ confirmSpaceCreation: async () => true }`: Auto-approve
|
|
113
90
|
* - Custom implementation of `ISpaceCreationHandler`
|
|
@@ -191,12 +168,8 @@ export declare class TinyCloudWeb {
|
|
|
191
168
|
* - session key management
|
|
192
169
|
* - creates, manages, and handles session data
|
|
193
170
|
* - manages/provides capabilities
|
|
194
|
-
*
|
|
195
|
-
* NOTE: When useNewAuth is true, this is a WebUserAuthorization instance.
|
|
196
|
-
* The type is `any` to allow both legacy and new auth modules.
|
|
197
|
-
* Use `webAuth` getter for typed access to WebUserAuthorization.
|
|
198
171
|
*/
|
|
199
|
-
userAuthorization:
|
|
172
|
+
userAuthorization: WebUserAuthorization;
|
|
200
173
|
/** Error Handler for Notifications */
|
|
201
174
|
private errorHandler;
|
|
202
175
|
/** Service Context for sdk-services */
|
|
@@ -216,7 +189,7 @@ export declare class TinyCloudWeb {
|
|
|
216
189
|
constructor(config?: Config);
|
|
217
190
|
/**
|
|
218
191
|
* Create a WebUserAuthorization instance from the config.
|
|
219
|
-
* Maps
|
|
192
|
+
* Maps Config options to WebUserAuthorizationConfig.
|
|
220
193
|
* @private
|
|
221
194
|
*/
|
|
222
195
|
private createWebUserAuthorization;
|
|
@@ -393,10 +366,26 @@ export declare class TinyCloudWeb {
|
|
|
393
366
|
*/
|
|
394
367
|
private createDelegationWrapper;
|
|
395
368
|
/**
|
|
396
|
-
* Get the session expiry time.
|
|
369
|
+
* Get the session expiry time by parsing the SIWE message.
|
|
397
370
|
* @internal
|
|
398
371
|
*/
|
|
399
372
|
private getSessionExpiry;
|
|
373
|
+
/**
|
|
374
|
+
* Create a direct root delegation from the wallet to a share key.
|
|
375
|
+
* This is the CORRECT solution for long-lived share links.
|
|
376
|
+
*
|
|
377
|
+
* Instead of creating a sub-delegation chain (PKH -> session key -> share key),
|
|
378
|
+
* this creates a DIRECT delegation (PKH -> share key), which is not constrained
|
|
379
|
+
* by the session's expiry time.
|
|
380
|
+
*
|
|
381
|
+
* This will trigger the OpenKey popup to sign a new SIWE message.
|
|
382
|
+
*
|
|
383
|
+
* @param params - Parameters for creating the root delegation
|
|
384
|
+
* @param hosts - TinyCloud host URLs
|
|
385
|
+
* @returns The delegation from wallet to share key, or undefined if failed
|
|
386
|
+
* @internal
|
|
387
|
+
*/
|
|
388
|
+
private createRootDelegationForSharing;
|
|
400
389
|
/**
|
|
401
390
|
* Create a delegation using SIWE-based flow.
|
|
402
391
|
* This method implements the correct delegation creation pattern:
|
|
@@ -416,7 +405,7 @@ export declare class TinyCloudWeb {
|
|
|
416
405
|
private createDelegationWithSIWE;
|
|
417
406
|
/**
|
|
418
407
|
* Convert TinyCloud session to ServiceSession.
|
|
419
|
-
* Gets session from
|
|
408
|
+
* Gets session from WebUserAuthorization.
|
|
420
409
|
* @internal
|
|
421
410
|
*/
|
|
422
411
|
private toServiceSession;
|
|
@@ -454,47 +443,31 @@ export declare class TinyCloudWeb {
|
|
|
454
443
|
*/
|
|
455
444
|
chainId: () => number | undefined;
|
|
456
445
|
/**
|
|
457
|
-
*
|
|
458
|
-
* @returns true if using WebUserAuthorization, false if using legacy UserAuthorization
|
|
459
|
-
*/
|
|
460
|
-
get isNewAuthEnabled(): boolean;
|
|
461
|
-
/**
|
|
462
|
-
* Get the WebUserAuthorization instance (new auth module only).
|
|
463
|
-
* Throws if not using new auth module.
|
|
464
|
-
*
|
|
465
|
-
* @throws Error if useNewAuth is false
|
|
446
|
+
* Get the WebUserAuthorization instance.
|
|
466
447
|
*/
|
|
467
448
|
get webAuth(): WebUserAuthorization;
|
|
468
449
|
/**
|
|
469
|
-
* Get the primary DID for this user
|
|
450
|
+
* Get the primary DID for this user.
|
|
470
451
|
*
|
|
471
452
|
* - If wallet connected and signed in: returns PKH DID (persistent identity)
|
|
472
453
|
* - If session-only mode: returns session key DID (ephemeral)
|
|
473
|
-
*
|
|
474
|
-
* @throws Error if useNewAuth is false
|
|
475
454
|
*/
|
|
476
455
|
get did(): string;
|
|
477
456
|
/**
|
|
478
|
-
* Get the session key DID
|
|
457
|
+
* Get the session key DID.
|
|
479
458
|
* Always available, even before sign-in.
|
|
480
459
|
*
|
|
481
460
|
* Format: `did:key:z6Mk...#z6Mk...`
|
|
482
|
-
*
|
|
483
|
-
* @throws Error if useNewAuth is false
|
|
484
461
|
*/
|
|
485
462
|
get sessionDid(): string;
|
|
486
463
|
/**
|
|
487
|
-
* Check if in session-only mode
|
|
464
|
+
* Check if in session-only mode.
|
|
488
465
|
* Session-only mode means no wallet is connected, but delegations can be received.
|
|
489
|
-
*
|
|
490
|
-
* @throws Error if useNewAuth is false
|
|
491
466
|
*/
|
|
492
467
|
get isSessionOnly(): boolean;
|
|
493
468
|
/**
|
|
494
|
-
* Check if a wallet is connected
|
|
469
|
+
* Check if a wallet is connected.
|
|
495
470
|
* Wallet may be connected but not signed in.
|
|
496
|
-
*
|
|
497
|
-
* @throws Error if useNewAuth is false
|
|
498
471
|
*/
|
|
499
472
|
get isWalletConnected(): boolean;
|
|
500
473
|
/**
|
|
@@ -506,12 +479,10 @@ export declare class TinyCloudWeb {
|
|
|
506
479
|
* @param provider - Web3 provider (e.g., window.ethereum)
|
|
507
480
|
* @param options - Optional configuration
|
|
508
481
|
*
|
|
509
|
-
* @throws Error if useNewAuth is false
|
|
510
|
-
*
|
|
511
482
|
* @example
|
|
512
483
|
* ```typescript
|
|
513
484
|
* // Create in session-only mode
|
|
514
|
-
* const tcw = new TinyCloudWeb(
|
|
485
|
+
* const tcw = new TinyCloudWeb();
|
|
515
486
|
* console.log(tcw.isSessionOnly); // true
|
|
516
487
|
*
|
|
517
488
|
* // User clicks "Connect Wallet"
|
|
@@ -538,14 +509,13 @@ export declare class TinyCloudWeb {
|
|
|
538
509
|
* @param delegation - The PortableDelegation to use (from createDelegation or transport)
|
|
539
510
|
* @returns A DelegatedAccess instance for performing operations
|
|
540
511
|
*
|
|
541
|
-
* @throws Error if useNewAuth is false (legacy auth not supported)
|
|
542
512
|
* @throws Error if in session-only mode and delegation doesn't target this user's DID
|
|
543
513
|
* @throws Error if in wallet mode and not signed in
|
|
544
514
|
*
|
|
545
515
|
* @example
|
|
546
516
|
* ```typescript
|
|
547
517
|
* // Session-only mode (most common for receiving delegations)
|
|
548
|
-
* const tcw = new TinyCloudWeb(
|
|
518
|
+
* const tcw = new TinyCloudWeb();
|
|
549
519
|
* const delegation = deserializeDelegation(receivedData);
|
|
550
520
|
*
|
|
551
521
|
* // The delegation must target tcw.did (session key DID in session-only mode)
|
|
@@ -556,7 +526,7 @@ export declare class TinyCloudWeb {
|
|
|
556
526
|
* await access.kv.put("shared/notes.txt", "Hello!");
|
|
557
527
|
*
|
|
558
528
|
* // Wallet mode (signed in user receiving delegation)
|
|
559
|
-
* const tcw = new TinyCloudWeb({
|
|
529
|
+
* const tcw = new TinyCloudWeb({ providers: { web3: { driver: window.ethereum } } });
|
|
560
530
|
* await tcw.signIn();
|
|
561
531
|
*
|
|
562
532
|
* // The delegation should target tcw.did (PKH DID when signed in)
|
|
@@ -639,7 +609,6 @@ export declare class TinyCloudWeb {
|
|
|
639
609
|
* @returns A portable delegation that can be sent to the recipient
|
|
640
610
|
*
|
|
641
611
|
* @throws Error if not signed in
|
|
642
|
-
* @throws Error if using legacy auth mode (requires useNewAuth: true)
|
|
643
612
|
*
|
|
644
613
|
* @example
|
|
645
614
|
* ```typescript
|
|
@@ -682,7 +651,6 @@ export declare class TinyCloudWeb {
|
|
|
682
651
|
* @param params - Sub-delegation parameters (must be within parent's scope)
|
|
683
652
|
* @returns A portable delegation for the sub-delegate
|
|
684
653
|
*
|
|
685
|
-
* @throws Error if useNewAuth is false (legacy auth not supported)
|
|
686
654
|
* @throws Error if in session-only mode (requires wallet)
|
|
687
655
|
* @throws Error if not signed in
|
|
688
656
|
* @throws Error if parent delegation does not allow sub-delegation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tcw.d.ts","sourceRoot":"","sources":["../../src/modules/tcw.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"tcw.d.ts","sourceRoot":"","sources":["../../src/modules/tcw.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,oBAAoB,EAEpB,eAAe,EAGhB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,aAAa,EACb,SAAS,EACV,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAGL,UAAU,EAKV,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ClB,2BAA2B;QAC3B,WAAW,EAAE,MAAM,CAAC;QACpB,6EAA6E;QAC7E,oBAAoB,CAAC,EAAE,OAAO,CAAC;QAC/B,gFAAgF;QAChF,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GACA,OAAO,CAAC,kBAAkB,CAAC;CA6G/B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinycloud/web-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A set of tools and utilities to help you build your app with TinyCloud.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"@metamask/detect-provider": "^1.2.0",
|
|
27
27
|
"@multiformats/multiaddr": "^13.0.1",
|
|
28
28
|
"@multiformats/multiaddr-to-uri": "^12.0.0",
|
|
29
|
-
"@tinycloud/sdk-core": "^1.
|
|
30
|
-
"@tinycloud/web-core": "^1.
|
|
31
|
-
"@tinycloud/web-sdk-wasm": "^1.0.
|
|
29
|
+
"@tinycloud/sdk-core": "^1.1.0",
|
|
30
|
+
"@tinycloud/web-core": "^1.1.0",
|
|
31
|
+
"@tinycloud/web-sdk-wasm": "^1.0.1",
|
|
32
32
|
"assert": "^2.1.0",
|
|
33
33
|
"axios": "^1.7.9",
|
|
34
34
|
"browser": "^0.2.6",
|
package/dist/625.index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(this.webpackChunk_tinycloud_web_sdk=this.webpackChunk_tinycloud_web_sdk||[]).push([[625],{8625(__unused_webpack___webpack_module__,__webpack_exports__,__webpack_require__){eval('{\n// EXPORTS\n__webpack_require__.d(__webpack_exports__, {\n WebSocket: () => (/* binding */ native_WebSocket)\n});\n\n;// ../../node_modules/isows/_esm/utils.js\nfunction getNativeWebSocket() {\n if (typeof WebSocket !== "undefined")\n return WebSocket;\n if (typeof __webpack_require__.g.WebSocket !== "undefined")\n return __webpack_require__.g.WebSocket;\n if (typeof window.WebSocket !== "undefined")\n return window.WebSocket;\n if (typeof self.WebSocket !== "undefined")\n return self.WebSocket;\n throw new Error("`WebSocket` is not supported in this environment");\n}\n//# sourceMappingURL=utils.js.map\n;// ../../node_modules/isows/_esm/native.js\n\nconst native_WebSocket = getNativeWebSocket();\n//# sourceMappingURL=native.js.map//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiODYyNS5qcyIsIm1hcHBpbmdzIjoiOzs7Ozs7O0FBQU87QUFDUDtBQUNBO0FBQ0EsZUFBZSxxQkFBTTtBQUNyQixlQUFlLHFCQUFNO0FBQ3JCO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBLGlDOztBQ1hnRDtBQUN6QyxNQUFNLGdCQUFTLEdBQUcsa0JBQWtCO0FBQzNDIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8vQHRpbnljbG91ZC93ZWItc2RrLy4uLy4uL25vZGVfbW9kdWxlcy9pc293cy9fZXNtL3V0aWxzLmpzP2MwODgiLCJ3ZWJwYWNrOi8vQHRpbnljbG91ZC93ZWItc2RrLy4uLy4uL25vZGVfbW9kdWxlcy9pc293cy9fZXNtL25hdGl2ZS5qcz9mN2Q3Il0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBmdW5jdGlvbiBnZXROYXRpdmVXZWJTb2NrZXQoKSB7XG4gICAgaWYgKHR5cGVvZiBXZWJTb2NrZXQgIT09IFwidW5kZWZpbmVkXCIpXG4gICAgICAgIHJldHVybiBXZWJTb2NrZXQ7XG4gICAgaWYgKHR5cGVvZiBnbG9iYWwuV2ViU29ja2V0ICE9PSBcInVuZGVmaW5lZFwiKVxuICAgICAgICByZXR1cm4gZ2xvYmFsLldlYlNvY2tldDtcbiAgICBpZiAodHlwZW9mIHdpbmRvdy5XZWJTb2NrZXQgIT09IFwidW5kZWZpbmVkXCIpXG4gICAgICAgIHJldHVybiB3aW5kb3cuV2ViU29ja2V0O1xuICAgIGlmICh0eXBlb2Ygc2VsZi5XZWJTb2NrZXQgIT09IFwidW5kZWZpbmVkXCIpXG4gICAgICAgIHJldHVybiBzZWxmLldlYlNvY2tldDtcbiAgICB0aHJvdyBuZXcgRXJyb3IoXCJgV2ViU29ja2V0YCBpcyBub3Qgc3VwcG9ydGVkIGluIHRoaXMgZW52aXJvbm1lbnRcIik7XG59XG4vLyMgc291cmNlTWFwcGluZ1VSTD11dGlscy5qcy5tYXAiLCJpbXBvcnQgeyBnZXROYXRpdmVXZWJTb2NrZXQgfSBmcm9tIFwiLi91dGlscy5qc1wiO1xuZXhwb3J0IGNvbnN0IFdlYlNvY2tldCA9IGdldE5hdGl2ZVdlYlNvY2tldCgpO1xuLy8jIHNvdXJjZU1hcHBpbmdVUkw9bmF0aXZlLmpzLm1hcCJdLCJuYW1lcyI6W10sInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///8625\n\n}')}}]);
|
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
import { providers, Signer } from "ethers";
|
|
2
|
-
import { tcwSession } from "@tinycloud/web-sdk-wasm";
|
|
3
|
-
import { AxiosInstance } from "axios";
|
|
4
|
-
import { SiweMessage } from "siwe";
|
|
5
|
-
import { EnsData } from "@tinycloud/web-core";
|
|
6
|
-
import type { ClientSession, ClientConfig, IConnected, Extension } from "@tinycloud/web-core/client";
|
|
7
|
-
import { IUserAuthorization as ICoreUserAuthorization, PartialSiweMessage } from "@tinycloud/sdk-core";
|
|
8
|
-
import { Session } from "./Storage/tinycloud";
|
|
9
|
-
/**
|
|
10
|
-
* Extended Client Config with TinyCloud options
|
|
11
|
-
*/
|
|
12
|
-
declare module "@tinycloud/web-core/client" {
|
|
13
|
-
interface ClientConfig {
|
|
14
|
-
/** Whether to automatically create space if it doesn't exist (default: true) */
|
|
15
|
-
autoCreateSpace?: boolean;
|
|
16
|
-
/** TinyCloud server endpoints (default: ["https://node.tinycloud.xyz"]) */
|
|
17
|
-
tinycloudHosts?: string[];
|
|
18
|
-
/** Space prefix for new sessions (default: "default") */
|
|
19
|
-
spacePrefix?: string;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Interface for tracking session state during SIWE message generation
|
|
24
|
-
*/
|
|
25
|
-
interface PendingSession {
|
|
26
|
-
/** Instance of SessionManager (null if consumed by build()) */
|
|
27
|
-
sessionManager: tcwSession.TCWSessionManager | null;
|
|
28
|
-
/** Session key JWK string (stored before build() consumes sessionManager) */
|
|
29
|
-
sessionKey?: string;
|
|
30
|
-
/** Ethereum address for the session */
|
|
31
|
-
address: string;
|
|
32
|
-
/** Timestamp when session was generated */
|
|
33
|
-
generatedAt: number;
|
|
34
|
-
/** Extensions that were applied to the session */
|
|
35
|
-
extensions: Extension[];
|
|
36
|
-
}
|
|
37
|
-
/** UserAuthorization Module
|
|
38
|
-
*
|
|
39
|
-
* Handles the capabilities that a user can provide a app, specifically
|
|
40
|
-
* authentication and authorization. This resource handles all key and
|
|
41
|
-
* signing capabilities including:
|
|
42
|
-
* - ethereum provider, wallet connection, SIWE message creation and signing
|
|
43
|
-
* - session key management
|
|
44
|
-
* - creates, manages, and handles session data
|
|
45
|
-
* - manages/provides capabilities
|
|
46
|
-
*/
|
|
47
|
-
interface IUserAuthorization {
|
|
48
|
-
provider: providers.Web3Provider;
|
|
49
|
-
session?: ClientSession;
|
|
50
|
-
extend: (extension: Extension) => void;
|
|
51
|
-
connect(): Promise<any>;
|
|
52
|
-
signIn(): Promise<any>;
|
|
53
|
-
/**
|
|
54
|
-
* ENS data supported by the SDK.
|
|
55
|
-
* @param address - User address.
|
|
56
|
-
* @param resolveEnsOpts - Options to resolve ENS.
|
|
57
|
-
* @returns Object containing ENS data.
|
|
58
|
-
*/
|
|
59
|
-
resolveEns(
|
|
60
|
-
/** User address */
|
|
61
|
-
address: string): Promise<EnsData>;
|
|
62
|
-
address(): string | undefined;
|
|
63
|
-
chainId(): number | undefined;
|
|
64
|
-
/**
|
|
65
|
-
* Signs a message using the private key of the connected address.
|
|
66
|
-
* @returns signature;
|
|
67
|
-
*/
|
|
68
|
-
signMessage(message: string): Promise<string>;
|
|
69
|
-
getSigner(): Signer;
|
|
70
|
-
signOut(): Promise<any>;
|
|
71
|
-
/**
|
|
72
|
-
* Generates a SIWE message for authentication with session key capabilities.
|
|
73
|
-
* @param address - Ethereum address performing the signing
|
|
74
|
-
* @param partial - Optional partial SIWE message to override defaults
|
|
75
|
-
* @returns SiweMessage object ready for signing
|
|
76
|
-
*/
|
|
77
|
-
generateSiweMessage(address: string, partial?: PartialSiweMessage): Promise<SiweMessage>;
|
|
78
|
-
/**
|
|
79
|
-
* Sign in to the SDK using a pre-signed SIWE message.
|
|
80
|
-
* @param siweMessage - The SIWE message that was generated
|
|
81
|
-
* @param signature - The signature of the SIWE message
|
|
82
|
-
* @returns Promise with the ClientSession object
|
|
83
|
-
*/
|
|
84
|
-
signInWithSignature(siweMessage: SiweMessage, signature: string): Promise<ClientSession>;
|
|
85
|
-
/**
|
|
86
|
-
* Get the space ID for the current session.
|
|
87
|
-
* @returns Space ID or undefined if not available
|
|
88
|
-
*/
|
|
89
|
-
getSpaceId(): string | undefined;
|
|
90
|
-
/**
|
|
91
|
-
* Get the configured TinyCloud host URLs.
|
|
92
|
-
* @returns Array of TinyCloud host URLs
|
|
93
|
-
*/
|
|
94
|
-
getTinycloudHosts(): string[];
|
|
95
|
-
/**
|
|
96
|
-
* Ensure the user's space exists on the TinyCloud server.
|
|
97
|
-
* Creates the space if it doesn't exist (when autoCreateSpace is true).
|
|
98
|
-
*/
|
|
99
|
-
ensureSpaceExists(): Promise<void>;
|
|
100
|
-
/**
|
|
101
|
-
* Get the active TinyCloud session.
|
|
102
|
-
* This provides access to the session for authenticated requests.
|
|
103
|
-
* @returns Session object or undefined if not signed in
|
|
104
|
-
*/
|
|
105
|
-
getTinycloudSession(): Session | undefined;
|
|
106
|
-
}
|
|
107
|
-
declare class UserAuthorizationInit {
|
|
108
|
-
private config?;
|
|
109
|
-
/** Extensions for the session. */
|
|
110
|
-
extensions: Extension[];
|
|
111
|
-
/** The session representation (once signed in). */
|
|
112
|
-
session?: ClientSession;
|
|
113
|
-
constructor(config?: ClientConfig);
|
|
114
|
-
/** Extend the session with a compatible extension. */
|
|
115
|
-
extend(extension: Extension): void;
|
|
116
|
-
/**
|
|
117
|
-
* Connect to the signing account using the configured provider.
|
|
118
|
-
* @returns UserAuthorizationConnected instance.
|
|
119
|
-
*/
|
|
120
|
-
connect(): Promise<UserAuthorizationConnected>;
|
|
121
|
-
}
|
|
122
|
-
/** An intermediate state: connected, but not signed-in. */
|
|
123
|
-
declare class UserAuthorizationConnected implements IConnected {
|
|
124
|
-
/** Instance of SessionManager */
|
|
125
|
-
builder: tcwSession.TCWSessionManager;
|
|
126
|
-
/** Config object. */
|
|
127
|
-
config: ClientConfig;
|
|
128
|
-
/** Enabled extensions. */
|
|
129
|
-
extensions: Extension[];
|
|
130
|
-
/** EthersJS provider. */
|
|
131
|
-
provider: providers.Web3Provider;
|
|
132
|
-
/**
|
|
133
|
-
* Promise that is initialized on construction of this class to run the "afterConnect" methods
|
|
134
|
-
* of the extensions.
|
|
135
|
-
*/
|
|
136
|
-
afterConnectHooksPromise: Promise<void>;
|
|
137
|
-
/** Verifies if extension is enabled. */
|
|
138
|
-
isExtensionEnabled: (namespace: string) => boolean;
|
|
139
|
-
/** Axios instance. */
|
|
140
|
-
api?: AxiosInstance;
|
|
141
|
-
/** Ethereum Provider */
|
|
142
|
-
constructor(
|
|
143
|
-
/** Instance of SessionManager */
|
|
144
|
-
builder: tcwSession.TCWSessionManager,
|
|
145
|
-
/** Config object. */
|
|
146
|
-
config: ClientConfig,
|
|
147
|
-
/** Enabled extensions. */
|
|
148
|
-
extensions: Extension[],
|
|
149
|
-
/** EthersJS provider. */
|
|
150
|
-
provider: providers.Web3Provider);
|
|
151
|
-
/**
|
|
152
|
-
* Default KV actions for TinyCloud services.
|
|
153
|
-
* These are added to every session to enable basic KV operations.
|
|
154
|
-
*/
|
|
155
|
-
private static readonly DEFAULT_KV_ACTIONS;
|
|
156
|
-
/**
|
|
157
|
-
* Default capabilities actions (for reading user capabilities).
|
|
158
|
-
*/
|
|
159
|
-
private static readonly DEFAULT_CAPABILITIES_ACTIONS;
|
|
160
|
-
/** Applies the "afterConnect" methods and the delegated capabilities of the extensions. */
|
|
161
|
-
applyExtensions(): Promise<void>;
|
|
162
|
-
/**
|
|
163
|
-
* Adds default KV capabilities for the given user address and chainId.
|
|
164
|
-
* Must be called after we have address/chainId but before build().
|
|
165
|
-
* @param address - User's Ethereum address
|
|
166
|
-
* @param chainId - Chain ID
|
|
167
|
-
* @param spacePrefix - Space prefix (default: "default")
|
|
168
|
-
* @param kvPrefix - KV path prefix for scoping access (default: "" for all paths)
|
|
169
|
-
*/
|
|
170
|
-
addDefaultCapabilities(address: string, chainId: number, spacePrefix?: string, kvPrefix?: string): void;
|
|
171
|
-
/**
|
|
172
|
-
* Applies the "afterSignIn" methods of the extensions.
|
|
173
|
-
* @param session - ClientSession object.
|
|
174
|
-
*/
|
|
175
|
-
afterSignIn(session: ClientSession): Promise<void>;
|
|
176
|
-
/**
|
|
177
|
-
* Requests the user to sign in.
|
|
178
|
-
* Generates the SIWE message for this session, requests the configured
|
|
179
|
-
* Signer to sign the message, calls the "afterSignIn" methods of the
|
|
180
|
-
* extensions.
|
|
181
|
-
* @returns Promise with the ClientSession object.
|
|
182
|
-
*/
|
|
183
|
-
signIn(): Promise<ClientSession>;
|
|
184
|
-
/**
|
|
185
|
-
* Requests the user to sign out.
|
|
186
|
-
* @param session - ClientSession object.
|
|
187
|
-
*/
|
|
188
|
-
signOut(session: ClientSession): Promise<void>;
|
|
189
|
-
}
|
|
190
|
-
declare class UserAuthorization implements IUserAuthorization, ICoreUserAuthorization {
|
|
191
|
-
private _config;
|
|
192
|
-
/** The Ethereum provider */
|
|
193
|
-
provider: providers.Web3Provider;
|
|
194
|
-
/** The session representation (once signed in). */
|
|
195
|
-
session?: ClientSession;
|
|
196
|
-
/** Session builder. */
|
|
197
|
-
private init;
|
|
198
|
-
/** Current connection */
|
|
199
|
-
private connection?;
|
|
200
|
-
/** The config object. */
|
|
201
|
-
private config;
|
|
202
|
-
/** Pending session state for signature-based initialization */
|
|
203
|
-
private pendingSession?;
|
|
204
|
-
/** Whether to automatically create space if it doesn't exist */
|
|
205
|
-
private autoCreateSpace;
|
|
206
|
-
/** TinyCloud server endpoints */
|
|
207
|
-
private tinycloudHosts;
|
|
208
|
-
/** Space prefix for new sessions */
|
|
209
|
-
private spacePrefix;
|
|
210
|
-
/** KV path prefix for scoping access */
|
|
211
|
-
private kvPrefix;
|
|
212
|
-
/** The space ID for the current session */
|
|
213
|
-
private _spaceId?;
|
|
214
|
-
/** Delegation header for the current session */
|
|
215
|
-
private _delegationHeader?;
|
|
216
|
-
/** The TinyCloud session containing delegation and space info */
|
|
217
|
-
private _tinycloudSession?;
|
|
218
|
-
/** The host where the user's space was found or created */
|
|
219
|
-
private _activeHost?;
|
|
220
|
-
constructor(_config?: ClientConfig);
|
|
221
|
-
/**
|
|
222
|
-
* Extends with functions that are called after connecting and signing in.
|
|
223
|
-
*/
|
|
224
|
-
extend(extension: Extension): void;
|
|
225
|
-
connect(): Promise<void>;
|
|
226
|
-
signIn(): Promise<ClientSession>;
|
|
227
|
-
/**
|
|
228
|
-
* ENS data supported by the SDK.
|
|
229
|
-
* @param address - User address.
|
|
230
|
-
* @param resolveEnsOpts - Options to resolve ENS.
|
|
231
|
-
* @returns Object containing ENS data.
|
|
232
|
-
*/
|
|
233
|
-
resolveEns(
|
|
234
|
-
/** User address */
|
|
235
|
-
address: string): Promise<EnsData>;
|
|
236
|
-
/**
|
|
237
|
-
* Invalidates user's session.
|
|
238
|
-
*/
|
|
239
|
-
signOut(): Promise<void>;
|
|
240
|
-
/**
|
|
241
|
-
* Gets the address that is connected and signed in.
|
|
242
|
-
* @returns Address.
|
|
243
|
-
*/
|
|
244
|
-
address: () => string | undefined;
|
|
245
|
-
/**
|
|
246
|
-
* Get the chainId that the address is connected and signed in on.
|
|
247
|
-
* @returns chainId.
|
|
248
|
-
*/
|
|
249
|
-
chainId: () => number | undefined;
|
|
250
|
-
/**
|
|
251
|
-
* Signs a message using the private key of the connected address.
|
|
252
|
-
* @returns signature;
|
|
253
|
-
*/
|
|
254
|
-
signMessage(message: string): Promise<string>;
|
|
255
|
-
/**
|
|
256
|
-
* Gets the provider that is connected and signed in.
|
|
257
|
-
* @returns Provider.
|
|
258
|
-
*/
|
|
259
|
-
getProvider(): providers.Web3Provider | undefined;
|
|
260
|
-
/**
|
|
261
|
-
* Returns the signer of the connected address.
|
|
262
|
-
* @returns ethers.Signer
|
|
263
|
-
* @see https://docs.ethers.io/v5/api/signer/#Signer
|
|
264
|
-
*/
|
|
265
|
-
getSigner(): Signer;
|
|
266
|
-
/**
|
|
267
|
-
* Generates a SIWE message for authentication with session key capabilities.
|
|
268
|
-
* This method initializes a SessionManager, generates a session key,
|
|
269
|
-
* applies extension capabilities, and builds a SIWE message for signing.
|
|
270
|
-
*
|
|
271
|
-
* @param address - Ethereum address performing the signing
|
|
272
|
-
* @param partial - Optional partial SIWE message to override defaults
|
|
273
|
-
* @returns SiweMessage object ready for signing
|
|
274
|
-
*/
|
|
275
|
-
generateSiweMessage(address: string, partial?: PartialSiweMessage): Promise<SiweMessage>;
|
|
276
|
-
/**
|
|
277
|
-
* Sign in to the SDK using a pre-signed SIWE message.
|
|
278
|
-
* This method must be called after generateSiweMessage().
|
|
279
|
-
* @param siweMessage - The SIWE message that was generated
|
|
280
|
-
* @param signature - The signature of the SIWE message
|
|
281
|
-
* @returns Promise with the ClientSession object
|
|
282
|
-
*/
|
|
283
|
-
signInWithSignature(siweMessage: SiweMessage, signature: string): Promise<ClientSession>;
|
|
284
|
-
/**
|
|
285
|
-
* Default KV actions for TinyCloud services.
|
|
286
|
-
* These are added to every session to enable basic KV operations.
|
|
287
|
-
*/
|
|
288
|
-
private static readonly DEFAULT_KV_ACTIONS;
|
|
289
|
-
/**
|
|
290
|
-
* Default capabilities actions (for reading user capabilities).
|
|
291
|
-
*/
|
|
292
|
-
private static readonly DEFAULT_CAPABILITIES_ACTIONS;
|
|
293
|
-
/**
|
|
294
|
-
* Applies extension capabilities (defaultActions/targetedActions) to the session manager.
|
|
295
|
-
* This method also adds default KV and capabilities actions.
|
|
296
|
-
*
|
|
297
|
-
* @private
|
|
298
|
-
* @param sessionManager - SessionManager instance to apply capabilities to
|
|
299
|
-
* @param extensions - Array of extensions to apply
|
|
300
|
-
* @param address - User's Ethereum address (for building target URIs)
|
|
301
|
-
* @param chainId - Chain ID (for building target URIs)
|
|
302
|
-
* @param spacePrefix - Space prefix (default: "default")
|
|
303
|
-
* @param kvPrefix - KV path prefix for scoping access (default: "" for all paths)
|
|
304
|
-
*/
|
|
305
|
-
private applyExtensionCapabilities;
|
|
306
|
-
/**
|
|
307
|
-
* Get the space ID for the current session.
|
|
308
|
-
* @returns Space ID or undefined if not available
|
|
309
|
-
*/
|
|
310
|
-
getSpaceId(): string | undefined;
|
|
311
|
-
/**
|
|
312
|
-
* Get the configured TinyCloud host URLs.
|
|
313
|
-
* @returns Array of TinyCloud host URLs
|
|
314
|
-
*/
|
|
315
|
-
getTinycloudHosts(): string[];
|
|
316
|
-
/**
|
|
317
|
-
* Get the active TinyCloud session.
|
|
318
|
-
* This provides access to the session for authenticated requests.
|
|
319
|
-
* @returns Session object or undefined if not signed in
|
|
320
|
-
*/
|
|
321
|
-
getTinycloudSession(): Session | undefined;
|
|
322
|
-
/**
|
|
323
|
-
* Create the space on the TinyCloud server (host delegation).
|
|
324
|
-
* This registers the user as the owner of the space.
|
|
325
|
-
* Uses a modal to confirm with the user before creating.
|
|
326
|
-
* @param host - The host to create the space on
|
|
327
|
-
* @returns Promise resolving to true if space was created, false if user dismissed
|
|
328
|
-
*/
|
|
329
|
-
private hostSpace;
|
|
330
|
-
/**
|
|
331
|
-
* Ensure the user's space exists on the TinyCloud server.
|
|
332
|
-
* Creates the space if it doesn't exist and autoCreateSpace is enabled.
|
|
333
|
-
*
|
|
334
|
-
* Strategy:
|
|
335
|
-
* 1. Try to activate the session on the first (primary) host.
|
|
336
|
-
* 2. If activation succeeds, set it as the `_activeHost` and return.
|
|
337
|
-
* 3. If the primary host returns 404, create the space there (don't skip
|
|
338
|
-
* because it might exist on other hosts - there is no replication).
|
|
339
|
-
* 4. If the primary host has a non-404 error, try remaining hosts.
|
|
340
|
-
*
|
|
341
|
-
* @throws Error if space creation fails or is disabled and space doesn't exist.
|
|
342
|
-
*/
|
|
343
|
-
ensureSpaceExists(): Promise<void>;
|
|
344
|
-
/**
|
|
345
|
-
* Create the space on a specific host and activate the session there.
|
|
346
|
-
*/
|
|
347
|
-
private createSpaceOnHost;
|
|
348
|
-
/**
|
|
349
|
-
* Apply extension afterSignIn hooks to the session.
|
|
350
|
-
* @param session - The ClientSession object
|
|
351
|
-
*/
|
|
352
|
-
private applyAfterSignInHooks;
|
|
353
|
-
/**
|
|
354
|
-
* Generate space ID and delegation header for the current session.
|
|
355
|
-
* This sets up the internal state needed for ensureSpaceExists() and SpaceConnection.
|
|
356
|
-
* @param session - The ClientSession object
|
|
357
|
-
*/
|
|
358
|
-
private setupSpaceSession;
|
|
359
|
-
}
|
|
360
|
-
export { IUserAuthorization, UserAuthorization, UserAuthorizationInit, UserAuthorizationConnected, PendingSession, };
|
|
361
|
-
//# sourceMappingURL=UserAuthorization.d.ts.map
|