@tinycloud/node-sdk 3.2.0-beta.1 → 3.2.0-beta.2

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
@@ -17062,6 +17062,7 @@ __export(index_exports, {
17062
17062
  IdentityParseError: () => import_sdk_core11.IdentityParseError,
17063
17063
  InvalidRestoredSessionError: () => InvalidRestoredSessionError,
17064
17064
  KVService: () => import_sdk_core13.KVService,
17065
+ MAX_SECRET_SCOPE_LENGTH: () => import_sdk_core16.MAX_SECRET_SCOPE_LENGTH,
17065
17066
  ManifestValidationError: () => import_sdk_core12.ManifestValidationError,
17066
17067
  MemorySessionStorage: () => MemorySessionStorage,
17067
17068
  NETWORK_NAME_PATTERN: () => import_sdk_core17.NETWORK_NAME_PATTERN,
@@ -17075,6 +17076,7 @@ __export(index_exports, {
17075
17076
  RUNTIME_DELEGATION_REJECTIONS: () => RUNTIME_DELEGATION_REJECTIONS,
17076
17077
  RuntimeDelegationRejectedError: () => RuntimeDelegationRejectedError,
17077
17078
  SECRET_NAME_RE: () => import_sdk_core16.SECRET_NAME_RE,
17079
+ SECRET_SCOPE_RE: () => import_sdk_core16.SECRET_SCOPE_RE,
17078
17080
  SQLAction: () => import_sdk_core14.SQLAction,
17079
17081
  SQLService: () => import_sdk_core14.SQLService,
17080
17082
  STORAGE_FULL_MESSAGE: () => import_sdk_core11.STORAGE_FULL_MESSAGE,
@@ -17087,6 +17089,7 @@ __export(index_exports, {
17087
17089
  Space: () => import_sdk_core21.Space,
17088
17090
  SpaceErrorCodes: () => import_sdk_core21.SpaceErrorCodes,
17089
17091
  SpaceService: () => import_sdk_core21.SpaceService,
17092
+ TC832_RESERVED_SCOPES: () => import_sdk_core16.TC832_RESERVED_SCOPES,
17090
17093
  TinyCloud: () => import_sdk_core10.TinyCloud,
17091
17094
  TinyCloudDebugLogger: () => import_sdk_core11.TinyCloudDebugLogger,
17092
17095
  TinyCloudNode: () => TinyCloudNode,
@@ -17100,6 +17103,7 @@ __export(index_exports, {
17100
17103
  activateCompactRuntimeDelegation: () => activateCompactRuntimeDelegation,
17101
17104
  activateValidatedRuntimeDelegation: () => activateValidatedRuntimeDelegation,
17102
17105
  addressStorageKey: () => import_sdk_core11.addressStorageKey,
17106
+ appSecretScope: () => import_sdk_core16.appSecretScope,
17103
17107
  buildCanonicalDecryptRequest: () => import_sdk_core17.buildCanonicalDecryptRequest,
17104
17108
  buildDecryptAttenuation: () => import_sdk_core17.buildDecryptAttenuation,
17105
17109
  buildDecryptFacts: () => import_sdk_core17.buildDecryptFacts,
@@ -17303,7 +17307,9 @@ var RUNTIME_DELEGATION_REJECTIONS = [
17303
17307
  "audience_mismatch",
17304
17308
  "resources_mismatch",
17305
17309
  "unsupported",
17306
- "activation_rejected"
17310
+ "activation_rejected",
17311
+ "activation_unavailable",
17312
+ "activation_unauthenticated"
17307
17313
  ];
17308
17314
  var RuntimeDelegationRejectedError = class extends Error {
17309
17315
  constructor(reason, message) {
@@ -17312,6 +17318,18 @@ var RuntimeDelegationRejectedError = class extends Error {
17312
17318
  this.reason = reason;
17313
17319
  }
17314
17320
  };
17321
+ function activationRejectionReason(error) {
17322
+ if (typeof error !== "object" || error === null) return "activation_rejected";
17323
+ if ("code" in error && error.code === "ACTIVATION_TRANSPORT_FAILED") {
17324
+ return "activation_unavailable";
17325
+ }
17326
+ const cause = "cause" in error ? error.cause : void 0;
17327
+ const status = typeof cause === "object" && cause !== null && "status" in cause ? cause.status : void 0;
17328
+ if (typeof status !== "number") return "activation_rejected";
17329
+ if (status === 408 || status === 429 || status >= 500) return "activation_unavailable";
17330
+ if (status === 401) return "activation_unauthenticated";
17331
+ return "activation_rejected";
17332
+ }
17315
17333
  function reject(reason, message) {
17316
17334
  throw new RuntimeDelegationRejectedError(reason, message);
17317
17335
  }
@@ -17696,7 +17714,10 @@ async function activateValidatedRuntimeDelegation(node, delegation, options) {
17696
17714
  await node.useRuntimeDelegation(installedCandidate);
17697
17715
  }
17698
17716
  } catch (error) {
17699
- reject("activation_rejected", error instanceof Error ? error.message : String(error));
17717
+ reject(
17718
+ activationRejectionReason(error),
17719
+ error instanceof Error ? error.message : String(error)
17720
+ );
17700
17721
  }
17701
17722
  const installed = node.getRuntimePermissionDelegations().find((candidate) => candidate.cid === cid);
17702
17723
  if (!installed) {
@@ -23495,10 +23516,18 @@ var _TinyCloudNode = class _TinyCloudNode {
23495
23516
  );
23496
23517
  }
23497
23518
  const targetHost = delegation.host ?? this.config.host;
23498
- const activateResult = await (0, import_sdk_core8.activateSessionWithHost)(
23499
- targetHost,
23500
- delegation.delegationHeader
23501
- );
23519
+ let activateResult;
23520
+ try {
23521
+ activateResult = await (0, import_sdk_core8.activateSessionWithHost)(
23522
+ targetHost,
23523
+ delegation.delegationHeader
23524
+ );
23525
+ } catch (cause) {
23526
+ throw Object.assign(
23527
+ new Error("The TinyCloud host could not be reached to activate the delegation."),
23528
+ { code: "ACTIVATION_TRANSPORT_FAILED", cause }
23529
+ );
23530
+ }
23502
23531
  if (!activateResult.success) {
23503
23532
  if (this.operationsFromDelegation(delegation).some(
23504
23533
  (operation) => operation.resource?.startsWith("urn:cid:") === true && operation.service === "delegation" && operation.action === "tinycloud.delegation/revoke"
@@ -25394,6 +25423,7 @@ var import_sdk_core23 = require("@tinycloud/sdk-core");
25394
25423
  IdentityParseError,
25395
25424
  InvalidRestoredSessionError,
25396
25425
  KVService,
25426
+ MAX_SECRET_SCOPE_LENGTH,
25397
25427
  ManifestValidationError,
25398
25428
  MemorySessionStorage,
25399
25429
  NETWORK_NAME_PATTERN,
@@ -25407,6 +25437,7 @@ var import_sdk_core23 = require("@tinycloud/sdk-core");
25407
25437
  RUNTIME_DELEGATION_REJECTIONS,
25408
25438
  RuntimeDelegationRejectedError,
25409
25439
  SECRET_NAME_RE,
25440
+ SECRET_SCOPE_RE,
25410
25441
  SQLAction,
25411
25442
  SQLService,
25412
25443
  STORAGE_FULL_MESSAGE,
@@ -25419,6 +25450,7 @@ var import_sdk_core23 = require("@tinycloud/sdk-core");
25419
25450
  Space,
25420
25451
  SpaceErrorCodes,
25421
25452
  SpaceService,
25453
+ TC832_RESERVED_SCOPES,
25422
25454
  TinyCloud,
25423
25455
  TinyCloudDebugLogger,
25424
25456
  TinyCloudNode,
@@ -25432,6 +25464,7 @@ var import_sdk_core23 = require("@tinycloud/sdk-core");
25432
25464
  activateCompactRuntimeDelegation,
25433
25465
  activateValidatedRuntimeDelegation,
25434
25466
  addressStorageKey,
25467
+ appSecretScope,
25435
25468
  buildCanonicalDecryptRequest,
25436
25469
  buildDecryptAttenuation,
25437
25470
  buildDecryptFacts,