@tinycloud/sdk-core 3.0.0-beta.12 → 3.0.0-beta.14

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
@@ -6546,6 +6546,7 @@ var DelegationErrorSchema = import_zod4.z.object({
6546
6546
  });
6547
6547
  var DelegationErrorCodes = {
6548
6548
  AUTH_REQUIRED: "AUTH_REQUIRED",
6549
+ AUTH_UNAUTHORIZED: "AUTH_UNAUTHORIZED",
6549
6550
  AUTH_EXPIRED: "AUTH_EXPIRED",
6550
6551
  NOT_INITIALIZED: "NOT_INITIALIZED",
6551
6552
  NOT_FOUND: "NOT_FOUND",
@@ -6910,7 +6911,7 @@ var CreateDelegationWasmResultSchema = import_zod4.z.object({
6910
6911
  // src/expiry.ts
6911
6912
  var EPHEMERAL_MS = 60 * 60 * 1e3;
6912
6913
  var SIGNED_READ_URL_MS = 5 * 60 * 1e3;
6913
- var SESSION_MS = 7 * 24 * 60 * 60 * 1e3;
6914
+ var SESSION_MS = 30 * 24 * 60 * 60 * 1e3;
6914
6915
  var SHARE_MS = 7 * 24 * 60 * 60 * 1e3;
6915
6916
  var APP_MS = 30 * 24 * 60 * 60 * 1e3;
6916
6917
  var MAX_MS = 10 * 365 * 24 * 60 * 60 * 1e3;
@@ -10928,6 +10929,13 @@ var ShareRecipientClient = class {
10928
10929
  };
10929
10930
 
10930
10931
  // src/delegations/SharingService.ts
10932
+ function spaceIdsEqual(left, right) {
10933
+ const normalizeOwnerAddress = (space) => {
10934
+ const match = /^(tinycloud:pkh:eip155:\d+:)(0x[0-9a-fA-F]{40})(:.+)$/.exec(space);
10935
+ return match === null ? space : `${match[1]}${match[2].toLowerCase()}${match[3]}`;
10936
+ };
10937
+ return normalizeOwnerAddress(left) === normalizeOwnerAddress(right);
10938
+ }
10931
10939
  function inferShortServiceFromActionUrns(actions) {
10932
10940
  let short;
10933
10941
  for (const action of actions) {
@@ -11250,7 +11258,7 @@ var SharingService = class {
11250
11258
  for (const key of allKeys) {
11251
11259
  const delegations = this.registry.getDelegationsForKey(key.id);
11252
11260
  for (const delegation of delegations) {
11253
- if (delegation.spaceId !== this.session?.spaceId) {
11261
+ if (delegation.spaceId === void 0 || !spaceIdsEqual(delegation.spaceId, this.session?.spaceId ?? "")) {
11254
11262
  continue;
11255
11263
  }
11256
11264
  if ((delegation.caveats?.length ?? 0) > 0) {
@@ -11378,11 +11386,23 @@ var SharingService = class {
11378
11386
  const errorText = await registerRes.text();
11379
11387
  const registrationTextActiveError = this.retiredGraphError();
11380
11388
  if (registrationTextActiveError) return { ok: false, error: registrationTextActiveError };
11389
+ const message = `Failed to register delegation with server: ${registerRes.status} ${errorText}`;
11390
+ if (registerRes.status === 401 || registerRes.status === 403) {
11391
+ return {
11392
+ ok: false,
11393
+ error: createError2(
11394
+ DelegationErrorCodes.AUTH_UNAUTHORIZED,
11395
+ message,
11396
+ void 0,
11397
+ { status: registerRes.status }
11398
+ )
11399
+ };
11400
+ }
11381
11401
  return {
11382
11402
  ok: false,
11383
11403
  error: createError2(
11384
11404
  DelegationErrorCodes.CREATION_FAILED,
11385
- `Failed to register delegation with server: ${registerRes.status} ${errorText}`
11405
+ message
11386
11406
  )
11387
11407
  };
11388
11408
  }