@tinycloud/node-sdk 3.0.0-beta.13 → 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/{core-DWFGaDwP.d.cts → core-D4IVgDr5.d.cts} +5 -1
- package/dist/{core-DWFGaDwP.d.ts → core-D4IVgDr5.d.ts} +5 -1
- package/dist/core.cjs +66 -50
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +65 -50
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +68 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -2
- package/dist/index.d.ts +24 -2
- package/dist/index.js +66 -50
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ISigner, Bytes, CapabilityPresentationEnvelopeV1, IWasmBindings, PersistedSessionProof, ISessionManager } from '@tinycloud/sdk-core';
|
|
2
2
|
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AccountApplication, AccountApplicationListOptions, AccountApplicationRegisterOptions, AccountDelegation, AccountDelegationListOptions, AccountDelegationPage, AccountDelegationQueryOptions, AccountDelegationRecord, AccountDelegationResource, AccountDelegationRevokeOptions, AccountIndexEnsureResult, AccountIndexRebuildResult, AccountIndexStatus, AccountIndexedReadOptions, AccountService, AccountServiceConfig, AccountSpace, AccountSpaceListOptions, AccountStatus, AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, BuildCanonicalDecryptRequestInput, BuildDecryptFactsInput, BuildDecryptInvocationInput, BuiltDecryptInvocation, CallbackStrategy, CanonicalAddress, CanonicalDecryptRequest, CanonicalJson, CanonicalParsedNetworkId, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, CaveatedDelegationUnsupportedError, ClientSession, ColumnInfo, ComposeManifestOptions, ComposedManifestRequest, CreateDelegationParams, DECRYPT_ACTION, DECRYPT_FACT_TYPE, DECRYPT_RESULT_TYPE, DEFAULT_ENCRYPTION_ALG, DEFAULT_KEY_VERSION, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DataVaultConfig, DataVaultService, DatabaseHandle, DecryptCapabilityProof, DecryptEnvelopeOptions, DecryptInvocationFact, DecryptInvocationSigner, DecryptRequestBody, DecryptResponseBody, DecryptTransport, DecryptTransportResponseError, DelegateReceivedShareParams, DelegatedShareAccess, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, DelegationRevocationReceipt, DidCacheKeyOptions, DidEqualsOptions, DiscoverNetworkInput, DiscoveredNetwork, DiscoverySource, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, ENCRYPTION_NETWORK_URN_PREFIX, ENCRYPTION_SERVICE, ENCRYPTION_SERVICE_SHORT, ENVELOPE_VERSION, EncodedShareData, EncryptToNetworkInput, EncryptToNetworkOptions, EncryptToNetworkResult, EncryptionCrypto, EncryptionError, EncryptionErrorInput, EncryptionService, EncryptionServiceConfig, ExecuteOptions, ExecuteResponse, Extension, FetchFunction, GenerateShareParams, HookEvent, HookServiceName, HookStreamEvent, HookSubscription, HookWebhookListOptions, HookWebhookRecord, HookWebhookRegistration, HookWebhookScope, HookWebhookUnregisterOptions, HooksService, HooksServiceConfig, ICapabilityKeyRegistry, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IENSResolver, IEncryptionService, IHooksService, IKVService, INotificationHandler, IPrefixedKVService, ISQLService, ISecretsService, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IdentityParseError, IngestOptions, InlineEncryptedEnvelope, InvokeFunction, JWK, KVBatchReadResponse, KVCreateSignedReadUrlOptions, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, NETWORK_NAME_PATTERN, NetworkDescriptor, NetworkIdError, NodeDescriptorFetcher, OpenKeyCallbackStrategy, OpenKeySigningRequestBody, OpenKeySigningResponseBody, OpenKeySigningStrategyOptions, OwnerDelegationPermission, ParsedNetworkId, ParsedSecretCatalogKey, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PkhDidParts, PrefixedKVService, ProtocolMismatchError, QueryOptions, QueryResponse, RandomReceiverKeyInput, ReceiveOptions, ReceiverKeyPair, ReceiverKeySigner, RegisterBatchSuccess, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ResolvedCapabilities, ResolvedDelegate, ResolvedSecretPath, ResourceCapability, SECRET_NAME_RE, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, SecretCatalogEntry, SecretPayload, SecretScopeOptions, SecretsError, SecretsService, ServiceContext, ServiceContextConfig, ServiceSession, SessionExpiredError, ShareAccess, ShareLink, ShareLinkData, ShareSchema, SharingService, SharingServiceConfig, SignCallback, SignInOptions, SignRequest, SignResponse, SignedReceiverKeyInput, SilentNotificationHandler, Space, SpaceAbilitiesMap, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, SubscribeOptions, TableInfo, TelemetryConfig, TelemetryEventHandler, TinyCloud, TinyCloudConfig, TinyCloudDebugEnableOptions, TinyCloudDebugEvent, TinyCloudDebugLevel, TinyCloudDebugLogger, TinyCloudDebugTimer, TinyCloudSession, UnsupportedFeatureError, VAULT_PERMISSION_SERVICE, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultNetworkReadResult, VaultPublicSpaceKVActions, VaultPutOptions, VerifyDecryptResponseInput, VersionCheckError, ViewInfo, WasmVaultFunctions, WellKnownDescriptorFetcher, addressStorageKey, buildCanonicalDecryptRequest, buildDecryptAttenuation, buildDecryptFacts, buildDecryptInvocation, buildNetworkId, buildSpaceUri, canonicalHashHex, canonicalSignedResponse, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeEncryptionJson, canonicalizeNetworkId, canonicalizeSecretScope, checkDecryptInvocationInput, checkNodeInfo, clearTinyCloudDebugLogs, composeManifestRequest, createCapabilityKeyRegistry, createOpenKeyCallbackSigningStrategy, createSharingService, createSpaceService, createVaultCrypto, decryptEnvelopeWithKey, defaultSpaceCreationHandler, deriveSignedReceiverKey, didCacheKey, didEquals, disableTinyCloudDebug, discoverNetwork, enableTinyCloudDebug, encryptToNetwork, encryptionBase64Decode, encryptionBase64Encode, encryptionError, encryptionUtf8Decode, encryptionUtf8Encode, ensureNetworkUsableForDecrypt, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, generateRandomReceiverKey, getTinyCloudDebugLogs, hexDecode, hexEncode, installTinyCloudDebugGlobals, isCapabilitySubset, isEvmAddress, isNetworkId, loadManifest, makePkhSpaceId, makePublicSpaceId, networkDiscoveryKey, openWrappedKey, parseCanonicalNetworkId, parseExpiry, parseNetworkId, parsePkhDid, parseSecretCatalogKey, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveManifest, resolveSecretListPrefix, resolveSecretPath, resourceCapabilitiesToSpaceAbilitiesMap, tinyCloudDebugLogger, validateEnvelope, validateManifest, verifyDecryptResponse } from '@tinycloud/sdk-core';
|
|
3
|
-
export { A as ACCEPTED_MARKER_VERSIONS, a as AuthDelegationArtifact, b as AuthRequestArtifact, B as BOOTSTRAP_COMPLETION_MARKER_KEY, c as BOOTSTRAP_COMPLETION_MARKER_VERSION, d as BootstrapCompletionMarker, e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, i as DelegationAuthority, E as EnsureEncryptionNetworkOptions, F as FileSessionStorage, M as MemorySessionStorage, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, k as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, P as PortableDelegation, R as RestorableSession, l as RuntimeDelegationActivator, m as RuntimePermissionGrantOptions, S as SecretPermissionHint, n as SecretReadInput, o as SecretReadResult, p as SignStrategy, T as TinyCloudNode, q as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, r as UnifiedOwnerRootReceipt, s as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, W as WasmKeyProvider, t as WasmKeyProviderConfig, u as activateCompactRuntimeDelegation, v as activateValidatedRuntimeDelegation, w as createWasmKeyProvider, x as defaultSignStrategy, y as deserializeDelegation, z as grantAuthRequest, G as serializeDelegation } from './core-
|
|
3
|
+
export { A as ACCEPTED_MARKER_VERSIONS, a as AuthDelegationArtifact, b as AuthRequestArtifact, B as BOOTSTRAP_COMPLETION_MARKER_KEY, c as BOOTSTRAP_COMPLETION_MARKER_VERSION, d as BootstrapCompletionMarker, e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, i as DelegationAuthority, E as EnsureEncryptionNetworkOptions, F as FileSessionStorage, I as InvalidRestoredSessionError, M as MemorySessionStorage, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, k as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, P as PortableDelegation, R as RestorableSession, l as RuntimeDelegationActivator, m as RuntimePermissionGrantOptions, S as SecretPermissionHint, n as SecretReadInput, o as SecretReadResult, p as SignStrategy, T as TinyCloudNode, q as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, r as UnifiedOwnerRootReceipt, s as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, W as WasmKeyProvider, t as WasmKeyProviderConfig, u as activateCompactRuntimeDelegation, v as activateValidatedRuntimeDelegation, w as createWasmKeyProvider, x as defaultSignStrategy, y as deserializeDelegation, z as grantAuthRequest, G as serializeDelegation } from './core-D4IVgDr5.cjs';
|
|
4
4
|
import { invoke, invokeAny, computeCid, prepareSession, completeSessionSetup, ensureEip55, makeSpaceId, createDelegation, parseRecapFromSiwe, parseVerifiedRecapFromSiwe, generateHostSIWEMessage, siweToDelegationHeaders, protocolVersion, vault_encrypt, vault_decrypt, vault_derive_key, vault_x25519_from_seed, vault_x25519_dh, vault_random_bytes, vault_sha256 } from '@tinycloud/node-sdk-wasm';
|
|
5
5
|
import 'events';
|
|
6
6
|
import '@tinycloud/sdk-services';
|
|
@@ -133,6 +133,28 @@ type NodeUserAuthorizationAuthorizeFn = (input: OpenKeyBridgeInput) => Promise<{
|
|
|
133
133
|
*/
|
|
134
134
|
declare function wireOpenKeyAuthorize(openkey: OpenKeyAuthorizeTinyCloud): NodeUserAuthorizationAuthorizeFn;
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Internal helpers for TinyCloudNode.delegateTo and the legacy
|
|
138
|
+
* createDelegation compatibility shim. Exported from their own module so
|
|
139
|
+
* they are easy to unit-test without spinning up a full TinyCloudNode.
|
|
140
|
+
*
|
|
141
|
+
* None of these are part of the public API — the module path is not
|
|
142
|
+
* re-exported from `@tinycloud/node-sdk` or `@tinycloud/node-sdk/core`.
|
|
143
|
+
*
|
|
144
|
+
* @packageDocumentation
|
|
145
|
+
*/
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Extract the `expirationTime` field of a signed SIWE message as a `Date`.
|
|
149
|
+
*
|
|
150
|
+
* Returns `undefined` only when the SIWE genuinely has no `Expiration Time`
|
|
151
|
+
* line (RFC-4501 permits it). Propagates parse errors — the SDK always
|
|
152
|
+
* produces signed SIWEs during sign-in, so an unparseable `session.siwe`
|
|
153
|
+
* means something is actively wrong and we do not want to silently skip
|
|
154
|
+
* the expiry check.
|
|
155
|
+
*/
|
|
156
|
+
declare function extractSiweExpiration(siwe: string): Date | undefined;
|
|
157
|
+
|
|
136
158
|
/**
|
|
137
159
|
* NodeWasmBindings - Default IWasmBindings implementation for Node.js.
|
|
138
160
|
*
|
|
@@ -175,4 +197,4 @@ declare class NodeWasmBindings implements IWasmBindings {
|
|
|
175
197
|
createSessionManager(): ISessionManager;
|
|
176
198
|
}
|
|
177
199
|
|
|
178
|
-
export { type NodeUserAuthorizationAuthorizeFn, NodeWasmBindings, type OpenKeyAuthorizeTinyCloud, type OpenKeyBridgeInput, PrivateKeySigner, wireOpenKeyAuthorize };
|
|
200
|
+
export { type NodeUserAuthorizationAuthorizeFn, NodeWasmBindings, type OpenKeyAuthorizeTinyCloud, type OpenKeyBridgeInput, PrivateKeySigner, extractSiweExpiration, wireOpenKeyAuthorize };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ISigner, Bytes, CapabilityPresentationEnvelopeV1, IWasmBindings, PersistedSessionProof, ISessionManager } from '@tinycloud/sdk-core';
|
|
2
2
|
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AccountApplication, AccountApplicationListOptions, AccountApplicationRegisterOptions, AccountDelegation, AccountDelegationListOptions, AccountDelegationPage, AccountDelegationQueryOptions, AccountDelegationRecord, AccountDelegationResource, AccountDelegationRevokeOptions, AccountIndexEnsureResult, AccountIndexRebuildResult, AccountIndexStatus, AccountIndexedReadOptions, AccountService, AccountServiceConfig, AccountSpace, AccountSpaceListOptions, AccountStatus, AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, BuildCanonicalDecryptRequestInput, BuildDecryptFactsInput, BuildDecryptInvocationInput, BuiltDecryptInvocation, CallbackStrategy, CanonicalAddress, CanonicalDecryptRequest, CanonicalJson, CanonicalParsedNetworkId, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, CaveatedDelegationUnsupportedError, ClientSession, ColumnInfo, ComposeManifestOptions, ComposedManifestRequest, CreateDelegationParams, DECRYPT_ACTION, DECRYPT_FACT_TYPE, DECRYPT_RESULT_TYPE, DEFAULT_ENCRYPTION_ALG, DEFAULT_KEY_VERSION, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DataVaultConfig, DataVaultService, DatabaseHandle, DecryptCapabilityProof, DecryptEnvelopeOptions, DecryptInvocationFact, DecryptInvocationSigner, DecryptRequestBody, DecryptResponseBody, DecryptTransport, DecryptTransportResponseError, DelegateReceivedShareParams, DelegatedShareAccess, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, DelegationRevocationReceipt, DidCacheKeyOptions, DidEqualsOptions, DiscoverNetworkInput, DiscoveredNetwork, DiscoverySource, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, ENCRYPTION_NETWORK_URN_PREFIX, ENCRYPTION_SERVICE, ENCRYPTION_SERVICE_SHORT, ENVELOPE_VERSION, EncodedShareData, EncryptToNetworkInput, EncryptToNetworkOptions, EncryptToNetworkResult, EncryptionCrypto, EncryptionError, EncryptionErrorInput, EncryptionService, EncryptionServiceConfig, ExecuteOptions, ExecuteResponse, Extension, FetchFunction, GenerateShareParams, HookEvent, HookServiceName, HookStreamEvent, HookSubscription, HookWebhookListOptions, HookWebhookRecord, HookWebhookRegistration, HookWebhookScope, HookWebhookUnregisterOptions, HooksService, HooksServiceConfig, ICapabilityKeyRegistry, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IENSResolver, IEncryptionService, IHooksService, IKVService, INotificationHandler, IPrefixedKVService, ISQLService, ISecretsService, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IdentityParseError, IngestOptions, InlineEncryptedEnvelope, InvokeFunction, JWK, KVBatchReadResponse, KVCreateSignedReadUrlOptions, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, NETWORK_NAME_PATTERN, NetworkDescriptor, NetworkIdError, NodeDescriptorFetcher, OpenKeyCallbackStrategy, OpenKeySigningRequestBody, OpenKeySigningResponseBody, OpenKeySigningStrategyOptions, OwnerDelegationPermission, ParsedNetworkId, ParsedSecretCatalogKey, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PkhDidParts, PrefixedKVService, ProtocolMismatchError, QueryOptions, QueryResponse, RandomReceiverKeyInput, ReceiveOptions, ReceiverKeyPair, ReceiverKeySigner, RegisterBatchSuccess, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ResolvedCapabilities, ResolvedDelegate, ResolvedSecretPath, ResourceCapability, SECRET_NAME_RE, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, SecretCatalogEntry, SecretPayload, SecretScopeOptions, SecretsError, SecretsService, ServiceContext, ServiceContextConfig, ServiceSession, SessionExpiredError, ShareAccess, ShareLink, ShareLinkData, ShareSchema, SharingService, SharingServiceConfig, SignCallback, SignInOptions, SignRequest, SignResponse, SignedReceiverKeyInput, SilentNotificationHandler, Space, SpaceAbilitiesMap, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, SubscribeOptions, TableInfo, TelemetryConfig, TelemetryEventHandler, TinyCloud, TinyCloudConfig, TinyCloudDebugEnableOptions, TinyCloudDebugEvent, TinyCloudDebugLevel, TinyCloudDebugLogger, TinyCloudDebugTimer, TinyCloudSession, UnsupportedFeatureError, VAULT_PERMISSION_SERVICE, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultNetworkReadResult, VaultPublicSpaceKVActions, VaultPutOptions, VerifyDecryptResponseInput, VersionCheckError, ViewInfo, WasmVaultFunctions, WellKnownDescriptorFetcher, addressStorageKey, buildCanonicalDecryptRequest, buildDecryptAttenuation, buildDecryptFacts, buildDecryptInvocation, buildNetworkId, buildSpaceUri, canonicalHashHex, canonicalSignedResponse, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeEncryptionJson, canonicalizeNetworkId, canonicalizeSecretScope, checkDecryptInvocationInput, checkNodeInfo, clearTinyCloudDebugLogs, composeManifestRequest, createCapabilityKeyRegistry, createOpenKeyCallbackSigningStrategy, createSharingService, createSpaceService, createVaultCrypto, decryptEnvelopeWithKey, defaultSpaceCreationHandler, deriveSignedReceiverKey, didCacheKey, didEquals, disableTinyCloudDebug, discoverNetwork, enableTinyCloudDebug, encryptToNetwork, encryptionBase64Decode, encryptionBase64Encode, encryptionError, encryptionUtf8Decode, encryptionUtf8Encode, ensureNetworkUsableForDecrypt, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, generateRandomReceiverKey, getTinyCloudDebugLogs, hexDecode, hexEncode, installTinyCloudDebugGlobals, isCapabilitySubset, isEvmAddress, isNetworkId, loadManifest, makePkhSpaceId, makePublicSpaceId, networkDiscoveryKey, openWrappedKey, parseCanonicalNetworkId, parseExpiry, parseNetworkId, parsePkhDid, parseSecretCatalogKey, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveManifest, resolveSecretListPrefix, resolveSecretPath, resourceCapabilitiesToSpaceAbilitiesMap, tinyCloudDebugLogger, validateEnvelope, validateManifest, verifyDecryptResponse } from '@tinycloud/sdk-core';
|
|
3
|
-
export { A as ACCEPTED_MARKER_VERSIONS, a as AuthDelegationArtifact, b as AuthRequestArtifact, B as BOOTSTRAP_COMPLETION_MARKER_KEY, c as BOOTSTRAP_COMPLETION_MARKER_VERSION, d as BootstrapCompletionMarker, e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, i as DelegationAuthority, E as EnsureEncryptionNetworkOptions, F as FileSessionStorage, M as MemorySessionStorage, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, k as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, P as PortableDelegation, R as RestorableSession, l as RuntimeDelegationActivator, m as RuntimePermissionGrantOptions, S as SecretPermissionHint, n as SecretReadInput, o as SecretReadResult, p as SignStrategy, T as TinyCloudNode, q as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, r as UnifiedOwnerRootReceipt, s as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, W as WasmKeyProvider, t as WasmKeyProviderConfig, u as activateCompactRuntimeDelegation, v as activateValidatedRuntimeDelegation, w as createWasmKeyProvider, x as defaultSignStrategy, y as deserializeDelegation, z as grantAuthRequest, G as serializeDelegation } from './core-
|
|
3
|
+
export { A as ACCEPTED_MARKER_VERSIONS, a as AuthDelegationArtifact, b as AuthRequestArtifact, B as BOOTSTRAP_COMPLETION_MARKER_KEY, c as BOOTSTRAP_COMPLETION_MARKER_VERSION, d as BootstrapCompletionMarker, e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, i as DelegationAuthority, E as EnsureEncryptionNetworkOptions, F as FileSessionStorage, I as InvalidRestoredSessionError, M as MemorySessionStorage, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, k as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, P as PortableDelegation, R as RestorableSession, l as RuntimeDelegationActivator, m as RuntimePermissionGrantOptions, S as SecretPermissionHint, n as SecretReadInput, o as SecretReadResult, p as SignStrategy, T as TinyCloudNode, q as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, r as UnifiedOwnerRootReceipt, s as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, W as WasmKeyProvider, t as WasmKeyProviderConfig, u as activateCompactRuntimeDelegation, v as activateValidatedRuntimeDelegation, w as createWasmKeyProvider, x as defaultSignStrategy, y as deserializeDelegation, z as grantAuthRequest, G as serializeDelegation } from './core-D4IVgDr5.js';
|
|
4
4
|
import { invoke, invokeAny, computeCid, prepareSession, completeSessionSetup, ensureEip55, makeSpaceId, createDelegation, parseRecapFromSiwe, parseVerifiedRecapFromSiwe, generateHostSIWEMessage, siweToDelegationHeaders, protocolVersion, vault_encrypt, vault_decrypt, vault_derive_key, vault_x25519_from_seed, vault_x25519_dh, vault_random_bytes, vault_sha256 } from '@tinycloud/node-sdk-wasm';
|
|
5
5
|
import 'events';
|
|
6
6
|
import '@tinycloud/sdk-services';
|
|
@@ -133,6 +133,28 @@ type NodeUserAuthorizationAuthorizeFn = (input: OpenKeyBridgeInput) => Promise<{
|
|
|
133
133
|
*/
|
|
134
134
|
declare function wireOpenKeyAuthorize(openkey: OpenKeyAuthorizeTinyCloud): NodeUserAuthorizationAuthorizeFn;
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Internal helpers for TinyCloudNode.delegateTo and the legacy
|
|
138
|
+
* createDelegation compatibility shim. Exported from their own module so
|
|
139
|
+
* they are easy to unit-test without spinning up a full TinyCloudNode.
|
|
140
|
+
*
|
|
141
|
+
* None of these are part of the public API — the module path is not
|
|
142
|
+
* re-exported from `@tinycloud/node-sdk` or `@tinycloud/node-sdk/core`.
|
|
143
|
+
*
|
|
144
|
+
* @packageDocumentation
|
|
145
|
+
*/
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Extract the `expirationTime` field of a signed SIWE message as a `Date`.
|
|
149
|
+
*
|
|
150
|
+
* Returns `undefined` only when the SIWE genuinely has no `Expiration Time`
|
|
151
|
+
* line (RFC-4501 permits it). Propagates parse errors — the SDK always
|
|
152
|
+
* produces signed SIWEs during sign-in, so an unparseable `session.siwe`
|
|
153
|
+
* means something is actively wrong and we do not want to silently skip
|
|
154
|
+
* the expiry check.
|
|
155
|
+
*/
|
|
156
|
+
declare function extractSiweExpiration(siwe: string): Date | undefined;
|
|
157
|
+
|
|
136
158
|
/**
|
|
137
159
|
* NodeWasmBindings - Default IWasmBindings implementation for Node.js.
|
|
138
160
|
*
|
|
@@ -175,4 +197,4 @@ declare class NodeWasmBindings implements IWasmBindings {
|
|
|
175
197
|
createSessionManager(): ISessionManager;
|
|
176
198
|
}
|
|
177
199
|
|
|
178
|
-
export { type NodeUserAuthorizationAuthorizeFn, NodeWasmBindings, type OpenKeyAuthorizeTinyCloud, type OpenKeyBridgeInput, PrivateKeySigner, wireOpenKeyAuthorize };
|
|
200
|
+
export { type NodeUserAuthorizationAuthorizeFn, NodeWasmBindings, type OpenKeyAuthorizeTinyCloud, type OpenKeyBridgeInput, PrivateKeySigner, extractSiweExpiration, wireOpenKeyAuthorize };
|
package/dist/index.js
CHANGED
|
@@ -19371,18 +19371,23 @@ var UnsupportedSessionRestoreError = class extends Error {
|
|
|
19371
19371
|
this.name = "UnsupportedSessionRestoreError";
|
|
19372
19372
|
}
|
|
19373
19373
|
};
|
|
19374
|
+
var InvalidRestoredSessionError = class extends Error {
|
|
19375
|
+
constructor(message = "Persisted session authority is invalid or expired.") {
|
|
19376
|
+
super(message);
|
|
19377
|
+
this.code = "AUTH_EXPIRED";
|
|
19378
|
+
this.name = "InvalidRestoredSessionError";
|
|
19379
|
+
}
|
|
19380
|
+
};
|
|
19374
19381
|
function canonicalRestoredVerificationMethod(canonicalVerificationMethod, persistedVerificationMethod) {
|
|
19375
19382
|
if (typeof persistedVerificationMethod !== "string") return void 0;
|
|
19376
19383
|
const principal = canonicalVerificationMethod.split("#", 1)[0];
|
|
19377
19384
|
return persistedVerificationMethod === principal || persistedVerificationMethod === canonicalVerificationMethod ? canonicalVerificationMethod : void 0;
|
|
19378
19385
|
}
|
|
19379
19386
|
function persistedExpiry(value) {
|
|
19380
|
-
if (typeof value !== "string")
|
|
19381
|
-
throw new Error("Persisted session without a SIWE expiration must include expiresAt.");
|
|
19382
|
-
}
|
|
19387
|
+
if (typeof value !== "string") throw new InvalidRestoredSessionError("Persisted session must include expiresAt.");
|
|
19383
19388
|
const expiry = new Date(value);
|
|
19384
19389
|
if (!Number.isFinite(expiry.getTime()) || expiry.getTime() <= Date.now()) {
|
|
19385
|
-
throw new
|
|
19390
|
+
throw new InvalidRestoredSessionError();
|
|
19386
19391
|
}
|
|
19387
19392
|
return expiry;
|
|
19388
19393
|
}
|
|
@@ -20574,7 +20579,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20574
20579
|
return;
|
|
20575
20580
|
} catch (error) {
|
|
20576
20581
|
const message = error instanceof Error ? error.message : String(error);
|
|
20577
|
-
if (/Unauthorized Action|\
|
|
20582
|
+
if (/Unauthorized Action|\b(?:401|403)\b/.test(message)) {
|
|
20578
20583
|
console.warn(
|
|
20579
20584
|
"TinyCloud account registry sync stopped: authorization verdict is not retryable",
|
|
20580
20585
|
error
|
|
@@ -20824,9 +20829,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20824
20829
|
*/
|
|
20825
20830
|
async restoreSession(sessionData) {
|
|
20826
20831
|
await this.wasmBindings.ensureInitialized?.();
|
|
20827
|
-
|
|
20832
|
+
let restoredJwk;
|
|
20833
|
+
try {
|
|
20834
|
+
restoredJwk = clonePersistedSessionJwk(sessionData.jwk);
|
|
20835
|
+
} catch {
|
|
20836
|
+
throw new InvalidRestoredSessionError("Persisted session has an invalid private Ed25519 session key.");
|
|
20837
|
+
}
|
|
20828
20838
|
if (sessionData.chainId !== void 0 && (!Number.isSafeInteger(sessionData.chainId) || sessionData.chainId <= 0)) {
|
|
20829
|
-
throw new
|
|
20839
|
+
throw new InvalidRestoredSessionError("Persisted session chain ID must be a positive safe integer.");
|
|
20830
20840
|
}
|
|
20831
20841
|
const stagedManager = this.wasmBindings.createSessionManager();
|
|
20832
20842
|
const stagedReplace = stagedManager.replaceSessionKey;
|
|
@@ -20838,32 +20848,31 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20838
20848
|
let stagedKeyId;
|
|
20839
20849
|
let stagedJwk;
|
|
20840
20850
|
let canonicalVerificationMethod;
|
|
20851
|
+
const keyIds = liveKeys.call(this.sessionManager);
|
|
20852
|
+
if (!Array.isArray(keyIds) || !keyIds.every((keyId) => typeof keyId === "string")) {
|
|
20853
|
+
throw new UnsupportedSessionRestoreError("it cannot reliably enumerate every live session signer");
|
|
20854
|
+
}
|
|
20855
|
+
for (const keyId of keyIds) {
|
|
20856
|
+
if (keyId === this.sessionKeyId) continue;
|
|
20857
|
+
const jwk = this.sessionManager.jwk(keyId);
|
|
20858
|
+
if (!jwk) throw new Error("missing live session key");
|
|
20859
|
+
stagedReplace.call(stagedManager, clonePersistedSessionJwk(JSON.parse(jwk)), keyId);
|
|
20860
|
+
}
|
|
20841
20861
|
try {
|
|
20842
|
-
const keyIds = liveKeys.call(this.sessionManager);
|
|
20843
|
-
if (!Array.isArray(keyIds) || !keyIds.every((keyId) => typeof keyId === "string")) {
|
|
20844
|
-
throw new UnsupportedSessionRestoreError("it cannot reliably enumerate every live session signer");
|
|
20845
|
-
}
|
|
20846
|
-
for (const keyId of keyIds) {
|
|
20847
|
-
if (keyId === this.sessionKeyId) continue;
|
|
20848
|
-
const jwk = this.sessionManager.jwk(keyId);
|
|
20849
|
-
if (!jwk) throw new Error("missing live session key");
|
|
20850
|
-
stagedReplace.call(stagedManager, clonePersistedSessionJwk(JSON.parse(jwk)), keyId);
|
|
20851
|
-
}
|
|
20852
20862
|
stagedKeyId = stagedReplace.call(stagedManager, restoredJwk, this.sessionKeyId);
|
|
20853
|
-
|
|
20854
|
-
|
|
20855
|
-
stagedJwk = clonePersistedSessionJwk(JSON.parse(stagedJwkJson));
|
|
20856
|
-
canonicalVerificationMethod = stagedManager.getDID(stagedKeyId);
|
|
20857
|
-
} catch (error) {
|
|
20858
|
-
if (error instanceof UnsupportedSessionRestoreError) throw error;
|
|
20859
|
-
throw new Error("Persisted session has an invalid private Ed25519 session key.");
|
|
20863
|
+
} catch {
|
|
20864
|
+
throw new InvalidRestoredSessionError("Persisted session has an invalid private Ed25519 session key.");
|
|
20860
20865
|
}
|
|
20866
|
+
const stagedJwkJson = stagedManager.jwk(stagedKeyId);
|
|
20867
|
+
if (!stagedJwkJson) throw new Error("missing restored session key");
|
|
20868
|
+
stagedJwk = clonePersistedSessionJwk(JSON.parse(stagedJwkJson));
|
|
20869
|
+
canonicalVerificationMethod = stagedManager.getDID(stagedKeyId);
|
|
20861
20870
|
const restoredVerificationMethod = canonicalRestoredVerificationMethod(
|
|
20862
20871
|
canonicalVerificationMethod,
|
|
20863
20872
|
sessionData.verificationMethod
|
|
20864
20873
|
);
|
|
20865
20874
|
if (!restoredVerificationMethod) {
|
|
20866
|
-
throw new
|
|
20875
|
+
throw new InvalidRestoredSessionError(
|
|
20867
20876
|
"Persisted session verification method does not match its private Ed25519 session key."
|
|
20868
20877
|
);
|
|
20869
20878
|
}
|
|
@@ -20875,25 +20884,36 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20875
20884
|
];
|
|
20876
20885
|
const hasPersistedProof = proofValues.every((value) => value !== void 0);
|
|
20877
20886
|
if (!hasPersistedProof && (proofValues.some((value) => value !== void 0) || sessionData.expiresAt !== void 0)) {
|
|
20878
|
-
throw new
|
|
20887
|
+
throw new InvalidRestoredSessionError("Persisted session authority metadata is incomplete.");
|
|
20888
|
+
}
|
|
20889
|
+
let restoredAddress;
|
|
20890
|
+
try {
|
|
20891
|
+
restoredAddress = hasPersistedProof ? canonicalizeAddress2(sessionData.address) : void 0;
|
|
20892
|
+
} catch {
|
|
20893
|
+
throw new InvalidRestoredSessionError("Persisted session has an invalid wallet address.");
|
|
20879
20894
|
}
|
|
20880
|
-
const restoredAddress = hasPersistedProof ? canonicalizeAddress2(sessionData.address) : void 0;
|
|
20881
20895
|
let stagedSessionExpiry = /* @__PURE__ */ new Date(0);
|
|
20882
20896
|
let stagedRecap = [];
|
|
20883
20897
|
if (hasPersistedProof) {
|
|
20884
20898
|
if (typeof this.wasmBindings.validatePersistedSession !== "function") {
|
|
20885
20899
|
throw new UnsupportedSessionRestoreError("it cannot verify persisted SIWE authority");
|
|
20886
20900
|
}
|
|
20887
|
-
const verified =
|
|
20888
|
-
|
|
20889
|
-
|
|
20890
|
-
|
|
20891
|
-
|
|
20892
|
-
|
|
20893
|
-
|
|
20894
|
-
|
|
20895
|
-
|
|
20896
|
-
|
|
20901
|
+
const verified = (() => {
|
|
20902
|
+
try {
|
|
20903
|
+
return this.wasmBindings.validatePersistedSession({
|
|
20904
|
+
delegationHeader: sessionData.delegationHeader,
|
|
20905
|
+
delegationCid: sessionData.delegationCid,
|
|
20906
|
+
spaceId: sessionData.spaceId,
|
|
20907
|
+
jwk: stagedJwk,
|
|
20908
|
+
address: restoredAddress,
|
|
20909
|
+
chainId: sessionData.chainId,
|
|
20910
|
+
siwe: sessionData.siwe,
|
|
20911
|
+
signature: sessionData.signature
|
|
20912
|
+
});
|
|
20913
|
+
} catch (error) {
|
|
20914
|
+
throw new InvalidRestoredSessionError(error instanceof Error ? error.message : String(error));
|
|
20915
|
+
}
|
|
20916
|
+
})();
|
|
20897
20917
|
const exactRecap = verified.verifiedRecap;
|
|
20898
20918
|
if (!Array.isArray(exactRecap) || !exactRecap.every(
|
|
20899
20919
|
(entry) => entry !== null && typeof entry === "object" && typeof entry.service === "string" && typeof entry.space === "string" && typeof entry.path === "string" && Array.isArray(entry.actions) && entry.actions.every((action) => typeof action === "string") && Array.isArray(entry.caveats) && entry.caveats.every(
|
|
@@ -20914,7 +20934,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
20914
20934
|
const signedExpiry = verified.expiresAt === void 0 ? void 0 : persistedExpiry(verified.expiresAt);
|
|
20915
20935
|
const persistedPolicyExpiry = sessionData.expiresAt === void 0 ? void 0 : persistedExpiry(sessionData.expiresAt);
|
|
20916
20936
|
if (signedExpiry && persistedPolicyExpiry && !sameInstant(signedExpiry, persistedPolicyExpiry)) {
|
|
20917
|
-
throw new
|
|
20937
|
+
throw new InvalidRestoredSessionError("Persisted session expiry does not match its signed SIWE authority.");
|
|
20918
20938
|
}
|
|
20919
20939
|
stagedSessionExpiry = signedExpiry ?? persistedPolicyExpiry ?? persistedExpiry(void 0);
|
|
20920
20940
|
}
|
|
@@ -21107,7 +21127,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
21107
21127
|
const delegations = input.recap.map((entry) => ({
|
|
21108
21128
|
cid: session.delegationCid,
|
|
21109
21129
|
delegateDID: session.verificationMethod,
|
|
21110
|
-
spaceId: entry.space,
|
|
21130
|
+
spaceId: this.spaceIdsEqual(entry.space, session.spaceId) ? session.spaceId : entry.space,
|
|
21111
21131
|
path: entry.path,
|
|
21112
21132
|
actions: [...entry.actions],
|
|
21113
21133
|
caveats: cloneRecapCaveats(entry.caveats),
|
|
@@ -23877,21 +23897,15 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
23877
23897
|
}
|
|
23878
23898
|
return granted.spaceId !== void 0 && requested.spaceId !== void 0 && this.spaceIdsEqual(granted.spaceId, requested.spaceId) && this.pathContains(granted.path, requested.path);
|
|
23879
23899
|
}
|
|
23880
|
-
// Space IDs are `tinycloud:pkh:eip155:<chain>:<0xADDR>:<name>`.
|
|
23881
|
-
// EIP-155 address
|
|
23882
|
-
//
|
|
23883
|
-
// the EIP-55 checksummed form — so a byte-for-byte compare spuriously rejects
|
|
23884
|
-
// an otherwise-valid grant. Lowercase ONLY the `eip155:<chain>:0x<addr>`
|
|
23885
|
-
// segment and leave everything else (crucially the case-sensitive space NAME)
|
|
23886
|
-
// byte-exact. Mirrors the CLI's `normalizeSpaceForCompare` (OPENKEY_SCOPE_MISMATCH fix).
|
|
23900
|
+
// Space IDs are `tinycloud:pkh:eip155:<chain>:<0xADDR>:<name>`. Compare
|
|
23901
|
+
// only the embedded EIP-155 address without case sensitivity; chain, name,
|
|
23902
|
+
// and all non-PKH space identifiers remain byte-exact.
|
|
23887
23903
|
spaceIdsEqual(a, b) {
|
|
23888
23904
|
return this.normalizeSpaceAddress(a) === this.normalizeSpaceAddress(b);
|
|
23889
23905
|
}
|
|
23890
23906
|
normalizeSpaceAddress(space) {
|
|
23891
|
-
|
|
23892
|
-
|
|
23893
|
-
(_match, prefix, addr) => prefix + addr.toLowerCase()
|
|
23894
|
-
);
|
|
23907
|
+
const match = /^(tinycloud:pkh:eip155:\d+:)(0x[0-9a-fA-F]{40})(:.+)$/.exec(space);
|
|
23908
|
+
return match === null ? space : `${match[1]}${match[2].toLowerCase()}${match[3]}`;
|
|
23895
23909
|
}
|
|
23896
23910
|
actionContains(grantedAction, requestedAction) {
|
|
23897
23911
|
if (grantedAction === requestedAction) {
|
|
@@ -25120,6 +25134,7 @@ export {
|
|
|
25120
25134
|
FileSessionStorage,
|
|
25121
25135
|
HooksService3 as HooksService,
|
|
25122
25136
|
IdentityParseError,
|
|
25137
|
+
InvalidRestoredSessionError,
|
|
25123
25138
|
KVService3 as KVService,
|
|
25124
25139
|
ManifestValidationError,
|
|
25125
25140
|
MemorySessionStorage,
|
|
@@ -25199,6 +25214,7 @@ export {
|
|
|
25199
25214
|
expandActionShortNames,
|
|
25200
25215
|
expandPermissionEntries2 as expandPermissionEntries,
|
|
25201
25216
|
expandPermissionEntry,
|
|
25217
|
+
extractSiweExpiration,
|
|
25202
25218
|
generateRandomReceiverKey,
|
|
25203
25219
|
getTinyCloudDebugLogs,
|
|
25204
25220
|
grantAuthRequest,
|