@tinycloud/node-sdk 3.8.0-beta.19 → 3.8.0-beta.20
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/README.md +6 -0
- package/dist/{TinyCloudNode-DfuhkGz7.d.ts → TinyCloudNode-BRyeZas2.d.ts} +2 -2
- package/dist/{TinyCloudNode-DLuN31i0.d.cts → TinyCloudNode-NrmztjDd.d.cts} +2 -2
- package/dist/{authority-BHLahKNJ.d.ts → authority-D6JMJwor.d.ts} +1 -1
- package/dist/{authority-Bgbd8NGB.d.cts → authority-Z-reu6zL.d.cts} +1 -1
- package/dist/core.cjs +27 -8
- 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 +27 -8
- 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 +27 -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 +27 -8
- 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 +2 -2
|
@@ -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-NrmztjDd.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-BRyeZas2.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
|
@@ -19659,8 +19659,7 @@ var NodeUserAuthorization = class {
|
|
|
19659
19659
|
/**
|
|
19660
19660
|
* Build SIWE overrides from the top-level nonce and siweConfig.
|
|
19661
19661
|
* - Top-level `nonce` is seeded first so `siweConfig.nonce` wins if both are set.
|
|
19662
|
-
* -
|
|
19663
|
-
* - resources are appended to the default resources
|
|
19662
|
+
* - resources are inserted after WASM preparation, before the final ReCap
|
|
19664
19663
|
* - uri triggers a warning (overwriting delegation target)
|
|
19665
19664
|
* - all other fields override directly
|
|
19666
19665
|
* - per-call nonce overrides siweConfig.nonce when provided
|
|
@@ -19678,9 +19677,6 @@ var NodeUserAuthorization = class {
|
|
|
19678
19677
|
if (statement) {
|
|
19679
19678
|
overrides.statement = this.statement ? `${statement} ${this.statement}` : statement;
|
|
19680
19679
|
}
|
|
19681
|
-
if (resources && resources.length > 0) {
|
|
19682
|
-
overrides.resources = resources;
|
|
19683
|
-
}
|
|
19684
19680
|
if (uri) {
|
|
19685
19681
|
console.warn(
|
|
19686
19682
|
"[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."
|
|
@@ -19692,6 +19688,29 @@ var NodeUserAuthorization = class {
|
|
|
19692
19688
|
}
|
|
19693
19689
|
return overrides;
|
|
19694
19690
|
}
|
|
19691
|
+
prepareSessionWithResources(params) {
|
|
19692
|
+
const resources = this.siweConfig?.resources;
|
|
19693
|
+
if (resources?.some((resource) => typeof resource !== "string" || !/^urn:tinycloud:recipients:[A-Za-z0-9_-]+$/.test(resource))) {
|
|
19694
|
+
throw new Error("SIWE metadata resources must be base64url recipients URIs");
|
|
19695
|
+
}
|
|
19696
|
+
const prepared = this.wasm.prepareSession(params);
|
|
19697
|
+
if (!resources?.length) return prepared;
|
|
19698
|
+
const recapLines = /^- urn:recap:[^\r\n]+$/gim;
|
|
19699
|
+
const recaps = prepared.siwe.match(recapLines);
|
|
19700
|
+
const recap = recaps?.[0];
|
|
19701
|
+
if (recaps?.length !== 1 || !prepared.siwe.endsWith(recap)) {
|
|
19702
|
+
throw new Error("Prepared SIWE must end with exactly one ReCap");
|
|
19703
|
+
}
|
|
19704
|
+
const insertedLines = resources.map((resource) => `- ${resource}`);
|
|
19705
|
+
const siwe = prepared.siwe.slice(0, -recap.length) + insertedLines.join("\n") + "\n" + recap;
|
|
19706
|
+
const expectedFields = (0, import_sdk_core5.extractImmutableSiweFields)(prepared.siwe);
|
|
19707
|
+
expectedFields.nonRecapResources = [expectedFields.nonRecapResources, ...insertedLines].filter(Boolean).join("\n");
|
|
19708
|
+
const actualRecaps = siwe.match(recapLines);
|
|
19709
|
+
if (actualRecaps?.length !== 1 || actualRecaps[0] !== recap || (0, import_sdk_core5.diffImmutableSiweFields)(expectedFields, (0, import_sdk_core5.extractImmutableSiweFields)(siwe)).length) {
|
|
19710
|
+
throw new Error("SIWE metadata insertion changed the prepared message");
|
|
19711
|
+
}
|
|
19712
|
+
return { ...prepared, siwe };
|
|
19713
|
+
}
|
|
19695
19714
|
/**
|
|
19696
19715
|
* Add an extension to the authorization flow.
|
|
19697
19716
|
*/
|
|
@@ -19939,7 +19958,7 @@ var NodeUserAuthorization = class {
|
|
|
19939
19958
|
spaceAbilities[spaceId] = (0, import_sdk_core5.resourceCapabilitiesToAbilitiesMap)(resources);
|
|
19940
19959
|
}
|
|
19941
19960
|
const abilities = spaceAbilities[options.spaceId] ?? (0, import_sdk_core5.resourceCapabilitiesToAbilitiesMap)([]);
|
|
19942
|
-
const prepared = this.
|
|
19961
|
+
const prepared = this.prepareSessionWithResources({
|
|
19943
19962
|
abilities,
|
|
19944
19963
|
spaceAbilities,
|
|
19945
19964
|
...options.rawAbilities !== void 0 ? { rawAbilities: options.rawAbilities } : {},
|
|
@@ -20032,7 +20051,7 @@ var NodeUserAuthorization = class {
|
|
|
20032
20051
|
const spaceId = capabilityPlan.spaceId;
|
|
20033
20052
|
const now = /* @__PURE__ */ new Date();
|
|
20034
20053
|
const expirationTime = new Date(now.getTime() + this.sessionExpirationMs);
|
|
20035
|
-
const prepared = this.
|
|
20054
|
+
const prepared = this.prepareSessionWithResources({
|
|
20036
20055
|
abilities: capabilityPlan.abilities,
|
|
20037
20056
|
...capabilityPlan.spaceAbilities !== void 0 ? { spaceAbilities: capabilityPlan.spaceAbilities } : {},
|
|
20038
20057
|
...capabilityPlan.rawAbilities !== void 0 ? { rawAbilities: capabilityPlan.rawAbilities } : {},
|
|
@@ -20178,7 +20197,7 @@ var NodeUserAuthorization = class {
|
|
|
20178
20197
|
const spaceId = capabilityPlan.spaceId;
|
|
20179
20198
|
const now = /* @__PURE__ */ new Date();
|
|
20180
20199
|
const expirationTime = new Date(now.getTime() + this.sessionExpirationMs);
|
|
20181
|
-
const prepared = this.
|
|
20200
|
+
const prepared = this.prepareSessionWithResources({
|
|
20182
20201
|
abilities: capabilityPlan.abilities,
|
|
20183
20202
|
...capabilityPlan.spaceAbilities !== void 0 ? { spaceAbilities: capabilityPlan.spaceAbilities } : {},
|
|
20184
20203
|
...capabilityPlan.rawAbilities !== void 0 ? { rawAbilities: capabilityPlan.rawAbilities } : {},
|