@tinycloud/sdk-services 2.11.0-beta.8 → 3.0.0-beta.8

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
@@ -115,6 +115,7 @@ __export(src_exports, {
115
115
  parseNetworkId: () => parseNetworkId,
116
116
  parsePermissionHint: () => parsePermissionHint,
117
117
  parsePermissionHintFromErrorText: () => parsePermissionHintFromErrorText,
118
+ parseSecretCatalogKey: () => parseSecretCatalogKey,
118
119
  permissionDeniedError: () => permissionDeniedError,
119
120
  resolveSecretListPrefix: () => resolveSecretListPrefix,
120
121
  resolveSecretPath: () => resolveSecretPath,
@@ -5752,7 +5753,9 @@ function canonicalizeSecretScope(scope) {
5752
5753
  }
5753
5754
  const trimmed = scope.trim();
5754
5755
  if (trimmed === "") {
5755
- throw new Error("Secret scope must be non-empty; omit scope for global secrets.");
5756
+ throw new Error(
5757
+ "Secret scope must be non-empty; omit scope for global secrets."
5758
+ );
5756
5759
  }
5757
5760
  const canonical = trimmed.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
5758
5761
  if (canonical === "") {
@@ -5787,6 +5790,28 @@ function resolveSecretListPrefix(options = {}) {
5787
5790
  const scope = canonicalizeSecretScope(options.scope);
5788
5791
  return scope === void 0 ? "vault/secrets/" : `vault/secrets/scoped/${scope}/`;
5789
5792
  }
5793
+ function parseSecretCatalogKey(key) {
5794
+ if (SECRET_NAME_RE.test(key)) {
5795
+ return { name: key };
5796
+ }
5797
+ const parts = key.split("/");
5798
+ if (parts.length !== 3 || parts[0] !== "scoped") {
5799
+ return void 0;
5800
+ }
5801
+ const [, rawScope, name] = parts;
5802
+ if (!name || !SECRET_NAME_RE.test(name)) {
5803
+ return void 0;
5804
+ }
5805
+ try {
5806
+ const scope = canonicalizeSecretScope(rawScope);
5807
+ if (scope === void 0 || scope !== rawScope) {
5808
+ return void 0;
5809
+ }
5810
+ return { name, scope };
5811
+ } catch {
5812
+ return void 0;
5813
+ }
5814
+ }
5790
5815
 
5791
5816
  // src/secrets/SecretsService.ts
5792
5817
  function invalidSecretInput(message) {
@@ -5800,7 +5825,9 @@ function resolveSecretPathResult(name, options) {
5800
5825
  try {
5801
5826
  return resolveSecretPath(name, options);
5802
5827
  } catch (error) {
5803
- return invalidSecretInput(error instanceof Error ? error.message : String(error));
5828
+ return invalidSecretInput(
5829
+ error instanceof Error ? error.message : String(error)
5830
+ );
5804
5831
  }
5805
5832
  }
5806
5833
  var SecretsService = class {
@@ -5849,7 +5876,9 @@ var SecretsService = class {
5849
5876
  const scope = canonicalizeSecretScope(options?.scope);
5850
5877
  prefix = scope === void 0 ? "secrets/" : `secrets/scoped/${scope}/`;
5851
5878
  } catch (error) {
5852
- return invalidSecretInput(error instanceof Error ? error.message : String(error));
5879
+ return invalidSecretInput(
5880
+ error instanceof Error ? error.message : String(error)
5881
+ );
5853
5882
  }
5854
5883
  const result = await this.vault.list({
5855
5884
  prefix,
@@ -5863,6 +5892,38 @@ var SecretsService = class {
5863
5892
  data: result.data.filter((name) => SECRET_NAME_RE.test(name))
5864
5893
  };
5865
5894
  }
5895
+ async listAll() {
5896
+ const entries = /* @__PURE__ */ new Map();
5897
+ let cursor;
5898
+ do {
5899
+ const result = await this.vault.listPage({
5900
+ prefix: "secrets/",
5901
+ removePrefix: true,
5902
+ limit: 1e3,
5903
+ ...cursor === void 0 ? {} : { cursor }
5904
+ });
5905
+ if (!result.ok) {
5906
+ return result;
5907
+ }
5908
+ for (const key of result.data.keys) {
5909
+ const entry = parseSecretCatalogKey(key);
5910
+ if (!entry) continue;
5911
+ entries.set(`${entry.scope ?? ""}\0${entry.name}`, entry);
5912
+ }
5913
+ cursor = result.data.truncated ? result.data.nextCursor : void 0;
5914
+ if (result.data.truncated && cursor === void 0) {
5915
+ return invalidSecretInput(
5916
+ "Secret catalog listing was truncated without a continuation cursor."
5917
+ );
5918
+ }
5919
+ } while (cursor !== void 0);
5920
+ return {
5921
+ ok: true,
5922
+ data: [...entries.values()].sort(
5923
+ (a, b) => (a.scope ?? "").localeCompare(b.scope ?? "") || a.name.localeCompare(b.name)
5924
+ )
5925
+ };
5926
+ }
5866
5927
  };
5867
5928
 
5868
5929
  // src/encryption/canonical.ts
@@ -6752,7 +6813,10 @@ var EncryptionService = class extends BaseService {
6752
6813
  const descriptor = usable.data;
6753
6814
  const networkPublicKey = base64Decode2(descriptor.publicEncryptionKey);
6754
6815
  const result = encryptToNetwork(this.crypto, {
6755
- networkId,
6816
+ // Discovery returns the node's canonical network identifier. Persist
6817
+ // that spelling in the envelope so a later response can be compared
6818
+ // byte-for-byte (notably for checksummed did:pkh principals).
6819
+ networkId: descriptor.networkId,
6756
6820
  networkPublicKey,
6757
6821
  plaintext,
6758
6822
  ...options?.aad !== void 0 ? { aad: options.aad } : {},
@@ -7011,6 +7075,7 @@ var import_decrypt_transport_response_error3 = require("@tinycloud/sdk-services/
7011
7075
  parseNetworkId,
7012
7076
  parsePermissionHint,
7013
7077
  parsePermissionHintFromErrorText,
7078
+ parseSecretCatalogKey,
7014
7079
  permissionDeniedError,
7015
7080
  resolveSecretListPrefix,
7016
7081
  resolveSecretPath,