@anywalletkit/extension-kit 0.1.3 → 0.1.5
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/README.md +7 -4
- package/dist/index.cjs +11 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -5
- package/dist/index.d.ts +27 -5
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
package/dist/index.d.cts
CHANGED
|
@@ -188,7 +188,7 @@ declare class Vault {
|
|
|
188
188
|
* Register a passkey as a second unlock path: the DEK (from the unlocked session)
|
|
189
189
|
* is sealed under HKDF-SHA256(`prf`, salt = credential id). The password stays
|
|
190
190
|
* the recovery path; `prf` is zeroized here. A v1 envelope must be unlocked (and
|
|
191
|
-
* thereby upgraded) first.
|
|
191
|
+
* thereby upgraded) first, and the vault must hold a secret (it proves the DEK).
|
|
192
192
|
*/
|
|
193
193
|
addPasskey(dek: Uint8Array, passkey: {
|
|
194
194
|
id: string;
|
|
@@ -215,7 +215,10 @@ declare class Vault {
|
|
|
215
215
|
private _random;
|
|
216
216
|
/** A fresh envelope (v2 by default, v1 with `kdf: 'pbkdf2'`) wrapping `dek` under `password`. */
|
|
217
217
|
private _sealEnvelope;
|
|
218
|
-
/**
|
|
218
|
+
/**
|
|
219
|
+
* The caller's DEK must open this envelope's secrets — it is the key the password protects, not
|
|
220
|
+
* any 32 bytes. An empty vault has nothing to prove it with, so it is refused rather than trusted.
|
|
221
|
+
*/
|
|
219
222
|
private _requireDek;
|
|
220
223
|
private _derivePbkdf2;
|
|
221
224
|
private _deriveScrypt;
|
|
@@ -408,6 +411,25 @@ declare function isRelayRequest(x: unknown): x is RelayRequest;
|
|
|
408
411
|
declare function isRelayToContent(x: unknown): x is RelayToContent;
|
|
409
412
|
declare function newRequestId(): string;
|
|
410
413
|
/** The content script's stamp: {@link PageRequest} + the page origin. */
|
|
414
|
+
/** What a content script's `message` listener receives (structural `MessageEvent`). */
|
|
415
|
+
interface PageMessageEvent {
|
|
416
|
+
data: unknown;
|
|
417
|
+
origin: string;
|
|
418
|
+
source: unknown;
|
|
419
|
+
}
|
|
420
|
+
/** The page window the content script shares (structural `window`). */
|
|
421
|
+
interface PageWindow {
|
|
422
|
+
location: {
|
|
423
|
+
origin: string;
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* The page's own request, or `null`. A content script must take only messages the page itself
|
|
428
|
+
* posted — `event.source` is the page window and `event.origin` its origin — or an iframe on the
|
|
429
|
+
* page (an ad, an embed) would have its `parent.postMessage` stamped with the site's origin and
|
|
430
|
+
* shown in the approval window as the site (round 3, H6).
|
|
431
|
+
*/
|
|
432
|
+
declare function pageRequestFrom(event: PageMessageEvent, page: PageWindow): PageRequest | null;
|
|
411
433
|
declare function stampOrigin(request: PageRequest, origin: string): RelayRequest;
|
|
412
434
|
/** What `port.sender` looks like (structural `chrome.runtime.MessageSender`). */
|
|
413
435
|
interface PortSender {
|
|
@@ -1365,14 +1387,14 @@ interface TonAddressParts {
|
|
|
1365
1387
|
workchain: number;
|
|
1366
1388
|
hash: Uint8Array;
|
|
1367
1389
|
}
|
|
1368
|
-
/** The
|
|
1390
|
+
/** The 32-byte digest a wallet signs for `ton_proof` — to verify a proof; sign with `WalletAccountTon.signTonProof`. */
|
|
1369
1391
|
declare function tonProofMessage(input: {
|
|
1370
1392
|
address: TonAddressParts;
|
|
1371
1393
|
domain: string;
|
|
1372
1394
|
timestamp: number;
|
|
1373
1395
|
payload: string;
|
|
1374
1396
|
}): Uint8Array;
|
|
1375
|
-
/** The
|
|
1397
|
+
/** The 32-byte digest a wallet signs for `signData` (text / binary) — to verify; sign with `WalletAccountTon.signTonConnectData`. */
|
|
1376
1398
|
declare function tonSignDataMessage(input: {
|
|
1377
1399
|
address: TonAddressParts;
|
|
1378
1400
|
domain: string;
|
|
@@ -1514,4 +1536,4 @@ declare class RecipientBook {
|
|
|
1514
1536
|
}>;
|
|
1515
1537
|
}
|
|
1516
1538
|
|
|
1517
|
-
export { ACTIVE_STATUSES, APPROVALS_MAX_PENDING_PER_ORIGIN, type AddChainApproval, type AlarmsLike, type ApprovalKind, ApprovalQueue, type ApprovalQueueOptions, type ApprovalRequest, type ApprovalWindow, type AssertionExpectations, type AssertionInput, type AssertionVerdict, BTC_CHAIN, BTC_ESPLORA, CHAIN_ACCOUNT_KEYS, type ChainAccountsKey, type ChainDescriptor, type ConnectApproval, DEFAULT_CHAIN, DEFAULT_NETWORKS, type EarnApproval, type EarnPlan, type EarnReviewMeta, type EarnTx, type EvmNetwork, type EvmSigner, FLOOR_TOLERANCE_BPS, type GateMatcher, type GatedOp, type HostCheck, type JsonStorage, KEYRING_STORAGE_KEY, LOOKALIKE_PREFIX, LOOKALIKE_SUFFIX, NEAR_CHAIN, NEAR_PROVIDERS, NON_EVM_CHAINS, NetworksTable, type OriginPermission, type OriginVia, PAGE_TARGET, PORT_NAME, type PageEvent, type PageRequest, type PageResponse, PermissionStore, type PermissionsState, PhishingDetector, type PhishingList, type PortSender, type PreparedTx, QueueLimitError, type QuoteRoutesOptions, READ_METHODS, RELAY_ERRORS, RecipientBook, type RecipientsState, type RelayChain, type RelayError, type RelayErrorOptions, type RelayEvent, type RelayRequest, type RelayResponse, type RelayToContent, type RelayToWorker, RequestRouter, ReviewDeclined, ReviewGate, type RouteListView, type RouteView, type RouterDeps, RouterError, SESSION_DEFAULT_AUTOLOCK_MS, SIGNING_METHODS, SOLANA_CHAIN, SOLANA_RPCS, type SealedBox, Session, type SessionAlarms, type SessionOptions, type SessionStorage, type SignApproval, type SignDeps, type SignRequestInfo, type SiweContext, type SiweInfo, type SiweMessage, type StorageAreaLike, type SwapApproval, type SwapRecord, type SwapRecordStatus, type SwapReviewMeta, SwapTracker, type SwapTrackerDeps, SwapsStore, type SwitchChainApproval, TONCONNECT_ERRORS, TONCONNECT_MAX_MESSAGES, TON_CHAIN, TON_ENDPOINTS, TRON_CHAIN, TRON_PROVIDERS, type TonAddressParts, TonConnectError, type TonConnectMessage, type TonConnectRequest, type TonConnectSendTransaction, type TonSignDataPayload, type TypedData, VAULT_DEFAULT_ITERATIONS, VAULT_LIMITS, VAULT_MIN_ITERATIONS, VAULT_MIN_PASSWORD_LENGTH, VAULT_MIN_SCRYPT, VAULT_SCRYPT, VAULT_STORAGE_KEY, Vault, type VaultEnvelope, type VaultEnvelopeV1, type VaultEnvelopeV2, VaultError, type VaultErrorCode, type VaultKdfInfo, type VaultOptions, type VaultPasskey, type VaultStorage, ZCASH_BLOCKCHAIR, ZCASH_CHAIN, approvalChallenge, caip2FromChainId, chainHex, chainTxMatcher, checkSenderOrigin, chromeAlarms, chromeJsonStorage, chromeKeyringStorage, chromeLocalVaultStorage, chromeSessionStorage, classifySignRequest, createSignHandler, decodedMessage, derToRaw, describeSiwe, earnApprovalPayload, earnPlanMatchers, encodeApproveCalldata, evmCallMatcher, executionFloor, fromBase64Url, hostOf, isCatalogChain, isEnvelopeV1, isEnvelopeV2, isLocalHost, isPageEvent, isPageRequest, isPageResponse, isRelayRequest, isRelayToContent, levenshtein, lookalikeOf, memoryAlarms, memoryApprovalWindow, memoryJsonStorage, memorySessionStorage, memoryVaultStorage, messageText, newRequestId, nonEvmChain, normalizeHost, parseAddChainParams, parseConnectRequest, parseRawAddress, parseSendTransaction, parseSignData, parseSiwe, parseSwapId, planMatchers, prepareTransaction, proofDomain, quoteRoutes, rank, rawToDer, relayError, reviewEarnPlan, reviewSwapPlan, siweProblems, stampOrigin, swapApprovalPayload, toBase64Url, toRelayError, tonConnectErrorCode, tonProofMessage, tonSignDataMessage, vaultSecretStorage, verifyAssertion };
|
|
1539
|
+
export { ACTIVE_STATUSES, APPROVALS_MAX_PENDING_PER_ORIGIN, type AddChainApproval, type AlarmsLike, type ApprovalKind, ApprovalQueue, type ApprovalQueueOptions, type ApprovalRequest, type ApprovalWindow, type AssertionExpectations, type AssertionInput, type AssertionVerdict, BTC_CHAIN, BTC_ESPLORA, CHAIN_ACCOUNT_KEYS, type ChainAccountsKey, type ChainDescriptor, type ConnectApproval, DEFAULT_CHAIN, DEFAULT_NETWORKS, type EarnApproval, type EarnPlan, type EarnReviewMeta, type EarnTx, type EvmNetwork, type EvmSigner, FLOOR_TOLERANCE_BPS, type GateMatcher, type GatedOp, type HostCheck, type JsonStorage, KEYRING_STORAGE_KEY, LOOKALIKE_PREFIX, LOOKALIKE_SUFFIX, NEAR_CHAIN, NEAR_PROVIDERS, NON_EVM_CHAINS, NetworksTable, type OriginPermission, type OriginVia, PAGE_TARGET, PORT_NAME, type PageEvent, type PageMessageEvent, type PageRequest, type PageResponse, type PageWindow, PermissionStore, type PermissionsState, PhishingDetector, type PhishingList, type PortSender, type PreparedTx, QueueLimitError, type QuoteRoutesOptions, READ_METHODS, RELAY_ERRORS, RecipientBook, type RecipientsState, type RelayChain, type RelayError, type RelayErrorOptions, type RelayEvent, type RelayRequest, type RelayResponse, type RelayToContent, type RelayToWorker, RequestRouter, ReviewDeclined, ReviewGate, type RouteListView, type RouteView, type RouterDeps, RouterError, SESSION_DEFAULT_AUTOLOCK_MS, SIGNING_METHODS, SOLANA_CHAIN, SOLANA_RPCS, type SealedBox, Session, type SessionAlarms, type SessionOptions, type SessionStorage, type SignApproval, type SignDeps, type SignRequestInfo, type SiweContext, type SiweInfo, type SiweMessage, type StorageAreaLike, type SwapApproval, type SwapRecord, type SwapRecordStatus, type SwapReviewMeta, SwapTracker, type SwapTrackerDeps, SwapsStore, type SwitchChainApproval, TONCONNECT_ERRORS, TONCONNECT_MAX_MESSAGES, TON_CHAIN, TON_ENDPOINTS, TRON_CHAIN, TRON_PROVIDERS, type TonAddressParts, TonConnectError, type TonConnectMessage, type TonConnectRequest, type TonConnectSendTransaction, type TonSignDataPayload, type TypedData, VAULT_DEFAULT_ITERATIONS, VAULT_LIMITS, VAULT_MIN_ITERATIONS, VAULT_MIN_PASSWORD_LENGTH, VAULT_MIN_SCRYPT, VAULT_SCRYPT, VAULT_STORAGE_KEY, Vault, type VaultEnvelope, type VaultEnvelopeV1, type VaultEnvelopeV2, VaultError, type VaultErrorCode, type VaultKdfInfo, type VaultOptions, type VaultPasskey, type VaultStorage, ZCASH_BLOCKCHAIR, ZCASH_CHAIN, approvalChallenge, caip2FromChainId, chainHex, chainTxMatcher, checkSenderOrigin, chromeAlarms, chromeJsonStorage, chromeKeyringStorage, chromeLocalVaultStorage, chromeSessionStorage, classifySignRequest, createSignHandler, decodedMessage, derToRaw, describeSiwe, earnApprovalPayload, earnPlanMatchers, encodeApproveCalldata, evmCallMatcher, executionFloor, fromBase64Url, hostOf, isCatalogChain, isEnvelopeV1, isEnvelopeV2, isLocalHost, isPageEvent, isPageRequest, isPageResponse, isRelayRequest, isRelayToContent, levenshtein, lookalikeOf, memoryAlarms, memoryApprovalWindow, memoryJsonStorage, memorySessionStorage, memoryVaultStorage, messageText, newRequestId, nonEvmChain, normalizeHost, pageRequestFrom, parseAddChainParams, parseConnectRequest, parseRawAddress, parseSendTransaction, parseSignData, parseSiwe, parseSwapId, planMatchers, prepareTransaction, proofDomain, quoteRoutes, rank, rawToDer, relayError, reviewEarnPlan, reviewSwapPlan, siweProblems, stampOrigin, swapApprovalPayload, toBase64Url, toRelayError, tonConnectErrorCode, tonProofMessage, tonSignDataMessage, vaultSecretStorage, verifyAssertion };
|
package/dist/index.d.ts
CHANGED
|
@@ -188,7 +188,7 @@ declare class Vault {
|
|
|
188
188
|
* Register a passkey as a second unlock path: the DEK (from the unlocked session)
|
|
189
189
|
* is sealed under HKDF-SHA256(`prf`, salt = credential id). The password stays
|
|
190
190
|
* the recovery path; `prf` is zeroized here. A v1 envelope must be unlocked (and
|
|
191
|
-
* thereby upgraded) first.
|
|
191
|
+
* thereby upgraded) first, and the vault must hold a secret (it proves the DEK).
|
|
192
192
|
*/
|
|
193
193
|
addPasskey(dek: Uint8Array, passkey: {
|
|
194
194
|
id: string;
|
|
@@ -215,7 +215,10 @@ declare class Vault {
|
|
|
215
215
|
private _random;
|
|
216
216
|
/** A fresh envelope (v2 by default, v1 with `kdf: 'pbkdf2'`) wrapping `dek` under `password`. */
|
|
217
217
|
private _sealEnvelope;
|
|
218
|
-
/**
|
|
218
|
+
/**
|
|
219
|
+
* The caller's DEK must open this envelope's secrets — it is the key the password protects, not
|
|
220
|
+
* any 32 bytes. An empty vault has nothing to prove it with, so it is refused rather than trusted.
|
|
221
|
+
*/
|
|
219
222
|
private _requireDek;
|
|
220
223
|
private _derivePbkdf2;
|
|
221
224
|
private _deriveScrypt;
|
|
@@ -408,6 +411,25 @@ declare function isRelayRequest(x: unknown): x is RelayRequest;
|
|
|
408
411
|
declare function isRelayToContent(x: unknown): x is RelayToContent;
|
|
409
412
|
declare function newRequestId(): string;
|
|
410
413
|
/** The content script's stamp: {@link PageRequest} + the page origin. */
|
|
414
|
+
/** What a content script's `message` listener receives (structural `MessageEvent`). */
|
|
415
|
+
interface PageMessageEvent {
|
|
416
|
+
data: unknown;
|
|
417
|
+
origin: string;
|
|
418
|
+
source: unknown;
|
|
419
|
+
}
|
|
420
|
+
/** The page window the content script shares (structural `window`). */
|
|
421
|
+
interface PageWindow {
|
|
422
|
+
location: {
|
|
423
|
+
origin: string;
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* The page's own request, or `null`. A content script must take only messages the page itself
|
|
428
|
+
* posted — `event.source` is the page window and `event.origin` its origin — or an iframe on the
|
|
429
|
+
* page (an ad, an embed) would have its `parent.postMessage` stamped with the site's origin and
|
|
430
|
+
* shown in the approval window as the site (round 3, H6).
|
|
431
|
+
*/
|
|
432
|
+
declare function pageRequestFrom(event: PageMessageEvent, page: PageWindow): PageRequest | null;
|
|
411
433
|
declare function stampOrigin(request: PageRequest, origin: string): RelayRequest;
|
|
412
434
|
/** What `port.sender` looks like (structural `chrome.runtime.MessageSender`). */
|
|
413
435
|
interface PortSender {
|
|
@@ -1365,14 +1387,14 @@ interface TonAddressParts {
|
|
|
1365
1387
|
workchain: number;
|
|
1366
1388
|
hash: Uint8Array;
|
|
1367
1389
|
}
|
|
1368
|
-
/** The
|
|
1390
|
+
/** The 32-byte digest a wallet signs for `ton_proof` — to verify a proof; sign with `WalletAccountTon.signTonProof`. */
|
|
1369
1391
|
declare function tonProofMessage(input: {
|
|
1370
1392
|
address: TonAddressParts;
|
|
1371
1393
|
domain: string;
|
|
1372
1394
|
timestamp: number;
|
|
1373
1395
|
payload: string;
|
|
1374
1396
|
}): Uint8Array;
|
|
1375
|
-
/** The
|
|
1397
|
+
/** The 32-byte digest a wallet signs for `signData` (text / binary) — to verify; sign with `WalletAccountTon.signTonConnectData`. */
|
|
1376
1398
|
declare function tonSignDataMessage(input: {
|
|
1377
1399
|
address: TonAddressParts;
|
|
1378
1400
|
domain: string;
|
|
@@ -1514,4 +1536,4 @@ declare class RecipientBook {
|
|
|
1514
1536
|
}>;
|
|
1515
1537
|
}
|
|
1516
1538
|
|
|
1517
|
-
export { ACTIVE_STATUSES, APPROVALS_MAX_PENDING_PER_ORIGIN, type AddChainApproval, type AlarmsLike, type ApprovalKind, ApprovalQueue, type ApprovalQueueOptions, type ApprovalRequest, type ApprovalWindow, type AssertionExpectations, type AssertionInput, type AssertionVerdict, BTC_CHAIN, BTC_ESPLORA, CHAIN_ACCOUNT_KEYS, type ChainAccountsKey, type ChainDescriptor, type ConnectApproval, DEFAULT_CHAIN, DEFAULT_NETWORKS, type EarnApproval, type EarnPlan, type EarnReviewMeta, type EarnTx, type EvmNetwork, type EvmSigner, FLOOR_TOLERANCE_BPS, type GateMatcher, type GatedOp, type HostCheck, type JsonStorage, KEYRING_STORAGE_KEY, LOOKALIKE_PREFIX, LOOKALIKE_SUFFIX, NEAR_CHAIN, NEAR_PROVIDERS, NON_EVM_CHAINS, NetworksTable, type OriginPermission, type OriginVia, PAGE_TARGET, PORT_NAME, type PageEvent, type PageRequest, type PageResponse, PermissionStore, type PermissionsState, PhishingDetector, type PhishingList, type PortSender, type PreparedTx, QueueLimitError, type QuoteRoutesOptions, READ_METHODS, RELAY_ERRORS, RecipientBook, type RecipientsState, type RelayChain, type RelayError, type RelayErrorOptions, type RelayEvent, type RelayRequest, type RelayResponse, type RelayToContent, type RelayToWorker, RequestRouter, ReviewDeclined, ReviewGate, type RouteListView, type RouteView, type RouterDeps, RouterError, SESSION_DEFAULT_AUTOLOCK_MS, SIGNING_METHODS, SOLANA_CHAIN, SOLANA_RPCS, type SealedBox, Session, type SessionAlarms, type SessionOptions, type SessionStorage, type SignApproval, type SignDeps, type SignRequestInfo, type SiweContext, type SiweInfo, type SiweMessage, type StorageAreaLike, type SwapApproval, type SwapRecord, type SwapRecordStatus, type SwapReviewMeta, SwapTracker, type SwapTrackerDeps, SwapsStore, type SwitchChainApproval, TONCONNECT_ERRORS, TONCONNECT_MAX_MESSAGES, TON_CHAIN, TON_ENDPOINTS, TRON_CHAIN, TRON_PROVIDERS, type TonAddressParts, TonConnectError, type TonConnectMessage, type TonConnectRequest, type TonConnectSendTransaction, type TonSignDataPayload, type TypedData, VAULT_DEFAULT_ITERATIONS, VAULT_LIMITS, VAULT_MIN_ITERATIONS, VAULT_MIN_PASSWORD_LENGTH, VAULT_MIN_SCRYPT, VAULT_SCRYPT, VAULT_STORAGE_KEY, Vault, type VaultEnvelope, type VaultEnvelopeV1, type VaultEnvelopeV2, VaultError, type VaultErrorCode, type VaultKdfInfo, type VaultOptions, type VaultPasskey, type VaultStorage, ZCASH_BLOCKCHAIR, ZCASH_CHAIN, approvalChallenge, caip2FromChainId, chainHex, chainTxMatcher, checkSenderOrigin, chromeAlarms, chromeJsonStorage, chromeKeyringStorage, chromeLocalVaultStorage, chromeSessionStorage, classifySignRequest, createSignHandler, decodedMessage, derToRaw, describeSiwe, earnApprovalPayload, earnPlanMatchers, encodeApproveCalldata, evmCallMatcher, executionFloor, fromBase64Url, hostOf, isCatalogChain, isEnvelopeV1, isEnvelopeV2, isLocalHost, isPageEvent, isPageRequest, isPageResponse, isRelayRequest, isRelayToContent, levenshtein, lookalikeOf, memoryAlarms, memoryApprovalWindow, memoryJsonStorage, memorySessionStorage, memoryVaultStorage, messageText, newRequestId, nonEvmChain, normalizeHost, parseAddChainParams, parseConnectRequest, parseRawAddress, parseSendTransaction, parseSignData, parseSiwe, parseSwapId, planMatchers, prepareTransaction, proofDomain, quoteRoutes, rank, rawToDer, relayError, reviewEarnPlan, reviewSwapPlan, siweProblems, stampOrigin, swapApprovalPayload, toBase64Url, toRelayError, tonConnectErrorCode, tonProofMessage, tonSignDataMessage, vaultSecretStorage, verifyAssertion };
|
|
1539
|
+
export { ACTIVE_STATUSES, APPROVALS_MAX_PENDING_PER_ORIGIN, type AddChainApproval, type AlarmsLike, type ApprovalKind, ApprovalQueue, type ApprovalQueueOptions, type ApprovalRequest, type ApprovalWindow, type AssertionExpectations, type AssertionInput, type AssertionVerdict, BTC_CHAIN, BTC_ESPLORA, CHAIN_ACCOUNT_KEYS, type ChainAccountsKey, type ChainDescriptor, type ConnectApproval, DEFAULT_CHAIN, DEFAULT_NETWORKS, type EarnApproval, type EarnPlan, type EarnReviewMeta, type EarnTx, type EvmNetwork, type EvmSigner, FLOOR_TOLERANCE_BPS, type GateMatcher, type GatedOp, type HostCheck, type JsonStorage, KEYRING_STORAGE_KEY, LOOKALIKE_PREFIX, LOOKALIKE_SUFFIX, NEAR_CHAIN, NEAR_PROVIDERS, NON_EVM_CHAINS, NetworksTable, type OriginPermission, type OriginVia, PAGE_TARGET, PORT_NAME, type PageEvent, type PageMessageEvent, type PageRequest, type PageResponse, type PageWindow, PermissionStore, type PermissionsState, PhishingDetector, type PhishingList, type PortSender, type PreparedTx, QueueLimitError, type QuoteRoutesOptions, READ_METHODS, RELAY_ERRORS, RecipientBook, type RecipientsState, type RelayChain, type RelayError, type RelayErrorOptions, type RelayEvent, type RelayRequest, type RelayResponse, type RelayToContent, type RelayToWorker, RequestRouter, ReviewDeclined, ReviewGate, type RouteListView, type RouteView, type RouterDeps, RouterError, SESSION_DEFAULT_AUTOLOCK_MS, SIGNING_METHODS, SOLANA_CHAIN, SOLANA_RPCS, type SealedBox, Session, type SessionAlarms, type SessionOptions, type SessionStorage, type SignApproval, type SignDeps, type SignRequestInfo, type SiweContext, type SiweInfo, type SiweMessage, type StorageAreaLike, type SwapApproval, type SwapRecord, type SwapRecordStatus, type SwapReviewMeta, SwapTracker, type SwapTrackerDeps, SwapsStore, type SwitchChainApproval, TONCONNECT_ERRORS, TONCONNECT_MAX_MESSAGES, TON_CHAIN, TON_ENDPOINTS, TRON_CHAIN, TRON_PROVIDERS, type TonAddressParts, TonConnectError, type TonConnectMessage, type TonConnectRequest, type TonConnectSendTransaction, type TonSignDataPayload, type TypedData, VAULT_DEFAULT_ITERATIONS, VAULT_LIMITS, VAULT_MIN_ITERATIONS, VAULT_MIN_PASSWORD_LENGTH, VAULT_MIN_SCRYPT, VAULT_SCRYPT, VAULT_STORAGE_KEY, Vault, type VaultEnvelope, type VaultEnvelopeV1, type VaultEnvelopeV2, VaultError, type VaultErrorCode, type VaultKdfInfo, type VaultOptions, type VaultPasskey, type VaultStorage, ZCASH_BLOCKCHAIR, ZCASH_CHAIN, approvalChallenge, caip2FromChainId, chainHex, chainTxMatcher, checkSenderOrigin, chromeAlarms, chromeJsonStorage, chromeKeyringStorage, chromeLocalVaultStorage, chromeSessionStorage, classifySignRequest, createSignHandler, decodedMessage, derToRaw, describeSiwe, earnApprovalPayload, earnPlanMatchers, encodeApproveCalldata, evmCallMatcher, executionFloor, fromBase64Url, hostOf, isCatalogChain, isEnvelopeV1, isEnvelopeV2, isLocalHost, isPageEvent, isPageRequest, isPageResponse, isRelayRequest, isRelayToContent, levenshtein, lookalikeOf, memoryAlarms, memoryApprovalWindow, memoryJsonStorage, memorySessionStorage, memoryVaultStorage, messageText, newRequestId, nonEvmChain, normalizeHost, pageRequestFrom, parseAddChainParams, parseConnectRequest, parseRawAddress, parseSendTransaction, parseSignData, parseSiwe, parseSwapId, planMatchers, prepareTransaction, proofDomain, quoteRoutes, rank, rawToDer, relayError, reviewEarnPlan, reviewSwapPlan, siweProblems, stampOrigin, swapApprovalPayload, toBase64Url, toRelayError, tonConnectErrorCode, tonProofMessage, tonSignDataMessage, vaultSecretStorage, verifyAssertion };
|
package/dist/index.js
CHANGED
|
@@ -170,7 +170,7 @@ var Vault = class {
|
|
|
170
170
|
* Register a passkey as a second unlock path: the DEK (from the unlocked session)
|
|
171
171
|
* is sealed under HKDF-SHA256(`prf`, salt = credential id). The password stays
|
|
172
172
|
* the recovery path; `prf` is zeroized here. A v1 envelope must be unlocked (and
|
|
173
|
-
* thereby upgraded) first.
|
|
173
|
+
* thereby upgraded) first, and the vault must hold a secret (it proves the DEK).
|
|
174
174
|
*/
|
|
175
175
|
async addPasskey(dek, passkey) {
|
|
176
176
|
try {
|
|
@@ -287,11 +287,14 @@ var Vault = class {
|
|
|
287
287
|
const kek = await this._deriveScrypt(password, salt, kdf);
|
|
288
288
|
return { v: 2, kdf, dek: await this._seal(kek, dek, aadDekV2(kdf)), secrets, passkeys, createdAt };
|
|
289
289
|
}
|
|
290
|
-
/**
|
|
290
|
+
/**
|
|
291
|
+
* The caller's DEK must open this envelope's secrets — it is the key the password protects, not
|
|
292
|
+
* any 32 bytes. An empty vault has nothing to prove it with, so it is refused rather than trusted.
|
|
293
|
+
*/
|
|
291
294
|
async _requireDek(dek, envelope) {
|
|
292
295
|
const ids = Object.keys(envelope.secrets);
|
|
293
296
|
const key = await this._importDek(dek);
|
|
294
|
-
if (ids.length === 0)
|
|
297
|
+
if (ids.length === 0) throw new VaultError("Add a secret to the vault before a passkey: an empty vault cannot prove the key is its own.", "invalid-input");
|
|
295
298
|
const probe = await this._open(key, envelope.secrets[ids[0]], aadSecret(ids[0]), "locked");
|
|
296
299
|
zeroize(probe);
|
|
297
300
|
}
|
|
@@ -603,6 +606,10 @@ function isRelayToContent(x) {
|
|
|
603
606
|
function newRequestId() {
|
|
604
607
|
return crypto.randomUUID();
|
|
605
608
|
}
|
|
609
|
+
function pageRequestFrom(event, page) {
|
|
610
|
+
if (event.source !== page || event.origin !== page.location.origin) return null;
|
|
611
|
+
return isPageRequest(event.data) ? event.data : null;
|
|
612
|
+
}
|
|
606
613
|
function stampOrigin(request, origin) {
|
|
607
614
|
const { id, chain, method } = request;
|
|
608
615
|
return "params" in request ? { kind: "request", id, origin, chain, method, params: request.params } : { kind: "request", id, origin, chain, method };
|
|
@@ -2376,6 +2383,7 @@ export {
|
|
|
2376
2383
|
newRequestId,
|
|
2377
2384
|
nonEvmChain,
|
|
2378
2385
|
normalizeHost,
|
|
2386
|
+
pageRequestFrom,
|
|
2379
2387
|
parseAddChainParams,
|
|
2380
2388
|
parseConnectRequest,
|
|
2381
2389
|
parseRawAddress,
|