@tinycloud/sdk-core 3.0.0-beta.5 → 3.0.0-beta.6

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/index.cjs CHANGED
@@ -177,6 +177,7 @@ __export(index_exports, {
177
177
  SERVICE_LONG_TO_SHORT: () => SERVICE_LONG_TO_SHORT,
178
178
  SERVICE_SHORT_TO_LONG: () => SERVICE_SHORT_TO_LONG,
179
179
  SHARE_DELIVERY_AUTHORIZATION_DOMAIN: () => SHARE_DELIVERY_AUTHORIZATION_DOMAIN,
180
+ SHARE_DELIVERY_AUTHORIZATION_V3_DOMAIN: () => SHARE_DELIVERY_AUTHORIZATION_V3_DOMAIN,
180
181
  SPACE: () => import_bootstrap4.SPACE,
181
182
  SQL: () => import_bootstrap4.SQL,
182
183
  SQLAction: () => import_sdk_services8.SQLAction,
@@ -447,6 +448,7 @@ __export(index_exports, {
447
448
  validatePolicyStatusUnsigned: () => validatePolicyStatusUnsigned,
448
449
  validatePolicyUnsigned: () => validatePolicyUnsigned,
449
450
  validateShareDeliveryAuthorizationBytes: () => validateShareDeliveryAuthorizationBytes,
451
+ validateShareDeliveryAuthorizationV3Bytes: () => validateShareDeliveryAuthorizationV3Bytes,
450
452
  validateUnifiedPolicyV2: () => validateUnifiedPolicyV2,
451
453
  verifyDecryptResponse: () => import_sdk_services8.verifyDecryptResponse,
452
454
  verifyDidKeyEd25519Signature: () => verifyDidKeyEd25519Signature,
@@ -2242,16 +2244,16 @@ function policyCapabilityContains(authority, request) {
2242
2244
  return caveatsContain(auth.caveats, req.caveats);
2243
2245
  }
2244
2246
  function normalizePolicyCapabilityWithOptions(input, options2) {
2245
- const object3 = expectObject(input, "$");
2246
- assertExactKeys(object3, ["service", "space", "path", "actions", "caveats"], "$");
2247
- const service = requiredString(object3, "service", "$", "policy-capability-malformed-service");
2247
+ const object4 = expectObject(input, "$");
2248
+ assertExactKeys(object4, ["service", "space", "path", "actions", "caveats"], "$");
2249
+ const service = requiredString(object4, "service", "$", "policy-capability-malformed-service");
2248
2250
  if (!CEILING_SERVICES.has(service)) {
2249
2251
  throw new PolicyCapabilityError(
2250
2252
  "policy-capability-malformed-service",
2251
2253
  "$.service is outside the frozen permissionsCeiling vocabulary"
2252
2254
  );
2253
2255
  }
2254
- const space = requiredString(object3, "space", "$", "policy-capability-malformed-space");
2256
+ const space = requiredString(object4, "space", "$", "policy-capability-malformed-space");
2255
2257
  validateConcreteSpace(space);
2256
2258
  const canonicalSpace = space.normalize("NFC");
2257
2259
  if (options2.requireCanonical && canonicalSpace !== space) {
@@ -2260,7 +2262,7 @@ function normalizePolicyCapabilityWithOptions(input, options2) {
2260
2262
  "$.space must already be canonical NFC"
2261
2263
  );
2262
2264
  }
2263
- const rawPath = requiredString(object3, "path", "$", "policy-capability-malformed-path");
2265
+ const rawPath = requiredString(object4, "path", "$", "policy-capability-malformed-path");
2264
2266
  validateRawPath(rawPath, options2);
2265
2267
  const path = normalizePath(rawPath);
2266
2268
  if (options2.requireCanonical && path !== rawPath) {
@@ -2271,7 +2273,7 @@ function normalizePolicyCapabilityWithOptions(input, options2) {
2271
2273
  }
2272
2274
  validateRawPath(path, options2);
2273
2275
  const actions = normalizeActions(
2274
- requiredArray(object3, "actions", "$", "policy-capability-malformed-action"),
2276
+ requiredArray(object4, "actions", "$", "policy-capability-malformed-action"),
2275
2277
  service,
2276
2278
  options2
2277
2279
  );
@@ -2280,9 +2282,9 @@ function normalizePolicyCapabilityWithOptions(input, options2) {
2280
2282
  output.space = canonicalSpace;
2281
2283
  output.path = path;
2282
2284
  output.actions = actions;
2283
- if (hasOwn(object3, "caveats")) {
2285
+ if (hasOwn(object4, "caveats")) {
2284
2286
  output.caveats = validateCaveats(
2285
- requiredValue(object3, "caveats", "$", "policy-capability-malformed-caveats"),
2287
+ requiredValue(object4, "caveats", "$", "policy-capability-malformed-caveats"),
2286
2288
  output.service
2287
2289
  );
2288
2290
  }
@@ -2305,9 +2307,9 @@ function expectObject(input, path) {
2305
2307
  );
2306
2308
  }
2307
2309
  }
2308
- function assertExactKeys(object3, allowed, path) {
2310
+ function assertExactKeys(object4, allowed, path) {
2309
2311
  const allowedSet = new Set(allowed);
2310
- for (const key of Object.keys(object3)) {
2312
+ for (const key of Object.keys(object4)) {
2311
2313
  if (!allowedSet.has(key)) {
2312
2314
  throw new PolicyCapabilityError(
2313
2315
  key === "id" || key === "scope" ? "policy-capability-malformed" : "policy-capability-unknown-key",
@@ -2316,21 +2318,21 @@ function assertExactKeys(object3, allowed, path) {
2316
2318
  }
2317
2319
  }
2318
2320
  }
2319
- function requiredValue(object3, key, path, code3) {
2320
- if (!hasOwn(object3, key)) {
2321
+ function requiredValue(object4, key, path, code3) {
2322
+ if (!hasOwn(object4, key)) {
2321
2323
  throw new PolicyCapabilityError(code3, `${path}.${key} is required`);
2322
2324
  }
2323
- return object3[key];
2325
+ return object4[key];
2324
2326
  }
2325
- function requiredString(object3, key, path, code3) {
2326
- const value = requiredValue(object3, key, path, code3);
2327
+ function requiredString(object4, key, path, code3) {
2328
+ const value = requiredValue(object4, key, path, code3);
2327
2329
  if (typeof value !== "string" || value.length === 0) {
2328
2330
  throw new PolicyCapabilityError(code3, `${path}.${key} must be a non-empty string`);
2329
2331
  }
2330
2332
  return value;
2331
2333
  }
2332
- function requiredArray(object3, key, path, code3) {
2333
- const value = requiredValue(object3, key, path, code3);
2334
+ function requiredArray(object4, key, path, code3) {
2335
+ const value = requiredValue(object4, key, path, code3);
2334
2336
  if (!Array.isArray(value)) {
2335
2337
  throw new PolicyCapabilityError(code3, `${path}.${key} must be an array`);
2336
2338
  }
@@ -2475,11 +2477,11 @@ function validateSqlStatement(input, path) {
2475
2477
  if (input === null || typeof input !== "object" || Array.isArray(input)) {
2476
2478
  throw new PolicyCapabilityError("policy-capability-malformed-caveats", `${path} must be an object`);
2477
2479
  }
2478
- const object3 = input;
2479
- assertCaveatKeys(object3, ["name", "sql", "fixedParams"], path);
2480
- caveatString(object3, "name", path);
2481
- caveatString(object3, "sql", path);
2482
- const fixedParams = requiredCaveat(object3, "fixedParams", path);
2480
+ const object4 = input;
2481
+ assertCaveatKeys(object4, ["name", "sql", "fixedParams"], path);
2482
+ caveatString(object4, "name", path);
2483
+ caveatString(object4, "sql", path);
2484
+ const fixedParams = requiredCaveat(object4, "fixedParams", path);
2483
2485
  if (!Array.isArray(fixedParams)) {
2484
2486
  throw new PolicyCapabilityError(
2485
2487
  "policy-capability-malformed-caveats",
@@ -2494,20 +2496,20 @@ function validateFixedParam(input, path) {
2494
2496
  if (input === null || typeof input !== "object" || Array.isArray(input)) {
2495
2497
  throw new PolicyCapabilityError("policy-capability-malformed-caveats", `${path} must be an object`);
2496
2498
  }
2497
- const object3 = input;
2498
- assertCaveatKeys(object3, ["index", "value"], path);
2499
- const index = requiredCaveat(object3, "index", path);
2499
+ const object4 = input;
2500
+ assertCaveatKeys(object4, ["index", "value"], path);
2501
+ const index = requiredCaveat(object4, "index", path);
2500
2502
  if (typeof index !== "number" || !Number.isSafeInteger(index) || index < 0) {
2501
2503
  throw new PolicyCapabilityError(
2502
2504
  "policy-capability-malformed-caveats",
2503
2505
  `${path}.index must be a non-negative integer`
2504
2506
  );
2505
2507
  }
2506
- requiredCaveat(object3, "value", path);
2508
+ requiredCaveat(object4, "value", path);
2507
2509
  }
2508
- function assertCaveatKeys(object3, allowed, path) {
2510
+ function assertCaveatKeys(object4, allowed, path) {
2509
2511
  const allowedSet = new Set(allowed);
2510
- for (const key of Object.keys(object3)) {
2512
+ for (const key of Object.keys(object4)) {
2511
2513
  if (!allowedSet.has(key)) {
2512
2514
  throw new PolicyCapabilityError(
2513
2515
  "policy-capability-malformed-caveats",
@@ -2516,17 +2518,17 @@ function assertCaveatKeys(object3, allowed, path) {
2516
2518
  }
2517
2519
  }
2518
2520
  }
2519
- function requiredCaveat(object3, key, path) {
2520
- if (!hasOwn(object3, key)) {
2521
+ function requiredCaveat(object4, key, path) {
2522
+ if (!hasOwn(object4, key)) {
2521
2523
  throw new PolicyCapabilityError(
2522
2524
  "policy-capability-malformed-caveats",
2523
2525
  `${path}.${key} is required`
2524
2526
  );
2525
2527
  }
2526
- return object3[key];
2528
+ return object4[key];
2527
2529
  }
2528
- function caveatString(object3, key, path) {
2529
- const value = requiredCaveat(object3, key, path);
2530
+ function caveatString(object4, key, path) {
2531
+ const value = requiredCaveat(object4, key, path);
2530
2532
  if (typeof value !== "string" || value.length === 0) {
2531
2533
  throw new PolicyCapabilityError(
2532
2534
  "policy-capability-malformed-caveats",
@@ -2557,8 +2559,8 @@ function caveatsContain(authority, request) {
2557
2559
  (statement) => authorityStatements.some((candidate) => jcsCanonicalize(candidate) === jcsCanonicalize(statement))
2558
2560
  );
2559
2561
  }
2560
- function hasOwn(object3, key) {
2561
- return objectHasOwn2(object3, key);
2562
+ function hasOwn(object4, key) {
2563
+ return objectHasOwn2(object4, key);
2562
2564
  }
2563
2565
 
2564
2566
  // src/policy/signed-object.ts
@@ -2886,17 +2888,17 @@ async function createAndSignSignedObject(input, signer) {
2886
2888
  }
2887
2889
  function createAndSignPolicy(input, signer) {
2888
2890
  return createAndSignSignedObject(input, signer).then(
2889
- (object3) => validatePolicySignedShape(object3)
2891
+ (object4) => validatePolicySignedShape(object4)
2890
2892
  );
2891
2893
  }
2892
2894
  function createAndSignPolicyStatus(input, signer) {
2893
2895
  return createAndSignSignedObject(input, signer).then(
2894
- (object3) => validatePolicyStatusSignedShape(object3)
2896
+ (object4) => validatePolicyStatusSignedShape(object4)
2895
2897
  );
2896
2898
  }
2897
2899
  function createAndSignPolicyEngineRecord(input, signer) {
2898
2900
  return createAndSignSignedObject(input, signer).then(
2899
- (object3) => validatePolicyEngineRecordSignedShape(object3)
2901
+ (object4) => validatePolicyEngineRecordSignedShape(object4)
2900
2902
  );
2901
2903
  }
2902
2904
  async function verifySignedObject(input) {
@@ -3000,9 +3002,9 @@ function validateUnsignedForDescriptor(input, descriptor) {
3000
3002
  }
3001
3003
  }
3002
3004
  function validatePolicyShape(input, signed) {
3003
- const object3 = expectJsonObject(normalizeJson(input), "$");
3005
+ const object4 = expectJsonObject(normalizeJson(input), "$");
3004
3006
  assertExactKeys2(
3005
- object3,
3007
+ object4,
3006
3008
  signed ? [
3007
3009
  "schema",
3008
3010
  "policyId",
@@ -3030,30 +3032,30 @@ function validatePolicyShape(input, signed) {
3030
3032
  ],
3031
3033
  "$"
3032
3034
  );
3033
- expectConst(requiredString2(object3, "schema", "$"), POLICY_SCHEMA, "$.schema");
3035
+ expectConst(requiredString2(object4, "schema", "$"), POLICY_SCHEMA, "$.schema");
3034
3036
  if (signed) {
3035
- requiredString2(object3, "policyId", "$");
3036
- validateSignature(requiredValue2(object3, "signature", "$"));
3037
+ requiredString2(object4, "policyId", "$");
3038
+ validateSignature(requiredValue2(object4, "signature", "$"));
3037
3039
  }
3038
- requiredString2(object3, "ownerDid", "$");
3039
- requiredString2(object3, "signingKeyDid", "$");
3040
- requiredDateString(object3, "createdAt", "$");
3041
- optionalDateString(object3, "expiresAt", "$");
3042
- validatePolicyResource(requiredValue2(object3, "resource", "$"), "$.resource");
3043
- validateExpression(requiredValue2(object3, "when", "$"), "$.when");
3044
- validateGrant(requiredValue2(object3, "grant", "$"), "$.grant");
3045
- if (hasOwn2(object3, "disclosure")) {
3046
- validateDisclosure(requiredValue2(object3, "disclosure", "$"), "$.disclosure");
3040
+ requiredString2(object4, "ownerDid", "$");
3041
+ requiredString2(object4, "signingKeyDid", "$");
3042
+ requiredDateString(object4, "createdAt", "$");
3043
+ optionalDateString(object4, "expiresAt", "$");
3044
+ validatePolicyResource(requiredValue2(object4, "resource", "$"), "$.resource");
3045
+ validateExpression(requiredValue2(object4, "when", "$"), "$.when");
3046
+ validateGrant(requiredValue2(object4, "grant", "$"), "$.grant");
3047
+ if (hasOwn2(object4, "disclosure")) {
3048
+ validateDisclosure(requiredValue2(object4, "disclosure", "$"), "$.disclosure");
3047
3049
  }
3048
- if (hasOwn2(object3, "audit")) {
3049
- validateAudit(requiredValue2(object3, "audit", "$"), "$.audit");
3050
+ if (hasOwn2(object4, "audit")) {
3051
+ validateAudit(requiredValue2(object4, "audit", "$"), "$.audit");
3050
3052
  }
3051
- return object3;
3053
+ return object4;
3052
3054
  }
3053
3055
  function validatePolicyStatusShape(input, signed) {
3054
- const object3 = expectJsonObject(normalizeJson(input), "$");
3056
+ const object4 = expectJsonObject(normalizeJson(input), "$");
3055
3057
  assertExactKeys2(
3056
- object3,
3058
+ object4,
3057
3059
  signed ? [
3058
3060
  "schema",
3059
3061
  "statusId",
@@ -3077,28 +3079,28 @@ function validatePolicyStatusShape(input, signed) {
3077
3079
  ],
3078
3080
  "$"
3079
3081
  );
3080
- expectConst(requiredString2(object3, "schema", "$"), POLICY_STATUS_SCHEMA, "$.schema");
3082
+ expectConst(requiredString2(object4, "schema", "$"), POLICY_STATUS_SCHEMA, "$.schema");
3081
3083
  if (signed) {
3082
- requiredString2(object3, "statusId", "$");
3083
- validateSignature(requiredValue2(object3, "signature", "$"));
3084
+ requiredString2(object4, "statusId", "$");
3085
+ validateSignature(requiredValue2(object4, "signature", "$"));
3084
3086
  }
3085
- requiredString2(object3, "policyId", "$");
3086
- requiredString2(object3, "ownerDid", "$");
3087
- requiredInteger(object3, "sequence", "$", 0);
3088
- expectOneOf(requiredString2(object3, "disposition", "$"), [
3087
+ requiredString2(object4, "policyId", "$");
3088
+ requiredString2(object4, "ownerDid", "$");
3089
+ requiredInteger(object4, "sequence", "$", 0);
3090
+ expectOneOf(requiredString2(object4, "disposition", "$"), [
3089
3091
  "active",
3090
3092
  "suspended",
3091
3093
  "revoked"
3092
3094
  ], "$.disposition");
3093
- requiredDateString(object3, "effectiveAt", "$");
3094
- optionalString(object3, "reasonCode", "$");
3095
- requiredString2(object3, "signingKeyDid", "$");
3096
- return object3;
3095
+ requiredDateString(object4, "effectiveAt", "$");
3096
+ optionalString(object4, "reasonCode", "$");
3097
+ requiredString2(object4, "signingKeyDid", "$");
3098
+ return object4;
3097
3099
  }
3098
3100
  function validatePolicyEngineRecordShape(input, signed) {
3099
- const object3 = expectJsonObject(normalizeJson(input), "$");
3101
+ const object4 = expectJsonObject(normalizeJson(input), "$");
3100
3102
  assertExactKeys2(
3101
- object3,
3103
+ object4,
3102
3104
  signed ? [
3103
3105
  "schema",
3104
3106
  "engineRecordId",
@@ -3123,44 +3125,44 @@ function validatePolicyEngineRecordShape(input, signed) {
3123
3125
  "$"
3124
3126
  );
3125
3127
  expectConst(
3126
- requiredString2(object3, "schema", "$"),
3128
+ requiredString2(object4, "schema", "$"),
3127
3129
  POLICY_ENGINE_RECORD_SCHEMA,
3128
3130
  "$.schema"
3129
3131
  );
3130
3132
  if (signed) {
3131
- requiredString2(object3, "engineRecordId", "$");
3132
- validateSignature(requiredValue2(object3, "signature", "$"));
3133
+ requiredString2(object4, "engineRecordId", "$");
3134
+ validateSignature(requiredValue2(object4, "signature", "$"));
3133
3135
  }
3134
- requiredString2(object3, "ownerDid", "$");
3135
- requiredString2(object3, "endpoint", "$");
3136
- requiredString2(object3, "audience", "$");
3136
+ requiredString2(object4, "ownerDid", "$");
3137
+ requiredString2(object4, "endpoint", "$");
3138
+ requiredString2(object4, "audience", "$");
3137
3139
  requiredStringArray(
3138
- object3,
3140
+ object4,
3139
3141
  "supportedPolicyVersions",
3140
3142
  "$",
3141
3143
  (value, path) => expectConst(value, "v0", path)
3142
3144
  );
3143
- requiredStringArray(object3, "supportedEvidenceVerifiers", "$");
3144
- requiredString2(object3, "grantIssuerDid", "$");
3145
- requiredDateString(object3, "expiresAt", "$");
3146
- return object3;
3145
+ requiredStringArray(object4, "supportedEvidenceVerifiers", "$");
3146
+ requiredString2(object4, "grantIssuerDid", "$");
3147
+ requiredDateString(object4, "expiresAt", "$");
3148
+ return object4;
3147
3149
  }
3148
3150
  function validateSignature(input) {
3149
- const object3 = expectJsonObject(input, "$.signature");
3150
- assertExactKeys2(object3, ["suite", "signerDid", "value"], "$.signature");
3151
- const suite = requiredString2(object3, "suite", "$.signature");
3151
+ const object4 = expectJsonObject(input, "$.signature");
3152
+ assertExactKeys2(object4, ["suite", "signerDid", "value"], "$.signature");
3153
+ const suite = requiredString2(object4, "suite", "$.signature");
3152
3154
  assertSupportedSignatureSuite(suite);
3153
- const signerDid = requiredString2(object3, "signerDid", "$.signature");
3154
- const value = requiredString2(object3, "value", "$.signature");
3155
+ const signerDid = requiredString2(object4, "signerDid", "$.signature");
3156
+ const value = requiredString2(object4, "value", "$.signature");
3155
3157
  decodeSignatureValue(value, suite);
3156
3158
  return { suite, signerDid, value };
3157
3159
  }
3158
3160
  function validatePolicyResource(input, path) {
3159
- const object3 = expectJsonObject(input, path);
3160
- assertExactKeys2(object3, ["resourceType", "resourceId", "permissionsCeiling"], path);
3161
- requiredString2(object3, "resourceType", path);
3162
- requiredString2(object3, "resourceId", path);
3163
- const ceiling = requiredArray2(object3, "permissionsCeiling", path, 1);
3161
+ const object4 = expectJsonObject(input, path);
3162
+ assertExactKeys2(object4, ["resourceType", "resourceId", "permissionsCeiling"], path);
3163
+ requiredString2(object4, "resourceType", path);
3164
+ requiredString2(object4, "resourceId", path);
3165
+ const ceiling = requiredArray2(object4, "permissionsCeiling", path, 1);
3164
3166
  for (let index = 0; index < ceiling.length; index++) {
3165
3167
  validatePolicyCapability(ceiling[index], `${path}.permissionsCeiling[${index}]`);
3166
3168
  }
@@ -3176,10 +3178,10 @@ function validatePolicyPermissionsCeilingForSigning(input) {
3176
3178
  }
3177
3179
  }
3178
3180
  function validatePolicyCapability(input, path) {
3179
- const object3 = expectJsonObject(input, path);
3181
+ const object4 = expectJsonObject(input, path);
3180
3182
  try {
3181
- const canonical = canonicalizePolicyCapability(object3);
3182
- if (jcsCanonicalize(object3) !== jcsCanonicalize(canonical)) {
3183
+ const canonical = canonicalizePolicyCapability(object4);
3184
+ if (jcsCanonicalize(object4) !== jcsCanonicalize(canonical)) {
3183
3185
  throw new SignedObjectSchemaError(`${path} must be canonical PolicyCapability JSON`);
3184
3186
  }
3185
3187
  } catch (error) {
@@ -3192,10 +3194,10 @@ function validatePolicyCapability(input, path) {
3192
3194
  }
3193
3195
  }
3194
3196
  function validatePolicyCapabilityForSigning(input, path) {
3195
- const object3 = expectJsonObject(input, path);
3197
+ const object4 = expectJsonObject(input, path);
3196
3198
  try {
3197
- const canonical = normalizePolicyCapability(object3);
3198
- if (jcsCanonicalize(object3) !== jcsCanonicalize(canonical)) {
3199
+ const canonical = normalizePolicyCapability(object4);
3200
+ if (jcsCanonicalize(object4) !== jcsCanonicalize(canonical)) {
3199
3201
  throw new SignedObjectSchemaError(`${path} must be strict canonical PolicyCapability JSON`);
3200
3202
  }
3201
3203
  } catch (error) {
@@ -3208,43 +3210,43 @@ function validatePolicyCapabilityForSigning(input, path) {
3208
3210
  }
3209
3211
  }
3210
3212
  function validateExpression(input, path) {
3211
- const object3 = expectJsonObject(input, path);
3212
- const keys = Object.keys(object3);
3213
+ const object4 = expectJsonObject(input, path);
3214
+ const keys = Object.keys(object4);
3213
3215
  if (keys.length !== 1) {
3214
3216
  throw new SignedObjectSchemaError(`${path} must have exactly one expression key`);
3215
3217
  }
3216
3218
  const key = keys[0];
3217
3219
  if (key === "allOf" || key === "anyOf") {
3218
- const values = requiredArray2(object3, key, path, 1);
3220
+ const values = requiredArray2(object4, key, path, 1);
3219
3221
  for (let index = 0; index < values.length; index++) {
3220
3222
  validateExpression(values[index], `${path}.${key}[${index}]`);
3221
3223
  }
3222
3224
  return;
3223
3225
  }
3224
3226
  if (key === "subject") {
3225
- const subject = expectJsonObject(requiredValue2(object3, "subject", path), `${path}.subject`);
3227
+ const subject = expectJsonObject(requiredValue2(object4, "subject", path), `${path}.subject`);
3226
3228
  assertExactKeys2(subject, ["did"], `${path}.subject`);
3227
3229
  requiredString2(subject, "did", `${path}.subject`);
3228
3230
  return;
3229
3231
  }
3230
3232
  if (key === "evidence") {
3231
- validateEvidenceRequirement(requiredValue2(object3, "evidence", path), `${path}.evidence`);
3233
+ validateEvidenceRequirement(requiredValue2(object4, "evidence", path), `${path}.evidence`);
3232
3234
  return;
3233
3235
  }
3234
3236
  throw new SignedObjectSchemaError(`${path} has unknown expression key ${key}`);
3235
3237
  }
3236
3238
  function validateEvidenceRequirement(input, path) {
3237
- const object3 = expectJsonObject(input, path);
3239
+ const object4 = expectJsonObject(input, path);
3238
3240
  assertExactKeys2(
3239
- object3,
3241
+ object4,
3240
3242
  ["requirementId", "verifier", "requirements", "authority", "freshness"],
3241
3243
  path
3242
3244
  );
3243
- requiredString2(object3, "requirementId", path);
3244
- requiredString2(object3, "verifier", path);
3245
- requiredValue2(object3, "requirements", path);
3246
- if (hasOwn2(object3, "authority")) {
3247
- const authority = expectJsonObject(requiredValue2(object3, "authority", path), `${path}.authority`);
3245
+ requiredString2(object4, "requirementId", path);
3246
+ requiredString2(object4, "verifier", path);
3247
+ requiredValue2(object4, "requirements", path);
3248
+ if (hasOwn2(object4, "authority")) {
3249
+ const authority = expectJsonObject(requiredValue2(object4, "authority", path), `${path}.authority`);
3248
3250
  assertExactKeys2(
3249
3251
  authority,
3250
3252
  ["profile", "acceptedIssuers", "allowOwnerAuthorizedIssuer"],
@@ -3256,35 +3258,35 @@ function validateEvidenceRequirement(input, path) {
3256
3258
  }
3257
3259
  optionalBoolean(authority, "allowOwnerAuthorizedIssuer", `${path}.authority`);
3258
3260
  }
3259
- if (hasOwn2(object3, "freshness")) {
3260
- const freshness = expectJsonObject(requiredValue2(object3, "freshness", path), `${path}.freshness`);
3261
+ if (hasOwn2(object4, "freshness")) {
3262
+ const freshness = expectJsonObject(requiredValue2(object4, "freshness", path), `${path}.freshness`);
3261
3263
  assertExactKeys2(freshness, ["maxStatusAgeSeconds"], `${path}.freshness`);
3262
3264
  requiredInteger(freshness, "maxStatusAgeSeconds", `${path}.freshness`, 0);
3263
3265
  }
3264
3266
  }
3265
3267
  function validateGrant(input, path) {
3266
- const object3 = expectJsonObject(input, path);
3267
- assertExactKeys2(object3, ["output", "maxTtlSeconds", "delegationMode", "revocation"], path);
3268
- expectConst(requiredString2(object3, "output", path), "portable-delegation", `${path}.output`);
3269
- requiredInteger(object3, "maxTtlSeconds", path, 1);
3270
- expectOneOf(requiredString2(object3, "delegationMode", path), [
3268
+ const object4 = expectJsonObject(input, path);
3269
+ assertExactKeys2(object4, ["output", "maxTtlSeconds", "delegationMode", "revocation"], path);
3270
+ expectConst(requiredString2(object4, "output", path), "portable-delegation", `${path}.output`);
3271
+ requiredInteger(object4, "maxTtlSeconds", path, 1);
3272
+ expectOneOf(requiredString2(object4, "delegationMode", path), [
3271
3273
  "terminal",
3272
3274
  "attenuable"
3273
3275
  ], `${path}.delegationMode`);
3274
- expectOneOf(requiredString2(object3, "revocation", path), [
3276
+ expectOneOf(requiredString2(object4, "revocation", path), [
3275
3277
  "refresh_only",
3276
3278
  "active_cutoff"
3277
3279
  ], `${path}.revocation`);
3278
3280
  }
3279
3281
  function validateDisclosure(input, path) {
3280
- const object3 = expectJsonObject(input, path);
3281
- assertExactKeys2(object3, ["denial"], path);
3282
- expectOneOf(requiredString2(object3, "denial", path), ["none", "code", "debug"], `${path}.denial`);
3282
+ const object4 = expectJsonObject(input, path);
3283
+ assertExactKeys2(object4, ["denial"], path);
3284
+ expectOneOf(requiredString2(object4, "denial", path), ["none", "code", "debug"], `${path}.denial`);
3283
3285
  }
3284
3286
  function validateAudit(input, path) {
3285
- const object3 = expectJsonObject(input, path);
3286
- assertExactKeys2(object3, ["issuance"], path);
3287
- expectOneOf(requiredString2(object3, "issuance", path), ["off", "security", "full"], `${path}.issuance`);
3287
+ const object4 = expectJsonObject(input, path);
3288
+ assertExactKeys2(object4, ["issuance"], path);
3289
+ expectOneOf(requiredString2(object4, "issuance", path), ["off", "security", "full"], `${path}.issuance`);
3288
3290
  }
3289
3291
  function materialForUnsigned(unsigned, descriptor) {
3290
3292
  const jcs = jcsCanonicalize(unsigned);
@@ -3433,9 +3435,9 @@ function encodeSignatureValue(value, suite) {
3433
3435
  decodeSignatureValue(encoded, suite);
3434
3436
  return encoded;
3435
3437
  }
3436
- function stripOwnIdAndSignature(object3, descriptor) {
3438
+ function stripOwnIdAndSignature(object4, descriptor) {
3437
3439
  const output = /* @__PURE__ */ Object.create(null);
3438
- for (const [key, value] of Object.entries(object3)) {
3440
+ for (const [key, value] of Object.entries(object4)) {
3439
3441
  if (key === descriptor.idField || key === "signature") {
3440
3442
  continue;
3441
3443
  }
@@ -3444,8 +3446,8 @@ function stripOwnIdAndSignature(object3, descriptor) {
3444
3446
  return output;
3445
3447
  }
3446
3448
  function descriptorForUnsigned(input) {
3447
- const object3 = expectJsonObject(normalizeJson(input), "$");
3448
- return descriptorForSchema(requiredString2(object3, "schema", "$"));
3449
+ const object4 = expectJsonObject(normalizeJson(input), "$");
3450
+ return descriptorForSchema(requiredString2(object4, "schema", "$"));
3449
3451
  }
3450
3452
  function descriptorForSchema(schema) {
3451
3453
  if (schema === POLICY_SCHEMA) return DESCRIPTORS.Policy;
@@ -3459,28 +3461,28 @@ function expectJsonObject(input, path) {
3459
3461
  }
3460
3462
  return input;
3461
3463
  }
3462
- function assertExactKeys2(object3, allowed, path) {
3464
+ function assertExactKeys2(object4, allowed, path) {
3463
3465
  const allowedSet = new Set(allowed);
3464
- for (const key of Object.keys(object3)) {
3466
+ for (const key of Object.keys(object4)) {
3465
3467
  if (!allowedSet.has(key)) {
3466
3468
  throw new SignedObjectSchemaError(`${path} has unknown field ${key}`);
3467
3469
  }
3468
3470
  }
3469
3471
  }
3470
- function requiredValue2(object3, key, path) {
3471
- if (!hasOwn2(object3, key)) {
3472
+ function requiredValue2(object4, key, path) {
3473
+ if (!hasOwn2(object4, key)) {
3472
3474
  throw new SignedObjectSchemaError(`${path}.${key} is required`);
3473
3475
  }
3474
- return object3[key];
3476
+ return object4[key];
3475
3477
  }
3476
- function requiredString2(object3, key, path) {
3477
- return requireStringType(requiredValue2(object3, key, path), `${path}.${key}`);
3478
+ function requiredString2(object4, key, path) {
3479
+ return requireStringType(requiredValue2(object4, key, path), `${path}.${key}`);
3478
3480
  }
3479
- function optionalString(object3, key, path) {
3480
- if (!hasOwn2(object3, key)) {
3481
+ function optionalString(object4, key, path) {
3482
+ if (!hasOwn2(object4, key)) {
3481
3483
  return;
3482
3484
  }
3483
- requireStringType(requiredValue2(object3, key, path), `${path}.${key}`);
3485
+ requireStringType(requiredValue2(object4, key, path), `${path}.${key}`);
3484
3486
  }
3485
3487
  function requireStringType(value, path) {
3486
3488
  if (typeof value !== "string" || value.length === 0) {
@@ -3488,16 +3490,16 @@ function requireStringType(value, path) {
3488
3490
  }
3489
3491
  return value;
3490
3492
  }
3491
- function optionalBoolean(object3, key, path) {
3492
- if (!hasOwn2(object3, key)) {
3493
+ function optionalBoolean(object4, key, path) {
3494
+ if (!hasOwn2(object4, key)) {
3493
3495
  return;
3494
3496
  }
3495
- if (typeof requiredValue2(object3, key, path) !== "boolean") {
3497
+ if (typeof requiredValue2(object4, key, path) !== "boolean") {
3496
3498
  throw new SignedObjectSchemaError(`${path}.${key} must be a boolean`);
3497
3499
  }
3498
3500
  }
3499
- function requiredInteger(object3, key, path, minimum) {
3500
- const value = requiredValue2(object3, key, path);
3501
+ function requiredInteger(object4, key, path, minimum) {
3502
+ const value = requiredValue2(object4, key, path);
3501
3503
  if (typeof value !== "number" || !Number.isSafeInteger(value) || value < minimum) {
3502
3504
  throw new SignedObjectSchemaError(
3503
3505
  `${path}.${key} must be an integer >= ${minimum}`
@@ -3505,8 +3507,8 @@ function requiredInteger(object3, key, path, minimum) {
3505
3507
  }
3506
3508
  return value;
3507
3509
  }
3508
- function requiredArray2(object3, key, path, minimum) {
3509
- const value = requiredValue2(object3, key, path);
3510
+ function requiredArray2(object4, key, path, minimum) {
3511
+ const value = requiredValue2(object4, key, path);
3510
3512
  if (!Array.isArray(value) || value.length < minimum) {
3511
3513
  throw new SignedObjectSchemaError(
3512
3514
  `${path}.${key} must be an array with at least ${minimum} item(s)`
@@ -3514,22 +3516,22 @@ function requiredArray2(object3, key, path, minimum) {
3514
3516
  }
3515
3517
  return value;
3516
3518
  }
3517
- function requiredStringArray(object3, key, path, check) {
3518
- const values = requiredArray2(object3, key, path, 0);
3519
+ function requiredStringArray(object4, key, path, check) {
3520
+ const values = requiredArray2(object4, key, path, 0);
3519
3521
  for (let index = 0; index < values.length; index++) {
3520
3522
  const itemPath = `${path}.${key}[${index}]`;
3521
3523
  const value = requireStringType(values[index], itemPath);
3522
3524
  check?.(value, itemPath);
3523
3525
  }
3524
3526
  }
3525
- function requiredDateString(object3, key, path) {
3526
- assertRfc3339(requiredString2(object3, key, path), `${path}.${key}`);
3527
+ function requiredDateString(object4, key, path) {
3528
+ assertRfc3339(requiredString2(object4, key, path), `${path}.${key}`);
3527
3529
  }
3528
- function optionalDateString(object3, key, path) {
3529
- if (!hasOwn2(object3, key)) {
3530
+ function optionalDateString(object4, key, path) {
3531
+ if (!hasOwn2(object4, key)) {
3530
3532
  return;
3531
3533
  }
3532
- assertRfc3339(requiredString2(object3, key, path), `${path}.${key}`);
3534
+ assertRfc3339(requiredString2(object4, key, path), `${path}.${key}`);
3533
3535
  }
3534
3536
  function assertRfc3339(value, path) {
3535
3537
  const match = value.match(
@@ -3561,8 +3563,8 @@ function expectOneOf(actual, allowed, path) {
3561
3563
  }
3562
3564
  throw new SignedObjectSchemaError(`${path} has unsupported value ${actual}`);
3563
3565
  }
3564
- function hasOwn2(object3, key) {
3565
- return objectHasOwn3(object3, key);
3566
+ function hasOwn2(object4, key) {
3567
+ return objectHasOwn3(object4, key);
3566
3568
  }
3567
3569
  function assertSupportedSignatureSuite(suite) {
3568
3570
  if (suite !== ED25519_JCS_SIGNATURE_SUITE && suite !== EIP191_JCS_SIGNATURE_SUITE) {
@@ -3789,9 +3791,9 @@ function expectObject2(input, path, code3) {
3789
3791
  );
3790
3792
  }
3791
3793
  }
3792
- function assertExactKeys3(object3, allowed, path) {
3794
+ function assertExactKeys3(object4, allowed, path) {
3793
3795
  const allowedSet = new Set(allowed);
3794
- for (const key of Object.keys(object3)) {
3796
+ for (const key of Object.keys(object4)) {
3795
3797
  if (!allowedSet.has(key)) {
3796
3798
  throw new PolicyAuthoringError(
3797
3799
  "policy-authoring-unknown-key",
@@ -3800,17 +3802,17 @@ function assertExactKeys3(object3, allowed, path) {
3800
3802
  }
3801
3803
  }
3802
3804
  }
3803
- function requiredValue3(object3, key, path) {
3804
- if (!hasOwn3(object3, key)) {
3805
+ function requiredValue3(object4, key, path) {
3806
+ if (!hasOwn3(object4, key)) {
3805
3807
  throw new PolicyAuthoringError(
3806
3808
  "policy-authoring-malformed",
3807
3809
  `${path}.${key} is required`
3808
3810
  );
3809
3811
  }
3810
- return object3[key];
3812
+ return object4[key];
3811
3813
  }
3812
- function requiredString3(object3, key, path) {
3813
- const value = requiredValue3(object3, key, path);
3814
+ function requiredString3(object4, key, path) {
3815
+ const value = requiredValue3(object4, key, path);
3814
3816
  if (typeof value !== "string" || value.length === 0) {
3815
3817
  throw new PolicyAuthoringError(
3816
3818
  "policy-authoring-malformed",
@@ -3819,11 +3821,11 @@ function requiredString3(object3, key, path) {
3819
3821
  }
3820
3822
  return value;
3821
3823
  }
3822
- function fieldString(object3, key, path, code3) {
3823
- if (!hasOwn3(object3, key)) {
3824
+ function fieldString(object4, key, path, code3) {
3825
+ if (!hasOwn3(object4, key)) {
3824
3826
  throw new PolicyAuthoringError(code3, `${path}.${key} is required`);
3825
3827
  }
3826
- const value = object3[key];
3828
+ const value = object4[key];
3827
3829
  if (typeof value !== "string" || value.length === 0) {
3828
3830
  throw new PolicyAuthoringError(
3829
3831
  code3,
@@ -3861,8 +3863,8 @@ function parseStrictRfc3339(value, path) {
3861
3863
  var objectHasOwn4 = Object.hasOwn ?? Object.prototype.hasOwnProperty.call.bind(
3862
3864
  Object.prototype.hasOwnProperty
3863
3865
  );
3864
- function hasOwn3(object3, key) {
3865
- return objectHasOwn4(object3, key);
3866
+ function hasOwn3(object4, key) {
3867
+ return objectHasOwn4(object4, key);
3866
3868
  }
3867
3869
 
3868
3870
  // src/policy/unified.ts
@@ -8381,13 +8383,13 @@ function canonicalizeRecapCaveats(caveats) {
8381
8383
  }
8382
8384
  if (Array.isArray(value)) return `[${value.map(canonicalize).join(",")}]`;
8383
8385
  if (typeof value === "object") {
8384
- const object3 = value;
8385
- const prototype = Object.getPrototypeOf(object3);
8386
+ const object4 = value;
8387
+ const prototype = Object.getPrototypeOf(object4);
8386
8388
  if (prototype !== Object.prototype && prototype !== null) {
8387
8389
  throw new Error("ReCap caveats must contain only JSON values.");
8388
8390
  }
8389
- return `{${Object.keys(object3).sort().map(
8390
- (key) => `${JSON.stringify(key)}:${canonicalize(object3[key])}`
8391
+ return `{${Object.keys(object4).sort().map(
8392
+ (key) => `${JSON.stringify(key)}:${canonicalize(object4[key])}`
8391
8393
  ).join(",")}}`;
8392
8394
  }
8393
8395
  throw new Error("ReCap caveats must contain only JSON values.");
@@ -8518,8 +8520,8 @@ function canonicalJson(value) {
8518
8520
  }
8519
8521
  if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
8520
8522
  if (typeof value === "object") {
8521
- const object3 = value;
8522
- return `{${Object.keys(object3).sort().map((key) => `${JSON.stringify(key)}:${canonicalJson(object3[key])}`).join(",")}}`;
8523
+ const object4 = value;
8524
+ return `{${Object.keys(object4).sort().map((key) => `${JSON.stringify(key)}:${canonicalJson(object4[key])}`).join(",")}}`;
8523
8525
  }
8524
8526
  throw new ShareEnvelopeError("invalid-envelope", "unsupported JSON value");
8525
8527
  }
@@ -9701,8 +9703,8 @@ function canonicalJsonForProof(value) {
9701
9703
  }
9702
9704
  if (Array.isArray(value)) return `[${value.map(canonicalJsonForProof).join(",")}]`;
9703
9705
  if (typeof value === "object") {
9704
- const object3 = value;
9705
- return `{${Object.keys(object3).sort().map((key) => `${JSON.stringify(key)}:${canonicalJsonForProof(object3[key])}`).join(",")}}`;
9706
+ const object4 = value;
9707
+ return `{${Object.keys(object4).sort().map((key) => `${JSON.stringify(key)}:${canonicalJsonForProof(object4[key])}`).join(",")}}`;
9706
9708
  }
9707
9709
  throw new ShareAccessError("SHARE_SESSION_INVALID");
9708
9710
  }
@@ -10411,12 +10413,12 @@ var ShareRecipientClient = class {
10411
10413
  this.assertDetachedProof(request.proof);
10412
10414
  }
10413
10415
  parseSessionCapability(value) {
10414
- const object3 = this.requireObject(value, "session capability");
10415
- if (typeof object3.spaceId !== "string") throw new ShareAccessError("SHARE_SESSION_INVALID", "session capability space is invalid");
10416
- if (!Array.isArray(object3.actions) || object3.actions.some((action) => !["read", "list", "edit"].includes(action))) throw new ShareAccessError("SHARE_SESSION_INVALID", "session capability actions are invalid");
10417
- const resource = this.requireObject(object3.resource, "session capability resource");
10416
+ const object4 = this.requireObject(value, "session capability");
10417
+ if (typeof object4.spaceId !== "string") throw new ShareAccessError("SHARE_SESSION_INVALID", "session capability space is invalid");
10418
+ if (!Array.isArray(object4.actions) || object4.actions.some((action) => !["read", "list", "edit"].includes(action))) throw new ShareAccessError("SHARE_SESSION_INVALID", "session capability actions are invalid");
10419
+ const resource = this.requireObject(object4.resource, "session capability resource");
10418
10420
  if (resource.kind !== "exact" && resource.kind !== "prefix" || typeof resource.path !== "string") throw new ShareAccessError("SHARE_SESSION_INVALID", "session capability resource is invalid");
10419
- return { spaceId: object3.spaceId, actions: [...new Set(object3.actions)], resource: { kind: resource.kind, path: resource.path } };
10421
+ return { spaceId: object4.spaceId, actions: [...new Set(object4.actions)], resource: { kind: resource.kind, path: resource.path } };
10420
10422
  }
10421
10423
  assertProvidedPolicySession(session, envelope) {
10422
10424
  const sessionExpiry = dateValue(session.expiresAt);
@@ -12157,6 +12159,97 @@ function shareDeliveryTrustedKid(publicKey) {
12157
12159
  return `${did}#${did.slice("did:key:".length)}`;
12158
12160
  }
12159
12161
 
12162
+ // src/delegations/share-delivery-v3.ts
12163
+ var import_ed2551910 = require("@noble/curves/ed25519");
12164
+ var SHARE_DELIVERY_AUTHORIZATION_V3_DOMAIN = "xyz.tinycloud.share/delivery-authorization/v3\0";
12165
+ var AUTHORIZATION_KEYS2 = [
12166
+ "type",
12167
+ "version",
12168
+ "jti",
12169
+ "shareCid",
12170
+ "shareId",
12171
+ "policyCid",
12172
+ "policyRootCid",
12173
+ "enforcementRootCid",
12174
+ "nodeAudience",
12175
+ "enforcerDid",
12176
+ "targetOrigin",
12177
+ "openCredentialsAudience",
12178
+ "holder",
12179
+ "recipientMatcher",
12180
+ "deliveryEmail",
12181
+ "shareUrl",
12182
+ "returnOrigin",
12183
+ "documentName",
12184
+ "senderDid",
12185
+ "senderTrust",
12186
+ "contentSource",
12187
+ "contentSourceDigestHex",
12188
+ "shareExpiresAt",
12189
+ "issuedAt",
12190
+ "reportAbuseToken",
12191
+ "actions",
12192
+ "resource",
12193
+ "requestBodyDigest",
12194
+ "idempotencyKey",
12195
+ "expiresAt",
12196
+ "dataAuthority"
12197
+ ];
12198
+ function exactObject(value, keys, label) {
12199
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`${label} is invalid`);
12200
+ const record2 = value;
12201
+ if (Object.keys(record2).length !== keys.length || keys.some((key) => !Object.prototype.hasOwnProperty.call(record2, key))) throw new Error(`${label} has unknown or missing fields`);
12202
+ return record2;
12203
+ }
12204
+ function decodeBase64Url3(value) {
12205
+ if (typeof value !== "string" || !/^[A-Za-z0-9_-]+$/.test(value)) throw new Error("share delivery value is not canonical base64url");
12206
+ if (typeof atob === "function") {
12207
+ const padded = value.replace(/-/g, "+").replace(/_/g, "/") + "=".repeat((4 - value.length % 4) % 4);
12208
+ return Uint8Array.from(atob(padded), (character) => character.charCodeAt(0));
12209
+ }
12210
+ if (typeof Buffer !== "undefined") return new Uint8Array(Buffer.from(value, "base64url"));
12211
+ throw new Error("base64url decoding is unavailable");
12212
+ }
12213
+ function object3(value, label) {
12214
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`${label} is invalid`);
12215
+ return value;
12216
+ }
12217
+ function validateShareDeliveryAuthorizationV3Bytes(bytes2, expected) {
12218
+ let parsed;
12219
+ try {
12220
+ parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes2));
12221
+ } catch {
12222
+ throw new Error("v3 share delivery response is not valid UTF-8 JSON");
12223
+ }
12224
+ const root = exactObject(parsed, ["authorization", "proof"], "v3 share delivery response");
12225
+ const authorization = exactObject(root.authorization, AUTHORIZATION_KEYS2, "v3 share delivery authorization");
12226
+ const proof = exactObject(root.proof, ["alg", "kid", "signature"], "v3 share delivery proof");
12227
+ const envelope = object3(expected.request.envelope, "v3 share envelope");
12228
+ const policyRoot = object3(envelope.policyRoot, "v3 policy root");
12229
+ const enforcementRoot = object3(envelope.enforcementRoot, "v3 enforcement root");
12230
+ const target = object3(envelope.target, "v3 target");
12231
+ const display = object3(envelope.display, "v3 display");
12232
+ const resource = object3(envelope.resource, "v3 resource");
12233
+ const envelopeSignature = object3(envelope.signature, "v3 envelope signature");
12234
+ const shareUrl = new URL(expected.request.shareUrl);
12235
+ const targetOrigin = String(target.origin);
12236
+ const targetUrl = new URL(targetOrigin);
12237
+ const targetHost = targetUrl.hostname;
12238
+ const expectedNodeAudience = `did:web:${targetHost}`;
12239
+ if (authorization.type !== "TinyCloudShareDeliveryAuthorization" || authorization.version !== 3 || authorization.dataAuthority !== false || authorization.jti !== expected.request.jti || authorization.shareCid !== expected.request.shareCid || authorization.shareId !== envelope.shareId || authorization.policyCid !== envelope.policyCid || authorization.policyRootCid !== policyRoot.cid || authorization.enforcementRootCid !== enforcementRoot.cid || authorization.enforcerDid !== target.nodeAudience || authorization.targetOrigin !== target.origin || authorization.nodeAudience !== expectedNodeAudience || expected.nodeProof.kid.split("#", 1)[0] !== expectedNodeAudience || authorization.recipientMatcher === void 0 || canonicalizeSignedObjectUnsigned(authorization.recipientMatcher) !== canonicalizeSignedObjectUnsigned(envelope.recipientMatcher) || canonicalizeSignedObjectUnsigned(authorization.contentSource) !== canonicalizeSignedObjectUnsigned(envelope.contentSource) || authorization.contentSourceDigestHex !== envelope.contentSourceDigestHex || authorization.deliveryEmail !== expected.request.recipientEmail || authorization.shareUrl !== expected.request.shareUrl || authorization.documentName !== expected.request.documentName || authorization.documentName !== display.filename || authorization.senderDid !== envelopeSignature.signerDid || authorization.senderTrust !== "verified" || canonicalizeSignedObjectUnsigned(authorization.actions) !== canonicalizeSignedObjectUnsigned(envelope.actions) || authorization.resource !== resource.path || authorization.shareExpiresAt !== envelope.expiry || authorization.requestBodyDigest !== expected.request.requestBodyDigest || authorization.expiresAt !== expected.request.expiresAt || authorization.idempotencyKey !== expected.request.jti || authorization.reportAbuseToken !== expected.request.jti || authorization.returnOrigin !== shareUrl.origin || shareUrl.pathname !== `/s/${authorization.shareCid}` || shareUrl.hash !== `#k=${expected.request.envelopeKey}` || targetUrl.protocol !== "https:" || shareUrl.protocol !== "https:") throw new Error("v3 share delivery authorization is not bound to the submitted request");
12240
+ if (typeof authorization.openCredentialsAudience !== "string" || authorization.openCredentialsAudience !== expected.credentialsAudience || authorization.openCredentialsAudience === authorization.nodeAudience || authorization.openCredentialsAudience === authorization.returnOrigin) throw new Error("v3 share delivery credentials audience is untrusted");
12241
+ if (proof.alg !== "EdDSA" || proof.kid !== expected.nodeProof.kid || typeof proof.signature !== "string") throw new Error("v3 share delivery proof is invalid");
12242
+ const issuedAt = Date.parse(String(authorization.issuedAt));
12243
+ const expiresAt = Date.parse(String(authorization.expiresAt));
12244
+ const shareExpiresAt = Date.parse(String(authorization.shareExpiresAt));
12245
+ if (!Number.isFinite(issuedAt) || !Number.isFinite(expiresAt) || !Number.isFinite(shareExpiresAt) || expiresAt <= issuedAt || expiresAt - issuedAt > 5 * 6e4 || shareExpiresAt <= issuedAt || typeof authorization.holder !== "string" || !authorization.holder.startsWith("did:")) throw new Error("v3 share delivery authorization time or holder is invalid");
12246
+ const publicKey = expected.nodeProof.publicKey.length === 34 ? expected.nodeProof.publicKey.slice(2) : expected.nodeProof.publicKey;
12247
+ const signature = decodeBase64Url3(proof.signature);
12248
+ const signed = new TextEncoder().encode(`${SHARE_DELIVERY_AUTHORIZATION_V3_DOMAIN}${canonicalizeSignedObjectUnsigned(authorization)}`);
12249
+ if (publicKey.length !== 32 || signature.length !== 64 || !import_ed2551910.ed25519.verify(signature, signed, publicKey)) throw new Error("v3 share delivery proof signature is invalid");
12250
+ return { authorization, proof };
12251
+ }
12252
+
12160
12253
  // src/delegations/sender-share-store.ts
12161
12254
  var MemorySenderShareRecordStorage = class {
12162
12255
  constructor() {
@@ -14877,8 +14970,8 @@ function stableJson(value) {
14877
14970
  if (Array.isArray(value)) {
14878
14971
  return `[${value.map(stableJson).join(",")}]`;
14879
14972
  }
14880
- const object3 = value;
14881
- return `{${Object.keys(object3).sort().map((key) => `${JSON.stringify(key)}:${stableJson(object3[key])}`).join(",")}}`;
14973
+ const object4 = value;
14974
+ return `{${Object.keys(object4).sort().map((key) => `${JSON.stringify(key)}:${stableJson(object4[key])}`).join(",")}}`;
14882
14975
  }
14883
14976
  function indexedDelegationFromRow(row) {
14884
14977
  const [
@@ -17778,7 +17871,7 @@ function portForProtocol(protocol) {
17778
17871
  }
17779
17872
 
17780
17873
  // src/location.ts
17781
- var import_ed2551910 = require("@noble/curves/ed25519");
17874
+ var import_ed2551911 = require("@noble/curves/ed25519");
17782
17875
  var import_viem5 = require("viem");
17783
17876
  var DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL = "https://registry.tinycloud.xyz";
17784
17877
  var DEFAULT_TINYCLOUD_FALLBACK_HOST = "https://node.tinycloud.xyz";
@@ -18344,13 +18437,13 @@ async function verifyPkhSignature(did, payload, signature) {
18344
18437
  }
18345
18438
  function verifyDidKeySignature(did, payload, signature) {
18346
18439
  const publicKey = ed25519PublicKeyFromDidKey2(did);
18347
- const signatureBytes = decodeBase64Url3(signature);
18440
+ const signatureBytes = decodeBase64Url4(signature);
18348
18441
  if (signatureBytes.length !== 64) {
18349
18442
  throw new LocationRecordValidationError(
18350
18443
  "did:key signature must be a base64url Ed25519 signature"
18351
18444
  );
18352
18445
  }
18353
- return import_ed2551910.ed25519.verify(
18446
+ return import_ed2551911.ed25519.verify(
18354
18447
  signatureBytes,
18355
18448
  new TextEncoder().encode(payload),
18356
18449
  publicKey
@@ -18358,7 +18451,7 @@ function verifyDidKeySignature(did, payload, signature) {
18358
18451
  }
18359
18452
  function verifyDidKeyEd25519Signature(did, payload, signature) {
18360
18453
  const publicKey = ed25519PublicKeyFromDidKey2(did);
18361
- return import_ed2551910.ed25519.verify(signature, payload, publicKey);
18454
+ return import_ed2551911.ed25519.verify(signature, payload, publicKey);
18362
18455
  }
18363
18456
  function ed25519PublicKeyFromDidKey2(did) {
18364
18457
  const identifier = did.slice("did:key:".length);
@@ -18397,7 +18490,7 @@ function base64UrlEncode3(bytes2) {
18397
18490
  }
18398
18491
  return output;
18399
18492
  }
18400
- function decodeBase64Url3(value) {
18493
+ function decodeBase64Url4(value) {
18401
18494
  const alphabet2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
18402
18495
  const bytes2 = [];
18403
18496
  let buffer = 0;