@initia/initia.js 0.2.20 → 0.2.22

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.
Files changed (63) hide show
  1. package/README.md +30 -31
  2. package/dist/TransportWebHID-BJGOHoD4.js +1 -0
  3. package/dist/TransportWebHID-BpNQALzF.mjs +154 -0
  4. package/dist/TransportWebUSB-Bog8kAV9.js +1 -0
  5. package/dist/TransportWebUSB-Bs9AHNsu.mjs +196 -0
  6. package/dist/client/index.d.ts +0 -1
  7. package/dist/client/rest/APIRequester.d.ts +1 -0
  8. package/dist/client/rest/Wallet.d.ts +1 -0
  9. package/dist/client/rest/api/AuthzAPI.d.ts +1 -1
  10. package/dist/client/rest/api/EvmAPI.d.ts +4 -4
  11. package/dist/client/rest/api/ForwardingAPI.d.ts +2 -1
  12. package/dist/client/rest/api/GovAPI.d.ts +4 -4
  13. package/dist/client/rest/api/GroupAPI.d.ts +7 -7
  14. package/dist/client/rest/api/IbcAPI.d.ts +2 -2
  15. package/dist/client/rest/api/IbcNftAPI.d.ts +1 -1
  16. package/dist/client/rest/api/IbcPermAPI.d.ts +1 -1
  17. package/dist/client/rest/api/IbcTransferAPI.d.ts +1 -11
  18. package/dist/client/rest/api/MoveAPI.d.ts +12 -20
  19. package/dist/client/rest/api/MstakingAPI.d.ts +1 -1
  20. package/dist/client/rest/api/OpchildAPI.d.ts +1 -1
  21. package/dist/client/rest/api/OphostAPI.d.ts +10 -10
  22. package/dist/client/rest/api/SlashingAPI.d.ts +4 -22
  23. package/dist/client/rest/api/TxAPI.d.ts +3 -3
  24. package/dist/client/rest/api/WasmAPI.d.ts +4 -4
  25. package/dist/core/Duration.d.ts +1 -2
  26. package/dist/core/auth/BaseAccount.d.ts +2 -2
  27. package/dist/core/bank/msgs/MsgMultiSend.d.ts +8 -8
  28. package/dist/core/crisis/msgs/MsgVerifyInvariant.d.ts +7 -7
  29. package/dist/core/gov/Vote.d.ts +2 -2
  30. package/dist/core/ibc/applications/transfer/index.d.ts +1 -0
  31. package/dist/core/ibc/core/client/index.d.ts +1 -0
  32. package/dist/core/ibc/core/client/msgs/tendermint/crypto.d.ts +2 -2
  33. package/dist/core/ibc/core/client/msgs/tendermint/types.d.ts +27 -28
  34. package/dist/core/ibc/lightclient/tendermint/Header.d.ts +5 -5
  35. package/dist/core/move/Module.d.ts +36 -0
  36. package/dist/core/move/index.d.ts +1 -0
  37. package/dist/core/move/msgs/MsgExecute.d.ts +2 -2
  38. package/dist/core/move/msgs/MsgPublish.d.ts +2 -2
  39. package/dist/core/move/msgs/MsgScript.d.ts +2 -2
  40. package/dist/core/mstaking/Redelegation.d.ts +3 -3
  41. package/dist/core/mstaking/UnbondingDelegation.d.ts +3 -3
  42. package/dist/core/mstaking/Validator.d.ts +9 -9
  43. package/dist/core/mstaking/msgs/MsgDelegate.d.ts +2 -2
  44. package/dist/core/mstaking/msgs/MsgEditValidator.d.ts +2 -2
  45. package/dist/core/mstaking/msgs/MsgUndelegate.d.ts +2 -2
  46. package/dist/core/slashing/SlashingParams.d.ts +4 -4
  47. package/dist/core/slashing/ValidatorSigningInfo.d.ts +37 -0
  48. package/dist/core/slashing/index.d.ts +1 -0
  49. package/dist/core/tx/SignatureV2.d.ts +1 -1
  50. package/dist/index-BNBWMUWc.mjs +456 -0
  51. package/dist/index-BY4R60_E.js +2 -0
  52. package/dist/index.cjs.js +2 -2
  53. package/dist/index.es.js +11293 -9146
  54. package/dist/key/RawKey.d.ts +1 -1
  55. package/dist/util/bcs.d.ts +10 -10
  56. package/package.json +14 -18
  57. package/dist/TransportWebHID-BwOWyIog.mjs +0 -313
  58. package/dist/TransportWebHID-CVJmgfzo.js +0 -1
  59. package/dist/TransportWebUSB-BjylRdFj.mjs +0 -413
  60. package/dist/TransportWebUSB-V4VV5RPc.js +0 -1
  61. package/dist/client/LocalInitia.d.ts +0 -18
  62. package/dist/index-CGO7OOZz.js +0 -2
  63. package/dist/index-LYdmc_QU.mjs +0 -449
@@ -1,7 +1,7 @@
1
1
  import { Key } from './Key';
2
2
  export declare class RawKey extends Key {
3
- eth: boolean;
4
3
  privateKey: Buffer;
4
+ eth: boolean;
5
5
  constructor(privateKey: Buffer, eth?: boolean);
6
6
  static fromHex(key: string): RawKey;
7
7
  sign(payload: Buffer): Promise<Buffer>;
@@ -18,20 +18,20 @@ export declare const bcs: {
18
18
  uleb128(options?: BcsTypeOptions<number>): import('@mysten/bcs').BcsType<number, number>;
19
19
  bytes<T extends number>(size: T, options?: BcsTypeOptions<Uint8Array, Iterable<number>>): import('@mysten/bcs').BcsType<Uint8Array, Uint8Array>;
20
20
  string(options?: BcsTypeOptions<string>): import('@mysten/bcs').BcsType<string, string>;
21
- fixedArray<T_1, Input>(size: number, type: import('@mysten/bcs').BcsType<T_1, Input>, options?: BcsTypeOptions<T_1[], Iterable<Input> & {
21
+ fixedArray<T, Input>(size: number, type: import('@mysten/bcs').BcsType<T, Input>, options?: BcsTypeOptions<T[], Iterable<Input> & {
22
22
  length: number;
23
- }> | undefined): import('@mysten/bcs').BcsType<T_1[], Iterable<Input> & {
23
+ }>): import('@mysten/bcs').BcsType<T[], Iterable<Input> & {
24
24
  length: number;
25
25
  }>;
26
- option<T_2, Input_1>(type: import('@mysten/bcs').BcsType<T_2, Input_1>): import('@mysten/bcs').BcsType<T_2 | null, Input_1 | null | undefined>;
27
- vector<T_3, Input_2>(type: import('@mysten/bcs').BcsType<T_3, Input_2>, options?: BcsTypeOptions<T_3[], Iterable<Input_2> & {
26
+ option<T, Input>(type: import('@mysten/bcs').BcsType<T, Input>): import('@mysten/bcs').BcsType<T | null, Input | null | undefined>;
27
+ vector<T, Input>(type: import('@mysten/bcs').BcsType<T, Input>, options?: BcsTypeOptions<T[], Iterable<Input> & {
28
28
  length: number;
29
- }> | undefined): import('@mysten/bcs').BcsType<T_3[], Iterable<Input_2> & {
29
+ }>): import('@mysten/bcs').BcsType<T[], Iterable<Input> & {
30
30
  length: number;
31
31
  }>;
32
- tuple<const Types extends readonly import('@mysten/bcs').BcsType<any, any>[]>(types: Types, options?: BcsTypeOptions<{ -readonly [K in keyof Types]: Types[K] extends import('@mysten/bcs').BcsType<infer T_4, any> ? T_4 : never; }, { [K_1 in keyof Types]: Types[K_1] extends import('@mysten/bcs').BcsType<any, infer T_5> ? T_5 : never; }> | undefined): import('@mysten/bcs').BcsType<{ -readonly [K_2 in keyof Types]: Types[K_2] extends import('@mysten/bcs').BcsType<infer T_6, any> ? T_6 : never; }, { [K_3 in keyof Types]: Types[K_3] extends import('@mysten/bcs').BcsType<any, infer T_7> ? T_7 : never; }>;
33
- struct<T_8 extends Record<string, import('@mysten/bcs').BcsType<any, any>>>(name: string, fields: T_8, options?: Omit<BcsTypeOptions<{ [K_4 in keyof T_8]: T_8[K_4] extends import('@mysten/bcs').BcsType<infer U, any> ? U : never; }, { [K_5 in keyof T_8]: T_8[K_5] extends import('@mysten/bcs').BcsType<any, infer U_1> ? U_1 : never; }>, "name"> | undefined): import('@mysten/bcs').BcsType<{ [K_6 in keyof T_8]: T_8[K_6] extends import('@mysten/bcs').BcsType<infer U_2, any> ? U_2 : never; }, { [K_7 in keyof T_8]: T_8[K_7] extends import('@mysten/bcs').BcsType<any, infer U_3> ? U_3 : never; }>;
34
- enum<T_9 extends Record<string, import('@mysten/bcs').BcsType<any, any> | null>>(name: string, values: T_9, options?: Omit<BcsTypeOptions<import('@mysten/bcs').EnumOutputShape<{ [K_8 in keyof T_9]: T_9[K_8] extends import('@mysten/bcs').BcsType<infer U_4, any> ? U_4 : true; }>, import('@mysten/bcs').EnumInputShape<{ [K_9 in keyof T_9]: T_9[K_9] extends import('@mysten/bcs').BcsType<any, infer U_5> ? U_5 : boolean | object | null; }>>, "name"> | undefined): import('@mysten/bcs').BcsType<import('@mysten/bcs').EnumOutputShape<{ [K_10 in keyof T_9]: T_9[K_10] extends import('@mysten/bcs').BcsType<infer U_6, any> ? U_6 : true; }>, import('@mysten/bcs').EnumInputShape<{ [K_11 in keyof T_9]: T_9[K_11] extends import('@mysten/bcs').BcsType<any, infer U_7> ? U_7 : boolean | object | null; }>>;
35
- map<K_12, V, InputK = K_12, InputV = V>(keyType: import('@mysten/bcs').BcsType<K_12, InputK>, valueType: import('@mysten/bcs').BcsType<V, InputV>): import('@mysten/bcs').BcsType<Map<K_12, V>, Map<InputK, InputV>>;
36
- lazy<T_10 extends import('@mysten/bcs').BcsType<any, any>>(cb: () => T_10): T_10;
32
+ tuple<const Types extends readonly import('@mysten/bcs').BcsType<any>[]>(types: Types, options?: BcsTypeOptions<{ -readonly [K in keyof Types]: Types[K] extends import('@mysten/bcs').BcsType<infer T, any> ? T : never; }, { [K in keyof Types]: Types[K] extends import('@mysten/bcs').BcsType<any, infer T> ? T : never; }>): import('@mysten/bcs').BcsType<{ -readonly [K in keyof Types]: Types[K] extends import('@mysten/bcs').BcsType<infer T, any> ? T : never; }, { [K_1 in keyof Types]: Types[K_1] extends import('@mysten/bcs').BcsType<any, infer T_1> ? T_1 : never; }>;
33
+ struct<T extends Record<string, import('@mysten/bcs').BcsType<any>>>(name: string, fields: T, options?: Omit<BcsTypeOptions<{ [K in keyof T]: T[K] extends import('@mysten/bcs').BcsType<infer U, any> ? U : never; }, { [K in keyof T]: T[K] extends import('@mysten/bcs').BcsType<any, infer U> ? U : never; }>, "name">): import('@mysten/bcs').BcsType<{ [K in keyof T]: T[K] extends import('@mysten/bcs').BcsType<infer U, any> ? U : never; }, { [K_1 in keyof T]: T[K_1] extends import('@mysten/bcs').BcsType<any, infer U_1> ? U_1 : never; }>;
34
+ enum<T extends Record<string, import('@mysten/bcs').BcsType<any> | null>>(name: string, values: T, options?: Omit<BcsTypeOptions<import('@mysten/bcs').EnumOutputShape<{ [K in keyof T]: T[K] extends import('@mysten/bcs').BcsType<infer U, any> ? U : true; }>, import('@mysten/bcs').EnumInputShape<{ [K in keyof T]: T[K] extends import('@mysten/bcs').BcsType<any, infer U> ? U : boolean | object | null; }>>, "name">): import('@mysten/bcs').BcsType<import('@mysten/bcs').EnumOutputShape<{ [K in keyof T]: T[K] extends import('@mysten/bcs').BcsType<infer U, any> ? U : true; }>, import('@mysten/bcs').EnumInputShape<{ [K_1 in keyof T]: T[K_1] extends import('@mysten/bcs').BcsType<any, infer U_1> ? U_1 : boolean | object | null; }>>;
35
+ map<K, V, InputK = K, InputV = V>(keyType: import('@mysten/bcs').BcsType<K, InputK>, valueType: import('@mysten/bcs').BcsType<V, InputV>): import('@mysten/bcs').BcsType<Map<K, V>, Map<InputK, InputV>>;
36
+ lazy<T extends import('@mysten/bcs').BcsType<any>>(cb: () => T): T;
37
37
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@initia/initia.js",
3
- "version": "0.2.20",
3
+ "version": "0.2.22",
4
4
  "description": "The JavaScript SDK for Initia",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Initia Foundation",
@@ -40,7 +40,6 @@
40
40
  "@types/ws": "^7.4.7",
41
41
  "@typescript-eslint/eslint-plugin": "^7",
42
42
  "@typescript-eslint/parser": "^7",
43
- "crypto-browserify": "^3.12.0",
44
43
  "eslint": "^8.57.0",
45
44
  "eslint-config-prettier": "^9.1.0",
46
45
  "eslint-plugin-import": "^2.29.0",
@@ -49,10 +48,7 @@
49
48
  "jest": "^29.1.1",
50
49
  "lint-staged": "^13.3.0",
51
50
  "prettier": "^3.1.1",
52
- "process": "^0.11.10",
53
- "stream-browserify": "^3.0.0",
54
51
  "ts-jest": "^29.2.5",
55
- "ts-loader": "^9.4.1",
56
52
  "ts-node": "^10.9.2",
57
53
  "typescript": "^5.4.5",
58
54
  "typescript-eslint": "^7.13.1",
@@ -60,24 +56,24 @@
60
56
  "vite-plugin-dts": "^4.2.3"
61
57
  },
62
58
  "dependencies": {
63
- "@initia/initia.proto": "^0.2.3",
64
- "@initia/opinit.proto": "^0.0.10",
65
- "@ledgerhq/hw-transport": "^6.27.12",
66
- "@ledgerhq/hw-transport-webhid": "^6.27.12",
67
- "@ledgerhq/hw-transport-webusb": "^6.27.12",
68
- "@mysten/bcs": "^1.0.2",
69
- "axios": "^1.7.4",
59
+ "@bitcoinerlab/secp256k1": "^1.1.1",
60
+ "@initia/initia.proto": "^0.2.4",
61
+ "@initia/opinit.proto": "^0.0.11",
62
+ "@ledgerhq/hw-transport": "^6.31.4",
63
+ "@ledgerhq/hw-transport-webhid": "^6.29.4",
64
+ "@ledgerhq/hw-transport-webusb": "^6.29.4",
65
+ "@mysten/bcs": "^1.1.0",
66
+ "axios": "^1.7.7",
70
67
  "bech32": "^2.0.0",
71
- "bignumber.js": "^9.1.0",
72
- "bip32": "^2.0.6",
73
- "bip39": "^3.0.4",
68
+ "bignumber.js": "^9.1.2",
69
+ "bip32": "^5.0.0-rc.0",
70
+ "bip39": "^3.1.0",
74
71
  "jscrypto": "^1.0.3",
75
72
  "keccak256": "^1.0.6",
76
- "long": "^5.2.0",
77
73
  "ripemd160": "^2.0.2",
78
- "secp256k1": "^5.0.0",
74
+ "secp256k1": "^5.0.1",
79
75
  "semver": "^7.6.3",
80
- "ws": "^7.5.10"
76
+ "ws": "^8.18.0"
81
77
  },
82
78
  "lint-staged": {
83
79
  "src/**/*.{mjs|ts}": [
@@ -1,313 +0,0 @@
1
- import E from "@ledgerhq/hw-transport";
2
- import { l as _, c as L, D as T, i as x, T as I, a as C, b as S, d as O } from "./index-LYdmc_QU.mjs";
3
- var R = /* @__PURE__ */ function() {
4
- var u = function(i, e) {
5
- return u = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n, r) {
6
- n.__proto__ = r;
7
- } || function(n, r) {
8
- for (var t in r) Object.prototype.hasOwnProperty.call(r, t) && (n[t] = r[t]);
9
- }, u(i, e);
10
- };
11
- return function(i, e) {
12
- if (typeof e != "function" && e !== null)
13
- throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
14
- u(i, e);
15
- function n() {
16
- this.constructor = i;
17
- }
18
- i.prototype = e === null ? Object.create(e) : (n.prototype = e.prototype, new n());
19
- };
20
- }(), l = function(u, i, e, n) {
21
- function r(t) {
22
- return t instanceof e ? t : new e(function(c) {
23
- c(t);
24
- });
25
- }
26
- return new (e || (e = Promise))(function(t, c) {
27
- function f(a) {
28
- try {
29
- o(n.next(a));
30
- } catch (h) {
31
- c(h);
32
- }
33
- }
34
- function s(a) {
35
- try {
36
- o(n.throw(a));
37
- } catch (h) {
38
- c(h);
39
- }
40
- }
41
- function o(a) {
42
- a.done ? t(a.value) : r(a.value).then(f, s);
43
- }
44
- o((n = n.apply(u, i || [])).next());
45
- });
46
- }, d = function(u, i) {
47
- var e = { label: 0, sent: function() {
48
- if (t[0] & 1) throw t[1];
49
- return t[1];
50
- }, trys: [], ops: [] }, n, r, t, c;
51
- return c = { next: f(0), throw: f(1), return: f(2) }, typeof Symbol == "function" && (c[Symbol.iterator] = function() {
52
- return this;
53
- }), c;
54
- function f(o) {
55
- return function(a) {
56
- return s([o, a]);
57
- };
58
- }
59
- function s(o) {
60
- if (n) throw new TypeError("Generator is already executing.");
61
- for (; e; ) try {
62
- if (n = 1, r && (t = o[0] & 2 ? r.return : o[0] ? r.throw || ((t = r.return) && t.call(r), 0) : r.next) && !(t = t.call(r, o[1])).done) return t;
63
- switch (r = 0, t && (o = [o[0] & 2, t.value]), o[0]) {
64
- case 0:
65
- case 1:
66
- t = o;
67
- break;
68
- case 4:
69
- return e.label++, { value: o[1], done: !1 };
70
- case 5:
71
- e.label++, r = o[1], o = [0];
72
- continue;
73
- case 7:
74
- o = e.ops.pop(), e.trys.pop();
75
- continue;
76
- default:
77
- if (t = e.trys, !(t = t.length > 0 && t[t.length - 1]) && (o[0] === 6 || o[0] === 2)) {
78
- e = 0;
79
- continue;
80
- }
81
- if (o[0] === 3 && (!t || o[1] > t[0] && o[1] < t[3])) {
82
- e.label = o[1];
83
- break;
84
- }
85
- if (o[0] === 6 && e.label < t[1]) {
86
- e.label = t[1], t = o;
87
- break;
88
- }
89
- if (t && e.label < t[2]) {
90
- e.label = t[2], e.ops.push(o);
91
- break;
92
- }
93
- t[2] && e.ops.pop(), e.trys.pop();
94
- continue;
95
- }
96
- o = i.call(u, e);
97
- } catch (a) {
98
- o = [6, a], r = 0;
99
- } finally {
100
- n = t = 0;
101
- }
102
- if (o[0] & 5) throw o[1];
103
- return { value: o[0] ? o[1] : void 0, done: !0 };
104
- }
105
- }, A = function(u, i) {
106
- var e = typeof Symbol == "function" && u[Symbol.iterator];
107
- if (!e) return u;
108
- var n = e.call(u), r, t = [], c;
109
- try {
110
- for (; (i === void 0 || i-- > 0) && !(r = n.next()).done; ) t.push(r.value);
111
- } catch (f) {
112
- c = { error: f };
113
- } finally {
114
- try {
115
- r && !r.done && (e = n.return) && e.call(n);
116
- } finally {
117
- if (c) throw c.error;
118
- }
119
- }
120
- return t;
121
- }, B = [
122
- {
123
- vendorId: S
124
- }
125
- ], H = function() {
126
- return Promise.resolve(!!(window.navigator && window.navigator.hid));
127
- }, w = function() {
128
- var u = navigator.hid;
129
- if (!u)
130
- throw new C("navigator.hid is not supported", "HIDNotSupported");
131
- return u;
132
- };
133
- function k() {
134
- return l(this, void 0, void 0, function() {
135
- var u;
136
- return d(this, function(i) {
137
- switch (i.label) {
138
- case 0:
139
- return [4, w().requestDevice({
140
- filters: B
141
- })];
142
- case 1:
143
- return u = i.sent(), Array.isArray(u) ? [2, u] : [2, [u]];
144
- }
145
- });
146
- });
147
- }
148
- function b() {
149
- return l(this, void 0, void 0, function() {
150
- var u;
151
- return d(this, function(i) {
152
- switch (i.label) {
153
- case 0:
154
- return [4, w().getDevices()];
155
- case 1:
156
- return u = i.sent(), [2, u.filter(function(e) {
157
- return e.vendorId === S;
158
- })];
159
- }
160
- });
161
- });
162
- }
163
- function P() {
164
- return l(this, void 0, void 0, function() {
165
- var u, i;
166
- return d(this, function(e) {
167
- switch (e.label) {
168
- case 0:
169
- return [4, b()];
170
- case 1:
171
- return u = e.sent(), u.length > 0 ? [2, u[0]] : [4, k()];
172
- case 2:
173
- return i = e.sent(), [2, i[0]];
174
- }
175
- });
176
- });
177
- }
178
- var q = (
179
- /** @class */
180
- function(u) {
181
- R(i, u);
182
- function i(e) {
183
- var n = u.call(this) || this;
184
- return n.channel = Math.floor(Math.random() * 65535), n.packetSize = 64, n.inputs = [], n.read = function() {
185
- return n.inputs.length ? Promise.resolve(n.inputs.shift()) : new Promise(function(r) {
186
- n.inputCallback = r;
187
- });
188
- }, n.onInputReport = function(r) {
189
- var t = Buffer.from(r.data.buffer);
190
- n.inputCallback ? (n.inputCallback(t), n.inputCallback = null) : n.inputs.push(t);
191
- }, n._disconnectEmitted = !1, n._emitDisconnect = function(r) {
192
- n._disconnectEmitted || (n._disconnectEmitted = !0, n.emit("disconnect", r));
193
- }, n.exchange = function(r) {
194
- return l(n, void 0, void 0, function() {
195
- var t, c = this;
196
- return d(this, function(f) {
197
- switch (f.label) {
198
- case 0:
199
- return [4, this.exchangeAtomicImpl(function() {
200
- return l(c, void 0, void 0, function() {
201
- var s, o, a, h, y, p, m, g, D;
202
- return d(this, function(v) {
203
- switch (v.label) {
204
- case 0:
205
- s = this, o = s.channel, a = s.packetSize, _("apdu", "=> " + r.toString("hex")), h = L(o, a), y = h.makeBlocks(r), p = 0, v.label = 1;
206
- case 1:
207
- return p < y.length ? [4, this.device.sendReport(0, y[p])] : [3, 4];
208
- case 2:
209
- v.sent(), v.label = 3;
210
- case 3:
211
- return p++, [3, 1];
212
- case 4:
213
- return (m = h.getReducedResult(g)) ? [3, 6] : [4, this.read()];
214
- case 5:
215
- return D = v.sent(), g = h.reduceResponse(g, D), [3, 4];
216
- case 6:
217
- return _("apdu", "<= " + m.toString("hex")), [2, m];
218
- }
219
- });
220
- });
221
- }).catch(function(s) {
222
- throw s && s.message && s.message.includes("write") ? (c._emitDisconnect(s), new T(s.message)) : s;
223
- })];
224
- case 1:
225
- return t = f.sent(), [2, t];
226
- }
227
- });
228
- });
229
- }, n.device = e, n.deviceModel = typeof e.productId == "number" ? x(e.productId) : void 0, e.addEventListener("inputreport", n.onInputReport), n;
230
- }
231
- return i.request = function() {
232
- return l(this, void 0, void 0, function() {
233
- var e, n;
234
- return d(this, function(r) {
235
- switch (r.label) {
236
- case 0:
237
- return [4, k()];
238
- case 1:
239
- return e = A.apply(void 0, [r.sent(), 1]), n = e[0], [2, i.open(n)];
240
- }
241
- });
242
- });
243
- }, i.openConnected = function() {
244
- return l(this, void 0, void 0, function() {
245
- var e;
246
- return d(this, function(n) {
247
- switch (n.label) {
248
- case 0:
249
- return [4, b()];
250
- case 1:
251
- return e = n.sent(), e.length === 0 ? [2, null] : [2, i.open(e[0])];
252
- }
253
- });
254
- });
255
- }, i.open = function(e) {
256
- return l(this, void 0, void 0, function() {
257
- var n, r;
258
- return d(this, function(t) {
259
- switch (t.label) {
260
- case 0:
261
- return [4, e.open()];
262
- case 1:
263
- return t.sent(), n = new i(e), r = function(c) {
264
- e === c.device && (w().removeEventListener("disconnect", r), n._emitDisconnect(new O()));
265
- }, w().addEventListener("disconnect", r), [2, n];
266
- }
267
- });
268
- });
269
- }, i.prototype.close = function() {
270
- return l(this, void 0, void 0, function() {
271
- return d(this, function(e) {
272
- switch (e.label) {
273
- case 0:
274
- return [4, this.exchangeBusyPromise];
275
- case 1:
276
- return e.sent(), this.device.removeEventListener("inputreport", this.onInputReport), [4, this.device.close()];
277
- case 2:
278
- return e.sent(), [
279
- 2
280
- /*return*/
281
- ];
282
- }
283
- });
284
- });
285
- }, i.prototype.setScrambleKey = function() {
286
- }, i.isSupported = H, i.list = b, i.listen = function(e) {
287
- var n = !1;
288
- P().then(function(t) {
289
- if (!t)
290
- e.error(new I("Access denied to use Ledger device"));
291
- else if (!n) {
292
- var c = typeof t.productId == "number" ? x(t.productId) : void 0;
293
- e.next({
294
- type: "add",
295
- descriptor: t,
296
- deviceModel: c
297
- }), e.complete();
298
- }
299
- }, function(t) {
300
- e.error(new I(t.message));
301
- });
302
- function r() {
303
- n = !0;
304
- }
305
- return {
306
- unsubscribe: r
307
- };
308
- }, i;
309
- }(E)
310
- );
311
- export {
312
- q as default
313
- };
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("@ledgerhq/hw-transport"),f=require("./index-CGO7OOZz.js");var I=function(){var u=function(i,e){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])},u(i,e)};return function(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");u(i,e);function t(){this.constructor=i}i.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}}(),l=function(u,i,e,t){function r(n){return n instanceof e?n:new e(function(c){c(n)})}return new(e||(e=Promise))(function(n,c){function d(a){try{o(t.next(a))}catch(v){c(v)}}function s(a){try{o(t.throw(a))}catch(v){c(v)}}function o(a){a.done?n(a.value):r(a.value).then(d,s)}o((t=t.apply(u,i||[])).next())})},h=function(u,i){var e={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},t,r,n,c;return c={next:d(0),throw:d(1),return:d(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function d(o){return function(a){return s([o,a])}}function s(o){if(t)throw new TypeError("Generator is already executing.");for(;e;)try{if(t=1,r&&(n=o[0]&2?r.return:o[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,o[1])).done)return n;switch(r=0,n&&(o=[o[0]&2,n.value]),o[0]){case 0:case 1:n=o;break;case 4:return e.label++,{value:o[1],done:!1};case 5:e.label++,r=o[1],o=[0];continue;case 7:o=e.ops.pop(),e.trys.pop();continue;default:if(n=e.trys,!(n=n.length>0&&n[n.length-1])&&(o[0]===6||o[0]===2)){e=0;continue}if(o[0]===3&&(!n||o[1]>n[0]&&o[1]<n[3])){e.label=o[1];break}if(o[0]===6&&e.label<n[1]){e.label=n[1],n=o;break}if(n&&e.label<n[2]){e.label=n[2],e.ops.push(o);break}n[2]&&e.ops.pop(),e.trys.pop();continue}o=i.call(u,e)}catch(a){o=[6,a],r=0}finally{t=n=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}},k=function(u,i){var e=typeof Symbol=="function"&&u[Symbol.iterator];if(!e)return u;var t=e.call(u),r,n=[],c;try{for(;(i===void 0||i-- >0)&&!(r=t.next()).done;)n.push(r.value)}catch(d){c={error:d}}finally{try{r&&!r.done&&(e=t.return)&&e.call(t)}finally{if(c)throw c.error}}return n},E=[{vendorId:f.ledgerUSBVendorId}],O=function(){return Promise.resolve(!!(window.navigator&&window.navigator.hid))},w=function(){var u=navigator.hid;if(!u)throw new f.TransportError("navigator.hid is not supported","HIDNotSupported");return u};function S(){return l(this,void 0,void 0,function(){var u;return h(this,function(i){switch(i.label){case 0:return[4,w().requestDevice({filters:E})];case 1:return u=i.sent(),Array.isArray(u)?[2,u]:[2,[u]]}})})}function _(){return l(this,void 0,void 0,function(){var u;return h(this,function(i){switch(i.label){case 0:return[4,w().getDevices()];case 1:return u=i.sent(),[2,u.filter(function(e){return e.vendorId===f.ledgerUSBVendorId})]}})})}function T(){return l(this,void 0,void 0,function(){var u,i;return h(this,function(e){switch(e.label){case 0:return[4,_()];case 1:return u=e.sent(),u.length>0?[2,u[0]]:[4,S()];case 2:return i=e.sent(),[2,i[0]]}})})}var C=function(u){I(i,u);function i(e){var t=u.call(this)||this;return t.channel=Math.floor(Math.random()*65535),t.packetSize=64,t.inputs=[],t.read=function(){return t.inputs.length?Promise.resolve(t.inputs.shift()):new Promise(function(r){t.inputCallback=r})},t.onInputReport=function(r){var n=Buffer.from(r.data.buffer);t.inputCallback?(t.inputCallback(n),t.inputCallback=null):t.inputs.push(n)},t._disconnectEmitted=!1,t._emitDisconnect=function(r){t._disconnectEmitted||(t._disconnectEmitted=!0,t.emit("disconnect",r))},t.exchange=function(r){return l(t,void 0,void 0,function(){var n,c=this;return h(this,function(d){switch(d.label){case 0:return[4,this.exchangeAtomicImpl(function(){return l(c,void 0,void 0,function(){var s,o,a,v,g,y,b,m,D;return h(this,function(p){switch(p.label){case 0:s=this,o=s.channel,a=s.packetSize,f.log("apdu","=> "+r.toString("hex")),v=f.createHIDframing(o,a),g=v.makeBlocks(r),y=0,p.label=1;case 1:return y<g.length?[4,this.device.sendReport(0,g[y])]:[3,4];case 2:p.sent(),p.label=3;case 3:return y++,[3,1];case 4:return(b=v.getReducedResult(m))?[3,6]:[4,this.read()];case 5:return D=p.sent(),m=v.reduceResponse(m,D),[3,4];case 6:return f.log("apdu","<= "+b.toString("hex")),[2,b]}})})}).catch(function(s){throw s&&s.message&&s.message.includes("write")?(c._emitDisconnect(s),new f.DisconnectedDeviceDuringOperation(s.message)):s})];case 1:return n=d.sent(),[2,n]}})})},t.device=e,t.deviceModel=typeof e.productId=="number"?f.identifyUSBProductId(e.productId):void 0,e.addEventListener("inputreport",t.onInputReport),t}return i.request=function(){return l(this,void 0,void 0,function(){var e,t;return h(this,function(r){switch(r.label){case 0:return[4,S()];case 1:return e=k.apply(void 0,[r.sent(),1]),t=e[0],[2,i.open(t)]}})})},i.openConnected=function(){return l(this,void 0,void 0,function(){var e;return h(this,function(t){switch(t.label){case 0:return[4,_()];case 1:return e=t.sent(),e.length===0?[2,null]:[2,i.open(e[0])]}})})},i.open=function(e){return l(this,void 0,void 0,function(){var t,r;return h(this,function(n){switch(n.label){case 0:return[4,e.open()];case 1:return n.sent(),t=new i(e),r=function(c){e===c.device&&(w().removeEventListener("disconnect",r),t._emitDisconnect(new f.DisconnectedDevice))},w().addEventListener("disconnect",r),[2,t]}})})},i.prototype.close=function(){return l(this,void 0,void 0,function(){return h(this,function(e){switch(e.label){case 0:return[4,this.exchangeBusyPromise];case 1:return e.sent(),this.device.removeEventListener("inputreport",this.onInputReport),[4,this.device.close()];case 2:return e.sent(),[2]}})})},i.prototype.setScrambleKey=function(){},i.isSupported=O,i.list=_,i.listen=function(e){var t=!1;T().then(function(n){if(!n)e.error(new f.TransportOpenUserCancelled("Access denied to use Ledger device"));else if(!t){var c=typeof n.productId=="number"?f.identifyUSBProductId(n.productId):void 0;e.next({type:"add",descriptor:n,deviceModel:c}),e.complete()}},function(n){e.error(new f.TransportOpenUserCancelled(n.message))});function r(){t=!0}return{unsubscribe:r}},i}(x);exports.default=C;