@tinycloud/node-sdk 2.0.2-beta.0 → 2.0.3-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/core.cjs +45 -15
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +16 -1
- package/dist/core.d.ts +16 -1
- package/dist/core.js +45 -15
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +45 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +45 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/core.cjs
CHANGED
|
@@ -318,6 +318,7 @@ var NodeUserAuthorization = class {
|
|
|
318
318
|
this.spaceCreationHandler = config.spaceCreationHandler;
|
|
319
319
|
this.tinycloudHosts = config.tinycloudHosts ?? ["https://node.tinycloud.xyz"];
|
|
320
320
|
this.enablePublicSpace = config.enablePublicSpace ?? true;
|
|
321
|
+
this.siweConfig = config.siweConfig;
|
|
321
322
|
this.sessionManager = this.wasm.createSessionManager();
|
|
322
323
|
}
|
|
323
324
|
/**
|
|
@@ -336,6 +337,31 @@ var NodeUserAuthorization = class {
|
|
|
336
337
|
get nodeFeatures() {
|
|
337
338
|
return this._nodeFeatures;
|
|
338
339
|
}
|
|
340
|
+
/**
|
|
341
|
+
* Build SIWE overrides from siweConfig.
|
|
342
|
+
* - statement is prepended to the default statement
|
|
343
|
+
* - resources are appended to the default resources
|
|
344
|
+
* - uri triggers a warning (overwriting delegation target)
|
|
345
|
+
* - all other fields override directly
|
|
346
|
+
*/
|
|
347
|
+
buildSiweOverrides() {
|
|
348
|
+
if (!this.siweConfig) return { uri: this.uri };
|
|
349
|
+
const { statement, resources, uri, ...rest } = this.siweConfig;
|
|
350
|
+
const overrides = { uri: this.uri, ...rest };
|
|
351
|
+
if (statement) {
|
|
352
|
+
overrides.statement = this.statement ? `${statement} ${this.statement}` : statement;
|
|
353
|
+
}
|
|
354
|
+
if (resources && resources.length > 0) {
|
|
355
|
+
overrides.resources = resources;
|
|
356
|
+
}
|
|
357
|
+
if (uri) {
|
|
358
|
+
console.warn(
|
|
359
|
+
"[tinycloud] siweConfig.uri is overwriting the delegation target URI. This may break delegation chain validation if the URI does not match the session key DID."
|
|
360
|
+
);
|
|
361
|
+
overrides.uri = uri;
|
|
362
|
+
}
|
|
363
|
+
return overrides;
|
|
364
|
+
}
|
|
339
365
|
/**
|
|
340
366
|
* Add an extension to the authorization flow.
|
|
341
367
|
*/
|
|
@@ -510,7 +536,8 @@ var NodeUserAuthorization = class {
|
|
|
510
536
|
issuedAt: now.toISOString(),
|
|
511
537
|
expirationTime: expirationTime.toISOString(),
|
|
512
538
|
spaceId,
|
|
513
|
-
jwk
|
|
539
|
+
jwk,
|
|
540
|
+
...this.buildSiweOverrides()
|
|
514
541
|
});
|
|
515
542
|
const signature = await this.requestSignature({
|
|
516
543
|
address,
|
|
@@ -649,7 +676,8 @@ var NodeUserAuthorization = class {
|
|
|
649
676
|
issuedAt: now.toISOString(),
|
|
650
677
|
expirationTime: expirationTime.toISOString(),
|
|
651
678
|
spaceId,
|
|
652
|
-
jwk
|
|
679
|
+
jwk,
|
|
680
|
+
...this.buildSiweOverrides()
|
|
653
681
|
});
|
|
654
682
|
return {
|
|
655
683
|
prepared,
|
|
@@ -1053,25 +1081,29 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
1053
1081
|
get nodeFeatures() {
|
|
1054
1082
|
return this.auth?.nodeFeatures ?? [];
|
|
1055
1083
|
}
|
|
1084
|
+
/** SIWE domain — uses config override or defaults to app.tinycloud.xyz */
|
|
1085
|
+
get siweDomain() {
|
|
1086
|
+
return this.config.domain ?? "app.tinycloud.xyz";
|
|
1087
|
+
}
|
|
1056
1088
|
/**
|
|
1057
1089
|
* Set up authorization handler and TinyCloud instance.
|
|
1058
1090
|
* @internal
|
|
1059
1091
|
*/
|
|
1060
1092
|
setupAuth(config) {
|
|
1061
1093
|
const host = this.config.host;
|
|
1062
|
-
const domain = config.domain ?? new URL(host).hostname;
|
|
1063
1094
|
this.auth = new NodeUserAuthorization({
|
|
1064
1095
|
signer: this.signer,
|
|
1065
1096
|
signStrategy: { type: "auto-sign" },
|
|
1066
1097
|
wasmBindings: this.wasmBindings,
|
|
1067
1098
|
sessionStorage: config.sessionStorage ?? new MemorySessionStorage(),
|
|
1068
|
-
domain,
|
|
1099
|
+
domain: this.siweDomain,
|
|
1069
1100
|
spacePrefix: config.prefix,
|
|
1070
1101
|
sessionExpirationMs: config.sessionExpirationMs ?? 60 * 60 * 1e3,
|
|
1071
1102
|
tinycloudHosts: [host],
|
|
1072
1103
|
autoCreateSpace: config.autoCreateSpace,
|
|
1073
1104
|
enablePublicSpace: config.enablePublicSpace ?? true,
|
|
1074
|
-
spaceCreationHandler: config.spaceCreationHandler
|
|
1105
|
+
spaceCreationHandler: config.spaceCreationHandler,
|
|
1106
|
+
siweConfig: config.siweConfig
|
|
1075
1107
|
});
|
|
1076
1108
|
this.tc = new import_sdk_core4.TinyCloud(this.auth);
|
|
1077
1109
|
}
|
|
@@ -1260,7 +1292,6 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
1260
1292
|
}
|
|
1261
1293
|
const prefix = options?.prefix ?? "default";
|
|
1262
1294
|
const host = this.config.host;
|
|
1263
|
-
const domain = new URL(host).hostname;
|
|
1264
1295
|
if (!_TinyCloudNode.nodeDefaults) {
|
|
1265
1296
|
throw new Error(
|
|
1266
1297
|
"connectWallet() requires PrivateKeySigner. Use connectSigner() instead, or import from '@tinycloud/node-sdk' (not '/core') for automatic Node.js defaults."
|
|
@@ -1272,7 +1303,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
1272
1303
|
signStrategy: { type: "auto-sign" },
|
|
1273
1304
|
wasmBindings: this.wasmBindings,
|
|
1274
1305
|
sessionStorage: options?.sessionStorage ?? this.config.sessionStorage ?? new MemorySessionStorage(),
|
|
1275
|
-
domain,
|
|
1306
|
+
domain: this.siweDomain,
|
|
1276
1307
|
spacePrefix: prefix,
|
|
1277
1308
|
sessionExpirationMs: this.config.sessionExpirationMs ?? 60 * 60 * 1e3,
|
|
1278
1309
|
tinycloudHosts: [host],
|
|
@@ -1302,14 +1333,13 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
1302
1333
|
}
|
|
1303
1334
|
const prefix = options?.prefix ?? "default";
|
|
1304
1335
|
const host = this.config.host;
|
|
1305
|
-
const domain = new URL(host).hostname;
|
|
1306
1336
|
this.signer = signer;
|
|
1307
1337
|
this.auth = new NodeUserAuthorization({
|
|
1308
1338
|
signer: this.signer,
|
|
1309
1339
|
signStrategy: { type: "auto-sign" },
|
|
1310
1340
|
wasmBindings: this.wasmBindings,
|
|
1311
1341
|
sessionStorage: options?.sessionStorage ?? this.config.sessionStorage ?? new MemorySessionStorage(),
|
|
1312
|
-
domain,
|
|
1342
|
+
domain: this.siweDomain,
|
|
1313
1343
|
spacePrefix: prefix,
|
|
1314
1344
|
sessionExpirationMs: this.config.sessionExpirationMs ?? 60 * 60 * 1e3,
|
|
1315
1345
|
tinycloudHosts: [host],
|
|
@@ -1620,7 +1650,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
1620
1650
|
abilities,
|
|
1621
1651
|
address: this.wasmBindings.ensureEip55(session.address),
|
|
1622
1652
|
chainId: session.chainId,
|
|
1623
|
-
domain:
|
|
1653
|
+
domain: this.siweDomain,
|
|
1624
1654
|
issuedAt: now.toISOString(),
|
|
1625
1655
|
expirationTime: params.requestedExpiry.toISOString(),
|
|
1626
1656
|
spaceId: params.spaceId,
|
|
@@ -1929,7 +1959,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
1929
1959
|
abilities,
|
|
1930
1960
|
address: this.wasmBindings.ensureEip55(this.session.address),
|
|
1931
1961
|
chainId: this.session.chainId,
|
|
1932
|
-
domain:
|
|
1962
|
+
domain: this.siweDomain,
|
|
1933
1963
|
issuedAt: now.toISOString(),
|
|
1934
1964
|
expirationTime: expirationTime.toISOString(),
|
|
1935
1965
|
spaceId: publicSpaceId,
|
|
@@ -2096,7 +2126,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
2096
2126
|
abilities,
|
|
2097
2127
|
address: this.wasmBindings.ensureEip55(session.address),
|
|
2098
2128
|
chainId: session.chainId,
|
|
2099
|
-
domain:
|
|
2129
|
+
domain: this.siweDomain,
|
|
2100
2130
|
issuedAt: now.toISOString(),
|
|
2101
2131
|
expirationTime: expirationTime.toISOString(),
|
|
2102
2132
|
spaceId: params.spaceIdOverride ?? session.spaceId,
|
|
@@ -2141,7 +2171,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
2141
2171
|
abilities: publicAbilities,
|
|
2142
2172
|
address: this.wasmBindings.ensureEip55(session.address),
|
|
2143
2173
|
chainId: session.chainId,
|
|
2144
|
-
domain:
|
|
2174
|
+
domain: this.siweDomain,
|
|
2145
2175
|
issuedAt: now.toISOString(),
|
|
2146
2176
|
expirationTime: expirationTime.toISOString(),
|
|
2147
2177
|
spaceId: publicSpaceId,
|
|
@@ -2240,7 +2270,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
2240
2270
|
abilities,
|
|
2241
2271
|
address: this.wasmBindings.ensureEip55(mySession.address),
|
|
2242
2272
|
chainId: mySession.chainId,
|
|
2243
|
-
domain:
|
|
2273
|
+
domain: this.siweDomain,
|
|
2244
2274
|
issuedAt: now.toISOString(),
|
|
2245
2275
|
expirationTime: expirationTime.toISOString(),
|
|
2246
2276
|
spaceId: delegation.spaceId,
|
|
@@ -2329,7 +2359,7 @@ var TinyCloudNode = class _TinyCloudNode {
|
|
|
2329
2359
|
abilities,
|
|
2330
2360
|
address: this.wasmBindings.ensureEip55(this._address),
|
|
2331
2361
|
chainId: this._chainId,
|
|
2332
|
-
domain:
|
|
2362
|
+
domain: this.siweDomain,
|
|
2333
2363
|
issuedAt: now.toISOString(),
|
|
2334
2364
|
expirationTime: actualExpiry.toISOString(),
|
|
2335
2365
|
spaceId: parentDelegation.spaceId,
|