@tinycloud/sdk-core 2.2.0-beta.7 → 2.2.0-beta.9

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
@@ -200,8 +200,9 @@ interface IENSResolver {
200
200
  * in their `manifest.json` and the shape we compare against when performing
201
201
  * the capability-subset derivability check in the delegation flow.
202
202
  *
203
- * `service` uses the long form (e.g. `"tinycloud.kv"`, `"tinycloud.sql"`)
204
- * which matches the ability-namespace half of the full action URN.
203
+ * `service` uses the long form (e.g. `"tinycloud.kv"`, `"tinycloud.sql"`).
204
+ * `"tinycloud.vault"` is an SDK-only shorthand that expands to the KV
205
+ * resources the vault service uses; it is never encoded as a recap service.
205
206
  */
206
207
  interface PermissionEntry {
207
208
  /** Service namespace, e.g. "tinycloud.kv", "tinycloud.sql", "tinycloud.duckdb", "tinycloud.capabilities". */
@@ -394,6 +395,8 @@ declare const DEFAULT_MANIFEST_SPACE = "applications";
394
395
  declare const ACCOUNT_REGISTRY_SPACE = "account";
395
396
  /** Account-space KV prefix used for installed-application registry records. */
396
397
  declare const ACCOUNT_REGISTRY_PATH = "applications/";
398
+ /** SDK-only permission service for encrypted vault resources. */
399
+ declare const VAULT_PERMISSION_SERVICE = "tinycloud.vault";
397
400
  /**
398
401
  * Known services and their short-form (recap URI) names. The TinyCloud
399
402
  * node encodes the recap resource URI with the short service name, while
@@ -424,6 +427,22 @@ declare function parseExpiry(duration: string): number;
424
427
  * → `["tinycloud.kv/get"]` (passed through unchanged)
425
428
  */
426
429
  declare function expandActionShortNames(service: string, actions: readonly string[]): string[];
430
+ /**
431
+ * Expand SDK virtual permission services into concrete recap-capable services.
432
+ *
433
+ * Today this handles `"tinycloud.vault"`, which is backed by KV resources:
434
+ * - read/get: `keys/<path>` + `vault/<path>` with `tinycloud.kv/get`
435
+ * - write/put: `keys/<path>` + `vault/<path>` with `tinycloud.kv/put`
436
+ * - delete/del: `keys/<path>` + `vault/<path>` with `tinycloud.kv/del`
437
+ * - list: `vault/<path>` with `tinycloud.kv/list`
438
+ * - head: `vault/<path>` with `tinycloud.kv/get`
439
+ * - metadata: `vault/<path>` with `tinycloud.kv/metadata`
440
+ */
441
+ declare function expandPermissionEntry(entry: PermissionEntry): PermissionEntry[];
442
+ /**
443
+ * Expand a list of permission entries using {@link expandPermissionEntry}.
444
+ */
445
+ declare function expandPermissionEntries(entries: readonly PermissionEntry[]): PermissionEntry[];
427
446
  /**
428
447
  * Apply the manifest prefix to a permission path per the spec rules.
429
448
  *
@@ -4566,4 +4585,4 @@ declare function resolveTinyCloudHosts(subject: string, options?: ResolveTinyClo
4566
4585
  declare function multiaddrToHttpUrl(input: string): string;
4567
4586
  declare function httpUrlToMultiaddr(input: string): string;
4568
4587
 
4569
- export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, type AbilitiesMap, AutoApproveSpaceCreationHandler, type AutoRejectStrategy, type AutoSignStrategy, type Bytes, type CallbackStrategy, type CapabilityEntry, CapabilityKeyRegistry, type CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, type ClientSession, ClientSessionSchema, CloudLocationResolutionError, type ComposeManifestOptions, type ComposedManifestRequest, type CreateDelegationFunction, type CreateDelegationParams, type CreateDelegationWasmParams, type CreateDelegationWasmResult, DEFAULT_DEFAULTS, DEFAULT_EXPIRY, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_TINYCLOUD_FALLBACK_HOST, DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL, type DelegatedResource, type Delegation, type DelegationApiResponse, type DelegationChain, type DelegationChainV2, type DelegationDirection, type DelegationError, type DelegationErrorCode, DelegationErrorCodes, type DelegationFilters, DelegationManager, type DelegationManagerConfig, type DelegationRecord, type Result as DelegationResult, type EncodedShareData, type EnsData, EnsDataSchema, type EventEmitterStrategy, type Extension, type GenerateShareParams, type ICapabilityKeyRegistry, type IENSResolver, type INotificationHandler, type ISessionManager, type ISessionStorage, type ISharingService, type ISigner, type ISpace, type ISpaceCreationHandler, type ISpaceScopedDelegations, type ISpaceScopedSharing, type ISpaceService, type IUserAuthorization, type IWasmBindings, type IngestOptions, type JWK, type KeyInfo, type KeyProvider, type KeyType, type LocationCandidate, type LocationCandidateInput, type LocationRecord, type LocationRecordPayload, type LocationRecordSigner, LocationRecordValidationError, type LocationResolutionAttempt, type LocationSource, type Manifest, type ManifestDefaults, type ManifestRegistryRecord, type ManifestSecretActions, ManifestValidationError, type NodeInfo, type ParseRecapFromSiwe, type PartialSiweMessage, type PermissionEntry, PermissionNotInManifestError, type PersistedSessionData, type PersistedTinyCloudSession, ProtocolMismatchError, type ReceiveOptions, type ResolveCloudLocationOptions, type ResolveTinyCloudHostsOptions, type ResolvedCapabilities, type ResolvedCloudLocation, type ResolvedDelegate, type ResolvedTinyCloudHosts, type ResourceCapability, SERVICE_LONG_TO_SHORT, SERVICE_SHORT_TO_LONG, type ServerHost, SessionExpiredError, type ShareAccess, type ShareLink, type ShareLinkData, type ShareSchema, SharingService, type SharingServiceConfig, type SignCallback, type SignInOptions, type SignRequest, type SignResponse, type SignStrategy, SilentNotificationHandler, type SiweConfig, SiweConfigSchema, Space, type SpaceAbilitiesMap, type SpaceConfig, type SpaceCreationContext, type SpaceDelegationParams, type SpaceErrorCode, SpaceErrorCodes, type SpaceHostResult, type SpaceInfo, type SpaceOwnership, SpaceService, type SpaceServiceConfig, type StoredDelegationChain, type SubsetCheckResult, TinyCloud, type TinyCloudConfig, type TinyCloudSession, UnsupportedFeatureError, type UserAuthorizationConfig, type ValidationError, VersionCheckError, type WasmRecapEntry, activateSessionWithHost, applyPrefix, buildSpaceUri, canonicalLocationPayload, checkNodeInfo, composeManifestRequest, createCapabilityKeyRegistry, createSharingService, createSpaceService, defaultSignStrategy, defaultSpaceCreationHandler, expandActionShortNames, fetchLocationRecord, fetchPeerId, httpUrlToMultiaddr, isCapabilitySubset, loadManifest, locationPayloadForRecord, makePublicSpaceId, manifestAbilitiesUnion, multiaddrToHttpUrl, normalizeDefaults, parseExpiry, parseRecapCapabilities, parseSpaceUri, resolveCloudLocation, resolveManifest, resolveTinyCloudHosts, resourceCapabilitiesToAbilitiesMap, resourceCapabilitiesToSpaceAbilitiesMap, signLocationRecord, submitHostDelegation, validateClientSession, validateLocationRecord, validateLocationRecordPayload, validateManifest, validatePersistedSessionData, verifyLocationRecord };
4588
+ export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, type AbilitiesMap, AutoApproveSpaceCreationHandler, type AutoRejectStrategy, type AutoSignStrategy, type Bytes, type CallbackStrategy, type CapabilityEntry, CapabilityKeyRegistry, type CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, type ClientSession, ClientSessionSchema, CloudLocationResolutionError, type ComposeManifestOptions, type ComposedManifestRequest, type CreateDelegationFunction, type CreateDelegationParams, type CreateDelegationWasmParams, type CreateDelegationWasmResult, DEFAULT_DEFAULTS, DEFAULT_EXPIRY, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_TINYCLOUD_FALLBACK_HOST, DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL, type DelegatedResource, type Delegation, type DelegationApiResponse, type DelegationChain, type DelegationChainV2, type DelegationDirection, type DelegationError, type DelegationErrorCode, DelegationErrorCodes, type DelegationFilters, DelegationManager, type DelegationManagerConfig, type DelegationRecord, type Result as DelegationResult, type EncodedShareData, type EnsData, EnsDataSchema, type EventEmitterStrategy, type Extension, type GenerateShareParams, type ICapabilityKeyRegistry, type IENSResolver, type INotificationHandler, type ISessionManager, type ISessionStorage, type ISharingService, type ISigner, type ISpace, type ISpaceCreationHandler, type ISpaceScopedDelegations, type ISpaceScopedSharing, type ISpaceService, type IUserAuthorization, type IWasmBindings, type IngestOptions, type JWK, type KeyInfo, type KeyProvider, type KeyType, type LocationCandidate, type LocationCandidateInput, type LocationRecord, type LocationRecordPayload, type LocationRecordSigner, LocationRecordValidationError, type LocationResolutionAttempt, type LocationSource, type Manifest, type ManifestDefaults, type ManifestRegistryRecord, type ManifestSecretActions, ManifestValidationError, type NodeInfo, type ParseRecapFromSiwe, type PartialSiweMessage, type PermissionEntry, PermissionNotInManifestError, type PersistedSessionData, type PersistedTinyCloudSession, ProtocolMismatchError, type ReceiveOptions, type ResolveCloudLocationOptions, type ResolveTinyCloudHostsOptions, type ResolvedCapabilities, type ResolvedCloudLocation, type ResolvedDelegate, type ResolvedTinyCloudHosts, type ResourceCapability, SERVICE_LONG_TO_SHORT, SERVICE_SHORT_TO_LONG, type ServerHost, SessionExpiredError, type ShareAccess, type ShareLink, type ShareLinkData, type ShareSchema, SharingService, type SharingServiceConfig, type SignCallback, type SignInOptions, type SignRequest, type SignResponse, type SignStrategy, SilentNotificationHandler, type SiweConfig, SiweConfigSchema, Space, type SpaceAbilitiesMap, type SpaceConfig, type SpaceCreationContext, type SpaceDelegationParams, type SpaceErrorCode, SpaceErrorCodes, type SpaceHostResult, type SpaceInfo, type SpaceOwnership, SpaceService, type SpaceServiceConfig, type StoredDelegationChain, type SubsetCheckResult, TinyCloud, type TinyCloudConfig, type TinyCloudSession, UnsupportedFeatureError, type UserAuthorizationConfig, VAULT_PERMISSION_SERVICE, type ValidationError, VersionCheckError, type WasmRecapEntry, activateSessionWithHost, applyPrefix, buildSpaceUri, canonicalLocationPayload, checkNodeInfo, composeManifestRequest, createCapabilityKeyRegistry, createSharingService, createSpaceService, defaultSignStrategy, defaultSpaceCreationHandler, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, fetchLocationRecord, fetchPeerId, httpUrlToMultiaddr, isCapabilitySubset, loadManifest, locationPayloadForRecord, makePublicSpaceId, manifestAbilitiesUnion, multiaddrToHttpUrl, normalizeDefaults, parseExpiry, parseRecapCapabilities, parseSpaceUri, resolveCloudLocation, resolveManifest, resolveTinyCloudHosts, resourceCapabilitiesToAbilitiesMap, resourceCapabilitiesToSpaceAbilitiesMap, signLocationRecord, submitHostDelegation, validateClientSession, validateLocationRecord, validateLocationRecordPayload, validateManifest, validatePersistedSessionData, verifyLocationRecord };
package/dist/index.d.ts CHANGED
@@ -200,8 +200,9 @@ interface IENSResolver {
200
200
  * in their `manifest.json` and the shape we compare against when performing
201
201
  * the capability-subset derivability check in the delegation flow.
202
202
  *
203
- * `service` uses the long form (e.g. `"tinycloud.kv"`, `"tinycloud.sql"`)
204
- * which matches the ability-namespace half of the full action URN.
203
+ * `service` uses the long form (e.g. `"tinycloud.kv"`, `"tinycloud.sql"`).
204
+ * `"tinycloud.vault"` is an SDK-only shorthand that expands to the KV
205
+ * resources the vault service uses; it is never encoded as a recap service.
205
206
  */
206
207
  interface PermissionEntry {
207
208
  /** Service namespace, e.g. "tinycloud.kv", "tinycloud.sql", "tinycloud.duckdb", "tinycloud.capabilities". */
@@ -394,6 +395,8 @@ declare const DEFAULT_MANIFEST_SPACE = "applications";
394
395
  declare const ACCOUNT_REGISTRY_SPACE = "account";
395
396
  /** Account-space KV prefix used for installed-application registry records. */
396
397
  declare const ACCOUNT_REGISTRY_PATH = "applications/";
398
+ /** SDK-only permission service for encrypted vault resources. */
399
+ declare const VAULT_PERMISSION_SERVICE = "tinycloud.vault";
397
400
  /**
398
401
  * Known services and their short-form (recap URI) names. The TinyCloud
399
402
  * node encodes the recap resource URI with the short service name, while
@@ -424,6 +427,22 @@ declare function parseExpiry(duration: string): number;
424
427
  * → `["tinycloud.kv/get"]` (passed through unchanged)
425
428
  */
426
429
  declare function expandActionShortNames(service: string, actions: readonly string[]): string[];
430
+ /**
431
+ * Expand SDK virtual permission services into concrete recap-capable services.
432
+ *
433
+ * Today this handles `"tinycloud.vault"`, which is backed by KV resources:
434
+ * - read/get: `keys/<path>` + `vault/<path>` with `tinycloud.kv/get`
435
+ * - write/put: `keys/<path>` + `vault/<path>` with `tinycloud.kv/put`
436
+ * - delete/del: `keys/<path>` + `vault/<path>` with `tinycloud.kv/del`
437
+ * - list: `vault/<path>` with `tinycloud.kv/list`
438
+ * - head: `vault/<path>` with `tinycloud.kv/get`
439
+ * - metadata: `vault/<path>` with `tinycloud.kv/metadata`
440
+ */
441
+ declare function expandPermissionEntry(entry: PermissionEntry): PermissionEntry[];
442
+ /**
443
+ * Expand a list of permission entries using {@link expandPermissionEntry}.
444
+ */
445
+ declare function expandPermissionEntries(entries: readonly PermissionEntry[]): PermissionEntry[];
427
446
  /**
428
447
  * Apply the manifest prefix to a permission path per the spec rules.
429
448
  *
@@ -4566,4 +4585,4 @@ declare function resolveTinyCloudHosts(subject: string, options?: ResolveTinyClo
4566
4585
  declare function multiaddrToHttpUrl(input: string): string;
4567
4586
  declare function httpUrlToMultiaddr(input: string): string;
4568
4587
 
4569
- export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, type AbilitiesMap, AutoApproveSpaceCreationHandler, type AutoRejectStrategy, type AutoSignStrategy, type Bytes, type CallbackStrategy, type CapabilityEntry, CapabilityKeyRegistry, type CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, type ClientSession, ClientSessionSchema, CloudLocationResolutionError, type ComposeManifestOptions, type ComposedManifestRequest, type CreateDelegationFunction, type CreateDelegationParams, type CreateDelegationWasmParams, type CreateDelegationWasmResult, DEFAULT_DEFAULTS, DEFAULT_EXPIRY, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_TINYCLOUD_FALLBACK_HOST, DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL, type DelegatedResource, type Delegation, type DelegationApiResponse, type DelegationChain, type DelegationChainV2, type DelegationDirection, type DelegationError, type DelegationErrorCode, DelegationErrorCodes, type DelegationFilters, DelegationManager, type DelegationManagerConfig, type DelegationRecord, type Result as DelegationResult, type EncodedShareData, type EnsData, EnsDataSchema, type EventEmitterStrategy, type Extension, type GenerateShareParams, type ICapabilityKeyRegistry, type IENSResolver, type INotificationHandler, type ISessionManager, type ISessionStorage, type ISharingService, type ISigner, type ISpace, type ISpaceCreationHandler, type ISpaceScopedDelegations, type ISpaceScopedSharing, type ISpaceService, type IUserAuthorization, type IWasmBindings, type IngestOptions, type JWK, type KeyInfo, type KeyProvider, type KeyType, type LocationCandidate, type LocationCandidateInput, type LocationRecord, type LocationRecordPayload, type LocationRecordSigner, LocationRecordValidationError, type LocationResolutionAttempt, type LocationSource, type Manifest, type ManifestDefaults, type ManifestRegistryRecord, type ManifestSecretActions, ManifestValidationError, type NodeInfo, type ParseRecapFromSiwe, type PartialSiweMessage, type PermissionEntry, PermissionNotInManifestError, type PersistedSessionData, type PersistedTinyCloudSession, ProtocolMismatchError, type ReceiveOptions, type ResolveCloudLocationOptions, type ResolveTinyCloudHostsOptions, type ResolvedCapabilities, type ResolvedCloudLocation, type ResolvedDelegate, type ResolvedTinyCloudHosts, type ResourceCapability, SERVICE_LONG_TO_SHORT, SERVICE_SHORT_TO_LONG, type ServerHost, SessionExpiredError, type ShareAccess, type ShareLink, type ShareLinkData, type ShareSchema, SharingService, type SharingServiceConfig, type SignCallback, type SignInOptions, type SignRequest, type SignResponse, type SignStrategy, SilentNotificationHandler, type SiweConfig, SiweConfigSchema, Space, type SpaceAbilitiesMap, type SpaceConfig, type SpaceCreationContext, type SpaceDelegationParams, type SpaceErrorCode, SpaceErrorCodes, type SpaceHostResult, type SpaceInfo, type SpaceOwnership, SpaceService, type SpaceServiceConfig, type StoredDelegationChain, type SubsetCheckResult, TinyCloud, type TinyCloudConfig, type TinyCloudSession, UnsupportedFeatureError, type UserAuthorizationConfig, type ValidationError, VersionCheckError, type WasmRecapEntry, activateSessionWithHost, applyPrefix, buildSpaceUri, canonicalLocationPayload, checkNodeInfo, composeManifestRequest, createCapabilityKeyRegistry, createSharingService, createSpaceService, defaultSignStrategy, defaultSpaceCreationHandler, expandActionShortNames, fetchLocationRecord, fetchPeerId, httpUrlToMultiaddr, isCapabilitySubset, loadManifest, locationPayloadForRecord, makePublicSpaceId, manifestAbilitiesUnion, multiaddrToHttpUrl, normalizeDefaults, parseExpiry, parseRecapCapabilities, parseSpaceUri, resolveCloudLocation, resolveManifest, resolveTinyCloudHosts, resourceCapabilitiesToAbilitiesMap, resourceCapabilitiesToSpaceAbilitiesMap, signLocationRecord, submitHostDelegation, validateClientSession, validateLocationRecord, validateLocationRecordPayload, validateManifest, validatePersistedSessionData, verifyLocationRecord };
4588
+ export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, type AbilitiesMap, AutoApproveSpaceCreationHandler, type AutoRejectStrategy, type AutoSignStrategy, type Bytes, type CallbackStrategy, type CapabilityEntry, CapabilityKeyRegistry, type CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, type ClientSession, ClientSessionSchema, CloudLocationResolutionError, type ComposeManifestOptions, type ComposedManifestRequest, type CreateDelegationFunction, type CreateDelegationParams, type CreateDelegationWasmParams, type CreateDelegationWasmResult, DEFAULT_DEFAULTS, DEFAULT_EXPIRY, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_TINYCLOUD_FALLBACK_HOST, DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL, type DelegatedResource, type Delegation, type DelegationApiResponse, type DelegationChain, type DelegationChainV2, type DelegationDirection, type DelegationError, type DelegationErrorCode, DelegationErrorCodes, type DelegationFilters, DelegationManager, type DelegationManagerConfig, type DelegationRecord, type Result as DelegationResult, type EncodedShareData, type EnsData, EnsDataSchema, type EventEmitterStrategy, type Extension, type GenerateShareParams, type ICapabilityKeyRegistry, type IENSResolver, type INotificationHandler, type ISessionManager, type ISessionStorage, type ISharingService, type ISigner, type ISpace, type ISpaceCreationHandler, type ISpaceScopedDelegations, type ISpaceScopedSharing, type ISpaceService, type IUserAuthorization, type IWasmBindings, type IngestOptions, type JWK, type KeyInfo, type KeyProvider, type KeyType, type LocationCandidate, type LocationCandidateInput, type LocationRecord, type LocationRecordPayload, type LocationRecordSigner, LocationRecordValidationError, type LocationResolutionAttempt, type LocationSource, type Manifest, type ManifestDefaults, type ManifestRegistryRecord, type ManifestSecretActions, ManifestValidationError, type NodeInfo, type ParseRecapFromSiwe, type PartialSiweMessage, type PermissionEntry, PermissionNotInManifestError, type PersistedSessionData, type PersistedTinyCloudSession, ProtocolMismatchError, type ReceiveOptions, type ResolveCloudLocationOptions, type ResolveTinyCloudHostsOptions, type ResolvedCapabilities, type ResolvedCloudLocation, type ResolvedDelegate, type ResolvedTinyCloudHosts, type ResourceCapability, SERVICE_LONG_TO_SHORT, SERVICE_SHORT_TO_LONG, type ServerHost, SessionExpiredError, type ShareAccess, type ShareLink, type ShareLinkData, type ShareSchema, SharingService, type SharingServiceConfig, type SignCallback, type SignInOptions, type SignRequest, type SignResponse, type SignStrategy, SilentNotificationHandler, type SiweConfig, SiweConfigSchema, Space, type SpaceAbilitiesMap, type SpaceConfig, type SpaceCreationContext, type SpaceDelegationParams, type SpaceErrorCode, SpaceErrorCodes, type SpaceHostResult, type SpaceInfo, type SpaceOwnership, SpaceService, type SpaceServiceConfig, type StoredDelegationChain, type SubsetCheckResult, TinyCloud, type TinyCloudConfig, type TinyCloudSession, UnsupportedFeatureError, type UserAuthorizationConfig, VAULT_PERMISSION_SERVICE, type ValidationError, VersionCheckError, type WasmRecapEntry, activateSessionWithHost, applyPrefix, buildSpaceUri, canonicalLocationPayload, checkNodeInfo, composeManifestRequest, createCapabilityKeyRegistry, createSharingService, createSpaceService, defaultSignStrategy, defaultSpaceCreationHandler, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, fetchLocationRecord, fetchPeerId, httpUrlToMultiaddr, isCapabilitySubset, loadManifest, locationPayloadForRecord, makePublicSpaceId, manifestAbilitiesUnion, multiaddrToHttpUrl, normalizeDefaults, parseExpiry, parseRecapCapabilities, parseSpaceUri, resolveCloudLocation, resolveManifest, resolveTinyCloudHosts, resourceCapabilitiesToAbilitiesMap, resourceCapabilitiesToSpaceAbilitiesMap, signLocationRecord, submitHostDelegation, validateClientSession, validateLocationRecord, validateLocationRecordPayload, validateManifest, validatePersistedSessionData, verifyLocationRecord };
package/dist/index.js CHANGED
@@ -2702,6 +2702,7 @@ var ACCOUNT_REGISTRY_SPACE = "account";
2702
2702
  var ACCOUNT_REGISTRY_PATH = "applications/";
2703
2703
  var SECRETS_SPACE = "secrets";
2704
2704
  var SECRET_NAME_RE = /^[A-Z][A-Z0-9_]*$/;
2705
+ var VAULT_PERMISSION_SERVICE = "tinycloud.vault";
2705
2706
  var SERVICE_SHORT_TO_LONG = Object.freeze({
2706
2707
  kv: "tinycloud.kv",
2707
2708
  sql: "tinycloud.sql",
@@ -2784,6 +2785,20 @@ function expandActionShortNames(service, actions) {
2784
2785
  return `${service}/${a}`;
2785
2786
  });
2786
2787
  }
2788
+ function expandPermissionEntry(entry) {
2789
+ if (entry.service !== VAULT_PERMISSION_SERVICE) {
2790
+ return [
2791
+ {
2792
+ ...entry,
2793
+ actions: expandActionShortNames(entry.service, entry.actions)
2794
+ }
2795
+ ];
2796
+ }
2797
+ return expandVaultPermissionEntry(entry);
2798
+ }
2799
+ function expandPermissionEntries(entries) {
2800
+ return entries.flatMap(expandPermissionEntry);
2801
+ }
2787
2802
  function applyPrefix(prefix, path, skipPrefix) {
2788
2803
  if (skipPrefix) {
2789
2804
  return path;
@@ -2911,6 +2926,16 @@ function validatePermissionEntry(p, path) {
2911
2926
  `${path}.actions must be a non-empty array`
2912
2927
  );
2913
2928
  }
2929
+ for (const action of entry.actions) {
2930
+ if (typeof action !== "string" || action.length === 0) {
2931
+ throw new ManifestValidationError(
2932
+ `${path}.actions must contain non-empty strings`
2933
+ );
2934
+ }
2935
+ if (entry.service === VAULT_PERMISSION_SERVICE) {
2936
+ vaultActionExpansion(action);
2937
+ }
2938
+ }
2914
2939
  if (entry.expiry !== void 0) {
2915
2940
  parseExpiry(entry.expiry);
2916
2941
  }
@@ -2960,7 +2985,7 @@ function resolveManifest(input) {
2960
2985
  ...secretEntries
2961
2986
  ];
2962
2987
  const resources = withCapabilitiesReadForSpaces(
2963
- allEntries.map((entry) => resolveEntry(entry, prefix, expiryMs, space))
2988
+ allEntries.flatMap((entry) => resolveEntry(entry, prefix, expiryMs, space))
2964
2989
  );
2965
2990
  const additionalDelegates = manifest.did === void 0 ? [] : [
2966
2991
  {
@@ -3072,19 +3097,85 @@ function resolveEntry(entry, prefix, _inheritedExpiryMs, inheritedSpace) {
3072
3097
  entry.path,
3073
3098
  entry.skipPrefix === true
3074
3099
  );
3075
- const resolvedActions = expandActionShortNames(entry.service, entry.actions);
3076
3100
  const entryExpiryMs = entry.expiry !== void 0 ? parseExpiry(entry.expiry) : void 0;
3077
- return {
3078
- service: entry.service,
3101
+ return expandPermissionEntry({
3102
+ ...entry,
3079
3103
  space: entry.space ?? inheritedSpace,
3080
3104
  path: resolvedPath,
3081
- actions: resolvedActions,
3105
+ skipPrefix: true
3106
+ }).map((expanded) => ({
3107
+ service: expanded.service,
3108
+ space: expanded.space ?? inheritedSpace,
3109
+ path: expanded.path,
3110
+ actions: expanded.actions,
3082
3111
  // Only populate `expiryMs` when the entry had its own expiry override.
3083
3112
  // When absent, callers use the parent (delegation or manifest) expiry
3084
3113
  // which is carried on ResolvedDelegate.expiryMs / ResolvedCapabilities.expiryMs.
3085
3114
  ...entryExpiryMs !== void 0 ? { expiryMs: entryExpiryMs } : {},
3086
3115
  ...entry.description !== void 0 ? { description: entry.description } : {}
3087
- };
3116
+ }));
3117
+ }
3118
+ function expandVaultPermissionEntry(entry) {
3119
+ const byBase = /* @__PURE__ */ new Map();
3120
+ for (const action of entry.actions) {
3121
+ const expansion = vaultActionExpansion(action);
3122
+ for (const base of expansion.bases) {
3123
+ const actions = byBase.get(base) ?? [];
3124
+ if (!actions.includes(expansion.action)) {
3125
+ actions.push(expansion.action);
3126
+ }
3127
+ byBase.set(base, actions);
3128
+ }
3129
+ }
3130
+ return [...byBase.entries()].map(([base, actions]) => ({
3131
+ ...entry,
3132
+ service: "tinycloud.kv",
3133
+ path: vaultKVPath(base, entry.path),
3134
+ actions,
3135
+ skipPrefix: true
3136
+ }));
3137
+ }
3138
+ function vaultActionExpansion(action) {
3139
+ const normalized = normalizeVaultAction(action);
3140
+ if (normalized === "read" || normalized === "get") {
3141
+ return { bases: ["keys", "vault"], action: "tinycloud.kv/get" };
3142
+ }
3143
+ if (normalized === "write" || normalized === "put") {
3144
+ return { bases: ["keys", "vault"], action: "tinycloud.kv/put" };
3145
+ }
3146
+ if (normalized === "delete" || normalized === "del") {
3147
+ return { bases: ["keys", "vault"], action: "tinycloud.kv/del" };
3148
+ }
3149
+ if (normalized === "list") {
3150
+ return { bases: ["vault"], action: "tinycloud.kv/list" };
3151
+ }
3152
+ if (normalized === "head") {
3153
+ return { bases: ["vault"], action: "tinycloud.kv/get" };
3154
+ }
3155
+ if (normalized === "metadata") {
3156
+ return { bases: ["vault"], action: "tinycloud.kv/metadata" };
3157
+ }
3158
+ throw new ManifestValidationError(
3159
+ `unknown vault action ${JSON.stringify(action)}; expected read, write, delete, get, put, del, list, head, or metadata`
3160
+ );
3161
+ }
3162
+ function normalizeVaultAction(action) {
3163
+ if (action.startsWith(`${VAULT_PERMISSION_SERVICE}/`)) {
3164
+ return action.slice(`${VAULT_PERMISSION_SERVICE}/`.length);
3165
+ }
3166
+ if (action.startsWith("tinycloud.kv/")) {
3167
+ return action.slice("tinycloud.kv/".length);
3168
+ }
3169
+ if (action.includes("/")) {
3170
+ throw new ManifestValidationError(
3171
+ `unknown vault action ${JSON.stringify(action)}; expected a tinycloud.vault or tinycloud.kv action`
3172
+ );
3173
+ }
3174
+ return action;
3175
+ }
3176
+ function vaultKVPath(base, path) {
3177
+ const normalized = path.startsWith("/") ? path.slice(1) : path;
3178
+ return `${base}/${normalized}`;
3088
3179
  }
3089
3180
  function cloneResourceCapability(entry) {
3090
3181
  return {
@@ -4953,6 +5044,7 @@ export {
4953
5044
  SpaceService,
4954
5045
  TinyCloud,
4955
5046
  UnsupportedFeatureError,
5047
+ VAULT_PERMISSION_SERVICE,
4956
5048
  VaultHeaders,
4957
5049
  VaultPublicSpaceKVActions,
4958
5050
  VersionCheckError,
@@ -4971,6 +5063,8 @@ export {
4971
5063
  defaultSpaceCreationHandler,
4972
5064
  err4 as err,
4973
5065
  expandActionShortNames,
5066
+ expandPermissionEntries,
5067
+ expandPermissionEntry,
4974
5068
  fetchLocationRecord,
4975
5069
  fetchPeerId,
4976
5070
  httpUrlToMultiaddr,