@txnlab/use-wallet 3.0.0-beta.1 → 3.0.0-beta.10
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/index.cjs +3696 -120
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +60 -28
- package/dist/index.d.ts +60 -28
- package/dist/index.js +3696 -107
- package/dist/index.js.map +1 -1
- package/package.json +11 -10
package/dist/index.cjs
CHANGED
|
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn2, res) => function __init() {
|
|
9
|
+
return fn2 && (res = (0, fn2[__getOwnPropNames(fn2)[0]])(fn2 = 0)), res;
|
|
10
|
+
};
|
|
8
11
|
var __export = (target, all) => {
|
|
9
12
|
for (var name in all)
|
|
10
13
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -15,17 +18,3368 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
18
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
19
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
20
|
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
28
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
29
|
+
mod
|
|
30
|
+
));
|
|
31
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
|
|
33
|
+
// ../../node_modules/.pnpm/@magic-sdk+types@24.0.1/node_modules/@magic-sdk/types/dist/es/index.mjs
|
|
34
|
+
var c, p, _, u, v, E, f, d, g, x, N, I, A, R, T, h, O, U, L, k, y;
|
|
35
|
+
var init_es = __esm({
|
|
36
|
+
"../../node_modules/.pnpm/@magic-sdk+types@24.0.1/node_modules/@magic-sdk/types/dist/es/index.mjs"() {
|
|
37
|
+
"use strict";
|
|
38
|
+
c = ((n) => (n.MissingApiKey = "MISSING_API_KEY", n.ModalNotReady = "MODAL_NOT_READY", n.MalformedResponse = "MALFORMED_RESPONSE", n.InvalidArgument = "INVALID_ARGUMENT", n.ExtensionNotInitialized = "EXTENSION_NOT_INITIALIZED", n.IncompatibleExtensions = "INCOMPATIBLE_EXTENSIONS", n))(c || {});
|
|
39
|
+
p = ((s) => (s.SyncWeb3Method = "SYNC_WEB3_METHOD", s.DuplicateIframe = "DUPLICATE_IFRAME", s.ReactNativeEndpointConfiguration = "REACT_NATIVE_ENDPOINT_CONFIGURATION", s.DeprecationNotice = "DEPRECATION_NOTICE", s.ProductAnnouncement = "ANNOUNCEMENT", s))(p || {});
|
|
40
|
+
_ = ((t) => (t[t.ParseError = -32700] = "ParseError", t[t.InvalidRequest = -32600] = "InvalidRequest", t[t.MethodNotFound = -32601] = "MethodNotFound", t[t.InvalidParams = -32602] = "InvalidParams", t[t.InternalError = -32603] = "InternalError", t[t.MagicLinkFailedVerification = -1e4] = "MagicLinkFailedVerification", t[t.MagicLinkExpired = -10001] = "MagicLinkExpired", t[t.MagicLinkRateLimited = -10002] = "MagicLinkRateLimited", t[t.MagicLinkInvalidRedirectURL = -10006] = "MagicLinkInvalidRedirectURL", t[t.UserAlreadyLoggedIn = -10003] = "UserAlreadyLoggedIn", t[t.UpdateEmailFailed = -10004] = "UpdateEmailFailed", t[t.UserRequestEditEmail = -10005] = "UserRequestEditEmail", t[t.InactiveRecipient = -10010] = "InactiveRecipient", t[t.AccessDeniedToUser = -10011] = "AccessDeniedToUser", t[t.RedirectLoginComplete = -10015] = "RedirectLoginComplete", t))(_ || {});
|
|
41
|
+
u = ((r) => (r.MetaMask = "metamask", r.CoinbaseWallet = "coinbase_wallet", r))(u || {});
|
|
42
|
+
v = ((i) => (i.WalletSelected = "wallet_selected", i.WalletConnected = "wallet_connected", i.WalletRejected = "wallet_rejected", i))(v || {});
|
|
43
|
+
E = ((e) => (e.LoginWithSms = "magic_auth_login_with_sms", e.LoginWithEmailOTP = "magic_auth_login_with_email_otp", e.LoginWithMagicLink = "magic_auth_login_with_magic_link", e.LoginWithCredential = "magic_auth_login_with_credential", e.SetAuthorizationToken = "magic_auth_set_authorization_token", e.GetIdToken = "magic_auth_get_id_token", e.GenerateIdToken = "magic_auth_generate_id_token", e.GetMetadata = "magic_auth_get_metadata", e.IsLoggedIn = "magic_is_logged_in", e.Logout = "magic_auth_logout", e.UpdateEmail = "magic_auth_update_email", e.UserSettings = "magic_auth_settings", e.UserSettingsTestMode = "magic_auth_settings_testing_mode", e.LoginWithSmsTestMode = "magic_auth_login_with_sms_testing_mode", e.LoginWithEmailOTPTestMode = "magic_auth_login_with_email_otp_testing_mode", e.LoginWithMagicLinkTestMode = "magic_login_with_magic_link_testing_mode", e.LoginWithCredentialTestMode = "magic_auth_login_with_credential_testing_mode", e.GetIdTokenTestMode = "magic_auth_get_id_token_testing_mode", e.GenerateIdTokenTestMode = "magic_auth_generate_id_token_testing_mode", e.GetMetadataTestMode = "magic_auth_get_metadata_testing_mode", e.IsLoggedInTestMode = "magic_auth_is_logged_in_testing_mode", e.LogoutTestMode = "magic_auth_logout_testing_mode", e.UpdateEmailTestMode = "magic_auth_update_email_testing_mode", e.IntermediaryEvent = "magic_intermediary_event", e.RequestAccounts = "eth_requestAccounts", e.GetInfo = "magic_get_info", e.ShowUI = "magic_wallet", e.NFTPurchase = "magic_nft_purchase", e.NFTCheckout = "magic_nft_checkout", e.NFTTransfer = "magic_nft_transfer", e.RequestUserInfoWithUI = "mc_request_user_info", e.Disconnect = "mc_disconnect", e.RecoverAccount = "magic_auth_recover_account", e.RecoverAccountTestMode = "magic_auth_recover_account_testing_mode", e.MagicBoxHeartBeat = "magic_box_heart_beat", e.AutoConnect = "mc_auto_connect", e.Login = "mc_login", e.EncryptV1 = "magic_auth_encrypt_v1", e.DecryptV1 = "magic_auth_decrypt_v1", e.ShowNFTs = "magic_show_nfts", e.ShowOnRamp = "magic_show_fiat_onramp", e.ShowSendTokensUI = "magic_show_send_tokens_ui", e.ShowAddress = "magic_show_address", e.ShowBalances = "magic_show_balances", e.SendGaslessTransaction = "eth_sendGaslessTransaction", e.RevealPK = "magic_reveal_key", e))(E || {});
|
|
44
|
+
f = ((m2) => (m2.MAGIC_HANDLE_RESPONSE = "MAGIC_HANDLE_RESPONSE", m2.MAGIC_OVERLAY_READY = "MAGIC_OVERLAY_READY", m2.MAGIC_SHOW_OVERLAY = "MAGIC_SHOW_OVERLAY", m2.MAGIC_HIDE_OVERLAY = "MAGIC_HIDE_OVERLAY", m2.MAGIC_HANDLE_EVENT = "MAGIC_HANDLE_EVENT", m2.MAGIC_MG_BOX_SEND_RECEIPT = "MAGIC_MG_BOX_SEND_RECEIPT", m2.MAGIC_SEND_PRODUCT_ANNOUNCEMENT = "MAGIC_SEND_PRODUCT_ANNOUNCEMENT", m2))(f || {});
|
|
45
|
+
d = ((a2) => (a2.MAGIC_HANDLE_REQUEST = "MAGIC_HANDLE_REQUEST", a2))(d || {});
|
|
46
|
+
g = ((i) => (i.UpdateEmail = "update-email", i.MFA = "mfa", i.Recovery = "recovery", i))(g || {});
|
|
47
|
+
x = ((a2) => (a2.Retry = "retry", a2))(x || {});
|
|
48
|
+
N = ((r) => (r.EmailSent = "email-sent", r.EmailNotDeliverable = "email-not-deliverable", r))(N || {});
|
|
49
|
+
I = ((r) => (r.VerifyEmailOtp = "verify-email-otp", r.Cancel = "cancel", r))(I || {});
|
|
50
|
+
A = ((i) => (i.EmailOTPSent = "email-otp-sent", i.InvalidEmailOtp = "invalid-email-otp", i.ExpiredEmailOtp = "expired-email-otp", i))(A || {});
|
|
51
|
+
R = ((a2) => (a2.Retry = "device-retry", a2))(R || {});
|
|
52
|
+
T = ((l) => (l.DeviceApproved = "device-approved", l.DeviceNeedsApproval = "device-needs-approval", l.DeviceVerificationLinkExpired = "device-verification-link-expired", l.DeviceVerificationEmailSent = "device-verification-email-sent", l))(T || {});
|
|
53
|
+
h = ((i) => (i.Retry = "Recency/auth-factor-retry", i.Cancel = "Recency/auth-factor-verification-cancel", i.VerifyEmailOtp = "Recency/auth-factor-verify-email-otp", i))(h || {});
|
|
54
|
+
O = ((n) => (n.PrimaryAuthFactorNeedsVerification = "Recency/auth-factor-needs-verification", n.PrimaryAuthFactorVerified = "Recency/auth-factor-verified", n.InvalidEmailOtp = "Recency/auth-factor-invalid-email-otp", n.EmailExpired = "Recency/auth-factor-verification-email-expired", n.EmailSent = "Recency/auth-factor-verification-email-sent", n.EmailNotDeliverable = "Recency/auth-factor-verification-email-not-deliverable", n))(O || {});
|
|
55
|
+
U = ((i) => (i.RetryWithNewEmail = "UpdateEmail/retry-with-new-email", i.Cancel = "UpdateEmail/new-email-verification-cancel", i.VerifyEmailOtp = "UpdateEmail/new-email-verify-otp", i))(U || {});
|
|
56
|
+
L = ((o) => (o.NewAuthFactorNeedsVerification = "UpdateEmail/new-email-needs-verification", o.EmailUpdated = "UpdateEmail/email-updated", o.InvalidEmailOtp = "UpdateEmail/new-email-invalid-email-otp", o.EmailExpired = "UpdateEmail/new-email-verification-email-expired", o.EmailSent = "UpdateEmail/new-email-verification-email-sent", o.EmailNotDeliverable = "UpdateEmail/new-email-verification-email-not-deliverable", o.InvalidEmail = "UpdateEmail/new-email-invalid", o.EmailAlreadyExists = "UpdateEmail/new-email-already-exists", o))(L || {});
|
|
57
|
+
k = ((a2) => (a2.Harmony = "HARMONY", a2))(k || {});
|
|
58
|
+
y = ((a2) => (a2.PhoneNumber = "phone_number", a2))(y || {});
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// ../../node_modules/.pnpm/@magic-sdk+provider@28.0.2_localforage@1.10.0/node_modules/@magic-sdk/provider/dist/es/index.mjs
|
|
63
|
+
function en(n) {
|
|
64
|
+
let t = { exports: {} };
|
|
65
|
+
return n(t, t.exports), t.exports;
|
|
66
|
+
}
|
|
67
|
+
function qn(n) {
|
|
68
|
+
return String.fromCharCode(parseInt(n.slice(1), 16));
|
|
69
|
+
}
|
|
70
|
+
function Dn(n) {
|
|
71
|
+
return `%${`00${n.charCodeAt(0).toString(16)}`.slice(-2)}`;
|
|
72
|
+
}
|
|
73
|
+
function Wn(n) {
|
|
74
|
+
return btoa(encodeURIComponent(n).replace(/%[0-9A-F]{2}/g, qn));
|
|
75
|
+
}
|
|
76
|
+
function Un(n) {
|
|
77
|
+
return decodeURIComponent(Array.from(atob(n), Dn).join(""));
|
|
78
|
+
}
|
|
79
|
+
function me(n) {
|
|
80
|
+
return Wn(JSON.stringify(n));
|
|
81
|
+
}
|
|
82
|
+
function lt(n) {
|
|
83
|
+
return JSON.parse(Un(n));
|
|
84
|
+
}
|
|
85
|
+
function O2(n) {
|
|
86
|
+
return typeof n == "undefined";
|
|
87
|
+
}
|
|
88
|
+
function Gn(n) {
|
|
89
|
+
return n === null;
|
|
90
|
+
}
|
|
91
|
+
function fe(n) {
|
|
92
|
+
return Gn(n) || O2(n);
|
|
93
|
+
}
|
|
94
|
+
function ut(n) {
|
|
95
|
+
return fe(n) ? false : !O2(n.jsonrpc) && !O2(n.id) && (!O2(n.result) || !O2(n.error));
|
|
96
|
+
}
|
|
97
|
+
function dt(n) {
|
|
98
|
+
return fe(n) ? false : typeof n == "number" && Object.values(_).includes(n);
|
|
99
|
+
}
|
|
100
|
+
function re(n) {
|
|
101
|
+
if (!n)
|
|
102
|
+
return true;
|
|
103
|
+
for (let t in n)
|
|
104
|
+
if (Object.hasOwnProperty.call(n, t))
|
|
105
|
+
return false;
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
function Kn(n, t) {
|
|
109
|
+
return Object.assign(h2, t), n;
|
|
110
|
+
}
|
|
111
|
+
function ht() {
|
|
112
|
+
return new A2(c.MissingApiKey, "Please provide an API key that you acquired from the Magic developer dashboard.");
|
|
113
|
+
}
|
|
114
|
+
function mt() {
|
|
115
|
+
return new A2(c.ModalNotReady, "Modal is not ready.");
|
|
116
|
+
}
|
|
117
|
+
function ft() {
|
|
118
|
+
return new A2(c.MalformedResponse, "Response from the Magic iframe is malformed.");
|
|
119
|
+
}
|
|
120
|
+
function Et(n) {
|
|
121
|
+
return new A2(c.ExtensionNotInitialized, `Extensions must be initialized with a Magic SDK instance before \`Extension.${n}\` can be accessed. Do not invoke \`Extension.${n}\` inside an extension constructor.`);
|
|
122
|
+
}
|
|
123
|
+
function yt(n) {
|
|
124
|
+
let t = `Some extensions are incompatible with \`${h2.sdkName}@${h2.version}\`:`;
|
|
125
|
+
return n.filter((e) => typeof e.compat != "undefined" && e.compat !== null).forEach((e) => {
|
|
126
|
+
let r = e.compat[h2.sdkName];
|
|
127
|
+
typeof r == "string" ? t += `
|
|
128
|
+
- Extension \`${e.name}\` supports version(s) \`${r}\`` : r || (t += `
|
|
129
|
+
- Extension \`${e.name}\` does not support ${h2.platform} environments.`);
|
|
130
|
+
}), new A2(c.IncompatibleExtensions, t);
|
|
131
|
+
}
|
|
132
|
+
function gt(n) {
|
|
133
|
+
let t = (e) => {
|
|
134
|
+
let r = e + 1, o = r % 10, s = r % 100;
|
|
135
|
+
return o === 1 && s !== 11 ? `${r}st` : o === 2 && s !== 12 ? `${r}nd` : o === 3 && s !== 13 ? `${r}rd` : `${r}th`;
|
|
136
|
+
};
|
|
137
|
+
return new A2(c.InvalidArgument, `Invalid ${t(n.argument)} argument given to \`${n.procedure}\`.
|
|
138
|
+
Expected: \`${n.expected}\`
|
|
139
|
+
Received: \`${n.received}\``);
|
|
140
|
+
}
|
|
141
|
+
function qr() {
|
|
142
|
+
return new W(p.DuplicateIframe, "Duplicate iframes found.");
|
|
143
|
+
}
|
|
144
|
+
function Rt() {
|
|
145
|
+
return new W(p.SyncWeb3Method, "Non-async web3 methods are deprecated in web3 > 1.0 and are not supported by the Magic web3 provider. Please use an async method instead.");
|
|
146
|
+
}
|
|
147
|
+
function vt() {
|
|
148
|
+
return new W(p.ReactNativeEndpointConfiguration, `CUSTOM DOMAINS ARE NOT SUPPORTED WHEN USING MAGIC SDK WITH REACT NATIVE! The \`endpoint\` parameter SHOULD NOT be provided. The Magic \`<iframe>\` is automatically wrapped by a WebView pointed at \`${h2.defaultEndpoint}\`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.`);
|
|
149
|
+
}
|
|
150
|
+
function U2(n) {
|
|
151
|
+
let { method: t, removalVersions: e, useInstead: r } = n, o = e[h2.sdkName], s = r ? ` Use \`${r}\` instead.` : "", a2 = `\`${t}\` will be removed from \`${h2.sdkName}\` in version \`${o}\`.${s}`;
|
|
152
|
+
return new W(p.DeprecationNotice, a2);
|
|
153
|
+
}
|
|
154
|
+
function* Bn() {
|
|
155
|
+
let n = 0;
|
|
156
|
+
for (; ; )
|
|
157
|
+
n < Number.MAX_SAFE_INTEGER ? yield ++n : n = 0;
|
|
158
|
+
}
|
|
159
|
+
function Se() {
|
|
160
|
+
return Hn.next().value;
|
|
161
|
+
}
|
|
162
|
+
function It(n) {
|
|
163
|
+
return Object.defineProperty(n, Tt, { value: true, enumerable: false }), n;
|
|
164
|
+
}
|
|
165
|
+
function Vn(n) {
|
|
166
|
+
return !!n[Tt];
|
|
167
|
+
}
|
|
168
|
+
function G(n) {
|
|
169
|
+
var t, e, r;
|
|
170
|
+
return Vn(n) || (n.jsonrpc = (t = n.jsonrpc) != null ? t : "2.0", n.id = Se(), n.method = (e = n.method) != null ? e : "noop", n.params = (r = n.params) != null ? r : [], It(n)), n;
|
|
171
|
+
}
|
|
172
|
+
function d2(n, t = []) {
|
|
173
|
+
return It({ params: t, method: n, jsonrpc: "2.0", id: Se() });
|
|
174
|
+
}
|
|
175
|
+
function ge() {
|
|
176
|
+
let n = new Oe();
|
|
177
|
+
return { emitter: n, createChainingEmitterMethod: (r, o) => (...s) => (n[r].apply(n, s), o), createBoundEmitterMethod: (r) => (...o) => n[r].apply(n, o) };
|
|
178
|
+
}
|
|
179
|
+
function xt(n) {
|
|
180
|
+
return !!n[Mt];
|
|
181
|
+
}
|
|
182
|
+
function k2(n) {
|
|
183
|
+
let t = _e(n), { createBoundEmitterMethod: e, createChainingEmitterMethod: r } = ge(), o = Symbol("Promise.then"), s = Symbol("Promise.catch"), a2 = Symbol("Promise.finally"), i = (l, p2) => (...x2) => {
|
|
184
|
+
let v2 = p2[l].apply(p2, x2);
|
|
185
|
+
return c3(v2);
|
|
186
|
+
}, c3 = (l) => Object.assign(l, { [Mt]: true, [o]: l[o] || l.then, [s]: l[s] || l.catch, [a2]: l[a2] || l.finally, then: i(o, l), catch: i(s, l), finally: i(a2, l), on: r("on", l), once: r("once", l), addListener: r("addListener", l), off: r("off", l), removeListener: r("removeListener", l), removeAllListeners: r("removeAllListeners", l), emit: e("emit"), eventNames: e("eventNames"), listeners: e("listeners"), listenerCount: e("listenerCount") }), u2 = c3(t.then((l) => (u2.emit("done", l), u2.emit("settled"), l), (l) => {
|
|
187
|
+
throw u2.emit("error", l), u2.emit("settled"), l;
|
|
188
|
+
}));
|
|
189
|
+
return u2;
|
|
190
|
+
}
|
|
191
|
+
function _e(n) {
|
|
192
|
+
return new Promise((t, e) => {
|
|
193
|
+
let r = n(t, e);
|
|
194
|
+
Promise.resolve(r).catch(e);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
function Nt(n, t) {
|
|
198
|
+
let [e] = n.split(".").map(Number);
|
|
199
|
+
return e >= t;
|
|
200
|
+
}
|
|
201
|
+
function J(n) {
|
|
202
|
+
return (...t) => m(this, null, function* () {
|
|
203
|
+
return Te || (Te = yield h2.configureStorage()), yield Te.ready(), Te[n](...t);
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
function Ct() {
|
|
207
|
+
let n = window.crypto.getRandomValues(new Uint8Array(16));
|
|
208
|
+
n[6] = n[6] & 15 | 64, n[8] = n[8] & 191 | 128;
|
|
209
|
+
let t = "";
|
|
210
|
+
return t += n[0].toString(16), t += n[1].toString(16), t += n[2].toString(16), t += n[3].toString(16), t += "-", t += n[4].toString(16), t += n[5].toString(16), t += "-", t += n[6].toString(16), t += n[7].toString(16), t += "-", t += n[8].toString(16), t += n[9].toString(16), t += "-", t += n[10].toString(16), t += n[11].toString(16), t += n[12].toString(16), t += n[13].toString(16), t += n[14].toString(16), t += n[15].toString(16), t;
|
|
211
|
+
}
|
|
212
|
+
function ae() {
|
|
213
|
+
let n = typeof window != "undefined" && !!window.crypto, t = n && !!window.crypto.subtle;
|
|
214
|
+
return n && t;
|
|
215
|
+
}
|
|
216
|
+
function Lt() {
|
|
217
|
+
return m(this, null, function* () {
|
|
218
|
+
let n = yield ir();
|
|
219
|
+
if (!n) {
|
|
220
|
+
console.info("unable to create public key or webcrypto is unsupported");
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
let { subtle: t } = window.crypto, e = yield y2(qe);
|
|
224
|
+
if (!e || !t) {
|
|
225
|
+
console.info("unable to find private key or webcrypto unsupported");
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
let r = { iat: Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3), jti: Ct() }, o = { typ: "dpop+jwt", alg: "ES256", jwk: n }, s = { protected: At(JSON.stringify(o)), claims: At(JSON.stringify(r)) }, a2 = cr(`${s.protected}.${s.claims}`), i = { name: St, hash: { name: "SHA-256" } }, c3 = ur(new Uint8Array(yield t.sign(i, e, a2)));
|
|
229
|
+
return `${s.protected}.${s.claims}.${c3}`;
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
function ir() {
|
|
233
|
+
return m(this, null, function* () {
|
|
234
|
+
if (!ae()) {
|
|
235
|
+
console.info("webcrypto is not supported");
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
return (yield y2(Ie)) || (yield ar()), y2(Ie);
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
function ar() {
|
|
242
|
+
return m(this, null, function* () {
|
|
243
|
+
let { subtle: n } = window.crypto, t = yield n.generateKey(or, false, ["sign"]), e = yield n.exportKey("jwk", t.publicKey);
|
|
244
|
+
yield M(qe, t.privateKey), yield M(Ie, e);
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
function At(n) {
|
|
248
|
+
return Ot(lr(n));
|
|
249
|
+
}
|
|
250
|
+
function cr(n) {
|
|
251
|
+
return new TextEncoder().encode(n);
|
|
252
|
+
}
|
|
253
|
+
function Ot(n) {
|
|
254
|
+
return btoa(n).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+/g, "");
|
|
255
|
+
}
|
|
256
|
+
function lr(n) {
|
|
257
|
+
return encodeURIComponent(n).replace(/%([0-9A-F]{2})/g, (e, r) => String.fromCharCode(parseInt(r, 16)));
|
|
258
|
+
}
|
|
259
|
+
function ur(n) {
|
|
260
|
+
let t = "";
|
|
261
|
+
return n.forEach((e) => {
|
|
262
|
+
t += String.fromCharCode(e);
|
|
263
|
+
}), Ot(t);
|
|
264
|
+
}
|
|
265
|
+
function Z() {
|
|
266
|
+
return m(this, null, function* () {
|
|
267
|
+
let n = [];
|
|
268
|
+
yield ke((t, e, r) => {
|
|
269
|
+
e.startsWith(`${De}_`) && n.push(e);
|
|
270
|
+
});
|
|
271
|
+
for (let t of n)
|
|
272
|
+
yield N2(t);
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
function _t(n) {
|
|
276
|
+
let t = "", e = new Uint8Array(n), r = e.byteLength;
|
|
277
|
+
for (let o = 0; o < r; o++)
|
|
278
|
+
t += String.fromCharCode(e[o]);
|
|
279
|
+
return window.btoa(t);
|
|
280
|
+
}
|
|
281
|
+
function kt(n) {
|
|
282
|
+
let t = window.atob(n), e = t.length, r = new Uint8Array(e);
|
|
283
|
+
for (let o = 0; o < e; o++)
|
|
284
|
+
r[o] = t.charCodeAt(o);
|
|
285
|
+
return r.buffer;
|
|
286
|
+
}
|
|
287
|
+
function pr() {
|
|
288
|
+
return m(this, null, function* () {
|
|
289
|
+
if (!ae()) {
|
|
290
|
+
console.info("webcrypto is not supported");
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
let { crypto: n } = window, t = yield y2(Ue);
|
|
294
|
+
return t || n.getRandomValues(new Uint8Array(12));
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
function hr() {
|
|
298
|
+
return m(this, null, function* () {
|
|
299
|
+
if (!ae()) {
|
|
300
|
+
console.info("webcrypto is not supported");
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
let { subtle: n } = window.crypto, t = yield y2(We);
|
|
304
|
+
return t || (yield n.generateKey({ name: Fe, length: dr }, false, ["encrypt", "decrypt"]));
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
function qt(n, t) {
|
|
308
|
+
return m(this, null, function* () {
|
|
309
|
+
let e = yield pr(), r = yield hr();
|
|
310
|
+
if (!e || !r || !n)
|
|
311
|
+
return;
|
|
312
|
+
let o = kt(n), { subtle: s } = window.crypto, a2 = yield s.encrypt({ name: Fe, iv: e }, r, o), i = _t(a2);
|
|
313
|
+
yield M(`${De}_${t}`, i), yield M(We, r), yield M(Ue, e);
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
function Dt(n) {
|
|
317
|
+
return m(this, null, function* () {
|
|
318
|
+
let t = yield y2(`${De}_${n}`), e = yield y2(Ue), r = yield y2(We);
|
|
319
|
+
if (!e || !t || !r || !ae())
|
|
320
|
+
return;
|
|
321
|
+
let { subtle: o } = window.crypto, s = yield o.decrypt({ name: Fe, iv: e }, r, kt(t));
|
|
322
|
+
return _t(s);
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
function Je(n, t) {
|
|
326
|
+
return t ? new URL(n, t) : new URL(n);
|
|
327
|
+
}
|
|
328
|
+
function fr(n) {
|
|
329
|
+
let t = Object.getPrototypeOf(n), e = [t];
|
|
330
|
+
for (; t !== P.prototype; )
|
|
331
|
+
t = Object.getPrototypeOf(t), e.push(t);
|
|
332
|
+
return e;
|
|
333
|
+
}
|
|
334
|
+
function Ft(n) {
|
|
335
|
+
return n.compat && n.compat[h2.sdkName] != null ? typeof n.compat[h2.sdkName] == "string" ? at(ct(h2.version), n.compat[h2.sdkName]) : !!n.compat[h2.sdkName] : true;
|
|
336
|
+
}
|
|
337
|
+
function Er(n, t, e) {
|
|
338
|
+
return !t && !e ? `${n}_eth_mainnet` : e ? `${n}_${JSON.stringify(e)}` : t ? typeof t == "string" ? `${n}_eth_${t}` : `${n}_${t.rpcUrl}_${t.chainId}_${t.chainType}` : `${n}_unknown`;
|
|
339
|
+
}
|
|
340
|
+
function yr(n) {
|
|
341
|
+
var o;
|
|
342
|
+
let t = (o = n == null ? void 0 : n.extensions) != null ? o : [], e = {}, r = [];
|
|
343
|
+
if (Array.isArray(t) ? t.forEach((s) => {
|
|
344
|
+
Ft(s) ? (s.init(this), (s.name || s.name !== q.Anonymous) && (this[s.name] = s), s instanceof q.Internal && (re(s.config) || (e[s.name] = s.config))) : r.push(s);
|
|
345
|
+
}) : Object.keys(t).forEach((s) => {
|
|
346
|
+
if (Ft(t[s])) {
|
|
347
|
+
t[s].init(this);
|
|
348
|
+
let a2 = t[s];
|
|
349
|
+
this[s] = a2, a2 instanceof q.Internal && (re(a2.config) || (e[t[s].name] = a2.config));
|
|
350
|
+
} else
|
|
351
|
+
r.push(t[s]);
|
|
352
|
+
}), r.length)
|
|
353
|
+
throw yt(r);
|
|
354
|
+
return e;
|
|
355
|
+
}
|
|
356
|
+
function Rr(n, t) {
|
|
357
|
+
return t && Array.isArray(n) ? n.find((e) => e.id === t) : n;
|
|
358
|
+
}
|
|
359
|
+
function vr(n, t) {
|
|
360
|
+
var o;
|
|
361
|
+
let e = (o = t.data.response) == null ? void 0 : o.id, r = Rr(n, e);
|
|
362
|
+
if (e && r) {
|
|
363
|
+
let s = new F(r).applyResult(t.data.response.result).applyError(t.data.response.error);
|
|
364
|
+
return { id: e, response: s };
|
|
365
|
+
}
|
|
366
|
+
return {};
|
|
367
|
+
}
|
|
368
|
+
function Tr(n, t, e) {
|
|
369
|
+
return m(this, null, function* () {
|
|
370
|
+
var i;
|
|
371
|
+
let r = yield y2("rt"), o;
|
|
372
|
+
if (h2.platform === "web")
|
|
373
|
+
try {
|
|
374
|
+
o = (i = yield y2("jwt")) != null ? i : yield Lt();
|
|
375
|
+
} catch (c3) {
|
|
376
|
+
console.error("webcrypto error", c3);
|
|
377
|
+
}
|
|
378
|
+
let s = { msgType: n, payload: t };
|
|
379
|
+
o && (s.jwt = o), o && r && (s.rt = r);
|
|
380
|
+
let a2 = yield Dt(e);
|
|
381
|
+
return a2 && (s.deviceShare = a2), s;
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
function Ir(n) {
|
|
385
|
+
return m(this, null, function* () {
|
|
386
|
+
!n.data.rt || (yield M("rt", n.data.rt));
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
var Gt, ue, Kt, jt, Bt, Ht, Ve, Vt, ze, Xt, Xe, j, B, zt, Yt, Zt, Qt, m, wt, tn, Ae, nn, f2, ne, Ye, it, rn, sn, Ze, de, Qe, et, ee, E2, on, H, an, cn, ln, un, dn, pn, hn, mn, fn, En, yn, gn, Rn, Ce, te, D, tt, nt, L2, T2, g2, vn, Tn, In, rt, bn, b, wn, Pn, Mn, xn, Nn, $n, Cn, An, Sn, Ln, at, On, st, ot, _n, kn, pe, he, ct, h2, pt, A2, _2, W, V, se, Hn, Tt, F, Pt, Oe, Mt, P, K, ve, ie, Te, y2, M, N2, er, tr, nr, rr, ke, qe, Ie, St, sr, or, De, We, Ue, Fe, dr, be, we, Pe, Q, Me, Ut, xe, Ke, q, Ne, ce, $e, Be;
|
|
390
|
+
var init_es2 = __esm({
|
|
391
|
+
"../../node_modules/.pnpm/@magic-sdk+provider@28.0.2_localforage@1.10.0/node_modules/@magic-sdk/provider/dist/es/index.mjs"() {
|
|
392
|
+
"use strict";
|
|
393
|
+
init_es();
|
|
394
|
+
init_es();
|
|
395
|
+
init_es();
|
|
396
|
+
init_es();
|
|
397
|
+
init_es();
|
|
398
|
+
init_es();
|
|
399
|
+
init_es();
|
|
400
|
+
init_es();
|
|
401
|
+
init_es();
|
|
402
|
+
Gt = Object.create;
|
|
403
|
+
ue = Object.defineProperty;
|
|
404
|
+
Kt = Object.defineProperties;
|
|
405
|
+
jt = Object.getOwnPropertyDescriptor;
|
|
406
|
+
Bt = Object.getOwnPropertyDescriptors;
|
|
407
|
+
Ht = Object.getOwnPropertyNames;
|
|
408
|
+
Ve = Object.getOwnPropertySymbols;
|
|
409
|
+
Vt = Object.getPrototypeOf;
|
|
410
|
+
ze = Object.prototype.hasOwnProperty;
|
|
411
|
+
Xt = Object.prototype.propertyIsEnumerable;
|
|
412
|
+
Xe = (n, t, e) => t in n ? ue(n, t, { enumerable: true, configurable: true, writable: true, value: e }) : n[t] = e;
|
|
413
|
+
j = (n, t) => {
|
|
414
|
+
for (var e in t || (t = {}))
|
|
415
|
+
ze.call(t, e) && Xe(n, e, t[e]);
|
|
416
|
+
if (Ve)
|
|
417
|
+
for (var e of Ve(t))
|
|
418
|
+
Xt.call(t, e) && Xe(n, e, t[e]);
|
|
419
|
+
return n;
|
|
420
|
+
};
|
|
421
|
+
B = (n, t) => Kt(n, Bt(t));
|
|
422
|
+
zt = (n, t) => () => (t || n((t = { exports: {} }).exports, t), t.exports);
|
|
423
|
+
Yt = (n, t) => {
|
|
424
|
+
for (var e in t)
|
|
425
|
+
ue(n, e, { get: t[e], enumerable: true });
|
|
426
|
+
};
|
|
427
|
+
Zt = (n, t, e, r) => {
|
|
428
|
+
if (t && typeof t == "object" || typeof t == "function")
|
|
429
|
+
for (let o of Ht(t))
|
|
430
|
+
!ze.call(n, o) && o !== e && ue(n, o, { get: () => t[o], enumerable: !(r = jt(t, o)) || r.enumerable });
|
|
431
|
+
return n;
|
|
432
|
+
};
|
|
433
|
+
Qt = (n, t, e) => (e = n != null ? Gt(Vt(n)) : {}, Zt(t || !n || !n.__esModule ? ue(e, "default", { value: n, enumerable: true }) : e, n));
|
|
434
|
+
m = (n, t, e) => new Promise((r, o) => {
|
|
435
|
+
var s = (c3) => {
|
|
436
|
+
try {
|
|
437
|
+
i(e.next(c3));
|
|
438
|
+
} catch (u2) {
|
|
439
|
+
o(u2);
|
|
440
|
+
}
|
|
441
|
+
}, a2 = (c3) => {
|
|
442
|
+
try {
|
|
443
|
+
i(e.throw(c3));
|
|
444
|
+
} catch (u2) {
|
|
445
|
+
o(u2);
|
|
446
|
+
}
|
|
447
|
+
}, i = (c3) => c3.done ? r(c3.value) : Promise.resolve(c3.value).then(s, a2);
|
|
448
|
+
i((e = e.apply(n, t)).next());
|
|
449
|
+
});
|
|
450
|
+
wt = zt((Gr, Le) => {
|
|
451
|
+
"use strict";
|
|
452
|
+
var Xn = Object.prototype.hasOwnProperty, w = "~";
|
|
453
|
+
function oe() {
|
|
454
|
+
}
|
|
455
|
+
Object.create && (oe.prototype = /* @__PURE__ */ Object.create(null), new oe().__proto__ || (w = false));
|
|
456
|
+
function zn(n, t, e) {
|
|
457
|
+
this.fn = n, this.context = t, this.once = e || false;
|
|
458
|
+
}
|
|
459
|
+
function bt2(n, t, e, r, o) {
|
|
460
|
+
if (typeof e != "function")
|
|
461
|
+
throw new TypeError("The listener must be a function");
|
|
462
|
+
var s = new zn(e, r || n, o), a2 = w ? w + t : t;
|
|
463
|
+
return n._events[a2] ? n._events[a2].fn ? n._events[a2] = [n._events[a2], s] : n._events[a2].push(s) : (n._events[a2] = s, n._eventsCount++), n;
|
|
464
|
+
}
|
|
465
|
+
function ye(n, t) {
|
|
466
|
+
--n._eventsCount === 0 ? n._events = new oe() : delete n._events[t];
|
|
467
|
+
}
|
|
468
|
+
function I2() {
|
|
469
|
+
this._events = new oe(), this._eventsCount = 0;
|
|
470
|
+
}
|
|
471
|
+
I2.prototype.eventNames = function() {
|
|
472
|
+
var t = [], e, r;
|
|
473
|
+
if (this._eventsCount === 0)
|
|
474
|
+
return t;
|
|
475
|
+
for (r in e = this._events)
|
|
476
|
+
Xn.call(e, r) && t.push(w ? r.slice(1) : r);
|
|
477
|
+
return Object.getOwnPropertySymbols ? t.concat(Object.getOwnPropertySymbols(e)) : t;
|
|
478
|
+
};
|
|
479
|
+
I2.prototype.listeners = function(t) {
|
|
480
|
+
var e = w ? w + t : t, r = this._events[e];
|
|
481
|
+
if (!r)
|
|
482
|
+
return [];
|
|
483
|
+
if (r.fn)
|
|
484
|
+
return [r.fn];
|
|
485
|
+
for (var o = 0, s = r.length, a2 = new Array(s); o < s; o++)
|
|
486
|
+
a2[o] = r[o].fn;
|
|
487
|
+
return a2;
|
|
488
|
+
};
|
|
489
|
+
I2.prototype.listenerCount = function(t) {
|
|
490
|
+
var e = w ? w + t : t, r = this._events[e];
|
|
491
|
+
return r ? r.fn ? 1 : r.length : 0;
|
|
492
|
+
};
|
|
493
|
+
I2.prototype.emit = function(t, e, r, o, s, a2) {
|
|
494
|
+
var i = w ? w + t : t;
|
|
495
|
+
if (!this._events[i])
|
|
496
|
+
return false;
|
|
497
|
+
var c3 = this._events[i], u2 = arguments.length, l, p2;
|
|
498
|
+
if (c3.fn) {
|
|
499
|
+
switch (c3.once && this.removeListener(t, c3.fn, void 0, true), u2) {
|
|
500
|
+
case 1:
|
|
501
|
+
return c3.fn.call(c3.context), true;
|
|
502
|
+
case 2:
|
|
503
|
+
return c3.fn.call(c3.context, e), true;
|
|
504
|
+
case 3:
|
|
505
|
+
return c3.fn.call(c3.context, e, r), true;
|
|
506
|
+
case 4:
|
|
507
|
+
return c3.fn.call(c3.context, e, r, o), true;
|
|
508
|
+
case 5:
|
|
509
|
+
return c3.fn.call(c3.context, e, r, o, s), true;
|
|
510
|
+
case 6:
|
|
511
|
+
return c3.fn.call(c3.context, e, r, o, s, a2), true;
|
|
512
|
+
}
|
|
513
|
+
for (p2 = 1, l = new Array(u2 - 1); p2 < u2; p2++)
|
|
514
|
+
l[p2 - 1] = arguments[p2];
|
|
515
|
+
c3.fn.apply(c3.context, l);
|
|
516
|
+
} else {
|
|
517
|
+
var x2 = c3.length, v2;
|
|
518
|
+
for (p2 = 0; p2 < x2; p2++)
|
|
519
|
+
switch (c3[p2].once && this.removeListener(t, c3[p2].fn, void 0, true), u2) {
|
|
520
|
+
case 1:
|
|
521
|
+
c3[p2].fn.call(c3[p2].context);
|
|
522
|
+
break;
|
|
523
|
+
case 2:
|
|
524
|
+
c3[p2].fn.call(c3[p2].context, e);
|
|
525
|
+
break;
|
|
526
|
+
case 3:
|
|
527
|
+
c3[p2].fn.call(c3[p2].context, e, r);
|
|
528
|
+
break;
|
|
529
|
+
case 4:
|
|
530
|
+
c3[p2].fn.call(c3[p2].context, e, r, o);
|
|
531
|
+
break;
|
|
532
|
+
default:
|
|
533
|
+
if (!l)
|
|
534
|
+
for (v2 = 1, l = new Array(u2 - 1); v2 < u2; v2++)
|
|
535
|
+
l[v2 - 1] = arguments[v2];
|
|
536
|
+
c3[p2].fn.apply(c3[p2].context, l);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
return true;
|
|
540
|
+
};
|
|
541
|
+
I2.prototype.on = function(t, e, r) {
|
|
542
|
+
return bt2(this, t, e, r, false);
|
|
543
|
+
};
|
|
544
|
+
I2.prototype.once = function(t, e, r) {
|
|
545
|
+
return bt2(this, t, e, r, true);
|
|
546
|
+
};
|
|
547
|
+
I2.prototype.removeListener = function(t, e, r, o) {
|
|
548
|
+
var s = w ? w + t : t;
|
|
549
|
+
if (!this._events[s])
|
|
550
|
+
return this;
|
|
551
|
+
if (!e)
|
|
552
|
+
return ye(this, s), this;
|
|
553
|
+
var a2 = this._events[s];
|
|
554
|
+
if (a2.fn)
|
|
555
|
+
a2.fn === e && (!o || a2.once) && (!r || a2.context === r) && ye(this, s);
|
|
556
|
+
else {
|
|
557
|
+
for (var i = 0, c3 = [], u2 = a2.length; i < u2; i++)
|
|
558
|
+
(a2[i].fn !== e || o && !a2[i].once || r && a2[i].context !== r) && c3.push(a2[i]);
|
|
559
|
+
c3.length ? this._events[s] = c3.length === 1 ? c3[0] : c3 : ye(this, s);
|
|
560
|
+
}
|
|
561
|
+
return this;
|
|
562
|
+
};
|
|
563
|
+
I2.prototype.removeAllListeners = function(t) {
|
|
564
|
+
var e;
|
|
565
|
+
return t ? (e = w ? w + t : t, this._events[e] && ye(this, e)) : (this._events = new oe(), this._eventsCount = 0), this;
|
|
566
|
+
};
|
|
567
|
+
I2.prototype.off = I2.prototype.removeListener;
|
|
568
|
+
I2.prototype.addListener = I2.prototype.on;
|
|
569
|
+
I2.prefixed = w;
|
|
570
|
+
I2.EventEmitter = I2;
|
|
571
|
+
typeof Le < "u" && (Le.exports = I2);
|
|
572
|
+
});
|
|
573
|
+
tn = Number.MAX_SAFE_INTEGER || 9007199254740991;
|
|
574
|
+
Ae = { SEMVER_SPEC_VERSION: "2.0.0", MAX_LENGTH: 256, MAX_SAFE_INTEGER: tn, MAX_SAFE_COMPONENT_LENGTH: 16 };
|
|
575
|
+
nn = typeof process == "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...n) => console.error("SEMVER", ...n) : () => {
|
|
576
|
+
};
|
|
577
|
+
f2 = nn;
|
|
578
|
+
ne = en(function(n, t) {
|
|
579
|
+
let { MAX_SAFE_COMPONENT_LENGTH: e } = Ae, r = (t = n.exports = {}).re = [], o = t.src = [], s = t.t = {}, a2 = 0, i = (c3, u2, l) => {
|
|
580
|
+
let p2 = a2++;
|
|
581
|
+
f2(p2, u2), s[c3] = p2, o[p2] = u2, r[p2] = new RegExp(u2, l ? "g" : void 0);
|
|
582
|
+
};
|
|
583
|
+
i("NUMERICIDENTIFIER", "0|[1-9]\\d*"), i("NUMERICIDENTIFIERLOOSE", "[0-9]+"), i("NONNUMERICIDENTIFIER", "\\d*[a-zA-Z-][a-zA-Z0-9-]*"), i("MAINVERSION", `(${o[s.NUMERICIDENTIFIER]})\\.(${o[s.NUMERICIDENTIFIER]})\\.(${o[s.NUMERICIDENTIFIER]})`), i("MAINVERSIONLOOSE", `(${o[s.NUMERICIDENTIFIERLOOSE]})\\.(${o[s.NUMERICIDENTIFIERLOOSE]})\\.(${o[s.NUMERICIDENTIFIERLOOSE]})`), i("PRERELEASEIDENTIFIER", `(?:${o[s.NUMERICIDENTIFIER]}|${o[s.NONNUMERICIDENTIFIER]})`), i("PRERELEASEIDENTIFIERLOOSE", `(?:${o[s.NUMERICIDENTIFIERLOOSE]}|${o[s.NONNUMERICIDENTIFIER]})`), i("PRERELEASE", `(?:-(${o[s.PRERELEASEIDENTIFIER]}(?:\\.${o[s.PRERELEASEIDENTIFIER]})*))`), i("PRERELEASELOOSE", `(?:-?(${o[s.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${o[s.PRERELEASEIDENTIFIERLOOSE]})*))`), i("BUILDIDENTIFIER", "[0-9A-Za-z-]+"), i("BUILD", `(?:\\+(${o[s.BUILDIDENTIFIER]}(?:\\.${o[s.BUILDIDENTIFIER]})*))`), i("FULLPLAIN", `v?${o[s.MAINVERSION]}${o[s.PRERELEASE]}?${o[s.BUILD]}?`), i("FULL", `^${o[s.FULLPLAIN]}$`), i("LOOSEPLAIN", `[v=\\s]*${o[s.MAINVERSIONLOOSE]}${o[s.PRERELEASELOOSE]}?${o[s.BUILD]}?`), i("LOOSE", `^${o[s.LOOSEPLAIN]}$`), i("GTLT", "((?:<|>)?=?)"), i("XRANGEIDENTIFIERLOOSE", `${o[s.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`), i("XRANGEIDENTIFIER", `${o[s.NUMERICIDENTIFIER]}|x|X|\\*`), i("XRANGEPLAIN", `[v=\\s]*(${o[s.XRANGEIDENTIFIER]})(?:\\.(${o[s.XRANGEIDENTIFIER]})(?:\\.(${o[s.XRANGEIDENTIFIER]})(?:${o[s.PRERELEASE]})?${o[s.BUILD]}?)?)?`), i("XRANGEPLAINLOOSE", `[v=\\s]*(${o[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[s.XRANGEIDENTIFIERLOOSE]})(?:\\.(${o[s.XRANGEIDENTIFIERLOOSE]})(?:${o[s.PRERELEASELOOSE]})?${o[s.BUILD]}?)?)?`), i("XRANGE", `^${o[s.GTLT]}\\s*${o[s.XRANGEPLAIN]}$`), i("XRANGELOOSE", `^${o[s.GTLT]}\\s*${o[s.XRANGEPLAINLOOSE]}$`), i("COERCE", `(^|[^\\d])(\\d{1,${e}})(?:\\.(\\d{1,${e}}))?(?:\\.(\\d{1,${e}}))?(?:$|[^\\d])`), i("COERCERTL", o[s.COERCE], true), i("LONETILDE", "(?:~>?)"), i("TILDETRIM", `(\\s*)${o[s.LONETILDE]}\\s+`, true), t.tildeTrimReplace = "$1~", i("TILDE", `^${o[s.LONETILDE]}${o[s.XRANGEPLAIN]}$`), i("TILDELOOSE", `^${o[s.LONETILDE]}${o[s.XRANGEPLAINLOOSE]}$`), i("LONECARET", "(?:\\^)"), i("CARETTRIM", `(\\s*)${o[s.LONECARET]}\\s+`, true), t.caretTrimReplace = "$1^", i("CARET", `^${o[s.LONECARET]}${o[s.XRANGEPLAIN]}$`), i("CARETLOOSE", `^${o[s.LONECARET]}${o[s.XRANGEPLAINLOOSE]}$`), i("COMPARATORLOOSE", `^${o[s.GTLT]}\\s*(${o[s.LOOSEPLAIN]})$|^$`), i("COMPARATOR", `^${o[s.GTLT]}\\s*(${o[s.FULLPLAIN]})$|^$`), i("COMPARATORTRIM", `(\\s*)${o[s.GTLT]}\\s*(${o[s.LOOSEPLAIN]}|${o[s.XRANGEPLAIN]})`, true), t.comparatorTrimReplace = "$1$2$3", i("HYPHENRANGE", `^\\s*(${o[s.XRANGEPLAIN]})\\s+-\\s+(${o[s.XRANGEPLAIN]})\\s*$`), i("HYPHENRANGELOOSE", `^\\s*(${o[s.XRANGEPLAINLOOSE]})\\s+-\\s+(${o[s.XRANGEPLAINLOOSE]})\\s*$`), i("STAR", "(<|>)?=?\\s*\\*"), i("GTE0", "^\\s*>=\\s*0.0.0\\s*$"), i("GTE0PRE", "^\\s*>=\\s*0.0.0-0\\s*$");
|
|
584
|
+
});
|
|
585
|
+
Ye = /^[0-9]+$/;
|
|
586
|
+
it = (n, t) => {
|
|
587
|
+
let e = Ye.test(n), r = Ye.test(t);
|
|
588
|
+
return e && r && (n = +n, t = +t), n === t ? 0 : e && !r ? -1 : r && !e ? 1 : n < t ? -1 : 1;
|
|
589
|
+
};
|
|
590
|
+
rn = (n, t) => it(t, n);
|
|
591
|
+
sn = { compareIdentifiers: it, rcompareIdentifiers: rn };
|
|
592
|
+
({ MAX_LENGTH: Ze, MAX_SAFE_INTEGER: de } = Ae);
|
|
593
|
+
({ re: Qe, t: et } = ne);
|
|
594
|
+
({ compareIdentifiers: ee } = sn);
|
|
595
|
+
E2 = class {
|
|
596
|
+
constructor(t, e) {
|
|
597
|
+
if (e && typeof e == "object" || (e = { loose: !!e, includePrerelease: false }), t instanceof E2) {
|
|
598
|
+
if (t.loose === !!e.loose && t.includePrerelease === !!e.includePrerelease)
|
|
599
|
+
return t;
|
|
600
|
+
t = t.version;
|
|
601
|
+
} else if (typeof t != "string")
|
|
602
|
+
throw new TypeError(`Invalid Version: ${t}`);
|
|
603
|
+
if (t.length > Ze)
|
|
604
|
+
throw new TypeError(`version is longer than ${Ze} characters`);
|
|
605
|
+
f2("SemVer", t, e), this.options = e, this.loose = !!e.loose, this.includePrerelease = !!e.includePrerelease;
|
|
606
|
+
let r = t.trim().match(e.loose ? Qe[et.LOOSE] : Qe[et.FULL]);
|
|
607
|
+
if (!r)
|
|
608
|
+
throw new TypeError(`Invalid Version: ${t}`);
|
|
609
|
+
if (this.raw = t, this.major = +r[1], this.minor = +r[2], this.patch = +r[3], this.major > de || this.major < 0)
|
|
610
|
+
throw new TypeError("Invalid major version");
|
|
611
|
+
if (this.minor > de || this.minor < 0)
|
|
612
|
+
throw new TypeError("Invalid minor version");
|
|
613
|
+
if (this.patch > de || this.patch < 0)
|
|
614
|
+
throw new TypeError("Invalid patch version");
|
|
615
|
+
r[4] ? this.prerelease = r[4].split(".").map((o) => {
|
|
616
|
+
if (/^[0-9]+$/.test(o)) {
|
|
617
|
+
let s = +o;
|
|
618
|
+
if (s >= 0 && s < de)
|
|
619
|
+
return s;
|
|
620
|
+
}
|
|
621
|
+
return o;
|
|
622
|
+
}) : this.prerelease = [], this.build = r[5] ? r[5].split(".") : [], this.format();
|
|
623
|
+
}
|
|
624
|
+
format() {
|
|
625
|
+
return this.version = `${this.major}.${this.minor}.${this.patch}`, this.prerelease.length && (this.version += `-${this.prerelease.join(".")}`), this.version;
|
|
626
|
+
}
|
|
627
|
+
toString() {
|
|
628
|
+
return this.version;
|
|
629
|
+
}
|
|
630
|
+
compare(t) {
|
|
631
|
+
if (f2("SemVer.compare", this.version, this.options, t), !(t instanceof E2)) {
|
|
632
|
+
if (typeof t == "string" && t === this.version)
|
|
633
|
+
return 0;
|
|
634
|
+
t = new E2(t, this.options);
|
|
635
|
+
}
|
|
636
|
+
return t.version === this.version ? 0 : this.compareMain(t) || this.comparePre(t);
|
|
637
|
+
}
|
|
638
|
+
compareMain(t) {
|
|
639
|
+
return t instanceof E2 || (t = new E2(t, this.options)), ee(this.major, t.major) || ee(this.minor, t.minor) || ee(this.patch, t.patch);
|
|
640
|
+
}
|
|
641
|
+
comparePre(t) {
|
|
642
|
+
if (t instanceof E2 || (t = new E2(t, this.options)), this.prerelease.length && !t.prerelease.length)
|
|
643
|
+
return -1;
|
|
644
|
+
if (!this.prerelease.length && t.prerelease.length)
|
|
645
|
+
return 1;
|
|
646
|
+
if (!this.prerelease.length && !t.prerelease.length)
|
|
647
|
+
return 0;
|
|
648
|
+
let e = 0;
|
|
649
|
+
do {
|
|
650
|
+
let r = this.prerelease[e], o = t.prerelease[e];
|
|
651
|
+
if (f2("prerelease compare", e, r, o), r === void 0 && o === void 0)
|
|
652
|
+
return 0;
|
|
653
|
+
if (o === void 0)
|
|
654
|
+
return 1;
|
|
655
|
+
if (r === void 0)
|
|
656
|
+
return -1;
|
|
657
|
+
if (r !== o)
|
|
658
|
+
return ee(r, o);
|
|
659
|
+
} while (++e);
|
|
660
|
+
}
|
|
661
|
+
compareBuild(t) {
|
|
662
|
+
t instanceof E2 || (t = new E2(t, this.options));
|
|
663
|
+
let e = 0;
|
|
664
|
+
do {
|
|
665
|
+
let r = this.build[e], o = t.build[e];
|
|
666
|
+
if (f2("prerelease compare", e, r, o), r === void 0 && o === void 0)
|
|
667
|
+
return 0;
|
|
668
|
+
if (o === void 0)
|
|
669
|
+
return 1;
|
|
670
|
+
if (r === void 0)
|
|
671
|
+
return -1;
|
|
672
|
+
if (r !== o)
|
|
673
|
+
return ee(r, o);
|
|
674
|
+
} while (++e);
|
|
675
|
+
}
|
|
676
|
+
inc(t, e) {
|
|
677
|
+
switch (t) {
|
|
678
|
+
case "premajor":
|
|
679
|
+
this.prerelease.length = 0, this.patch = 0, this.minor = 0, this.major++, this.inc("pre", e);
|
|
680
|
+
break;
|
|
681
|
+
case "preminor":
|
|
682
|
+
this.prerelease.length = 0, this.patch = 0, this.minor++, this.inc("pre", e);
|
|
683
|
+
break;
|
|
684
|
+
case "prepatch":
|
|
685
|
+
this.prerelease.length = 0, this.inc("patch", e), this.inc("pre", e);
|
|
686
|
+
break;
|
|
687
|
+
case "prerelease":
|
|
688
|
+
this.prerelease.length === 0 && this.inc("patch", e), this.inc("pre", e);
|
|
689
|
+
break;
|
|
690
|
+
case "major":
|
|
691
|
+
this.minor === 0 && this.patch === 0 && this.prerelease.length !== 0 || this.major++, this.minor = 0, this.patch = 0, this.prerelease = [];
|
|
692
|
+
break;
|
|
693
|
+
case "minor":
|
|
694
|
+
this.patch === 0 && this.prerelease.length !== 0 || this.minor++, this.patch = 0, this.prerelease = [];
|
|
695
|
+
break;
|
|
696
|
+
case "patch":
|
|
697
|
+
this.prerelease.length === 0 && this.patch++, this.prerelease = [];
|
|
698
|
+
break;
|
|
699
|
+
case "pre":
|
|
700
|
+
if (this.prerelease.length === 0)
|
|
701
|
+
this.prerelease = [0];
|
|
702
|
+
else {
|
|
703
|
+
let r = this.prerelease.length;
|
|
704
|
+
for (; --r >= 0; )
|
|
705
|
+
typeof this.prerelease[r] == "number" && (this.prerelease[r]++, r = -2);
|
|
706
|
+
r === -1 && this.prerelease.push(0);
|
|
707
|
+
}
|
|
708
|
+
e && (this.prerelease[0] === e ? isNaN(this.prerelease[1]) && (this.prerelease = [e, 0]) : this.prerelease = [e, 0]);
|
|
709
|
+
break;
|
|
710
|
+
default:
|
|
711
|
+
throw new Error(`invalid increment argument: ${t}`);
|
|
712
|
+
}
|
|
713
|
+
return this.format(), this.raw = this.version, this;
|
|
714
|
+
}
|
|
715
|
+
};
|
|
716
|
+
on = (n, t, e) => new E2(n, e).compare(new E2(t, e));
|
|
717
|
+
H = on;
|
|
718
|
+
an = (n, t, e) => H(n, t, e) === 0;
|
|
719
|
+
cn = an;
|
|
720
|
+
ln = (n, t, e) => H(n, t, e) !== 0;
|
|
721
|
+
un = ln;
|
|
722
|
+
dn = (n, t, e) => H(n, t, e) > 0;
|
|
723
|
+
pn = dn;
|
|
724
|
+
hn = (n, t, e) => H(n, t, e) >= 0;
|
|
725
|
+
mn = hn;
|
|
726
|
+
fn = (n, t, e) => H(n, t, e) < 0;
|
|
727
|
+
En = fn;
|
|
728
|
+
yn = (n, t, e) => H(n, t, e) <= 0;
|
|
729
|
+
gn = yn;
|
|
730
|
+
Rn = (n, t, e, r) => {
|
|
731
|
+
switch (t) {
|
|
732
|
+
case "===":
|
|
733
|
+
return typeof n == "object" && (n = n.version), typeof e == "object" && (e = e.version), n === e;
|
|
734
|
+
case "!==":
|
|
735
|
+
return typeof n == "object" && (n = n.version), typeof e == "object" && (e = e.version), n !== e;
|
|
736
|
+
case "":
|
|
737
|
+
case "=":
|
|
738
|
+
case "==":
|
|
739
|
+
return cn(n, e, r);
|
|
740
|
+
case "!=":
|
|
741
|
+
return un(n, e, r);
|
|
742
|
+
case ">":
|
|
743
|
+
return pn(n, e, r);
|
|
744
|
+
case ">=":
|
|
745
|
+
return mn(n, e, r);
|
|
746
|
+
case "<":
|
|
747
|
+
return En(n, e, r);
|
|
748
|
+
case "<=":
|
|
749
|
+
return gn(n, e, r);
|
|
750
|
+
default:
|
|
751
|
+
throw new TypeError(`Invalid operator: ${t}`);
|
|
752
|
+
}
|
|
753
|
+
};
|
|
754
|
+
Ce = Rn;
|
|
755
|
+
te = Symbol("SemVer ANY");
|
|
756
|
+
D = class {
|
|
757
|
+
static get ANY() {
|
|
758
|
+
return te;
|
|
759
|
+
}
|
|
760
|
+
constructor(t, e) {
|
|
761
|
+
if (e && typeof e == "object" || (e = { loose: !!e, includePrerelease: false }), t instanceof D) {
|
|
762
|
+
if (t.loose === !!e.loose)
|
|
763
|
+
return t;
|
|
764
|
+
t = t.value;
|
|
765
|
+
}
|
|
766
|
+
f2("comparator", t, e), this.options = e, this.loose = !!e.loose, this.parse(t), this.semver === te ? this.value = "" : this.value = this.operator + this.semver.version, f2("comp", this);
|
|
767
|
+
}
|
|
768
|
+
parse(t) {
|
|
769
|
+
let e = this.options.loose ? tt[nt.COMPARATORLOOSE] : tt[nt.COMPARATOR], r = t.match(e);
|
|
770
|
+
if (!r)
|
|
771
|
+
throw new TypeError(`Invalid comparator: ${t}`);
|
|
772
|
+
this.operator = r[1] !== void 0 ? r[1] : "", this.operator === "=" && (this.operator = ""), r[2] ? this.semver = new E2(r[2], this.options.loose) : this.semver = te;
|
|
773
|
+
}
|
|
774
|
+
toString() {
|
|
775
|
+
return this.value;
|
|
776
|
+
}
|
|
777
|
+
test(t) {
|
|
778
|
+
if (f2("Comparator.test", t, this.options.loose), this.semver === te || t === te)
|
|
779
|
+
return true;
|
|
780
|
+
if (typeof t == "string")
|
|
781
|
+
try {
|
|
782
|
+
t = new E2(t, this.options);
|
|
783
|
+
} catch (e) {
|
|
784
|
+
return false;
|
|
785
|
+
}
|
|
786
|
+
return Ce(t, this.operator, this.semver, this.options);
|
|
787
|
+
}
|
|
788
|
+
intersects(t, e) {
|
|
789
|
+
if (!(t instanceof D))
|
|
790
|
+
throw new TypeError("a Comparator is required");
|
|
791
|
+
if (e && typeof e == "object" || (e = { loose: !!e, includePrerelease: false }), this.operator === "")
|
|
792
|
+
return this.value === "" || new L2(t.value, e).test(this.value);
|
|
793
|
+
if (t.operator === "")
|
|
794
|
+
return t.value === "" || new L2(this.value, e).test(t.semver);
|
|
795
|
+
let r = !(this.operator !== ">=" && this.operator !== ">" || t.operator !== ">=" && t.operator !== ">"), o = !(this.operator !== "<=" && this.operator !== "<" || t.operator !== "<=" && t.operator !== "<"), s = this.semver.version === t.semver.version, a2 = !(this.operator !== ">=" && this.operator !== "<=" || t.operator !== ">=" && t.operator !== "<="), i = Ce(this.semver, "<", t.semver, e) && (this.operator === ">=" || this.operator === ">") && (t.operator === "<=" || t.operator === "<"), c3 = Ce(this.semver, ">", t.semver, e) && (this.operator === "<=" || this.operator === "<") && (t.operator === ">=" || t.operator === ">");
|
|
796
|
+
return r || o || s && a2 || i || c3;
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
({ re: tt, t: nt } = ne);
|
|
800
|
+
L2 = class {
|
|
801
|
+
constructor(t, e) {
|
|
802
|
+
if (e && typeof e == "object" || (e = { loose: !!e, includePrerelease: false }), t instanceof L2)
|
|
803
|
+
return t.loose === !!e.loose && t.includePrerelease === !!e.includePrerelease ? t : new L2(t.raw, e);
|
|
804
|
+
if (t instanceof D)
|
|
805
|
+
return this.raw = t.value, this.set = [[t]], this.format(), this;
|
|
806
|
+
if (this.options = e, this.loose = !!e.loose, this.includePrerelease = !!e.includePrerelease, this.raw = t, this.set = t.split(/\s*\|\|\s*/).map((r) => this.parseRange(r.trim())).filter((r) => r.length), !this.set.length)
|
|
807
|
+
throw new TypeError(`Invalid SemVer Range: ${t}`);
|
|
808
|
+
this.format();
|
|
809
|
+
}
|
|
810
|
+
format() {
|
|
811
|
+
return this.range = this.set.map((t) => t.join(" ").trim()).join("||").trim(), this.range;
|
|
812
|
+
}
|
|
813
|
+
toString() {
|
|
814
|
+
return this.range;
|
|
815
|
+
}
|
|
816
|
+
parseRange(t) {
|
|
817
|
+
let { loose: e } = this.options;
|
|
818
|
+
t = t.trim();
|
|
819
|
+
let r = e ? T2[g2.HYPHENRANGELOOSE] : T2[g2.HYPHENRANGE];
|
|
820
|
+
t = t.replace(r, Sn(this.options.includePrerelease)), f2("hyphen replace", t), t = t.replace(T2[g2.COMPARATORTRIM], vn), f2("comparator trim", t, T2[g2.COMPARATORTRIM]), t = (t = (t = t.replace(T2[g2.TILDETRIM], Tn)).replace(T2[g2.CARETTRIM], In)).split(/\s+/).join(" ");
|
|
821
|
+
let o = e ? T2[g2.COMPARATORLOOSE] : T2[g2.COMPARATOR];
|
|
822
|
+
return t.split(" ").map((s) => bn(s, this.options)).join(" ").split(/\s+/).map((s) => An(s, this.options)).filter(this.options.loose ? (s) => !!s.match(o) : () => true).map((s) => new D(s, this.options));
|
|
823
|
+
}
|
|
824
|
+
intersects(t, e) {
|
|
825
|
+
if (!(t instanceof L2))
|
|
826
|
+
throw new TypeError("a Range is required");
|
|
827
|
+
return this.set.some((r) => rt(r, e) && t.set.some((o) => rt(o, e) && r.every((s) => o.every((a2) => s.intersects(a2, e)))));
|
|
828
|
+
}
|
|
829
|
+
test(t) {
|
|
830
|
+
if (!t)
|
|
831
|
+
return false;
|
|
832
|
+
if (typeof t == "string")
|
|
833
|
+
try {
|
|
834
|
+
t = new E2(t, this.options);
|
|
835
|
+
} catch (e) {
|
|
836
|
+
return false;
|
|
837
|
+
}
|
|
838
|
+
for (let e = 0; e < this.set.length; e++)
|
|
839
|
+
if (Ln(this.set[e], t, this.options))
|
|
840
|
+
return true;
|
|
841
|
+
return false;
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
({ re: T2, t: g2, comparatorTrimReplace: vn, tildeTrimReplace: Tn, caretTrimReplace: In } = ne);
|
|
845
|
+
rt = (n, t) => {
|
|
846
|
+
let e = true, r = n.slice(), o = r.pop();
|
|
847
|
+
for (; e && r.length; )
|
|
848
|
+
e = r.every((s) => o.intersects(s, t)), o = r.pop();
|
|
849
|
+
return e;
|
|
850
|
+
};
|
|
851
|
+
bn = (n, t) => (f2("comp", n, t), n = Mn(n, t), f2("caret", n), n = wn(n, t), f2("tildes", n), n = Nn(n, t), f2("xrange", n), n = Cn(n, t), f2("stars", n), n);
|
|
852
|
+
b = (n) => !n || n.toLowerCase() === "x" || n === "*";
|
|
853
|
+
wn = (n, t) => n.trim().split(/\s+/).map((e) => Pn(e, t)).join(" ");
|
|
854
|
+
Pn = (n, t) => {
|
|
855
|
+
let e = t.loose ? T2[g2.TILDELOOSE] : T2[g2.TILDE];
|
|
856
|
+
return n.replace(e, (r, o, s, a2, i) => {
|
|
857
|
+
let c3;
|
|
858
|
+
return f2("tilde", n, r, o, s, a2, i), b(o) ? c3 = "" : b(s) ? c3 = `>=${o}.0.0 <${+o + 1}.0.0-0` : b(a2) ? c3 = `>=${o}.${s}.0 <${o}.${+s + 1}.0-0` : i ? (f2("replaceTilde pr", i), c3 = `>=${o}.${s}.${a2}-${i} <${o}.${+s + 1}.0-0`) : c3 = `>=${o}.${s}.${a2} <${o}.${+s + 1}.0-0`, f2("tilde return", c3), c3;
|
|
859
|
+
});
|
|
860
|
+
};
|
|
861
|
+
Mn = (n, t) => n.trim().split(/\s+/).map((e) => xn(e, t)).join(" ");
|
|
862
|
+
xn = (n, t) => {
|
|
863
|
+
f2("caret", n, t);
|
|
864
|
+
let e = t.loose ? T2[g2.CARETLOOSE] : T2[g2.CARET], r = t.includePrerelease ? "-0" : "";
|
|
865
|
+
return n.replace(e, (o, s, a2, i, c3) => {
|
|
866
|
+
let u2;
|
|
867
|
+
return f2("caret", n, o, s, a2, i, c3), b(s) ? u2 = "" : b(a2) ? u2 = `>=${s}.0.0${r} <${+s + 1}.0.0-0` : b(i) ? u2 = s === "0" ? `>=${s}.${a2}.0${r} <${s}.${+a2 + 1}.0-0` : `>=${s}.${a2}.0${r} <${+s + 1}.0.0-0` : c3 ? (f2("replaceCaret pr", c3), u2 = s === "0" ? a2 === "0" ? `>=${s}.${a2}.${i}-${c3} <${s}.${a2}.${+i + 1}-0` : `>=${s}.${a2}.${i}-${c3} <${s}.${+a2 + 1}.0-0` : `>=${s}.${a2}.${i}-${c3} <${+s + 1}.0.0-0`) : (f2("no pr"), u2 = s === "0" ? a2 === "0" ? `>=${s}.${a2}.${i}${r} <${s}.${a2}.${+i + 1}-0` : `>=${s}.${a2}.${i}${r} <${s}.${+a2 + 1}.0-0` : `>=${s}.${a2}.${i} <${+s + 1}.0.0-0`), f2("caret return", u2), u2;
|
|
868
|
+
});
|
|
869
|
+
};
|
|
870
|
+
Nn = (n, t) => (f2("replaceXRanges", n, t), n.split(/\s+/).map((e) => $n(e, t)).join(" "));
|
|
871
|
+
$n = (n, t) => {
|
|
872
|
+
n = n.trim();
|
|
873
|
+
let e = t.loose ? T2[g2.XRANGELOOSE] : T2[g2.XRANGE];
|
|
874
|
+
return n.replace(e, (r, o, s, a2, i, c3) => {
|
|
875
|
+
f2("xRange", n, r, o, s, a2, i, c3);
|
|
876
|
+
let u2 = b(s), l = u2 || b(a2), p2 = l || b(i), x2 = p2;
|
|
877
|
+
return o === "=" && x2 && (o = ""), c3 = t.includePrerelease ? "-0" : "", u2 ? r = o === ">" || o === "<" ? "<0.0.0-0" : "*" : o && x2 ? (l && (a2 = 0), i = 0, o === ">" ? (o = ">=", l ? (s = +s + 1, a2 = 0, i = 0) : (a2 = +a2 + 1, i = 0)) : o === "<=" && (o = "<", l ? s = +s + 1 : a2 = +a2 + 1), o === "<" && (c3 = "-0"), r = `${o + s}.${a2}.${i}${c3}`) : l ? r = `>=${s}.0.0${c3} <${+s + 1}.0.0-0` : p2 && (r = `>=${s}.${a2}.0${c3} <${s}.${+a2 + 1}.0-0`), f2("xRange return", r), r;
|
|
878
|
+
});
|
|
879
|
+
};
|
|
880
|
+
Cn = (n, t) => (f2("replaceStars", n, t), n.trim().replace(T2[g2.STAR], ""));
|
|
881
|
+
An = (n, t) => (f2("replaceGTE0", n, t), n.trim().replace(T2[t.includePrerelease ? g2.GTE0PRE : g2.GTE0], ""));
|
|
882
|
+
Sn = (n) => (t, e, r, o, s, a2, i, c3, u2, l, p2, x2, v2) => `${e = b(r) ? "" : b(o) ? `>=${r}.0.0${n ? "-0" : ""}` : b(s) ? `>=${r}.${o}.0${n ? "-0" : ""}` : a2 ? `>=${e}` : `>=${e}${n ? "-0" : ""}`} ${c3 = b(u2) ? "" : b(l) ? `<${+u2 + 1}.0.0-0` : b(p2) ? `<${u2}.${+l + 1}.0-0` : x2 ? `<=${u2}.${l}.${p2}-${x2}` : n ? `<${u2}.${l}.${+p2 + 1}-0` : `<=${c3}`}`.trim();
|
|
883
|
+
Ln = (n, t, e) => {
|
|
884
|
+
for (let r = 0; r < n.length; r++)
|
|
885
|
+
if (!n[r].test(t))
|
|
886
|
+
return false;
|
|
887
|
+
if (t.prerelease.length && !e.includePrerelease) {
|
|
888
|
+
for (let r = 0; r < n.length; r++)
|
|
889
|
+
if (f2(n[r].semver), n[r].semver !== D.ANY && n[r].semver.prerelease.length > 0) {
|
|
890
|
+
let o = n[r].semver;
|
|
891
|
+
if (o.major === t.major && o.minor === t.minor && o.patch === t.patch)
|
|
892
|
+
return true;
|
|
893
|
+
}
|
|
894
|
+
return false;
|
|
895
|
+
}
|
|
896
|
+
return true;
|
|
897
|
+
};
|
|
898
|
+
at = (n, t, e) => {
|
|
899
|
+
try {
|
|
900
|
+
t = new L2(t, e);
|
|
901
|
+
} catch (r) {
|
|
902
|
+
return false;
|
|
903
|
+
}
|
|
904
|
+
return t.test(n);
|
|
905
|
+
};
|
|
906
|
+
({ MAX_LENGTH: On } = Ae);
|
|
907
|
+
({ re: st, t: ot } = ne);
|
|
908
|
+
_n = (n, t) => {
|
|
909
|
+
if (t && typeof t == "object" || (t = { loose: !!t, includePrerelease: false }), n instanceof E2)
|
|
910
|
+
return n;
|
|
911
|
+
if (typeof n != "string" || n.length > On || !(t.loose ? st[ot.LOOSE] : st[ot.FULL]).test(n))
|
|
912
|
+
return null;
|
|
913
|
+
try {
|
|
914
|
+
return new E2(n, t);
|
|
915
|
+
} catch (e) {
|
|
916
|
+
return null;
|
|
917
|
+
}
|
|
918
|
+
};
|
|
919
|
+
kn = _n;
|
|
920
|
+
({ re: pe, t: he } = ne);
|
|
921
|
+
ct = (n, t) => {
|
|
922
|
+
if (n instanceof E2)
|
|
923
|
+
return n;
|
|
924
|
+
if (typeof n == "number" && (n = String(n)), typeof n != "string")
|
|
925
|
+
return null;
|
|
926
|
+
let e = null;
|
|
927
|
+
if ((t = t || {}).rtl) {
|
|
928
|
+
let r;
|
|
929
|
+
for (; (r = pe[he.COERCERTL].exec(n)) && (!e || e.index + e[0].length !== n.length); )
|
|
930
|
+
e && r.index + r[0].length === e.index + e[0].length || (e = r), pe[he.COERCERTL].lastIndex = r.index + r[1].length + r[2].length;
|
|
931
|
+
pe[he.COERCERTL].lastIndex = -1;
|
|
932
|
+
} else
|
|
933
|
+
e = n.match(pe[he.COERCE]);
|
|
934
|
+
return e === null ? null : kn(`${e[2]}.${e[3] || "0"}.${e[4] || "0"}`, t);
|
|
935
|
+
};
|
|
936
|
+
h2 = {};
|
|
937
|
+
pt = { "magic-sdk": "magic-sdk", "@magic-sdk/react-native": "magic-sdk-rn", "@magic-sdk/react-native-bare": "magic-sdk-rn-bare", "@magic-sdk/react-native-expo": "magic-sdk-rn-expo" };
|
|
938
|
+
A2 = class extends Error {
|
|
939
|
+
constructor(e, r) {
|
|
940
|
+
super(`Magic SDK Error: [${e}] ${r}`);
|
|
941
|
+
this.code = e;
|
|
942
|
+
this.rawMessage = r;
|
|
943
|
+
this.__proto__ = Error;
|
|
944
|
+
Object.setPrototypeOf(this, A2.prototype);
|
|
945
|
+
}
|
|
946
|
+
};
|
|
947
|
+
_2 = class extends Error {
|
|
948
|
+
constructor(e) {
|
|
949
|
+
super();
|
|
950
|
+
this.__proto__ = Error;
|
|
951
|
+
let r = Number(e == null ? void 0 : e.code);
|
|
952
|
+
this.rawMessage = (e == null ? void 0 : e.message) || "Internal error", this.code = dt(r) ? r : _.InternalError, this.message = `Magic RPC Error: [${this.code}] ${this.rawMessage}`, this.data = (e == null ? void 0 : e.data) || void 0, Object.setPrototypeOf(this, _2.prototype);
|
|
953
|
+
}
|
|
954
|
+
};
|
|
955
|
+
W = class {
|
|
956
|
+
constructor(t, e) {
|
|
957
|
+
this.code = t;
|
|
958
|
+
this.rawMessage = e;
|
|
959
|
+
this.message = `Magic SDK Warning: [${t}] ${e}`;
|
|
960
|
+
}
|
|
961
|
+
log() {
|
|
962
|
+
console.warn(this.message);
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
V = class extends Error {
|
|
966
|
+
constructor(e, r, o, s) {
|
|
967
|
+
super(`Magic Extension Error (${e.name}): [${r}] ${o}`);
|
|
968
|
+
this.code = r;
|
|
969
|
+
this.rawMessage = o;
|
|
970
|
+
this.data = s;
|
|
971
|
+
this.__proto__ = Error;
|
|
972
|
+
Object.setPrototypeOf(this, V.prototype);
|
|
973
|
+
}
|
|
974
|
+
};
|
|
975
|
+
se = class {
|
|
976
|
+
constructor(t, e, r) {
|
|
977
|
+
this.code = e;
|
|
978
|
+
this.rawMessage = r;
|
|
979
|
+
this.message = `Magic Extension Warning (${t.name}): [${e}] ${r}`;
|
|
980
|
+
}
|
|
981
|
+
log() {
|
|
982
|
+
console.warn(this.message);
|
|
983
|
+
}
|
|
984
|
+
};
|
|
985
|
+
Hn = Bn();
|
|
986
|
+
Tt = Symbol("Payload pre-processed by Magic SDK");
|
|
987
|
+
F = class {
|
|
988
|
+
constructor(t) {
|
|
989
|
+
t instanceof F ? (this._jsonrpc = t.payload.jsonrpc, this._id = t.payload.id, this._result = t.payload.result, this._error = t.payload.error) : ut(t) ? (this._jsonrpc = t.jsonrpc, this._id = t.id, this._result = t.result, this._error = t.error) : (this._jsonrpc = t.jsonrpc, this._id = t.id, this._result = void 0, this._error = void 0);
|
|
990
|
+
}
|
|
991
|
+
applyError(t) {
|
|
992
|
+
return this._error = t, this;
|
|
993
|
+
}
|
|
994
|
+
applyResult(t) {
|
|
995
|
+
return this._result = t, this;
|
|
996
|
+
}
|
|
997
|
+
get hasError() {
|
|
998
|
+
return typeof this._error != "undefined" && this._error !== null;
|
|
999
|
+
}
|
|
1000
|
+
get hasResult() {
|
|
1001
|
+
return typeof this._result != "undefined";
|
|
1002
|
+
}
|
|
1003
|
+
get payload() {
|
|
1004
|
+
return { jsonrpc: this._jsonrpc, id: this._id, result: this._result, error: this._error };
|
|
1005
|
+
}
|
|
1006
|
+
};
|
|
1007
|
+
Pt = Qt(wt());
|
|
1008
|
+
Oe = class extends Pt.default {
|
|
1009
|
+
};
|
|
1010
|
+
Mt = Symbol("isPromiEvent");
|
|
1011
|
+
P = class {
|
|
1012
|
+
constructor(t) {
|
|
1013
|
+
this.sdk = t;
|
|
1014
|
+
}
|
|
1015
|
+
get overlay() {
|
|
1016
|
+
return this.sdk.overlay;
|
|
1017
|
+
}
|
|
1018
|
+
request(t) {
|
|
1019
|
+
let e = this.overlay.post(d.MAGIC_HANDLE_REQUEST, G(t)), r = k2((s, a2) => {
|
|
1020
|
+
e.then((i) => {
|
|
1021
|
+
if (o(), i.hasError)
|
|
1022
|
+
a2(new _2(i.payload.error));
|
|
1023
|
+
else if (i.hasResult)
|
|
1024
|
+
s(i.payload.result);
|
|
1025
|
+
else
|
|
1026
|
+
throw ft();
|
|
1027
|
+
}).catch((i) => {
|
|
1028
|
+
o(), a2(i);
|
|
1029
|
+
});
|
|
1030
|
+
}), o = this.overlay.on(f.MAGIC_HANDLE_EVENT, (s) => {
|
|
1031
|
+
var i;
|
|
1032
|
+
let { response: a2 } = s.data;
|
|
1033
|
+
if (a2.id === t.id && ((i = a2.result) == null ? void 0 : i.event)) {
|
|
1034
|
+
let { event: c3, params: u2 = [] } = a2.result;
|
|
1035
|
+
r.emit(c3, ...u2);
|
|
1036
|
+
}
|
|
1037
|
+
});
|
|
1038
|
+
return r;
|
|
1039
|
+
}
|
|
1040
|
+
createIntermediaryEvent(t, e) {
|
|
1041
|
+
return (o) => {
|
|
1042
|
+
let s = d2(E.IntermediaryEvent, [{ payloadId: e, eventType: t, args: o }]);
|
|
1043
|
+
this.request(s);
|
|
1044
|
+
};
|
|
1045
|
+
}
|
|
1046
|
+
};
|
|
1047
|
+
K = { "magic-sdk": "v18.0.0", "@magic-sdk/react-native": "v14.0.0", "@magic-sdk/react-native-bare": "v19.0.0", "@magic-sdk/react-native-expo": "v19.0.0" };
|
|
1048
|
+
ve = class extends P {
|
|
1049
|
+
loginWithMagicLink(t) {
|
|
1050
|
+
let e = h2.sdkName === "@magic-sdk/react-native" || h2.sdkName === "@magic-sdk/react-native-bare" || h2.sdkName === "@magic-sdk/react-native-expo";
|
|
1051
|
+
if (e && Nt(h2.version, 19))
|
|
1052
|
+
throw new Error("loginWithMagicLink() is deprecated for this package, please utlize a passcode method like loginWithSMS or loginWithEmailOTP instead.");
|
|
1053
|
+
e && U2({ method: "auth.loginWithMagicLink()", removalVersions: K, useInstead: "auth.loginWithEmailOTP()" }).log();
|
|
1054
|
+
let { email: r, showUI: o = true, redirectURI: s, overrides: a2 } = t, i = d2(this.sdk.testMode ? E.LoginWithMagicLinkTestMode : E.LoginWithMagicLink, [{ email: r, showUI: o, redirectURI: s, overrides: a2 }]);
|
|
1055
|
+
return this.request(i);
|
|
1056
|
+
}
|
|
1057
|
+
loginWithSMS(t) {
|
|
1058
|
+
let { phoneNumber: e } = t, r = d2(this.sdk.testMode ? E.LoginWithSmsTestMode : E.LoginWithSms, [{ phoneNumber: e, showUI: true }]);
|
|
1059
|
+
return this.request(r);
|
|
1060
|
+
}
|
|
1061
|
+
loginWithEmailOTP(t) {
|
|
1062
|
+
let { email: e, showUI: r, deviceCheckUI: o, overrides: s } = t, a2 = d2(this.sdk.testMode ? E.LoginWithEmailOTPTestMode : E.LoginWithEmailOTP, [{ email: e, showUI: r, deviceCheckUI: o, overrides: s }]), i = this.request(a2);
|
|
1063
|
+
return !o && i && i.on(R.Retry, () => {
|
|
1064
|
+
this.createIntermediaryEvent(R.Retry, a2.id)();
|
|
1065
|
+
}), !r && i && (i.on(I.VerifyEmailOtp, (c3) => {
|
|
1066
|
+
this.createIntermediaryEvent(I.VerifyEmailOtp, a2.id)(c3);
|
|
1067
|
+
}), i.on(I.Cancel, () => {
|
|
1068
|
+
this.createIntermediaryEvent(I.Cancel, a2.id)();
|
|
1069
|
+
})), i;
|
|
1070
|
+
}
|
|
1071
|
+
loginWithCredential(t) {
|
|
1072
|
+
let e = t != null ? t : "";
|
|
1073
|
+
if (!t && h2.platform === "web") {
|
|
1074
|
+
e = window.location.search;
|
|
1075
|
+
let o = window.location.origin + window.location.pathname;
|
|
1076
|
+
window.history.replaceState(null, "", o);
|
|
1077
|
+
}
|
|
1078
|
+
let r = d2(this.sdk.testMode ? E.LoginWithCredentialTestMode : E.LoginWithCredential, [e]);
|
|
1079
|
+
return this.request(r);
|
|
1080
|
+
}
|
|
1081
|
+
setAuthorizationToken(t) {
|
|
1082
|
+
let e = d2(E.SetAuthorizationToken, [{ jwt: t }]);
|
|
1083
|
+
return this.request(e);
|
|
1084
|
+
}
|
|
1085
|
+
updateEmailWithUI(t) {
|
|
1086
|
+
let { email: e, showUI: r = true } = t, o = d2(this.sdk.testMode ? E.UpdateEmailTestMode : E.UpdateEmail, [{ email: e, showUI: r }]), s = this.request(o);
|
|
1087
|
+
return r || (s.on(h.Retry, () => {
|
|
1088
|
+
this.createIntermediaryEvent(h.Retry, o.id)();
|
|
1089
|
+
}), s.on(h.Cancel, () => {
|
|
1090
|
+
this.createIntermediaryEvent(h.Cancel, o.id)();
|
|
1091
|
+
}), s.on(h.VerifyEmailOtp, (a2) => {
|
|
1092
|
+
this.createIntermediaryEvent(h.VerifyEmailOtp, o.id)(a2);
|
|
1093
|
+
}), s.on(U.RetryWithNewEmail, (a2) => {
|
|
1094
|
+
this.createIntermediaryEvent(U.RetryWithNewEmail, o.id)(a2);
|
|
1095
|
+
}), s.on(U.Cancel, () => {
|
|
1096
|
+
this.createIntermediaryEvent(U.Cancel, o.id)();
|
|
1097
|
+
}), s.on(U.VerifyEmailOtp, (a2) => {
|
|
1098
|
+
this.createIntermediaryEvent(U.VerifyEmailOtp, o.id)(a2);
|
|
1099
|
+
})), s;
|
|
1100
|
+
}
|
|
1101
|
+
};
|
|
1102
|
+
ie = {};
|
|
1103
|
+
Yt(ie, { clear: () => er, getItem: () => y2, iterate: () => ke, key: () => nr, keys: () => rr, length: () => tr, removeItem: () => N2, setItem: () => M });
|
|
1104
|
+
y2 = J("getItem");
|
|
1105
|
+
M = J("setItem");
|
|
1106
|
+
N2 = J("removeItem");
|
|
1107
|
+
er = J("clear");
|
|
1108
|
+
tr = J("length");
|
|
1109
|
+
nr = J("key");
|
|
1110
|
+
rr = J("keys");
|
|
1111
|
+
ke = J("iterate");
|
|
1112
|
+
qe = "STORE_KEY_PRIVATE_KEY";
|
|
1113
|
+
Ie = "STORE_KEY_PUBLIC_JWK";
|
|
1114
|
+
St = "ECDSA";
|
|
1115
|
+
sr = "P-256";
|
|
1116
|
+
or = { name: St, namedCurve: sr };
|
|
1117
|
+
De = "ds";
|
|
1118
|
+
We = "ek";
|
|
1119
|
+
Ue = "iv";
|
|
1120
|
+
Fe = "AES-GCM";
|
|
1121
|
+
dr = 256;
|
|
1122
|
+
be = class extends P {
|
|
1123
|
+
constructor() {
|
|
1124
|
+
super(...arguments);
|
|
1125
|
+
this.localForageKey = "mc_active_wallet";
|
|
1126
|
+
this.localForageIsLoggedInKey = "magic_auth_is_logged_in";
|
|
1127
|
+
this.userLoggedOutCallbacks = [];
|
|
1128
|
+
}
|
|
1129
|
+
getIdToken(e) {
|
|
1130
|
+
let r = d2(this.sdk.testMode ? E.GetIdTokenTestMode : E.GetIdToken, [e]);
|
|
1131
|
+
return this.request(r);
|
|
1132
|
+
}
|
|
1133
|
+
generateIdToken(e) {
|
|
1134
|
+
let r = d2(this.sdk.testMode ? E.GenerateIdTokenTestMode : E.GenerateIdToken, [e]);
|
|
1135
|
+
return this.request(r);
|
|
1136
|
+
}
|
|
1137
|
+
getInfo() {
|
|
1138
|
+
return m(this, null, function* () {
|
|
1139
|
+
let e = yield y2(this.localForageKey), r = d2(E.GetInfo, [{ walletType: e }]);
|
|
1140
|
+
return this.request(r);
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
isLoggedIn() {
|
|
1144
|
+
return k2((e, r) => m(this, null, function* () {
|
|
1145
|
+
try {
|
|
1146
|
+
let o = false;
|
|
1147
|
+
this.sdk.useStorageCache && (o = (yield y2(this.localForageIsLoggedInKey)) === "true", o && e(true));
|
|
1148
|
+
let s = d2(this.sdk.testMode ? E.IsLoggedInTestMode : E.IsLoggedIn), a2 = yield this.request(s);
|
|
1149
|
+
this.sdk.useStorageCache && (a2 ? M(this.localForageIsLoggedInKey, true) : N2(this.localForageIsLoggedInKey), o && !a2 && this.emitUserLoggedOut(true)), e(a2);
|
|
1150
|
+
} catch (o) {
|
|
1151
|
+
r(o);
|
|
1152
|
+
}
|
|
1153
|
+
}));
|
|
1154
|
+
}
|
|
1155
|
+
logout() {
|
|
1156
|
+
return N2(this.localForageKey), N2(this.localForageIsLoggedInKey), Z(), k2((e, r) => m(this, null, function* () {
|
|
1157
|
+
try {
|
|
1158
|
+
let o = d2(this.sdk.testMode ? E.LogoutTestMode : E.Logout), s = yield this.request(o);
|
|
1159
|
+
this.sdk.useStorageCache && this.emitUserLoggedOut(s), e(s);
|
|
1160
|
+
} catch (o) {
|
|
1161
|
+
r(o);
|
|
1162
|
+
}
|
|
1163
|
+
}));
|
|
1164
|
+
}
|
|
1165
|
+
requestInfoWithUI(e) {
|
|
1166
|
+
let r = d2(E.RequestUserInfoWithUI, e ? [e] : []);
|
|
1167
|
+
return this.request(r);
|
|
1168
|
+
}
|
|
1169
|
+
showSettings(e) {
|
|
1170
|
+
let r = d2(this.sdk.testMode ? E.UserSettingsTestMode : E.UserSettings, [e]);
|
|
1171
|
+
return this.request(r);
|
|
1172
|
+
}
|
|
1173
|
+
recoverAccount(e) {
|
|
1174
|
+
let r = d2(this.sdk.testMode ? E.RecoverAccountTestMode : E.RecoverAccount, [e]);
|
|
1175
|
+
return this.request(r);
|
|
1176
|
+
}
|
|
1177
|
+
revealPrivateKey() {
|
|
1178
|
+
let e = d2(E.RevealPK);
|
|
1179
|
+
return this.request(e);
|
|
1180
|
+
}
|
|
1181
|
+
getMetadata() {
|
|
1182
|
+
U2({ method: "user.getMetadata()", removalVersions: K, useInstead: "user.getInfo()" }).log();
|
|
1183
|
+
let e = d2(this.sdk.testMode ? E.GetMetadataTestMode : E.GetMetadata);
|
|
1184
|
+
return this.request(e);
|
|
1185
|
+
}
|
|
1186
|
+
onUserLoggedOut(e) {
|
|
1187
|
+
this.userLoggedOutCallbacks.push(e);
|
|
1188
|
+
}
|
|
1189
|
+
emitUserLoggedOut(e) {
|
|
1190
|
+
this.userLoggedOutCallbacks.forEach((r) => {
|
|
1191
|
+
r(e);
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
};
|
|
1195
|
+
we = class extends P {
|
|
1196
|
+
constructor() {
|
|
1197
|
+
super(...arguments);
|
|
1198
|
+
this.localForageKey = "mc_active_wallet";
|
|
1199
|
+
}
|
|
1200
|
+
connectWithUI() {
|
|
1201
|
+
let e = k2((r, o) => m(this, null, function* () {
|
|
1202
|
+
try {
|
|
1203
|
+
if (this.isMetaMaskBrowser() && (yield this.isWalletEnabled(u.MetaMask))) {
|
|
1204
|
+
let u2 = yield this.autoConnectIfWalletBrowser(u.MetaMask);
|
|
1205
|
+
r(u2);
|
|
1206
|
+
return;
|
|
1207
|
+
}
|
|
1208
|
+
if (this.isCoinbaseWalletBrowser() && (yield this.isWalletEnabled(u.CoinbaseWallet))) {
|
|
1209
|
+
let u2 = yield this.autoConnectIfWalletBrowser(u.CoinbaseWallet);
|
|
1210
|
+
r(u2);
|
|
1211
|
+
return;
|
|
1212
|
+
}
|
|
1213
|
+
let s = this.getUserEnv(), a2 = d2(E.Login, [s]), i = this.request(a2);
|
|
1214
|
+
i.on(v.WalletSelected, (u2) => this.handleWalletSelected(B(j({}, u2), { payloadId: a2.id }))), i.on("id-token-created", (u2) => {
|
|
1215
|
+
e.emit("id-token-created", u2);
|
|
1216
|
+
});
|
|
1217
|
+
let c3 = yield i;
|
|
1218
|
+
c3.error && o(c3), r(c3);
|
|
1219
|
+
} catch (s) {
|
|
1220
|
+
o(s);
|
|
1221
|
+
}
|
|
1222
|
+
}));
|
|
1223
|
+
return e;
|
|
1224
|
+
}
|
|
1225
|
+
showUI() {
|
|
1226
|
+
return this.request(d2(E.ShowUI));
|
|
1227
|
+
}
|
|
1228
|
+
showAddress() {
|
|
1229
|
+
return this.request(d2(E.ShowAddress));
|
|
1230
|
+
}
|
|
1231
|
+
showSendTokensUI() {
|
|
1232
|
+
return this.request(d2(E.ShowSendTokensUI));
|
|
1233
|
+
}
|
|
1234
|
+
showOnRamp() {
|
|
1235
|
+
return this.request(d2(E.ShowOnRamp));
|
|
1236
|
+
}
|
|
1237
|
+
showNFTs() {
|
|
1238
|
+
return this.request(d2(E.ShowNFTs));
|
|
1239
|
+
}
|
|
1240
|
+
showBalances() {
|
|
1241
|
+
return this.request(d2(E.ShowBalances));
|
|
1242
|
+
}
|
|
1243
|
+
sendGaslessTransaction(e, r) {
|
|
1244
|
+
return this.request(d2(E.SendGaslessTransaction, [e, r]));
|
|
1245
|
+
}
|
|
1246
|
+
getInfo() {
|
|
1247
|
+
return m(this, null, function* () {
|
|
1248
|
+
U2({ method: "wallet.getInfo()", removalVersions: K, useInstead: "user.getInfo()" }).log();
|
|
1249
|
+
let e = yield y2(this.localForageKey), r = d2(E.GetInfo, [{ walletType: e }]);
|
|
1250
|
+
return this.request(r);
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1253
|
+
disconnect() {
|
|
1254
|
+
U2({ method: "wallet.disconnect()", removalVersions: K, useInstead: "user.logout()" }).log(), N2(this.localForageKey), Z();
|
|
1255
|
+
let e = d2(E.Disconnect);
|
|
1256
|
+
return this.request(e);
|
|
1257
|
+
}
|
|
1258
|
+
requestUserInfoWithUI(e) {
|
|
1259
|
+
U2({ method: "wallet.requestUserInfoWithUI()", removalVersions: K, useInstead: "user.requestUserInfoWithUI()" }).log();
|
|
1260
|
+
let r = d2(E.RequestUserInfoWithUI, e ? [e] : []);
|
|
1261
|
+
return this.request(r);
|
|
1262
|
+
}
|
|
1263
|
+
getProvider() {
|
|
1264
|
+
return m(this, null, function* () {
|
|
1265
|
+
switch (yield y2(this.localForageKey)) {
|
|
1266
|
+
case u.MetaMask:
|
|
1267
|
+
return this.getMetaMaskProvider();
|
|
1268
|
+
case u.CoinbaseWallet:
|
|
1269
|
+
return this.getCoinbaseProvider();
|
|
1270
|
+
default:
|
|
1271
|
+
return this.sdk.rpcProvider;
|
|
1272
|
+
}
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
isMetaMaskInstalled() {
|
|
1276
|
+
var e, r, o;
|
|
1277
|
+
return ((e = window.ethereum) == null ? void 0 : e.isMetaMask) || !!((o = (r = window.ethereum) == null ? void 0 : r.providers) != null && o.find((s) => s == null ? void 0 : s.isMetaMask));
|
|
1278
|
+
}
|
|
1279
|
+
isMetaMaskBrowser() {
|
|
1280
|
+
return this.isMobile() && this.isMetaMaskInstalled();
|
|
1281
|
+
}
|
|
1282
|
+
getMetaMaskProvider() {
|
|
1283
|
+
var e, r;
|
|
1284
|
+
return ((r = (e = window.ethereum) == null ? void 0 : e.providers) == null ? void 0 : r.find((o) => o == null ? void 0 : o.isMetaMask)) || window.ethereum;
|
|
1285
|
+
}
|
|
1286
|
+
connectToMetaMask() {
|
|
1287
|
+
if (this.isMobile() && !this.isMetaMaskInstalled()) {
|
|
1288
|
+
let e = `https://metamask.app.link/dapp/${window.location.href.replace(/(^\w+:|^)\/\//, "")}`;
|
|
1289
|
+
window.location.href = e;
|
|
1290
|
+
}
|
|
1291
|
+
return this.getMetaMaskProvider().request({ method: "eth_requestAccounts" });
|
|
1292
|
+
}
|
|
1293
|
+
isCoinbaseWalletInstalled() {
|
|
1294
|
+
var e, r, o;
|
|
1295
|
+
return ((e = window.ethereum) == null ? void 0 : e.isCoinbaseWallet) || !!((o = (r = window.ethereum) == null ? void 0 : r.providers) != null && o.find((s) => s == null ? void 0 : s.isCoinbaseWallet));
|
|
1296
|
+
}
|
|
1297
|
+
isCoinbaseWalletBrowser() {
|
|
1298
|
+
var e;
|
|
1299
|
+
return !!((e = window.ethereum) != null && e.isCoinbaseBrowser);
|
|
1300
|
+
}
|
|
1301
|
+
getCoinbaseProvider() {
|
|
1302
|
+
var e, r;
|
|
1303
|
+
return ((r = (e = window.ethereum) == null ? void 0 : e.providers) == null ? void 0 : r.find((o) => o == null ? void 0 : o.isCoinbaseWallet)) || window.ethereum;
|
|
1304
|
+
}
|
|
1305
|
+
connectToCoinbaseWallet() {
|
|
1306
|
+
if (this.isMobile() && !this.isCoinbaseWalletBrowser()) {
|
|
1307
|
+
let r = `https://go.cb-w.com/dapp?cb_url=${encodeURIComponent(window.location.href)}`;
|
|
1308
|
+
window.location.href = r;
|
|
1309
|
+
}
|
|
1310
|
+
return this.getCoinbaseProvider().request({ method: "eth_requestAccounts" });
|
|
1311
|
+
}
|
|
1312
|
+
isMobile() {
|
|
1313
|
+
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Silk|Opera Mini/i.test(navigator.userAgent);
|
|
1314
|
+
}
|
|
1315
|
+
getUserEnv() {
|
|
1316
|
+
return { env: { isMetaMaskInstalled: this.isMetaMaskInstalled(), isCoinbaseWalletInstalled: this.isCoinbaseWalletInstalled() } };
|
|
1317
|
+
}
|
|
1318
|
+
connectToThirdPartyWallet(e) {
|
|
1319
|
+
switch (e) {
|
|
1320
|
+
case u.MetaMask:
|
|
1321
|
+
return this.connectToMetaMask();
|
|
1322
|
+
case u.CoinbaseWallet:
|
|
1323
|
+
return this.connectToCoinbaseWallet();
|
|
1324
|
+
default:
|
|
1325
|
+
throw new Error(`Invalid provider: ${e}. Must be one of "metamask" or "coinbase_wallet".`);
|
|
1326
|
+
}
|
|
1327
|
+
}
|
|
1328
|
+
isWalletEnabled(e) {
|
|
1329
|
+
let r = d2("mc_is_wallet_enabled", [{ wallet: e }]);
|
|
1330
|
+
return this.request(r);
|
|
1331
|
+
}
|
|
1332
|
+
handleWalletSelected(e) {
|
|
1333
|
+
return m(this, null, function* () {
|
|
1334
|
+
try {
|
|
1335
|
+
let r = yield this.connectToThirdPartyWallet(e.wallet);
|
|
1336
|
+
yield M(this.localForageKey, e.wallet), this.createIntermediaryEvent(v.WalletConnected, e.payloadId)(r);
|
|
1337
|
+
} catch (r) {
|
|
1338
|
+
console.error(r), this.createIntermediaryEvent(v.WalletRejected, e.payloadId)();
|
|
1339
|
+
}
|
|
1340
|
+
});
|
|
1341
|
+
}
|
|
1342
|
+
autoConnectIfWalletBrowser(e) {
|
|
1343
|
+
return m(this, null, function* () {
|
|
1344
|
+
let r;
|
|
1345
|
+
e === u.MetaMask && (r = yield this.getMetaMaskProvider().request({ method: "eth_requestAccounts" })), e === u.CoinbaseWallet && (r = yield this.getCoinbaseProvider().request({ method: "eth_requestAccounts" })), yield M(this.localForageKey, e);
|
|
1346
|
+
let o = d2(E.AutoConnect, [{ wallet: e, address: r }]);
|
|
1347
|
+
return this.request(o);
|
|
1348
|
+
});
|
|
1349
|
+
}
|
|
1350
|
+
};
|
|
1351
|
+
({ createBoundEmitterMethod: Pe, createChainingEmitterMethod: Q } = ge());
|
|
1352
|
+
Me = class extends P {
|
|
1353
|
+
constructor() {
|
|
1354
|
+
super(...arguments);
|
|
1355
|
+
this.isMagic = true;
|
|
1356
|
+
this.on = Q("on", this);
|
|
1357
|
+
this.once = Q("once", this);
|
|
1358
|
+
this.addListener = Q("addListener", this);
|
|
1359
|
+
this.off = Q("off", this);
|
|
1360
|
+
this.removeListener = Q("removeListener", this);
|
|
1361
|
+
this.removeAllListeners = Q("removeAllListeners", this);
|
|
1362
|
+
this.emit = Pe("emit");
|
|
1363
|
+
this.eventNames = Pe("eventNames");
|
|
1364
|
+
this.listeners = Pe("listeners");
|
|
1365
|
+
this.listenerCount = Pe("listenerCount");
|
|
1366
|
+
}
|
|
1367
|
+
sendAsync(e, r) {
|
|
1368
|
+
if (!r)
|
|
1369
|
+
throw gt({ procedure: "Magic.rpcProvider.sendAsync", argument: 1, expected: "function", received: r === null ? "null" : typeof r });
|
|
1370
|
+
if (Array.isArray(e))
|
|
1371
|
+
this.overlay.post(d.MAGIC_HANDLE_REQUEST, e.map((o) => {
|
|
1372
|
+
let s = G(o);
|
|
1373
|
+
return this.prefixPayloadMethodForTestMode(s), s;
|
|
1374
|
+
})).then((o) => {
|
|
1375
|
+
r(null, o.map((s) => B(j({}, s.payload), { error: s.hasError ? new _2(s.payload.error) : null })));
|
|
1376
|
+
});
|
|
1377
|
+
else {
|
|
1378
|
+
let o = G(e);
|
|
1379
|
+
this.prefixPayloadMethodForTestMode(o), this.overlay.post(d.MAGIC_HANDLE_REQUEST, o).then((s) => {
|
|
1380
|
+
r(s.hasError ? new _2(s.payload.error) : null, s.payload);
|
|
1381
|
+
});
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
send(e, r) {
|
|
1385
|
+
if (typeof e == "string") {
|
|
1386
|
+
let s = d2(e, Array.isArray(r) ? r : []);
|
|
1387
|
+
return this.request(s);
|
|
1388
|
+
}
|
|
1389
|
+
if (Array.isArray(e) || !!r) {
|
|
1390
|
+
this.sendAsync(e, r);
|
|
1391
|
+
return;
|
|
1392
|
+
}
|
|
1393
|
+
let o = Rt();
|
|
1394
|
+
return o.log(), new F(e).applyError({ code: -32603, message: o.rawMessage }).payload;
|
|
1395
|
+
}
|
|
1396
|
+
enable() {
|
|
1397
|
+
let e = d2(E.Login);
|
|
1398
|
+
return this.request(e);
|
|
1399
|
+
}
|
|
1400
|
+
request(e) {
|
|
1401
|
+
return this.prefixPayloadMethodForTestMode(e), super.request(e);
|
|
1402
|
+
}
|
|
1403
|
+
prefixPayloadMethodForTestMode(e) {
|
|
1404
|
+
let r = "testMode/eth/";
|
|
1405
|
+
this.sdk.testMode && (e.method = `${r}${e.method}`);
|
|
1406
|
+
}
|
|
1407
|
+
};
|
|
1408
|
+
Ut = ["request", "overlay", "sdk"];
|
|
1409
|
+
xe = class extends P {
|
|
1410
|
+
constructor() {
|
|
1411
|
+
super(void 0);
|
|
1412
|
+
this.__sdk_access_field_descriptors__ = /* @__PURE__ */ new Map();
|
|
1413
|
+
this.__is_initialized__ = false;
|
|
1414
|
+
this.utils = { createPromiEvent: k2, isPromiEvent: xt, encodeJSON: me, decodeJSON: lt, createJsonRpcRequestPayload: d2, standardizeJsonRpcRequestPayload: G, storage: ie };
|
|
1415
|
+
let e = [this, ...fr(this)];
|
|
1416
|
+
Ut.forEach((r) => {
|
|
1417
|
+
let o = e.map((c3) => Object.getOwnPropertyDescriptor(c3, r)), s = o.findIndex((c3) => !!c3), a2 = s > 0, i = o[s];
|
|
1418
|
+
i && (this.__sdk_access_field_descriptors__.set(r, { descriptor: i, isPrototypeField: a2 }), Object.defineProperty(this, r, { configurable: true, get: () => {
|
|
1419
|
+
throw Et(r);
|
|
1420
|
+
} }));
|
|
1421
|
+
});
|
|
1422
|
+
}
|
|
1423
|
+
init(e) {
|
|
1424
|
+
this.__is_initialized__ || (Ut.forEach((r) => {
|
|
1425
|
+
if (this.__sdk_access_field_descriptors__.has(r)) {
|
|
1426
|
+
let { descriptor: o, isPrototypeField: s } = this.__sdk_access_field_descriptors__.get(r);
|
|
1427
|
+
s ? delete this[r] : Object.defineProperty(this, r, o);
|
|
1428
|
+
}
|
|
1429
|
+
}), this.sdk = e, this.__is_initialized__ = true);
|
|
1430
|
+
}
|
|
1431
|
+
createDeprecationWarning(e) {
|
|
1432
|
+
let { method: r, removalVersion: o, useInstead: s } = e, a2 = s ? ` Use \`${s}\` instead.` : "", i = `\`${r}\` will be removed from this Extension in version \`${o}\`.${a2}`;
|
|
1433
|
+
return new se(this, "DEPRECATION_NOTICE", i);
|
|
1434
|
+
}
|
|
1435
|
+
createWarning(e, r) {
|
|
1436
|
+
return new se(this, e, r);
|
|
1437
|
+
}
|
|
1438
|
+
createError(e, r, o) {
|
|
1439
|
+
return new V(this, e, r, o);
|
|
1440
|
+
}
|
|
1441
|
+
};
|
|
1442
|
+
Ke = class extends xe {
|
|
1443
|
+
};
|
|
1444
|
+
q = class extends xe {
|
|
1445
|
+
};
|
|
1446
|
+
q.Internal = Ke, q.Anonymous = "anonymous extension";
|
|
1447
|
+
Ne = class extends P {
|
|
1448
|
+
purchase(t) {
|
|
1449
|
+
let e = d2(E.NFTPurchase, [t]);
|
|
1450
|
+
return this.request(e);
|
|
1451
|
+
}
|
|
1452
|
+
checkout(t) {
|
|
1453
|
+
let e = d2(E.NFTCheckout, [t]);
|
|
1454
|
+
return this.request(e);
|
|
1455
|
+
}
|
|
1456
|
+
transfer(t) {
|
|
1457
|
+
let e = d2(E.NFTTransfer, [t]);
|
|
1458
|
+
return this.request(e);
|
|
1459
|
+
}
|
|
1460
|
+
};
|
|
1461
|
+
ce = class {
|
|
1462
|
+
constructor(t, e) {
|
|
1463
|
+
this.apiKey = t;
|
|
1464
|
+
var a2;
|
|
1465
|
+
if (!t)
|
|
1466
|
+
throw ht();
|
|
1467
|
+
h2.platform === "react-native" && (e == null ? void 0 : e.endpoint) && vt().log();
|
|
1468
|
+
let { defaultEndpoint: r, version: o } = h2;
|
|
1469
|
+
this.testMode = !!(e != null && e.testMode), this.useStorageCache = !!(e != null && e.useStorageCache), this.endpoint = Je((a2 = e == null ? void 0 : e.endpoint) != null ? a2 : r).origin, this.auth = new ve(this), this.user = new be(this), this.wallet = new we(this), this.nft = new Ne(this), this.rpcProvider = new Me(this);
|
|
1470
|
+
let s = yr.call(this, e);
|
|
1471
|
+
this.parameters = me(B(j({ API_KEY: this.apiKey, DOMAIN_ORIGIN: window.location ? window.location.origin : "", ETH_NETWORK: e == null ? void 0 : e.network, host: Je(this.endpoint).host, sdk: pt[h2.sdkName], version: o, ext: re(s) ? void 0 : s, locale: (e == null ? void 0 : e.locale) || "en_US" }, h2.bundleId ? { bundleId: h2.bundleId } : {}), { meta: e == null ? void 0 : e.meta })), this.networkHash = Er(this.apiKey, e == null ? void 0 : e.network, re(s) ? void 0 : s), e != null && e.deferPreload || this.preload();
|
|
1472
|
+
}
|
|
1473
|
+
get overlay() {
|
|
1474
|
+
if (!ce.__overlays__.has(this.parameters)) {
|
|
1475
|
+
let t = new h2.ViewController(this.endpoint, this.parameters, this.networkHash);
|
|
1476
|
+
t.init(), ce.__overlays__.set(this.parameters, t);
|
|
1477
|
+
}
|
|
1478
|
+
return ce.__overlays__.get(this.parameters);
|
|
1479
|
+
}
|
|
1480
|
+
preload() {
|
|
1481
|
+
return m(this, null, function* () {
|
|
1482
|
+
yield this.overlay.checkIsReadyForRequest;
|
|
1483
|
+
});
|
|
1484
|
+
}
|
|
1485
|
+
};
|
|
1486
|
+
$e = ce;
|
|
1487
|
+
$e.__overlays__ = /* @__PURE__ */ new Map();
|
|
1488
|
+
Be = class {
|
|
1489
|
+
constructor(t, e, r) {
|
|
1490
|
+
this.endpoint = t;
|
|
1491
|
+
this.parameters = e;
|
|
1492
|
+
this.networkHash = r;
|
|
1493
|
+
this.messageHandlers = /* @__PURE__ */ new Set();
|
|
1494
|
+
this.isConnectedToInternet = true;
|
|
1495
|
+
this.checkIsReadyForRequest = this.waitForReady(), this.isReadyForRequest = false, this.listen();
|
|
1496
|
+
}
|
|
1497
|
+
post(t, e) {
|
|
1498
|
+
return m(this, null, function* () {
|
|
1499
|
+
return _e((r, o) => m(this, null, function* () {
|
|
1500
|
+
if (!this.isConnectedToInternet) {
|
|
1501
|
+
let l = mt();
|
|
1502
|
+
o(l);
|
|
1503
|
+
}
|
|
1504
|
+
this.isReadyForRequest || (yield this.waitForReady());
|
|
1505
|
+
let s = [], a2 = Array.isArray(e) ? e.map((l) => l.id) : [], i = yield Tr(`${t}-${this.parameters}`, e, this.networkHash);
|
|
1506
|
+
yield this._post(i);
|
|
1507
|
+
let c3 = (l) => (p2) => {
|
|
1508
|
+
var He;
|
|
1509
|
+
let { id: x2, response: v2 } = vr(e, p2);
|
|
1510
|
+
if (Ir(p2), ((He = v2 == null ? void 0 : v2.payload.error) == null ? void 0 : He.message) === "User denied account access.")
|
|
1511
|
+
Z();
|
|
1512
|
+
else if (p2.data.deviceShare) {
|
|
1513
|
+
let { deviceShare: Jt } = p2.data;
|
|
1514
|
+
qt(Jt, this.networkHash);
|
|
1515
|
+
}
|
|
1516
|
+
x2 && v2 && Array.isArray(e) && a2.includes(x2) ? (s.push(v2), s.length === e.length && (l(), r(s))) : x2 && v2 && !Array.isArray(e) && x2 === e.id && (l(), r(v2));
|
|
1517
|
+
}, u2 = this.on(f.MAGIC_HANDLE_RESPONSE, c3(() => u2()));
|
|
1518
|
+
}));
|
|
1519
|
+
});
|
|
1520
|
+
}
|
|
1521
|
+
on(t, e) {
|
|
1522
|
+
let r = e.bind(window), o = (s) => {
|
|
1523
|
+
s.data.msgType === `${t}-${this.parameters}` && r(s);
|
|
1524
|
+
};
|
|
1525
|
+
return this.messageHandlers.add(o), () => this.messageHandlers.delete(o);
|
|
1526
|
+
}
|
|
1527
|
+
waitForReady() {
|
|
1528
|
+
return new Promise((t) => {
|
|
1529
|
+
let e = this.on(f.MAGIC_OVERLAY_READY, () => {
|
|
1530
|
+
this.isReadyForRequest = true, t(), e();
|
|
1531
|
+
});
|
|
1532
|
+
});
|
|
1533
|
+
}
|
|
1534
|
+
listen() {
|
|
1535
|
+
this.on(f.MAGIC_HIDE_OVERLAY, () => {
|
|
1536
|
+
this.hideOverlay();
|
|
1537
|
+
}), this.on(f.MAGIC_SHOW_OVERLAY, () => {
|
|
1538
|
+
this.showOverlay();
|
|
1539
|
+
}), this.on(f.MAGIC_SEND_PRODUCT_ANNOUNCEMENT, (t) => {
|
|
1540
|
+
t.data.response.result.product_announcement && new W(p.ProductAnnouncement, t.data.response.result.product_announcement).log();
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1543
|
+
};
|
|
1544
|
+
}
|
|
1545
|
+
});
|
|
1546
|
+
|
|
1547
|
+
// ../../node_modules/.pnpm/@magic-sdk+commons@24.0.2_@magic-sdk+provider@28.0.2_@magic-sdk+types@24.0.1/node_modules/@magic-sdk/commons/dist/es/index.mjs
|
|
1548
|
+
var init_es3 = __esm({
|
|
1549
|
+
"../../node_modules/.pnpm/@magic-sdk+commons@24.0.2_@magic-sdk+provider@28.0.2_@magic-sdk+types@24.0.1/node_modules/@magic-sdk/commons/dist/es/index.mjs"() {
|
|
1550
|
+
"use strict";
|
|
1551
|
+
init_es2();
|
|
1552
|
+
init_es();
|
|
1553
|
+
}
|
|
1554
|
+
});
|
|
1555
|
+
|
|
1556
|
+
// ../../node_modules/.pnpm/magic-sdk@28.0.3/node_modules/magic-sdk/dist/es/index.mjs
|
|
1557
|
+
var es_exports = {};
|
|
1558
|
+
__export(es_exports, {
|
|
1559
|
+
DeepLinkPage: () => g,
|
|
1560
|
+
DeviceVerificationEventEmit: () => R,
|
|
1561
|
+
DeviceVerificationEventOnReceived: () => T,
|
|
1562
|
+
EthChainType: () => k,
|
|
1563
|
+
Events: () => v,
|
|
1564
|
+
Extension: () => q,
|
|
1565
|
+
ExtensionError: () => V,
|
|
1566
|
+
ExtensionWarning: () => se,
|
|
1567
|
+
LoginWithEmailOTPEventEmit: () => I,
|
|
1568
|
+
LoginWithEmailOTPEventOnReceived: () => A,
|
|
1569
|
+
LoginWithMagicLinkEventEmit: () => x,
|
|
1570
|
+
LoginWithMagicLinkEventOnReceived: () => N,
|
|
1571
|
+
Magic: () => bt,
|
|
1572
|
+
MagicIncomingWindowMessage: () => f,
|
|
1573
|
+
MagicOutgoingWindowMessage: () => d,
|
|
1574
|
+
MagicPayloadMethod: () => E,
|
|
1575
|
+
RPCError: () => _2,
|
|
1576
|
+
RPCErrorCode: () => _,
|
|
1577
|
+
RecencyCheckEventEmit: () => h,
|
|
1578
|
+
RecencyCheckEventOnReceived: () => O,
|
|
1579
|
+
RecoveryMethodType: () => y,
|
|
1580
|
+
SDKError: () => A2,
|
|
1581
|
+
SDKErrorCode: () => c,
|
|
1582
|
+
SDKWarning: () => W,
|
|
1583
|
+
SDKWarningCode: () => p,
|
|
1584
|
+
UpdateEmailEventEmit: () => U,
|
|
1585
|
+
UpdateEmailEventOnReceived: () => L,
|
|
1586
|
+
Wallets: () => u,
|
|
1587
|
+
isPromiEvent: () => xt
|
|
1588
|
+
});
|
|
1589
|
+
function ft2(b2) {
|
|
1590
|
+
for (let [A3, R2] of Object.entries(at2))
|
|
1591
|
+
b2.style[A3] = R2;
|
|
1592
|
+
}
|
|
1593
|
+
function ut2(b2) {
|
|
1594
|
+
let A3 = [].slice.call(document.querySelectorAll(".magic-iframe"));
|
|
1595
|
+
return Boolean(A3.find((R2) => R2.src.includes(b2)));
|
|
1596
|
+
}
|
|
1597
|
+
var Zr, Je2, qr2, kr, et2, rt2, ve2, $e2, tt2, Ze2, se2, ke2, rr2, ge2, Te2, at2, pe2, bt;
|
|
1598
|
+
var init_es4 = __esm({
|
|
1599
|
+
"../../node_modules/.pnpm/magic-sdk@28.0.3/node_modules/magic-sdk/dist/es/index.mjs"() {
|
|
1600
|
+
"use strict";
|
|
1601
|
+
init_es2();
|
|
1602
|
+
init_es2();
|
|
1603
|
+
init_es3();
|
|
1604
|
+
Zr = Object.create;
|
|
1605
|
+
Je2 = Object.defineProperty;
|
|
1606
|
+
qr2 = Object.getOwnPropertyDescriptor;
|
|
1607
|
+
kr = Object.getOwnPropertyNames;
|
|
1608
|
+
et2 = Object.getPrototypeOf;
|
|
1609
|
+
rt2 = Object.prototype.hasOwnProperty;
|
|
1610
|
+
ve2 = ((b2) => typeof require != "undefined" ? require : typeof Proxy != "undefined" ? new Proxy(b2, { get: (A3, R2) => (typeof require != "undefined" ? require : A3)[R2] }) : b2)(function(b2) {
|
|
1611
|
+
if (typeof require != "undefined")
|
|
1612
|
+
return require.apply(this, arguments);
|
|
1613
|
+
throw new Error('Dynamic require of "' + b2 + '" is not supported');
|
|
1614
|
+
});
|
|
1615
|
+
$e2 = (b2, A3) => () => (A3 || b2((A3 = { exports: {} }).exports, A3), A3.exports);
|
|
1616
|
+
tt2 = (b2, A3, R2, L3) => {
|
|
1617
|
+
if (A3 && typeof A3 == "object" || typeof A3 == "function")
|
|
1618
|
+
for (let D2 of kr(A3))
|
|
1619
|
+
!rt2.call(b2, D2) && D2 !== R2 && Je2(b2, D2, { get: () => A3[D2], enumerable: !(L3 = qr2(A3, D2)) || L3.enumerable });
|
|
1620
|
+
return b2;
|
|
1621
|
+
};
|
|
1622
|
+
Ze2 = (b2, A3, R2) => (R2 = b2 != null ? Zr(et2(b2)) : {}, tt2(A3 || !b2 || !b2.__esModule ? Je2(R2, "default", { value: b2, enumerable: true }) : R2, b2));
|
|
1623
|
+
se2 = (b2, A3, R2) => new Promise((L3, D2) => {
|
|
1624
|
+
var X = (I2) => {
|
|
1625
|
+
try {
|
|
1626
|
+
Y(R2.next(I2));
|
|
1627
|
+
} catch (M2) {
|
|
1628
|
+
D2(M2);
|
|
1629
|
+
}
|
|
1630
|
+
}, P2 = (I2) => {
|
|
1631
|
+
try {
|
|
1632
|
+
Y(R2.throw(I2));
|
|
1633
|
+
} catch (M2) {
|
|
1634
|
+
D2(M2);
|
|
1635
|
+
}
|
|
1636
|
+
}, Y = (I2) => I2.done ? L3(I2.value) : Promise.resolve(I2.value).then(X, P2);
|
|
1637
|
+
Y((R2 = R2.apply(b2, A3)).next());
|
|
1638
|
+
});
|
|
1639
|
+
ke2 = $e2((qe2, Ne2) => {
|
|
1640
|
+
(function(b2) {
|
|
1641
|
+
if (typeof qe2 == "object" && typeof Ne2 < "u")
|
|
1642
|
+
Ne2.exports = b2();
|
|
1643
|
+
else if (typeof define == "function" && define.amd)
|
|
1644
|
+
define([], b2);
|
|
1645
|
+
else {
|
|
1646
|
+
var A3;
|
|
1647
|
+
typeof window < "u" ? A3 = window : typeof global < "u" ? A3 = global : typeof self < "u" ? A3 = self : A3 = this, A3.localforage = b2();
|
|
1648
|
+
}
|
|
1649
|
+
})(function() {
|
|
1650
|
+
var b2, A3, R2;
|
|
1651
|
+
return function L3(D2, X, P2) {
|
|
1652
|
+
function Y(H2, $) {
|
|
1653
|
+
if (!X[H2]) {
|
|
1654
|
+
if (!D2[H2]) {
|
|
1655
|
+
var m2 = typeof ve2 == "function" && ve2;
|
|
1656
|
+
if (!$ && m2)
|
|
1657
|
+
return m2(H2, true);
|
|
1658
|
+
if (I2)
|
|
1659
|
+
return I2(H2, true);
|
|
1660
|
+
var _3 = new Error("Cannot find module '" + H2 + "'");
|
|
1661
|
+
throw _3.code = "MODULE_NOT_FOUND", _3;
|
|
1662
|
+
}
|
|
1663
|
+
var B2 = X[H2] = { exports: {} };
|
|
1664
|
+
D2[H2][0].call(B2.exports, function(z) {
|
|
1665
|
+
var Z2 = D2[H2][1][z];
|
|
1666
|
+
return Y(Z2 || z);
|
|
1667
|
+
}, B2, B2.exports, L3, D2, X, P2);
|
|
1668
|
+
}
|
|
1669
|
+
return X[H2].exports;
|
|
1670
|
+
}
|
|
1671
|
+
for (var I2 = typeof ve2 == "function" && ve2, M2 = 0; M2 < P2.length; M2++)
|
|
1672
|
+
Y(P2[M2]);
|
|
1673
|
+
return Y;
|
|
1674
|
+
}({ 1: [function(L3, D2, X) {
|
|
1675
|
+
(function(P2) {
|
|
1676
|
+
"use strict";
|
|
1677
|
+
var Y = P2.MutationObserver || P2.WebKitMutationObserver, I2;
|
|
1678
|
+
if (Y) {
|
|
1679
|
+
var M2 = 0, H2 = new Y(z), $ = P2.document.createTextNode("");
|
|
1680
|
+
H2.observe($, { characterData: true }), I2 = function() {
|
|
1681
|
+
$.data = M2 = ++M2 % 2;
|
|
1682
|
+
};
|
|
1683
|
+
} else if (!P2.setImmediate && typeof P2.MessageChannel < "u") {
|
|
1684
|
+
var m2 = new P2.MessageChannel();
|
|
1685
|
+
m2.port1.onmessage = z, I2 = function() {
|
|
1686
|
+
m2.port2.postMessage(0);
|
|
1687
|
+
};
|
|
1688
|
+
} else
|
|
1689
|
+
"document" in P2 && "onreadystatechange" in P2.document.createElement("script") ? I2 = function() {
|
|
1690
|
+
var F2 = P2.document.createElement("script");
|
|
1691
|
+
F2.onreadystatechange = function() {
|
|
1692
|
+
z(), F2.onreadystatechange = null, F2.parentNode.removeChild(F2), F2 = null;
|
|
1693
|
+
}, P2.document.documentElement.appendChild(F2);
|
|
1694
|
+
} : I2 = function() {
|
|
1695
|
+
setTimeout(z, 0);
|
|
1696
|
+
};
|
|
1697
|
+
var _3, B2 = [];
|
|
1698
|
+
function z() {
|
|
1699
|
+
_3 = true;
|
|
1700
|
+
for (var F2, k3, U3 = B2.length; U3; ) {
|
|
1701
|
+
for (k3 = B2, B2 = [], F2 = -1; ++F2 < U3; )
|
|
1702
|
+
k3[F2]();
|
|
1703
|
+
U3 = B2.length;
|
|
1704
|
+
}
|
|
1705
|
+
_3 = false;
|
|
1706
|
+
}
|
|
1707
|
+
D2.exports = Z2;
|
|
1708
|
+
function Z2(F2) {
|
|
1709
|
+
B2.push(F2) === 1 && !_3 && I2();
|
|
1710
|
+
}
|
|
1711
|
+
}).call(this, typeof global < "u" ? global : typeof self < "u" ? self : typeof window < "u" ? window : {});
|
|
1712
|
+
}, {}], 2: [function(L3, D2, X) {
|
|
1713
|
+
"use strict";
|
|
1714
|
+
var P2 = L3(1);
|
|
1715
|
+
function Y() {
|
|
1716
|
+
}
|
|
1717
|
+
var I2 = {}, M2 = ["REJECTED"], H2 = ["FULFILLED"], $ = ["PENDING"];
|
|
1718
|
+
D2.exports = m2;
|
|
1719
|
+
function m2(h3) {
|
|
1720
|
+
if (typeof h3 != "function")
|
|
1721
|
+
throw new TypeError("resolver must be a function");
|
|
1722
|
+
this.state = $, this.queue = [], this.outcome = void 0, h3 !== Y && Z2(this, h3);
|
|
1723
|
+
}
|
|
1724
|
+
m2.prototype.catch = function(h3) {
|
|
1725
|
+
return this.then(null, h3);
|
|
1726
|
+
}, m2.prototype.then = function(h3, N3) {
|
|
1727
|
+
if (typeof h3 != "function" && this.state === H2 || typeof N3 != "function" && this.state === M2)
|
|
1728
|
+
return this;
|
|
1729
|
+
var E3 = new this.constructor(Y);
|
|
1730
|
+
if (this.state !== $) {
|
|
1731
|
+
var O3 = this.state === H2 ? h3 : N3;
|
|
1732
|
+
B2(E3, O3, this.outcome);
|
|
1733
|
+
} else
|
|
1734
|
+
this.queue.push(new _3(E3, h3, N3));
|
|
1735
|
+
return E3;
|
|
1736
|
+
};
|
|
1737
|
+
function _3(h3, N3, E3) {
|
|
1738
|
+
this.promise = h3, typeof N3 == "function" && (this.onFulfilled = N3, this.callFulfilled = this.otherCallFulfilled), typeof E3 == "function" && (this.onRejected = E3, this.callRejected = this.otherCallRejected);
|
|
1739
|
+
}
|
|
1740
|
+
_3.prototype.callFulfilled = function(h3) {
|
|
1741
|
+
I2.resolve(this.promise, h3);
|
|
1742
|
+
}, _3.prototype.otherCallFulfilled = function(h3) {
|
|
1743
|
+
B2(this.promise, this.onFulfilled, h3);
|
|
1744
|
+
}, _3.prototype.callRejected = function(h3) {
|
|
1745
|
+
I2.reject(this.promise, h3);
|
|
1746
|
+
}, _3.prototype.otherCallRejected = function(h3) {
|
|
1747
|
+
B2(this.promise, this.onRejected, h3);
|
|
1748
|
+
};
|
|
1749
|
+
function B2(h3, N3, E3) {
|
|
1750
|
+
P2(function() {
|
|
1751
|
+
var O3;
|
|
1752
|
+
try {
|
|
1753
|
+
O3 = N3(E3);
|
|
1754
|
+
} catch (V2) {
|
|
1755
|
+
return I2.reject(h3, V2);
|
|
1756
|
+
}
|
|
1757
|
+
O3 === h3 ? I2.reject(h3, new TypeError("Cannot resolve promise with itself")) : I2.resolve(h3, O3);
|
|
1758
|
+
});
|
|
1759
|
+
}
|
|
1760
|
+
I2.resolve = function(h3, N3) {
|
|
1761
|
+
var E3 = F2(z, N3);
|
|
1762
|
+
if (E3.status === "error")
|
|
1763
|
+
return I2.reject(h3, E3.value);
|
|
1764
|
+
var O3 = E3.value;
|
|
1765
|
+
if (O3)
|
|
1766
|
+
Z2(h3, O3);
|
|
1767
|
+
else {
|
|
1768
|
+
h3.state = H2, h3.outcome = N3;
|
|
1769
|
+
for (var V2 = -1, j2 = h3.queue.length; ++V2 < j2; )
|
|
1770
|
+
h3.queue[V2].callFulfilled(N3);
|
|
1771
|
+
}
|
|
1772
|
+
return h3;
|
|
1773
|
+
}, I2.reject = function(h3, N3) {
|
|
1774
|
+
h3.state = M2, h3.outcome = N3;
|
|
1775
|
+
for (var E3 = -1, O3 = h3.queue.length; ++E3 < O3; )
|
|
1776
|
+
h3.queue[E3].callRejected(N3);
|
|
1777
|
+
return h3;
|
|
1778
|
+
};
|
|
1779
|
+
function z(h3) {
|
|
1780
|
+
var N3 = h3 && h3.then;
|
|
1781
|
+
if (h3 && (typeof h3 == "object" || typeof h3 == "function") && typeof N3 == "function")
|
|
1782
|
+
return function() {
|
|
1783
|
+
N3.apply(h3, arguments);
|
|
1784
|
+
};
|
|
1785
|
+
}
|
|
1786
|
+
function Z2(h3, N3) {
|
|
1787
|
+
var E3 = false;
|
|
1788
|
+
function O3(J2) {
|
|
1789
|
+
E3 || (E3 = true, I2.reject(h3, J2));
|
|
1790
|
+
}
|
|
1791
|
+
function V2(J2) {
|
|
1792
|
+
E3 || (E3 = true, I2.resolve(h3, J2));
|
|
1793
|
+
}
|
|
1794
|
+
function j2() {
|
|
1795
|
+
N3(V2, O3);
|
|
1796
|
+
}
|
|
1797
|
+
var Q2 = F2(j2);
|
|
1798
|
+
Q2.status === "error" && O3(Q2.value);
|
|
1799
|
+
}
|
|
1800
|
+
function F2(h3, N3) {
|
|
1801
|
+
var E3 = {};
|
|
1802
|
+
try {
|
|
1803
|
+
E3.value = h3(N3), E3.status = "success";
|
|
1804
|
+
} catch (O3) {
|
|
1805
|
+
E3.status = "error", E3.value = O3;
|
|
1806
|
+
}
|
|
1807
|
+
return E3;
|
|
1808
|
+
}
|
|
1809
|
+
m2.resolve = k3;
|
|
1810
|
+
function k3(h3) {
|
|
1811
|
+
return h3 instanceof this ? h3 : I2.resolve(new this(Y), h3);
|
|
1812
|
+
}
|
|
1813
|
+
m2.reject = U3;
|
|
1814
|
+
function U3(h3) {
|
|
1815
|
+
var N3 = new this(Y);
|
|
1816
|
+
return I2.reject(N3, h3);
|
|
1817
|
+
}
|
|
1818
|
+
m2.all = ae2;
|
|
1819
|
+
function ae2(h3) {
|
|
1820
|
+
var N3 = this;
|
|
1821
|
+
if (Object.prototype.toString.call(h3) !== "[object Array]")
|
|
1822
|
+
return this.reject(new TypeError("must be an array"));
|
|
1823
|
+
var E3 = h3.length, O3 = false;
|
|
1824
|
+
if (!E3)
|
|
1825
|
+
return this.resolve([]);
|
|
1826
|
+
for (var V2 = new Array(E3), j2 = 0, Q2 = -1, J2 = new this(Y); ++Q2 < E3; )
|
|
1827
|
+
ee2(h3[Q2], Q2);
|
|
1828
|
+
return J2;
|
|
1829
|
+
function ee2(oe, a2) {
|
|
1830
|
+
N3.resolve(oe).then(s, function(v2) {
|
|
1831
|
+
O3 || (O3 = true, I2.reject(J2, v2));
|
|
1832
|
+
});
|
|
1833
|
+
function s(v2) {
|
|
1834
|
+
V2[a2] = v2, ++j2 === E3 && !O3 && (O3 = true, I2.resolve(J2, V2));
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
m2.race = re2;
|
|
1839
|
+
function re2(h3) {
|
|
1840
|
+
var N3 = this;
|
|
1841
|
+
if (Object.prototype.toString.call(h3) !== "[object Array]")
|
|
1842
|
+
return this.reject(new TypeError("must be an array"));
|
|
1843
|
+
var E3 = h3.length, O3 = false;
|
|
1844
|
+
if (!E3)
|
|
1845
|
+
return this.resolve([]);
|
|
1846
|
+
for (var V2 = -1, j2 = new this(Y); ++V2 < E3; )
|
|
1847
|
+
Q2(h3[V2]);
|
|
1848
|
+
return j2;
|
|
1849
|
+
function Q2(J2) {
|
|
1850
|
+
N3.resolve(J2).then(function(ee2) {
|
|
1851
|
+
O3 || (O3 = true, I2.resolve(j2, ee2));
|
|
1852
|
+
}, function(ee2) {
|
|
1853
|
+
O3 || (O3 = true, I2.reject(j2, ee2));
|
|
1854
|
+
});
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
}, { 1: 1 }], 3: [function(L3, D2, X) {
|
|
1858
|
+
(function(P2) {
|
|
1859
|
+
"use strict";
|
|
1860
|
+
typeof P2.Promise != "function" && (P2.Promise = L3(2));
|
|
1861
|
+
}).call(this, typeof global < "u" ? global : typeof self < "u" ? self : typeof window < "u" ? window : {});
|
|
1862
|
+
}, { 2: 2 }], 4: [function(L3, D2, X) {
|
|
1863
|
+
"use strict";
|
|
1864
|
+
var P2 = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
|
|
1865
|
+
return typeof e;
|
|
1866
|
+
} : function(e) {
|
|
1867
|
+
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
|
|
1868
|
+
};
|
|
1869
|
+
function Y(e, t) {
|
|
1870
|
+
if (!(e instanceof t))
|
|
1871
|
+
throw new TypeError("Cannot call a class as a function");
|
|
1872
|
+
}
|
|
1873
|
+
function I2() {
|
|
1874
|
+
try {
|
|
1875
|
+
if (typeof indexedDB < "u")
|
|
1876
|
+
return indexedDB;
|
|
1877
|
+
if (typeof webkitIndexedDB < "u")
|
|
1878
|
+
return webkitIndexedDB;
|
|
1879
|
+
if (typeof mozIndexedDB < "u")
|
|
1880
|
+
return mozIndexedDB;
|
|
1881
|
+
if (typeof OIndexedDB < "u")
|
|
1882
|
+
return OIndexedDB;
|
|
1883
|
+
if (typeof msIndexedDB < "u")
|
|
1884
|
+
return msIndexedDB;
|
|
1885
|
+
} catch {
|
|
1886
|
+
return;
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
var M2 = I2();
|
|
1890
|
+
function H2() {
|
|
1891
|
+
try {
|
|
1892
|
+
if (!M2 || !M2.open)
|
|
1893
|
+
return false;
|
|
1894
|
+
var e = typeof openDatabase < "u" && /(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent) && !/BlackBerry/.test(navigator.platform), t = typeof fetch == "function" && fetch.toString().indexOf("[native code") !== -1;
|
|
1895
|
+
return (!e || t) && typeof indexedDB < "u" && typeof IDBKeyRange < "u";
|
|
1896
|
+
} catch {
|
|
1897
|
+
return false;
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
function $(e, t) {
|
|
1901
|
+
e = e || [], t = t || {};
|
|
1902
|
+
try {
|
|
1903
|
+
return new Blob(e, t);
|
|
1904
|
+
} catch (n) {
|
|
1905
|
+
if (n.name !== "TypeError")
|
|
1906
|
+
throw n;
|
|
1907
|
+
for (var r = typeof BlobBuilder < "u" ? BlobBuilder : typeof MSBlobBuilder < "u" ? MSBlobBuilder : typeof MozBlobBuilder < "u" ? MozBlobBuilder : WebKitBlobBuilder, o = new r(), i = 0; i < e.length; i += 1)
|
|
1908
|
+
o.append(e[i]);
|
|
1909
|
+
return o.getBlob(t.type);
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
typeof Promise > "u" && L3(3);
|
|
1913
|
+
var m2 = Promise;
|
|
1914
|
+
function _3(e, t) {
|
|
1915
|
+
t && e.then(function(r) {
|
|
1916
|
+
t(null, r);
|
|
1917
|
+
}, function(r) {
|
|
1918
|
+
t(r);
|
|
1919
|
+
});
|
|
1920
|
+
}
|
|
1921
|
+
function B2(e, t, r) {
|
|
1922
|
+
typeof t == "function" && e.then(t), typeof r == "function" && e.catch(r);
|
|
1923
|
+
}
|
|
1924
|
+
function z(e) {
|
|
1925
|
+
return typeof e != "string" && (console.warn(e + " used as a key, but it is not a string."), e = String(e)), e;
|
|
1926
|
+
}
|
|
1927
|
+
function Z2() {
|
|
1928
|
+
if (arguments.length && typeof arguments[arguments.length - 1] == "function")
|
|
1929
|
+
return arguments[arguments.length - 1];
|
|
1930
|
+
}
|
|
1931
|
+
var F2 = "local-forage-detect-blob-support", k3 = void 0, U3 = {}, ae2 = Object.prototype.toString, re2 = "readonly", h3 = "readwrite";
|
|
1932
|
+
function N3(e) {
|
|
1933
|
+
for (var t = e.length, r = new ArrayBuffer(t), o = new Uint8Array(r), i = 0; i < t; i++)
|
|
1934
|
+
o[i] = e.charCodeAt(i);
|
|
1935
|
+
return r;
|
|
1936
|
+
}
|
|
1937
|
+
function E3(e) {
|
|
1938
|
+
return new m2(function(t) {
|
|
1939
|
+
var r = e.transaction(F2, h3), o = $([""]);
|
|
1940
|
+
r.objectStore(F2).put(o, "key"), r.onabort = function(i) {
|
|
1941
|
+
i.preventDefault(), i.stopPropagation(), t(false);
|
|
1942
|
+
}, r.oncomplete = function() {
|
|
1943
|
+
var i = navigator.userAgent.match(/Chrome\/(\d+)/), n = navigator.userAgent.match(/Edge\//);
|
|
1944
|
+
t(n || !i || parseInt(i[1], 10) >= 43);
|
|
1945
|
+
};
|
|
1946
|
+
}).catch(function() {
|
|
1947
|
+
return false;
|
|
1948
|
+
});
|
|
1949
|
+
}
|
|
1950
|
+
function O3(e) {
|
|
1951
|
+
return typeof k3 == "boolean" ? m2.resolve(k3) : E3(e).then(function(t) {
|
|
1952
|
+
return k3 = t, k3;
|
|
1953
|
+
});
|
|
1954
|
+
}
|
|
1955
|
+
function V2(e) {
|
|
1956
|
+
var t = U3[e.name], r = {};
|
|
1957
|
+
r.promise = new m2(function(o, i) {
|
|
1958
|
+
r.resolve = o, r.reject = i;
|
|
1959
|
+
}), t.deferredOperations.push(r), t.dbReady ? t.dbReady = t.dbReady.then(function() {
|
|
1960
|
+
return r.promise;
|
|
1961
|
+
}) : t.dbReady = r.promise;
|
|
1962
|
+
}
|
|
1963
|
+
function j2(e) {
|
|
1964
|
+
var t = U3[e.name], r = t.deferredOperations.pop();
|
|
1965
|
+
if (r)
|
|
1966
|
+
return r.resolve(), r.promise;
|
|
1967
|
+
}
|
|
1968
|
+
function Q2(e, t) {
|
|
1969
|
+
var r = U3[e.name], o = r.deferredOperations.pop();
|
|
1970
|
+
if (o)
|
|
1971
|
+
return o.reject(t), o.promise;
|
|
1972
|
+
}
|
|
1973
|
+
function J2(e, t) {
|
|
1974
|
+
return new m2(function(r, o) {
|
|
1975
|
+
if (U3[e.name] = U3[e.name] || G2(), e.db)
|
|
1976
|
+
if (t)
|
|
1977
|
+
V2(e), e.db.close();
|
|
1978
|
+
else
|
|
1979
|
+
return r(e.db);
|
|
1980
|
+
var i = [e.name];
|
|
1981
|
+
t && i.push(e.version);
|
|
1982
|
+
var n = M2.open.apply(M2, i);
|
|
1983
|
+
t && (n.onupgradeneeded = function(f3) {
|
|
1984
|
+
var u2 = n.result;
|
|
1985
|
+
try {
|
|
1986
|
+
u2.createObjectStore(e.storeName), f3.oldVersion <= 1 && u2.createObjectStore(F2);
|
|
1987
|
+
} catch (c3) {
|
|
1988
|
+
if (c3.name === "ConstraintError")
|
|
1989
|
+
console.warn('The database "' + e.name + '" has been upgraded from version ' + f3.oldVersion + " to version " + f3.newVersion + ', but the storage "' + e.storeName + '" already exists.');
|
|
1990
|
+
else
|
|
1991
|
+
throw c3;
|
|
1992
|
+
}
|
|
1993
|
+
}), n.onerror = function(f3) {
|
|
1994
|
+
f3.preventDefault(), o(n.error);
|
|
1995
|
+
}, n.onsuccess = function() {
|
|
1996
|
+
var f3 = n.result;
|
|
1997
|
+
f3.onversionchange = function(u2) {
|
|
1998
|
+
u2.target.close();
|
|
1999
|
+
}, r(f3), j2(e);
|
|
2000
|
+
};
|
|
2001
|
+
});
|
|
2002
|
+
}
|
|
2003
|
+
function ee2(e) {
|
|
2004
|
+
return J2(e, false);
|
|
2005
|
+
}
|
|
2006
|
+
function oe(e) {
|
|
2007
|
+
return J2(e, true);
|
|
2008
|
+
}
|
|
2009
|
+
function a2(e, t) {
|
|
2010
|
+
if (!e.db)
|
|
2011
|
+
return true;
|
|
2012
|
+
var r = !e.db.objectStoreNames.contains(e.storeName), o = e.version < e.db.version, i = e.version > e.db.version;
|
|
2013
|
+
if (o && (e.version !== t && console.warn('The database "' + e.name + `" can't be downgraded from version ` + e.db.version + " to version " + e.version + "."), e.version = e.db.version), i || r) {
|
|
2014
|
+
if (r) {
|
|
2015
|
+
var n = e.db.version + 1;
|
|
2016
|
+
n > e.version && (e.version = n);
|
|
2017
|
+
}
|
|
2018
|
+
return true;
|
|
2019
|
+
}
|
|
2020
|
+
return false;
|
|
2021
|
+
}
|
|
2022
|
+
function s(e) {
|
|
2023
|
+
return new m2(function(t, r) {
|
|
2024
|
+
var o = new FileReader();
|
|
2025
|
+
o.onerror = r, o.onloadend = function(i) {
|
|
2026
|
+
var n = btoa(i.target.result || "");
|
|
2027
|
+
t({ __local_forage_encoded_blob: true, data: n, type: e.type });
|
|
2028
|
+
}, o.readAsBinaryString(e);
|
|
2029
|
+
});
|
|
2030
|
+
}
|
|
2031
|
+
function v2(e) {
|
|
2032
|
+
var t = N3(atob(e.data));
|
|
2033
|
+
return $([t], { type: e.type });
|
|
2034
|
+
}
|
|
2035
|
+
function p2(e) {
|
|
2036
|
+
return e && e.__local_forage_encoded_blob;
|
|
2037
|
+
}
|
|
2038
|
+
function g3(e) {
|
|
2039
|
+
var t = this, r = t._initReady().then(function() {
|
|
2040
|
+
var o = U3[t._dbInfo.name];
|
|
2041
|
+
if (o && o.dbReady)
|
|
2042
|
+
return o.dbReady;
|
|
2043
|
+
});
|
|
2044
|
+
return B2(r, e, e), r;
|
|
2045
|
+
}
|
|
2046
|
+
function w(e) {
|
|
2047
|
+
V2(e);
|
|
2048
|
+
for (var t = U3[e.name], r = t.forages, o = 0; o < r.length; o++) {
|
|
2049
|
+
var i = r[o];
|
|
2050
|
+
i._dbInfo.db && (i._dbInfo.db.close(), i._dbInfo.db = null);
|
|
2051
|
+
}
|
|
2052
|
+
return e.db = null, ee2(e).then(function(n) {
|
|
2053
|
+
return e.db = n, a2(e) ? oe(e) : n;
|
|
2054
|
+
}).then(function(n) {
|
|
2055
|
+
e.db = t.db = n;
|
|
2056
|
+
for (var f3 = 0; f3 < r.length; f3++)
|
|
2057
|
+
r[f3]._dbInfo.db = n;
|
|
2058
|
+
}).catch(function(n) {
|
|
2059
|
+
throw Q2(e, n), n;
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2062
|
+
function T3(e, t, r, o) {
|
|
2063
|
+
o === void 0 && (o = 1);
|
|
2064
|
+
try {
|
|
2065
|
+
var i = e.db.transaction(e.storeName, t);
|
|
2066
|
+
r(null, i);
|
|
2067
|
+
} catch (n) {
|
|
2068
|
+
if (o > 0 && (!e.db || n.name === "InvalidStateError" || n.name === "NotFoundError"))
|
|
2069
|
+
return m2.resolve().then(function() {
|
|
2070
|
+
if (!e.db || n.name === "NotFoundError" && !e.db.objectStoreNames.contains(e.storeName) && e.version <= e.db.version)
|
|
2071
|
+
return e.db && (e.version = e.db.version + 1), oe(e);
|
|
2072
|
+
}).then(function() {
|
|
2073
|
+
return w(e).then(function() {
|
|
2074
|
+
T3(e, t, r, o - 1);
|
|
2075
|
+
});
|
|
2076
|
+
}).catch(r);
|
|
2077
|
+
r(n);
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
function G2() {
|
|
2081
|
+
return { forages: [], db: null, dbReady: null, deferredOperations: [] };
|
|
2082
|
+
}
|
|
2083
|
+
function fe2(e) {
|
|
2084
|
+
var t = this, r = { db: null };
|
|
2085
|
+
if (e)
|
|
2086
|
+
for (var o in e)
|
|
2087
|
+
r[o] = e[o];
|
|
2088
|
+
var i = U3[r.name];
|
|
2089
|
+
i || (i = G2(), U3[r.name] = i), i.forages.push(t), t._initReady || (t._initReady = t.ready, t.ready = g3);
|
|
2090
|
+
var n = [];
|
|
2091
|
+
function f3() {
|
|
2092
|
+
return m2.resolve();
|
|
2093
|
+
}
|
|
2094
|
+
for (var u2 = 0; u2 < i.forages.length; u2++) {
|
|
2095
|
+
var c3 = i.forages[u2];
|
|
2096
|
+
c3 !== t && n.push(c3._initReady().catch(f3));
|
|
2097
|
+
}
|
|
2098
|
+
var l = i.forages.slice(0);
|
|
2099
|
+
return m2.all(n).then(function() {
|
|
2100
|
+
return r.db = i.db, ee2(r);
|
|
2101
|
+
}).then(function(d3) {
|
|
2102
|
+
return r.db = d3, a2(r, t._defaultConfig.version) ? oe(r) : d3;
|
|
2103
|
+
}).then(function(d3) {
|
|
2104
|
+
r.db = i.db = d3, t._dbInfo = r;
|
|
2105
|
+
for (var y3 = 0; y3 < l.length; y3++) {
|
|
2106
|
+
var S = l[y3];
|
|
2107
|
+
S !== t && (S._dbInfo.db = r.db, S._dbInfo.version = r.version);
|
|
2108
|
+
}
|
|
2109
|
+
});
|
|
2110
|
+
}
|
|
2111
|
+
function ie2(e, t) {
|
|
2112
|
+
var r = this;
|
|
2113
|
+
e = z(e);
|
|
2114
|
+
var o = new m2(function(i, n) {
|
|
2115
|
+
r.ready().then(function() {
|
|
2116
|
+
T3(r._dbInfo, re2, function(f3, u2) {
|
|
2117
|
+
if (f3)
|
|
2118
|
+
return n(f3);
|
|
2119
|
+
try {
|
|
2120
|
+
var c3 = u2.objectStore(r._dbInfo.storeName), l = c3.get(e);
|
|
2121
|
+
l.onsuccess = function() {
|
|
2122
|
+
var d3 = l.result;
|
|
2123
|
+
d3 === void 0 && (d3 = null), p2(d3) && (d3 = v2(d3)), i(d3);
|
|
2124
|
+
}, l.onerror = function() {
|
|
2125
|
+
n(l.error);
|
|
2126
|
+
};
|
|
2127
|
+
} catch (d3) {
|
|
2128
|
+
n(d3);
|
|
2129
|
+
}
|
|
2130
|
+
});
|
|
2131
|
+
}).catch(n);
|
|
2132
|
+
});
|
|
2133
|
+
return _3(o, t), o;
|
|
2134
|
+
}
|
|
2135
|
+
function ce2(e, t) {
|
|
2136
|
+
var r = this, o = new m2(function(i, n) {
|
|
2137
|
+
r.ready().then(function() {
|
|
2138
|
+
T3(r._dbInfo, re2, function(f3, u2) {
|
|
2139
|
+
if (f3)
|
|
2140
|
+
return n(f3);
|
|
2141
|
+
try {
|
|
2142
|
+
var c3 = u2.objectStore(r._dbInfo.storeName), l = c3.openCursor(), d3 = 1;
|
|
2143
|
+
l.onsuccess = function() {
|
|
2144
|
+
var y3 = l.result;
|
|
2145
|
+
if (y3) {
|
|
2146
|
+
var S = y3.value;
|
|
2147
|
+
p2(S) && (S = v2(S));
|
|
2148
|
+
var x2 = e(S, y3.key, d3++);
|
|
2149
|
+
x2 !== void 0 ? i(x2) : y3.continue();
|
|
2150
|
+
} else
|
|
2151
|
+
i();
|
|
2152
|
+
}, l.onerror = function() {
|
|
2153
|
+
n(l.error);
|
|
2154
|
+
};
|
|
2155
|
+
} catch (y3) {
|
|
2156
|
+
n(y3);
|
|
2157
|
+
}
|
|
2158
|
+
});
|
|
2159
|
+
}).catch(n);
|
|
2160
|
+
});
|
|
2161
|
+
return _3(o, t), o;
|
|
2162
|
+
}
|
|
2163
|
+
function nr2(e, t, r) {
|
|
2164
|
+
var o = this;
|
|
2165
|
+
e = z(e);
|
|
2166
|
+
var i = new m2(function(n, f3) {
|
|
2167
|
+
var u2;
|
|
2168
|
+
o.ready().then(function() {
|
|
2169
|
+
return u2 = o._dbInfo, ae2.call(t) === "[object Blob]" ? O3(u2.db).then(function(c3) {
|
|
2170
|
+
return c3 ? t : s(t);
|
|
2171
|
+
}) : t;
|
|
2172
|
+
}).then(function(c3) {
|
|
2173
|
+
T3(o._dbInfo, h3, function(l, d3) {
|
|
2174
|
+
if (l)
|
|
2175
|
+
return f3(l);
|
|
2176
|
+
try {
|
|
2177
|
+
var y3 = d3.objectStore(o._dbInfo.storeName);
|
|
2178
|
+
c3 === null && (c3 = void 0);
|
|
2179
|
+
var S = y3.put(c3, e);
|
|
2180
|
+
d3.oncomplete = function() {
|
|
2181
|
+
c3 === void 0 && (c3 = null), n(c3);
|
|
2182
|
+
}, d3.onabort = d3.onerror = function() {
|
|
2183
|
+
var x2 = S.error ? S.error : S.transaction.error;
|
|
2184
|
+
f3(x2);
|
|
2185
|
+
};
|
|
2186
|
+
} catch (x2) {
|
|
2187
|
+
f3(x2);
|
|
2188
|
+
}
|
|
2189
|
+
});
|
|
2190
|
+
}).catch(f3);
|
|
2191
|
+
});
|
|
2192
|
+
return _3(i, r), i;
|
|
2193
|
+
}
|
|
2194
|
+
function or2(e, t) {
|
|
2195
|
+
var r = this;
|
|
2196
|
+
e = z(e);
|
|
2197
|
+
var o = new m2(function(i, n) {
|
|
2198
|
+
r.ready().then(function() {
|
|
2199
|
+
T3(r._dbInfo, h3, function(f3, u2) {
|
|
2200
|
+
if (f3)
|
|
2201
|
+
return n(f3);
|
|
2202
|
+
try {
|
|
2203
|
+
var c3 = u2.objectStore(r._dbInfo.storeName), l = c3.delete(e);
|
|
2204
|
+
u2.oncomplete = function() {
|
|
2205
|
+
i();
|
|
2206
|
+
}, u2.onerror = function() {
|
|
2207
|
+
n(l.error);
|
|
2208
|
+
}, u2.onabort = function() {
|
|
2209
|
+
var d3 = l.error ? l.error : l.transaction.error;
|
|
2210
|
+
n(d3);
|
|
2211
|
+
};
|
|
2212
|
+
} catch (d3) {
|
|
2213
|
+
n(d3);
|
|
2214
|
+
}
|
|
2215
|
+
});
|
|
2216
|
+
}).catch(n);
|
|
2217
|
+
});
|
|
2218
|
+
return _3(o, t), o;
|
|
2219
|
+
}
|
|
2220
|
+
function ir2(e) {
|
|
2221
|
+
var t = this, r = new m2(function(o, i) {
|
|
2222
|
+
t.ready().then(function() {
|
|
2223
|
+
T3(t._dbInfo, h3, function(n, f3) {
|
|
2224
|
+
if (n)
|
|
2225
|
+
return i(n);
|
|
2226
|
+
try {
|
|
2227
|
+
var u2 = f3.objectStore(t._dbInfo.storeName), c3 = u2.clear();
|
|
2228
|
+
f3.oncomplete = function() {
|
|
2229
|
+
o();
|
|
2230
|
+
}, f3.onabort = f3.onerror = function() {
|
|
2231
|
+
var l = c3.error ? c3.error : c3.transaction.error;
|
|
2232
|
+
i(l);
|
|
2233
|
+
};
|
|
2234
|
+
} catch (l) {
|
|
2235
|
+
i(l);
|
|
2236
|
+
}
|
|
2237
|
+
});
|
|
2238
|
+
}).catch(i);
|
|
2239
|
+
});
|
|
2240
|
+
return _3(r, e), r;
|
|
2241
|
+
}
|
|
2242
|
+
function ar2(e) {
|
|
2243
|
+
var t = this, r = new m2(function(o, i) {
|
|
2244
|
+
t.ready().then(function() {
|
|
2245
|
+
T3(t._dbInfo, re2, function(n, f3) {
|
|
2246
|
+
if (n)
|
|
2247
|
+
return i(n);
|
|
2248
|
+
try {
|
|
2249
|
+
var u2 = f3.objectStore(t._dbInfo.storeName), c3 = u2.count();
|
|
2250
|
+
c3.onsuccess = function() {
|
|
2251
|
+
o(c3.result);
|
|
2252
|
+
}, c3.onerror = function() {
|
|
2253
|
+
i(c3.error);
|
|
2254
|
+
};
|
|
2255
|
+
} catch (l) {
|
|
2256
|
+
i(l);
|
|
2257
|
+
}
|
|
2258
|
+
});
|
|
2259
|
+
}).catch(i);
|
|
2260
|
+
});
|
|
2261
|
+
return _3(r, e), r;
|
|
2262
|
+
}
|
|
2263
|
+
function fr2(e, t) {
|
|
2264
|
+
var r = this, o = new m2(function(i, n) {
|
|
2265
|
+
if (e < 0) {
|
|
2266
|
+
i(null);
|
|
2267
|
+
return;
|
|
2268
|
+
}
|
|
2269
|
+
r.ready().then(function() {
|
|
2270
|
+
T3(r._dbInfo, re2, function(f3, u2) {
|
|
2271
|
+
if (f3)
|
|
2272
|
+
return n(f3);
|
|
2273
|
+
try {
|
|
2274
|
+
var c3 = u2.objectStore(r._dbInfo.storeName), l = false, d3 = c3.openKeyCursor();
|
|
2275
|
+
d3.onsuccess = function() {
|
|
2276
|
+
var y3 = d3.result;
|
|
2277
|
+
if (!y3) {
|
|
2278
|
+
i(null);
|
|
2279
|
+
return;
|
|
2280
|
+
}
|
|
2281
|
+
e === 0 || l ? i(y3.key) : (l = true, y3.advance(e));
|
|
2282
|
+
}, d3.onerror = function() {
|
|
2283
|
+
n(d3.error);
|
|
2284
|
+
};
|
|
2285
|
+
} catch (y3) {
|
|
2286
|
+
n(y3);
|
|
2287
|
+
}
|
|
2288
|
+
});
|
|
2289
|
+
}).catch(n);
|
|
2290
|
+
});
|
|
2291
|
+
return _3(o, t), o;
|
|
2292
|
+
}
|
|
2293
|
+
function ur2(e) {
|
|
2294
|
+
var t = this, r = new m2(function(o, i) {
|
|
2295
|
+
t.ready().then(function() {
|
|
2296
|
+
T3(t._dbInfo, re2, function(n, f3) {
|
|
2297
|
+
if (n)
|
|
2298
|
+
return i(n);
|
|
2299
|
+
try {
|
|
2300
|
+
var u2 = f3.objectStore(t._dbInfo.storeName), c3 = u2.openKeyCursor(), l = [];
|
|
2301
|
+
c3.onsuccess = function() {
|
|
2302
|
+
var d3 = c3.result;
|
|
2303
|
+
if (!d3) {
|
|
2304
|
+
o(l);
|
|
2305
|
+
return;
|
|
2306
|
+
}
|
|
2307
|
+
l.push(d3.key), d3.continue();
|
|
2308
|
+
}, c3.onerror = function() {
|
|
2309
|
+
i(c3.error);
|
|
2310
|
+
};
|
|
2311
|
+
} catch (d3) {
|
|
2312
|
+
i(d3);
|
|
2313
|
+
}
|
|
2314
|
+
});
|
|
2315
|
+
}).catch(i);
|
|
2316
|
+
});
|
|
2317
|
+
return _3(r, e), r;
|
|
2318
|
+
}
|
|
2319
|
+
function sr2(e, t) {
|
|
2320
|
+
t = Z2.apply(this, arguments);
|
|
2321
|
+
var r = this.config();
|
|
2322
|
+
e = typeof e != "function" && e || {}, e.name || (e.name = e.name || r.name, e.storeName = e.storeName || r.storeName);
|
|
2323
|
+
var o = this, i;
|
|
2324
|
+
if (!e.name)
|
|
2325
|
+
i = m2.reject("Invalid arguments");
|
|
2326
|
+
else {
|
|
2327
|
+
var n = e.name === r.name && o._dbInfo.db, f3 = n ? m2.resolve(o._dbInfo.db) : ee2(e).then(function(u2) {
|
|
2328
|
+
var c3 = U3[e.name], l = c3.forages;
|
|
2329
|
+
c3.db = u2;
|
|
2330
|
+
for (var d3 = 0; d3 < l.length; d3++)
|
|
2331
|
+
l[d3]._dbInfo.db = u2;
|
|
2332
|
+
return u2;
|
|
2333
|
+
});
|
|
2334
|
+
e.storeName ? i = f3.then(function(u2) {
|
|
2335
|
+
if (!!u2.objectStoreNames.contains(e.storeName)) {
|
|
2336
|
+
var c3 = u2.version + 1;
|
|
2337
|
+
V2(e);
|
|
2338
|
+
var l = U3[e.name], d3 = l.forages;
|
|
2339
|
+
u2.close();
|
|
2340
|
+
for (var y3 = 0; y3 < d3.length; y3++) {
|
|
2341
|
+
var S = d3[y3];
|
|
2342
|
+
S._dbInfo.db = null, S._dbInfo.version = c3;
|
|
2343
|
+
}
|
|
2344
|
+
var x2 = new m2(function(C, K2) {
|
|
2345
|
+
var W2 = M2.open(e.name, c3);
|
|
2346
|
+
W2.onerror = function(q2) {
|
|
2347
|
+
var de2 = W2.result;
|
|
2348
|
+
de2.close(), K2(q2);
|
|
2349
|
+
}, W2.onupgradeneeded = function() {
|
|
2350
|
+
var q2 = W2.result;
|
|
2351
|
+
q2.deleteObjectStore(e.storeName);
|
|
2352
|
+
}, W2.onsuccess = function() {
|
|
2353
|
+
var q2 = W2.result;
|
|
2354
|
+
q2.close(), C(q2);
|
|
2355
|
+
};
|
|
2356
|
+
});
|
|
2357
|
+
return x2.then(function(C) {
|
|
2358
|
+
l.db = C;
|
|
2359
|
+
for (var K2 = 0; K2 < d3.length; K2++) {
|
|
2360
|
+
var W2 = d3[K2];
|
|
2361
|
+
W2._dbInfo.db = C, j2(W2._dbInfo);
|
|
2362
|
+
}
|
|
2363
|
+
}).catch(function(C) {
|
|
2364
|
+
throw (Q2(e, C) || m2.resolve()).catch(function() {
|
|
2365
|
+
}), C;
|
|
2366
|
+
});
|
|
2367
|
+
}
|
|
2368
|
+
}) : i = f3.then(function(u2) {
|
|
2369
|
+
V2(e);
|
|
2370
|
+
var c3 = U3[e.name], l = c3.forages;
|
|
2371
|
+
u2.close();
|
|
2372
|
+
for (var d3 = 0; d3 < l.length; d3++) {
|
|
2373
|
+
var y3 = l[d3];
|
|
2374
|
+
y3._dbInfo.db = null;
|
|
2375
|
+
}
|
|
2376
|
+
var S = new m2(function(x2, C) {
|
|
2377
|
+
var K2 = M2.deleteDatabase(e.name);
|
|
2378
|
+
K2.onerror = function() {
|
|
2379
|
+
var W2 = K2.result;
|
|
2380
|
+
W2 && W2.close(), C(K2.error);
|
|
2381
|
+
}, K2.onblocked = function() {
|
|
2382
|
+
console.warn('dropInstance blocked for database "' + e.name + '" until all open connections are closed');
|
|
2383
|
+
}, K2.onsuccess = function() {
|
|
2384
|
+
var W2 = K2.result;
|
|
2385
|
+
W2 && W2.close(), x2(W2);
|
|
2386
|
+
};
|
|
2387
|
+
});
|
|
2388
|
+
return S.then(function(x2) {
|
|
2389
|
+
c3.db = x2;
|
|
2390
|
+
for (var C = 0; C < l.length; C++) {
|
|
2391
|
+
var K2 = l[C];
|
|
2392
|
+
j2(K2._dbInfo);
|
|
2393
|
+
}
|
|
2394
|
+
}).catch(function(x2) {
|
|
2395
|
+
throw (Q2(e, x2) || m2.resolve()).catch(function() {
|
|
2396
|
+
}), x2;
|
|
2397
|
+
});
|
|
2398
|
+
});
|
|
2399
|
+
}
|
|
2400
|
+
return _3(i, t), i;
|
|
2401
|
+
}
|
|
2402
|
+
var cr2 = { _driver: "asyncStorage", _initStorage: fe2, _support: H2(), iterate: ce2, getItem: ie2, setItem: nr2, removeItem: or2, clear: ir2, length: ar2, key: fr2, keys: ur2, dropInstance: sr2 };
|
|
2403
|
+
function lr2() {
|
|
2404
|
+
return typeof openDatabase == "function";
|
|
2405
|
+
}
|
|
2406
|
+
var te2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", dr2 = "~~local_forage_type~", Be2 = /^~~local_forage_type~([^~]+)~/, he2 = "__lfsc__:", be2 = he2.length, _e2 = "arbf", we2 = "blob", xe2 = "si08", Oe2 = "ui08", Ce2 = "uic8", Le = "si16", Pe2 = "si32", Me2 = "ur16", Fe2 = "ui32", Ue2 = "fl32", Ye2 = "fl64", ze2 = be2 + _e2.length, We2 = Object.prototype.toString;
|
|
2407
|
+
function Ke2(e) {
|
|
2408
|
+
var t = e.length * 0.75, r = e.length, o, i = 0, n, f3, u2, c3;
|
|
2409
|
+
e[e.length - 1] === "=" && (t--, e[e.length - 2] === "=" && t--);
|
|
2410
|
+
var l = new ArrayBuffer(t), d3 = new Uint8Array(l);
|
|
2411
|
+
for (o = 0; o < r; o += 4)
|
|
2412
|
+
n = te2.indexOf(e[o]), f3 = te2.indexOf(e[o + 1]), u2 = te2.indexOf(e[o + 2]), c3 = te2.indexOf(e[o + 3]), d3[i++] = n << 2 | f3 >> 4, d3[i++] = (f3 & 15) << 4 | u2 >> 2, d3[i++] = (u2 & 3) << 6 | c3 & 63;
|
|
2413
|
+
return l;
|
|
2414
|
+
}
|
|
2415
|
+
function Ee(e) {
|
|
2416
|
+
var t = new Uint8Array(e), r = "", o;
|
|
2417
|
+
for (o = 0; o < t.length; o += 3)
|
|
2418
|
+
r += te2[t[o] >> 2], r += te2[(t[o] & 3) << 4 | t[o + 1] >> 4], r += te2[(t[o + 1] & 15) << 2 | t[o + 2] >> 6], r += te2[t[o + 2] & 63];
|
|
2419
|
+
return t.length % 3 === 2 ? r = r.substring(0, r.length - 1) + "=" : t.length % 3 === 1 && (r = r.substring(0, r.length - 2) + "=="), r;
|
|
2420
|
+
}
|
|
2421
|
+
function vr2(e, t) {
|
|
2422
|
+
var r = "";
|
|
2423
|
+
if (e && (r = We2.call(e)), e && (r === "[object ArrayBuffer]" || e.buffer && We2.call(e.buffer) === "[object ArrayBuffer]")) {
|
|
2424
|
+
var o, i = he2;
|
|
2425
|
+
e instanceof ArrayBuffer ? (o = e, i += _e2) : (o = e.buffer, r === "[object Int8Array]" ? i += xe2 : r === "[object Uint8Array]" ? i += Oe2 : r === "[object Uint8ClampedArray]" ? i += Ce2 : r === "[object Int16Array]" ? i += Le : r === "[object Uint16Array]" ? i += Me2 : r === "[object Int32Array]" ? i += Pe2 : r === "[object Uint32Array]" ? i += Fe2 : r === "[object Float32Array]" ? i += Ue2 : r === "[object Float64Array]" ? i += Ye2 : t(new Error("Failed to get type for BinaryArray"))), t(i + Ee(o));
|
|
2426
|
+
} else if (r === "[object Blob]") {
|
|
2427
|
+
var n = new FileReader();
|
|
2428
|
+
n.onload = function() {
|
|
2429
|
+
var f3 = dr2 + e.type + "~" + Ee(this.result);
|
|
2430
|
+
t(he2 + we2 + f3);
|
|
2431
|
+
}, n.readAsArrayBuffer(e);
|
|
2432
|
+
} else
|
|
2433
|
+
try {
|
|
2434
|
+
t(JSON.stringify(e));
|
|
2435
|
+
} catch (f3) {
|
|
2436
|
+
console.error("Couldn't convert value into a JSON string: ", e), t(null, f3);
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
function hr2(e) {
|
|
2440
|
+
if (e.substring(0, be2) !== he2)
|
|
2441
|
+
return JSON.parse(e);
|
|
2442
|
+
var t = e.substring(ze2), r = e.substring(be2, ze2), o;
|
|
2443
|
+
if (r === we2 && Be2.test(t)) {
|
|
2444
|
+
var i = t.match(Be2);
|
|
2445
|
+
o = i[1], t = t.substring(i[0].length);
|
|
2446
|
+
}
|
|
2447
|
+
var n = Ke2(t);
|
|
2448
|
+
switch (r) {
|
|
2449
|
+
case _e2:
|
|
2450
|
+
return n;
|
|
2451
|
+
case we2:
|
|
2452
|
+
return $([n], { type: o });
|
|
2453
|
+
case xe2:
|
|
2454
|
+
return new Int8Array(n);
|
|
2455
|
+
case Oe2:
|
|
2456
|
+
return new Uint8Array(n);
|
|
2457
|
+
case Ce2:
|
|
2458
|
+
return new Uint8ClampedArray(n);
|
|
2459
|
+
case Le:
|
|
2460
|
+
return new Int16Array(n);
|
|
2461
|
+
case Me2:
|
|
2462
|
+
return new Uint16Array(n);
|
|
2463
|
+
case Pe2:
|
|
2464
|
+
return new Int32Array(n);
|
|
2465
|
+
case Fe2:
|
|
2466
|
+
return new Uint32Array(n);
|
|
2467
|
+
case Ue2:
|
|
2468
|
+
return new Float32Array(n);
|
|
2469
|
+
case Ye2:
|
|
2470
|
+
return new Float64Array(n);
|
|
2471
|
+
default:
|
|
2472
|
+
throw new Error("Unkown type: " + r);
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
var Ie2 = { serialize: vr2, deserialize: hr2, stringToBuffer: Ke2, bufferToString: Ee };
|
|
2476
|
+
function He(e, t, r, o) {
|
|
2477
|
+
e.executeSql("CREATE TABLE IF NOT EXISTS " + t.storeName + " (id INTEGER PRIMARY KEY, key unique, value)", [], r, o);
|
|
2478
|
+
}
|
|
2479
|
+
function mr(e) {
|
|
2480
|
+
var t = this, r = { db: null };
|
|
2481
|
+
if (e)
|
|
2482
|
+
for (var o in e)
|
|
2483
|
+
r[o] = typeof e[o] != "string" ? e[o].toString() : e[o];
|
|
2484
|
+
var i = new m2(function(n, f3) {
|
|
2485
|
+
try {
|
|
2486
|
+
r.db = openDatabase(r.name, String(r.version), r.description, r.size);
|
|
2487
|
+
} catch (u2) {
|
|
2488
|
+
return f3(u2);
|
|
2489
|
+
}
|
|
2490
|
+
r.db.transaction(function(u2) {
|
|
2491
|
+
He(u2, r, function() {
|
|
2492
|
+
t._dbInfo = r, n();
|
|
2493
|
+
}, function(c3, l) {
|
|
2494
|
+
f3(l);
|
|
2495
|
+
});
|
|
2496
|
+
}, f3);
|
|
2497
|
+
});
|
|
2498
|
+
return r.serializer = Ie2, i;
|
|
2499
|
+
}
|
|
2500
|
+
function ne2(e, t, r, o, i, n) {
|
|
2501
|
+
e.executeSql(r, o, i, function(f3, u2) {
|
|
2502
|
+
u2.code === u2.SYNTAX_ERR ? f3.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?", [t.storeName], function(c3, l) {
|
|
2503
|
+
l.rows.length ? n(c3, u2) : He(c3, t, function() {
|
|
2504
|
+
c3.executeSql(r, o, i, n);
|
|
2505
|
+
}, n);
|
|
2506
|
+
}, n) : n(f3, u2);
|
|
2507
|
+
}, n);
|
|
2508
|
+
}
|
|
2509
|
+
function yr2(e, t) {
|
|
2510
|
+
var r = this;
|
|
2511
|
+
e = z(e);
|
|
2512
|
+
var o = new m2(function(i, n) {
|
|
2513
|
+
r.ready().then(function() {
|
|
2514
|
+
var f3 = r._dbInfo;
|
|
2515
|
+
f3.db.transaction(function(u2) {
|
|
2516
|
+
ne2(u2, f3, "SELECT * FROM " + f3.storeName + " WHERE key = ? LIMIT 1", [e], function(c3, l) {
|
|
2517
|
+
var d3 = l.rows.length ? l.rows.item(0).value : null;
|
|
2518
|
+
d3 && (d3 = f3.serializer.deserialize(d3)), i(d3);
|
|
2519
|
+
}, function(c3, l) {
|
|
2520
|
+
n(l);
|
|
2521
|
+
});
|
|
2522
|
+
});
|
|
2523
|
+
}).catch(n);
|
|
2524
|
+
});
|
|
2525
|
+
return _3(o, t), o;
|
|
2526
|
+
}
|
|
2527
|
+
function pr2(e, t) {
|
|
2528
|
+
var r = this, o = new m2(function(i, n) {
|
|
2529
|
+
r.ready().then(function() {
|
|
2530
|
+
var f3 = r._dbInfo;
|
|
2531
|
+
f3.db.transaction(function(u2) {
|
|
2532
|
+
ne2(u2, f3, "SELECT * FROM " + f3.storeName, [], function(c3, l) {
|
|
2533
|
+
for (var d3 = l.rows, y3 = d3.length, S = 0; S < y3; S++) {
|
|
2534
|
+
var x2 = d3.item(S), C = x2.value;
|
|
2535
|
+
if (C && (C = f3.serializer.deserialize(C)), C = e(C, x2.key, S + 1), C !== void 0) {
|
|
2536
|
+
i(C);
|
|
2537
|
+
return;
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
i();
|
|
2541
|
+
}, function(c3, l) {
|
|
2542
|
+
n(l);
|
|
2543
|
+
});
|
|
2544
|
+
});
|
|
2545
|
+
}).catch(n);
|
|
2546
|
+
});
|
|
2547
|
+
return _3(o, t), o;
|
|
2548
|
+
}
|
|
2549
|
+
function Ve2(e, t, r, o) {
|
|
2550
|
+
var i = this;
|
|
2551
|
+
e = z(e);
|
|
2552
|
+
var n = new m2(function(f3, u2) {
|
|
2553
|
+
i.ready().then(function() {
|
|
2554
|
+
t === void 0 && (t = null);
|
|
2555
|
+
var c3 = t, l = i._dbInfo;
|
|
2556
|
+
l.serializer.serialize(t, function(d3, y3) {
|
|
2557
|
+
y3 ? u2(y3) : l.db.transaction(function(S) {
|
|
2558
|
+
ne2(S, l, "INSERT OR REPLACE INTO " + l.storeName + " (key, value) VALUES (?, ?)", [e, d3], function() {
|
|
2559
|
+
f3(c3);
|
|
2560
|
+
}, function(x2, C) {
|
|
2561
|
+
u2(C);
|
|
2562
|
+
});
|
|
2563
|
+
}, function(S) {
|
|
2564
|
+
if (S.code === S.QUOTA_ERR) {
|
|
2565
|
+
if (o > 0) {
|
|
2566
|
+
f3(Ve2.apply(i, [e, c3, r, o - 1]));
|
|
2567
|
+
return;
|
|
2568
|
+
}
|
|
2569
|
+
u2(S);
|
|
2570
|
+
}
|
|
2571
|
+
});
|
|
2572
|
+
});
|
|
2573
|
+
}).catch(u2);
|
|
2574
|
+
});
|
|
2575
|
+
return _3(n, r), n;
|
|
2576
|
+
}
|
|
2577
|
+
function gr(e, t, r) {
|
|
2578
|
+
return Ve2.apply(this, [e, t, r, 1]);
|
|
2579
|
+
}
|
|
2580
|
+
function br(e, t) {
|
|
2581
|
+
var r = this;
|
|
2582
|
+
e = z(e);
|
|
2583
|
+
var o = new m2(function(i, n) {
|
|
2584
|
+
r.ready().then(function() {
|
|
2585
|
+
var f3 = r._dbInfo;
|
|
2586
|
+
f3.db.transaction(function(u2) {
|
|
2587
|
+
ne2(u2, f3, "DELETE FROM " + f3.storeName + " WHERE key = ?", [e], function() {
|
|
2588
|
+
i();
|
|
2589
|
+
}, function(c3, l) {
|
|
2590
|
+
n(l);
|
|
2591
|
+
});
|
|
2592
|
+
});
|
|
2593
|
+
}).catch(n);
|
|
2594
|
+
});
|
|
2595
|
+
return _3(o, t), o;
|
|
2596
|
+
}
|
|
2597
|
+
function _r(e) {
|
|
2598
|
+
var t = this, r = new m2(function(o, i) {
|
|
2599
|
+
t.ready().then(function() {
|
|
2600
|
+
var n = t._dbInfo;
|
|
2601
|
+
n.db.transaction(function(f3) {
|
|
2602
|
+
ne2(f3, n, "DELETE FROM " + n.storeName, [], function() {
|
|
2603
|
+
o();
|
|
2604
|
+
}, function(u2, c3) {
|
|
2605
|
+
i(c3);
|
|
2606
|
+
});
|
|
2607
|
+
});
|
|
2608
|
+
}).catch(i);
|
|
2609
|
+
});
|
|
2610
|
+
return _3(r, e), r;
|
|
2611
|
+
}
|
|
2612
|
+
function wr(e) {
|
|
2613
|
+
var t = this, r = new m2(function(o, i) {
|
|
2614
|
+
t.ready().then(function() {
|
|
2615
|
+
var n = t._dbInfo;
|
|
2616
|
+
n.db.transaction(function(f3) {
|
|
2617
|
+
ne2(f3, n, "SELECT COUNT(key) as c FROM " + n.storeName, [], function(u2, c3) {
|
|
2618
|
+
var l = c3.rows.item(0).c;
|
|
2619
|
+
o(l);
|
|
2620
|
+
}, function(u2, c3) {
|
|
2621
|
+
i(c3);
|
|
2622
|
+
});
|
|
2623
|
+
});
|
|
2624
|
+
}).catch(i);
|
|
2625
|
+
});
|
|
2626
|
+
return _3(r, e), r;
|
|
2627
|
+
}
|
|
2628
|
+
function Er2(e, t) {
|
|
2629
|
+
var r = this, o = new m2(function(i, n) {
|
|
2630
|
+
r.ready().then(function() {
|
|
2631
|
+
var f3 = r._dbInfo;
|
|
2632
|
+
f3.db.transaction(function(u2) {
|
|
2633
|
+
ne2(u2, f3, "SELECT key FROM " + f3.storeName + " WHERE id = ? LIMIT 1", [e + 1], function(c3, l) {
|
|
2634
|
+
var d3 = l.rows.length ? l.rows.item(0).key : null;
|
|
2635
|
+
i(d3);
|
|
2636
|
+
}, function(c3, l) {
|
|
2637
|
+
n(l);
|
|
2638
|
+
});
|
|
2639
|
+
});
|
|
2640
|
+
}).catch(n);
|
|
2641
|
+
});
|
|
2642
|
+
return _3(o, t), o;
|
|
2643
|
+
}
|
|
2644
|
+
function Ir2(e) {
|
|
2645
|
+
var t = this, r = new m2(function(o, i) {
|
|
2646
|
+
t.ready().then(function() {
|
|
2647
|
+
var n = t._dbInfo;
|
|
2648
|
+
n.db.transaction(function(f3) {
|
|
2649
|
+
ne2(f3, n, "SELECT key FROM " + n.storeName, [], function(u2, c3) {
|
|
2650
|
+
for (var l = [], d3 = 0; d3 < c3.rows.length; d3++)
|
|
2651
|
+
l.push(c3.rows.item(d3).key);
|
|
2652
|
+
o(l);
|
|
2653
|
+
}, function(u2, c3) {
|
|
2654
|
+
i(c3);
|
|
2655
|
+
});
|
|
2656
|
+
});
|
|
2657
|
+
}).catch(i);
|
|
2658
|
+
});
|
|
2659
|
+
return _3(r, e), r;
|
|
2660
|
+
}
|
|
2661
|
+
function Sr(e) {
|
|
2662
|
+
return new m2(function(t, r) {
|
|
2663
|
+
e.transaction(function(o) {
|
|
2664
|
+
o.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'", [], function(i, n) {
|
|
2665
|
+
for (var f3 = [], u2 = 0; u2 < n.rows.length; u2++)
|
|
2666
|
+
f3.push(n.rows.item(u2).name);
|
|
2667
|
+
t({ db: e, storeNames: f3 });
|
|
2668
|
+
}, function(i, n) {
|
|
2669
|
+
r(n);
|
|
2670
|
+
});
|
|
2671
|
+
}, function(o) {
|
|
2672
|
+
r(o);
|
|
2673
|
+
});
|
|
2674
|
+
});
|
|
2675
|
+
}
|
|
2676
|
+
function Ar(e, t) {
|
|
2677
|
+
t = Z2.apply(this, arguments);
|
|
2678
|
+
var r = this.config();
|
|
2679
|
+
e = typeof e != "function" && e || {}, e.name || (e.name = e.name || r.name, e.storeName = e.storeName || r.storeName);
|
|
2680
|
+
var o = this, i;
|
|
2681
|
+
return e.name ? i = new m2(function(n) {
|
|
2682
|
+
var f3;
|
|
2683
|
+
e.name === r.name ? f3 = o._dbInfo.db : f3 = openDatabase(e.name, "", "", 0), e.storeName ? n({ db: f3, storeNames: [e.storeName] }) : n(Sr(f3));
|
|
2684
|
+
}).then(function(n) {
|
|
2685
|
+
return new m2(function(f3, u2) {
|
|
2686
|
+
n.db.transaction(function(c3) {
|
|
2687
|
+
function l(x2) {
|
|
2688
|
+
return new m2(function(C, K2) {
|
|
2689
|
+
c3.executeSql("DROP TABLE IF EXISTS " + x2, [], function() {
|
|
2690
|
+
C();
|
|
2691
|
+
}, function(W2, q2) {
|
|
2692
|
+
K2(q2);
|
|
2693
|
+
});
|
|
2694
|
+
});
|
|
2695
|
+
}
|
|
2696
|
+
for (var d3 = [], y3 = 0, S = n.storeNames.length; y3 < S; y3++)
|
|
2697
|
+
d3.push(l(n.storeNames[y3]));
|
|
2698
|
+
m2.all(d3).then(function() {
|
|
2699
|
+
f3();
|
|
2700
|
+
}).catch(function(x2) {
|
|
2701
|
+
u2(x2);
|
|
2702
|
+
});
|
|
2703
|
+
}, function(c3) {
|
|
2704
|
+
u2(c3);
|
|
2705
|
+
});
|
|
2706
|
+
});
|
|
2707
|
+
}) : i = m2.reject("Invalid arguments"), _3(i, t), i;
|
|
2708
|
+
}
|
|
2709
|
+
var Rr2 = { _driver: "webSQLStorage", _initStorage: mr, _support: lr2(), iterate: pr2, getItem: yr2, setItem: gr, removeItem: br, clear: _r, length: wr, key: Er2, keys: Ir2, dropInstance: Ar };
|
|
2710
|
+
function Dr() {
|
|
2711
|
+
try {
|
|
2712
|
+
return typeof localStorage < "u" && "setItem" in localStorage && !!localStorage.setItem;
|
|
2713
|
+
} catch {
|
|
2714
|
+
return false;
|
|
2715
|
+
}
|
|
2716
|
+
}
|
|
2717
|
+
function Ge(e, t) {
|
|
2718
|
+
var r = e.name + "/";
|
|
2719
|
+
return e.storeName !== t.storeName && (r += e.storeName + "/"), r;
|
|
2720
|
+
}
|
|
2721
|
+
function Nr() {
|
|
2722
|
+
var e = "_localforage_support_test";
|
|
2723
|
+
try {
|
|
2724
|
+
return localStorage.setItem(e, true), localStorage.removeItem(e), false;
|
|
2725
|
+
} catch {
|
|
2726
|
+
return true;
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
function Tr2() {
|
|
2730
|
+
return !Nr() || localStorage.length > 0;
|
|
2731
|
+
}
|
|
2732
|
+
function Br(e) {
|
|
2733
|
+
var t = this, r = {};
|
|
2734
|
+
if (e)
|
|
2735
|
+
for (var o in e)
|
|
2736
|
+
r[o] = e[o];
|
|
2737
|
+
return r.keyPrefix = Ge(e, t._defaultConfig), Tr2() ? (t._dbInfo = r, r.serializer = Ie2, m2.resolve()) : m2.reject();
|
|
2738
|
+
}
|
|
2739
|
+
function xr(e) {
|
|
2740
|
+
var t = this, r = t.ready().then(function() {
|
|
2741
|
+
for (var o = t._dbInfo.keyPrefix, i = localStorage.length - 1; i >= 0; i--) {
|
|
2742
|
+
var n = localStorage.key(i);
|
|
2743
|
+
n.indexOf(o) === 0 && localStorage.removeItem(n);
|
|
2744
|
+
}
|
|
2745
|
+
});
|
|
2746
|
+
return _3(r, e), r;
|
|
2747
|
+
}
|
|
2748
|
+
function Or(e, t) {
|
|
2749
|
+
var r = this;
|
|
2750
|
+
e = z(e);
|
|
2751
|
+
var o = r.ready().then(function() {
|
|
2752
|
+
var i = r._dbInfo, n = localStorage.getItem(i.keyPrefix + e);
|
|
2753
|
+
return n && (n = i.serializer.deserialize(n)), n;
|
|
2754
|
+
});
|
|
2755
|
+
return _3(o, t), o;
|
|
2756
|
+
}
|
|
2757
|
+
function Cr(e, t) {
|
|
2758
|
+
var r = this, o = r.ready().then(function() {
|
|
2759
|
+
for (var i = r._dbInfo, n = i.keyPrefix, f3 = n.length, u2 = localStorage.length, c3 = 1, l = 0; l < u2; l++) {
|
|
2760
|
+
var d3 = localStorage.key(l);
|
|
2761
|
+
if (d3.indexOf(n) === 0) {
|
|
2762
|
+
var y3 = localStorage.getItem(d3);
|
|
2763
|
+
if (y3 && (y3 = i.serializer.deserialize(y3)), y3 = e(y3, d3.substring(f3), c3++), y3 !== void 0)
|
|
2764
|
+
return y3;
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
});
|
|
2768
|
+
return _3(o, t), o;
|
|
2769
|
+
}
|
|
2770
|
+
function Lr(e, t) {
|
|
2771
|
+
var r = this, o = r.ready().then(function() {
|
|
2772
|
+
var i = r._dbInfo, n;
|
|
2773
|
+
try {
|
|
2774
|
+
n = localStorage.key(e);
|
|
2775
|
+
} catch {
|
|
2776
|
+
n = null;
|
|
2777
|
+
}
|
|
2778
|
+
return n && (n = n.substring(i.keyPrefix.length)), n;
|
|
2779
|
+
});
|
|
2780
|
+
return _3(o, t), o;
|
|
2781
|
+
}
|
|
2782
|
+
function Pr(e) {
|
|
2783
|
+
var t = this, r = t.ready().then(function() {
|
|
2784
|
+
for (var o = t._dbInfo, i = localStorage.length, n = [], f3 = 0; f3 < i; f3++) {
|
|
2785
|
+
var u2 = localStorage.key(f3);
|
|
2786
|
+
u2.indexOf(o.keyPrefix) === 0 && n.push(u2.substring(o.keyPrefix.length));
|
|
2787
|
+
}
|
|
2788
|
+
return n;
|
|
2789
|
+
});
|
|
2790
|
+
return _3(r, e), r;
|
|
2791
|
+
}
|
|
2792
|
+
function Mr(e) {
|
|
2793
|
+
var t = this, r = t.keys().then(function(o) {
|
|
2794
|
+
return o.length;
|
|
2795
|
+
});
|
|
2796
|
+
return _3(r, e), r;
|
|
2797
|
+
}
|
|
2798
|
+
function Fr(e, t) {
|
|
2799
|
+
var r = this;
|
|
2800
|
+
e = z(e);
|
|
2801
|
+
var o = r.ready().then(function() {
|
|
2802
|
+
var i = r._dbInfo;
|
|
2803
|
+
localStorage.removeItem(i.keyPrefix + e);
|
|
2804
|
+
});
|
|
2805
|
+
return _3(o, t), o;
|
|
2806
|
+
}
|
|
2807
|
+
function Ur(e, t, r) {
|
|
2808
|
+
var o = this;
|
|
2809
|
+
e = z(e);
|
|
2810
|
+
var i = o.ready().then(function() {
|
|
2811
|
+
t === void 0 && (t = null);
|
|
2812
|
+
var n = t;
|
|
2813
|
+
return new m2(function(f3, u2) {
|
|
2814
|
+
var c3 = o._dbInfo;
|
|
2815
|
+
c3.serializer.serialize(t, function(l, d3) {
|
|
2816
|
+
if (d3)
|
|
2817
|
+
u2(d3);
|
|
2818
|
+
else
|
|
2819
|
+
try {
|
|
2820
|
+
localStorage.setItem(c3.keyPrefix + e, l), f3(n);
|
|
2821
|
+
} catch (y3) {
|
|
2822
|
+
(y3.name === "QuotaExceededError" || y3.name === "NS_ERROR_DOM_QUOTA_REACHED") && u2(y3), u2(y3);
|
|
2823
|
+
}
|
|
2824
|
+
});
|
|
2825
|
+
});
|
|
2826
|
+
});
|
|
2827
|
+
return _3(i, r), i;
|
|
2828
|
+
}
|
|
2829
|
+
function Yr(e, t) {
|
|
2830
|
+
if (t = Z2.apply(this, arguments), e = typeof e != "function" && e || {}, !e.name) {
|
|
2831
|
+
var r = this.config();
|
|
2832
|
+
e.name = e.name || r.name, e.storeName = e.storeName || r.storeName;
|
|
2833
|
+
}
|
|
2834
|
+
var o = this, i;
|
|
2835
|
+
return e.name ? i = new m2(function(n) {
|
|
2836
|
+
e.storeName ? n(Ge(e, o._defaultConfig)) : n(e.name + "/");
|
|
2837
|
+
}).then(function(n) {
|
|
2838
|
+
for (var f3 = localStorage.length - 1; f3 >= 0; f3--) {
|
|
2839
|
+
var u2 = localStorage.key(f3);
|
|
2840
|
+
u2.indexOf(n) === 0 && localStorage.removeItem(u2);
|
|
2841
|
+
}
|
|
2842
|
+
}) : i = m2.reject("Invalid arguments"), _3(i, t), i;
|
|
2843
|
+
}
|
|
2844
|
+
var zr = { _driver: "localStorageWrapper", _initStorage: Br, _support: Dr(), iterate: Cr, getItem: Or, setItem: Ur, removeItem: Fr, clear: xr, length: Mr, key: Lr, keys: Pr, dropInstance: Yr }, Wr = function(t, r) {
|
|
2845
|
+
return t === r || typeof t == "number" && typeof r == "number" && isNaN(t) && isNaN(r);
|
|
2846
|
+
}, Kr = function(t, r) {
|
|
2847
|
+
for (var o = t.length, i = 0; i < o; ) {
|
|
2848
|
+
if (Wr(t[i], r))
|
|
2849
|
+
return true;
|
|
2850
|
+
i++;
|
|
2851
|
+
}
|
|
2852
|
+
return false;
|
|
2853
|
+
}, je = Array.isArray || function(e) {
|
|
2854
|
+
return Object.prototype.toString.call(e) === "[object Array]";
|
|
2855
|
+
}, le = {}, Xe2 = {}, ue2 = { INDEXEDDB: cr2, WEBSQL: Rr2, LOCALSTORAGE: zr }, Hr = [ue2.INDEXEDDB._driver, ue2.WEBSQL._driver, ue2.LOCALSTORAGE._driver], me2 = ["dropInstance"], Se2 = ["clear", "getItem", "iterate", "key", "keys", "length", "removeItem", "setItem"].concat(me2), Vr = { description: "", driver: Hr.slice(), name: "localforage", size: 4980736, storeName: "keyvaluepairs", version: 1 };
|
|
2856
|
+
function Gr(e, t) {
|
|
2857
|
+
e[t] = function() {
|
|
2858
|
+
var r = arguments;
|
|
2859
|
+
return e.ready().then(function() {
|
|
2860
|
+
return e[t].apply(e, r);
|
|
2861
|
+
});
|
|
2862
|
+
};
|
|
2863
|
+
}
|
|
2864
|
+
function Ae2() {
|
|
2865
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
2866
|
+
var t = arguments[e];
|
|
2867
|
+
if (t)
|
|
2868
|
+
for (var r in t)
|
|
2869
|
+
t.hasOwnProperty(r) && (je(t[r]) ? arguments[0][r] = t[r].slice() : arguments[0][r] = t[r]);
|
|
2870
|
+
}
|
|
2871
|
+
return arguments[0];
|
|
2872
|
+
}
|
|
2873
|
+
var jr = function() {
|
|
2874
|
+
function e(t) {
|
|
2875
|
+
Y(this, e);
|
|
2876
|
+
for (var r in ue2)
|
|
2877
|
+
if (ue2.hasOwnProperty(r)) {
|
|
2878
|
+
var o = ue2[r], i = o._driver;
|
|
2879
|
+
this[r] = i, le[i] || this.defineDriver(o);
|
|
2880
|
+
}
|
|
2881
|
+
this._defaultConfig = Ae2({}, Vr), this._config = Ae2({}, this._defaultConfig, t), this._driverSet = null, this._initDriver = null, this._ready = false, this._dbInfo = null, this._wrapLibraryMethodsWithReady(), this.setDriver(this._config.driver).catch(function() {
|
|
2882
|
+
});
|
|
2883
|
+
}
|
|
2884
|
+
return e.prototype.config = function(r) {
|
|
2885
|
+
if ((typeof r > "u" ? "undefined" : P2(r)) === "object") {
|
|
2886
|
+
if (this._ready)
|
|
2887
|
+
return new Error("Can't call config() after localforage has been used.");
|
|
2888
|
+
for (var o in r) {
|
|
2889
|
+
if (o === "storeName" && (r[o] = r[o].replace(/\W/g, "_")), o === "version" && typeof r[o] != "number")
|
|
2890
|
+
return new Error("Database version must be a number.");
|
|
2891
|
+
this._config[o] = r[o];
|
|
2892
|
+
}
|
|
2893
|
+
return "driver" in r && r.driver ? this.setDriver(this._config.driver) : true;
|
|
2894
|
+
} else
|
|
2895
|
+
return typeof r == "string" ? this._config[r] : this._config;
|
|
2896
|
+
}, e.prototype.defineDriver = function(r, o, i) {
|
|
2897
|
+
var n = new m2(function(f3, u2) {
|
|
2898
|
+
try {
|
|
2899
|
+
var c3 = r._driver, l = new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");
|
|
2900
|
+
if (!r._driver) {
|
|
2901
|
+
u2(l);
|
|
2902
|
+
return;
|
|
2903
|
+
}
|
|
2904
|
+
for (var d3 = Se2.concat("_initStorage"), y3 = 0, S = d3.length; y3 < S; y3++) {
|
|
2905
|
+
var x2 = d3[y3], C = !Kr(me2, x2);
|
|
2906
|
+
if ((C || r[x2]) && typeof r[x2] != "function") {
|
|
2907
|
+
u2(l);
|
|
2908
|
+
return;
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
var K2 = function() {
|
|
2912
|
+
for (var de2 = function(Jr) {
|
|
2913
|
+
return function() {
|
|
2914
|
+
var $r = new Error("Method " + Jr + " is not implemented by the current driver"), Qe2 = m2.reject($r);
|
|
2915
|
+
return _3(Qe2, arguments[arguments.length - 1]), Qe2;
|
|
2916
|
+
};
|
|
2917
|
+
}, Re = 0, Qr = me2.length; Re < Qr; Re++) {
|
|
2918
|
+
var De2 = me2[Re];
|
|
2919
|
+
r[De2] || (r[De2] = de2(De2));
|
|
2920
|
+
}
|
|
2921
|
+
};
|
|
2922
|
+
K2();
|
|
2923
|
+
var W2 = function(de2) {
|
|
2924
|
+
le[c3] && console.info("Redefining LocalForage driver: " + c3), le[c3] = r, Xe2[c3] = de2, f3();
|
|
2925
|
+
};
|
|
2926
|
+
"_support" in r ? r._support && typeof r._support == "function" ? r._support().then(W2, u2) : W2(!!r._support) : W2(true);
|
|
2927
|
+
} catch (q2) {
|
|
2928
|
+
u2(q2);
|
|
2929
|
+
}
|
|
2930
|
+
});
|
|
2931
|
+
return B2(n, o, i), n;
|
|
2932
|
+
}, e.prototype.driver = function() {
|
|
2933
|
+
return this._driver || null;
|
|
2934
|
+
}, e.prototype.getDriver = function(r, o, i) {
|
|
2935
|
+
var n = le[r] ? m2.resolve(le[r]) : m2.reject(new Error("Driver not found."));
|
|
2936
|
+
return B2(n, o, i), n;
|
|
2937
|
+
}, e.prototype.getSerializer = function(r) {
|
|
2938
|
+
var o = m2.resolve(Ie2);
|
|
2939
|
+
return B2(o, r), o;
|
|
2940
|
+
}, e.prototype.ready = function(r) {
|
|
2941
|
+
var o = this, i = o._driverSet.then(function() {
|
|
2942
|
+
return o._ready === null && (o._ready = o._initDriver()), o._ready;
|
|
2943
|
+
});
|
|
2944
|
+
return B2(i, r, r), i;
|
|
2945
|
+
}, e.prototype.setDriver = function(r, o, i) {
|
|
2946
|
+
var n = this;
|
|
2947
|
+
je(r) || (r = [r]);
|
|
2948
|
+
var f3 = this._getSupportedDrivers(r);
|
|
2949
|
+
function u2() {
|
|
2950
|
+
n._config.driver = n.driver();
|
|
2951
|
+
}
|
|
2952
|
+
function c3(y3) {
|
|
2953
|
+
return n._extend(y3), u2(), n._ready = n._initStorage(n._config), n._ready;
|
|
2954
|
+
}
|
|
2955
|
+
function l(y3) {
|
|
2956
|
+
return function() {
|
|
2957
|
+
var S = 0;
|
|
2958
|
+
function x2() {
|
|
2959
|
+
for (; S < y3.length; ) {
|
|
2960
|
+
var C = y3[S];
|
|
2961
|
+
return S++, n._dbInfo = null, n._ready = null, n.getDriver(C).then(c3).catch(x2);
|
|
2962
|
+
}
|
|
2963
|
+
u2();
|
|
2964
|
+
var K2 = new Error("No available storage method found.");
|
|
2965
|
+
return n._driverSet = m2.reject(K2), n._driverSet;
|
|
2966
|
+
}
|
|
2967
|
+
return x2();
|
|
2968
|
+
};
|
|
2969
|
+
}
|
|
2970
|
+
var d3 = this._driverSet !== null ? this._driverSet.catch(function() {
|
|
2971
|
+
return m2.resolve();
|
|
2972
|
+
}) : m2.resolve();
|
|
2973
|
+
return this._driverSet = d3.then(function() {
|
|
2974
|
+
var y3 = f3[0];
|
|
2975
|
+
return n._dbInfo = null, n._ready = null, n.getDriver(y3).then(function(S) {
|
|
2976
|
+
n._driver = S._driver, u2(), n._wrapLibraryMethodsWithReady(), n._initDriver = l(f3);
|
|
2977
|
+
});
|
|
2978
|
+
}).catch(function() {
|
|
2979
|
+
u2();
|
|
2980
|
+
var y3 = new Error("No available storage method found.");
|
|
2981
|
+
return n._driverSet = m2.reject(y3), n._driverSet;
|
|
2982
|
+
}), B2(this._driverSet, o, i), this._driverSet;
|
|
2983
|
+
}, e.prototype.supports = function(r) {
|
|
2984
|
+
return !!Xe2[r];
|
|
2985
|
+
}, e.prototype._extend = function(r) {
|
|
2986
|
+
Ae2(this, r);
|
|
2987
|
+
}, e.prototype._getSupportedDrivers = function(r) {
|
|
2988
|
+
for (var o = [], i = 0, n = r.length; i < n; i++) {
|
|
2989
|
+
var f3 = r[i];
|
|
2990
|
+
this.supports(f3) && o.push(f3);
|
|
2991
|
+
}
|
|
2992
|
+
return o;
|
|
2993
|
+
}, e.prototype._wrapLibraryMethodsWithReady = function() {
|
|
2994
|
+
for (var r = 0, o = Se2.length; r < o; r++)
|
|
2995
|
+
Gr(this, Se2[r]);
|
|
2996
|
+
}, e.prototype.createInstance = function(r) {
|
|
2997
|
+
return new e(r);
|
|
2998
|
+
}, e;
|
|
2999
|
+
}(), Xr = new jr();
|
|
3000
|
+
D2.exports = Xr;
|
|
3001
|
+
}, { 3: 3 }] }, {}, [4])(4);
|
|
3002
|
+
});
|
|
3003
|
+
});
|
|
3004
|
+
rr2 = $e2((ye, er2) => {
|
|
3005
|
+
(function(b2, A3) {
|
|
3006
|
+
typeof ye == "object" && typeof er2 < "u" ? A3(ye) : typeof define == "function" && define.amd ? define("localforage-driver-memory", ["exports"], A3) : A3(b2.LocalforageDriverMemory = {});
|
|
3007
|
+
})(typeof self < "u" ? self : ye, function(b2) {
|
|
3008
|
+
"use strict";
|
|
3009
|
+
var A3 = "localforage-driver-memory";
|
|
3010
|
+
function R2(a2) {
|
|
3011
|
+
var s = typeof Symbol == "function" && a2[Symbol.iterator], v2 = 0;
|
|
3012
|
+
return s ? s.call(a2) : { next: function() {
|
|
3013
|
+
return a2 && v2 >= a2.length && (a2 = void 0), { value: a2 && a2[v2++], done: !a2 };
|
|
3014
|
+
} };
|
|
3015
|
+
}
|
|
3016
|
+
function L3(a2, s) {
|
|
3017
|
+
a2 = a2 || [], s = s || {};
|
|
3018
|
+
try {
|
|
3019
|
+
return new Blob(a2, s);
|
|
3020
|
+
} catch (w) {
|
|
3021
|
+
if (w.name !== "TypeError")
|
|
3022
|
+
throw w;
|
|
3023
|
+
for (var v2 = typeof BlobBuilder < "u" ? BlobBuilder : typeof MSBlobBuilder < "u" ? MSBlobBuilder : typeof MozBlobBuilder < "u" ? MozBlobBuilder : WebKitBlobBuilder, p2 = new v2(), g3 = 0; g3 < a2.length; g3 += 1)
|
|
3024
|
+
p2.append(a2[g3]);
|
|
3025
|
+
return p2.getBlob(s.type);
|
|
3026
|
+
}
|
|
3027
|
+
}
|
|
3028
|
+
var D2 = /^~~local_forage_type~([^~]+)~/, X = 9, P2 = X + 4, Y = Object.prototype.toString;
|
|
3029
|
+
function I2(a2) {
|
|
3030
|
+
var s = a2.length * 0.75, v2 = a2.length;
|
|
3031
|
+
a2[a2.length - 1] === "=" && (s--, a2[a2.length - 2] === "=" && s--);
|
|
3032
|
+
for (var p2 = new ArrayBuffer(s), g3 = new Uint8Array(p2), w = 0, T3 = 0; w < v2; w += 4) {
|
|
3033
|
+
var G2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a2[w]), fe2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a2[w + 1]), ie2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a2[w + 2]), ce2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a2[w + 3]);
|
|
3034
|
+
g3[T3++] = G2 << 2 | fe2 >> 4, g3[T3++] = (fe2 & 15) << 4 | ie2 >> 2, g3[T3++] = (ie2 & 3) << 6 | ce2 & 63;
|
|
3035
|
+
}
|
|
3036
|
+
return p2;
|
|
3037
|
+
}
|
|
3038
|
+
function M2(a2) {
|
|
3039
|
+
for (var s = new Uint8Array(a2), v2 = "", p2 = 0; p2 < s.length; p2 += 3)
|
|
3040
|
+
v2 += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[s[p2] >> 2], v2 += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(s[p2] & 3) << 4 | s[p2 + 1] >> 4], v2 += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(s[p2 + 1] & 15) << 2 | s[p2 + 2] >> 6], v2 += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[s[p2 + 2] & 63];
|
|
3041
|
+
return s.length % 3 === 2 ? v2 = v2.substring(0, v2.length - 1) + "=" : s.length % 3 === 1 && (v2 = v2.substring(0, v2.length - 2) + "=="), v2;
|
|
3042
|
+
}
|
|
3043
|
+
function H2(a2, s) {
|
|
3044
|
+
var v2 = "";
|
|
3045
|
+
if (a2 && (v2 = Y.call(a2)), a2 && (v2 === "[object ArrayBuffer]" || a2.buffer && Y.call(a2.buffer) === "[object ArrayBuffer]")) {
|
|
3046
|
+
var p2 = void 0, g3 = "__lfsc__:";
|
|
3047
|
+
a2 instanceof ArrayBuffer ? (p2 = a2, g3 += "arbf") : (p2 = a2.buffer, v2 === "[object Int8Array]" ? g3 += "si08" : v2 === "[object Uint8Array]" ? g3 += "ui08" : v2 === "[object Uint8ClampedArray]" ? g3 += "uic8" : v2 === "[object Int16Array]" ? g3 += "si16" : v2 === "[object Uint16Array]" ? g3 += "ur16" : v2 === "[object Int32Array]" ? g3 += "si32" : v2 === "[object Uint32Array]" ? g3 += "ui32" : v2 === "[object Float32Array]" ? g3 += "fl32" : v2 === "[object Float64Array]" ? g3 += "fl64" : s(new Error("Failed to get type for BinaryArray"))), s(g3 + M2(p2));
|
|
3048
|
+
} else if (v2 === "[object Blob]") {
|
|
3049
|
+
var w = new FileReader();
|
|
3050
|
+
w.onload = function() {
|
|
3051
|
+
var T3 = "~~local_forage_type~" + a2.type + "~" + M2(this.result);
|
|
3052
|
+
s("__lfsc__:blob" + T3);
|
|
3053
|
+
}, w.readAsArrayBuffer(a2);
|
|
3054
|
+
} else
|
|
3055
|
+
try {
|
|
3056
|
+
s(JSON.stringify(a2));
|
|
3057
|
+
} catch (T3) {
|
|
3058
|
+
console.error("Couldn't convert value into a JSON string: ", a2), s(null, T3);
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
function $(a2) {
|
|
3062
|
+
if (a2.substring(0, X) !== "__lfsc__:")
|
|
3063
|
+
return JSON.parse(a2);
|
|
3064
|
+
var s = a2.substring(P2), v2 = a2.substring(X, P2), p2;
|
|
3065
|
+
if (v2 === "blob" && D2.test(s)) {
|
|
3066
|
+
var g3 = s.match(D2);
|
|
3067
|
+
p2 = g3[1], s = s.substring(g3[0].length);
|
|
3068
|
+
}
|
|
3069
|
+
var w = I2(s);
|
|
3070
|
+
switch (v2) {
|
|
3071
|
+
case "arbf":
|
|
3072
|
+
return w;
|
|
3073
|
+
case "blob":
|
|
3074
|
+
return L3([w], { type: p2 });
|
|
3075
|
+
case "si08":
|
|
3076
|
+
return new Int8Array(w);
|
|
3077
|
+
case "ui08":
|
|
3078
|
+
return new Uint8Array(w);
|
|
3079
|
+
case "uic8":
|
|
3080
|
+
return new Uint8ClampedArray(w);
|
|
3081
|
+
case "si16":
|
|
3082
|
+
return new Int16Array(w);
|
|
3083
|
+
case "ur16":
|
|
3084
|
+
return new Uint16Array(w);
|
|
3085
|
+
case "si32":
|
|
3086
|
+
return new Int32Array(w);
|
|
3087
|
+
case "ui32":
|
|
3088
|
+
return new Uint32Array(w);
|
|
3089
|
+
case "fl32":
|
|
3090
|
+
return new Float32Array(w);
|
|
3091
|
+
case "fl64":
|
|
3092
|
+
return new Float64Array(w);
|
|
3093
|
+
default:
|
|
3094
|
+
throw new Error("Unkown type: " + v2);
|
|
3095
|
+
}
|
|
3096
|
+
}
|
|
3097
|
+
function m2(a2) {
|
|
3098
|
+
var s, v2;
|
|
3099
|
+
if (a2 === null || typeof a2 != "object" || "isActiveClone" in a2)
|
|
3100
|
+
return a2;
|
|
3101
|
+
var p2 = a2 instanceof Date ? new Date(a2) : a2.constructor();
|
|
3102
|
+
try {
|
|
3103
|
+
for (var g3 = R2(Object.keys(a2)), w = g3.next(); !w.done; w = g3.next()) {
|
|
3104
|
+
var T3 = w.value;
|
|
3105
|
+
Object.prototype.hasOwnProperty.call(a2, T3) && (a2.isActiveClone = null, p2[T3] = m2(a2[T3]), delete a2.isActiveClone);
|
|
3106
|
+
}
|
|
3107
|
+
} catch (G2) {
|
|
3108
|
+
s = { error: G2 };
|
|
3109
|
+
} finally {
|
|
3110
|
+
try {
|
|
3111
|
+
w && !w.done && (v2 = g3.return) && v2.call(g3);
|
|
3112
|
+
} finally {
|
|
3113
|
+
if (s)
|
|
3114
|
+
throw s.error;
|
|
3115
|
+
}
|
|
3116
|
+
}
|
|
3117
|
+
return p2;
|
|
3118
|
+
}
|
|
3119
|
+
function _3(a2, s) {
|
|
3120
|
+
return (a2.name || s.name) + "/" + (a2.storeName || s.storeName) + "/";
|
|
3121
|
+
}
|
|
3122
|
+
function B2(a2, s) {
|
|
3123
|
+
s && a2.then(function(v2) {
|
|
3124
|
+
s(null, v2);
|
|
3125
|
+
}, function(v2) {
|
|
3126
|
+
s(v2);
|
|
3127
|
+
});
|
|
3128
|
+
}
|
|
3129
|
+
function z() {
|
|
3130
|
+
for (var a2 = [], s = 0; s < arguments.length; s++)
|
|
3131
|
+
a2[s] = arguments[s];
|
|
3132
|
+
if (arguments.length && typeof arguments[arguments.length - 1] == "function")
|
|
3133
|
+
return arguments[arguments.length - 1];
|
|
3134
|
+
}
|
|
3135
|
+
function Z2(a2, s) {
|
|
3136
|
+
var v2 = this;
|
|
3137
|
+
if (s = z.apply(this, arguments), a2 = typeof a2 != "function" && a2 || {}, !a2.name) {
|
|
3138
|
+
var p2 = this.config();
|
|
3139
|
+
a2.name = a2.name || p2.name, a2.storeName = a2.storeName || p2.storeName;
|
|
3140
|
+
}
|
|
3141
|
+
var g3;
|
|
3142
|
+
return a2.name ? g3 = new Promise(function(w) {
|
|
3143
|
+
a2.storeName ? w(_3(a2, v2._defaultConfig)) : w(a2.name + "/");
|
|
3144
|
+
}) : g3 = Promise.reject("Invalid arguments"), { promise: g3, callback: s };
|
|
3145
|
+
}
|
|
3146
|
+
function F2(a2) {
|
|
3147
|
+
return typeof a2 != "string" && (console.warn(a2 + " used as a key, but it is not a string."), a2 = String(a2)), a2;
|
|
3148
|
+
}
|
|
3149
|
+
var k3 = { bufferToString: M2, deserialize: $, serialize: H2, stringToBuffer: I2 }, U3 = {}, ae2 = function() {
|
|
3150
|
+
function a2(s) {
|
|
3151
|
+
this.kp = s, this.data = {};
|
|
3152
|
+
}
|
|
3153
|
+
return a2.resolve = function(s) {
|
|
3154
|
+
return U3[s] || (U3[s] = new a2(s)), U3[s];
|
|
3155
|
+
}, a2.prototype.clear = function() {
|
|
3156
|
+
this.data = {};
|
|
3157
|
+
}, a2.prototype.drop = function() {
|
|
3158
|
+
this.clear(), delete U3[this.kp];
|
|
3159
|
+
}, a2.prototype.get = function(s) {
|
|
3160
|
+
return this.data[s];
|
|
3161
|
+
}, a2.prototype.key = function(s) {
|
|
3162
|
+
return this.keys()[s];
|
|
3163
|
+
}, a2.prototype.keys = function() {
|
|
3164
|
+
return Object.keys(this.data);
|
|
3165
|
+
}, a2.prototype.rm = function(s) {
|
|
3166
|
+
delete this.data[s];
|
|
3167
|
+
}, a2.prototype.set = function(s, v2) {
|
|
3168
|
+
this.data[s] = v2;
|
|
3169
|
+
}, a2;
|
|
3170
|
+
}();
|
|
3171
|
+
function re2(a2) {
|
|
3172
|
+
var s = a2 ? m2(a2) : {}, v2 = _3(s, this._defaultConfig), p2 = ae2.resolve(v2);
|
|
3173
|
+
return this._dbInfo = s, this._dbInfo.serializer = k3, this._dbInfo.keyPrefix = v2, this._dbInfo.mStore = p2, Promise.resolve();
|
|
3174
|
+
}
|
|
3175
|
+
function h3(a2) {
|
|
3176
|
+
var s = this, v2 = this.ready().then(function() {
|
|
3177
|
+
s._dbInfo.mStore.clear();
|
|
3178
|
+
});
|
|
3179
|
+
return B2(v2, a2), v2;
|
|
3180
|
+
}
|
|
3181
|
+
function N3(a2, s) {
|
|
3182
|
+
var v2 = Z2.apply(this, arguments), p2 = v2.promise, g3 = v2.callback, w = p2.then(function(T3) {
|
|
3183
|
+
ae2.resolve(T3).drop();
|
|
3184
|
+
});
|
|
3185
|
+
return B2(w, g3), p2;
|
|
3186
|
+
}
|
|
3187
|
+
function E3(a2, s) {
|
|
3188
|
+
var v2 = this;
|
|
3189
|
+
a2 = F2(a2);
|
|
3190
|
+
var p2 = this.ready().then(function() {
|
|
3191
|
+
var g3 = v2._dbInfo.mStore.get(a2);
|
|
3192
|
+
return g3 == null ? null : v2._dbInfo.serializer.deserialize(g3);
|
|
3193
|
+
});
|
|
3194
|
+
return B2(p2, s), p2;
|
|
3195
|
+
}
|
|
3196
|
+
function O3(a2, s) {
|
|
3197
|
+
var v2 = this, p2 = this.ready().then(function() {
|
|
3198
|
+
for (var g3 = v2._dbInfo.mStore, w = g3.keys(), T3 = 0; T3 < w.length; T3++) {
|
|
3199
|
+
var G2 = g3.get(w[T3]);
|
|
3200
|
+
if (G2 && (G2 = v2._dbInfo.serializer.deserialize(G2)), G2 = a2(G2, w[T3], T3 + 1), G2 !== void 0)
|
|
3201
|
+
return G2;
|
|
3202
|
+
}
|
|
3203
|
+
});
|
|
3204
|
+
return B2(p2, s), p2;
|
|
3205
|
+
}
|
|
3206
|
+
function V2(a2, s) {
|
|
3207
|
+
var v2 = this, p2 = this.ready().then(function() {
|
|
3208
|
+
var g3;
|
|
3209
|
+
try {
|
|
3210
|
+
g3 = v2._dbInfo.mStore.key(a2), g3 === void 0 && (g3 = null);
|
|
3211
|
+
} catch {
|
|
3212
|
+
g3 = null;
|
|
3213
|
+
}
|
|
3214
|
+
return g3;
|
|
3215
|
+
});
|
|
3216
|
+
return B2(p2, s), p2;
|
|
3217
|
+
}
|
|
3218
|
+
function j2(a2) {
|
|
3219
|
+
var s = this, v2 = this.ready().then(function() {
|
|
3220
|
+
return s._dbInfo.mStore.keys();
|
|
3221
|
+
});
|
|
3222
|
+
return B2(v2, a2), v2;
|
|
3223
|
+
}
|
|
3224
|
+
function Q2(a2) {
|
|
3225
|
+
var s = this.keys().then(function(v2) {
|
|
3226
|
+
return v2.length;
|
|
3227
|
+
});
|
|
3228
|
+
return B2(s, a2), s;
|
|
3229
|
+
}
|
|
3230
|
+
function J2(a2, s) {
|
|
3231
|
+
var v2 = this;
|
|
3232
|
+
a2 = F2(a2);
|
|
3233
|
+
var p2 = this.ready().then(function() {
|
|
3234
|
+
v2._dbInfo.mStore.rm(a2);
|
|
3235
|
+
});
|
|
3236
|
+
return B2(p2, s), p2;
|
|
3237
|
+
}
|
|
3238
|
+
function ee2(a2, s, v2) {
|
|
3239
|
+
var p2 = this;
|
|
3240
|
+
a2 = F2(a2);
|
|
3241
|
+
var g3 = this.ready().then(function() {
|
|
3242
|
+
s === void 0 && (s = null);
|
|
3243
|
+
var w = s;
|
|
3244
|
+
return new Promise(function(T3, G2) {
|
|
3245
|
+
p2._dbInfo.serializer.serialize(s, function(fe2, ie2) {
|
|
3246
|
+
if (ie2)
|
|
3247
|
+
G2(ie2);
|
|
3248
|
+
else
|
|
3249
|
+
try {
|
|
3250
|
+
p2._dbInfo.mStore.set(a2, fe2), T3(w);
|
|
3251
|
+
} catch (ce2) {
|
|
3252
|
+
G2(ce2);
|
|
3253
|
+
}
|
|
3254
|
+
});
|
|
3255
|
+
});
|
|
3256
|
+
});
|
|
3257
|
+
return B2(g3, v2), g3;
|
|
3258
|
+
}
|
|
3259
|
+
var oe = true;
|
|
3260
|
+
b2._support = oe, b2._driver = A3, b2._initStorage = re2, b2.clear = h3, b2.dropInstance = N3, b2.getItem = E3, b2.iterate = O3, b2.key = V2, b2.keys = j2, b2.length = Q2, b2.removeItem = J2, b2.setItem = ee2, Object.defineProperty(b2, "__esModule", { value: true });
|
|
3261
|
+
});
|
|
3262
|
+
});
|
|
3263
|
+
ge2 = Ze2(ke2());
|
|
3264
|
+
Te2 = Ze2(rr2());
|
|
3265
|
+
at2 = { display: "none", position: "fixed", top: "0", right: "0", width: "100%", height: "100%", borderRadius: "0", border: "none", zIndex: "2147483647" };
|
|
3266
|
+
pe2 = class extends Be {
|
|
3267
|
+
constructor() {
|
|
3268
|
+
super(...arguments);
|
|
3269
|
+
this.activeElement = null;
|
|
3270
|
+
}
|
|
3271
|
+
init() {
|
|
3272
|
+
this.test = "hello", this.iframe = new Promise((R2) => {
|
|
3273
|
+
let L3 = () => {
|
|
3274
|
+
if (ut2(encodeURIComponent(this.parameters)))
|
|
3275
|
+
qr().log();
|
|
3276
|
+
else {
|
|
3277
|
+
let D2 = document.createElement("iframe");
|
|
3278
|
+
D2.classList.add("magic-iframe"), D2.dataset.magicIframeLabel = Je(this.endpoint).host, D2.title = "Secure Modal", D2.src = Je(`/send?params=${encodeURIComponent(this.parameters)}`, this.endpoint).href, D2.allow = "clipboard-read; clipboard-write", ft2(D2), document.body.appendChild(D2), R2(D2);
|
|
3279
|
+
}
|
|
3280
|
+
};
|
|
3281
|
+
["loaded", "interactive", "complete"].includes(document.readyState) ? L3() : window.addEventListener("load", L3, false);
|
|
3282
|
+
}), window.addEventListener("message", (R2) => {
|
|
3283
|
+
var L3;
|
|
3284
|
+
if (R2.origin === this.endpoint && R2.data && R2.data.msgType && this.messageHandlers.size) {
|
|
3285
|
+
R2.data.response = (L3 = R2.data.response) != null ? L3 : {};
|
|
3286
|
+
for (let D2 of this.messageHandlers.values())
|
|
3287
|
+
D2(R2);
|
|
3288
|
+
}
|
|
3289
|
+
});
|
|
3290
|
+
}
|
|
3291
|
+
showOverlay() {
|
|
3292
|
+
return se2(this, null, function* () {
|
|
3293
|
+
let R2 = yield this.iframe;
|
|
3294
|
+
R2.style.display = "block", this.activeElement = document.activeElement, R2.focus();
|
|
3295
|
+
});
|
|
3296
|
+
}
|
|
3297
|
+
hideOverlay() {
|
|
3298
|
+
return se2(this, null, function* () {
|
|
3299
|
+
var L3;
|
|
3300
|
+
let R2 = yield this.iframe;
|
|
3301
|
+
R2.style.display = "none", (L3 = this.activeElement) != null && L3.focus && this.activeElement.focus(), this.activeElement = null;
|
|
3302
|
+
});
|
|
3303
|
+
}
|
|
3304
|
+
_post(R2) {
|
|
3305
|
+
return se2(this, null, function* () {
|
|
3306
|
+
let L3 = yield this.iframe;
|
|
3307
|
+
if (L3 && L3.contentWindow)
|
|
3308
|
+
L3.contentWindow.postMessage(R2, this.endpoint);
|
|
3309
|
+
else
|
|
3310
|
+
throw mt();
|
|
3311
|
+
});
|
|
3312
|
+
}
|
|
3313
|
+
};
|
|
3314
|
+
bt = Kn($e, { platform: "web", sdkName: "magic-sdk", version: "28.0.3", defaultEndpoint: "https://auth.magic.link/", ViewController: pe2, configureStorage: () => se2(void 0, null, function* () {
|
|
3315
|
+
let b2 = ge2.default.createInstance({ name: "MagicAuthLocalStorageDB", storeName: "MagicAuthLocalStorage" });
|
|
3316
|
+
return yield b2.defineDriver(Te2), yield b2.setDriver([ge2.default.INDEXEDDB, ge2.default.LOCALSTORAGE, Te2._driver]), b2;
|
|
3317
|
+
}) });
|
|
3318
|
+
}
|
|
3319
|
+
});
|
|
3320
|
+
|
|
3321
|
+
// ../../node_modules/.pnpm/@magic-ext+algorand@23.0.2/node_modules/@magic-ext/algorand/dist/es/index.mjs
|
|
3322
|
+
var es_exports2 = {};
|
|
3323
|
+
__export(es_exports2, {
|
|
3324
|
+
AlgorandExtension: () => c2
|
|
3325
|
+
});
|
|
3326
|
+
var a, c2;
|
|
3327
|
+
var init_es5 = __esm({
|
|
3328
|
+
"../../node_modules/.pnpm/@magic-ext+algorand@23.0.2/node_modules/@magic-ext/algorand/dist/es/index.mjs"() {
|
|
3329
|
+
"use strict";
|
|
3330
|
+
init_es3();
|
|
3331
|
+
a = (s, e, n) => new Promise((g3, o) => {
|
|
3332
|
+
var l = (r) => {
|
|
3333
|
+
try {
|
|
3334
|
+
i(n.next(r));
|
|
3335
|
+
} catch (t) {
|
|
3336
|
+
o(t);
|
|
3337
|
+
}
|
|
3338
|
+
}, u2 = (r) => {
|
|
3339
|
+
try {
|
|
3340
|
+
i(n.throw(r));
|
|
3341
|
+
} catch (t) {
|
|
3342
|
+
o(t);
|
|
3343
|
+
}
|
|
3344
|
+
}, i = (r) => r.done ? g3(r.value) : Promise.resolve(r.value).then(l, u2);
|
|
3345
|
+
i((n = n.apply(s, e)).next());
|
|
3346
|
+
});
|
|
3347
|
+
c2 = class extends q.Internal {
|
|
3348
|
+
constructor(n) {
|
|
3349
|
+
super();
|
|
3350
|
+
this.algorandConfig = n;
|
|
3351
|
+
this.name = "algod";
|
|
3352
|
+
this.config = {};
|
|
3353
|
+
this.config = { rpcUrl: n.rpcUrl, chainType: "ALOGD" };
|
|
3354
|
+
}
|
|
3355
|
+
signTransaction(n) {
|
|
3356
|
+
return a(this, null, function* () {
|
|
3357
|
+
return this.request(this.utils.createJsonRpcRequestPayload("algod_signTransaction", n));
|
|
3358
|
+
});
|
|
3359
|
+
}
|
|
3360
|
+
signBid(n) {
|
|
3361
|
+
return a(this, null, function* () {
|
|
3362
|
+
return this.request(this.utils.createJsonRpcRequestPayload("algod_signBid", n));
|
|
3363
|
+
});
|
|
3364
|
+
}
|
|
3365
|
+
getWallet() {
|
|
3366
|
+
return a(this, null, function* () {
|
|
3367
|
+
return this.request(this.utils.createJsonRpcRequestPayload("algod_getWallet", []));
|
|
3368
|
+
});
|
|
3369
|
+
}
|
|
3370
|
+
signGroupTransaction(n) {
|
|
3371
|
+
return a(this, null, function* () {
|
|
3372
|
+
return this.request(this.utils.createJsonRpcRequestPayload("algod_signGroupTransaction", n));
|
|
3373
|
+
});
|
|
3374
|
+
}
|
|
3375
|
+
signGroupTransactionV2(n) {
|
|
3376
|
+
return a(this, null, function* () {
|
|
3377
|
+
return this.request(this.utils.createJsonRpcRequestPayload("algod_signGroupTransactionV2", n));
|
|
3378
|
+
});
|
|
3379
|
+
}
|
|
3380
|
+
};
|
|
3381
|
+
}
|
|
3382
|
+
});
|
|
29
3383
|
|
|
30
3384
|
// src/index.ts
|
|
31
3385
|
var src_exports = {};
|
|
@@ -34,6 +3388,7 @@ __export(src_exports, {
|
|
|
34
3388
|
DeflyWallet: () => DeflyWallet,
|
|
35
3389
|
ExodusWallet: () => ExodusWallet,
|
|
36
3390
|
KmdWallet: () => KmdWallet,
|
|
3391
|
+
MagicAuth: () => MagicAuth,
|
|
37
3392
|
MnemonicWallet: () => MnemonicWallet,
|
|
38
3393
|
NetworkId: () => NetworkId,
|
|
39
3394
|
PeraWallet: () => PeraWallet,
|
|
@@ -46,8 +3401,8 @@ __export(src_exports, {
|
|
|
46
3401
|
module.exports = __toCommonJS(src_exports);
|
|
47
3402
|
|
|
48
3403
|
// src/manager.ts
|
|
49
|
-
var
|
|
50
|
-
var
|
|
3404
|
+
var import_store11 = require("@tanstack/store");
|
|
3405
|
+
var import_algosdk11 = __toESM(require("algosdk"), 1);
|
|
51
3406
|
|
|
52
3407
|
// src/network.ts
|
|
53
3408
|
var NetworkId = /* @__PURE__ */ ((NetworkId2) => {
|
|
@@ -67,18 +3422,25 @@ function isNetworkConfigMap(config) {
|
|
|
67
3422
|
var nodeServerMap = {
|
|
68
3423
|
["mainnet" /* MAINNET */]: "https://mainnet-api.algonode.cloud",
|
|
69
3424
|
["testnet" /* TESTNET */]: "https://testnet-api.algonode.cloud",
|
|
70
|
-
["betanet" /* BETANET */]: "https://betanet-api.algonode.cloud"
|
|
71
|
-
["localnet" /* LOCALNET */]: "http://localhost"
|
|
3425
|
+
["betanet" /* BETANET */]: "https://betanet-api.algonode.cloud"
|
|
72
3426
|
};
|
|
73
3427
|
function createDefaultNetworkConfig() {
|
|
74
|
-
|
|
75
|
-
|
|
3428
|
+
const localnetConfig = {
|
|
3429
|
+
token: "a".repeat(64),
|
|
3430
|
+
baseServer: "http://localhost",
|
|
3431
|
+
port: 4001,
|
|
3432
|
+
headers: {}
|
|
3433
|
+
};
|
|
3434
|
+
return Object.values(NetworkId).reduce((configMap, value) => {
|
|
3435
|
+
const network = value;
|
|
3436
|
+
const isLocalnet = network === "localnet" /* LOCALNET */;
|
|
3437
|
+
configMap[network] = isLocalnet ? localnetConfig : {
|
|
76
3438
|
token: "",
|
|
77
|
-
baseServer: nodeServerMap[
|
|
3439
|
+
baseServer: nodeServerMap[network],
|
|
78
3440
|
port: "",
|
|
79
3441
|
headers: {}
|
|
80
3442
|
};
|
|
81
|
-
return
|
|
3443
|
+
return configMap;
|
|
82
3444
|
}, {});
|
|
83
3445
|
}
|
|
84
3446
|
var caipChainId = {
|
|
@@ -125,17 +3487,17 @@ var BaseWallet = class {
|
|
|
125
3487
|
this.metadata = { ...ctor.defaultMetadata, ...metadata };
|
|
126
3488
|
}
|
|
127
3489
|
static defaultMetadata = { name: "Base Wallet", icon: "" };
|
|
128
|
-
setActive() {
|
|
3490
|
+
setActive = () => {
|
|
129
3491
|
console.info(`[Wallet] Set active wallet: ${this.id}`);
|
|
130
3492
|
setActiveWallet(this.store, { walletId: this.id });
|
|
131
|
-
}
|
|
132
|
-
setActiveAccount(account) {
|
|
3493
|
+
};
|
|
3494
|
+
setActiveAccount = (account) => {
|
|
133
3495
|
console.info(`[Wallet] Set active account: ${account}`);
|
|
134
3496
|
setActiveAccount(this.store, {
|
|
135
3497
|
walletId: this.id,
|
|
136
3498
|
address: account
|
|
137
3499
|
});
|
|
138
|
-
}
|
|
3500
|
+
};
|
|
139
3501
|
// ---------- Derived Properties ------------------------------------ //
|
|
140
3502
|
get name() {
|
|
141
3503
|
return this.id.toUpperCase();
|
|
@@ -176,10 +3538,10 @@ var BaseWallet = class {
|
|
|
176
3538
|
};
|
|
177
3539
|
|
|
178
3540
|
// src/wallets/defly.ts
|
|
179
|
-
var
|
|
3541
|
+
var import_algosdk10 = __toESM(require("algosdk"), 1);
|
|
180
3542
|
|
|
181
3543
|
// src/utils.ts
|
|
182
|
-
var
|
|
3544
|
+
var import_algosdk9 = __toESM(require("algosdk"), 1);
|
|
183
3545
|
|
|
184
3546
|
// src/wallets/types.ts
|
|
185
3547
|
var WalletId = /* @__PURE__ */ ((WalletId2) => {
|
|
@@ -188,6 +3550,7 @@ var WalletId = /* @__PURE__ */ ((WalletId2) => {
|
|
|
188
3550
|
WalletId2["KIBISIS"] = "kibisis";
|
|
189
3551
|
WalletId2["KMD"] = "kmd";
|
|
190
3552
|
WalletId2["LUTE"] = "lute";
|
|
3553
|
+
WalletId2["MAGIC"] = "magic";
|
|
191
3554
|
WalletId2["MNEMONIC"] = "mnemonic";
|
|
192
3555
|
WalletId2["PERA"] = "pera";
|
|
193
3556
|
WalletId2["WALLETCONNECT"] = "walletconnect";
|
|
@@ -223,7 +3586,7 @@ var ExodusWallet = class extends BaseWallet {
|
|
|
223
3586
|
this.client = client;
|
|
224
3587
|
return client;
|
|
225
3588
|
}
|
|
226
|
-
async
|
|
3589
|
+
connect = async () => {
|
|
227
3590
|
console.info("[ExodusWallet] Connecting...");
|
|
228
3591
|
try {
|
|
229
3592
|
const client = this.client || await this.initializeClient();
|
|
@@ -252,12 +3615,12 @@ var ExodusWallet = class extends BaseWallet {
|
|
|
252
3615
|
}
|
|
253
3616
|
return [];
|
|
254
3617
|
}
|
|
255
|
-
}
|
|
256
|
-
async
|
|
3618
|
+
};
|
|
3619
|
+
disconnect = async () => {
|
|
257
3620
|
console.info("[ExodusWallet] Disconnecting...");
|
|
258
3621
|
this.onDisconnect();
|
|
259
|
-
}
|
|
260
|
-
async
|
|
3622
|
+
};
|
|
3623
|
+
resumeSession = async () => {
|
|
261
3624
|
try {
|
|
262
3625
|
const state = this.store.state;
|
|
263
3626
|
const walletState = state.wallets[this.id];
|
|
@@ -273,7 +3636,7 @@ var ExodusWallet = class extends BaseWallet {
|
|
|
273
3636
|
console.error(`[ExodusWallet] Error resuming session: ${error.message}`);
|
|
274
3637
|
this.onDisconnect();
|
|
275
3638
|
}
|
|
276
|
-
}
|
|
3639
|
+
};
|
|
277
3640
|
signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
|
|
278
3641
|
if (!this.client) {
|
|
279
3642
|
throw new Error("[ExodusWallet] Client not initialized!");
|
|
@@ -289,7 +3652,7 @@ var ExodusWallet = class extends BaseWallet {
|
|
|
289
3652
|
const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
|
|
290
3653
|
const txnBuffer = msgpackTxnGroup[idx];
|
|
291
3654
|
const txn = isSigned ? import_algosdk.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk.default.decodeUnsignedTransaction(txnBuffer);
|
|
292
|
-
const txnBase64 =
|
|
3655
|
+
const txnBase64 = byteArrayToBase64(txn.toByte());
|
|
293
3656
|
if (shouldSign) {
|
|
294
3657
|
txnsToSign.push({ txn: txnBase64 });
|
|
295
3658
|
signedIndexes.push(idx);
|
|
@@ -299,7 +3662,7 @@ var ExodusWallet = class extends BaseWallet {
|
|
|
299
3662
|
});
|
|
300
3663
|
const signTxnsResult = await this.client.signTxns(txnsToSign);
|
|
301
3664
|
const signedTxnsBase64 = signTxnsResult.filter(Boolean);
|
|
302
|
-
const signedTxns = signedTxnsBase64.map((txn) =>
|
|
3665
|
+
const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
|
|
303
3666
|
const txnGroupSigned = mergeSignedTxnsWithGroup(
|
|
304
3667
|
signedTxns,
|
|
305
3668
|
msgpackTxnGroup,
|
|
@@ -313,7 +3676,7 @@ var ExodusWallet = class extends BaseWallet {
|
|
|
313
3676
|
throw new Error("[ExodusWallet] Client not initialized!");
|
|
314
3677
|
}
|
|
315
3678
|
const txnsToSign = txnGroup.reduce((acc, txn, idx) => {
|
|
316
|
-
const txnBase64 =
|
|
3679
|
+
const txnBase64 = byteArrayToBase64(txn.toByte());
|
|
317
3680
|
if (indexesToSign.includes(idx)) {
|
|
318
3681
|
acc.push({ txn: txnBase64 });
|
|
319
3682
|
} else {
|
|
@@ -323,7 +3686,7 @@ var ExodusWallet = class extends BaseWallet {
|
|
|
323
3686
|
}, []);
|
|
324
3687
|
const signTxnsResult = await this.client.signTxns(txnsToSign);
|
|
325
3688
|
const signedTxnsBase64 = signTxnsResult.filter(Boolean);
|
|
326
|
-
const signedTxns = signedTxnsBase64.map((txn) =>
|
|
3689
|
+
const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
|
|
327
3690
|
return signedTxns;
|
|
328
3691
|
};
|
|
329
3692
|
};
|
|
@@ -530,7 +3893,7 @@ var KibisisWallet = class _KibisisWallet extends BaseWallet {
|
|
|
530
3893
|
};
|
|
531
3894
|
}
|
|
532
3895
|
}
|
|
533
|
-
async
|
|
3896
|
+
connect = async () => {
|
|
534
3897
|
console.info("[KibisisWallet] Connecting...");
|
|
535
3898
|
try {
|
|
536
3899
|
await this.getSupportedMethods();
|
|
@@ -552,14 +3915,14 @@ var KibisisWallet = class _KibisisWallet extends BaseWallet {
|
|
|
552
3915
|
console.error(`[KibisisWallet] Error connecting: ${error.message}`);
|
|
553
3916
|
return [];
|
|
554
3917
|
}
|
|
555
|
-
}
|
|
556
|
-
async
|
|
3918
|
+
};
|
|
3919
|
+
disconnect = async () => {
|
|
557
3920
|
console.info("[KibisisWallet] Disconnecting...");
|
|
558
3921
|
this.onDisconnect();
|
|
559
|
-
}
|
|
560
|
-
resumeSession() {
|
|
3922
|
+
};
|
|
3923
|
+
resumeSession = () => {
|
|
561
3924
|
return Promise.resolve();
|
|
562
|
-
}
|
|
3925
|
+
};
|
|
563
3926
|
signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
|
|
564
3927
|
try {
|
|
565
3928
|
await this.getSupportedMethods();
|
|
@@ -574,7 +3937,7 @@ var KibisisWallet = class _KibisisWallet extends BaseWallet {
|
|
|
574
3937
|
const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
|
|
575
3938
|
const txnBuffer = msgpackTxnGroup[idx];
|
|
576
3939
|
const txn = isSigned ? import_algosdk2.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk2.default.decodeUnsignedTransaction(txnBuffer);
|
|
577
|
-
const txnBase64 =
|
|
3940
|
+
const txnBase64 = byteArrayToBase64(txn.toByte());
|
|
578
3941
|
if (shouldSign) {
|
|
579
3942
|
txnsToSign.push({ txn: txnBase64 });
|
|
580
3943
|
signedIndexes.push(idx);
|
|
@@ -584,7 +3947,7 @@ var KibisisWallet = class _KibisisWallet extends BaseWallet {
|
|
|
584
3947
|
});
|
|
585
3948
|
const signTxnsResult = await this.signTxns(txnsToSign);
|
|
586
3949
|
const signedTxnsBase64 = signTxnsResult.filter(Boolean);
|
|
587
|
-
const signedTxns = signedTxnsBase64.map((txn) =>
|
|
3950
|
+
const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
|
|
588
3951
|
const txnGroupSigned = mergeSignedTxnsWithGroup(
|
|
589
3952
|
signedTxns,
|
|
590
3953
|
msgpackTxnGroup,
|
|
@@ -602,7 +3965,7 @@ var KibisisWallet = class _KibisisWallet extends BaseWallet {
|
|
|
602
3965
|
transactionSigner = async (txnGroup, indexesToSign) => {
|
|
603
3966
|
try {
|
|
604
3967
|
const txnsToSign = txnGroup.reduce((acc, txn, idx) => {
|
|
605
|
-
const txnBase64 =
|
|
3968
|
+
const txnBase64 = byteArrayToBase64(txn.toByte());
|
|
606
3969
|
if (indexesToSign.includes(idx)) {
|
|
607
3970
|
acc.push({ txn: txnBase64 });
|
|
608
3971
|
} else {
|
|
@@ -612,7 +3975,7 @@ var KibisisWallet = class _KibisisWallet extends BaseWallet {
|
|
|
612
3975
|
}, []);
|
|
613
3976
|
const signTxnsResult = await this.signTxns(txnsToSign);
|
|
614
3977
|
const signedTxnsBase64 = signTxnsResult.filter(Boolean);
|
|
615
|
-
const signedTxns = signedTxnsBase64.map((txn) =>
|
|
3978
|
+
const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
|
|
616
3979
|
return signedTxns;
|
|
617
3980
|
} catch (error) {
|
|
618
3981
|
console.error(
|
|
@@ -660,7 +4023,7 @@ var KmdWallet = class extends BaseWallet {
|
|
|
660
4023
|
this.client = client;
|
|
661
4024
|
return client;
|
|
662
4025
|
}
|
|
663
|
-
async
|
|
4026
|
+
connect = async () => {
|
|
664
4027
|
console.info("[KmdWallet] Connecting...");
|
|
665
4028
|
try {
|
|
666
4029
|
if (!this.client) {
|
|
@@ -690,11 +4053,11 @@ var KmdWallet = class extends BaseWallet {
|
|
|
690
4053
|
console.error("[KmdWallet] Error connecting:", error);
|
|
691
4054
|
return [];
|
|
692
4055
|
}
|
|
693
|
-
}
|
|
694
|
-
async
|
|
4056
|
+
};
|
|
4057
|
+
disconnect = async () => {
|
|
695
4058
|
console.info("[KmdWallet] Disconnecting...");
|
|
696
4059
|
this.onDisconnect();
|
|
697
|
-
}
|
|
4060
|
+
};
|
|
698
4061
|
resumeSession = async () => {
|
|
699
4062
|
try {
|
|
700
4063
|
const state = this.store.state;
|
|
@@ -854,7 +4217,7 @@ var LuteWallet = class extends BaseWallet {
|
|
|
854
4217
|
const genesisId = `${genesis.network}-${genesis.id}`;
|
|
855
4218
|
return genesisId;
|
|
856
4219
|
}
|
|
857
|
-
async
|
|
4220
|
+
connect = async () => {
|
|
858
4221
|
console.info("[LuteWallet] Connecting...");
|
|
859
4222
|
try {
|
|
860
4223
|
const client = this.client || await this.initializeClient();
|
|
@@ -880,12 +4243,12 @@ var LuteWallet = class extends BaseWallet {
|
|
|
880
4243
|
console.error(`[LuteWallet] Error connecting: ${error.message}`);
|
|
881
4244
|
return [];
|
|
882
4245
|
}
|
|
883
|
-
}
|
|
884
|
-
async
|
|
4246
|
+
};
|
|
4247
|
+
disconnect = async () => {
|
|
885
4248
|
console.info("[LuteWallet] Disconnecting...");
|
|
886
4249
|
this.onDisconnect();
|
|
887
|
-
}
|
|
888
|
-
async
|
|
4250
|
+
};
|
|
4251
|
+
resumeSession = async () => {
|
|
889
4252
|
try {
|
|
890
4253
|
const state = this.store.state;
|
|
891
4254
|
const walletState = state.wallets[this.id];
|
|
@@ -898,7 +4261,7 @@ var LuteWallet = class extends BaseWallet {
|
|
|
898
4261
|
console.error(`[LuteWallet] Error resuming session: ${error.message}`);
|
|
899
4262
|
this.onDisconnect();
|
|
900
4263
|
}
|
|
901
|
-
}
|
|
4264
|
+
};
|
|
902
4265
|
signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
|
|
903
4266
|
try {
|
|
904
4267
|
if (!this.client) {
|
|
@@ -915,7 +4278,7 @@ var LuteWallet = class extends BaseWallet {
|
|
|
915
4278
|
const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
|
|
916
4279
|
const txnBuffer = msgpackTxnGroup[idx];
|
|
917
4280
|
const txn = isSigned ? import_algosdk4.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk4.default.decodeUnsignedTransaction(txnBuffer);
|
|
918
|
-
const txnBase64 =
|
|
4281
|
+
const txnBase64 = byteArrayToBase64(txn.toByte());
|
|
919
4282
|
if (shouldSign) {
|
|
920
4283
|
txnsToSign.push({ txn: txnBase64 });
|
|
921
4284
|
signedIndexes.push(idx);
|
|
@@ -945,7 +4308,7 @@ var LuteWallet = class extends BaseWallet {
|
|
|
945
4308
|
throw new Error("[LuteWallet] Client not initialized!");
|
|
946
4309
|
}
|
|
947
4310
|
const txnsToSign = txnGroup.reduce((acc, txn, idx) => {
|
|
948
|
-
const txnBase64 =
|
|
4311
|
+
const txnBase64 = byteArrayToBase64(txn.toByte());
|
|
949
4312
|
if (indexesToSign.includes(idx)) {
|
|
950
4313
|
acc.push({ txn: txnBase64 });
|
|
951
4314
|
} else {
|
|
@@ -965,9 +4328,195 @@ var LuteWallet = class extends BaseWallet {
|
|
|
965
4328
|
};
|
|
966
4329
|
};
|
|
967
4330
|
|
|
968
|
-
// src/wallets/
|
|
4331
|
+
// src/wallets/magic.ts
|
|
969
4332
|
var import_algosdk5 = __toESM(require("algosdk"), 1);
|
|
970
|
-
var icon4 =
|
|
4333
|
+
var icon4 = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCEtLSBHZW5lcmF0ZWQgYnkgUGl4ZWxtYXRvciBQcm8gMy40LjMgLS0+Cjxzdmcgd2lkdGg9IjQ3IiBoZWlnaHQ9IjQ3IiB2aWV3Qm94PSIwIDAgNDcgNDciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgICA8cGF0aCBpZD0iUGF0aCIgZmlsbD0iIzY4NTFmZiIgZmlsbC1ydWxlPSJldmVub2RkIiBzdHJva2U9Im5vbmUiIGQ9Ik0gMjMuOTYwODYxIDEuODA3NjkgQyAyNS44MzUwNzcgNC4xMDMxNTMgMjcuOTAyMjE2IDYuMjM0ODkgMzAuMTM3NTM5IDguMTc4MTY5IEMgMjguNjQ3OTY4IDEzLjAwOTMyMyAyNy44NDYwOTIgMTguMTQyMDk0IDI3Ljg0NjA5MiAyMy40NjIxNTQgQyAyNy44NDYwOTIgMjguNzgyMzA3IDI4LjY0ODA2MiAzMy45MTUxNjkgMzAuMTM3NjMgMzguNzQ2MzY4IEMgMjcuOTAyMjE2IDQwLjY4OTcyNCAyNS44MzUwNzcgNDIuODIxNDc2IDIzLjk2MDg2MSA0NS4xMTY5ODUgQyAyMi4wODY1NTQgNDIuODIxNDc2IDIwLjAxOTQxNSA0MC42ODk2MzIgMTcuNzgzOTk4IDM4Ljc0NjM2OCBDIDE5LjI3MzQ3NiAzMy45MTUxNjkgMjAuMDc1NDQ1IDI4Ljc4MjQgMjAuMDc1NDQ1IDIzLjQ2MjMzNyBDIDIwLjA3NTQ0NSAxOC4xNDIyNzcgMTkuMjczNDc2IDEzLjAwOTUwNiAxNy43ODM5OTggOC4xNzgzMTggQyAyMC4wMTk0MTUgNi4yMzUwMDEgMjIuMDg2NTU0IDQuMTAzMjEgMjMuOTYwODYxIDEuODA3NjkgWiBNIDEzLjUxMTQyNyAzNS40MDY0MDMgQyAxMS4xNDUxMzkgMzMuNzQ3ODE0IDguNjMzODE2IDMyLjI4MjA2MyA2LjAwMDI2OSAzMS4wMzE5MzcgQyA2LjczMDc3NiAyOC42Mzc0NzYgNy4xMjM3NTQgMjYuMDk1NzgzIDcuMTIzNzU0IDIzLjQ2MjQyOSBDIDcuMTIzNzU0IDIwLjgyODg5MiA2LjczMDc2MiAxOC4yODcyMDEgNi4wMDAyMzUgMTUuODkyNzM4IEMgOC42MzM4MTYgMTQuNjQyNjE2IDExLjE0NTE3NSAxMy4xNzY4NjEgMTMuNTExNTAxIDExLjUxODI3NiBDIDE0LjQxNjMxMSAxNS4zNTI1NTQgMTQuODk1MDc0IDE5LjM1MTQxNCAxNC44OTUwNzQgMjMuNDYyMTU0IEMgMTQuODk1MDc0IDI3LjU3Mjk4NSAxNC40MTYyODMgMzEuNTcxOTM4IDEzLjUxMTQyNyAzNS40MDY0MDMgWiBNIDMzLjAyNzA0NiAyMy40NjIzMzcgQyAzMy4wMjcwNDYgMjcuNTcyOTg1IDMzLjUwNTc1MyAzMS41NzE4NDYgMzQuNDEwNTUzIDM1LjQwNjEyNCBDIDM2Ljc3Njg1OSAzMy43NDc2MzEgMzkuMjg4MDk0IDMyLjI4MTg3NiA0MS45MjE1MzkgMzEuMDMxODQ1IEMgNDEuMTkxMDE3IDI4LjYzNzM4NCA0MC43OTgwNjEgMjYuMDk1NjkyIDQwLjc5ODA2MSAyMy40NjIyNDYgQyA0MC43OTgwNjEgMjAuODI4OCA0MS4xOTEwMTcgMTguMjg3MjAxIDQxLjkyMTUzOSAxNS44OTI4MyBDIDM5LjI4ODA5NCAxNC42NDI3MDggMzYuNzc2NzY4IDEzLjE3NzA0OCAzNC40MTA1NTMgMTEuNTE4NTU1IEMgMzMuNTA1NzUzIDE1LjM1MjgzMSAzMy4wMjcwNDYgMTkuMzUxNjkyIDMzLjAyNzA0NiAyMy40NjIzMzcgWiIvPgo8L3N2Zz4K";
|
|
4334
|
+
var MagicAuth = class extends BaseWallet {
|
|
4335
|
+
client = null;
|
|
4336
|
+
options;
|
|
4337
|
+
store;
|
|
4338
|
+
userInfo = null;
|
|
4339
|
+
constructor({
|
|
4340
|
+
id,
|
|
4341
|
+
store,
|
|
4342
|
+
subscribe,
|
|
4343
|
+
getAlgodClient,
|
|
4344
|
+
options,
|
|
4345
|
+
metadata = {}
|
|
4346
|
+
}) {
|
|
4347
|
+
super({ id, metadata, getAlgodClient, store, subscribe });
|
|
4348
|
+
if (!options?.apiKey) {
|
|
4349
|
+
throw new Error("[Magic] Missing required option: apiKey");
|
|
4350
|
+
}
|
|
4351
|
+
this.options = options;
|
|
4352
|
+
this.store = store;
|
|
4353
|
+
}
|
|
4354
|
+
static defaultMetadata = { name: "Magic", icon: icon4 };
|
|
4355
|
+
async initializeClient() {
|
|
4356
|
+
console.info("[Magic] Initializing client...");
|
|
4357
|
+
const Magic = (await Promise.resolve().then(() => (init_es4(), es_exports))).Magic;
|
|
4358
|
+
const AlgorandExtension = (await Promise.resolve().then(() => (init_es5(), es_exports2))).AlgorandExtension;
|
|
4359
|
+
const client = new Magic(this.options.apiKey, {
|
|
4360
|
+
extensions: {
|
|
4361
|
+
algorand: new AlgorandExtension({
|
|
4362
|
+
rpcUrl: ""
|
|
4363
|
+
})
|
|
4364
|
+
}
|
|
4365
|
+
});
|
|
4366
|
+
this.client = client;
|
|
4367
|
+
return client;
|
|
4368
|
+
}
|
|
4369
|
+
connect = async (args) => {
|
|
4370
|
+
console.info("[Magic] Connecting...");
|
|
4371
|
+
if (!args?.email || typeof args.email !== "string") {
|
|
4372
|
+
throw new Error("Magic Link provider requires an email (string) to connect");
|
|
4373
|
+
}
|
|
4374
|
+
const { email } = args;
|
|
4375
|
+
const client = this.client || await this.initializeClient();
|
|
4376
|
+
console.info(`[Magic] Logging in ${email}...`);
|
|
4377
|
+
await client.auth.loginWithMagicLink({ email });
|
|
4378
|
+
const userInfo = await client.user.getInfo();
|
|
4379
|
+
if (!userInfo) {
|
|
4380
|
+
throw new Error("User info not found!");
|
|
4381
|
+
}
|
|
4382
|
+
if (!userInfo.publicAddress) {
|
|
4383
|
+
throw new Error("No account found!");
|
|
4384
|
+
}
|
|
4385
|
+
this.userInfo = userInfo;
|
|
4386
|
+
console.info(`[Magic] Login successful`, userInfo);
|
|
4387
|
+
const walletAccount = {
|
|
4388
|
+
name: userInfo.email ?? "Magic Wallet 1",
|
|
4389
|
+
address: userInfo.publicAddress
|
|
4390
|
+
};
|
|
4391
|
+
const walletState = {
|
|
4392
|
+
accounts: [walletAccount],
|
|
4393
|
+
activeAccount: walletAccount
|
|
4394
|
+
};
|
|
4395
|
+
addWallet(this.store, {
|
|
4396
|
+
walletId: this.id,
|
|
4397
|
+
wallet: walletState
|
|
4398
|
+
});
|
|
4399
|
+
console.info("[Magic] \u2705 Connected.", walletState);
|
|
4400
|
+
return [walletAccount];
|
|
4401
|
+
};
|
|
4402
|
+
disconnect = async () => {
|
|
4403
|
+
console.info("[Magic] Disconnecting...");
|
|
4404
|
+
try {
|
|
4405
|
+
this.onDisconnect();
|
|
4406
|
+
console.info(`[Magic] Logging out ${this.userInfo?.email || "user"}...`);
|
|
4407
|
+
await this.client?.user.logout();
|
|
4408
|
+
console.info("[Magic] Disconnected.");
|
|
4409
|
+
} catch (error) {
|
|
4410
|
+
console.error(error);
|
|
4411
|
+
}
|
|
4412
|
+
};
|
|
4413
|
+
resumeSession = async () => {
|
|
4414
|
+
try {
|
|
4415
|
+
const state = this.store.state;
|
|
4416
|
+
const walletState = state.wallets[this.id];
|
|
4417
|
+
if (!walletState) {
|
|
4418
|
+
return;
|
|
4419
|
+
}
|
|
4420
|
+
console.info("[Magic] Resuming session...");
|
|
4421
|
+
const client = this.client || await this.initializeClient();
|
|
4422
|
+
const isLoggedIn = await client.user.isLoggedIn();
|
|
4423
|
+
if (!isLoggedIn) {
|
|
4424
|
+
console.warn("[Magic] Not logged in, please reconnect...");
|
|
4425
|
+
this.onDisconnect();
|
|
4426
|
+
return;
|
|
4427
|
+
}
|
|
4428
|
+
const userInfo = await client.user.getInfo();
|
|
4429
|
+
if (!userInfo) {
|
|
4430
|
+
await client.user.logout();
|
|
4431
|
+
throw new Error("User info not found!");
|
|
4432
|
+
}
|
|
4433
|
+
if (!userInfo.publicAddress) {
|
|
4434
|
+
await client.user.logout();
|
|
4435
|
+
throw new Error("No account found!");
|
|
4436
|
+
}
|
|
4437
|
+
this.userInfo = userInfo;
|
|
4438
|
+
const walletAccount = {
|
|
4439
|
+
name: userInfo.email ?? "Magic Wallet 1",
|
|
4440
|
+
address: userInfo.publicAddress
|
|
4441
|
+
};
|
|
4442
|
+
const storedAccount = walletState.accounts[0];
|
|
4443
|
+
const { name, address } = walletAccount;
|
|
4444
|
+
const { name: storedName, address: storedAddress } = storedAccount;
|
|
4445
|
+
const match = name === storedName && address === storedAddress;
|
|
4446
|
+
if (!match) {
|
|
4447
|
+
console.warn(`[Magic] Session account mismatch, updating account`, {
|
|
4448
|
+
prev: storedAccount,
|
|
4449
|
+
current: walletAccount
|
|
4450
|
+
});
|
|
4451
|
+
setAccounts(this.store, {
|
|
4452
|
+
walletId: this.id,
|
|
4453
|
+
accounts: [walletAccount]
|
|
4454
|
+
});
|
|
4455
|
+
}
|
|
4456
|
+
console.info("[Magic] Session resumed.");
|
|
4457
|
+
} catch (error) {
|
|
4458
|
+
console.error(`[Magic] Error resuming session: ${error.message}`);
|
|
4459
|
+
}
|
|
4460
|
+
};
|
|
4461
|
+
signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
|
|
4462
|
+
if (!this.client) {
|
|
4463
|
+
throw new Error("[Magic] Client not initialized!");
|
|
4464
|
+
}
|
|
4465
|
+
const txnsToSign = [];
|
|
4466
|
+
const signedIndexes = [];
|
|
4467
|
+
const msgpackTxnGroup = normalizeTxnGroup(txnGroup);
|
|
4468
|
+
const decodedObjects = msgpackTxnGroup.map((txn) => {
|
|
4469
|
+
return import_algosdk5.default.decodeObj(txn);
|
|
4470
|
+
});
|
|
4471
|
+
decodedObjects.forEach((txnObject, idx) => {
|
|
4472
|
+
const isSigned = isSignedTxnObject(txnObject);
|
|
4473
|
+
const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
|
|
4474
|
+
const txnBuffer = msgpackTxnGroup[idx];
|
|
4475
|
+
const txn = isSigned ? import_algosdk5.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk5.default.decodeUnsignedTransaction(txnBuffer);
|
|
4476
|
+
const txnBase64 = byteArrayToBase64(txn.toByte());
|
|
4477
|
+
if (shouldSign) {
|
|
4478
|
+
txnsToSign.push({ txn: txnBase64 });
|
|
4479
|
+
signedIndexes.push(idx);
|
|
4480
|
+
} else {
|
|
4481
|
+
txnsToSign.push({ txn: txnBase64, signers: [] });
|
|
4482
|
+
}
|
|
4483
|
+
});
|
|
4484
|
+
const signTxnsResult = await this.client.algorand.signGroupTransactionV2(
|
|
4485
|
+
txnsToSign
|
|
4486
|
+
);
|
|
4487
|
+
const signedTxnsBase64 = signTxnsResult.filter(Boolean);
|
|
4488
|
+
const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
|
|
4489
|
+
const txnGroupSigned = mergeSignedTxnsWithGroup(
|
|
4490
|
+
signedTxns,
|
|
4491
|
+
msgpackTxnGroup,
|
|
4492
|
+
signedIndexes,
|
|
4493
|
+
returnGroup
|
|
4494
|
+
);
|
|
4495
|
+
return txnGroupSigned;
|
|
4496
|
+
};
|
|
4497
|
+
transactionSigner = async (txnGroup, indexesToSign) => {
|
|
4498
|
+
if (!this.client) {
|
|
4499
|
+
throw new Error("[Magic] Client not initialized!");
|
|
4500
|
+
}
|
|
4501
|
+
const txnsToSign = txnGroup.reduce((acc, txn, idx) => {
|
|
4502
|
+
const txnBase64 = byteArrayToBase64(txn.toByte());
|
|
4503
|
+
if (indexesToSign.includes(idx)) {
|
|
4504
|
+
acc.push({ txn: txnBase64 });
|
|
4505
|
+
} else {
|
|
4506
|
+
acc.push({ txn: txnBase64, signers: [] });
|
|
4507
|
+
}
|
|
4508
|
+
return acc;
|
|
4509
|
+
}, []);
|
|
4510
|
+
const signTxnsResult = await this.client.algorand.signGroupTransactionV2(txnsToSign);
|
|
4511
|
+
const signedTxnsBase64 = signTxnsResult.filter(Boolean);
|
|
4512
|
+
const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
|
|
4513
|
+
return signedTxns;
|
|
4514
|
+
};
|
|
4515
|
+
};
|
|
4516
|
+
|
|
4517
|
+
// src/wallets/mnemonic.ts
|
|
4518
|
+
var import_algosdk6 = __toESM(require("algosdk"), 1);
|
|
4519
|
+
var icon5 = `data:image/svg+xml,%3c%3fxml version='1.0' encoding='UTF-8'%3f%3e %3c!-- Generated by Pixelmator Pro 3.2.2 --%3e %3csvg width='409' height='210' viewBox='0 0 409 210' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3ctext id='MNEMONIC' xml:space='preserve' x='0' y='129' font-family='Helvetica' font-size='72' fill='black'%3eMNEMONIC%3c/text%3e%3c/svg%3e`;
|
|
971
4520
|
var MnemonicWallet = class extends BaseWallet {
|
|
972
4521
|
account = null;
|
|
973
4522
|
options;
|
|
@@ -985,7 +4534,7 @@ var MnemonicWallet = class extends BaseWallet {
|
|
|
985
4534
|
this.options = { persistToStorage };
|
|
986
4535
|
this.store = store;
|
|
987
4536
|
}
|
|
988
|
-
static defaultMetadata = { name: "Mnemonic", icon:
|
|
4537
|
+
static defaultMetadata = { name: "Mnemonic", icon: icon5 };
|
|
989
4538
|
// @todo: Show explicit security warning if persistToStorage is true
|
|
990
4539
|
// @todo: Save/load mnemonic from storage if persistToStorage is true
|
|
991
4540
|
// @todo: Throw error with link to docs if using mainnet
|
|
@@ -995,11 +4544,11 @@ var MnemonicWallet = class extends BaseWallet {
|
|
|
995
4544
|
this.account = null;
|
|
996
4545
|
throw new Error("No mnemonic provided");
|
|
997
4546
|
}
|
|
998
|
-
const account =
|
|
4547
|
+
const account = import_algosdk6.default.mnemonicToSecretKey(mnemonic);
|
|
999
4548
|
this.account = account;
|
|
1000
4549
|
return account;
|
|
1001
4550
|
}
|
|
1002
|
-
async
|
|
4551
|
+
connect = async () => {
|
|
1003
4552
|
console.info("[MnemonicWallet] Connecting...");
|
|
1004
4553
|
try {
|
|
1005
4554
|
const account = this.initializeAccount();
|
|
@@ -1019,8 +4568,8 @@ var MnemonicWallet = class extends BaseWallet {
|
|
|
1019
4568
|
console.error("[MnemonicWallet] Error connecting:", error);
|
|
1020
4569
|
throw error;
|
|
1021
4570
|
}
|
|
1022
|
-
}
|
|
1023
|
-
async
|
|
4571
|
+
};
|
|
4572
|
+
disconnect = async () => {
|
|
1024
4573
|
console.info("[MnemonicWallet] Disconnecting...");
|
|
1025
4574
|
try {
|
|
1026
4575
|
this.account = null;
|
|
@@ -1028,8 +4577,8 @@ var MnemonicWallet = class extends BaseWallet {
|
|
|
1028
4577
|
} catch (error) {
|
|
1029
4578
|
console.error(error);
|
|
1030
4579
|
}
|
|
1031
|
-
}
|
|
1032
|
-
async
|
|
4580
|
+
};
|
|
4581
|
+
resumeSession = async () => {
|
|
1033
4582
|
const state = this.store.state;
|
|
1034
4583
|
const walletState = state.wallets[this.id];
|
|
1035
4584
|
if (walletState) {
|
|
@@ -1040,7 +4589,7 @@ var MnemonicWallet = class extends BaseWallet {
|
|
|
1040
4589
|
console.error(error);
|
|
1041
4590
|
}
|
|
1042
4591
|
}
|
|
1043
|
-
}
|
|
4592
|
+
};
|
|
1044
4593
|
signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
|
|
1045
4594
|
if (!this.account) {
|
|
1046
4595
|
throw new Error("[MnemonicWallet] Client not initialized!");
|
|
@@ -1048,15 +4597,15 @@ var MnemonicWallet = class extends BaseWallet {
|
|
|
1048
4597
|
const txnGroupSigned = [];
|
|
1049
4598
|
const msgpackTxnGroup = normalizeTxnGroup(txnGroup);
|
|
1050
4599
|
const decodedObjects = msgpackTxnGroup.map((txn) => {
|
|
1051
|
-
return
|
|
4600
|
+
return import_algosdk6.default.decodeObj(txn);
|
|
1052
4601
|
});
|
|
1053
4602
|
decodedObjects.forEach((txnObject, idx) => {
|
|
1054
4603
|
const isIndexMatch = !indexesToSign || indexesToSign.includes(idx);
|
|
1055
4604
|
const isSigned = isSignedTxnObject(txnObject);
|
|
1056
|
-
const canSign = !isSigned &&
|
|
4605
|
+
const canSign = !isSigned && import_algosdk6.default.encodeAddress(txnObject.snd) === this.account.addr;
|
|
1057
4606
|
const shouldSign = isIndexMatch && canSign;
|
|
1058
4607
|
if (shouldSign) {
|
|
1059
|
-
const txn =
|
|
4608
|
+
const txn = import_algosdk6.default.Transaction.from_obj_for_encoding(txnObject);
|
|
1060
4609
|
const signedTxn = txn.signTxn(this.account.sk);
|
|
1061
4610
|
txnGroupSigned.push(signedTxn);
|
|
1062
4611
|
} else if (returnGroup) {
|
|
@@ -1081,8 +4630,8 @@ var MnemonicWallet = class extends BaseWallet {
|
|
|
1081
4630
|
};
|
|
1082
4631
|
|
|
1083
4632
|
// src/wallets/pera.ts
|
|
1084
|
-
var
|
|
1085
|
-
var
|
|
4633
|
+
var import_algosdk7 = __toESM(require("algosdk"), 1);
|
|
4634
|
+
var icon6 = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48c3ZnIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNzcgMTg3Ij48cmVjdCB4PSItMTEuMzgiIHk9Ii0yNS45NyIgd2lkdGg9IjIwMC4wMiIgaGVpZ2h0PSIyMzEuNTMiIHN0eWxlPSJmaWxsOiNmZTU7Ii8+PHBhdGggZD0iTTk0LjA1LDU5LjYxYzIuMDUsOC40OCwxLjM2LDE1Ljk0LTEuNTUsMTYuNjYtMi45LC43Mi02LjkxLTUuNTctOC45Ni0xNC4wNS0yLjA1LTguNDgtMS4zNi0xNS45NCwxLjU1LTE2LjY2LDIuOS0uNzIsNi45MSw1LjU3LDguOTYsMTQuMDVaIiBzdHlsZT0iZmlsbDojMWMxYzFjOyIvPjxwYXRoIGQ9Ik0xMjcuODUsNjYuOWMtNC41My00LjgxLTEzLjU1LTMuNS0yMC4xNSwyLjkxLTYuNTksNi40MS04LjI2LDE1LjUtMy43MywyMC4zMSw0LjUzLDQuOCwxMy41NSwzLjUsMjAuMTUtMi45MXM4LjI2LTE1LjUsMy43My0yMC4zMVoiIHN0eWxlPSJmaWxsOiMxYzFjMWM7Ii8+PHBhdGggZD0iTTkxLjc5LDE0MC40N2MyLjktLjcyLDMuNDktOC42LDEuMzItMTcuNjEtMi4xNy05LTYuMjktMTUuNzEtOS4xOS0xNC45OS0yLjksLjcyLTMuNDksOC42LTEuMzIsMTcuNjEsMi4xNyw5LDYuMjksMTUuNzEsOS4xOSwxNC45OVoiIHN0eWxlPSJmaWxsOiMxYzFjMWM7Ii8+PHBhdGggZD0iTTYyLjIyLDcxLjNjOC4zNywyLjQ3LDE0LjQ4LDYuOCwxMy42Niw5LjY3LS44MywyLjg3LTguMjgsMy4yLTE2LjY1LC43My04LjM3LTIuNDctMTQuNDgtNi44LTEzLjY2LTkuNjcsLjgzLTIuODcsOC4yOC0zLjIsMTYuNjUtLjczWiIgc3R5bGU9ImZpbGw6IzFjMWMxYzsiLz48cGF0aCBkPSJNMTE2LjU0LDEwMy43NGM4Ljg4LDIuNjIsMTUuNDEsNy4wNywxNC41OSw5Ljk0LS44MywyLjg3LTguNywzLjA4LTE3LjU4LC40Ni04Ljg4LTIuNjItMTUuNDEtNy4wNy0xNC41OS05Ljk0LC44My0yLjg3LDguNy0zLjA4LDE3LjU4LS40NloiIHN0eWxlPSJmaWxsOiMxYzFjMWM7Ii8+PHBhdGggZD0iTTcxLjY0LDk3LjcxYy0yLjA4LTIuMTUtOC44OCwuOTgtMTUuMiw2Ljk5LTYuMzIsNi4wMS05Ljc2LDEyLjYzLTcuNjksMTQuNzgsMi4wOCwyLjE1LDguODgtLjk4LDE1LjItNi45OSw2LjMyLTYuMDEsOS43Ni0xMi42Myw3LjY5LTE0Ljc4WiIgc3R5bGU9ImZpbGw6IzFjMWMxYzsiLz48L3N2Zz4=";
|
|
1086
4635
|
var PeraWallet = class extends BaseWallet {
|
|
1087
4636
|
client = null;
|
|
1088
4637
|
options;
|
|
@@ -1092,24 +4641,27 @@ var PeraWallet = class extends BaseWallet {
|
|
|
1092
4641
|
store,
|
|
1093
4642
|
subscribe,
|
|
1094
4643
|
getAlgodClient,
|
|
1095
|
-
options
|
|
4644
|
+
options,
|
|
1096
4645
|
metadata = {}
|
|
1097
4646
|
}) {
|
|
1098
4647
|
super({ id, metadata, getAlgodClient, store, subscribe });
|
|
4648
|
+
if (!options?.projectId) {
|
|
4649
|
+
throw new Error("[PeraWallet] Missing required option: projectId");
|
|
4650
|
+
}
|
|
1099
4651
|
this.options = options;
|
|
1100
4652
|
this.store = store;
|
|
1101
4653
|
}
|
|
1102
|
-
static defaultMetadata = { name: "Pera", icon:
|
|
4654
|
+
static defaultMetadata = { name: "Pera", icon: icon6 };
|
|
1103
4655
|
async initializeClient() {
|
|
1104
4656
|
console.info("[PeraWallet] Initializing client...");
|
|
1105
|
-
const module2 = await import("@perawallet/connect");
|
|
1106
|
-
const PeraWalletConnect = module2.
|
|
4657
|
+
const module2 = await import("@perawallet/connect-beta");
|
|
4658
|
+
const PeraWalletConnect = module2.PeraWalletConnect || module2.default.PeraWalletConnect;
|
|
1107
4659
|
const client = new PeraWalletConnect(this.options);
|
|
1108
|
-
client.
|
|
4660
|
+
client.client?.on("session_delete", this.onDisconnect);
|
|
1109
4661
|
this.client = client;
|
|
1110
4662
|
return client;
|
|
1111
4663
|
}
|
|
1112
|
-
async
|
|
4664
|
+
connect = async () => {
|
|
1113
4665
|
console.info("[PeraWallet] Connecting...");
|
|
1114
4666
|
try {
|
|
1115
4667
|
const client = this.client || await this.initializeClient();
|
|
@@ -1138,8 +4690,8 @@ var PeraWallet = class extends BaseWallet {
|
|
|
1138
4690
|
}
|
|
1139
4691
|
return [];
|
|
1140
4692
|
}
|
|
1141
|
-
}
|
|
1142
|
-
async
|
|
4693
|
+
};
|
|
4694
|
+
disconnect = async () => {
|
|
1143
4695
|
console.info("[PeraWallet] Disconnecting...");
|
|
1144
4696
|
try {
|
|
1145
4697
|
await this.client?.disconnect();
|
|
@@ -1147,8 +4699,8 @@ var PeraWallet = class extends BaseWallet {
|
|
|
1147
4699
|
} catch (error) {
|
|
1148
4700
|
console.error(error);
|
|
1149
4701
|
}
|
|
1150
|
-
}
|
|
1151
|
-
async
|
|
4702
|
+
};
|
|
4703
|
+
resumeSession = async () => {
|
|
1152
4704
|
try {
|
|
1153
4705
|
const state = this.store.state;
|
|
1154
4706
|
const walletState = state.wallets[this.id];
|
|
@@ -1177,7 +4729,7 @@ var PeraWallet = class extends BaseWallet {
|
|
|
1177
4729
|
console.error(`[PeraWallet] Error resuming session: ${error.message}`);
|
|
1178
4730
|
this.onDisconnect();
|
|
1179
4731
|
}
|
|
1180
|
-
}
|
|
4732
|
+
};
|
|
1181
4733
|
signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
|
|
1182
4734
|
if (!this.client) {
|
|
1183
4735
|
throw new Error("[PeraWallet] Client not initialized!");
|
|
@@ -1186,13 +4738,13 @@ var PeraWallet = class extends BaseWallet {
|
|
|
1186
4738
|
const signedIndexes = [];
|
|
1187
4739
|
const msgpackTxnGroup = normalizeTxnGroup(txnGroup);
|
|
1188
4740
|
const decodedObjects = msgpackTxnGroup.map((txn) => {
|
|
1189
|
-
return
|
|
4741
|
+
return import_algosdk7.default.decodeObj(txn);
|
|
1190
4742
|
});
|
|
1191
4743
|
decodedObjects.forEach((txnObject, idx) => {
|
|
1192
4744
|
const isSigned = isSignedTxnObject(txnObject);
|
|
1193
4745
|
const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
|
|
1194
4746
|
const txnBuffer = msgpackTxnGroup[idx];
|
|
1195
|
-
const txn = isSigned ?
|
|
4747
|
+
const txn = isSigned ? import_algosdk7.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk7.default.decodeUnsignedTransaction(txnBuffer);
|
|
1196
4748
|
if (shouldSign) {
|
|
1197
4749
|
txnsToSign.push({ txn });
|
|
1198
4750
|
signedIndexes.push(idx);
|
|
@@ -1227,9 +4779,8 @@ var PeraWallet = class extends BaseWallet {
|
|
|
1227
4779
|
};
|
|
1228
4780
|
|
|
1229
4781
|
// src/wallets/walletconnect.ts
|
|
1230
|
-
var
|
|
1231
|
-
var
|
|
1232
|
-
var icon6 = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIKCSB2aWV3Qm94PSIwIDAgNDgwIDQ4MCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNDgwIDQ4MDsiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPgoJLnN0MHtmaWxsOiMzMzk2RkY7fQo8L3N0eWxlPgo8cGF0aCBjbGFzcz0ic3QwIiBkPSJNMTI2LjYsMTY4YzYyLjYtNjEuMywxNjQuMi02MS4zLDIyNi44LDBsNy41LDcuNGMzLjEsMy4xLDMuMSw4LDAsMTEuMWwtMjUuOCwyNS4yYy0xLjYsMS41LTQuMSwxLjUtNS43LDAKCWwtMTAuNC0xMC4yYy00My43LTQyLjgtMTE0LjUtNDIuOC0xNTguMiwwbC0xMS4xLDEwLjljLTEuNiwxLjUtNC4xLDEuNS01LjcsMGwtMjUuOC0yNS4yYy0zLjEtMy4xLTMuMS04LDAtMTEuMUwxMjYuNiwxNjh6CgkgTTQwNi43LDIyMC4ybDIyLjksMjIuNWMzLjEsMy4xLDMuMSw4LDAsMTEuMUwzMjYuMiwzNTUuMWMtMy4xLDMuMS04LjIsMy4xLTExLjMsMGwtNzMuNC03MS45Yy0wLjgtMC44LTIuMS0wLjgtMi44LDBsLTczLjQsNzEuOQoJYy0zLjEsMy4xLTguMiwzLjEtMTEuMywwTDUwLjMsMjUzLjhjLTMuMS0zLjEtMy4xLTgsMC0xMS4xbDIyLjktMjIuNWMzLjEtMy4xLDguMi0zLjEsMTEuMywwbDczLjQsNzEuOWMwLjgsMC44LDIuMSwwLjgsMi44LDAKCWw3My40LTcxLjljMy4xLTMuMSw4LjItMy4xLDExLjMsMGw3My40LDcxLjljMC44LDAuOCwyLjEsMC44LDIuOCwwbDczLjQtNzEuOUMzOTguNSwyMTcuMSw0MDMuNiwyMTcuMSw0MDYuNywyMjAuMkw0MDYuNywyMjAuMnoiLz4KPC9zdmc+Cg==";
|
|
4782
|
+
var import_algosdk8 = __toESM(require("algosdk"), 1);
|
|
4783
|
+
var icon7 = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMYXllcl8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIKCSB2aWV3Qm94PSIwIDAgNDgwIDQ4MCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgNDgwIDQ4MDsiIHhtbDpzcGFjZT0icHJlc2VydmUiPgo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPgoJLnN0MHtmaWxsOiMzMzk2RkY7fQo8L3N0eWxlPgo8cGF0aCBjbGFzcz0ic3QwIiBkPSJNMTI2LjYsMTY4YzYyLjYtNjEuMywxNjQuMi02MS4zLDIyNi44LDBsNy41LDcuNGMzLjEsMy4xLDMuMSw4LDAsMTEuMWwtMjUuOCwyNS4yYy0xLjYsMS41LTQuMSwxLjUtNS43LDAKCWwtMTAuNC0xMC4yYy00My43LTQyLjgtMTE0LjUtNDIuOC0xNTguMiwwbC0xMS4xLDEwLjljLTEuNiwxLjUtNC4xLDEuNS01LjcsMGwtMjUuOC0yNS4yYy0zLjEtMy4xLTMuMS04LDAtMTEuMUwxMjYuNiwxNjh6CgkgTTQwNi43LDIyMC4ybDIyLjksMjIuNWMzLjEsMy4xLDMuMSw4LDAsMTEuMUwzMjYuMiwzNTUuMWMtMy4xLDMuMS04LjIsMy4xLTExLjMsMGwtNzMuNC03MS45Yy0wLjgtMC44LTIuMS0wLjgtMi44LDBsLTczLjQsNzEuOQoJYy0zLjEsMy4xLTguMiwzLjEtMTEuMywwTDUwLjMsMjUzLjhjLTMuMS0zLjEtMy4xLTgsMC0xMS4xbDIyLjktMjIuNWMzLjEtMy4xLDguMi0zLjEsMTEuMywwbDczLjQsNzEuOWMwLjgsMC44LDIuMSwwLjgsMi44LDAKCWw3My40LTcxLjljMy4xLTMuMSw4LjItMy4xLDExLjMsMGw3My40LDcxLjljMC44LDAuOCwyLjEsMC44LDIuOCwwbDczLjQtNzEuOUMzOTguNSwyMTcuMSw0MDMuNiwyMTcuMSw0MDYuNywyMjAuMkw0MDYuNywyMjAuMnoiLz4KPC9zdmc+Cg==";
|
|
1233
4784
|
var WalletConnect = class extends BaseWallet {
|
|
1234
4785
|
client = null;
|
|
1235
4786
|
options;
|
|
@@ -1253,7 +4804,7 @@ var WalletConnect = class extends BaseWallet {
|
|
|
1253
4804
|
const {
|
|
1254
4805
|
projectId,
|
|
1255
4806
|
relayUrl = "wss://relay.walletconnect.com",
|
|
1256
|
-
metadata: _metadata
|
|
4807
|
+
metadata: _metadata,
|
|
1257
4808
|
...modalOptions
|
|
1258
4809
|
} = options;
|
|
1259
4810
|
this.options = {
|
|
@@ -1265,7 +4816,7 @@ var WalletConnect = class extends BaseWallet {
|
|
|
1265
4816
|
this.chains = Object.values(caipChainId);
|
|
1266
4817
|
this.store = store;
|
|
1267
4818
|
}
|
|
1268
|
-
static defaultMetadata = { name: "WalletConnect", icon:
|
|
4819
|
+
static defaultMetadata = { name: "WalletConnect", icon: icon7 };
|
|
1269
4820
|
async initializeClient() {
|
|
1270
4821
|
console.info("[WalletConnect] Initializing client...");
|
|
1271
4822
|
const SignClient = (await import("@walletconnect/sign-client")).SignClient;
|
|
@@ -1334,7 +4885,7 @@ var WalletConnect = class extends BaseWallet {
|
|
|
1334
4885
|
this.session = session;
|
|
1335
4886
|
return walletAccounts;
|
|
1336
4887
|
}
|
|
1337
|
-
async
|
|
4888
|
+
connect = async () => {
|
|
1338
4889
|
console.info("[WalletConnect] Connecting...");
|
|
1339
4890
|
try {
|
|
1340
4891
|
const client = this.client || await this.initializeClient();
|
|
@@ -1360,22 +4911,25 @@ var WalletConnect = class extends BaseWallet {
|
|
|
1360
4911
|
} finally {
|
|
1361
4912
|
this.modal?.closeModal();
|
|
1362
4913
|
}
|
|
1363
|
-
}
|
|
1364
|
-
async
|
|
4914
|
+
};
|
|
4915
|
+
disconnect = async () => {
|
|
1365
4916
|
console.info("[WalletConnect] Disconnecting...");
|
|
1366
4917
|
try {
|
|
1367
4918
|
if (this.client && this.session) {
|
|
1368
4919
|
await this.client.disconnect({
|
|
1369
4920
|
topic: this.session.topic,
|
|
1370
|
-
reason:
|
|
4921
|
+
reason: {
|
|
4922
|
+
message: "User disconnected.",
|
|
4923
|
+
code: 6e3
|
|
4924
|
+
}
|
|
1371
4925
|
});
|
|
1372
4926
|
}
|
|
1373
4927
|
this.onDisconnect();
|
|
1374
4928
|
} catch (error) {
|
|
1375
4929
|
console.error(error);
|
|
1376
4930
|
}
|
|
1377
|
-
}
|
|
1378
|
-
async
|
|
4931
|
+
};
|
|
4932
|
+
resumeSession = async () => {
|
|
1379
4933
|
try {
|
|
1380
4934
|
const state = this.store.state;
|
|
1381
4935
|
const walletState = state.wallets[this.id];
|
|
@@ -1393,7 +4947,7 @@ var WalletConnect = class extends BaseWallet {
|
|
|
1393
4947
|
console.error(`[WalletConnect] Error resuming session: ${error.message}`);
|
|
1394
4948
|
this.onDisconnect();
|
|
1395
4949
|
}
|
|
1396
|
-
}
|
|
4950
|
+
};
|
|
1397
4951
|
signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
|
|
1398
4952
|
if (!this.client) {
|
|
1399
4953
|
throw new Error("[WalletConnect] Client not initialized!");
|
|
@@ -1408,14 +4962,14 @@ var WalletConnect = class extends BaseWallet {
|
|
|
1408
4962
|
const signedIndexes = [];
|
|
1409
4963
|
const msgpackTxnGroup = normalizeTxnGroup(txnGroup);
|
|
1410
4964
|
const decodedObjects = msgpackTxnGroup.map((txn) => {
|
|
1411
|
-
return
|
|
4965
|
+
return import_algosdk8.default.decodeObj(txn);
|
|
1412
4966
|
});
|
|
1413
4967
|
decodedObjects.forEach((txnObject, idx) => {
|
|
1414
4968
|
const isSigned = isSignedTxnObject(txnObject);
|
|
1415
4969
|
const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
|
|
1416
4970
|
const txnBuffer = msgpackTxnGroup[idx];
|
|
1417
|
-
const txn = isSigned ?
|
|
1418
|
-
const txnBase64 =
|
|
4971
|
+
const txn = isSigned ? import_algosdk8.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk8.default.decodeUnsignedTransaction(txnBuffer);
|
|
4972
|
+
const txnBase64 = byteArrayToBase64(txn.toByte());
|
|
1419
4973
|
if (shouldSign) {
|
|
1420
4974
|
txnsToSign.push({ txn: txnBase64 });
|
|
1421
4975
|
signedIndexes.push(idx);
|
|
@@ -1430,7 +4984,7 @@ var WalletConnect = class extends BaseWallet {
|
|
|
1430
4984
|
request
|
|
1431
4985
|
});
|
|
1432
4986
|
const signedTxnsBase64 = signTxnsResult.filter(Boolean);
|
|
1433
|
-
const signedTxns = signedTxnsBase64.map((txn) =>
|
|
4987
|
+
const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
|
|
1434
4988
|
const txnGroupSigned = mergeSignedTxnsWithGroup(
|
|
1435
4989
|
signedTxns,
|
|
1436
4990
|
msgpackTxnGroup,
|
|
@@ -1450,7 +5004,7 @@ var WalletConnect = class extends BaseWallet {
|
|
|
1450
5004
|
throw new Error(`[WalletConnect] Invalid network: ${this.activeNetwork}`);
|
|
1451
5005
|
}
|
|
1452
5006
|
const txnsToSign = txnGroup.reduce((acc, txn, idx) => {
|
|
1453
|
-
const txnBase64 =
|
|
5007
|
+
const txnBase64 = byteArrayToBase64(txn.toByte());
|
|
1454
5008
|
if (indexesToSign.includes(idx)) {
|
|
1455
5009
|
acc.push({ txn: txnBase64 });
|
|
1456
5010
|
} else {
|
|
@@ -1465,7 +5019,7 @@ var WalletConnect = class extends BaseWallet {
|
|
|
1465
5019
|
request
|
|
1466
5020
|
});
|
|
1467
5021
|
const signedTxnsBase64 = signTxnsResult.filter(Boolean);
|
|
1468
|
-
const signedTxns = signedTxnsBase64.map((txn) =>
|
|
5022
|
+
const signedTxns = signedTxnsBase64.map((txn) => base64ToByteArray(txn));
|
|
1469
5023
|
return signedTxns;
|
|
1470
5024
|
};
|
|
1471
5025
|
};
|
|
@@ -1478,6 +5032,7 @@ function createWalletMap() {
|
|
|
1478
5032
|
["kibisis" /* KIBISIS */]: KibisisWallet,
|
|
1479
5033
|
["kmd" /* KMD */]: KmdWallet,
|
|
1480
5034
|
["lute" /* LUTE */]: LuteWallet,
|
|
5035
|
+
["magic" /* MAGIC */]: MagicAuth,
|
|
1481
5036
|
["mnemonic" /* MNEMONIC */]: MnemonicWallet,
|
|
1482
5037
|
["pera" /* PERA */]: PeraWallet,
|
|
1483
5038
|
["walletconnect" /* WALLETCONNECT */]: WalletConnect
|
|
@@ -1496,6 +5051,26 @@ function compareAccounts(accounts, compareTo) {
|
|
|
1496
5051
|
}
|
|
1497
5052
|
return true;
|
|
1498
5053
|
}
|
|
5054
|
+
function base64ToByteArray(blob) {
|
|
5055
|
+
return stringToByteArray(atob(blob));
|
|
5056
|
+
}
|
|
5057
|
+
function byteArrayToBase64(array) {
|
|
5058
|
+
return btoa(byteArrayToString(array));
|
|
5059
|
+
}
|
|
5060
|
+
function stringToByteArray(str) {
|
|
5061
|
+
const array = new Uint8Array(str.length);
|
|
5062
|
+
for (let i = 0; i < str.length; i++) {
|
|
5063
|
+
array[i] = str.charCodeAt(i);
|
|
5064
|
+
}
|
|
5065
|
+
return array;
|
|
5066
|
+
}
|
|
5067
|
+
function byteArrayToString(array) {
|
|
5068
|
+
let result = "";
|
|
5069
|
+
for (let i = 0; i < array.length; i++) {
|
|
5070
|
+
result += String.fromCharCode(array[i]);
|
|
5071
|
+
}
|
|
5072
|
+
return result;
|
|
5073
|
+
}
|
|
1499
5074
|
function isTransaction(item) {
|
|
1500
5075
|
if (Array.isArray(item)) {
|
|
1501
5076
|
return item.every(
|
|
@@ -1516,7 +5091,7 @@ function normalizeTxnGroup(txnGroup) {
|
|
|
1516
5091
|
if (isTransactionType) {
|
|
1517
5092
|
const transactionGroup = Array.isArray(txnGroup[0]) ? txnGroup.flatMap((txn) => txn) : txnGroup;
|
|
1518
5093
|
return transactionGroup.map((txn) => {
|
|
1519
|
-
return
|
|
5094
|
+
return import_algosdk9.default.encodeUnsignedTransaction(txn);
|
|
1520
5095
|
});
|
|
1521
5096
|
} else {
|
|
1522
5097
|
const transactionGroup = Array.isArray(txnGroup[0]) ? txnGroup.flatMap((txn) => txn) : txnGroup;
|
|
@@ -1526,7 +5101,7 @@ function normalizeTxnGroup(txnGroup) {
|
|
|
1526
5101
|
function shouldSignTxnObject(txnObject, addresses, indexesToSign, idx) {
|
|
1527
5102
|
const isIndexMatch = !indexesToSign || indexesToSign.includes(idx);
|
|
1528
5103
|
const isSigned = isSignedTxnObject(txnObject);
|
|
1529
|
-
const canSign = !isSigned && addresses.includes(
|
|
5104
|
+
const canSign = !isSigned && addresses.includes(import_algosdk9.default.encodeAddress(txnObject.snd));
|
|
1530
5105
|
const shouldSign = isIndexMatch && canSign;
|
|
1531
5106
|
return shouldSign;
|
|
1532
5107
|
}
|
|
@@ -1583,7 +5158,7 @@ function generateUuid() {
|
|
|
1583
5158
|
}
|
|
1584
5159
|
|
|
1585
5160
|
// src/wallets/defly.ts
|
|
1586
|
-
var
|
|
5161
|
+
var icon8 = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+Cjxzdmcgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4bWw6c3BhY2U9InByZXNlcnZlIiB4bWxuczpzZXJpZj0iaHR0cDovL3d3dy5zZXJpZi5jb20vIiBzdHlsZT0iZmlsbC1ydWxlOmV2ZW5vZGQ7Y2xpcC1ydWxlOmV2ZW5vZGQ7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO3N0cm9rZS1taXRlcmxpbWl0OjI7Ij4KICAgIDxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDI0IiBoZWlnaHQ9IjEwMjQiLz4KICAgIDxnIHRyYW5zZm9ybT0ibWF0cml4KDEuNjgyMDksMCwwLDEuNjgyMDksMjI2LjM2OCwyMTIuODE4KSI+CiAgICAgICAgPHBhdGggZD0iTTMyNy4wNDksMjgwLjE5MkwxNjkuNTI0LDEzTDEyLDI4MC4xOTJMMTY5LjUyNCwxODkuMDg0TDMyNy4wNDksMjgwLjE5MloiIHN0eWxlPSJmaWxsOndoaXRlO2ZpbGwtcnVsZTpub256ZXJvOyIvPgogICAgPC9nPgogICAgPGcgdHJhbnNmb3JtPSJtYXRyaXgoMS42ODIwOSwwLDAsMS42ODIwOSwyMjYuMzY4LDIxMi44MTgpIj4KICAgICAgICA8cGF0aCBkPSJNMjk5LjU0NiwzMDdMMTY5LjUyNSwyMzguNDczTDM5LjUwNCwzMDdMMTY5LjUyNSwyNjQuNjdMMjk5LjU0NiwzMDdaIiBzdHlsZT0iZmlsbDp3aGl0ZTtmaWxsLXJ1bGU6bm9uemVybzsiLz4KICAgIDwvZz4KPC9zdmc+Cg==";
|
|
1587
5162
|
var DeflyWallet = class extends BaseWallet {
|
|
1588
5163
|
client = null;
|
|
1589
5164
|
options;
|
|
@@ -1600,7 +5175,7 @@ var DeflyWallet = class extends BaseWallet {
|
|
|
1600
5175
|
this.options = options;
|
|
1601
5176
|
this.store = store;
|
|
1602
5177
|
}
|
|
1603
|
-
static defaultMetadata = { name: "Defly", icon:
|
|
5178
|
+
static defaultMetadata = { name: "Defly", icon: icon8 };
|
|
1604
5179
|
async initializeClient() {
|
|
1605
5180
|
console.info("[DeflyWallet] Initializing client...");
|
|
1606
5181
|
const module2 = await import("@blockshake/defly-connect");
|
|
@@ -1610,7 +5185,7 @@ var DeflyWallet = class extends BaseWallet {
|
|
|
1610
5185
|
this.client = client;
|
|
1611
5186
|
return client;
|
|
1612
5187
|
}
|
|
1613
|
-
async
|
|
5188
|
+
connect = async () => {
|
|
1614
5189
|
console.info("[DeflyWallet] Connecting...");
|
|
1615
5190
|
try {
|
|
1616
5191
|
const client = this.client || await this.initializeClient();
|
|
@@ -1639,8 +5214,8 @@ var DeflyWallet = class extends BaseWallet {
|
|
|
1639
5214
|
}
|
|
1640
5215
|
return [];
|
|
1641
5216
|
}
|
|
1642
|
-
}
|
|
1643
|
-
async
|
|
5217
|
+
};
|
|
5218
|
+
disconnect = async () => {
|
|
1644
5219
|
console.info("[DeflyWallet] Disconnecting...");
|
|
1645
5220
|
try {
|
|
1646
5221
|
await this.client?.disconnect();
|
|
@@ -1648,8 +5223,8 @@ var DeflyWallet = class extends BaseWallet {
|
|
|
1648
5223
|
} catch (error) {
|
|
1649
5224
|
console.error(error);
|
|
1650
5225
|
}
|
|
1651
|
-
}
|
|
1652
|
-
async
|
|
5226
|
+
};
|
|
5227
|
+
resumeSession = async () => {
|
|
1653
5228
|
try {
|
|
1654
5229
|
const state = this.store.state;
|
|
1655
5230
|
const walletState = state.wallets[this.id];
|
|
@@ -1678,7 +5253,7 @@ var DeflyWallet = class extends BaseWallet {
|
|
|
1678
5253
|
console.error(`[DeflyWallet] Error resuming session: ${error.message}`);
|
|
1679
5254
|
this.onDisconnect();
|
|
1680
5255
|
}
|
|
1681
|
-
}
|
|
5256
|
+
};
|
|
1682
5257
|
signTransactions = async (txnGroup, indexesToSign, returnGroup = true) => {
|
|
1683
5258
|
if (!this.client) {
|
|
1684
5259
|
throw new Error("[DeflyWallet] Client not initialized!");
|
|
@@ -1687,13 +5262,13 @@ var DeflyWallet = class extends BaseWallet {
|
|
|
1687
5262
|
const signedIndexes = [];
|
|
1688
5263
|
const msgpackTxnGroup = normalizeTxnGroup(txnGroup);
|
|
1689
5264
|
const decodedObjects = msgpackTxnGroup.map((txn) => {
|
|
1690
|
-
return
|
|
5265
|
+
return import_algosdk10.default.decodeObj(txn);
|
|
1691
5266
|
});
|
|
1692
5267
|
decodedObjects.forEach((txnObject, idx) => {
|
|
1693
5268
|
const isSigned = isSignedTxnObject(txnObject);
|
|
1694
5269
|
const shouldSign = shouldSignTxnObject(txnObject, this.addresses, indexesToSign, idx);
|
|
1695
5270
|
const txnBuffer = msgpackTxnGroup[idx];
|
|
1696
|
-
const txn = isSigned ?
|
|
5271
|
+
const txn = isSigned ? import_algosdk10.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk10.default.decodeUnsignedTransaction(txnBuffer);
|
|
1697
5272
|
if (shouldSign) {
|
|
1698
5273
|
txnsToSign.push({ txn });
|
|
1699
5274
|
signedIndexes.push(idx);
|
|
@@ -1772,7 +5347,7 @@ function setActiveAccount(store, { walletId, address }) {
|
|
|
1772
5347
|
if (!wallet) {
|
|
1773
5348
|
return state;
|
|
1774
5349
|
}
|
|
1775
|
-
const activeAccount = wallet.accounts.find((
|
|
5350
|
+
const activeAccount = wallet.accounts.find((a2) => a2.address === address);
|
|
1776
5351
|
if (!activeAccount) {
|
|
1777
5352
|
return state;
|
|
1778
5353
|
}
|
|
@@ -1859,7 +5434,7 @@ var WalletManager = class {
|
|
|
1859
5434
|
...defaultState,
|
|
1860
5435
|
activeNetwork: network
|
|
1861
5436
|
};
|
|
1862
|
-
this.store = new
|
|
5437
|
+
this.store = new import_store11.Store(initialState, {
|
|
1863
5438
|
onUpdate: () => this.savePersistedState()
|
|
1864
5439
|
});
|
|
1865
5440
|
this.savePersistedState();
|
|
@@ -1970,15 +5545,15 @@ var WalletManager = class {
|
|
|
1970
5545
|
createAlgodClient(config) {
|
|
1971
5546
|
console.info(`[Manager] Creating Algodv2 client for ${this.activeNetwork}...`);
|
|
1972
5547
|
const { token = "", baseServer, port = "", headers = {} } = config;
|
|
1973
|
-
return new
|
|
5548
|
+
return new import_algosdk11.default.Algodv2(token, baseServer, port, headers);
|
|
1974
5549
|
}
|
|
1975
5550
|
getAlgodClient = () => {
|
|
1976
5551
|
return this.algodClient;
|
|
1977
5552
|
};
|
|
1978
|
-
setActiveNetwork(networkId) {
|
|
5553
|
+
setActiveNetwork = (networkId) => {
|
|
1979
5554
|
setActiveNetwork(this.store, { networkId });
|
|
1980
5555
|
this.algodClient = this.createAlgodClient(this.networkConfig[networkId]);
|
|
1981
|
-
}
|
|
5556
|
+
};
|
|
1982
5557
|
get activeNetwork() {
|
|
1983
5558
|
return this.store.state.activeNetwork;
|
|
1984
5559
|
}
|
|
@@ -2048,6 +5623,7 @@ var WalletManager = class {
|
|
|
2048
5623
|
DeflyWallet,
|
|
2049
5624
|
ExodusWallet,
|
|
2050
5625
|
KmdWallet,
|
|
5626
|
+
MagicAuth,
|
|
2051
5627
|
MnemonicWallet,
|
|
2052
5628
|
NetworkId,
|
|
2053
5629
|
PeraWallet,
|