@tinycloud/sdk-core 2.2.0-beta.0 → 2.2.0-beta.1

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.d.cts CHANGED
@@ -226,6 +226,8 @@ interface PermissionEntry {
226
226
  skipPrefix?: boolean;
227
227
  /** Per-entry expiry override, ms-format. */
228
228
  expiry?: string;
229
+ /** User/agent-facing context for why this permission is requested. */
230
+ description?: string;
229
231
  }
230
232
  /**
231
233
  * The valid values for `Manifest.defaults`.
@@ -296,6 +298,8 @@ interface ResourceCapability {
296
298
  actions: string[];
297
299
  /** Per-entry expiry override in milliseconds. */
298
300
  expiryMs?: number;
301
+ /** User/agent-facing context copied from the source permission entry. */
302
+ description?: string;
299
303
  }
300
304
  /**
301
305
  * A resolved delegation entry with fully-expanded permissions.
@@ -2131,8 +2135,8 @@ declare const ShareLinkSchema: z.ZodObject<{
2131
2135
  };
2132
2136
  token: string;
2133
2137
  schema: "base64" | "compact" | "ipfs";
2134
- expiresAt?: Date | undefined;
2135
2138
  description?: string | undefined;
2139
+ expiresAt?: Date | undefined;
2136
2140
  }, {
2137
2141
  url: string;
2138
2142
  delegation: {
@@ -2151,8 +2155,8 @@ declare const ShareLinkSchema: z.ZodObject<{
2151
2155
  };
2152
2156
  token: string;
2153
2157
  schema: "base64" | "compact" | "ipfs";
2154
- expiresAt?: Date | undefined;
2155
2158
  description?: string | undefined;
2159
+ expiresAt?: Date | undefined;
2156
2160
  }>;
2157
2161
  type ShareLink = z.infer<typeof ShareLinkSchema>;
2158
2162
  type ShareLinkData<T = unknown> = {
@@ -2209,15 +2213,15 @@ declare const GenerateShareParamsSchema: z.ZodObject<{
2209
2213
  path: string;
2210
2214
  actions?: string[] | undefined;
2211
2215
  expiry?: Date | undefined;
2212
- schema?: "base64" | "compact" | "ipfs" | undefined;
2213
2216
  description?: string | undefined;
2217
+ schema?: "base64" | "compact" | "ipfs" | undefined;
2214
2218
  baseUrl?: string | undefined;
2215
2219
  }, {
2216
2220
  path: string;
2217
2221
  actions?: string[] | undefined;
2218
2222
  expiry?: Date | undefined;
2219
- schema?: "base64" | "compact" | "ipfs" | undefined;
2220
2223
  description?: string | undefined;
2224
+ schema?: "base64" | "compact" | "ipfs" | undefined;
2221
2225
  baseUrl?: string | undefined;
2222
2226
  }>;
2223
2227
  type GenerateShareParams = z.infer<typeof GenerateShareParamsSchema>;
package/dist/index.d.ts CHANGED
@@ -226,6 +226,8 @@ interface PermissionEntry {
226
226
  skipPrefix?: boolean;
227
227
  /** Per-entry expiry override, ms-format. */
228
228
  expiry?: string;
229
+ /** User/agent-facing context for why this permission is requested. */
230
+ description?: string;
229
231
  }
230
232
  /**
231
233
  * The valid values for `Manifest.defaults`.
@@ -296,6 +298,8 @@ interface ResourceCapability {
296
298
  actions: string[];
297
299
  /** Per-entry expiry override in milliseconds. */
298
300
  expiryMs?: number;
301
+ /** User/agent-facing context copied from the source permission entry. */
302
+ description?: string;
299
303
  }
300
304
  /**
301
305
  * A resolved delegation entry with fully-expanded permissions.
@@ -2131,8 +2135,8 @@ declare const ShareLinkSchema: z.ZodObject<{
2131
2135
  };
2132
2136
  token: string;
2133
2137
  schema: "base64" | "compact" | "ipfs";
2134
- expiresAt?: Date | undefined;
2135
2138
  description?: string | undefined;
2139
+ expiresAt?: Date | undefined;
2136
2140
  }, {
2137
2141
  url: string;
2138
2142
  delegation: {
@@ -2151,8 +2155,8 @@ declare const ShareLinkSchema: z.ZodObject<{
2151
2155
  };
2152
2156
  token: string;
2153
2157
  schema: "base64" | "compact" | "ipfs";
2154
- expiresAt?: Date | undefined;
2155
2158
  description?: string | undefined;
2159
+ expiresAt?: Date | undefined;
2156
2160
  }>;
2157
2161
  type ShareLink = z.infer<typeof ShareLinkSchema>;
2158
2162
  type ShareLinkData<T = unknown> = {
@@ -2209,15 +2213,15 @@ declare const GenerateShareParamsSchema: z.ZodObject<{
2209
2213
  path: string;
2210
2214
  actions?: string[] | undefined;
2211
2215
  expiry?: Date | undefined;
2212
- schema?: "base64" | "compact" | "ipfs" | undefined;
2213
2216
  description?: string | undefined;
2217
+ schema?: "base64" | "compact" | "ipfs" | undefined;
2214
2218
  baseUrl?: string | undefined;
2215
2219
  }, {
2216
2220
  path: string;
2217
2221
  actions?: string[] | undefined;
2218
2222
  expiry?: Date | undefined;
2219
- schema?: "base64" | "compact" | "ipfs" | undefined;
2220
2223
  description?: string | undefined;
2224
+ schema?: "base64" | "compact" | "ipfs" | undefined;
2221
2225
  baseUrl?: string | undefined;
2222
2226
  }>;
2223
2227
  type GenerateShareParams = z.infer<typeof GenerateShareParamsSchema>;
package/dist/index.js CHANGED
@@ -2754,9 +2754,7 @@ function parseExpiry(duration) {
2754
2754
  `expiry must be a non-empty duration string (got ${JSON.stringify(duration)})`
2755
2755
  );
2756
2756
  }
2757
- const parsed = ms(
2758
- duration
2759
- );
2757
+ const parsed = ms(duration);
2760
2758
  if (typeof parsed !== "number" || !Number.isFinite(parsed) || parsed <= 0) {
2761
2759
  throw new ManifestValidationError(
2762
2760
  `invalid expiry duration: ${JSON.stringify(duration)}`
@@ -2811,23 +2809,33 @@ function validateManifest(input) {
2811
2809
  );
2812
2810
  }
2813
2811
  if (typeof m.app_id !== "string" || m.app_id.length === 0) {
2814
- throw new ManifestValidationError("manifest.app_id is required and must be a non-empty string");
2812
+ throw new ManifestValidationError(
2813
+ "manifest.app_id is required and must be a non-empty string"
2814
+ );
2815
2815
  }
2816
2816
  if (typeof m.name !== "string" || m.name.length === 0) {
2817
- throw new ManifestValidationError("manifest.name is required and must be a non-empty string");
2817
+ throw new ManifestValidationError(
2818
+ "manifest.name is required and must be a non-empty string"
2819
+ );
2818
2820
  }
2819
2821
  if (m.did !== void 0 && (typeof m.did !== "string" || m.did.length === 0)) {
2820
- throw new ManifestValidationError("manifest.did must be a non-empty DID string");
2822
+ throw new ManifestValidationError(
2823
+ "manifest.did must be a non-empty DID string"
2824
+ );
2821
2825
  }
2822
2826
  if (m.space !== void 0 && (typeof m.space !== "string" || m.space.length === 0)) {
2823
- throw new ManifestValidationError("manifest.space must be a non-empty string");
2827
+ throw new ManifestValidationError(
2828
+ "manifest.space must be a non-empty string"
2829
+ );
2824
2830
  }
2825
2831
  if (m.expiry !== void 0) {
2826
2832
  parseExpiry(m.expiry);
2827
2833
  }
2828
2834
  if (m.permissions !== void 0) {
2829
2835
  if (!Array.isArray(m.permissions)) {
2830
- throw new ManifestValidationError("manifest.permissions must be an array");
2836
+ throw new ManifestValidationError(
2837
+ "manifest.permissions must be an array"
2838
+ );
2831
2839
  }
2832
2840
  m.permissions.forEach(
2833
2841
  (p, i) => validatePermissionEntry(p, `permissions[${i}]`)
@@ -2844,7 +2852,9 @@ function validatePermissionEntry(p, path) {
2844
2852
  throw new ManifestValidationError(`${path}.service is required`);
2845
2853
  }
2846
2854
  if (entry.space !== void 0 && (typeof entry.space !== "string" || entry.space.length === 0)) {
2847
- throw new ManifestValidationError(`${path}.space must be a non-empty string`);
2855
+ throw new ManifestValidationError(
2856
+ `${path}.space must be a non-empty string`
2857
+ );
2848
2858
  }
2849
2859
  if (typeof entry.path !== "string") {
2850
2860
  throw new ManifestValidationError(
@@ -2935,7 +2945,8 @@ function resolveEntry(entry, prefix, _inheritedExpiryMs, inheritedSpace) {
2935
2945
  // Only populate `expiryMs` when the entry had its own expiry override.
2936
2946
  // When absent, callers use the parent (delegation or manifest) expiry
2937
2947
  // which is carried on ResolvedDelegate.expiryMs / ResolvedCapabilities.expiryMs.
2938
- ...entryExpiryMs !== void 0 ? { expiryMs: entryExpiryMs } : {}
2948
+ ...entryExpiryMs !== void 0 ? { expiryMs: entryExpiryMs } : {},
2949
+ ...entry.description !== void 0 ? { description: entry.description } : {}
2939
2950
  };
2940
2951
  }
2941
2952
  function cloneResourceCapability(entry) {
@@ -2944,7 +2955,8 @@ function cloneResourceCapability(entry) {
2944
2955
  space: entry.space,
2945
2956
  path: entry.path,
2946
2957
  actions: [...entry.actions],
2947
- ...entry.expiryMs !== void 0 ? { expiryMs: entry.expiryMs } : {}
2958
+ ...entry.expiryMs !== void 0 ? { expiryMs: entry.expiryMs } : {},
2959
+ ...entry.description !== void 0 ? { description: entry.description } : {}
2948
2960
  };
2949
2961
  }
2950
2962
  function clonePermissionEntry(entry) {
@@ -2954,7 +2966,8 @@ function clonePermissionEntry(entry) {
2954
2966
  path: entry.path,
2955
2967
  actions: [...entry.actions],
2956
2968
  ...entry.skipPrefix !== void 0 ? { skipPrefix: entry.skipPrefix } : {},
2957
- ...entry.expiry !== void 0 ? { expiry: entry.expiry } : {}
2969
+ ...entry.expiry !== void 0 ? { expiry: entry.expiry } : {},
2970
+ ...entry.description !== void 0 ? { description: entry.description } : {}
2958
2971
  };
2959
2972
  }
2960
2973
  function dedupeResources(resources) {
@@ -2973,6 +2986,9 @@ function dedupeResources(resources) {
2973
2986
  seen.add(action);
2974
2987
  }
2975
2988
  }
2989
+ if (existing.description === void 0 && resource.description !== void 0) {
2990
+ existing.description = resource.description;
2991
+ }
2976
2992
  }
2977
2993
  return [...byKey.values()];
2978
2994
  }
@@ -2981,11 +2997,7 @@ function accountRegistryPermission() {
2981
2997
  service: "tinycloud.kv",
2982
2998
  space: ACCOUNT_REGISTRY_SPACE,
2983
2999
  path: ACCOUNT_REGISTRY_PATH,
2984
- actions: [
2985
- "tinycloud.kv/get",
2986
- "tinycloud.kv/put",
2987
- "tinycloud.kv/list"
2988
- ]
3000
+ actions: ["tinycloud.kv/get", "tinycloud.kv/put", "tinycloud.kv/list"]
2989
3001
  };
2990
3002
  }
2991
3003
  function composeManifestRequest(inputs, options = {}) {