@tinycloud/node-sdk 3.8.0-beta.20 → 3.8.0-beta.22
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/{TinyCloudNode-NrmztjDd.d.cts → TinyCloudNode-DaD5vJhL.d.cts} +2 -0
- package/dist/{TinyCloudNode-BRyeZas2.d.ts → TinyCloudNode-k3TbBwwj.d.ts} +2 -0
- package/dist/{authority-D6JMJwor.d.ts → authority-C_fWaxAu.d.ts} +1 -1
- package/dist/{authority-Z-reu6zL.d.cts → authority-DJdbZM6k.d.cts} +1 -1
- package/dist/core.cjs +39 -11
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +40 -11
- package/dist/core.js.map +1 -1
- package/dist/encryption-keys.d.cts +1 -1
- package/dist/encryption-keys.d.ts +1 -1
- package/dist/index.cjs +39 -11
- 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 +40 -11
- package/dist/index.js.map +1 -1
- package/dist/replication/authority.d.cts +2 -2
- package/dist/replication/authority.d.ts +2 -2
- package/package.json +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NamedKeyClient } from '@tinycloud/sdk-services/encryption/named-keys';
|
|
2
2
|
export { DecryptManyResult, KeyCallOptions, KeyDescriptor, KeyEncryptOptions, NamedKeyClient, NamedKeyEnvelope, NamedKeyError, NamedKeyErrorCode, PublicKeyDescriptor, buildKeyAdminFacts, buildKeyDescribeFacts } from '@tinycloud/sdk-services/encryption/named-keys';
|
|
3
|
-
import { T as TinyCloudNode } from './TinyCloudNode-
|
|
3
|
+
import { T as TinyCloudNode } from './TinyCloudNode-DaD5vJhL.cjs';
|
|
4
4
|
import '@tinycloud/sdk-core';
|
|
5
5
|
import '@tinycloud/sdk-services/kv/replication';
|
|
6
6
|
import '@tinycloud/sdk-services';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NamedKeyClient } from '@tinycloud/sdk-services/encryption/named-keys';
|
|
2
2
|
export { DecryptManyResult, KeyCallOptions, KeyDescriptor, KeyEncryptOptions, NamedKeyClient, NamedKeyEnvelope, NamedKeyError, NamedKeyErrorCode, PublicKeyDescriptor, buildKeyAdminFacts, buildKeyDescribeFacts } from '@tinycloud/sdk-services/encryption/named-keys';
|
|
3
|
-
import { T as TinyCloudNode } from './TinyCloudNode-
|
|
3
|
+
import { T as TinyCloudNode } from './TinyCloudNode-k3TbBwwj.js';
|
|
4
4
|
import '@tinycloud/sdk-core';
|
|
5
5
|
import '@tinycloud/sdk-services/kv/replication';
|
|
6
6
|
import '@tinycloud/sdk-services';
|
package/dist/index.cjs
CHANGED
|
@@ -18814,6 +18814,7 @@ function deserializeDelegation(data) {
|
|
|
18814
18814
|
|
|
18815
18815
|
// src/TinyCloudNode.ts
|
|
18816
18816
|
var import_siwe2 = require("siwe");
|
|
18817
|
+
var import_share_envelope = require("@tinycloud/share-envelope");
|
|
18817
18818
|
|
|
18818
18819
|
// src/replication/module-registry.ts
|
|
18819
18820
|
var nodeLoaders;
|
|
@@ -20039,8 +20040,8 @@ var NodeUserAuthorization = class {
|
|
|
20039
20040
|
this.assertSignInCurrent(generation);
|
|
20040
20041
|
await this.refreshNamedKeyFeatureForSignIn(address, chainId);
|
|
20041
20042
|
this.assertSignInCurrent(generation);
|
|
20042
|
-
const keyId = `session-${Date.now()}`;
|
|
20043
|
-
this.sessionManager.
|
|
20043
|
+
const keyId = `session-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
20044
|
+
this.sessionManager.createSessionKey(keyId);
|
|
20044
20045
|
this.activeSessionKeyId = keyId;
|
|
20045
20046
|
const jwkString = this.sessionManager.jwk(keyId);
|
|
20046
20047
|
if (!jwkString) {
|
|
@@ -26107,7 +26108,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26107
26108
|
if (!session || !Array.isArray(permissions) || permissions.length === 0) {
|
|
26108
26109
|
return false;
|
|
26109
26110
|
}
|
|
26110
|
-
const expanded =
|
|
26111
|
+
const expanded = (0, import_sdk_core10.expandRuntimePermissionEntries)(permissions, (0, import_sdk_core10.pkhDid)(session.address, session.chainId));
|
|
26111
26112
|
if (this.sessionCoversPermissionEntries(session, expanded)) {
|
|
26112
26113
|
return true;
|
|
26113
26114
|
}
|
|
@@ -26127,7 +26128,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26127
26128
|
if (!session || !Array.isArray(permissions) || permissions.length === 0) {
|
|
26128
26129
|
return [];
|
|
26129
26130
|
}
|
|
26130
|
-
const expanded =
|
|
26131
|
+
const expanded = (0, import_sdk_core10.expandRuntimePermissionEntries)(permissions, (0, import_sdk_core10.pkhDid)(session.address, session.chainId));
|
|
26131
26132
|
return this.findRuntimeGrantsForPermissionEntries(expanded, session).map(
|
|
26132
26133
|
(grant) => grant.delegation
|
|
26133
26134
|
);
|
|
@@ -26302,7 +26303,28 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26302
26303
|
throw new import_sdk_core10.SessionExpiredError(sessionExpiry);
|
|
26303
26304
|
}
|
|
26304
26305
|
}
|
|
26305
|
-
const expanded =
|
|
26306
|
+
const expanded = (0, import_sdk_core10.expandRuntimePermissionEntries)(permissions, (0, import_sdk_core10.pkhDid)(session.address, session.chainId));
|
|
26307
|
+
const bindsShareKey = expanded.some((entry) => entry.service === import_sdk_core10.ENCRYPTION_PERMISSION_SERVICE && entry.actions.includes("tinycloud.encryption/key.create"));
|
|
26308
|
+
const captured = bindsShareKey ? { ...session, jwk: { ...options?.expectedSessionKey ?? session.jwk } } : session;
|
|
26309
|
+
const assertCapturedKey = bindsShareKey ? () => {
|
|
26310
|
+
const live = session.jwk;
|
|
26311
|
+
const key2 = captured.jwk;
|
|
26312
|
+
if (this.currentTinyCloudSession() !== session || session.verificationMethod !== captured.verificationMethod || session.delegationCid !== captured.delegationCid || session.spaceId !== captured.spaceId || session.address !== captured.address || session.chainId !== captured.chainId || live?.kty !== key2.kty || live?.crv !== key2.crv || live?.x !== key2.x || live?.y !== key2.y || live?.d !== key2.d) {
|
|
26313
|
+
throw new Error("Runtime permission request cancelled because the session key changed.");
|
|
26314
|
+
}
|
|
26315
|
+
} : void 0;
|
|
26316
|
+
const sessionKeyDid = bindsShareKey ? this.sessionDid : void 0;
|
|
26317
|
+
if (bindsShareKey) {
|
|
26318
|
+
const key2 = captured.jwk;
|
|
26319
|
+
if (key2.kty !== "OKP" || key2.crv !== "Ed25519" || typeof key2.x !== "string") {
|
|
26320
|
+
throw new Error("Runtime permission session key does not match its signed identity.");
|
|
26321
|
+
}
|
|
26322
|
+
const keyDid = (0, import_share_envelope.didKeyFromEd25519PublicKey)(base64UrlDecode(key2.x));
|
|
26323
|
+
if (!didPrincipalMatches2(keyDid, sessionKeyDid) || !didPrincipalMatches2(keyDid, captured.verificationMethod) || !didPrincipalMatches2(keyDid, new import_siwe2.SiweMessage(session.siwe).uri)) {
|
|
26324
|
+
throw new Error("Runtime permission session key does not match its signed identity.");
|
|
26325
|
+
}
|
|
26326
|
+
assertCapturedKey();
|
|
26327
|
+
}
|
|
26306
26328
|
if (this.sessionCoversPermissionEntries(session, expanded)) {
|
|
26307
26329
|
return [];
|
|
26308
26330
|
}
|
|
@@ -26352,13 +26374,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26352
26374
|
return this.wasmBindings.prepareSession({
|
|
26353
26375
|
abilities,
|
|
26354
26376
|
...rawForDelegation.length > 0 ? { rawAbilities: this.permissionsToRawAbilities(rawForDelegation) } : {},
|
|
26355
|
-
address: this.wasmBindings.ensureEip55(
|
|
26356
|
-
chainId:
|
|
26377
|
+
address: this.wasmBindings.ensureEip55(captured.address),
|
|
26378
|
+
chainId: captured.chainId,
|
|
26357
26379
|
domain: this.siweDomain,
|
|
26358
26380
|
issuedAt: now.toISOString(),
|
|
26359
26381
|
expirationTime: expiresAt.toISOString(),
|
|
26360
26382
|
spaceId,
|
|
26361
|
-
jwk:
|
|
26383
|
+
jwk: captured.jwk
|
|
26362
26384
|
});
|
|
26363
26385
|
} catch (error) {
|
|
26364
26386
|
if (rawForDelegation.some((entry) => this.isRawRevocationPermissionEntry(entry)) && /invalid ReCap resource URI/i.test(error instanceof Error ? error.message : String(error))) {
|
|
@@ -26370,8 +26392,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26370
26392
|
throw error;
|
|
26371
26393
|
}
|
|
26372
26394
|
})();
|
|
26395
|
+
if (bindsShareKey && !didPrincipalMatches2(new import_siwe2.SiweMessage(prepared.siwe).uri, sessionKeyDid)) {
|
|
26396
|
+
throw new Error("Prepared runtime permission targets a different session key.");
|
|
26397
|
+
}
|
|
26398
|
+
assertCapturedKey?.();
|
|
26373
26399
|
const signature2 = await this.signer.signMessage(prepared.siwe);
|
|
26374
26400
|
graph.assertActive();
|
|
26401
|
+
assertCapturedKey?.();
|
|
26375
26402
|
const delegatedSession = this.wasmBindings.completeSessionSetup({
|
|
26376
26403
|
...prepared,
|
|
26377
26404
|
signature: signature2
|
|
@@ -26400,18 +26427,19 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26400
26427
|
delegatedSession,
|
|
26401
26428
|
delegatedEntries,
|
|
26402
26429
|
spaceId,
|
|
26403
|
-
|
|
26430
|
+
captured,
|
|
26404
26431
|
expiresAt,
|
|
26405
26432
|
{ siwe: prepared.siwe, signature: signature2 }
|
|
26406
26433
|
);
|
|
26407
26434
|
graph.assertActive();
|
|
26435
|
+
assertCapturedKey?.();
|
|
26408
26436
|
this.runtimePermissionGrants.push({
|
|
26409
26437
|
session: {
|
|
26410
26438
|
delegationHeader: delegatedSession.delegationHeader,
|
|
26411
26439
|
delegationCid: delegatedSession.delegationCid,
|
|
26412
26440
|
spaceId,
|
|
26413
|
-
verificationMethod:
|
|
26414
|
-
jwk:
|
|
26441
|
+
verificationMethod: captured.verificationMethod,
|
|
26442
|
+
jwk: captured.jwk
|
|
26415
26443
|
},
|
|
26416
26444
|
delegation,
|
|
26417
26445
|
operations: this.permissionOperations(delegatedEntries, spaceId),
|