@1sat/wallet 0.0.14 → 0.0.16
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/cwi/index.d.ts +1 -0
- package/dist/cwi/index.d.ts.map +1 -1
- package/dist/cwi/index.js +1 -0
- package/dist/cwi/index.js.map +1 -1
- package/dist/cwi/types.d.ts +28 -28
- package/dist/cwi/types.d.ts.map +1 -1
- package/dist/cwi/types.js +28 -28
- package/dist/cwi/types.js.map +1 -1
- package/dist/cwi/web.d.ts +26 -0
- package/dist/cwi/web.d.ts.map +1 -0
- package/dist/cwi/web.js +188 -0
- package/dist/cwi/web.js.map +1 -0
- package/dist/index.d.ts +1 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -30
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/cwi/index.d.ts
CHANGED
|
@@ -9,4 +9,5 @@ export { CWIEventName, type CWIResponseDetail } from './types';
|
|
|
9
9
|
export { createCWI, type CWITransport } from './factory';
|
|
10
10
|
export { createEventCWI, CWI as EventCWI } from './event';
|
|
11
11
|
export { createChromeCWI, ChromeCWI } from './chrome';
|
|
12
|
+
export { createWebCWI, type WebCWIConfig, type WebCWIResult } from './web';
|
|
12
13
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cwi/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cwi/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,GAAG,IAAI,QAAQ,EAAE,MAAM,SAAS,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cwi/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,GAAG,IAAI,QAAQ,EAAE,MAAM,SAAS,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,OAAO,CAAA"}
|
package/dist/cwi/index.js
CHANGED
|
@@ -9,4 +9,5 @@ export { CWIEventName } from './types';
|
|
|
9
9
|
export { createCWI } from './factory';
|
|
10
10
|
export { createEventCWI, CWI as EventCWI } from './event';
|
|
11
11
|
export { createChromeCWI, ChromeCWI } from './chrome';
|
|
12
|
+
export { createWebCWI } from './web';
|
|
12
13
|
//# sourceMappingURL=index.js.map
|
package/dist/cwi/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cwi/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAA0B,MAAM,SAAS,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAqB,MAAM,WAAW,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,GAAG,IAAI,QAAQ,EAAE,MAAM,SAAS,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cwi/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAA0B,MAAM,SAAS,CAAA;AAC9D,OAAO,EAAE,SAAS,EAAqB,MAAM,WAAW,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,GAAG,IAAI,QAAQ,EAAE,MAAM,SAAS,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACrD,OAAO,EAAE,YAAY,EAAwC,MAAM,OAAO,CAAA"}
|
package/dist/cwi/types.d.ts
CHANGED
|
@@ -2,34 +2,34 @@
|
|
|
2
2
|
* CWI (Compute With Integrity) - Shared types for BRC-100 WalletInterface implementations
|
|
3
3
|
*/
|
|
4
4
|
export declare enum CWIEventName {
|
|
5
|
-
LIST_OUTPUTS = "
|
|
6
|
-
LIST_ACTIONS = "
|
|
7
|
-
GET_PUBLIC_KEY = "
|
|
8
|
-
GET_HEIGHT = "
|
|
9
|
-
GET_HEADER_FOR_HEIGHT = "
|
|
10
|
-
GET_NETWORK = "
|
|
11
|
-
GET_VERSION = "
|
|
12
|
-
IS_AUTHENTICATED = "
|
|
13
|
-
WAIT_FOR_AUTHENTICATION = "
|
|
14
|
-
CREATE_ACTION = "
|
|
15
|
-
SIGN_ACTION = "
|
|
16
|
-
ABORT_ACTION = "
|
|
17
|
-
INTERNALIZE_ACTION = "
|
|
18
|
-
CREATE_SIGNATURE = "
|
|
19
|
-
VERIFY_SIGNATURE = "
|
|
20
|
-
ENCRYPT = "
|
|
21
|
-
DECRYPT = "
|
|
22
|
-
CREATE_HMAC = "
|
|
23
|
-
VERIFY_HMAC = "
|
|
24
|
-
RELINQUISH_OUTPUT = "
|
|
25
|
-
ACQUIRE_CERTIFICATE = "
|
|
26
|
-
LIST_CERTIFICATES = "
|
|
27
|
-
PROVE_CERTIFICATE = "
|
|
28
|
-
RELINQUISH_CERTIFICATE = "
|
|
29
|
-
DISCOVER_BY_IDENTITY_KEY = "
|
|
30
|
-
DISCOVER_BY_ATTRIBUTES = "
|
|
31
|
-
REVEAL_COUNTERPARTY_KEY_LINKAGE = "
|
|
32
|
-
REVEAL_SPECIFIC_KEY_LINKAGE = "
|
|
5
|
+
LIST_OUTPUTS = "listOutputs",
|
|
6
|
+
LIST_ACTIONS = "listActions",
|
|
7
|
+
GET_PUBLIC_KEY = "getPublicKey",
|
|
8
|
+
GET_HEIGHT = "getHeight",
|
|
9
|
+
GET_HEADER_FOR_HEIGHT = "getHeaderForHeight",
|
|
10
|
+
GET_NETWORK = "getNetwork",
|
|
11
|
+
GET_VERSION = "getVersion",
|
|
12
|
+
IS_AUTHENTICATED = "isAuthenticated",
|
|
13
|
+
WAIT_FOR_AUTHENTICATION = "waitForAuthentication",
|
|
14
|
+
CREATE_ACTION = "createAction",
|
|
15
|
+
SIGN_ACTION = "signAction",
|
|
16
|
+
ABORT_ACTION = "abortAction",
|
|
17
|
+
INTERNALIZE_ACTION = "internalizeAction",
|
|
18
|
+
CREATE_SIGNATURE = "createSignature",
|
|
19
|
+
VERIFY_SIGNATURE = "verifySignature",
|
|
20
|
+
ENCRYPT = "encrypt",
|
|
21
|
+
DECRYPT = "decrypt",
|
|
22
|
+
CREATE_HMAC = "createHmac",
|
|
23
|
+
VERIFY_HMAC = "verifyHmac",
|
|
24
|
+
RELINQUISH_OUTPUT = "relinquishOutput",
|
|
25
|
+
ACQUIRE_CERTIFICATE = "acquireCertificate",
|
|
26
|
+
LIST_CERTIFICATES = "listCertificates",
|
|
27
|
+
PROVE_CERTIFICATE = "proveCertificate",
|
|
28
|
+
RELINQUISH_CERTIFICATE = "relinquishCertificate",
|
|
29
|
+
DISCOVER_BY_IDENTITY_KEY = "discoverByIdentityKey",
|
|
30
|
+
DISCOVER_BY_ATTRIBUTES = "discoverByAttributes",
|
|
31
|
+
REVEAL_COUNTERPARTY_KEY_LINKAGE = "revealCounterpartyKeyLinkage",
|
|
32
|
+
REVEAL_SPECIFIC_KEY_LINKAGE = "revealSpecificKeyLinkage"
|
|
33
33
|
}
|
|
34
34
|
export interface CWIResponseDetail<T = unknown> {
|
|
35
35
|
type: CWIEventName;
|
package/dist/cwi/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/cwi/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,oBAAY,YAAY;IAEvB,YAAY,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/cwi/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,oBAAY,YAAY;IAEvB,YAAY,gBAAgB;IAC5B,YAAY,gBAAgB;IAC5B,cAAc,iBAAiB;IAC/B,UAAU,cAAc;IACxB,qBAAqB,uBAAuB;IAC5C,WAAW,eAAe;IAC1B,WAAW,eAAe;IAC1B,gBAAgB,oBAAoB;IACpC,uBAAuB,0BAA0B;IAGjD,aAAa,iBAAiB;IAC9B,WAAW,eAAe;IAC1B,YAAY,gBAAgB;IAC5B,kBAAkB,sBAAsB;IACxC,gBAAgB,oBAAoB;IACpC,gBAAgB,oBAAoB;IACpC,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,WAAW,eAAe;IAC1B,WAAW,eAAe;IAC1B,iBAAiB,qBAAqB;IAGtC,mBAAmB,uBAAuB;IAC1C,iBAAiB,qBAAqB;IACtC,iBAAiB,qBAAqB;IACtC,sBAAsB,0BAA0B;IAChD,wBAAwB,0BAA0B;IAClD,sBAAsB,yBAAyB;IAG/C,+BAA+B,iCAAiC;IAChE,2BAA2B,6BAA6B;CACxD;AAGD,MAAM,WAAW,iBAAiB,CAAC,CAAC,GAAG,OAAO;IAC7C,IAAI,EAAE,YAAY,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,CAAC,CAAA;IACR,KAAK,CAAC,EAAE,MAAM,CAAA;CACd"}
|
package/dist/cwi/types.js
CHANGED
|
@@ -5,36 +5,36 @@
|
|
|
5
5
|
export var CWIEventName;
|
|
6
6
|
(function (CWIEventName) {
|
|
7
7
|
// Read-only operations
|
|
8
|
-
CWIEventName["LIST_OUTPUTS"] = "
|
|
9
|
-
CWIEventName["LIST_ACTIONS"] = "
|
|
10
|
-
CWIEventName["GET_PUBLIC_KEY"] = "
|
|
11
|
-
CWIEventName["GET_HEIGHT"] = "
|
|
12
|
-
CWIEventName["GET_HEADER_FOR_HEIGHT"] = "
|
|
13
|
-
CWIEventName["GET_NETWORK"] = "
|
|
14
|
-
CWIEventName["GET_VERSION"] = "
|
|
15
|
-
CWIEventName["IS_AUTHENTICATED"] = "
|
|
16
|
-
CWIEventName["WAIT_FOR_AUTHENTICATION"] = "
|
|
8
|
+
CWIEventName["LIST_OUTPUTS"] = "listOutputs";
|
|
9
|
+
CWIEventName["LIST_ACTIONS"] = "listActions";
|
|
10
|
+
CWIEventName["GET_PUBLIC_KEY"] = "getPublicKey";
|
|
11
|
+
CWIEventName["GET_HEIGHT"] = "getHeight";
|
|
12
|
+
CWIEventName["GET_HEADER_FOR_HEIGHT"] = "getHeaderForHeight";
|
|
13
|
+
CWIEventName["GET_NETWORK"] = "getNetwork";
|
|
14
|
+
CWIEventName["GET_VERSION"] = "getVersion";
|
|
15
|
+
CWIEventName["IS_AUTHENTICATED"] = "isAuthenticated";
|
|
16
|
+
CWIEventName["WAIT_FOR_AUTHENTICATION"] = "waitForAuthentication";
|
|
17
17
|
// Signing operations (require password)
|
|
18
|
-
CWIEventName["CREATE_ACTION"] = "
|
|
19
|
-
CWIEventName["SIGN_ACTION"] = "
|
|
20
|
-
CWIEventName["ABORT_ACTION"] = "
|
|
21
|
-
CWIEventName["INTERNALIZE_ACTION"] = "
|
|
22
|
-
CWIEventName["CREATE_SIGNATURE"] = "
|
|
23
|
-
CWIEventName["VERIFY_SIGNATURE"] = "
|
|
24
|
-
CWIEventName["ENCRYPT"] = "
|
|
25
|
-
CWIEventName["DECRYPT"] = "
|
|
26
|
-
CWIEventName["CREATE_HMAC"] = "
|
|
27
|
-
CWIEventName["VERIFY_HMAC"] = "
|
|
28
|
-
CWIEventName["RELINQUISH_OUTPUT"] = "
|
|
18
|
+
CWIEventName["CREATE_ACTION"] = "createAction";
|
|
19
|
+
CWIEventName["SIGN_ACTION"] = "signAction";
|
|
20
|
+
CWIEventName["ABORT_ACTION"] = "abortAction";
|
|
21
|
+
CWIEventName["INTERNALIZE_ACTION"] = "internalizeAction";
|
|
22
|
+
CWIEventName["CREATE_SIGNATURE"] = "createSignature";
|
|
23
|
+
CWIEventName["VERIFY_SIGNATURE"] = "verifySignature";
|
|
24
|
+
CWIEventName["ENCRYPT"] = "encrypt";
|
|
25
|
+
CWIEventName["DECRYPT"] = "decrypt";
|
|
26
|
+
CWIEventName["CREATE_HMAC"] = "createHmac";
|
|
27
|
+
CWIEventName["VERIFY_HMAC"] = "verifyHmac";
|
|
28
|
+
CWIEventName["RELINQUISH_OUTPUT"] = "relinquishOutput";
|
|
29
29
|
// Certificate operations
|
|
30
|
-
CWIEventName["ACQUIRE_CERTIFICATE"] = "
|
|
31
|
-
CWIEventName["LIST_CERTIFICATES"] = "
|
|
32
|
-
CWIEventName["PROVE_CERTIFICATE"] = "
|
|
33
|
-
CWIEventName["RELINQUISH_CERTIFICATE"] = "
|
|
34
|
-
CWIEventName["DISCOVER_BY_IDENTITY_KEY"] = "
|
|
35
|
-
CWIEventName["DISCOVER_BY_ATTRIBUTES"] = "
|
|
30
|
+
CWIEventName["ACQUIRE_CERTIFICATE"] = "acquireCertificate";
|
|
31
|
+
CWIEventName["LIST_CERTIFICATES"] = "listCertificates";
|
|
32
|
+
CWIEventName["PROVE_CERTIFICATE"] = "proveCertificate";
|
|
33
|
+
CWIEventName["RELINQUISH_CERTIFICATE"] = "relinquishCertificate";
|
|
34
|
+
CWIEventName["DISCOVER_BY_IDENTITY_KEY"] = "discoverByIdentityKey";
|
|
35
|
+
CWIEventName["DISCOVER_BY_ATTRIBUTES"] = "discoverByAttributes";
|
|
36
36
|
// Key linkage
|
|
37
|
-
CWIEventName["REVEAL_COUNTERPARTY_KEY_LINKAGE"] = "
|
|
38
|
-
CWIEventName["REVEAL_SPECIFIC_KEY_LINKAGE"] = "
|
|
37
|
+
CWIEventName["REVEAL_COUNTERPARTY_KEY_LINKAGE"] = "revealCounterpartyKeyLinkage";
|
|
38
|
+
CWIEventName["REVEAL_SPECIFIC_KEY_LINKAGE"] = "revealSpecificKeyLinkage";
|
|
39
39
|
})(CWIEventName || (CWIEventName = {}));
|
|
40
40
|
//# sourceMappingURL=types.js.map
|
package/dist/cwi/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/cwi/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,+DAA+D;AAC/D,MAAM,CAAN,IAAY,YAoCX;AApCD,WAAY,YAAY;IACvB,uBAAuB;IACvB,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/cwi/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,+DAA+D;AAC/D,MAAM,CAAN,IAAY,YAoCX;AApCD,WAAY,YAAY;IACvB,uBAAuB;IACvB,4CAA4B,CAAA;IAC5B,4CAA4B,CAAA;IAC5B,+CAA+B,CAAA;IAC/B,wCAAwB,CAAA;IACxB,4DAA4C,CAAA;IAC5C,0CAA0B,CAAA;IAC1B,0CAA0B,CAAA;IAC1B,oDAAoC,CAAA;IACpC,iEAAiD,CAAA;IAEjD,wCAAwC;IACxC,8CAA8B,CAAA;IAC9B,0CAA0B,CAAA;IAC1B,4CAA4B,CAAA;IAC5B,wDAAwC,CAAA;IACxC,oDAAoC,CAAA;IACpC,oDAAoC,CAAA;IACpC,mCAAmB,CAAA;IACnB,mCAAmB,CAAA;IACnB,0CAA0B,CAAA;IAC1B,0CAA0B,CAAA;IAC1B,sDAAsC,CAAA;IAEtC,yBAAyB;IACzB,0DAA0C,CAAA;IAC1C,sDAAsC,CAAA;IACtC,sDAAsC,CAAA;IACtC,gEAAgD,CAAA;IAChD,kEAAkD,CAAA;IAClD,+DAA+C,CAAA;IAE/C,cAAc;IACd,gFAAgE,CAAA;IAChE,wEAAwD,CAAA;AACzD,CAAC,EApCW,YAAY,KAAZ,YAAY,QAoCvB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CWI Web Transport - For remote web wallets via iframe/postMessage
|
|
3
|
+
* Creates a hidden iframe to the wallet host and communicates via postMessage.
|
|
4
|
+
*/
|
|
5
|
+
import type { WalletInterface } from '@bsv/sdk';
|
|
6
|
+
export interface WebCWIConfig {
|
|
7
|
+
/** Base URL for wallet host (default: https://1sat.market) */
|
|
8
|
+
walletUrl?: string;
|
|
9
|
+
/** Iframe path on wallet host (default: /wallet/cwi) */
|
|
10
|
+
iframePath?: string;
|
|
11
|
+
/** Request timeout in milliseconds (default: 120000) */
|
|
12
|
+
timeout?: number;
|
|
13
|
+
/** Handshake timeout in milliseconds (default: 5000) */
|
|
14
|
+
handshakeTimeout?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface WebCWIResult {
|
|
17
|
+
wallet: WalletInterface;
|
|
18
|
+
destroy: () => void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create a WalletInterface backed by a remote web wallet via iframe/postMessage.
|
|
22
|
+
*
|
|
23
|
+
* Returns { wallet, destroy }. Call destroy() to remove the iframe and clean up listeners.
|
|
24
|
+
*/
|
|
25
|
+
export declare function createWebCWI(config?: WebCWIConfig): WebCWIResult;
|
|
26
|
+
//# sourceMappingURL=web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/cwi/web.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAS/C,MAAM,WAAW,YAAY;IAC5B,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,wDAAwD;IACxD,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,wDAAwD;IACxD,gBAAgB,CAAC,EAAE,MAAM,CAAA;CACzB;AAED,MAAM,WAAW,YAAY;IAC5B,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,MAAM,IAAI,CAAA;CACnB;AAkDD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,YAAY,GAAG,YAAY,CAuLhE"}
|
package/dist/cwi/web.js
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CWI Web Transport - For remote web wallets via iframe/postMessage
|
|
3
|
+
* Creates a hidden iframe to the wallet host and communicates via postMessage.
|
|
4
|
+
*/
|
|
5
|
+
import { createCWI } from './factory';
|
|
6
|
+
const DEFAULT_WALLET_URL = 'https://1sat.market';
|
|
7
|
+
const DEFAULT_IFRAME_PATH = '/wallet/cwi';
|
|
8
|
+
const DEFAULT_REQUEST_TIMEOUT_MS = 120_000;
|
|
9
|
+
const DEFAULT_HANDSHAKE_TIMEOUT_MS = 5_000;
|
|
10
|
+
const isRecord = (v) => typeof v === 'object' && v !== null;
|
|
11
|
+
const isResponse = (v) => isRecord(v) && v.type === 'CWI' && v.isInvocation === false && typeof v.id === 'string';
|
|
12
|
+
const isState = (v) => isRecord(v) && v.type === 'CWI' && isRecord(v.cwiState);
|
|
13
|
+
const createId = () => typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function'
|
|
14
|
+
? crypto.randomUUID()
|
|
15
|
+
: `${Date.now()}-${Math.random().toString(36).slice(2, 14)}`;
|
|
16
|
+
/**
|
|
17
|
+
* Create a WalletInterface backed by a remote web wallet via iframe/postMessage.
|
|
18
|
+
*
|
|
19
|
+
* Returns { wallet, destroy }. Call destroy() to remove the iframe and clean up listeners.
|
|
20
|
+
*/
|
|
21
|
+
export function createWebCWI(config) {
|
|
22
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
23
|
+
throw new Error('createWebCWI requires a browser environment');
|
|
24
|
+
}
|
|
25
|
+
const walletUrl = config?.walletUrl ?? DEFAULT_WALLET_URL;
|
|
26
|
+
const iframePath = config?.iframePath ?? DEFAULT_IFRAME_PATH;
|
|
27
|
+
const requestTimeout = config?.timeout ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
28
|
+
const handshakeTimeout = config?.handshakeTimeout ?? DEFAULT_HANDSHAKE_TIMEOUT_MS;
|
|
29
|
+
const walletOrigin = new URL(walletUrl).origin;
|
|
30
|
+
const iframeUrl = new URL(iframePath, walletUrl).toString();
|
|
31
|
+
const pending = new Map();
|
|
32
|
+
let iframe = null;
|
|
33
|
+
let destroyed = false;
|
|
34
|
+
let handshakeResolve = null;
|
|
35
|
+
let handshakeReject = null;
|
|
36
|
+
let handshakeComplete = false;
|
|
37
|
+
const handleMessage = (event) => {
|
|
38
|
+
if (destroyed)
|
|
39
|
+
return;
|
|
40
|
+
if (event.origin !== walletOrigin)
|
|
41
|
+
return;
|
|
42
|
+
const iframeWindow = iframe?.contentWindow;
|
|
43
|
+
if (!iframeWindow || event.source !== iframeWindow)
|
|
44
|
+
return;
|
|
45
|
+
const data = event.data;
|
|
46
|
+
if (isState(data)) {
|
|
47
|
+
if (data.cwiState.fallbackRecommended) {
|
|
48
|
+
handshakeReject?.(new Error('Web wallet indicated fallback recommended'));
|
|
49
|
+
handshakeResolve = null;
|
|
50
|
+
handshakeReject = null;
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (!handshakeComplete) {
|
|
54
|
+
handshakeComplete = true;
|
|
55
|
+
handshakeResolve?.();
|
|
56
|
+
handshakeResolve = null;
|
|
57
|
+
handshakeReject = null;
|
|
58
|
+
}
|
|
59
|
+
if (data.cwiState.hasPermission === true) {
|
|
60
|
+
updateIframeVisibility(true);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
updateIframeVisibility(false);
|
|
64
|
+
}
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (!isResponse(data))
|
|
68
|
+
return;
|
|
69
|
+
const req = pending.get(data.id);
|
|
70
|
+
if (!req)
|
|
71
|
+
return;
|
|
72
|
+
pending.delete(data.id);
|
|
73
|
+
clearTimeout(req.timeoutId);
|
|
74
|
+
if (data.status === 'error') {
|
|
75
|
+
req.reject(new Error(data.description ?? 'Web wallet request failed'));
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
req.resolve(data.result);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
const updateIframeVisibility = (show) => {
|
|
82
|
+
if (!iframe)
|
|
83
|
+
return;
|
|
84
|
+
iframe.style.zIndex = '2147483647';
|
|
85
|
+
if (show) {
|
|
86
|
+
iframe.style.width = '100%';
|
|
87
|
+
iframe.style.height = '100%';
|
|
88
|
+
iframe.style.opacity = '1';
|
|
89
|
+
iframe.style.pointerEvents = 'auto';
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
iframe.style.width = '0';
|
|
93
|
+
iframe.style.height = '0';
|
|
94
|
+
iframe.style.opacity = '0';
|
|
95
|
+
iframe.style.pointerEvents = 'none';
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
const ensureIframe = () => {
|
|
99
|
+
if (iframe)
|
|
100
|
+
return iframe;
|
|
101
|
+
const el = document.createElement('iframe');
|
|
102
|
+
el.src = iframeUrl;
|
|
103
|
+
el.setAttribute('aria-hidden', 'true');
|
|
104
|
+
el.style.position = 'fixed';
|
|
105
|
+
el.style.top = '0';
|
|
106
|
+
el.style.left = '0';
|
|
107
|
+
el.style.width = '0';
|
|
108
|
+
el.style.height = '0';
|
|
109
|
+
el.style.border = '0';
|
|
110
|
+
el.style.opacity = '0';
|
|
111
|
+
el.style.pointerEvents = 'none';
|
|
112
|
+
const parent = document.body ?? document.documentElement;
|
|
113
|
+
if (!parent)
|
|
114
|
+
throw new Error('Unable to mount CWI iframe');
|
|
115
|
+
parent.appendChild(el);
|
|
116
|
+
iframe = el;
|
|
117
|
+
return el;
|
|
118
|
+
};
|
|
119
|
+
const waitForHandshake = () => {
|
|
120
|
+
if (handshakeComplete)
|
|
121
|
+
return Promise.resolve();
|
|
122
|
+
return new Promise((resolve, reject) => {
|
|
123
|
+
handshakeResolve = resolve;
|
|
124
|
+
handshakeReject = reject;
|
|
125
|
+
setTimeout(() => {
|
|
126
|
+
if (!handshakeComplete) {
|
|
127
|
+
handshakeReject?.(new Error('Web wallet handshake timed out'));
|
|
128
|
+
handshakeResolve = null;
|
|
129
|
+
handshakeReject = null;
|
|
130
|
+
}
|
|
131
|
+
}, handshakeTimeout);
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
window.addEventListener('message', handleMessage);
|
|
135
|
+
ensureIframe();
|
|
136
|
+
const transport = async (action, params) => {
|
|
137
|
+
if (destroyed)
|
|
138
|
+
throw new Error('WebCWI has been destroyed');
|
|
139
|
+
await waitForHandshake();
|
|
140
|
+
const target = iframe?.contentWindow;
|
|
141
|
+
if (!target)
|
|
142
|
+
throw new Error('CWI iframe is not reachable');
|
|
143
|
+
const id = createId();
|
|
144
|
+
const request = {
|
|
145
|
+
type: 'CWI',
|
|
146
|
+
isInvocation: true,
|
|
147
|
+
id,
|
|
148
|
+
call: action,
|
|
149
|
+
args: params,
|
|
150
|
+
};
|
|
151
|
+
return new Promise((resolve, reject) => {
|
|
152
|
+
const timeoutId = setTimeout(() => {
|
|
153
|
+
pending.delete(id);
|
|
154
|
+
reject(new Error(`Web wallet request timed out: ${action}`));
|
|
155
|
+
}, requestTimeout);
|
|
156
|
+
pending.set(id, {
|
|
157
|
+
resolve: resolve,
|
|
158
|
+
reject,
|
|
159
|
+
timeoutId,
|
|
160
|
+
});
|
|
161
|
+
try {
|
|
162
|
+
target.postMessage(request, walletOrigin);
|
|
163
|
+
}
|
|
164
|
+
catch (err) {
|
|
165
|
+
clearTimeout(timeoutId);
|
|
166
|
+
pending.delete(id);
|
|
167
|
+
reject(new Error(`Failed to post message to web wallet: ${err instanceof Error ? err.message : String(err)}`));
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
const destroy = () => {
|
|
172
|
+
if (destroyed)
|
|
173
|
+
return;
|
|
174
|
+
destroyed = true;
|
|
175
|
+
window.removeEventListener('message', handleMessage);
|
|
176
|
+
for (const req of pending.values()) {
|
|
177
|
+
clearTimeout(req.timeoutId);
|
|
178
|
+
req.reject(new Error('WebCWI destroyed'));
|
|
179
|
+
}
|
|
180
|
+
pending.clear();
|
|
181
|
+
if (iframe?.parentNode) {
|
|
182
|
+
iframe.parentNode.removeChild(iframe);
|
|
183
|
+
}
|
|
184
|
+
iframe = null;
|
|
185
|
+
};
|
|
186
|
+
return { wallet: createCWI(transport), destroy };
|
|
187
|
+
}
|
|
188
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/cwi/web.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAqB,SAAS,EAAE,MAAM,WAAW,CAAA;AAGxD,MAAM,kBAAkB,GAAG,qBAAqB,CAAA;AAChD,MAAM,mBAAmB,GAAG,aAAa,CAAA;AACzC,MAAM,0BAA0B,GAAG,OAAO,CAAA;AAC1C,MAAM,4BAA4B,GAAG,KAAK,CAAA;AAoD1C,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAgC,EAAE,CAC7D,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAA;AAEpC,MAAM,UAAU,GAAG,CAAC,CAAU,EAA2B,EAAE,CAC1D,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,YAAY,KAAK,KAAK,IAAI,OAAO,CAAC,CAAC,EAAE,KAAK,QAAQ,CAAA;AAExF,MAAM,OAAO,GAAG,CAAC,CAAU,EAAwB,EAAE,CACpD,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,QAAQ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AAC,CAAA;YAC/G,CAAC;QACF,CAAC,CAAC,CAAA;IACH,CAAC,CAAA;IAED,MAAM,OAAO,GAAG,GAAS,EAAE;QAC1B,IAAI,SAAS;YAAE,OAAM;QACrB,SAAS,GAAG,IAAI,CAAA;QAEhB,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAA;QAEpD,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YACpC,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;YAC3B,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAA;QAC1C,CAAC;QACD,OAAO,CAAC,KAAK,EAAE,CAAA;QAEf,IAAI,MAAM,EAAE,UAAU,EAAE,CAAC;YACxB,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;QACtC,CAAC;QACD,MAAM,GAAG,IAAI,CAAA;IACd,CAAC,CAAA;IAED,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAA;AACjD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,31 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @1sat/wallet - BRC-100 Wallet Engine for 1Sat Ordinals SDK
|
|
3
|
-
*
|
|
4
|
-
* This package provides the wallet functionality for the 1Sat SDK.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```typescript
|
|
8
|
-
* import { OneSatWallet, OneSatServices } from '@1sat/wallet'
|
|
9
|
-
* import { WalletStorageManager, StorageIdb } from '@bsv/wallet-toolbox/mobile'
|
|
10
|
-
*
|
|
11
|
-
* // Create storage (from @bsv/wallet-toolbox)
|
|
12
|
-
* const storage = await WalletStorageManager.createWalletStorageManager(
|
|
13
|
-
* new StorageIdb({ name: 'my-wallet' })
|
|
14
|
-
* )
|
|
15
|
-
*
|
|
16
|
-
* // Initialize wallet
|
|
17
|
-
* const wallet = new OneSatWallet({
|
|
18
|
-
* rootKey: privateKey,
|
|
19
|
-
* storage,
|
|
20
|
-
* chain: 'main',
|
|
21
|
-
* owners: new Set([address1, address2])
|
|
22
|
-
* })
|
|
23
|
-
*
|
|
24
|
-
* // Sync and use
|
|
25
|
-
* wallet.syncAll()
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export { OneSatWallet, type IngestResult, type OneSatWalletArgs, type OneSatWalletEvents, } from './OneSatWallet';
|
|
29
1
|
export { OneSatServices } from '@1sat/client';
|
|
30
2
|
export type { Bsv21OutputData, Bsv21TokenData, Bsv21TransactionData, Capability, OrdfsMetadata, SyncOutput, } from '@1sat/types';
|
|
31
3
|
export { ReadOnlySigner } from './signers/ReadOnlySigner';
|
|
@@ -33,5 +5,5 @@ export { ArcadeClient, BaseClient, BeefClient, Bsv21Client, ChaintracksClient, O
|
|
|
33
5
|
export { Bsv21Indexer, CosignIndexer, deriveFundAddress, FundIndexer, Indexer, InscriptionIndexer, LockIndexer, Listing, MapIndexer, OpNSIndexer, OrdLockIndexer, OriginIndexer, Outpoint, parseAddress, SigmaIndexer, type Bsv21, type CosignData, type File, type IndexData, type IndexSummary, type Inscription, type Origin, type ParseContext, type ParseResult, type Sigma, type Txo, } from './indexers';
|
|
34
6
|
export { AddressManager, AddressSyncFetcher, AddressSyncManager, AddressSyncProcessor, AddressSyncQueueIdb, AddressSyncQueueSqlite, BRC29_PROTOCOL_ID, YOURS_PREFIX, type AddressDerivation, type AddressSyncEvents, type AddressSyncFetcherEvents, type AddressSyncFetcherOptions, type AddressSyncManagerOptions, type AddressSyncProcessorEvents, type AddressSyncProcessorOptions, type AddressSyncQueueInput, type AddressSyncQueueItem, type AddressSyncQueueItemStatus, type AddressSyncQueueStats, type AddressSyncQueueStorage, type AddressSyncState, } from './address-sync';
|
|
35
7
|
export { FileBackupProvider, FileRestoreReader, Zip, ZipDeflate, unzip, type BackupManifest, type BackupProgressCallback, type BackupProgressEvent, type Unzipped, } from './backup';
|
|
36
|
-
export { ChromeCWI, CWIEventName, EventCWI, createChromeCWI, createCWI, createEventCWI, type CWIResponseDetail, type CWITransport, } from './cwi';
|
|
8
|
+
export { ChromeCWI, CWIEventName, EventCWI, createChromeCWI, createCWI, createEventCWI, createWebCWI, type CWIResponseDetail, type CWITransport, type WebCWIConfig, type WebCWIResult, } from './cwi';
|
|
37
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,YAAY,EACX,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,UAAU,EACV,aAAa,EACb,UAAU,GACV,MAAM,aAAa,CAAA;AAGpB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAGzD,OAAO,EACN,YAAY,EACZ,UAAU,EACV,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,aAAa,EACb,SAAS,GACT,MAAM,cAAc,CAAA;AAGrB,OAAO,EACN,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,kBAAkB,EAClB,WAAW,EACX,OAAO,EACP,UAAU,EACV,WAAW,EACX,cAAc,EACd,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,KAAK,KAAK,EACV,KAAK,UAAU,EACf,KAAK,IAAI,EACT,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,KAAK,EACV,KAAK,GAAG,GACR,MAAM,YAAY,CAAA;AAGnB,OAAO,EACN,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EAChC,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,0BAA0B,EAC/B,KAAK,qBAAqB,EAC1B,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,GACrB,MAAM,gBAAgB,CAAA;AAGvB,OAAO,EACN,kBAAkB,EAClB,iBAAiB,EACjB,GAAG,EACH,UAAU,EACV,KAAK,EACL,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,QAAQ,GACb,MAAM,UAAU,CAAA;AAGjB,OAAO,EACN,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,SAAS,EACT,cAAc,EACd,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,YAAY,GACjB,MAAM,OAAO,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,32 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @1sat/wallet - BRC-100 Wallet Engine for 1Sat Ordinals SDK
|
|
3
|
-
*
|
|
4
|
-
* This package provides the wallet functionality for the 1Sat SDK.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```typescript
|
|
8
|
-
* import { OneSatWallet, OneSatServices } from '@1sat/wallet'
|
|
9
|
-
* import { WalletStorageManager, StorageIdb } from '@bsv/wallet-toolbox/mobile'
|
|
10
|
-
*
|
|
11
|
-
* // Create storage (from @bsv/wallet-toolbox)
|
|
12
|
-
* const storage = await WalletStorageManager.createWalletStorageManager(
|
|
13
|
-
* new StorageIdb({ name: 'my-wallet' })
|
|
14
|
-
* )
|
|
15
|
-
*
|
|
16
|
-
* // Initialize wallet
|
|
17
|
-
* const wallet = new OneSatWallet({
|
|
18
|
-
* rootKey: privateKey,
|
|
19
|
-
* storage,
|
|
20
|
-
* chain: 'main',
|
|
21
|
-
* owners: new Set([address1, address2])
|
|
22
|
-
* })
|
|
23
|
-
*
|
|
24
|
-
* // Sync and use
|
|
25
|
-
* wallet.syncAll()
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
// Core wallet exports
|
|
29
|
-
export { OneSatWallet, } from './OneSatWallet';
|
|
30
1
|
// Services
|
|
31
2
|
export { OneSatServices } from '@1sat/client';
|
|
32
3
|
// Signers
|
|
@@ -40,7 +11,7 @@ export { AddressManager, AddressSyncFetcher, AddressSyncManager, AddressSyncProc
|
|
|
40
11
|
// Backup
|
|
41
12
|
export { FileBackupProvider, FileRestoreReader, Zip, ZipDeflate, unzip, } from './backup';
|
|
42
13
|
// CWI (Compute With Integrity)
|
|
43
|
-
export { ChromeCWI, CWIEventName, EventCWI, createChromeCWI, createCWI, createEventCWI, } from './cwi';
|
|
14
|
+
export { ChromeCWI, CWIEventName, EventCWI, createChromeCWI, createCWI, createEventCWI, createWebCWI, } from './cwi';
|
|
44
15
|
// Note: Storage utilities (StorageIdb, WalletStorageManager, Chain) should be
|
|
45
16
|
// imported directly from '@bsv/wallet-toolbox/mobile'
|
|
46
17
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,WAAW;AACX,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAU7C,UAAU;AACV,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAEzD,cAAc;AACd,OAAO,EACN,YAAY,EACZ,UAAU,EACV,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,aAAa,EACb,SAAS,GACT,MAAM,cAAc,CAAA;AAErB,WAAW;AACX,OAAO,EACN,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,kBAAkB,EAClB,WAAW,EACX,OAAO,EACP,UAAU,EACV,WAAW,EACX,cAAc,EACd,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,YAAY,GAYZ,MAAM,YAAY,CAAA;AAEnB,eAAe;AACf,OAAO,EACN,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,YAAY,GAcZ,MAAM,gBAAgB,CAAA;AAEvB,SAAS;AACT,OAAO,EACN,kBAAkB,EAClB,iBAAiB,EACjB,GAAG,EACH,UAAU,EACV,KAAK,GAKL,MAAM,UAAU,CAAA;AAEjB,+BAA+B;AAC/B,OAAO,EACN,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,SAAS,EACT,cAAc,EACd,YAAY,GAKZ,MAAM,OAAO,CAAA;AAEd,8EAA8E;AAC9E,sDAAsD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1sat/wallet",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "BRC-100 wallet engine for 1Sat Ordinals SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@1sat/client": "^0.0.7",
|
|
24
24
|
"@1sat/types": "^0.0.6",
|
|
25
|
-
"@bopen-io/templates": "^1.1.
|
|
25
|
+
"@bopen-io/templates": "^1.1.9",
|
|
26
26
|
"@msgpack/msgpack": "^3.1.3",
|
|
27
27
|
"fflate": "^0.8.2"
|
|
28
28
|
},
|