@tinycloud/sdk-core 3.0.0-beta.15 → 3.0.0-beta.18
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/delegations/index.cjs +43 -34
- package/dist/delegations/index.cjs.map +1 -1
- package/dist/delegations/index.d.cts +2 -2
- package/dist/delegations/index.d.ts +2 -2
- package/dist/delegations/index.js +43 -34
- package/dist/delegations/index.js.map +1 -1
- package/dist/index.cjs +43 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +43 -34
- package/dist/index.js.map +1 -1
- package/dist/{recipient-types.schema-lAKNQlxx.d.cts → recipient-types.schema-D9AI8tjN.d.cts} +34 -8
- package/dist/{recipient-types.schema-lAKNQlxx.d.ts → recipient-types.schema-D9AI8tjN.d.ts} +34 -8
- package/package.json +2 -2
|
@@ -5599,11 +5599,11 @@ var SharingService = class {
|
|
|
5599
5599
|
}
|
|
5600
5600
|
return result;
|
|
5601
5601
|
};
|
|
5602
|
-
const canSatisfyFromRegistry = this.
|
|
5602
|
+
const canSatisfyFromRegistry = this.classifyDelegationAuthority(
|
|
5603
5603
|
fullPath,
|
|
5604
5604
|
actions,
|
|
5605
5605
|
requestedExpiry
|
|
5606
|
-
);
|
|
5606
|
+
) === "ok";
|
|
5607
5607
|
if (canSatisfyFromRegistry) {
|
|
5608
5608
|
const delegationResult = await this.createSessionDelegation(plainDID, fullPath, actions, expiry);
|
|
5609
5609
|
const childDelegationActiveError = this.retiredGraphError();
|
|
@@ -5673,49 +5673,58 @@ var SharingService = class {
|
|
|
5673
5673
|
return { ok: true, data: shareLink };
|
|
5674
5674
|
}
|
|
5675
5675
|
/**
|
|
5676
|
-
*
|
|
5677
|
-
*
|
|
5678
|
-
*
|
|
5679
|
-
*
|
|
5680
|
-
*
|
|
5681
|
-
*
|
|
5676
|
+
* Report, without side effects, whether this session's registry authority
|
|
5677
|
+
* can issue the child delegation {@link generate} would create for the same
|
|
5678
|
+
* `path`, `actions` and `expiry` (defaults and `pathPrefix` applied the
|
|
5679
|
+
* same way):
|
|
5680
|
+
*
|
|
5681
|
+
* - `"ok"`: an uncaveated entry covers it.
|
|
5682
|
+
* - `"caveated"`: only caveated entries cover it. SharingService cannot
|
|
5683
|
+
* carry signed ReCap caveats into a child delegation.
|
|
5684
|
+
* - `"not-covered"`: no entry covers it, or there is no session.
|
|
5685
|
+
*
|
|
5686
|
+
* It does not consult `onRootDelegationNeeded`, so a signer-backed session
|
|
5687
|
+
* may still generate when this is not `"ok"`.
|
|
5688
|
+
*/
|
|
5689
|
+
preflightGenerate(params) {
|
|
5690
|
+
if (!this.session || !params.path) return "not-covered";
|
|
5691
|
+
const fullPath = this.pathPrefix ? `${this.pathPrefix}/${params.path}`.replace(/\/+/g, "/") : params.path;
|
|
5692
|
+
return this.classifyDelegationAuthority(
|
|
5693
|
+
fullPath,
|
|
5694
|
+
params.actions ?? DEFAULT_READ_ACTIONS,
|
|
5695
|
+
params.expiry ?? new Date(Date.now() + DEFAULT_EXPIRY_MS)
|
|
5696
|
+
);
|
|
5697
|
+
}
|
|
5698
|
+
/**
|
|
5699
|
+
* Classify the registry's authority for a child delegation. An entry
|
|
5700
|
+
* satisfies it when it is in the session space, valid, lasts at least until
|
|
5701
|
+
* `requestedExpiry`, allows sub-delegation, covers `path` (exact or parent)
|
|
5702
|
+
* and grants every action. Satisfying entries with caveats are unusable.
|
|
5682
5703
|
* @internal
|
|
5683
5704
|
*/
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
for (const key of
|
|
5687
|
-
const
|
|
5688
|
-
for (const delegation of delegations) {
|
|
5705
|
+
classifyDelegationAuthority(path, actions, requestedExpiry) {
|
|
5706
|
+
let coveredOnlyByCaveated = false;
|
|
5707
|
+
for (const key of this.registry.getAllKeys()) {
|
|
5708
|
+
for (const delegation of this.registry.getDelegationsForKey(key.id)) {
|
|
5689
5709
|
if (delegation.spaceId === void 0 || !spaceIdsEqual(delegation.spaceId, this.session?.spaceId ?? "")) {
|
|
5690
5710
|
continue;
|
|
5691
5711
|
}
|
|
5692
|
-
if ((delegation
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
if (!this.
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
if (delegation.expiry < requestedExpiry) {
|
|
5699
|
-
continue;
|
|
5700
|
-
}
|
|
5701
|
-
if (delegation.allowSubDelegation === false) {
|
|
5702
|
-
continue;
|
|
5703
|
-
}
|
|
5704
|
-
const delegationPath = delegation.path || "";
|
|
5705
|
-
if (!this.pathMatches(delegationPath, path)) {
|
|
5712
|
+
if (!this.registry.isDelegationValid(delegation)) continue;
|
|
5713
|
+
if (delegation.expiry < requestedExpiry) continue;
|
|
5714
|
+
if (delegation.allowSubDelegation === false) continue;
|
|
5715
|
+
if (!this.pathMatches(delegation.path || "", path)) continue;
|
|
5716
|
+
const delegationActions = delegation.actions || [];
|
|
5717
|
+
if (!actions.every((action) => delegationActions.includes(action) || delegationActions.includes("*"))) {
|
|
5706
5718
|
continue;
|
|
5707
5719
|
}
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
(action) => delegationActions.includes(action) || delegationActions.includes("*")
|
|
5711
|
-
);
|
|
5712
|
-
if (!hasAllActions) {
|
|
5720
|
+
if ((delegation.caveats?.length ?? 0) > 0) {
|
|
5721
|
+
coveredOnlyByCaveated = true;
|
|
5713
5722
|
continue;
|
|
5714
5723
|
}
|
|
5715
|
-
return
|
|
5724
|
+
return "ok";
|
|
5716
5725
|
}
|
|
5717
5726
|
}
|
|
5718
|
-
return
|
|
5727
|
+
return coveredOnlyByCaveated ? "caveated" : "not-covered";
|
|
5719
5728
|
}
|
|
5720
5729
|
retiredGraphError() {
|
|
5721
5730
|
try {
|