@tinycloud/node-sdk 3.6.0-beta.7 → 3.6.0-beta.8
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 +412 -390
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +9 -2
- package/dist/core.d.ts +9 -2
- package/dist/core.js +38 -14
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +470 -450
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +37 -14
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -18694,11 +18694,11 @@ import {
|
|
|
18694
18694
|
bootstrapSteps,
|
|
18695
18695
|
ErrorCodes as ErrorCodes2,
|
|
18696
18696
|
ENCRYPTION_PERMISSION_SERVICE as ENCRYPTION_PERMISSION_SERVICE2,
|
|
18697
|
-
CaveatedDelegationUnsupportedError,
|
|
18697
|
+
CaveatedDelegationUnsupportedError as CaveatedDelegationUnsupportedError2,
|
|
18698
18698
|
PermissionNotInManifestError,
|
|
18699
18699
|
SessionExpiredError,
|
|
18700
18700
|
canonicalizeRecapCaveats as canonicalizeRecapCaveats2,
|
|
18701
|
-
recapCaveatsEqual,
|
|
18701
|
+
recapCaveatsEqual as recapCaveatsEqual2,
|
|
18702
18702
|
expandPermissionEntries as expandPermissionEntriesCore,
|
|
18703
18703
|
isCapabilitySubset as isCapabilitySubset2,
|
|
18704
18704
|
isExplicitOnlyAction,
|
|
@@ -18785,6 +18785,22 @@ import {
|
|
|
18785
18785
|
ENCRYPTION
|
|
18786
18786
|
} from "@tinycloud/sdk-core";
|
|
18787
18787
|
|
|
18788
|
+
// src/authorization/caveatRefusal.ts
|
|
18789
|
+
import {
|
|
18790
|
+
CaveatedDelegationUnsupportedError,
|
|
18791
|
+
recapCaveatsEqual
|
|
18792
|
+
} from "@tinycloud/sdk-core";
|
|
18793
|
+
function refuseCaveated(input) {
|
|
18794
|
+
const caveated = [input ?? []].flat().flatMap((item) => [item, ...item.permissions ?? []]).filter(({ caveats }) => {
|
|
18795
|
+
try {
|
|
18796
|
+
return caveats === null || !recapCaveatsEqual(caveats, void 0);
|
|
18797
|
+
} catch {
|
|
18798
|
+
return true;
|
|
18799
|
+
}
|
|
18800
|
+
});
|
|
18801
|
+
if (caveated.length) throw new CaveatedDelegationUnsupportedError(caveated);
|
|
18802
|
+
}
|
|
18803
|
+
|
|
18788
18804
|
// src/authorization/strategies.ts
|
|
18789
18805
|
import { createOpenKeyCallbackSigningStrategy } from "@tinycloud/sdk-core";
|
|
18790
18806
|
var defaultSignStrategy = { type: "auto-sign" };
|
|
@@ -19753,6 +19769,7 @@ var NodeUserAuthorization = class {
|
|
|
19753
19769
|
this._lastActivationSkippedSpaceIds = result.status === 404 ? [primarySpaceId] : [];
|
|
19754
19770
|
}
|
|
19755
19771
|
async createBootstrapSession(options) {
|
|
19772
|
+
refuseCaveated(options.capabilityRequest.manifests);
|
|
19756
19773
|
if (!this._address || !this._chainId) {
|
|
19757
19774
|
throw new Error("Must be signed in before creating bootstrap sessions");
|
|
19758
19775
|
}
|
|
@@ -19854,6 +19871,7 @@ var NodeUserAuthorization = class {
|
|
|
19854
19871
|
* @param options - Optional per-call SIWE overrides for this sign-in only
|
|
19855
19872
|
*/
|
|
19856
19873
|
async signIn(options) {
|
|
19874
|
+
refuseCaveated(this.getCapabilityRequest()?.manifests);
|
|
19857
19875
|
const generation = this.sessionGeneration;
|
|
19858
19876
|
const address = canonicalizeAddress(await this.signer.getAddress());
|
|
19859
19877
|
const chainId = await this.signer.getChainId();
|
|
@@ -20005,6 +20023,7 @@ var NodeUserAuthorization = class {
|
|
|
20005
20023
|
* ```
|
|
20006
20024
|
*/
|
|
20007
20025
|
async prepareSessionForSigning() {
|
|
20026
|
+
refuseCaveated(this.getCapabilityRequest()?.manifests);
|
|
20008
20027
|
const address = canonicalizeAddress(await this.signer.getAddress());
|
|
20009
20028
|
const chainId = await this.signer.getChainId();
|
|
20010
20029
|
const keyId = `session-${Date.now()}`;
|
|
@@ -20136,6 +20155,7 @@ var NodeUserAuthorization = class {
|
|
|
20136
20155
|
* @param options Optional overrides for the OpenKey request.
|
|
20137
20156
|
*/
|
|
20138
20157
|
async signInWithOpenKey(authorizeFn, options) {
|
|
20158
|
+
refuseCaveated(this.getCapabilityRequest()?.manifests);
|
|
20139
20159
|
if (options?.host !== void 0) {
|
|
20140
20160
|
const overrideHost = options.host.trim();
|
|
20141
20161
|
if (!overrideHost) {
|
|
@@ -21345,6 +21365,7 @@ function ownerDelegationPermissions(params) {
|
|
|
21345
21365
|
if (!Array.isArray(params.permissions)) {
|
|
21346
21366
|
throw new Error("Owner delegation permissions are invalid");
|
|
21347
21367
|
}
|
|
21368
|
+
refuseCaveated(params.permissions);
|
|
21348
21369
|
permissions.push(...params.permissions.map((permission) => ({
|
|
21349
21370
|
service: permission.service,
|
|
21350
21371
|
path: permission.path,
|
|
@@ -21719,7 +21740,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21719
21740
|
if (!granted?.caveats?.length) {
|
|
21720
21741
|
return entry;
|
|
21721
21742
|
}
|
|
21722
|
-
if (entry.caveats !== void 0 && !
|
|
21743
|
+
if (entry.caveats !== void 0 && !recapCaveatsEqual2(entry.caveats, granted.caveats)) {
|
|
21723
21744
|
throw new Error("Invocation caveats do not match signed ReCap authority.");
|
|
21724
21745
|
}
|
|
21725
21746
|
return { ...entry, caveats: cloneRecapCaveats(granted.caveats) };
|
|
@@ -22438,6 +22459,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
22438
22459
|
await this.signInWith(() => this.auth.signInWithOpenKey(authorizeFn, options));
|
|
22439
22460
|
}
|
|
22440
22461
|
async signInWith(performSignIn) {
|
|
22462
|
+
refuseCaveated(this.auth?.capabilityRequest?.manifests);
|
|
22441
22463
|
const epoch = this.sessionEpoch;
|
|
22442
22464
|
const attempt = ++this.latestSessionAttempt;
|
|
22443
22465
|
await this.signOutInFlight;
|
|
@@ -26360,7 +26382,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26360
26382
|
throw new SessionExpiredError(plan.expiredAt ?? sessionExpiry ?? /* @__PURE__ */ new Date(0));
|
|
26361
26383
|
}
|
|
26362
26384
|
if (plan.refused === "CAVEATED_AUTHORITY") {
|
|
26363
|
-
throw new
|
|
26385
|
+
throw new CaveatedDelegationUnsupportedError2(plan.caveated ?? []);
|
|
26364
26386
|
}
|
|
26365
26387
|
throw new PermissionNotInManifestError(plan.missing ?? [], plan.granted ?? []);
|
|
26366
26388
|
}
|
|
@@ -26401,7 +26423,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26401
26423
|
*/
|
|
26402
26424
|
planDerivation(expandedEntries, session, effectiveExpiration, nowMs) {
|
|
26403
26425
|
const caveatedRequest = expandedEntries.filter(
|
|
26404
|
-
(entry) => !
|
|
26426
|
+
(entry) => !recapCaveatsEqual2(entry.caveats, void 0)
|
|
26405
26427
|
);
|
|
26406
26428
|
if (caveatedRequest.length > 0) {
|
|
26407
26429
|
return { refused: "CAVEATED_AUTHORITY", caveated: caveatedRequest };
|
|
@@ -26764,10 +26786,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26764
26786
|
*/
|
|
26765
26787
|
assertDelegationCaveatsPreservable(entries) {
|
|
26766
26788
|
const caveated = entries.filter(
|
|
26767
|
-
(entry) => !
|
|
26789
|
+
(entry) => !recapCaveatsEqual2(entry.caveats, void 0)
|
|
26768
26790
|
);
|
|
26769
26791
|
if (caveated.length > 0) {
|
|
26770
|
-
throw new
|
|
26792
|
+
throw new CaveatedDelegationUnsupportedError2(caveated);
|
|
26771
26793
|
}
|
|
26772
26794
|
}
|
|
26773
26795
|
/**
|
|
@@ -26779,7 +26801,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26779
26801
|
assertRuntimeGrantCaveatsPreservable(entries, requestedOperations, grant) {
|
|
26780
26802
|
const caveated = this.caveatedRuntimeGrantEntries(entries, requestedOperations, grant);
|
|
26781
26803
|
if (caveated.length > 0) {
|
|
26782
|
-
throw new
|
|
26804
|
+
throw new CaveatedDelegationUnsupportedError2(caveated);
|
|
26783
26805
|
}
|
|
26784
26806
|
}
|
|
26785
26807
|
/**
|
|
@@ -26796,7 +26818,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26796
26818
|
const requested = requestedOperations[operationIndex++];
|
|
26797
26819
|
if (!requested) continue;
|
|
26798
26820
|
const constrained = grant.operations.find(
|
|
26799
|
-
(granted) => this.operationCovers(granted, requested) && !
|
|
26821
|
+
(granted) => this.operationCovers(granted, requested) && !recapCaveatsEqual2(granted.caveats, void 0)
|
|
26800
26822
|
);
|
|
26801
26823
|
if (constrained) {
|
|
26802
26824
|
caveated.push({
|
|
@@ -26813,7 +26835,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26813
26835
|
assertPortableDelegationCaveatsPreservable(delegation) {
|
|
26814
26836
|
const entries = [];
|
|
26815
26837
|
const add3 = (service, space, path, actions, caveats) => {
|
|
26816
|
-
if (
|
|
26838
|
+
if (recapCaveatsEqual2(caveats, void 0)) return;
|
|
26817
26839
|
entries.push({
|
|
26818
26840
|
service: service.startsWith("tinycloud.") ? service : `tinycloud.${service}`,
|
|
26819
26841
|
space,
|
|
@@ -26833,7 +26855,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
26833
26855
|
add3(resource.service, resource.space, resource.path, resource.actions, resource.caveats);
|
|
26834
26856
|
}
|
|
26835
26857
|
if (entries.length > 0) {
|
|
26836
|
-
throw new
|
|
26858
|
+
throw new CaveatedDelegationUnsupportedError2(entries);
|
|
26837
26859
|
}
|
|
26838
26860
|
}
|
|
26839
26861
|
shortServiceName(service) {
|
|
@@ -27159,7 +27181,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
27159
27181
|
if (granted.service !== requested.service || !this.actionContains(granted.action, requested.action)) {
|
|
27160
27182
|
return false;
|
|
27161
27183
|
}
|
|
27162
|
-
if (requested.caveats !== void 0 && !
|
|
27184
|
+
if (requested.caveats !== void 0 && !recapCaveatsEqual2(granted.caveats, requested.caveats)) {
|
|
27163
27185
|
return false;
|
|
27164
27186
|
}
|
|
27165
27187
|
if (granted.resource !== void 0 || requested.resource !== void 0) {
|
|
@@ -27584,6 +27606,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
27584
27606
|
*/
|
|
27585
27607
|
async createSubDelegation(parentDelegation, params) {
|
|
27586
27608
|
this.assertPortableDelegationCaveatsPreservable(parentDelegation);
|
|
27609
|
+
refuseCaveated(params.resources);
|
|
27587
27610
|
if (!this.signer) {
|
|
27588
27611
|
throw new Error("Cannot createSubDelegation() in session-only mode. Requires wallet mode.");
|
|
27589
27612
|
}
|
|
@@ -27923,7 +27946,7 @@ import {
|
|
|
27923
27946
|
DEFAULT_MANIFEST_SPACE as DEFAULT_MANIFEST_SPACE2,
|
|
27924
27947
|
DEFAULT_MANIFEST_VERSION,
|
|
27925
27948
|
VAULT_PERMISSION_SERVICE,
|
|
27926
|
-
CaveatedDelegationUnsupportedError as
|
|
27949
|
+
CaveatedDelegationUnsupportedError as CaveatedDelegationUnsupportedError3,
|
|
27927
27950
|
PermissionNotInManifestError as PermissionNotInManifestError2,
|
|
27928
27951
|
SessionExpiredError as SessionExpiredError2,
|
|
27929
27952
|
ManifestValidationError,
|
|
@@ -30561,7 +30584,7 @@ export {
|
|
|
30561
30584
|
BOOTSTRAP_COMPLETION_MARKER_VERSION,
|
|
30562
30585
|
CapabilityKeyRegistry2 as CapabilityKeyRegistry,
|
|
30563
30586
|
CapabilityKeyRegistryErrorCodes,
|
|
30564
|
-
|
|
30587
|
+
CaveatedDelegationUnsupportedError3 as CaveatedDelegationUnsupportedError,
|
|
30565
30588
|
DECRYPT_ACTION3 as DECRYPT_ACTION,
|
|
30566
30589
|
DECRYPT_FACT_TYPE,
|
|
30567
30590
|
DECRYPT_RESULT_TYPE,
|