@reef-knot/ledger-connector 4.5.0 → 5.0.0-alpha.1

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.
@@ -1,187 +1,146 @@
1
- import { __awaiter } from '../_virtual/_tslib.js';
2
- import { BigNumber } from '@ethersproject/bignumber';
3
- import { Signer } from '@ethersproject/abstract-signer';
4
- import { serialize } from '@ethersproject/transactions';
5
- import { toUtf8Bytes } from '@ethersproject/strings';
6
- import { hexlify, joinSignature } from '@ethersproject/bytes';
7
- import { _TypedDataEncoder } from '@ethersproject/hash';
8
- import { checkError, toNumber, convertToUnsigned } from './helpers.js';
9
- import { LS_KEY_DERIVATION_PATH } from './constants.js';
1
+ import { LS_KEY_DERIVATION_PATH } from "./constants.js";
2
+ import { checkError, convertToUnsigned, toNumber } from "./helpers.js";
3
+ import { hexlify, joinSignature } from "@ethersproject/bytes";
4
+ import { BigNumber } from "@ethersproject/bignumber";
5
+ import { Signer } from "@ethersproject/abstract-signer";
6
+ import { serialize } from "@ethersproject/transactions";
7
+ import { toUtf8Bytes } from "@ethersproject/strings";
8
+ import { _TypedDataEncoder } from "@ethersproject/hash";
10
9
 
10
+ //#region src/hid/signer.ts
11
11
  const defaultPath = "m/44'/60'/0'/0/0";
12
- class LedgerHQSigner extends Signer {
13
- get path() {
14
- if (typeof window !== 'undefined') {
15
- return window.localStorage.getItem(LS_KEY_DERIVATION_PATH) || defaultPath;
16
- }
17
- return defaultPath;
18
- }
19
- constructor(provider) {
20
- super();
21
- // required by JsonRpcSigner type
22
- this._index = 0;
23
- this._address = '';
24
- this.provider = provider;
25
- }
26
- withEthApp(callback) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- const transport = yield this.provider.getTransport();
29
- try {
30
- const {
31
- default: Eth
32
- } = yield import('@ledgerhq/hw-app-eth');
33
- const eth = new Eth(transport);
34
- yield eth.getAppConfiguration();
35
- // eslint-disable-next-line @typescript-eslint/await-thenable
36
- return yield callback(eth);
37
- } catch (error) {
38
- return checkError(error);
39
- } finally {
40
- yield transport.close();
41
- }
42
- });
43
- }
44
- getAddress() {
45
- return __awaiter(this, void 0, void 0, function* () {
46
- const account = yield this.withEthApp(eth => eth.getAddress(this.path));
47
- this._address = this.provider.formatter.address(account.address);
48
- return this._address;
49
- });
50
- }
51
- signMessage(message) {
52
- return __awaiter(this, void 0, void 0, function* () {
53
- if (typeof message === 'string') {
54
- // eslint-disable-next-line no-param-reassign
55
- message = toUtf8Bytes(message);
56
- }
57
- const messageHex = hexlify(message).substring(2);
58
- const sig = yield this.withEthApp(eth => eth.signPersonalMessage(this.path, messageHex));
59
- sig.r = `0x${sig.r}`;
60
- sig.s = `0x${sig.s}`;
61
- return joinSignature(sig);
62
- });
63
- }
64
- populateUnsigned(transaction) {
65
- return __awaiter(this, void 0, void 0, function* () {
66
- const populated = yield this.populateTransaction(transaction);
67
- const nonce = toNumber(populated.nonce);
68
- if (populated.type === 0) {
69
- const {
70
- gasLimit,
71
- type,
72
- chainId,
73
- gasPrice,
74
- value,
75
- data,
76
- to
77
- } = populated;
78
- // Allowed transaction keys for Legacy and EIP-155 Transactions
79
- return {
80
- gasLimit,
81
- type,
82
- chainId,
83
- gasPrice,
84
- nonce,
85
- value,
86
- data,
87
- to
88
- };
89
- }
90
- return Object.assign(Object.assign({}, populated), {
91
- nonce
92
- });
93
- });
94
- }
95
- signTransaction(transaction_1) {
96
- return __awaiter(this, arguments, void 0, function* (transaction, loadConfig = {}, resolutionConfig = {}) {
97
- const unsignedTx = yield convertToUnsigned(transaction);
98
- const populatedTx = yield this.populateUnsigned(unsignedTx);
99
- const serializedTx = serialize(populatedTx).substring(2);
100
- const {
101
- ledgerService
102
- } = yield import('@ledgerhq/hw-app-eth');
103
- const resolution = yield ledgerService.resolveTransaction(serializedTx, loadConfig, resolutionConfig);
104
- const sig = yield this.withEthApp(eth => eth.signTransaction(this.path, serializedTx, resolution));
105
- return serialize(populatedTx, {
106
- v: BigNumber.from(`0x${sig.v}`).toNumber(),
107
- r: `0x${sig.r}`,
108
- s: `0x${sig.s}`
109
- });
110
- });
111
- }
112
- connect(provider) {
113
- return new LedgerHQSigner(provider);
114
- }
115
- // eslint-disable-next-line class-methods-use-this
116
- connectUnchecked() {
117
- throw new Error('method is not implemented');
118
- }
119
- // eslint-disable-next-line class-methods-use-this
120
- sendUncheckedTransaction() {
121
- throw new Error('method is not implemented');
122
- }
123
- // eslint-disable-next-line class-methods-use-this, @typescript-eslint/require-await
124
- unlock() {
125
- return __awaiter(this, void 0, void 0, function* () {
126
- throw new Error('method is not implemented');
127
- });
128
- }
129
- // eslint-disable-next-line class-methods-use-this, @typescript-eslint/require-await
130
- _legacySignMessage(_message) {
131
- return __awaiter(this, void 0, void 0, function* () {
132
- throw new Error('method is not implemented');
133
- });
134
- }
135
- // _signTypedData as per ethers Signer, cleans up types, replaces domain, calculates primaryType
136
- _signTypedData(domain, _types, value) {
137
- return __awaiter(this, void 0, void 0, function* () {
138
- const types = Object.assign({}, _types);
139
- delete types.EIP712Domain;
140
- const encoder = new _TypedDataEncoder(types);
141
- const data = {
142
- domain: {
143
- name: domain.name,
144
- verifyingContract: domain.verifyingContract,
145
- version: domain.version,
146
- chainId: domain.chainId // eslint-disable-next-line radix
147
- ? parseInt(domain.chainId.toString()) : undefined
148
- },
149
- types: Object.assign(Object.assign({}, types), {
150
- EIP712Domain: [{
151
- name: 'name',
152
- type: 'string'
153
- }, {
154
- name: 'version',
155
- type: 'string'
156
- }, {
157
- name: 'chainId',
158
- type: 'uint256'
159
- }, {
160
- name: 'verifyingContract',
161
- type: 'address'
162
- }]
163
- }),
164
- primaryType: encoder.primaryType,
165
- message: value
166
- };
167
- return this.__signEIP712Message(data);
168
- });
169
- }
170
- // custom method, also called directly on eth_signTypedData_v4 RPC request
171
- __signEIP712Message(data) {
172
- return __awaiter(this, void 0, void 0, function* () {
173
- const {
174
- r,
175
- s,
176
- v
177
- } = yield this.withEthApp(eth => eth.signEIP712Message(this.path, data));
178
- return joinSignature({
179
- r: `0x${r}`,
180
- s: `0x${s}`,
181
- v
182
- });
183
- });
184
- }
185
- }
12
+ var LedgerHQSigner = class LedgerHQSigner extends Signer {
13
+ get path() {
14
+ if (typeof window !== "undefined") return window.localStorage.getItem(LS_KEY_DERIVATION_PATH) || defaultPath;
15
+ return defaultPath;
16
+ }
17
+ constructor(provider) {
18
+ super();
19
+ this._index = 0;
20
+ this._address = "";
21
+ this.provider = provider;
22
+ }
23
+ async withEthApp(callback) {
24
+ const transport = await this.provider.getTransport();
25
+ try {
26
+ const { default: Eth } = await import("@ledgerhq/hw-app-eth");
27
+ const eth = new Eth(transport);
28
+ await eth.getAppConfiguration();
29
+ return await callback(eth);
30
+ } catch (error) {
31
+ return checkError(error);
32
+ } finally {
33
+ await transport.close();
34
+ }
35
+ }
36
+ async getAddress() {
37
+ const account = await this.withEthApp((eth) => eth.getAddress(this.path));
38
+ this._address = this.provider.formatter.address(account.address);
39
+ return this._address;
40
+ }
41
+ async signMessage(message) {
42
+ if (typeof message === "string") message = toUtf8Bytes(message);
43
+ const messageHex = hexlify(message).substring(2);
44
+ const sig = await this.withEthApp((eth) => eth.signPersonalMessage(this.path, messageHex));
45
+ sig.r = `0x${sig.r}`;
46
+ sig.s = `0x${sig.s}`;
47
+ return joinSignature(sig);
48
+ }
49
+ async populateUnsigned(transaction) {
50
+ const populated = await this.populateTransaction(transaction);
51
+ const nonce = toNumber(populated.nonce);
52
+ if (populated.type === 0) {
53
+ const { gasLimit, type, chainId, gasPrice, value, data, to } = populated;
54
+ return {
55
+ gasLimit,
56
+ type,
57
+ chainId,
58
+ gasPrice,
59
+ nonce,
60
+ value,
61
+ data,
62
+ to
63
+ };
64
+ }
65
+ return {
66
+ ...populated,
67
+ nonce
68
+ };
69
+ }
70
+ async signTransaction(transaction, loadConfig = {}, resolutionConfig = {}) {
71
+ const unsignedTx = await convertToUnsigned(transaction);
72
+ const populatedTx = await this.populateUnsigned(unsignedTx);
73
+ const serializedTx = serialize(populatedTx).substring(2);
74
+ const { ledgerService } = await import("@ledgerhq/hw-app-eth");
75
+ const resolution = await ledgerService.resolveTransaction(serializedTx, loadConfig, resolutionConfig);
76
+ const sig = await this.withEthApp((eth) => eth.signTransaction(this.path, serializedTx, resolution));
77
+ return serialize(populatedTx, {
78
+ v: BigNumber.from(`0x${sig.v}`).toNumber(),
79
+ r: `0x${sig.r}`,
80
+ s: `0x${sig.s}`
81
+ });
82
+ }
83
+ connect(provider) {
84
+ return new LedgerHQSigner(provider);
85
+ }
86
+ connectUnchecked() {
87
+ throw new Error("method is not implemented");
88
+ }
89
+ sendUncheckedTransaction() {
90
+ throw new Error("method is not implemented");
91
+ }
92
+ async unlock() {
93
+ throw new Error("method is not implemented");
94
+ }
95
+ async _legacySignMessage(_message) {
96
+ throw new Error("method is not implemented");
97
+ }
98
+ async _signTypedData(domain, _types, value) {
99
+ const types = { ..._types };
100
+ delete types.EIP712Domain;
101
+ const encoder = new _TypedDataEncoder(types);
102
+ const data = {
103
+ domain: {
104
+ name: domain.name,
105
+ verifyingContract: domain.verifyingContract,
106
+ version: domain.version,
107
+ chainId: domain.chainId ? parseInt(domain.chainId.toString()) : void 0
108
+ },
109
+ types: {
110
+ ...types,
111
+ EIP712Domain: [
112
+ {
113
+ name: "name",
114
+ type: "string"
115
+ },
116
+ {
117
+ name: "version",
118
+ type: "string"
119
+ },
120
+ {
121
+ name: "chainId",
122
+ type: "uint256"
123
+ },
124
+ {
125
+ name: "verifyingContract",
126
+ type: "address"
127
+ }
128
+ ]
129
+ },
130
+ primaryType: encoder.primaryType,
131
+ message: value
132
+ };
133
+ return this.__signEIP712Message(data);
134
+ }
135
+ async __signEIP712Message(data) {
136
+ const { r, s, v } = await this.withEthApp((eth) => eth.signEIP712Message(this.path, data));
137
+ return joinSignature({
138
+ r: `0x${r}`,
139
+ s: `0x${s}`,
140
+ v
141
+ });
142
+ }
143
+ };
186
144
 
187
- export { LedgerHQSigner };
145
+ //#endregion
146
+ export { LedgerHQSigner };
@@ -1 +1 @@
1
- {"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../src/iframe/connector.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAIrC,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,eAAO,MAAM,YAAY,eAAe,CAAC;AACzC,eAAO,MAAM,IAAI,gBAAgB,CAAC;AAElC,KAAK,uBAAuB,GAAG;IAC7B,OAAO,CAAC,EAAE,6BAA6B,CAAC;IACxC,YAAY,EAAE,KAAK,CAAC;CACrB,CAAC;AAGF,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,YAAY,GACb,EAAE,uBAAuB,6GA0IzB;yBA7Ie,mBAAmB"}
1
+ {"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../src/iframe/connector.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAIrC,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,eAAO,MAAM,YAAY,eAAe,CAAC;AACzC,eAAO,MAAM,IAAI,gBAAgB,CAAC;AAElC,KAAK,uBAAuB,GAAG;IAC7B,OAAO,CAAC,EAAE,6BAA6B,CAAC;IACxC,YAAY,EAAE,KAAK,CAAC;CACrB,CAAC;AAGF,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,YAAY,GACb,EAAE,uBAAuB,6GAmJzB;yBAtJe,mBAAmB"}
@@ -1,176 +1,113 @@
1
- import { __awaiter } from '../_virtual/_tslib.js';
2
- import { createConnector, SwitchChainNotSupportedError } from 'wagmi';
3
- import { UserRejectedRequestError, ResourceUnavailableRpcError } from 'viem';
4
- import { getAddress } from '@ethersproject/address';
5
- import { hexValue } from '@ethersproject/bytes';
6
- import { Web3Provider } from '@ethersproject/providers';
1
+ import { SwitchChainNotSupportedError, createConnector } from "wagmi";
2
+ import { ResourceUnavailableRpcError, UserRejectedRequestError } from "viem";
3
+ import { getAddress } from "@ethersproject/address";
4
+ import { hexValue } from "@ethersproject/bytes";
5
+ import { Web3Provider } from "@ethersproject/providers";
7
6
 
8
- const idLedgerLive = 'ledgerLive';
9
- const name = 'Ledger Live';
10
- ledgerLiveConnector.type = 'ledgerLive';
11
- function ledgerLiveConnector({
12
- options,
13
- defaultChain
14
- }) {
15
- const providers = {};
16
- return createConnector(({
17
- chains,
18
- emitter
19
- }) => ({
20
- id: idLedgerLive,
21
- name,
22
- type: ledgerLiveConnector.type,
23
- getProvider() {
24
- return __awaiter(this, arguments, void 0, function* ({
25
- chainId
26
- } = {}) {
27
- var _a;
28
- const chain = (_a = chains.find(x => x.id === chainId)) !== null && _a !== void 0 ? _a : defaultChain;
29
- if (!providers[chain.id]) {
30
- const {
31
- LedgerIFrameProvider
32
- } = yield import('./provider.js');
33
- providers[chain.id] = new LedgerIFrameProvider(options);
34
- }
35
- return providers[chain.id];
36
- });
37
- },
38
- connect() {
39
- return __awaiter(this, arguments, void 0, function* ({
40
- chainId
41
- } = {}) {
42
- try {
43
- const provider = yield this.getProvider();
44
- // works without bind because it's an obj created(scoped) in a function
45
- provider.on('accountsChanged', this.onAccountsChanged);
46
- provider.on('chainChanged', this.onChainChanged);
47
- emitter.emit('message', {
48
- type: 'connecting'
49
- });
50
- const accounts = yield this.getAccounts();
51
- let currentChainId = yield this.getChainId();
52
- if (chainId && currentChainId !== chainId && this.switchChain) {
53
- const chain = yield this.switchChain({
54
- chainId
55
- });
56
- currentChainId = chain.id;
57
- }
58
- return {
59
- accounts,
60
- chainId: currentChainId
61
- };
62
- } catch (error) {
63
- if (error instanceof Error) {
64
- if (error.code === 4001) {
65
- throw new UserRejectedRequestError(error);
66
- }
67
- throw new ResourceUnavailableRpcError(error);
68
- }
69
- throw error;
70
- }
71
- });
72
- },
73
- switchChain(_a) {
74
- return __awaiter(this, arguments, void 0, function* ({
75
- chainId
76
- }) {
77
- var _b;
78
- const provider = yield this.getProvider();
79
- const id = hexValue(chainId);
80
- try {
81
- yield provider.send('wallet_switchEthereumChain', [{
82
- chainId: id
83
- }]);
84
- return (_b = chains.find(x => x.id === chainId)) !== null && _b !== void 0 ? _b : {
85
- id: chainId,
86
- name: `Chain ${id}`,
87
- network: `${id}`,
88
- nativeCurrency: {
89
- decimals: 18,
90
- name: 'Ether',
91
- symbol: 'ETH'
92
- },
93
- rpcUrls: {
94
- default: {
95
- http: ['']
96
- },
97
- public: {
98
- http: ['']
99
- }
100
- }
101
- };
102
- } catch (error) {
103
- const message = typeof error === 'string' ? error : error === null || error === void 0 ? void 0 : error.message;
104
- if (/user rejected request/i.test(message)) {
105
- throw new UserRejectedRequestError(error);
106
- }
107
- throw new SwitchChainNotSupportedError({
108
- connector: {
109
- name
110
- } // only name is needed to generate an error message
111
- });
112
- }
113
- });
114
- },
115
- getAccounts() {
116
- return __awaiter(this, void 0, void 0, function* () {
117
- const provider = yield this.getProvider();
118
- const accounts = yield provider.send('eth_requestAccounts');
119
- // return checksum address
120
- return accounts.map(getAddress);
121
- });
122
- },
123
- getChainId() {
124
- return __awaiter(this, void 0, void 0, function* () {
125
- const provider = yield this.getProvider();
126
- const chainId = yield provider.send('eth_chainId');
127
- return Number(chainId);
128
- });
129
- },
130
- getSigner() {
131
- return __awaiter(this, void 0, void 0, function* () {
132
- const [provider, accounts] = yield Promise.all([this.getProvider(), this.getAccounts()]);
133
- return new Web3Provider(provider).getSigner(accounts[0]);
134
- });
135
- },
136
- isAuthorized() {
137
- return __awaiter(this, void 0, void 0, function* () {
138
- try {
139
- const provider = yield this.getProvider();
140
- const accounts = yield provider.send('eth_accounts');
141
- const account = accounts[0];
142
- return !!account;
143
- } catch (_a) {
144
- return false;
145
- }
146
- });
147
- },
148
- onAccountsChanged(accounts) {
149
- if (accounts.length === 0 || !accounts[0]) {
150
- emitter.emit('disconnect');
151
- void this.disconnect();
152
- } else {
153
- emitter.emit('change', {
154
- accounts
155
- });
156
- }
157
- },
158
- onChainChanged(chainId) {
159
- emitter.emit('change', {
160
- chainId: Number(chainId)
161
- });
162
- },
163
- disconnect() {
164
- return __awaiter(this, void 0, void 0, function* () {
165
- const provider = yield this.getProvider();
166
- provider.removeListener('accountsChanged', this.onAccountsChanged);
167
- provider.removeListener('chainChanged', this.onChainChanged);
168
- });
169
- },
170
- onDisconnect() {
171
- emitter.emit('disconnect');
172
- }
173
- }));
7
+ //#region src/iframe/connector.ts
8
+ const idLedgerLive = "ledgerLive";
9
+ const name = "Ledger Live";
10
+ ledgerLiveConnector.type = "ledgerLive";
11
+ function ledgerLiveConnector({ options, defaultChain }) {
12
+ const providers = {};
13
+ return createConnector(({ chains, emitter }) => ({
14
+ id: idLedgerLive,
15
+ name,
16
+ type: ledgerLiveConnector.type,
17
+ async getProvider({ chainId } = {}) {
18
+ const chain = chains.find((x) => x.id === chainId) ?? defaultChain;
19
+ if (!providers[chain.id]) {
20
+ const { LedgerIFrameProvider } = await import("./provider.js");
21
+ providers[chain.id] = new LedgerIFrameProvider(options);
22
+ }
23
+ return providers[chain.id];
24
+ },
25
+ async connect({ chainId, withCapabilities } = {}) {
26
+ try {
27
+ const provider = await this.getProvider();
28
+ provider.on("accountsChanged", this.onAccountsChanged);
29
+ provider.on("chainChanged", this.onChainChanged);
30
+ emitter.emit("message", { type: "connecting" });
31
+ const accounts = await this.getAccounts();
32
+ let currentChainId = await this.getChainId();
33
+ if (chainId && currentChainId !== chainId && this.switchChain) currentChainId = (await this.switchChain({ chainId })).id;
34
+ return {
35
+ accounts: withCapabilities ? accounts.map((address) => ({
36
+ address,
37
+ capabilities: {}
38
+ })) : accounts,
39
+ chainId: currentChainId
40
+ };
41
+ } catch (error) {
42
+ if (error instanceof Error) {
43
+ if (error.code === 4001) throw new UserRejectedRequestError(error);
44
+ throw new ResourceUnavailableRpcError(error);
45
+ }
46
+ throw error;
47
+ }
48
+ },
49
+ async switchChain({ chainId }) {
50
+ const provider = await this.getProvider();
51
+ const id = hexValue(chainId);
52
+ try {
53
+ await provider.send("wallet_switchEthereumChain", [{ chainId: id }]);
54
+ return chains.find((x) => x.id === chainId) ?? {
55
+ id: chainId,
56
+ name: `Chain ${id}`,
57
+ network: `${id}`,
58
+ nativeCurrency: {
59
+ decimals: 18,
60
+ name: "Ether",
61
+ symbol: "ETH"
62
+ },
63
+ rpcUrls: {
64
+ default: { http: [""] },
65
+ public: { http: [""] }
66
+ }
67
+ };
68
+ } catch (error) {
69
+ const message = typeof error === "string" ? error : error?.message;
70
+ if (/user rejected request/i.test(message)) throw new UserRejectedRequestError(error);
71
+ throw new SwitchChainNotSupportedError({ connector: { name } });
72
+ }
73
+ },
74
+ async getAccounts() {
75
+ return (await (await this.getProvider()).send("eth_requestAccounts")).map(getAddress);
76
+ },
77
+ async getChainId() {
78
+ const chainId = await (await this.getProvider()).send("eth_chainId");
79
+ return Number(chainId);
80
+ },
81
+ async getSigner() {
82
+ const [provider, accounts] = await Promise.all([this.getProvider(), this.getAccounts()]);
83
+ return new Web3Provider(provider).getSigner(accounts[0]);
84
+ },
85
+ async isAuthorized() {
86
+ try {
87
+ return !!(await (await this.getProvider()).send("eth_accounts"))[0];
88
+ } catch {
89
+ return false;
90
+ }
91
+ },
92
+ onAccountsChanged(accounts) {
93
+ if (accounts.length === 0 || !accounts[0]) {
94
+ emitter.emit("disconnect");
95
+ this.disconnect();
96
+ } else emitter.emit("change", { accounts });
97
+ },
98
+ onChainChanged(chainId) {
99
+ emitter.emit("change", { chainId: Number(chainId) });
100
+ },
101
+ async disconnect() {
102
+ const provider = await this.getProvider();
103
+ provider.removeListener("accountsChanged", this.onAccountsChanged);
104
+ provider.removeListener("chainChanged", this.onChainChanged);
105
+ },
106
+ onDisconnect() {
107
+ emitter.emit("disconnect");
108
+ }
109
+ }));
174
110
  }
175
111
 
176
- export { idLedgerLive, ledgerLiveConnector, name };
112
+ //#endregion
113
+ export { idLedgerLive, ledgerLiveConnector, name };
@@ -1,13 +1,14 @@
1
+ //#region src/iframe/helpers.ts
1
2
  const isIframe = () => globalThis.window && globalThis.window.parent !== globalThis.window;
2
3
  const isLedgerLive = () => {
3
- if (typeof window === 'undefined') return false;
4
- try {
5
- const params = new URLSearchParams(window.self.location.search);
6
- const isEmbed = !!params.get('embed');
7
- return isIframe() && isEmbed;
8
- } catch (error) {
9
- return false;
10
- }
4
+ if (typeof window === "undefined") return false;
5
+ try {
6
+ const isEmbed = !!new URLSearchParams(window.self.location.search).get("embed");
7
+ return isIframe() && isEmbed;
8
+ } catch (error) {
9
+ return false;
10
+ }
11
11
  };
12
12
 
13
- export { isIframe, isLedgerLive };
13
+ //#endregion
14
+ export { isIframe, isLedgerLive };
@@ -0,0 +1,2 @@
1
+ import { idLedgerLive, ledgerLiveConnector, name } from "./connector.js";
2
+ import { isIframe, isLedgerLive } from "./helpers.js";