@tinycloud/node-sdk 3.8.0-beta.10 → 3.8.0-beta.11
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/{TinyCloudNode-Dy65bxqs.d.cts → TinyCloudNode-BVDUdEcf.d.cts} +27 -2
- package/dist/{TinyCloudNode-DnD-SH6t.d.ts → TinyCloudNode-jMK_2Uj8.d.ts} +27 -2
- package/dist/{authority-Rbye1U4o.d.cts → authority-DJ-PE4Xo.d.cts} +1 -1
- package/dist/{authority-BQnTX3fI.d.ts → authority-i22vHbbp.d.ts} +1 -1
- package/dist/core.cjs +111 -7
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +109 -6
- package/dist/core.js.map +1 -1
- package/dist/encryption-keys.d.cts +1 -1
- package/dist/encryption-keys.d.ts +1 -1
- package/dist/index.cjs +65 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +65 -7
- package/dist/index.js.map +1 -1
- package/dist/replication/authority.d.cts +2 -2
- package/dist/replication/authority.d.ts +2 -2
- package/package.json +1 -1
package/dist/core.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ReplicationOptions, Manifest, PermissionEntry } from '@tinycloud/sdk-core';
|
|
2
2
|
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AccountApplication, AccountApplicationListOptions, AccountApplicationRegisterOptions, AccountDelegation, AccountDelegationListOptions, AccountDelegationRevokeOptions, AccountIndexEnsureResult, AccountIndexRebuildResult, AccountIndexStatus, AccountIndexedReadOptions, AccountService, AccountServiceConfig, AccountSpace, AccountSpaceListOptions, AccountStatus, AuthorityRefusal, AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, CallbackStrategy, CanonicalAddress, CanonicalParsedNetworkId, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, CaveatedDelegationUnsupportedError, ClientSession, ColumnInfo, ComposeManifestOptions, ComposedManifestRequest, CreateDelegationParams, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DataVaultConfig, DataVaultService, DatabaseHandle, DelegateReceivedShareParams, DelegatedShareAccess, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, DidCacheKeyOptions, DidEqualsOptions, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, EncodedShareData, ExecuteOptions, ExecuteResponse, Extension, FetchFunction, GenerateShareParams, ICapabilityKeyRegistry, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IENSResolver, IKVService, INotificationHandler, IPrefixedKVService, ISQLService, ISecretsService, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IdentityParseError, IngestOptions, InvokeFunction, JWK, KVBatchReadResponse, KVCreateSignedReadUrlOptions, KVListPage, KVReadThrough, KVReplicaHandle, KVReplicaSpec, KVReplicaStorage, KVReplicationController, KVReplicationDeps, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, LocalGetResult, LocalListResult, LocalReadMeta, LocalReplicaStatus, LocalSyncResult, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, OpenKeyCallbackStrategy, OpenKeySigningRequestBody, OpenKeySigningResponseBody, OpenKeySigningStrategyOptions, ParsedSecretCatalogKey, PendingWriteRecord, PendingWriteState, PendingWriteStore, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PinnedKey, PkhDidParts, PrefixedKVService, ProtocolMismatchError, PurgeTarget, QueryOptions, QueryResponse, ReceiveOptions, RegisterBatchSuccess, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ReplicaAuthorityState, ReplicaCoverage, ReplicaDevice, ReplicaGatedHandle, ReplicaGrantInfo, ReplicaInspectedStatus, ReplicaState, ReplicaStatusEntry, ReplicationAuthority, ReplicationControl, ReplicationEvent, ReplicationIdentity, ReplicationOptions, ReplicationPurgeReport, ReplicationReason, ReplicationScheduler, ResolvedCapabilities, ResolvedDelegate, ResolvedReplicationOptions, 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, SilentNotificationHandler, Space, SpaceAbilitiesMap, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, 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, VersionCheckError, ViewInfo, WasmVaultFunctions, addressStorageKey, buildSpaceUri, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, canonicalizeSecretScope, checkNodeInfo, clearTinyCloudDebugLogs, composeManifestRequest, createCapabilityKeyRegistry, createOpenKeyCallbackSigningStrategy, createSharingService, createSpaceService, createVaultCrypto, defaultSpaceCreationHandler, didCacheKey, didEquals, disableTinyCloudDebug, enableTinyCloudDebug, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, isCapabilitySubset, isEvmAddress, loadManifest, makePkhSpaceId, makePublicSpaceId, parseCanonicalNetworkId, parseExpiry, parsePkhDid, parseSecretCatalogKey, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveManifest, resolveSecretListPrefix, resolveSecretPath, resourceCapabilitiesToSpaceAbilitiesMap, tinyCloudDebugLogger, validateManifest } from '@tinycloud/sdk-core';
|
|
3
3
|
import { _ as __gated_network } from './gated-network-BEF2XSTC.cjs';
|
|
4
|
-
import { _ as __authority } from './authority-
|
|
4
|
+
import { _ as __authority } from './authority-DJ-PE4Xo.cjs';
|
|
5
5
|
import { _ as __runtime } from './runtime-mRhSu-vJ.cjs';
|
|
6
6
|
import { ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
|
|
7
7
|
export { F as FileSessionStorage, M as MemorySessionStorage, W as WasmKeyProvider, a as WasmKeyProviderConfig, c as createWasmKeyProvider } from './WasmKeyProvider-5Ee7fcAw.cjs';
|
|
8
|
-
export { B as BootstrapWarning, C as CreateOwnerDelegationParams, D as DelegateToOptions, a as DelegateToResult, b as DelegatedAccess, E as EnsureEncryptionNetworkOptions, I as InvalidRestoredSessionError, N as NodeEventEmitterStrategy, c as NodeUserAuthorization, d as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, R as RuntimePermissionGrantOptions, S as SecretPermissionHint,
|
|
8
|
+
export { B as BootstrapWarning, C as CreateOwnerDelegationParams, D as DelegateToOptions, a as DelegateToResult, b as DelegatedAccess, E as EnsureEncryptionNetworkOptions, I as InvalidRestoredSessionError, N as NodeEventEmitterStrategy, c as NodeUserAuthorization, d as NodeUserAuthorizationConfig, O as OpenKeyAuthorizeTinyCloud, e as OwnerDelegationReceipt, P as PreparedOpenKeyAuthorization, R as RuntimePermissionGrantOptions, S as SecretPermissionHint, f as SecretReadInput, g as SecretReadResult, h as SignStrategy, T as TinyCloudNode, i as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, j as UnifiedOwnerRootReceipt, k as UnsupportedSessionRestoreError, l as defaultSignStrategy, w as wireOpenKeyAuthorize } from './TinyCloudNode-BVDUdEcf.cjs';
|
|
9
9
|
export { C as CompactRuntimeDelegationInput, P as PortableDelegation, R as RuntimeDelegationRejectedError, a as RuntimeDelegationRejection, V as ValidatedRuntimeDelegation, b as activateCompactRuntimeDelegation, c as activateValidatedRuntimeDelegation, d as deserializeDelegation, s as serializeDelegation } from './delegation-Ckc3UETl.cjs';
|
|
10
10
|
import '@tinycloud/sdk-services';
|
|
11
11
|
import '@tinycloud/sdk-services/encryption/named-keys';
|
package/dist/core.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ReplicationOptions, Manifest, PermissionEntry } from '@tinycloud/sdk-core';
|
|
2
2
|
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AccountApplication, AccountApplicationListOptions, AccountApplicationRegisterOptions, AccountDelegation, AccountDelegationListOptions, AccountDelegationRevokeOptions, AccountIndexEnsureResult, AccountIndexRebuildResult, AccountIndexStatus, AccountIndexedReadOptions, AccountService, AccountServiceConfig, AccountSpace, AccountSpaceListOptions, AccountStatus, AuthorityRefusal, AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, CallbackStrategy, CanonicalAddress, CanonicalParsedNetworkId, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, CaveatedDelegationUnsupportedError, ClientSession, ColumnInfo, ComposeManifestOptions, ComposedManifestRequest, CreateDelegationParams, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DataVaultConfig, DataVaultService, DatabaseHandle, DelegateReceivedShareParams, DelegatedShareAccess, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, DidCacheKeyOptions, DidEqualsOptions, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, EncodedShareData, ExecuteOptions, ExecuteResponse, Extension, FetchFunction, GenerateShareParams, ICapabilityKeyRegistry, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IENSResolver, IKVService, INotificationHandler, IPrefixedKVService, ISQLService, ISecretsService, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IdentityParseError, IngestOptions, InvokeFunction, JWK, KVBatchReadResponse, KVCreateSignedReadUrlOptions, KVListPage, KVReadThrough, KVReplicaHandle, KVReplicaSpec, KVReplicaStorage, KVReplicationController, KVReplicationDeps, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, LocalGetResult, LocalListResult, LocalReadMeta, LocalReplicaStatus, LocalSyncResult, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, OpenKeyCallbackStrategy, OpenKeySigningRequestBody, OpenKeySigningResponseBody, OpenKeySigningStrategyOptions, ParsedSecretCatalogKey, PendingWriteRecord, PendingWriteState, PendingWriteStore, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PinnedKey, PkhDidParts, PrefixedKVService, ProtocolMismatchError, PurgeTarget, QueryOptions, QueryResponse, ReceiveOptions, RegisterBatchSuccess, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ReplicaAuthorityState, ReplicaCoverage, ReplicaDevice, ReplicaGatedHandle, ReplicaGrantInfo, ReplicaInspectedStatus, ReplicaState, ReplicaStatusEntry, ReplicationAuthority, ReplicationControl, ReplicationEvent, ReplicationIdentity, ReplicationOptions, ReplicationPurgeReport, ReplicationReason, ReplicationScheduler, ResolvedCapabilities, ResolvedDelegate, ResolvedReplicationOptions, 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, SilentNotificationHandler, Space, SpaceAbilitiesMap, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, 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, VersionCheckError, ViewInfo, WasmVaultFunctions, addressStorageKey, buildSpaceUri, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, canonicalizeSecretScope, checkNodeInfo, clearTinyCloudDebugLogs, composeManifestRequest, createCapabilityKeyRegistry, createOpenKeyCallbackSigningStrategy, createSharingService, createSpaceService, createVaultCrypto, defaultSpaceCreationHandler, didCacheKey, didEquals, disableTinyCloudDebug, enableTinyCloudDebug, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, isCapabilitySubset, isEvmAddress, loadManifest, makePkhSpaceId, makePublicSpaceId, parseCanonicalNetworkId, parseExpiry, parsePkhDid, parseSecretCatalogKey, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveManifest, resolveSecretListPrefix, resolveSecretPath, resourceCapabilitiesToSpaceAbilitiesMap, tinyCloudDebugLogger, validateManifest } from '@tinycloud/sdk-core';
|
|
3
3
|
import { _ as __gated_network } from './gated-network-BEF2XSTC.js';
|
|
4
|
-
import { _ as __authority } from './authority-
|
|
4
|
+
import { _ as __authority } from './authority-i22vHbbp.js';
|
|
5
5
|
import { _ as __runtime } from './runtime-CO4VXnPq.js';
|
|
6
6
|
import { ReplicaDenyInput } from '@tinycloud/sdk-services/kv/replication';
|
|
7
7
|
export { F as FileSessionStorage, M as MemorySessionStorage, W as WasmKeyProvider, a as WasmKeyProviderConfig, c as createWasmKeyProvider } from './WasmKeyProvider-5Ee7fcAw.js';
|
|
8
|
-
export { B as BootstrapWarning, C as CreateOwnerDelegationParams, D as DelegateToOptions, a as DelegateToResult, b as DelegatedAccess, E as EnsureEncryptionNetworkOptions, I as InvalidRestoredSessionError, N as NodeEventEmitterStrategy, c as NodeUserAuthorization, d as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, R as RuntimePermissionGrantOptions, S as SecretPermissionHint,
|
|
8
|
+
export { B as BootstrapWarning, C as CreateOwnerDelegationParams, D as DelegateToOptions, a as DelegateToResult, b as DelegatedAccess, E as EnsureEncryptionNetworkOptions, I as InvalidRestoredSessionError, N as NodeEventEmitterStrategy, c as NodeUserAuthorization, d as NodeUserAuthorizationConfig, O as OpenKeyAuthorizeTinyCloud, e as OwnerDelegationReceipt, P as PreparedOpenKeyAuthorization, R as RuntimePermissionGrantOptions, S as SecretPermissionHint, f as SecretReadInput, g as SecretReadResult, h as SignStrategy, T as TinyCloudNode, i as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, j as UnifiedOwnerRootReceipt, k as UnsupportedSessionRestoreError, l as defaultSignStrategy, w as wireOpenKeyAuthorize } from './TinyCloudNode-jMK_2Uj8.js';
|
|
9
9
|
export { C as CompactRuntimeDelegationInput, P as PortableDelegation, R as RuntimeDelegationRejectedError, a as RuntimeDelegationRejection, V as ValidatedRuntimeDelegation, b as activateCompactRuntimeDelegation, c as activateValidatedRuntimeDelegation, d as deserializeDelegation, s as serializeDelegation } from './delegation-Ckc3UETl.js';
|
|
10
10
|
import '@tinycloud/sdk-services';
|
|
11
11
|
import '@tinycloud/sdk-services/encryption/named-keys';
|
package/dist/core.js
CHANGED
|
@@ -436,6 +436,7 @@ function cloneAbilitiesMap(actions) {
|
|
|
436
436
|
var NodeUserAuthorization = class {
|
|
437
437
|
constructor(config) {
|
|
438
438
|
this.activeSessionKeyId = "default";
|
|
439
|
+
this.preparedSessionCounter = 0;
|
|
439
440
|
/** Incremented by resetSession; a sign-in started earlier publishes nothing. */
|
|
440
441
|
this.sessionGeneration = 0;
|
|
441
442
|
/**
|
|
@@ -1569,9 +1570,8 @@ var NodeUserAuthorization = class {
|
|
|
1569
1570
|
const address = canonicalizeAddress(await this.signer.getAddress());
|
|
1570
1571
|
const chainId = await this.signer.getChainId();
|
|
1571
1572
|
await this.refreshNamedKeyFeatureForSignIn(address, chainId);
|
|
1572
|
-
const keyId = `session-${Date.now()}`;
|
|
1573
|
-
this.sessionManager.
|
|
1574
|
-
this.activeSessionKeyId = keyId;
|
|
1573
|
+
const keyId = `openkey-session-${Date.now()}-${++this.preparedSessionCounter}`;
|
|
1574
|
+
this.sessionManager.createSessionKey(keyId);
|
|
1575
1575
|
const jwkString = this.sessionManager.jwk(keyId);
|
|
1576
1576
|
if (!jwkString) {
|
|
1577
1577
|
throw new Error("Failed to create session key");
|
|
@@ -1652,6 +1652,7 @@ var NodeUserAuthorization = class {
|
|
|
1652
1652
|
await this.sessionStorage.save(address, persistedData);
|
|
1653
1653
|
this._session = clientSession;
|
|
1654
1654
|
this._tinyCloudSession = tinyCloudSession;
|
|
1655
|
+
this.activeSessionKeyId = keyId;
|
|
1655
1656
|
this._address = address;
|
|
1656
1657
|
this._chainId = chainId;
|
|
1657
1658
|
await this.refreshNodeInfo();
|
|
@@ -1698,6 +1699,11 @@ var NodeUserAuthorization = class {
|
|
|
1698
1699
|
* @param options Optional overrides for the OpenKey request.
|
|
1699
1700
|
*/
|
|
1700
1701
|
async signInWithOpenKey(authorizeFn, options) {
|
|
1702
|
+
const pending = await this.prepareOpenKeySignIn(options);
|
|
1703
|
+
return this.completeOpenKeySignIn(pending, authorizeFn(pending.request), options);
|
|
1704
|
+
}
|
|
1705
|
+
/** Finish address, host and SIWE preparation before an approval click. */
|
|
1706
|
+
async prepareOpenKeySignIn(options) {
|
|
1701
1707
|
refuseCaveated(this.getCapabilityRequest()?.manifests);
|
|
1702
1708
|
if (options?.host !== void 0) {
|
|
1703
1709
|
const overrideHost = options.host.trim();
|
|
@@ -1709,7 +1715,7 @@ var NodeUserAuthorization = class {
|
|
|
1709
1715
|
const signingAddress = canonicalizeAddress(await this.signer.getAddress());
|
|
1710
1716
|
const signingChainId = await this.signer.getChainId();
|
|
1711
1717
|
await this.resolveTinyCloudHostsForSignIn(signingAddress, signingChainId);
|
|
1712
|
-
const { prepared, keyId, jwk } = await this.prepareSessionForSigning();
|
|
1718
|
+
const { prepared, keyId, jwk, address, chainId } = await this.prepareSessionForSigning();
|
|
1713
1719
|
const presentation = this.buildPresentationEnvelope(options?.reason);
|
|
1714
1720
|
const hostHint = this.primaryTinyCloudHost;
|
|
1715
1721
|
const originalRequest = {
|
|
@@ -1721,12 +1727,32 @@ var NodeUserAuthorization = class {
|
|
|
1721
1727
|
keyId: options?.openkeyKeyId,
|
|
1722
1728
|
presentation
|
|
1723
1729
|
};
|
|
1730
|
+
return {
|
|
1731
|
+
request: originalRequest,
|
|
1732
|
+
prepared,
|
|
1733
|
+
keyId,
|
|
1734
|
+
jwk,
|
|
1735
|
+
address,
|
|
1736
|
+
chainId,
|
|
1737
|
+
generation: this.sessionGeneration,
|
|
1738
|
+
createdAt: Date.now()
|
|
1739
|
+
};
|
|
1740
|
+
}
|
|
1741
|
+
/** Complete a prepared approval. The caller starts authorization before awaiting this method. */
|
|
1742
|
+
async completeOpenKeySignIn(pending, authorization, options) {
|
|
1743
|
+
if (Date.now() - pending.createdAt > 5 * 6e4) {
|
|
1744
|
+
throw new Error("Prepared OpenKey sign-in expired; prepare again");
|
|
1745
|
+
}
|
|
1746
|
+
if (pending.generation !== this.sessionGeneration) {
|
|
1747
|
+
throw new Error("Prepared OpenKey sign-in expired after sign-out");
|
|
1748
|
+
}
|
|
1749
|
+
const { request: originalRequest, prepared, keyId, jwk } = pending;
|
|
1724
1750
|
let result;
|
|
1725
1751
|
let signed;
|
|
1726
1752
|
let signature;
|
|
1727
1753
|
for (let attempt = 0; ; ) {
|
|
1728
1754
|
try {
|
|
1729
|
-
result ?? (result = await
|
|
1755
|
+
result ?? (result = await authorization);
|
|
1730
1756
|
signed = await this.verifyOpenKeyResult(result, prepared);
|
|
1731
1757
|
signature = result.signature;
|
|
1732
1758
|
break;
|
|
@@ -2147,6 +2173,50 @@ var NodeUserAuthorization = class {
|
|
|
2147
2173
|
}
|
|
2148
2174
|
};
|
|
2149
2175
|
|
|
2176
|
+
// src/authorization/openKeyBridge.ts
|
|
2177
|
+
function wireOpenKeyAuthorize(openkey, opts) {
|
|
2178
|
+
return async (input) => {
|
|
2179
|
+
const result = await openkey.authorizeTinyCloud({
|
|
2180
|
+
protocolVersion: 1,
|
|
2181
|
+
siwe: input.siwe,
|
|
2182
|
+
keyId: input.keyId,
|
|
2183
|
+
jwk: input.jwk,
|
|
2184
|
+
host: input.host,
|
|
2185
|
+
// Forward the presentation envelope verbatim — the OpenKey SDK
|
|
2186
|
+
// validates and size-bounds it before use.
|
|
2187
|
+
presentation: input.presentation
|
|
2188
|
+
}, opts);
|
|
2189
|
+
if (result.protocolVersion !== 1) {
|
|
2190
|
+
throw new Error(
|
|
2191
|
+
`wireOpenKeyAuthorize: OpenKey returned unsupported protocolVersion ${result.protocolVersion}`
|
|
2192
|
+
);
|
|
2193
|
+
}
|
|
2194
|
+
if (typeof result.signedMessage !== "string" || !result.signedMessage) {
|
|
2195
|
+
throw new Error(
|
|
2196
|
+
"wireOpenKeyAuthorize: OpenKey returned no signedMessage \u2014 cannot complete a TinyCloud session"
|
|
2197
|
+
);
|
|
2198
|
+
}
|
|
2199
|
+
if (!Array.isArray(result.selectedActionKeys)) {
|
|
2200
|
+
throw new Error(
|
|
2201
|
+
"wireOpenKeyAuthorize: OpenKey returned no selectedActionKeys"
|
|
2202
|
+
);
|
|
2203
|
+
}
|
|
2204
|
+
if (!Array.isArray(result.permissions)) {
|
|
2205
|
+
throw new Error(
|
|
2206
|
+
"wireOpenKeyAuthorize: OpenKey returned no permissions"
|
|
2207
|
+
);
|
|
2208
|
+
}
|
|
2209
|
+
return {
|
|
2210
|
+
protocolVersion: 1,
|
|
2211
|
+
address: result.address,
|
|
2212
|
+
signature: result.signature,
|
|
2213
|
+
signedMessage: result.signedMessage,
|
|
2214
|
+
selectedActionKeys: result.selectedActionKeys,
|
|
2215
|
+
permissions: result.permissions
|
|
2216
|
+
};
|
|
2217
|
+
};
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2150
2220
|
// src/recordingServiceContext.ts
|
|
2151
2221
|
import {
|
|
2152
2222
|
ServiceContext
|
|
@@ -3871,6 +3941,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3871
3941
|
constructor(config = {}) {
|
|
3872
3942
|
this.signer = null;
|
|
3873
3943
|
this.auth = null;
|
|
3944
|
+
this.consumedOpenKeyPendings = /* @__PURE__ */ new WeakSet();
|
|
3874
3945
|
this.tc = null;
|
|
3875
3946
|
this._chainId = 1;
|
|
3876
3947
|
this.replicaPurgeFailedHandlers = /* @__PURE__ */ new Set();
|
|
@@ -4811,6 +4882,37 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4811
4882
|
}
|
|
4812
4883
|
await this.signInWith(() => this.auth.signInWithOpenKey(authorizeFn, options));
|
|
4813
4884
|
}
|
|
4885
|
+
/** Prepare the OpenKey request before the approval click. */
|
|
4886
|
+
async prepareOpenKeySignIn() {
|
|
4887
|
+
if (!this.signer || !this.tc || !this.auth) {
|
|
4888
|
+
throw new Error("Cannot prepare OpenKey sign-in in session-only mode. Provide a signer in config.");
|
|
4889
|
+
}
|
|
4890
|
+
await this.signOutInFlight;
|
|
4891
|
+
await this.accountRegistryTail;
|
|
4892
|
+
await this.wasmBindings.ensureInitialized?.();
|
|
4893
|
+
return this.auth.prepareOpenKeySignIn();
|
|
4894
|
+
}
|
|
4895
|
+
/** Start OpenKey authorization synchronously, then complete normal session setup. */
|
|
4896
|
+
signInWithPreparedOpenKey(pending, authorizeFn) {
|
|
4897
|
+
if (!this.signer || !this.tc || !this.auth || this.signOutInFlight) {
|
|
4898
|
+
throw new Error("Prepared OpenKey sign-in is unavailable");
|
|
4899
|
+
}
|
|
4900
|
+
if (this.consumedOpenKeyPendings.has(pending)) {
|
|
4901
|
+
throw new Error("Prepared OpenKey sign-in was already used");
|
|
4902
|
+
}
|
|
4903
|
+
if (Date.now() - pending.createdAt > 5 * 6e4) {
|
|
4904
|
+
throw new Error("Prepared OpenKey sign-in expired; prepare again");
|
|
4905
|
+
}
|
|
4906
|
+
this.consumedOpenKeyPendings.add(pending);
|
|
4907
|
+
const authorization = authorizeFn(pending.request);
|
|
4908
|
+
void authorization.catch(() => void 0);
|
|
4909
|
+
return this.signInWith(() => {
|
|
4910
|
+
if (this._address !== pending.address || this._chainId !== pending.chainId) {
|
|
4911
|
+
throw new Error("OpenKey account changed after sign-in preparation");
|
|
4912
|
+
}
|
|
4913
|
+
return this.auth.completeOpenKeySignIn(pending, authorization);
|
|
4914
|
+
});
|
|
4915
|
+
}
|
|
4814
4916
|
async signInWith(performSignIn) {
|
|
4815
4917
|
refuseCaveated(this.auth?.capabilityRequest?.manifests);
|
|
4816
4918
|
const epoch = this.sessionEpoch;
|
|
@@ -10340,6 +10442,7 @@ export {
|
|
|
10340
10442
|
resourceCapabilitiesToSpaceAbilitiesMap2 as resourceCapabilitiesToSpaceAbilitiesMap,
|
|
10341
10443
|
serializeDelegation,
|
|
10342
10444
|
tinyCloudDebugLogger2 as tinyCloudDebugLogger,
|
|
10343
|
-
validateManifest
|
|
10445
|
+
validateManifest,
|
|
10446
|
+
wireOpenKeyAuthorize
|
|
10344
10447
|
};
|
|
10345
10448
|
//# sourceMappingURL=core.js.map
|