@tinycloud/sdk-core 3.0.0-beta.17 → 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 +1 -1
package/dist/index.cjs
CHANGED
|
@@ -11150,11 +11150,11 @@ var SharingService = class {
|
|
|
11150
11150
|
}
|
|
11151
11151
|
return result;
|
|
11152
11152
|
};
|
|
11153
|
-
const canSatisfyFromRegistry = this.
|
|
11153
|
+
const canSatisfyFromRegistry = this.classifyDelegationAuthority(
|
|
11154
11154
|
fullPath,
|
|
11155
11155
|
actions,
|
|
11156
11156
|
requestedExpiry
|
|
11157
|
-
);
|
|
11157
|
+
) === "ok";
|
|
11158
11158
|
if (canSatisfyFromRegistry) {
|
|
11159
11159
|
const delegationResult = await this.createSessionDelegation(plainDID, fullPath, actions, expiry);
|
|
11160
11160
|
const childDelegationActiveError = this.retiredGraphError();
|
|
@@ -11224,49 +11224,58 @@ var SharingService = class {
|
|
|
11224
11224
|
return { ok: true, data: shareLink };
|
|
11225
11225
|
}
|
|
11226
11226
|
/**
|
|
11227
|
-
*
|
|
11228
|
-
*
|
|
11229
|
-
*
|
|
11230
|
-
*
|
|
11231
|
-
*
|
|
11232
|
-
*
|
|
11227
|
+
* Report, without side effects, whether this session's registry authority
|
|
11228
|
+
* can issue the child delegation {@link generate} would create for the same
|
|
11229
|
+
* `path`, `actions` and `expiry` (defaults and `pathPrefix` applied the
|
|
11230
|
+
* same way):
|
|
11231
|
+
*
|
|
11232
|
+
* - `"ok"`: an uncaveated entry covers it.
|
|
11233
|
+
* - `"caveated"`: only caveated entries cover it. SharingService cannot
|
|
11234
|
+
* carry signed ReCap caveats into a child delegation.
|
|
11235
|
+
* - `"not-covered"`: no entry covers it, or there is no session.
|
|
11236
|
+
*
|
|
11237
|
+
* It does not consult `onRootDelegationNeeded`, so a signer-backed session
|
|
11238
|
+
* may still generate when this is not `"ok"`.
|
|
11239
|
+
*/
|
|
11240
|
+
preflightGenerate(params) {
|
|
11241
|
+
if (!this.session || !params.path) return "not-covered";
|
|
11242
|
+
const fullPath = this.pathPrefix ? `${this.pathPrefix}/${params.path}`.replace(/\/+/g, "/") : params.path;
|
|
11243
|
+
return this.classifyDelegationAuthority(
|
|
11244
|
+
fullPath,
|
|
11245
|
+
params.actions ?? DEFAULT_READ_ACTIONS,
|
|
11246
|
+
params.expiry ?? new Date(Date.now() + DEFAULT_EXPIRY_MS)
|
|
11247
|
+
);
|
|
11248
|
+
}
|
|
11249
|
+
/**
|
|
11250
|
+
* Classify the registry's authority for a child delegation. An entry
|
|
11251
|
+
* satisfies it when it is in the session space, valid, lasts at least until
|
|
11252
|
+
* `requestedExpiry`, allows sub-delegation, covers `path` (exact or parent)
|
|
11253
|
+
* and grants every action. Satisfying entries with caveats are unusable.
|
|
11233
11254
|
* @internal
|
|
11234
11255
|
*/
|
|
11235
|
-
|
|
11236
|
-
|
|
11237
|
-
for (const key of
|
|
11238
|
-
const
|
|
11239
|
-
for (const delegation of delegations) {
|
|
11256
|
+
classifyDelegationAuthority(path, actions, requestedExpiry) {
|
|
11257
|
+
let coveredOnlyByCaveated = false;
|
|
11258
|
+
for (const key of this.registry.getAllKeys()) {
|
|
11259
|
+
for (const delegation of this.registry.getDelegationsForKey(key.id)) {
|
|
11240
11260
|
if (delegation.spaceId === void 0 || !spaceIdsEqual(delegation.spaceId, this.session?.spaceId ?? "")) {
|
|
11241
11261
|
continue;
|
|
11242
11262
|
}
|
|
11243
|
-
if ((delegation
|
|
11244
|
-
|
|
11245
|
-
|
|
11246
|
-
if (!this.
|
|
11247
|
-
|
|
11248
|
-
|
|
11249
|
-
if (delegation.expiry < requestedExpiry) {
|
|
11250
|
-
continue;
|
|
11251
|
-
}
|
|
11252
|
-
if (delegation.allowSubDelegation === false) {
|
|
11253
|
-
continue;
|
|
11254
|
-
}
|
|
11255
|
-
const delegationPath = delegation.path || "";
|
|
11256
|
-
if (!this.pathMatches(delegationPath, path)) {
|
|
11263
|
+
if (!this.registry.isDelegationValid(delegation)) continue;
|
|
11264
|
+
if (delegation.expiry < requestedExpiry) continue;
|
|
11265
|
+
if (delegation.allowSubDelegation === false) continue;
|
|
11266
|
+
if (!this.pathMatches(delegation.path || "", path)) continue;
|
|
11267
|
+
const delegationActions = delegation.actions || [];
|
|
11268
|
+
if (!actions.every((action) => delegationActions.includes(action) || delegationActions.includes("*"))) {
|
|
11257
11269
|
continue;
|
|
11258
11270
|
}
|
|
11259
|
-
|
|
11260
|
-
|
|
11261
|
-
(action) => delegationActions.includes(action) || delegationActions.includes("*")
|
|
11262
|
-
);
|
|
11263
|
-
if (!hasAllActions) {
|
|
11271
|
+
if ((delegation.caveats?.length ?? 0) > 0) {
|
|
11272
|
+
coveredOnlyByCaveated = true;
|
|
11264
11273
|
continue;
|
|
11265
11274
|
}
|
|
11266
|
-
return
|
|
11275
|
+
return "ok";
|
|
11267
11276
|
}
|
|
11268
11277
|
}
|
|
11269
|
-
return
|
|
11278
|
+
return coveredOnlyByCaveated ? "caveated" : "not-covered";
|
|
11270
11279
|
}
|
|
11271
11280
|
retiredGraphError() {
|
|
11272
11281
|
try {
|