@tinycloud/node-sdk 2.1.0-beta.4 → 2.1.0-beta.6
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/core.cjs +18 -8
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +9 -4
- package/dist/core.d.ts +9 -4
- package/dist/core.js +18 -8
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +18 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +18 -8
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/core.cjs
CHANGED
|
@@ -414,14 +414,17 @@ var NodeUserAuthorization = class {
|
|
|
414
414
|
* - resources are appended to the default resources
|
|
415
415
|
* - uri triggers a warning (overwriting delegation target)
|
|
416
416
|
* - all other fields override directly
|
|
417
|
+
* - per-call nonce overrides siweConfig.nonce when provided
|
|
417
418
|
*/
|
|
418
|
-
buildSiweOverrides() {
|
|
419
|
+
buildSiweOverrides(options) {
|
|
419
420
|
const base = { uri: this.uri };
|
|
420
421
|
if (this.nonce !== void 0) {
|
|
421
422
|
base.nonce = this.nonce;
|
|
422
423
|
}
|
|
423
|
-
if (!this.siweConfig)
|
|
424
|
-
|
|
424
|
+
if (!this.siweConfig && !options?.nonce) {
|
|
425
|
+
return base;
|
|
426
|
+
}
|
|
427
|
+
const { statement, resources, uri, ...rest } = this.siweConfig ?? {};
|
|
425
428
|
const overrides = { ...base, ...rest };
|
|
426
429
|
if (statement) {
|
|
427
430
|
overrides.statement = this.statement ? `${statement} ${this.statement}` : statement;
|
|
@@ -435,6 +438,9 @@ var NodeUserAuthorization = class {
|
|
|
435
438
|
);
|
|
436
439
|
overrides.uri = uri;
|
|
437
440
|
}
|
|
441
|
+
if (options?.nonce) {
|
|
442
|
+
overrides.nonce = options.nonce;
|
|
443
|
+
}
|
|
438
444
|
return overrides;
|
|
439
445
|
}
|
|
440
446
|
/**
|
|
@@ -593,8 +599,10 @@ var NodeUserAuthorization = class {
|
|
|
593
599
|
* 2. Call prepareSession() which generates the SIWE with ReCap capabilities
|
|
594
600
|
* 3. Sign the SIWE string from prepareSession
|
|
595
601
|
* 4. Call completeSessionSetup() with the prepared session + signature
|
|
602
|
+
*
|
|
603
|
+
* @param options - Optional per-call SIWE overrides for this sign-in only
|
|
596
604
|
*/
|
|
597
|
-
async signIn() {
|
|
605
|
+
async signIn(options) {
|
|
598
606
|
this._address = await this.signer.getAddress();
|
|
599
607
|
this._chainId = await this.signer.getChainId();
|
|
600
608
|
const address = this.wasm.ensureEip55(this._address);
|
|
@@ -618,7 +626,7 @@ var NodeUserAuthorization = class {
|
|
|
618
626
|
expirationTime: expirationTime.toISOString(),
|
|
619
627
|
spaceId,
|
|
620
628
|
jwk,
|
|
621
|
-
...this.buildSiweOverrides()
|
|
629
|
+
...this.buildSiweOverrides(options)
|
|
622
630
|
});
|
|
623
631
|
const signature = await this.requestSignature({
|
|
624
632
|
address,
|
|
@@ -1345,8 +1353,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1345
1353
|
* Sign in and create a new session.
|
|
1346
1354
|
* This creates the user's space if it doesn't exist.
|
|
1347
1355
|
* Requires wallet mode (privateKey in config).
|
|
1356
|
+
*
|
|
1357
|
+
* @param options - Optional per-call SIWE overrides for this sign-in only
|
|
1348
1358
|
*/
|
|
1349
|
-
async signIn() {
|
|
1359
|
+
async signIn(options) {
|
|
1350
1360
|
if (!this.signer || !this.tc) {
|
|
1351
1361
|
throw new Error(
|
|
1352
1362
|
"Cannot signIn() in session-only mode. Provide a privateKey in config to create your own space."
|
|
@@ -1360,7 +1370,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1360
1370
|
this._duckdb = void 0;
|
|
1361
1371
|
this._hooks = void 0;
|
|
1362
1372
|
this._serviceContext = void 0;
|
|
1363
|
-
await this.tc.signIn();
|
|
1373
|
+
await this.tc.signIn(options);
|
|
1364
1374
|
this.initializeServices();
|
|
1365
1375
|
this.notificationHandler.success("Successfully signed in");
|
|
1366
1376
|
}
|
|
@@ -2476,7 +2486,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2476
2486
|
expirationSecs
|
|
2477
2487
|
});
|
|
2478
2488
|
const primary = result.resources[0];
|
|
2479
|
-
const delegationHeader = { Authorization:
|
|
2489
|
+
const delegationHeader = { Authorization: result.delegation };
|
|
2480
2490
|
const activateResult = await (0, import_sdk_core5.activateSessionWithHost)(
|
|
2481
2491
|
this.config.host,
|
|
2482
2492
|
delegationHeader
|