@txnlab/use-wallet 4.3.0 → 4.4.0-beta.0
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 +3143 -470
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +238 -24
- package/dist/index.d.ts +238 -24
- package/dist/index.js +3156 -468
- package/dist/index.js.map +1 -1
- package/package.json +33 -16
package/dist/index.cjs
CHANGED
|
@@ -8,6 +8,9 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
|
8
8
|
var __esm = (fn, res) => function __init() {
|
|
9
9
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
10
|
};
|
|
11
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
12
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
13
|
+
};
|
|
11
14
|
var __export = (target, all) => {
|
|
12
15
|
for (var name in all)
|
|
13
16
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -30,43 +33,43 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
33
|
));
|
|
31
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
35
|
|
|
33
|
-
// ../../node_modules/.pnpm/@magic-sdk+types@24.
|
|
34
|
-
var m, v, u, _, f, g, Z, E,
|
|
36
|
+
// ../../node_modules/.pnpm/@magic-sdk+types@24.21.0/node_modules/@magic-sdk/types/dist/es/index.mjs
|
|
37
|
+
var m, v, u, _, f, g, Z, E, y, x, A, R, I, N, h, T, O, S, b, C, F, U, k, L, w, D, V, G, H, q, W, J, Y, B, P, j, Q, X, z;
|
|
35
38
|
var init_es = __esm({
|
|
36
|
-
"../../node_modules/.pnpm/@magic-sdk+types@24.
|
|
39
|
+
"../../node_modules/.pnpm/@magic-sdk+types@24.21.0/node_modules/@magic-sdk/types/dist/es/index.mjs"() {
|
|
37
40
|
"use strict";
|
|
38
|
-
m = ((
|
|
39
|
-
v = ((
|
|
41
|
+
m = ((o) => (o.MissingApiKey = "MISSING_API_KEY", o.ModalNotReady = "MODAL_NOT_READY", o.ConnectionLost = "CONNECTION_WAS_LOST", o.MalformedResponse = "MALFORMED_RESPONSE", o.InvalidArgument = "INVALID_ARGUMENT", o.ExtensionNotInitialized = "EXTENSION_NOT_INITIALIZED", o.IncompatibleExtensions = "INCOMPATIBLE_EXTENSIONS", o))(m || {});
|
|
42
|
+
v = ((s) => (s.SyncWeb3Method = "SYNC_WEB3_METHOD", s.DuplicateIframe = "DUPLICATE_IFRAME", s.ReactNativeEndpointConfiguration = "REACT_NATIVE_ENDPOINT_CONFIGURATION", s.DeprecationNotice = "DEPRECATION_NOTICE", s.ProductAnnouncement = "ANNOUNCEMENT", s))(v || {});
|
|
40
43
|
u = ((i) => (i[i.ParseError = -32700] = "ParseError", i[i.InvalidRequest = -32600] = "InvalidRequest", i[i.MethodNotFound = -32601] = "MethodNotFound", i[i.InvalidParams = -32602] = "InvalidParams", i[i.InternalError = -32603] = "InternalError", i[i.MagicLinkFailedVerification = -1e4] = "MagicLinkFailedVerification", i[i.MagicLinkExpired = -10001] = "MagicLinkExpired", i[i.MagicLinkRateLimited = -10002] = "MagicLinkRateLimited", i[i.MagicLinkInvalidRedirectURL = -10006] = "MagicLinkInvalidRedirectURL", i[i.UserAlreadyLoggedIn = -10003] = "UserAlreadyLoggedIn", i[i.UpdateEmailFailed = -10004] = "UpdateEmailFailed", i[i.UserRequestEditEmail = -10005] = "UserRequestEditEmail", i[i.InactiveRecipient = -10010] = "InactiveRecipient", i[i.AccessDeniedToUser = -10011] = "AccessDeniedToUser", i[i.RedirectLoginComplete = -10015] = "RedirectLoginComplete", i[i.DpopInvalidated = -10019] = "DpopInvalidated", i))(u || {});
|
|
41
44
|
_ = ((t) => (t.PROVIDER = "magic_3pw_provider", t.ADDRESS = "magic_3pw_address", t.CHAIN_ID = "magic_3pw_chainId", t))(_ || {});
|
|
42
45
|
f = ((t) => (t.WalletConnected = "wallet_connected", t.WalletRejected = "wallet_rejected", t.Web3ModalSelected = "web3modal_selected", t))(f || {});
|
|
43
46
|
g = ((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.EnableMFA = "magic_auth_enable_mfa_flow", e.DisableMFA = "magic_auth_disable_mfa_flow", e))(g || {});
|
|
44
47
|
Z = ["magic_intermediary_event", "magic_nft_checkout", "mc_login"];
|
|
45
|
-
E = ((
|
|
46
|
-
|
|
47
|
-
|
|
48
|
+
E = ((c) => (c.MAGIC_HANDLE_RESPONSE = "MAGIC_HANDLE_RESPONSE", c.MAGIC_OVERLAY_READY = "MAGIC_OVERLAY_READY", c.MAGIC_SHOW_OVERLAY = "MAGIC_SHOW_OVERLAY", c.MAGIC_HIDE_OVERLAY = "MAGIC_HIDE_OVERLAY", c.MAGIC_HANDLE_EVENT = "MAGIC_HANDLE_EVENT", c.MAGIC_MG_BOX_SEND_RECEIPT = "MAGIC_MG_BOX_SEND_RECEIPT", c.MAGIC_SEND_PRODUCT_ANNOUNCEMENT = "MAGIC_SEND_PRODUCT_ANNOUNCEMENT", c.MAGIC_PONG = "MAGIC_PONG", c.MAGIC_POPUP_RESPONSE = "MAGIC_POPUP_RESPONSE", c.MAGIC_POPUP_OAUTH_VERIFY_RESPONSE = "MAGIC_POPUP_OAUTH_VERIFY_RESPONSE", c))(E || {});
|
|
49
|
+
y = ((l) => (l.MAGIC_HANDLE_REQUEST = "MAGIC_HANDLE_REQUEST", l.MAGIC_PING = "MAGIC_PING", l))(y || {});
|
|
50
|
+
x = ((t) => (t.UpdateEmail = "update-email", t.MFA = "mfa", t.Recovery = "recovery", t))(x || {});
|
|
48
51
|
A = ((r10) => (r10.Retry = "retry", r10))(A || {});
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
R = ((l) => (l.EmailSent = "email-sent", l.EmailNotDeliverable = "email-not-deliverable", l))(R || {});
|
|
53
|
+
I = ((s) => (s.VerifyEmailOtp = "verify-email-otp", s.VerifyMFACode = "verify-mfa-code", s.LostDevice = "lost-device", s.VerifyRecoveryCode = "verify-recovery-code", s.Cancel = "cancel", s))(I || {});
|
|
51
54
|
N = ((t) => (t.VerifySmsOtp = "verify-sms-otp", t.Cancel = "cancel", t.Retry = "retry", t))(N || {});
|
|
52
55
|
h = ((t) => (t.SmsOTPSent = "sms-otp-sent", t.InvalidSmsOtp = "invalid-sms-otp", t.ExpiredSmsOtp = "expired-sms-otp", t))(h || {});
|
|
53
|
-
T = ((
|
|
56
|
+
T = ((d) => (d.EmailOTPSent = "email-otp-sent", d.InvalidEmailOtp = "invalid-email-otp", d.InvalidMfaOtp = "invalid-mfa-otp", d.ExpiredEmailOtp = "expired-email-otp", d.MfaSentHandle = "mfa-sent-handle", d.RecoveryCodeSentHandle = "recovery-code-sent-handle", d.InvalidRecoveryCode = "invalid-recovery-code", d.RecoveryCodeSuccess = "recovery-code-success", d.LoginThrottled = "login-throttled", d))(T || {});
|
|
54
57
|
O = ((r10) => (r10.Retry = "device-retry", r10))(O || {});
|
|
55
58
|
S = ((n) => (n.DeviceApproved = "device-approved", n.DeviceNeedsApproval = "device-needs-approval", n.DeviceVerificationLinkExpired = "device-verification-link-expired", n.DeviceVerificationEmailSent = "device-verification-email-sent", n))(S || {});
|
|
56
59
|
b = ((n) => (n.Retry = "Recency/auth-factor-retry", n.Cancel = "Recency/auth-factor-verification-cancel", n.VerifyEmailOtp = "Recency/auth-factor-verify-email-otp", n.VerifyMFACode = "Recency/verify-mfa-code", n))(b || {});
|
|
57
60
|
C = ((a) => (a.PrimaryAuthFactorNeedsVerification = "Recency/auth-factor-needs-verification", a.PrimaryAuthFactorVerified = "Recency/auth-factor-verified", a.InvalidEmailOtp = "Recency/auth-factor-invalid-email-otp", a.EmailExpired = "Recency/auth-factor-verification-email-expired", a.EmailSent = "Recency/auth-factor-verification-email-sent", a.EmailNotDeliverable = "Recency/auth-factor-verification-email-not-deliverable", a))(C || {});
|
|
58
61
|
F = ((t) => (t.RetryWithNewEmail = "UpdateEmail/retry-with-new-email", t.Cancel = "UpdateEmail/new-email-verification-cancel", t.VerifyEmailOtp = "UpdateEmail/new-email-verify-otp", t))(F || {});
|
|
59
|
-
U = ((
|
|
62
|
+
U = ((p2) => (p2.NewAuthFactorNeedsVerification = "UpdateEmail/new-email-needs-verification", p2.EmailUpdated = "UpdateEmail/email-updated", p2.InvalidEmailOtp = "UpdateEmail/new-email-invalid-email-otp", p2.EmailExpired = "UpdateEmail/new-email-verification-email-expired", p2.EmailSent = "UpdateEmail/new-email-verification-email-sent", p2.EmailNotDeliverable = "UpdateEmail/new-email-verification-email-not-deliverable", p2.InvalidEmail = "UpdateEmail/new-email-invalid", p2.EmailAlreadyExists = "UpdateEmail/new-email-already-exists", p2))(U || {});
|
|
60
63
|
k = ((r10) => (r10.IDTokenCreated = "Auth/id-token-created", r10))(k || {});
|
|
61
64
|
L = ((r10) => (r10.Cancel = "Farcaster/cancel", r10))(L || {});
|
|
62
65
|
w = ((t) => (t.MFASecretGenerated = "mfa-secret-generated", t.InvalidMFAOtp = "invalid-mfa-otp", t.MFARecoveryCodes = "mfa-recovery-codes", t))(w || {});
|
|
63
|
-
D = ((
|
|
66
|
+
D = ((l) => (l.VerifyMFACode = "verify-mfa-code", l.Cancel = "cancel-mfa-setup", l))(D || {});
|
|
64
67
|
V = ((t) => (t.MFACodeRequested = "mfa-code-requested", t.InvalidMFAOtp = "invalid-mfa-otp", t.InvalidRecoveryCode = "invalid-recovery-code", t))(V || {});
|
|
65
68
|
G = ((t) => (t.VerifyMFACode = "verify-mfa-code", t.LostDevice = "lost-device", t.Cancel = "cancel-mfa-disable", t))(G || {});
|
|
66
69
|
H = ((r10) => (r10.Harmony = "HARMONY", r10))(H || {});
|
|
67
70
|
q = ((r10) => (r10.ClosedByUser = "closed-by-user", r10))(q || {});
|
|
68
71
|
W = ((r10) => (r10.ClosedByUser = "closed-by-user-on-received", r10))(W || {});
|
|
69
|
-
J = ((o) => (o.EnterNewPhoneNumber = "enter-new-phone-number", o.EnterOtpCode = "enter-otp-code", o.RecoveryFactorAlreadyExists = "recovery-factor-already-exists", o.MalformedPhoneNumber = "malformed-phone-number", o.InvalidOtpCode = "invalid-otp-code", o))(J || {});
|
|
72
|
+
J = ((o) => (o.EnterNewPhoneNumber = "enter-new-phone-number", o.EnterOtpCode = "enter-otp-code", o.RecoveryFactorAlreadyExists = "recovery-factor-already-exists", o.MalformedPhoneNumber = "malformed-phone-number", o.InvalidOtpCode = "invalid-otp-code", o.RecoveryFactorUpdated = "recovery-factor-updated", o.RecoveryFactorDeleted = "recovery-factor-deleted", o))(J || {});
|
|
70
73
|
Y = ((n) => (n.SendNewPhoneNumber = "send-new-phone-number", n.SendOtpCode = "send-otp-code", n.Cancel = "cancel", n.StartEditPhoneNumber = "start-edit-phone-number", n))(Y || {});
|
|
71
74
|
B = ((r10) => (r10.PhoneNumber = "phone_number", r10))(B || {});
|
|
72
75
|
P = ((a) => (a.SmsOtpSent = "sms-otp-sent", a.LoginThrottled = "login-throttled", a.InvalidSmsOtp = "invalid-sms-otp", a.SmsVerified = "sms-verified", a.AccountRecovered = "account-recovered", a.UpdateEmailRequired = "update-email-required", a))(P || {});
|
|
@@ -77,7 +80,7 @@ var init_es = __esm({
|
|
|
77
80
|
}
|
|
78
81
|
});
|
|
79
82
|
|
|
80
|
-
// ../../node_modules/.pnpm/@magic-sdk+provider@29.
|
|
83
|
+
// ../../node_modules/.pnpm/@magic-sdk+provider@29.4.2_localforage@1.10.0/node_modules/@magic-sdk/provider/dist/es/index.mjs
|
|
81
84
|
function or(r10) {
|
|
82
85
|
let e = { exports: {} };
|
|
83
86
|
return r10(e, e.exports), e.exports;
|
|
@@ -94,28 +97,28 @@ function Gr(r10) {
|
|
|
94
97
|
function Kr(r10) {
|
|
95
98
|
return decodeURIComponent(Array.from(atob(r10), Jr).join(""));
|
|
96
99
|
}
|
|
97
|
-
function
|
|
100
|
+
function ce(r10) {
|
|
98
101
|
return Gr(JSON.stringify(r10));
|
|
99
102
|
}
|
|
100
103
|
function at(r10) {
|
|
101
104
|
return JSON.parse(Kr(r10));
|
|
102
105
|
}
|
|
103
|
-
function
|
|
106
|
+
function N2(r10) {
|
|
104
107
|
return typeof r10 > "u";
|
|
105
108
|
}
|
|
106
109
|
function Br(r10) {
|
|
107
110
|
return r10 === null;
|
|
108
111
|
}
|
|
109
|
-
function
|
|
110
|
-
return Br(r10) ||
|
|
112
|
+
function le(r10) {
|
|
113
|
+
return Br(r10) || N2(r10);
|
|
111
114
|
}
|
|
112
115
|
function ct(r10) {
|
|
113
|
-
return
|
|
116
|
+
return le(r10) ? false : !N2(r10.jsonrpc) && !N2(r10.id) && (!N2(r10.result) || !N2(r10.error));
|
|
114
117
|
}
|
|
115
118
|
function lt(r10) {
|
|
116
|
-
return
|
|
119
|
+
return le(r10) ? false : typeof r10 == "number" && Object.values(u).includes(r10);
|
|
117
120
|
}
|
|
118
|
-
function
|
|
121
|
+
function ee(r10) {
|
|
119
122
|
if (!r10) return true;
|
|
120
123
|
for (let e in r10) if (Object.hasOwnProperty.call(r10, e)) return false;
|
|
121
124
|
return true;
|
|
@@ -170,11 +173,11 @@ function* zr() {
|
|
|
170
173
|
let r10 = 0;
|
|
171
174
|
for (; ; ) r10 < Number.MAX_SAFE_INTEGER ? yield ++r10 : r10 = 0;
|
|
172
175
|
}
|
|
173
|
-
function
|
|
176
|
+
function $e() {
|
|
174
177
|
return Yr.next().value;
|
|
175
178
|
}
|
|
176
179
|
function O2(r10) {
|
|
177
|
-
return async (...e) => (
|
|
180
|
+
return async (...e) => (pe || (pe = await m2.configureStorage()), await pe.ready(), pe[r10](...e));
|
|
178
181
|
}
|
|
179
182
|
function vt() {
|
|
180
183
|
let r10 = window.crypto.getRandomValues(new Uint8Array(16));
|
|
@@ -182,12 +185,12 @@ function vt() {
|
|
|
182
185
|
let e = "";
|
|
183
186
|
return e += r10[0].toString(16), e += r10[1].toString(16), e += r10[2].toString(16), e += r10[3].toString(16), e += "-", e += r10[4].toString(16), e += r10[5].toString(16), e += "-", e += r10[6].toString(16), e += r10[7].toString(16), e += "-", e += r10[8].toString(16), e += r10[9].toString(16), e += "-", e += r10[10].toString(16), e += r10[11].toString(16), e += r10[12].toString(16), e += r10[13].toString(16), e += r10[14].toString(16), e += r10[15].toString(16), e;
|
|
184
187
|
}
|
|
185
|
-
function
|
|
188
|
+
function re() {
|
|
186
189
|
let r10 = typeof window < "u" && !!window.crypto, e = r10 && !!window.crypto.subtle;
|
|
187
190
|
return r10 && e;
|
|
188
191
|
}
|
|
189
192
|
function bt() {
|
|
190
|
-
A2(
|
|
193
|
+
A2(he), A2(Oe);
|
|
191
194
|
}
|
|
192
195
|
async function Pt() {
|
|
193
196
|
let r10 = await sn();
|
|
@@ -195,7 +198,7 @@ async function Pt() {
|
|
|
195
198
|
console.info("unable to create public key or webcrypto is unsupported");
|
|
196
199
|
return;
|
|
197
200
|
}
|
|
198
|
-
let { subtle: e } = window.crypto, t = await R2(
|
|
201
|
+
let { subtle: e } = window.crypto, t = await R2(Oe);
|
|
199
202
|
if (!t || !e) {
|
|
200
203
|
console.info("unable to find private key or webcrypto unsupported");
|
|
201
204
|
return;
|
|
@@ -204,15 +207,15 @@ async function Pt() {
|
|
|
204
207
|
return `${o.protected}.${o.claims}.${c}`;
|
|
205
208
|
}
|
|
206
209
|
async function sn() {
|
|
207
|
-
if (!
|
|
210
|
+
if (!re()) {
|
|
208
211
|
console.info("webcrypto is not supported");
|
|
209
212
|
return;
|
|
210
213
|
}
|
|
211
|
-
return await R2(
|
|
214
|
+
return await R2(he) || await on(), R2(he);
|
|
212
215
|
}
|
|
213
216
|
async function on() {
|
|
214
217
|
let { subtle: r10 } = window.crypto, e = await r10.generateKey(nn, false, ["sign"]), t = await r10.exportKey("jwk", e.publicKey);
|
|
215
|
-
await S2(
|
|
218
|
+
await S2(Oe, e.privateKey), await S2(he, t);
|
|
216
219
|
}
|
|
217
220
|
function Tt(r10) {
|
|
218
221
|
return wt(cn(r10));
|
|
@@ -239,20 +242,20 @@ function un(r10) {
|
|
|
239
242
|
return !!r10[St];
|
|
240
243
|
}
|
|
241
244
|
function F2(r10) {
|
|
242
|
-
return un(r10) || (r10.jsonrpc = r10.jsonrpc ?? "2.0", r10.id =
|
|
245
|
+
return un(r10) || (r10.jsonrpc = r10.jsonrpc ?? "2.0", r10.id = $e(), r10.method = r10.method ?? "noop", r10.params = r10.params ?? [], xt(r10)), r10;
|
|
243
246
|
}
|
|
244
247
|
function p(r10, e = []) {
|
|
245
|
-
return xt({ params: e, method: r10, jsonrpc: "2.0", id:
|
|
248
|
+
return xt({ params: e, method: r10, jsonrpc: "2.0", id: $e() });
|
|
246
249
|
}
|
|
247
|
-
function
|
|
248
|
-
let r10 = new
|
|
250
|
+
function fe() {
|
|
251
|
+
let r10 = new ke();
|
|
249
252
|
return { emitter: r10, createChainingEmitterMethod: (s, n) => (...o) => (r10[s].apply(r10, o), n), createBoundEmitterMethod: (s) => (...n) => r10[s].apply(r10, n) };
|
|
250
253
|
}
|
|
251
254
|
function $t(r10) {
|
|
252
255
|
return !!r10[At];
|
|
253
256
|
}
|
|
254
257
|
function b2(r10) {
|
|
255
|
-
let e =
|
|
258
|
+
let e = De(r10), { createBoundEmitterMethod: t, createChainingEmitterMethod: s } = fe(), n = Symbol("Promise.then"), o = Symbol("Promise.catch"), i = Symbol("Promise.finally"), a = (l, u2) => (...P2) => {
|
|
256
259
|
let w2 = u2[l].apply(u2, P2);
|
|
257
260
|
return c(w2);
|
|
258
261
|
}, c = (l) => Object.assign(l, { [At]: true, [n]: l[n] || l.then, [o]: l[o] || l.catch, [i]: l[i] || l.finally, then: a(n, l), catch: a(o, l), finally: a(i, l), on: s("on", l), once: s("once", l), addListener: s("addListener", l), off: s("off", l), removeListener: s("removeListener", l), removeAllListeners: s("removeAllListeners", l), emit: t("emit"), eventNames: t("eventNames"), listeners: t("listeners"), listenerCount: t("listenerCount") }), d = c(e.then((l) => (d.emit("done", l), d.emit("settled"), l), (l) => {
|
|
@@ -262,7 +265,7 @@ function b2(r10) {
|
|
|
262
265
|
d.emit(q.ClosedByUser);
|
|
263
266
|
}), d;
|
|
264
267
|
}
|
|
265
|
-
function
|
|
268
|
+
function De(r10) {
|
|
266
269
|
return new Promise((e, t) => {
|
|
267
270
|
let s = r10(e, t);
|
|
268
271
|
Promise.resolve(s).catch(t);
|
|
@@ -272,10 +275,10 @@ function Lt(r10, e) {
|
|
|
272
275
|
let [t] = r10.split(".").map(Number);
|
|
273
276
|
return t >= e;
|
|
274
277
|
}
|
|
275
|
-
async function
|
|
278
|
+
async function Re() {
|
|
276
279
|
let r10 = [];
|
|
277
|
-
await
|
|
278
|
-
t.startsWith(`${
|
|
280
|
+
await Le((e, t, s) => {
|
|
281
|
+
t.startsWith(`${qe}_`) && r10.push(t);
|
|
279
282
|
});
|
|
280
283
|
for (let e of r10) await A2(e);
|
|
281
284
|
}
|
|
@@ -290,72 +293,67 @@ function kt(r10) {
|
|
|
290
293
|
return s.buffer;
|
|
291
294
|
}
|
|
292
295
|
async function In() {
|
|
293
|
-
if (!
|
|
296
|
+
if (!re()) {
|
|
294
297
|
console.info("webcrypto is not supported");
|
|
295
298
|
return;
|
|
296
299
|
}
|
|
297
|
-
let { crypto: r10 } = window, e = await R2(
|
|
300
|
+
let { crypto: r10 } = window, e = await R2(Fe);
|
|
298
301
|
return e || r10.getRandomValues(new Uint8Array(12));
|
|
299
302
|
}
|
|
300
303
|
async function bn() {
|
|
301
|
-
if (!
|
|
304
|
+
if (!re()) {
|
|
302
305
|
console.info("webcrypto is not supported");
|
|
303
306
|
return;
|
|
304
307
|
}
|
|
305
|
-
let { subtle: r10 } = window.crypto, e = await R2(
|
|
306
|
-
return e || await r10.generateKey({ name:
|
|
308
|
+
let { subtle: r10 } = window.crypto, e = await R2(Ue);
|
|
309
|
+
return e || await r10.generateKey({ name: We, length: Tn }, false, ["encrypt", "decrypt"]);
|
|
307
310
|
}
|
|
308
311
|
async function Dt(r10, e) {
|
|
309
312
|
let t = await In(), s = await bn();
|
|
310
313
|
if (!t || !s || !r10) return;
|
|
311
|
-
let n = kt(r10), { subtle: o } = window.crypto, i = await o.encrypt({ name:
|
|
312
|
-
await S2(`${
|
|
314
|
+
let n = kt(r10), { subtle: o } = window.crypto, i = await o.encrypt({ name: We, iv: t }, s, n), a = _t(i);
|
|
315
|
+
await S2(`${qe}_${e}`, a), await S2(Ue, s), await S2(Fe, t);
|
|
313
316
|
}
|
|
314
317
|
async function qt(r10) {
|
|
315
|
-
let e = await R2(`${
|
|
316
|
-
if (!t || !e || !s || !
|
|
317
|
-
let { subtle: n } = window.crypto, o = await n.decrypt({ name:
|
|
318
|
+
let e = await R2(`${qe}_${r10}`), t = await R2(Fe), s = await R2(Ue);
|
|
319
|
+
if (!t || !e || !s || !re()) return;
|
|
320
|
+
let { subtle: n } = window.crypto, o = await n.decrypt({ name: We, iv: t }, s, kt(e));
|
|
318
321
|
return _t(o);
|
|
319
322
|
}
|
|
320
|
-
function
|
|
323
|
+
function Je(r10, e) {
|
|
321
324
|
return e ? new URL(r10, e) : new URL(r10);
|
|
322
325
|
}
|
|
323
|
-
function
|
|
324
|
-
let e = Object.getPrototypeOf(r10), t = [e];
|
|
325
|
-
for (; e !== f2.prototype; ) e = Object.getPrototypeOf(e), t.push(e);
|
|
326
|
-
return t;
|
|
327
|
-
}
|
|
328
|
-
function Jt(r10) {
|
|
326
|
+
function Wt(r10) {
|
|
329
327
|
return r10.compat && r10.compat[m2.sdkName] != null ? typeof r10.compat[m2.sdkName] == "string" ? ot(it(m2.version), r10.compat[m2.sdkName]) : !!r10.compat[m2.sdkName] : true;
|
|
330
328
|
}
|
|
331
|
-
function
|
|
329
|
+
function wn(r10, e, t) {
|
|
332
330
|
return !e && !t ? `${r10}_eth_mainnet` : t ? `${r10}_${JSON.stringify(t)}` : e ? typeof e == "string" ? `${r10}_eth_${e}` : `${r10}_${e.rpcUrl}_${e.chainId}_${e.chainType}` : `${r10}_unknown`;
|
|
333
331
|
}
|
|
334
|
-
function
|
|
332
|
+
function Sn(r10) {
|
|
335
333
|
let e = r10?.extensions ?? [], t = {}, s = [];
|
|
336
334
|
if (Array.isArray(e) ? e.forEach((n) => {
|
|
337
|
-
|
|
335
|
+
Wt(n) ? (n.init(this), n.name && (this[n.name] = n), ee(n.config) || (t[n.name] = n.config)) : s.push(n);
|
|
338
336
|
}) : Object.keys(e).forEach((n) => {
|
|
339
|
-
if (
|
|
337
|
+
if (Wt(e[n])) {
|
|
340
338
|
e[n].init(this);
|
|
341
339
|
let o = e[n];
|
|
342
|
-
this[n] = o,
|
|
340
|
+
this[n] = o, ee(o.config) || (t[e[n].name] = o.config);
|
|
343
341
|
} else s.push(e[n]);
|
|
344
342
|
}), s.length) throw Et(s);
|
|
345
343
|
return t;
|
|
346
344
|
}
|
|
347
|
-
function
|
|
345
|
+
function xn(r10, e) {
|
|
348
346
|
return e && Array.isArray(r10) ? r10.find((t) => t.id === e) : r10;
|
|
349
347
|
}
|
|
350
|
-
function
|
|
351
|
-
let t = e.data.response?.id, s =
|
|
348
|
+
function Jt(r10, e) {
|
|
349
|
+
let t = e.data.response?.id, s = xn(r10, t);
|
|
352
350
|
if (t && s) {
|
|
353
351
|
let n = new K(s).applyResult(e.data.response.result).applyError(e.data.response.error);
|
|
354
352
|
return { id: t, response: n };
|
|
355
353
|
}
|
|
356
354
|
return {};
|
|
357
355
|
}
|
|
358
|
-
async function
|
|
356
|
+
async function Gt(r10, e, t) {
|
|
359
357
|
let s = await R2("rt"), n;
|
|
360
358
|
if (m2.platform === "web") try {
|
|
361
359
|
n = await R2("jwt") ?? await Pt();
|
|
@@ -367,10 +365,10 @@ async function Kt(r10, e, t) {
|
|
|
367
365
|
let i = await qt(t);
|
|
368
366
|
return i && (o.deviceShare = i), o;
|
|
369
367
|
}
|
|
370
|
-
async function
|
|
368
|
+
async function Kt(r10) {
|
|
371
369
|
r10.data.rt && await S2("rt", r10.data.rt);
|
|
372
370
|
}
|
|
373
|
-
function
|
|
371
|
+
function jt(r10, e) {
|
|
374
372
|
let t = null;
|
|
375
373
|
return function(...s) {
|
|
376
374
|
t && clearTimeout(t), t = setTimeout(() => {
|
|
@@ -378,9 +376,14 @@ function Vt(r10, e) {
|
|
|
378
376
|
}, e);
|
|
379
377
|
};
|
|
380
378
|
}
|
|
381
|
-
|
|
379
|
+
function $n(r10) {
|
|
380
|
+
let e = Object.getPrototypeOf(r10), t = [e];
|
|
381
|
+
for (; e !== f2.prototype; ) e = Object.getPrototypeOf(e), t.push(e);
|
|
382
|
+
return t;
|
|
383
|
+
}
|
|
384
|
+
var zt, Ce, Yt, Qt, Zt, er, tr, rr, nr, sr, Ct, ir, Ae, ar, h2, Z2, Xe, st, cr, lr, ze, oe, Ye, Qe, X2, M, dr, J2, ur, pr, mr, hr, Er, fr, gr, yr, Rr, vr, Tr, Ir, br, Ne, z2, Y2, Ze, et, Q2, y2, E2, Pr, wr, Sr, tt, xr, T2, Mr, Cr, Nr, Ar, $r, Lr, Or, _r, kr, Dr, ot, qr, rt, nt, Ur, Fr, ie, ae, it, m2, dt, $, U2, L2, de, te, Yr, me, pe, R2, S2, A2, Qr, Zr, en, tn, Le, Oe, he, It, rn, nn, St, K, Nt, ke, At, f2, vn, ye, qe, Ue, Fe, We, Tn, Te, Ie, Pe, we, H2, Se, Me, Ke, Nn, Bt, Vt, An, je, Ht, Ve, Be, He;
|
|
382
385
|
var init_es2 = __esm({
|
|
383
|
-
"../../node_modules/.pnpm/@magic-sdk+provider@29.
|
|
386
|
+
"../../node_modules/.pnpm/@magic-sdk+provider@29.4.2_localforage@1.10.0/node_modules/@magic-sdk/provider/dist/es/index.mjs"() {
|
|
384
387
|
"use strict";
|
|
385
388
|
init_es();
|
|
386
389
|
init_es();
|
|
@@ -409,12 +412,12 @@ var init_es2 = __esm({
|
|
|
409
412
|
return r10;
|
|
410
413
|
};
|
|
411
414
|
sr = (r10, e, t) => (t = r10 != null ? zt(Zt(r10)) : {}, nr(e || !r10 || !r10.__esModule ? Ce(t, "default", { value: r10, enumerable: true }) : t, r10));
|
|
412
|
-
|
|
415
|
+
Ct = tr((ls, _e) => {
|
|
413
416
|
"use strict";
|
|
414
417
|
var pn = Object.prototype.hasOwnProperty, I2 = "~";
|
|
415
|
-
function
|
|
418
|
+
function ne() {
|
|
416
419
|
}
|
|
417
|
-
Object.create && (
|
|
420
|
+
Object.create && (ne.prototype = /* @__PURE__ */ Object.create(null), new ne().__proto__ || (I2 = false));
|
|
418
421
|
function mn(r10, e, t) {
|
|
419
422
|
this.fn = r10, this.context = e, this.once = t || false;
|
|
420
423
|
}
|
|
@@ -423,11 +426,11 @@ var init_es2 = __esm({
|
|
|
423
426
|
var o = new mn(t, s || r10, n), i = I2 ? I2 + e : e;
|
|
424
427
|
return r10._events[i] ? r10._events[i].fn ? r10._events[i] = [r10._events[i], o] : r10._events[i].push(o) : (r10._events[i] = o, r10._eventsCount++), r10;
|
|
425
428
|
}
|
|
426
|
-
function
|
|
427
|
-
--r10._eventsCount === 0 ? r10._events = new
|
|
429
|
+
function Ee(r10, e) {
|
|
430
|
+
--r10._eventsCount === 0 ? r10._events = new ne() : delete r10._events[e];
|
|
428
431
|
}
|
|
429
432
|
function v2() {
|
|
430
|
-
this._events = new
|
|
433
|
+
this._events = new ne(), this._eventsCount = 0;
|
|
431
434
|
}
|
|
432
435
|
v2.prototype.eventNames = function() {
|
|
433
436
|
var e = [], t, s;
|
|
@@ -498,32 +501,32 @@ var init_es2 = __esm({
|
|
|
498
501
|
v2.prototype.removeListener = function(e, t, s, n) {
|
|
499
502
|
var o = I2 ? I2 + e : e;
|
|
500
503
|
if (!this._events[o]) return this;
|
|
501
|
-
if (!t) return
|
|
504
|
+
if (!t) return Ee(this, o), this;
|
|
502
505
|
var i = this._events[o];
|
|
503
|
-
if (i.fn) i.fn === t && (!n || i.once) && (!s || i.context === s) &&
|
|
506
|
+
if (i.fn) i.fn === t && (!n || i.once) && (!s || i.context === s) && Ee(this, o);
|
|
504
507
|
else {
|
|
505
508
|
for (var a = 0, c = [], d = i.length; a < d; a++) (i[a].fn !== t || n && !i[a].once || s && i[a].context !== s) && c.push(i[a]);
|
|
506
|
-
c.length ? this._events[o] = c.length === 1 ? c[0] : c :
|
|
509
|
+
c.length ? this._events[o] = c.length === 1 ? c[0] : c : Ee(this, o);
|
|
507
510
|
}
|
|
508
511
|
return this;
|
|
509
512
|
};
|
|
510
513
|
v2.prototype.removeAllListeners = function(e) {
|
|
511
514
|
var t;
|
|
512
|
-
return e ? (t = I2 ? I2 + e : e, this._events[t] &&
|
|
515
|
+
return e ? (t = I2 ? I2 + e : e, this._events[t] && Ee(this, t)) : (this._events = new ne(), this._eventsCount = 0), this;
|
|
513
516
|
};
|
|
514
517
|
v2.prototype.off = v2.prototype.removeListener;
|
|
515
518
|
v2.prototype.addListener = v2.prototype.on;
|
|
516
519
|
v2.prefixed = I2;
|
|
517
520
|
v2.EventEmitter = v2;
|
|
518
|
-
typeof
|
|
521
|
+
typeof _e < "u" && (_e.exports = v2);
|
|
519
522
|
});
|
|
520
523
|
ir = Number.MAX_SAFE_INTEGER || 9007199254740991;
|
|
521
|
-
|
|
524
|
+
Ae = { SEMVER_SPEC_VERSION: "2.0.0", MAX_LENGTH: 256, MAX_SAFE_INTEGER: ir, MAX_SAFE_COMPONENT_LENGTH: 16 };
|
|
522
525
|
ar = typeof process == "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...r10) => console.error("SEMVER", ...r10) : () => {
|
|
523
526
|
};
|
|
524
527
|
h2 = ar;
|
|
525
|
-
|
|
526
|
-
let { MAX_SAFE_COMPONENT_LENGTH: t } =
|
|
528
|
+
Z2 = or(function(r10, e) {
|
|
529
|
+
let { MAX_SAFE_COMPONENT_LENGTH: t } = Ae, s = (e = r10.exports = {}).re = [], n = e.src = [], o = e.t = {}, i = 0, a = (c, d, l) => {
|
|
527
530
|
let u2 = i++;
|
|
528
531
|
h2(u2, d), o[c] = u2, n[u2] = d, s[u2] = new RegExp(d, l ? "g" : void 0);
|
|
529
532
|
};
|
|
@@ -536,9 +539,9 @@ var init_es2 = __esm({
|
|
|
536
539
|
};
|
|
537
540
|
cr = (r10, e) => st(e, r10);
|
|
538
541
|
lr = { compareIdentifiers: st, rcompareIdentifiers: cr };
|
|
539
|
-
({ MAX_LENGTH: ze, MAX_SAFE_INTEGER:
|
|
540
|
-
({ re: Ye, t: Qe } =
|
|
541
|
-
({ compareIdentifiers:
|
|
542
|
+
({ MAX_LENGTH: ze, MAX_SAFE_INTEGER: oe } = Ae);
|
|
543
|
+
({ re: Ye, t: Qe } = Z2);
|
|
544
|
+
({ compareIdentifiers: X2 } = lr);
|
|
542
545
|
M = class r {
|
|
543
546
|
constructor(e, t) {
|
|
544
547
|
if (t && typeof t == "object" || (t = { loose: !!t, includePrerelease: false }), e instanceof r) {
|
|
@@ -549,13 +552,13 @@ var init_es2 = __esm({
|
|
|
549
552
|
h2("SemVer", e, t), this.options = t, this.loose = !!t.loose, this.includePrerelease = !!t.includePrerelease;
|
|
550
553
|
let s = e.trim().match(t.loose ? Ye[Qe.LOOSE] : Ye[Qe.FULL]);
|
|
551
554
|
if (!s) throw new TypeError(`Invalid Version: ${e}`);
|
|
552
|
-
if (this.raw = e, this.major = +s[1], this.minor = +s[2], this.patch = +s[3], this.major >
|
|
553
|
-
if (this.minor >
|
|
554
|
-
if (this.patch >
|
|
555
|
+
if (this.raw = e, this.major = +s[1], this.minor = +s[2], this.patch = +s[3], this.major > oe || this.major < 0) throw new TypeError("Invalid major version");
|
|
556
|
+
if (this.minor > oe || this.minor < 0) throw new TypeError("Invalid minor version");
|
|
557
|
+
if (this.patch > oe || this.patch < 0) throw new TypeError("Invalid patch version");
|
|
555
558
|
s[4] ? this.prerelease = s[4].split(".").map((n) => {
|
|
556
559
|
if (/^[0-9]+$/.test(n)) {
|
|
557
560
|
let o = +n;
|
|
558
|
-
if (o >= 0 && o <
|
|
561
|
+
if (o >= 0 && o < oe) return o;
|
|
559
562
|
}
|
|
560
563
|
return n;
|
|
561
564
|
}) : this.prerelease = [], this.build = s[5] ? s[5].split(".") : [], this.format();
|
|
@@ -574,7 +577,7 @@ var init_es2 = __esm({
|
|
|
574
577
|
return e.version === this.version ? 0 : this.compareMain(e) || this.comparePre(e);
|
|
575
578
|
}
|
|
576
579
|
compareMain(e) {
|
|
577
|
-
return e instanceof r || (e = new r(e, this.options)),
|
|
580
|
+
return e instanceof r || (e = new r(e, this.options)), X2(this.major, e.major) || X2(this.minor, e.minor) || X2(this.patch, e.patch);
|
|
578
581
|
}
|
|
579
582
|
comparePre(e) {
|
|
580
583
|
if (e instanceof r || (e = new r(e, this.options)), this.prerelease.length && !e.prerelease.length) return -1;
|
|
@@ -586,7 +589,7 @@ var init_es2 = __esm({
|
|
|
586
589
|
if (h2("prerelease compare", t, s, n), s === void 0 && n === void 0) return 0;
|
|
587
590
|
if (n === void 0) return 1;
|
|
588
591
|
if (s === void 0) return -1;
|
|
589
|
-
if (s !== n) return
|
|
592
|
+
if (s !== n) return X2(s, n);
|
|
590
593
|
} while (++t);
|
|
591
594
|
}
|
|
592
595
|
compareBuild(e) {
|
|
@@ -597,7 +600,7 @@ var init_es2 = __esm({
|
|
|
597
600
|
if (h2("prerelease compare", t, s, n), s === void 0 && n === void 0) return 0;
|
|
598
601
|
if (n === void 0) return 1;
|
|
599
602
|
if (s === void 0) return -1;
|
|
600
|
-
if (s !== n) return
|
|
603
|
+
if (s !== n) return X2(s, n);
|
|
601
604
|
} while (++t);
|
|
602
605
|
}
|
|
603
606
|
inc(e, t) {
|
|
@@ -676,49 +679,49 @@ var init_es2 = __esm({
|
|
|
676
679
|
throw new TypeError(`Invalid operator: ${e}`);
|
|
677
680
|
}
|
|
678
681
|
};
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
+
Ne = br;
|
|
683
|
+
z2 = Symbol("SemVer ANY");
|
|
684
|
+
Y2 = class r2 {
|
|
682
685
|
static get ANY() {
|
|
683
|
-
return
|
|
686
|
+
return z2;
|
|
684
687
|
}
|
|
685
688
|
constructor(e, t) {
|
|
686
689
|
if (t && typeof t == "object" || (t = { loose: !!t, includePrerelease: false }), e instanceof r2) {
|
|
687
690
|
if (e.loose === !!t.loose) return e;
|
|
688
691
|
e = e.value;
|
|
689
692
|
}
|
|
690
|
-
h2("comparator", e, t), this.options = t, this.loose = !!t.loose, this.parse(e), this.semver ===
|
|
693
|
+
h2("comparator", e, t), this.options = t, this.loose = !!t.loose, this.parse(e), this.semver === z2 ? this.value = "" : this.value = this.operator + this.semver.version, h2("comp", this);
|
|
691
694
|
}
|
|
692
695
|
parse(e) {
|
|
693
696
|
let t = this.options.loose ? Ze[et.COMPARATORLOOSE] : Ze[et.COMPARATOR], s = e.match(t);
|
|
694
697
|
if (!s) throw new TypeError(`Invalid comparator: ${e}`);
|
|
695
|
-
this.operator = s[1] !== void 0 ? s[1] : "", this.operator === "=" && (this.operator = ""), s[2] ? this.semver = new M(s[2], this.options.loose) : this.semver =
|
|
698
|
+
this.operator = s[1] !== void 0 ? s[1] : "", this.operator === "=" && (this.operator = ""), s[2] ? this.semver = new M(s[2], this.options.loose) : this.semver = z2;
|
|
696
699
|
}
|
|
697
700
|
toString() {
|
|
698
701
|
return this.value;
|
|
699
702
|
}
|
|
700
703
|
test(e) {
|
|
701
|
-
if (h2("Comparator.test", e, this.options.loose), this.semver ===
|
|
704
|
+
if (h2("Comparator.test", e, this.options.loose), this.semver === z2 || e === z2) return true;
|
|
702
705
|
if (typeof e == "string") try {
|
|
703
706
|
e = new M(e, this.options);
|
|
704
707
|
} catch {
|
|
705
708
|
return false;
|
|
706
709
|
}
|
|
707
|
-
return
|
|
710
|
+
return Ne(e, this.operator, this.semver, this.options);
|
|
708
711
|
}
|
|
709
712
|
intersects(e, t) {
|
|
710
713
|
if (!(e instanceof r2)) throw new TypeError("a Comparator is required");
|
|
711
|
-
if (t && typeof t == "object" || (t = { loose: !!t, includePrerelease: false }), this.operator === "") return this.value === "" || new
|
|
712
|
-
if (e.operator === "") return e.value === "" || new
|
|
713
|
-
let s = !(this.operator !== ">=" && this.operator !== ">" || e.operator !== ">=" && e.operator !== ">"), n = !(this.operator !== "<=" && this.operator !== "<" || e.operator !== "<=" && e.operator !== "<"), o = this.semver.version === e.semver.version, i = !(this.operator !== ">=" && this.operator !== "<=" || e.operator !== ">=" && e.operator !== "<="), a =
|
|
714
|
+
if (t && typeof t == "object" || (t = { loose: !!t, includePrerelease: false }), this.operator === "") return this.value === "" || new Q2(e.value, t).test(this.value);
|
|
715
|
+
if (e.operator === "") return e.value === "" || new Q2(this.value, t).test(e.semver);
|
|
716
|
+
let s = !(this.operator !== ">=" && this.operator !== ">" || e.operator !== ">=" && e.operator !== ">"), n = !(this.operator !== "<=" && this.operator !== "<" || e.operator !== "<=" && e.operator !== "<"), o = this.semver.version === e.semver.version, i = !(this.operator !== ">=" && this.operator !== "<=" || e.operator !== ">=" && e.operator !== "<="), a = Ne(this.semver, "<", e.semver, t) && (this.operator === ">=" || this.operator === ">") && (e.operator === "<=" || e.operator === "<"), c = Ne(this.semver, ">", e.semver, t) && (this.operator === "<=" || this.operator === "<") && (e.operator === ">=" || e.operator === ">");
|
|
714
717
|
return s || n || o && i || a || c;
|
|
715
718
|
}
|
|
716
719
|
};
|
|
717
|
-
({ re: Ze, t: et } =
|
|
718
|
-
|
|
720
|
+
({ re: Ze, t: et } = Z2);
|
|
721
|
+
Q2 = class r3 {
|
|
719
722
|
constructor(e, t) {
|
|
720
723
|
if (t && typeof t == "object" || (t = { loose: !!t, includePrerelease: false }), e instanceof r3) return e.loose === !!t.loose && e.includePrerelease === !!t.includePrerelease ? e : new r3(e.raw, t);
|
|
721
|
-
if (e instanceof
|
|
724
|
+
if (e instanceof Y2) return this.raw = e.value, this.set = [[e]], this.format(), this;
|
|
722
725
|
if (this.options = t, this.loose = !!t.loose, this.includePrerelease = !!t.includePrerelease, this.raw = e, this.set = e.split(/\s*\|\|\s*/).map((s) => this.parseRange(s.trim())).filter((s) => s.length), !this.set.length) throw new TypeError(`Invalid SemVer Range: ${e}`);
|
|
723
726
|
this.format();
|
|
724
727
|
}
|
|
@@ -734,7 +737,7 @@ var init_es2 = __esm({
|
|
|
734
737
|
let s = t ? y2[E2.HYPHENRANGELOOSE] : y2[E2.HYPHENRANGE];
|
|
735
738
|
e = e.replace(s, kr(this.options.includePrerelease)), h2("hyphen replace", e), e = e.replace(y2[E2.COMPARATORTRIM], Pr), h2("comparator trim", e, y2[E2.COMPARATORTRIM]), e = (e = (e = e.replace(y2[E2.TILDETRIM], wr)).replace(y2[E2.CARETTRIM], Sr)).split(/\s+/).join(" ");
|
|
736
739
|
let n = t ? y2[E2.COMPARATORLOOSE] : y2[E2.COMPARATOR];
|
|
737
|
-
return e.split(" ").map((o) => xr(o, this.options)).join(" ").split(/\s+/).map((o) => _r(o, this.options)).filter(this.options.loose ? (o) => !!o.match(n) : () => true).map((o) => new
|
|
740
|
+
return e.split(" ").map((o) => xr(o, this.options)).join(" ").split(/\s+/).map((o) => _r(o, this.options)).filter(this.options.loose ? (o) => !!o.match(n) : () => true).map((o) => new Y2(o, this.options));
|
|
738
741
|
}
|
|
739
742
|
intersects(e, t) {
|
|
740
743
|
if (!(e instanceof r3)) throw new TypeError("a Range is required");
|
|
@@ -751,23 +754,23 @@ var init_es2 = __esm({
|
|
|
751
754
|
return false;
|
|
752
755
|
}
|
|
753
756
|
};
|
|
754
|
-
({ re: y2, t: E2, comparatorTrimReplace: Pr, tildeTrimReplace: wr, caretTrimReplace: Sr } =
|
|
757
|
+
({ re: y2, t: E2, comparatorTrimReplace: Pr, tildeTrimReplace: wr, caretTrimReplace: Sr } = Z2);
|
|
755
758
|
tt = (r10, e) => {
|
|
756
759
|
let t = true, s = r10.slice(), n = s.pop();
|
|
757
760
|
for (; t && s.length; ) t = s.every((o) => n.intersects(o, e)), n = s.pop();
|
|
758
761
|
return t;
|
|
759
762
|
};
|
|
760
|
-
xr = (r10, e) => (h2("comp", r10, e), r10 =
|
|
763
|
+
xr = (r10, e) => (h2("comp", r10, e), r10 = Nr(r10, e), h2("caret", r10), r10 = Mr(r10, e), h2("tildes", r10), r10 = $r(r10, e), h2("xrange", r10), r10 = Or(r10, e), h2("stars", r10), r10);
|
|
761
764
|
T2 = (r10) => !r10 || r10.toLowerCase() === "x" || r10 === "*";
|
|
762
|
-
Mr = (r10, e) => r10.trim().split(/\s+/).map((t) =>
|
|
763
|
-
|
|
765
|
+
Mr = (r10, e) => r10.trim().split(/\s+/).map((t) => Cr(t, e)).join(" ");
|
|
766
|
+
Cr = (r10, e) => {
|
|
764
767
|
let t = e.loose ? y2[E2.TILDELOOSE] : y2[E2.TILDE];
|
|
765
768
|
return r10.replace(t, (s, n, o, i, a) => {
|
|
766
769
|
let c;
|
|
767
770
|
return h2("tilde", r10, s, n, o, i, a), T2(n) ? c = "" : T2(o) ? c = `>=${n}.0.0 <${+n + 1}.0.0-0` : T2(i) ? c = `>=${n}.${o}.0 <${n}.${+o + 1}.0-0` : a ? (h2("replaceTilde pr", a), c = `>=${n}.${o}.${i}-${a} <${n}.${+o + 1}.0-0`) : c = `>=${n}.${o}.${i} <${n}.${+o + 1}.0-0`, h2("tilde return", c), c;
|
|
768
771
|
});
|
|
769
772
|
};
|
|
770
|
-
|
|
773
|
+
Nr = (r10, e) => r10.trim().split(/\s+/).map((t) => Ar(t, e)).join(" ");
|
|
771
774
|
Ar = (r10, e) => {
|
|
772
775
|
h2("caret", r10, e);
|
|
773
776
|
let t = e.loose ? y2[E2.CARETLOOSE] : y2[E2.CARET], s = e.includePrerelease ? "-0" : "";
|
|
@@ -792,7 +795,7 @@ var init_es2 = __esm({
|
|
|
792
795
|
Dr = (r10, e, t) => {
|
|
793
796
|
for (let s = 0; s < r10.length; s++) if (!r10[s].test(e)) return false;
|
|
794
797
|
if (e.prerelease.length && !t.includePrerelease) {
|
|
795
|
-
for (let s = 0; s < r10.length; s++) if (h2(r10[s].semver), r10[s].semver !==
|
|
798
|
+
for (let s = 0; s < r10.length; s++) if (h2(r10[s].semver), r10[s].semver !== Y2.ANY && r10[s].semver.prerelease.length > 0) {
|
|
796
799
|
let n = r10[s].semver;
|
|
797
800
|
if (n.major === e.major && n.minor === e.minor && n.patch === e.patch) return true;
|
|
798
801
|
}
|
|
@@ -802,14 +805,14 @@ var init_es2 = __esm({
|
|
|
802
805
|
};
|
|
803
806
|
ot = (r10, e, t) => {
|
|
804
807
|
try {
|
|
805
|
-
e = new
|
|
808
|
+
e = new Q2(e, t);
|
|
806
809
|
} catch {
|
|
807
810
|
return false;
|
|
808
811
|
}
|
|
809
812
|
return e.test(r10);
|
|
810
813
|
};
|
|
811
|
-
({ MAX_LENGTH: qr } =
|
|
812
|
-
({ re: rt, t: nt } =
|
|
814
|
+
({ MAX_LENGTH: qr } = Ae);
|
|
815
|
+
({ re: rt, t: nt } = Z2);
|
|
813
816
|
Ur = (r10, e) => {
|
|
814
817
|
if (e && typeof e == "object" || (e = { loose: !!e, includePrerelease: false }), r10 instanceof M) return r10;
|
|
815
818
|
if (typeof r10 != "string" || r10.length > qr || !(e.loose ? rt[nt.LOOSE] : rt[nt.FULL]).test(r10)) return null;
|
|
@@ -820,16 +823,16 @@ var init_es2 = __esm({
|
|
|
820
823
|
}
|
|
821
824
|
};
|
|
822
825
|
Fr = Ur;
|
|
823
|
-
({ re:
|
|
826
|
+
({ re: ie, t: ae } = Z2);
|
|
824
827
|
it = (r10, e) => {
|
|
825
828
|
if (r10 instanceof M) return r10;
|
|
826
829
|
if (typeof r10 == "number" && (r10 = String(r10)), typeof r10 != "string") return null;
|
|
827
830
|
let t = null;
|
|
828
831
|
if ((e = e || {}).rtl) {
|
|
829
832
|
let s;
|
|
830
|
-
for (; (s = ae
|
|
831
|
-
ae
|
|
832
|
-
} else t = r10.match(ae
|
|
833
|
+
for (; (s = ie[ae.COERCERTL].exec(r10)) && (!t || t.index + t[0].length !== r10.length); ) t && s.index + s[0].length === t.index + t[0].length || (t = s), ie[ae.COERCERTL].lastIndex = s.index + s[1].length + s[2].length;
|
|
834
|
+
ie[ae.COERCERTL].lastIndex = -1;
|
|
835
|
+
} else t = r10.match(ie[ae.COERCE]);
|
|
833
836
|
return t === null ? null : Fr(`${t[2]}.${t[3] || "0"}.${t[4] || "0"}`, e);
|
|
834
837
|
};
|
|
835
838
|
m2 = {};
|
|
@@ -865,7 +868,7 @@ var init_es2 = __esm({
|
|
|
865
868
|
console.warn(this.message);
|
|
866
869
|
}
|
|
867
870
|
};
|
|
868
|
-
|
|
871
|
+
de = class r6 extends Error {
|
|
869
872
|
constructor(t, s, n, o) {
|
|
870
873
|
super(`Magic Extension Error (${t.name}): [${s}] ${n}`);
|
|
871
874
|
this.code = s;
|
|
@@ -875,7 +878,7 @@ var init_es2 = __esm({
|
|
|
875
878
|
}
|
|
876
879
|
__proto__ = Error;
|
|
877
880
|
};
|
|
878
|
-
|
|
881
|
+
te = class {
|
|
879
882
|
constructor(e, t, s) {
|
|
880
883
|
this.code = t;
|
|
881
884
|
this.rawMessage = s;
|
|
@@ -887,8 +890,8 @@ var init_es2 = __esm({
|
|
|
887
890
|
}
|
|
888
891
|
};
|
|
889
892
|
Yr = zr();
|
|
890
|
-
|
|
891
|
-
rr(
|
|
893
|
+
me = {};
|
|
894
|
+
rr(me, { clear: () => Qr, getItem: () => R2, iterate: () => Le, key: () => en, keys: () => tn, length: () => Zr, removeItem: () => A2, setItem: () => S2 });
|
|
892
895
|
R2 = O2("getItem");
|
|
893
896
|
S2 = O2("setItem");
|
|
894
897
|
A2 = O2("removeItem");
|
|
@@ -896,9 +899,9 @@ var init_es2 = __esm({
|
|
|
896
899
|
Zr = O2("length");
|
|
897
900
|
en = O2("key");
|
|
898
901
|
tn = O2("keys");
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
+
Le = O2("iterate");
|
|
903
|
+
Oe = "STORE_KEY_PRIVATE_KEY";
|
|
904
|
+
he = "STORE_KEY_PUBLIC_JWK";
|
|
902
905
|
It = "ECDSA";
|
|
903
906
|
rn = "P-256";
|
|
904
907
|
nn = { name: It, namedCurve: rn };
|
|
@@ -927,8 +930,8 @@ var init_es2 = __esm({
|
|
|
927
930
|
return { jsonrpc: this._jsonrpc, id: this._id, result: this._result, error: this._error };
|
|
928
931
|
}
|
|
929
932
|
};
|
|
930
|
-
|
|
931
|
-
|
|
933
|
+
Nt = sr(Ct());
|
|
934
|
+
ke = class extends Nt.default {
|
|
932
935
|
};
|
|
933
936
|
At = Symbol("isPromiEvent");
|
|
934
937
|
f2 = class {
|
|
@@ -942,7 +945,7 @@ var init_es2 = __esm({
|
|
|
942
945
|
if (this.sdk.thirdPartyWallets.isConnected && !Z.includes(e.method)) return b2((i, a) => {
|
|
943
946
|
this.sdk.thirdPartyWallets.requestOverride(e).then(i).catch(a);
|
|
944
947
|
});
|
|
945
|
-
let t = this.overlay.post(
|
|
948
|
+
let t = this.overlay.post(y.MAGIC_HANDLE_REQUEST, F2(e)), s = b2((o, i) => {
|
|
946
949
|
t.then((a) => {
|
|
947
950
|
if (n(), a.hasError) i(new U2(a.payload.error));
|
|
948
951
|
else if (a.hasResult) o(a.payload.result);
|
|
@@ -967,10 +970,10 @@ var init_es2 = __esm({
|
|
|
967
970
|
}
|
|
968
971
|
};
|
|
969
972
|
vn = { "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" };
|
|
970
|
-
|
|
973
|
+
ye = class extends f2 {
|
|
971
974
|
loginWithMagicLink(e) {
|
|
972
975
|
let t = m2.sdkName === "@magic-sdk/react-native" || m2.sdkName === "@magic-sdk/react-native-bare" || m2.sdkName === "@magic-sdk/react-native-expo";
|
|
973
|
-
if (t && Lt(m2.version, 19)) throw new Error("loginWithMagicLink() is deprecated for this package, please
|
|
976
|
+
if (t && Lt(m2.version, 19)) throw new Error("loginWithMagicLink() is deprecated for this package, please utilize a passcode method like loginWithSMS or loginWithEmailOTP instead.");
|
|
974
977
|
t && Rt({ method: "auth.loginWithMagicLink()", removalVersions: vn, useInstead: "auth.loginWithEmailOTP()" }).log();
|
|
975
978
|
let { email: s, showUI: n = true, redirectURI: o, overrides: i, lifespan: a } = e, c = p(this.sdk.testMode ? g.LoginWithMagicLinkTestMode : g.LoginWithMagicLink, [{ email: s, showUI: n, redirectURI: o, overrides: i, lifespan: a }]);
|
|
976
979
|
return this.request(c);
|
|
@@ -987,16 +990,16 @@ var init_es2 = __esm({
|
|
|
987
990
|
let { email: t, showUI: s, deviceCheckUI: n, overrides: o, lifespan: i } = e, a = p(this.sdk.testMode ? g.LoginWithEmailOTPTestMode : g.LoginWithEmailOTP, [{ email: t, showUI: s, deviceCheckUI: n, overrides: o, lifespan: i }]), c = this.request(a);
|
|
988
991
|
return !n && c && c.on(O.Retry, () => {
|
|
989
992
|
this.createIntermediaryEvent(O.Retry, a.id)();
|
|
990
|
-
}), !s && c && (c.on(
|
|
991
|
-
this.createIntermediaryEvent(
|
|
992
|
-
}), c.on(
|
|
993
|
-
this.createIntermediaryEvent(
|
|
994
|
-
}), c.on(
|
|
995
|
-
this.createIntermediaryEvent(
|
|
996
|
-
}), c.on(
|
|
997
|
-
this.createIntermediaryEvent(
|
|
998
|
-
}), c.on(
|
|
999
|
-
this.createIntermediaryEvent(
|
|
993
|
+
}), !s && c && (c.on(I.VerifyEmailOtp, (d) => {
|
|
994
|
+
this.createIntermediaryEvent(I.VerifyEmailOtp, a.id)(d);
|
|
995
|
+
}), c.on(I.VerifyMFACode, (d) => {
|
|
996
|
+
this.createIntermediaryEvent(I.VerifyMFACode, a.id)(d);
|
|
997
|
+
}), c.on(I.LostDevice, () => {
|
|
998
|
+
this.createIntermediaryEvent(I.LostDevice, a.id)();
|
|
999
|
+
}), c.on(I.VerifyRecoveryCode, (d) => {
|
|
1000
|
+
this.createIntermediaryEvent(I.VerifyRecoveryCode, a.id)(d);
|
|
1001
|
+
}), c.on(I.Cancel, () => {
|
|
1002
|
+
this.createIntermediaryEvent(I.Cancel, a.id)();
|
|
1000
1003
|
})), c;
|
|
1001
1004
|
}
|
|
1002
1005
|
loginWithCredential(e) {
|
|
@@ -1032,12 +1035,12 @@ var init_es2 = __esm({
|
|
|
1032
1035
|
})), o;
|
|
1033
1036
|
}
|
|
1034
1037
|
};
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1038
|
+
qe = "ds";
|
|
1039
|
+
Ue = "ek";
|
|
1040
|
+
Fe = "iv";
|
|
1041
|
+
We = "AES-GCM";
|
|
1039
1042
|
Tn = 256;
|
|
1040
|
-
|
|
1043
|
+
Te = class extends f2 {
|
|
1041
1044
|
getIdToken(e) {
|
|
1042
1045
|
let t = p(this.sdk.testMode ? g.GetIdTokenTestMode : g.GetIdToken, [e]);
|
|
1043
1046
|
return this.request(t);
|
|
@@ -1063,7 +1066,7 @@ var init_es2 = __esm({
|
|
|
1063
1066
|
});
|
|
1064
1067
|
}
|
|
1065
1068
|
logout() {
|
|
1066
|
-
return A2(this.localForageIsLoggedInKey),
|
|
1069
|
+
return A2(this.localForageIsLoggedInKey), Re(), b2(async (e, t) => {
|
|
1067
1070
|
try {
|
|
1068
1071
|
let s = p(this.sdk.testMode ? g.LogoutTestMode : g.Logout), n = await this.request(s);
|
|
1069
1072
|
this.sdk.useStorageCache && this.emitUserLoggedOut(n), e(n);
|
|
@@ -1141,7 +1144,7 @@ var init_es2 = __esm({
|
|
|
1141
1144
|
localForageIsLoggedInKey = "magic_auth_is_logged_in";
|
|
1142
1145
|
userLoggedOutCallbacks = [];
|
|
1143
1146
|
};
|
|
1144
|
-
|
|
1147
|
+
Ie = class extends f2 {
|
|
1145
1148
|
connectWithUI(e) {
|
|
1146
1149
|
let t = b2(async (s, n) => {
|
|
1147
1150
|
try {
|
|
@@ -1181,7 +1184,7 @@ var init_es2 = __esm({
|
|
|
1181
1184
|
return this.request(p(g.SendGaslessTransaction, [e, t]));
|
|
1182
1185
|
}
|
|
1183
1186
|
};
|
|
1184
|
-
|
|
1187
|
+
Pe = class extends f2 {
|
|
1185
1188
|
eventListeners = [];
|
|
1186
1189
|
enabledWallets = {};
|
|
1187
1190
|
isConnected = false;
|
|
@@ -1265,12 +1268,12 @@ var init_es2 = __esm({
|
|
|
1265
1268
|
});
|
|
1266
1269
|
}
|
|
1267
1270
|
};
|
|
1268
|
-
({ createBoundEmitterMethod:
|
|
1269
|
-
|
|
1271
|
+
({ createBoundEmitterMethod: we, createChainingEmitterMethod: H2 } = fe());
|
|
1272
|
+
Se = class extends f2 {
|
|
1270
1273
|
isMagic = true;
|
|
1271
1274
|
sendAsync(e, t) {
|
|
1272
1275
|
if (!t) throw ft({ procedure: "Magic.rpcProvider.sendAsync", argument: 1, expected: "function", received: t === null ? "null" : typeof t });
|
|
1273
|
-
if (Array.isArray(e)) this.overlay.post(
|
|
1276
|
+
if (Array.isArray(e)) this.overlay.post(y.MAGIC_HANDLE_REQUEST, e.map((s) => {
|
|
1274
1277
|
let n = F2(s);
|
|
1275
1278
|
return this.prefixPayloadMethodForTestMode(n), n;
|
|
1276
1279
|
})).then((s) => {
|
|
@@ -1278,7 +1281,7 @@ var init_es2 = __esm({
|
|
|
1278
1281
|
});
|
|
1279
1282
|
else {
|
|
1280
1283
|
let s = F2(e);
|
|
1281
|
-
this.prefixPayloadMethodForTestMode(s), this.overlay.post(
|
|
1284
|
+
this.prefixPayloadMethodForTestMode(s), this.overlay.post(y.MAGIC_HANDLE_REQUEST, s).then((n) => {
|
|
1282
1285
|
t(n.hasError ? new U2(n.payload.error) : null, n.payload);
|
|
1283
1286
|
});
|
|
1284
1287
|
}
|
|
@@ -1312,52 +1315,12 @@ var init_es2 = __esm({
|
|
|
1312
1315
|
off = H2("off", this);
|
|
1313
1316
|
removeListener = H2("removeListener", this);
|
|
1314
1317
|
removeAllListeners = H2("removeAllListeners", this);
|
|
1315
|
-
emit =
|
|
1316
|
-
eventNames =
|
|
1317
|
-
listeners =
|
|
1318
|
-
listenerCount =
|
|
1319
|
-
};
|
|
1320
|
-
Wt = ["request", "overlay", "sdk"];
|
|
1321
|
-
Ke = class extends f2 {
|
|
1322
|
-
compat;
|
|
1323
|
-
__sdk_access_field_descriptors__ = /* @__PURE__ */ new Map();
|
|
1324
|
-
__is_initialized__ = false;
|
|
1325
|
-
utils = { createPromiEvent: b2, isPromiEvent: $t, encodeJSON: le, decodeJSON: at, createJsonRpcRequestPayload: p, standardizeJsonRpcRequestPayload: F2, storage: he };
|
|
1326
|
-
constructor() {
|
|
1327
|
-
super(void 0);
|
|
1328
|
-
let e = [this, ...wn(this)];
|
|
1329
|
-
Wt.forEach((t) => {
|
|
1330
|
-
let s = e.map((a) => Object.getOwnPropertyDescriptor(a, t)), n = s.findIndex((a) => !!a), o = n > 0, i = s[n];
|
|
1331
|
-
i && (this.__sdk_access_field_descriptors__.set(t, { descriptor: i, isPrototypeField: o }), Object.defineProperty(this, t, { configurable: true, get: () => {
|
|
1332
|
-
throw ht(t);
|
|
1333
|
-
} }));
|
|
1334
|
-
});
|
|
1335
|
-
}
|
|
1336
|
-
init(e) {
|
|
1337
|
-
this.__is_initialized__ || (Wt.forEach((t) => {
|
|
1338
|
-
if (this.__sdk_access_field_descriptors__.has(t)) {
|
|
1339
|
-
let { descriptor: s, isPrototypeField: n } = this.__sdk_access_field_descriptors__.get(t);
|
|
1340
|
-
n ? delete this[t] : Object.defineProperty(this, t, s);
|
|
1341
|
-
}
|
|
1342
|
-
}), this.sdk = e, this.__is_initialized__ = true);
|
|
1343
|
-
}
|
|
1344
|
-
createDeprecationWarning(e) {
|
|
1345
|
-
let { method: t, removalVersion: s, useInstead: n } = e, o = n ? ` Use \`${n}\` instead.` : "", i = `\`${t}\` will be removed from this Extension in version \`${s}\`.${o}`;
|
|
1346
|
-
return new re(this, "DEPRECATION_NOTICE", i);
|
|
1347
|
-
}
|
|
1348
|
-
createWarning(e, t) {
|
|
1349
|
-
return new re(this, e, t);
|
|
1350
|
-
}
|
|
1351
|
-
createError(e, t, s) {
|
|
1352
|
-
return new ue(this, e, t, s);
|
|
1353
|
-
}
|
|
1354
|
-
};
|
|
1355
|
-
je = class extends Ke {
|
|
1318
|
+
emit = we("emit");
|
|
1319
|
+
eventNames = we("eventNames");
|
|
1320
|
+
listeners = we("listeners");
|
|
1321
|
+
listenerCount = we("listenerCount");
|
|
1356
1322
|
};
|
|
1357
|
-
|
|
1358
|
-
static Internal = je;
|
|
1359
|
-
};
|
|
1360
|
-
Ne = class extends f2 {
|
|
1323
|
+
Me = class extends f2 {
|
|
1361
1324
|
purchase(e) {
|
|
1362
1325
|
let t = p(g.NFTPurchase, [e]);
|
|
1363
1326
|
return this.request(t);
|
|
@@ -1380,15 +1343,15 @@ var init_es2 = __esm({
|
|
|
1380
1343
|
return this.request(t);
|
|
1381
1344
|
}
|
|
1382
1345
|
};
|
|
1383
|
-
|
|
1346
|
+
Ke = class r8 {
|
|
1384
1347
|
constructor(e, t) {
|
|
1385
1348
|
this.apiKey = e;
|
|
1386
1349
|
if (!e) throw ut();
|
|
1387
1350
|
m2.platform === "react-native" && t?.endpoint && yt().log();
|
|
1388
1351
|
let { defaultEndpoint: s, version: n } = m2;
|
|
1389
|
-
this.testMode = !!t?.testMode, this.useStorageCache = !!t?.useStorageCache, this.endpoint =
|
|
1390
|
-
let o =
|
|
1391
|
-
this.parameters =
|
|
1352
|
+
this.testMode = !!t?.testMode, this.useStorageCache = !!t?.useStorageCache, this.endpoint = Je(t?.endpoint ?? s).origin, this.auth = new ye(this), this.user = new Te(this), this.wallet = new Ie(this), this.nft = new Me(this), this.thirdPartyWallets = new Pe(this), this.rpcProvider = new Se(this);
|
|
1353
|
+
let o = Sn.call(this, t);
|
|
1354
|
+
this.parameters = ce({ API_KEY: this.apiKey, DOMAIN_ORIGIN: typeof window < "u" && window?.location ? window?.location.origin : "", ETH_NETWORK: t?.network, host: Je(this.endpoint).host, sdk: dt[m2.sdkName], version: n, ext: ee(o) ? void 0 : o, locale: t?.locale || "en_US", authConfig: t?.authConfig ? { ...t.authConfig } : void 0, ...m2.bundleId ? { bundleId: m2.bundleId } : {}, meta: t?.meta }), this.networkHash = wn(this.apiKey, t?.network, ee(o) ? void 0 : o), t?.deferPreload || this.preload();
|
|
1392
1355
|
}
|
|
1393
1356
|
static __overlays__ = /* @__PURE__ */ new Map();
|
|
1394
1357
|
endpoint;
|
|
@@ -1413,11 +1376,11 @@ var init_es2 = __esm({
|
|
|
1413
1376
|
await this.overlay.waitForReady();
|
|
1414
1377
|
}
|
|
1415
1378
|
};
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1379
|
+
Nn = 1e3;
|
|
1380
|
+
Bt = 60 * Nn;
|
|
1381
|
+
Vt = 5 * Bt;
|
|
1382
|
+
An = 60 * Bt;
|
|
1383
|
+
je = class {
|
|
1421
1384
|
constructor(e, t, s) {
|
|
1422
1385
|
this.endpoint = e;
|
|
1423
1386
|
this.parameters = t;
|
|
@@ -1429,21 +1392,21 @@ var init_es2 = __esm({
|
|
|
1429
1392
|
isConnectedToInternet = true;
|
|
1430
1393
|
lastPongTime = null;
|
|
1431
1394
|
heartbeatIntervalTimer = null;
|
|
1432
|
-
heartbeatDebounce =
|
|
1395
|
+
heartbeatDebounce = jt(() => {
|
|
1433
1396
|
this.endpoint === "https://auth.magic.link/" && this.heartBeatCheck();
|
|
1434
|
-
},
|
|
1397
|
+
}, An);
|
|
1435
1398
|
async post(e, t) {
|
|
1436
|
-
return
|
|
1399
|
+
return De(async (s, n) => {
|
|
1437
1400
|
if (!this.isConnectedToInternet) {
|
|
1438
1401
|
let l = pt();
|
|
1439
1402
|
n(l);
|
|
1440
1403
|
}
|
|
1441
1404
|
await this.checkRelayerExistsInDOM() || (this.isReadyForRequest = false, await this.reloadRelayer()), this.isReadyForRequest || await this.waitForReady();
|
|
1442
|
-
let o = [], i = Array.isArray(t) ? t.map((l) => l.id) : [], a = await
|
|
1405
|
+
let o = [], i = Array.isArray(t) ? t.map((l) => l.id) : [], a = await Gt(`${e}-${this.parameters}`, t, this.networkHash);
|
|
1443
1406
|
await this._post(a);
|
|
1444
1407
|
let c = (l) => (u2) => {
|
|
1445
|
-
let { id: P2, response: w2 } =
|
|
1446
|
-
if (
|
|
1408
|
+
let { id: P2, response: w2 } = Jt(t, u2);
|
|
1409
|
+
if (Kt(u2), w2?.payload.error?.message === "User denied account access.") Re();
|
|
1447
1410
|
else if (u2.data.deviceShare) {
|
|
1448
1411
|
let { deviceShare: Xt } = u2.data;
|
|
1449
1412
|
Dt(Xt, this.networkHash);
|
|
@@ -1476,12 +1439,12 @@ var init_es2 = __esm({
|
|
|
1476
1439
|
}
|
|
1477
1440
|
heartBeatCheck() {
|
|
1478
1441
|
let e = true, t = async () => {
|
|
1479
|
-
let s = { msgType: `${
|
|
1442
|
+
let s = { msgType: `${y.MAGIC_PING}-${this.parameters}`, payload: [] };
|
|
1480
1443
|
await this._post(s);
|
|
1481
1444
|
};
|
|
1482
1445
|
this.heartbeatIntervalTimer = setInterval(async () => {
|
|
1483
1446
|
if (this.lastPongTime) {
|
|
1484
|
-
if (Date.now() - this.lastPongTime >
|
|
1447
|
+
if (Date.now() - this.lastPongTime > Vt * 2) {
|
|
1485
1448
|
this.reloadRelayer(), e = true;
|
|
1486
1449
|
return;
|
|
1487
1450
|
}
|
|
@@ -1490,29 +1453,69 @@ var init_es2 = __esm({
|
|
|
1490
1453
|
return;
|
|
1491
1454
|
}
|
|
1492
1455
|
await t(), e = false;
|
|
1493
|
-
},
|
|
1456
|
+
}, Vt);
|
|
1494
1457
|
}
|
|
1495
1458
|
stopHeartBeat() {
|
|
1496
1459
|
this.heartbeatDebounce(), this.lastPongTime = null, this.heartbeatIntervalTimer && (clearInterval(this.heartbeatIntervalTimer), this.heartbeatIntervalTimer = null);
|
|
1497
1460
|
}
|
|
1498
1461
|
};
|
|
1462
|
+
Ht = ["request", "overlay", "sdk"];
|
|
1463
|
+
Ve = class extends f2 {
|
|
1464
|
+
compat;
|
|
1465
|
+
__sdk_access_field_descriptors__ = /* @__PURE__ */ new Map();
|
|
1466
|
+
__is_initialized__ = false;
|
|
1467
|
+
utils = { createPromiEvent: b2, isPromiEvent: $t, encodeJSON: ce, decodeJSON: at, createJsonRpcRequestPayload: p, standardizeJsonRpcRequestPayload: F2, storage: me };
|
|
1468
|
+
constructor() {
|
|
1469
|
+
super(void 0);
|
|
1470
|
+
let e = [this, ...$n(this)];
|
|
1471
|
+
Ht.forEach((t) => {
|
|
1472
|
+
let s = e.map((a) => Object.getOwnPropertyDescriptor(a, t)), n = s.findIndex((a) => !!a), o = n > 0, i = s[n];
|
|
1473
|
+
i && (this.__sdk_access_field_descriptors__.set(t, { descriptor: i, isPrototypeField: o }), Object.defineProperty(this, t, { configurable: true, get: () => {
|
|
1474
|
+
throw ht(t);
|
|
1475
|
+
} }));
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
init(e) {
|
|
1479
|
+
this.__is_initialized__ || (Ht.forEach((t) => {
|
|
1480
|
+
if (this.__sdk_access_field_descriptors__.has(t)) {
|
|
1481
|
+
let { descriptor: s, isPrototypeField: n } = this.__sdk_access_field_descriptors__.get(t);
|
|
1482
|
+
n ? delete this[t] : Object.defineProperty(this, t, s);
|
|
1483
|
+
}
|
|
1484
|
+
}), this.sdk = e, this.__is_initialized__ = true);
|
|
1485
|
+
}
|
|
1486
|
+
createDeprecationWarning(e) {
|
|
1487
|
+
let { method: t, removalVersion: s, useInstead: n } = e, o = n ? ` Use \`${n}\` instead.` : "", i = `\`${t}\` will be removed from this Extension in version \`${s}\`.${o}`;
|
|
1488
|
+
return new te(this, "DEPRECATION_NOTICE", i);
|
|
1489
|
+
}
|
|
1490
|
+
createWarning(e, t) {
|
|
1491
|
+
return new te(this, e, t);
|
|
1492
|
+
}
|
|
1493
|
+
createError(e, t, s) {
|
|
1494
|
+
return new de(this, e, t, s);
|
|
1495
|
+
}
|
|
1496
|
+
};
|
|
1497
|
+
Be = class extends Ve {
|
|
1498
|
+
};
|
|
1499
|
+
He = class {
|
|
1500
|
+
static Internal = Be;
|
|
1501
|
+
};
|
|
1499
1502
|
}
|
|
1500
1503
|
});
|
|
1501
1504
|
|
|
1502
|
-
// ../../node_modules/.pnpm/@magic-sdk+commons@25.
|
|
1505
|
+
// ../../node_modules/.pnpm/@magic-sdk+commons@25.4.2_@magic-sdk+provider@29.4.2_localforage@1.10.0__@magic-sdk+types@24.21.0/node_modules/@magic-sdk/commons/dist/es/index.mjs
|
|
1503
1506
|
var init_es3 = __esm({
|
|
1504
|
-
"../../node_modules/.pnpm/@magic-sdk+commons@25.
|
|
1507
|
+
"../../node_modules/.pnpm/@magic-sdk+commons@25.4.2_@magic-sdk+provider@29.4.2_localforage@1.10.0__@magic-sdk+types@24.21.0/node_modules/@magic-sdk/commons/dist/es/index.mjs"() {
|
|
1505
1508
|
"use strict";
|
|
1506
1509
|
init_es2();
|
|
1507
1510
|
init_es();
|
|
1508
1511
|
}
|
|
1509
1512
|
});
|
|
1510
1513
|
|
|
1511
|
-
// ../../node_modules/.pnpm/magic-sdk@29.
|
|
1514
|
+
// ../../node_modules/.pnpm/magic-sdk@29.4.2/node_modules/magic-sdk/dist/es/index.mjs
|
|
1512
1515
|
var es_exports = {};
|
|
1513
1516
|
__export(es_exports, {
|
|
1514
1517
|
AuthEventOnReceived: () => k,
|
|
1515
|
-
DeepLinkPage: () =>
|
|
1518
|
+
DeepLinkPage: () => x,
|
|
1516
1519
|
DeviceVerificationEventEmit: () => O,
|
|
1517
1520
|
DeviceVerificationEventOnReceived: () => S,
|
|
1518
1521
|
DisableMFAEventEmit: () => G,
|
|
@@ -1520,20 +1523,20 @@ __export(es_exports, {
|
|
|
1520
1523
|
EnableMFAEventEmit: () => D,
|
|
1521
1524
|
EnableMFAEventOnReceived: () => w,
|
|
1522
1525
|
EthChainType: () => H,
|
|
1523
|
-
Extension: () =>
|
|
1524
|
-
ExtensionError: () =>
|
|
1525
|
-
ExtensionWarning: () =>
|
|
1526
|
+
Extension: () => He,
|
|
1527
|
+
ExtensionError: () => de,
|
|
1528
|
+
ExtensionWarning: () => te,
|
|
1526
1529
|
FarcasterLoginEventEmit: () => L,
|
|
1527
1530
|
LocalStorageKeys: () => _,
|
|
1528
|
-
LoginWithEmailOTPEventEmit: () =>
|
|
1531
|
+
LoginWithEmailOTPEventEmit: () => I,
|
|
1529
1532
|
LoginWithEmailOTPEventOnReceived: () => T,
|
|
1530
1533
|
LoginWithMagicLinkEventEmit: () => A,
|
|
1531
|
-
LoginWithMagicLinkEventOnReceived: () =>
|
|
1534
|
+
LoginWithMagicLinkEventOnReceived: () => R,
|
|
1532
1535
|
LoginWithSmsOTPEventEmit: () => N,
|
|
1533
1536
|
LoginWithSmsOTPEventOnReceived: () => h,
|
|
1534
1537
|
Magic: () => wt2,
|
|
1535
1538
|
MagicIncomingWindowMessage: () => E,
|
|
1536
|
-
MagicOutgoingWindowMessage: () =>
|
|
1539
|
+
MagicOutgoingWindowMessage: () => y,
|
|
1537
1540
|
MagicPayloadMethod: () => g,
|
|
1538
1541
|
NftCheckoutIntermediaryEvents: () => Q,
|
|
1539
1542
|
RPCError: () => U2,
|
|
@@ -1565,9 +1568,9 @@ function ft2(_2) {
|
|
|
1565
1568
|
function st2(_2) {
|
|
1566
1569
|
return !![].slice.call(document.querySelectorAll(".magic-iframe")).find((O3) => O3.src.includes(_2));
|
|
1567
1570
|
}
|
|
1568
|
-
var $r2, Qe2, Zr2, qr2, kr2, et2, de2, Je2, rt2, $e2, qe2, er2,
|
|
1571
|
+
var $r2, Qe2, Zr2, qr2, kr2, et2, de2, Je2, rt2, $e2, qe2, er2, pe2, Te2, at2, ye2, wt2;
|
|
1569
1572
|
var init_es4 = __esm({
|
|
1570
|
-
"../../node_modules/.pnpm/magic-sdk@29.
|
|
1573
|
+
"../../node_modules/.pnpm/magic-sdk@29.4.2/node_modules/magic-sdk/dist/es/index.mjs"() {
|
|
1571
1574
|
"use strict";
|
|
1572
1575
|
init_es2();
|
|
1573
1576
|
init_es2();
|
|
@@ -1584,8 +1587,8 @@ var init_es4 = __esm({
|
|
|
1584
1587
|
throw Error('Dynamic require of "' + _2 + '" is not supported');
|
|
1585
1588
|
});
|
|
1586
1589
|
Je2 = (_2, y3) => () => (y3 || _2((y3 = { exports: {} }).exports, y3), y3.exports);
|
|
1587
|
-
rt2 = (_2, y3, O3,
|
|
1588
|
-
if (y3 && typeof y3 == "object" || typeof y3 == "function") for (let W2 of qr2(y3)) !et2.call(_2, W2) && W2 !== O3 && Qe2(_2, W2, { get: () => y3[W2], enumerable: !(
|
|
1590
|
+
rt2 = (_2, y3, O3, C2) => {
|
|
1591
|
+
if (y3 && typeof y3 == "object" || typeof y3 == "function") for (let W2 of qr2(y3)) !et2.call(_2, W2) && W2 !== O3 && Qe2(_2, W2, { get: () => y3[W2], enumerable: !(C2 = Zr2(y3, W2)) || C2.enumerable });
|
|
1589
1592
|
return _2;
|
|
1590
1593
|
};
|
|
1591
1594
|
$e2 = (_2, y3, O3) => (O3 = _2 != null ? $r2(kr2(_2)) : {}, rt2(y3 || !_2 || !_2.__esModule ? Qe2(O3, "default", { value: _2, enumerable: true }) : O3, _2));
|
|
@@ -1600,7 +1603,7 @@ var init_es4 = __esm({
|
|
|
1600
1603
|
}
|
|
1601
1604
|
})(function() {
|
|
1602
1605
|
var _2, y3, O3;
|
|
1603
|
-
return function
|
|
1606
|
+
return (function C2(W2, Z3, L3) {
|
|
1604
1607
|
function V2(K2, J3) {
|
|
1605
1608
|
if (!Z3[K2]) {
|
|
1606
1609
|
if (!W2[K2]) {
|
|
@@ -1614,13 +1617,13 @@ var init_es4 = __esm({
|
|
|
1614
1617
|
W2[K2][0].call(T3.exports, function(F3) {
|
|
1615
1618
|
var $2 = W2[K2][1][F3];
|
|
1616
1619
|
return V2($2 || F3);
|
|
1617
|
-
}, T3, T3.exports,
|
|
1620
|
+
}, T3, T3.exports, C2, W2, Z3, L3);
|
|
1618
1621
|
}
|
|
1619
1622
|
return Z3[K2].exports;
|
|
1620
1623
|
}
|
|
1621
1624
|
for (var D2 = typeof de2 == "function" && de2, z3 = 0; z3 < L3.length; z3++) V2(L3[z3]);
|
|
1622
1625
|
return V2;
|
|
1623
|
-
}({ 1: [function(
|
|
1626
|
+
})({ 1: [function(C2, W2, Z3) {
|
|
1624
1627
|
(function(L3) {
|
|
1625
1628
|
"use strict";
|
|
1626
1629
|
var V2 = L3.MutationObserver || L3.WebKitMutationObserver, D2;
|
|
@@ -1656,9 +1659,9 @@ var init_es4 = __esm({
|
|
|
1656
1659
|
T3.push(P2) === 1 && !w2 && D2();
|
|
1657
1660
|
}
|
|
1658
1661
|
}).call(this, typeof global < "u" ? global : typeof self < "u" ? self : typeof window < "u" ? window : {});
|
|
1659
|
-
}, {}], 2: [function(
|
|
1662
|
+
}, {}], 2: [function(C2, W2, Z3) {
|
|
1660
1663
|
"use strict";
|
|
1661
|
-
var L3 =
|
|
1664
|
+
var L3 = C2(1);
|
|
1662
1665
|
function V2() {
|
|
1663
1666
|
}
|
|
1664
1667
|
var D2 = {}, z3 = ["REJECTED"], K2 = ["FULFILLED"], J3 = ["PENDING"];
|
|
@@ -1673,8 +1676,8 @@ var init_es4 = __esm({
|
|
|
1673
1676
|
if (typeof h3 != "function" && this.state === K2 || typeof A3 != "function" && this.state === z3) return this;
|
|
1674
1677
|
var E3 = new this.constructor(V2);
|
|
1675
1678
|
if (this.state !== J3) {
|
|
1676
|
-
var
|
|
1677
|
-
T3(E3,
|
|
1679
|
+
var N3 = this.state === K2 ? h3 : A3;
|
|
1680
|
+
T3(E3, N3, this.outcome);
|
|
1678
1681
|
} else this.queue.push(new w2(E3, h3, A3));
|
|
1679
1682
|
return E3;
|
|
1680
1683
|
};
|
|
@@ -1692,20 +1695,20 @@ var init_es4 = __esm({
|
|
|
1692
1695
|
};
|
|
1693
1696
|
function T3(h3, A3, E3) {
|
|
1694
1697
|
L3(function() {
|
|
1695
|
-
var
|
|
1698
|
+
var N3;
|
|
1696
1699
|
try {
|
|
1697
|
-
|
|
1700
|
+
N3 = A3(E3);
|
|
1698
1701
|
} catch (H3) {
|
|
1699
1702
|
return D2.reject(h3, H3);
|
|
1700
1703
|
}
|
|
1701
|
-
|
|
1704
|
+
N3 === h3 ? D2.reject(h3, new TypeError("Cannot resolve promise with itself")) : D2.resolve(h3, N3);
|
|
1702
1705
|
});
|
|
1703
1706
|
}
|
|
1704
1707
|
D2.resolve = function(h3, A3) {
|
|
1705
1708
|
var E3 = P2(F3, A3);
|
|
1706
1709
|
if (E3.status === "error") return D2.reject(h3, E3.value);
|
|
1707
|
-
var
|
|
1708
|
-
if (
|
|
1710
|
+
var N3 = E3.value;
|
|
1711
|
+
if (N3) $2(h3, N3);
|
|
1709
1712
|
else {
|
|
1710
1713
|
h3.state = K2, h3.outcome = A3;
|
|
1711
1714
|
for (var H3 = -1, j2 = h3.queue.length; ++H3 < j2; ) h3.queue[H3].callFulfilled(A3);
|
|
@@ -1713,7 +1716,7 @@ var init_es4 = __esm({
|
|
|
1713
1716
|
return h3;
|
|
1714
1717
|
}, D2.reject = function(h3, A3) {
|
|
1715
1718
|
h3.state = z3, h3.outcome = A3;
|
|
1716
|
-
for (var E3 = -1,
|
|
1719
|
+
for (var E3 = -1, N3 = h3.queue.length; ++E3 < N3; ) h3.queue[E3].callRejected(A3);
|
|
1717
1720
|
return h3;
|
|
1718
1721
|
};
|
|
1719
1722
|
function F3(h3) {
|
|
@@ -1724,24 +1727,24 @@ var init_es4 = __esm({
|
|
|
1724
1727
|
}
|
|
1725
1728
|
function $2(h3, A3) {
|
|
1726
1729
|
var E3 = false;
|
|
1727
|
-
function
|
|
1730
|
+
function N3(Q3) {
|
|
1728
1731
|
E3 || (E3 = true, D2.reject(h3, Q3));
|
|
1729
1732
|
}
|
|
1730
1733
|
function H3(Q3) {
|
|
1731
1734
|
E3 || (E3 = true, D2.resolve(h3, Q3));
|
|
1732
1735
|
}
|
|
1733
1736
|
function j2() {
|
|
1734
|
-
A3(H3,
|
|
1737
|
+
A3(H3, N3);
|
|
1735
1738
|
}
|
|
1736
1739
|
var X3 = P2(j2);
|
|
1737
|
-
X3.status === "error" &&
|
|
1740
|
+
X3.status === "error" && N3(X3.value);
|
|
1738
1741
|
}
|
|
1739
1742
|
function P2(h3, A3) {
|
|
1740
1743
|
var E3 = {};
|
|
1741
1744
|
try {
|
|
1742
1745
|
E3.value = h3(A3), E3.status = "success";
|
|
1743
|
-
} catch (
|
|
1744
|
-
E3.status = "error", E3.value =
|
|
1746
|
+
} catch (N3) {
|
|
1747
|
+
E3.status = "error", E3.value = N3;
|
|
1745
1748
|
}
|
|
1746
1749
|
return E3;
|
|
1747
1750
|
}
|
|
@@ -1758,16 +1761,16 @@ var init_es4 = __esm({
|
|
|
1758
1761
|
function ae2(h3) {
|
|
1759
1762
|
var A3 = this;
|
|
1760
1763
|
if (Object.prototype.toString.call(h3) !== "[object Array]") return this.reject(new TypeError("must be an array"));
|
|
1761
|
-
var E3 = h3.length,
|
|
1764
|
+
var E3 = h3.length, N3 = false;
|
|
1762
1765
|
if (!E3) return this.resolve([]);
|
|
1763
1766
|
for (var H3 = new Array(E3), j2 = 0, X3 = -1, Q3 = new this(V2); ++X3 < E3; ) ee2(h3[X3], X3);
|
|
1764
1767
|
return Q3;
|
|
1765
|
-
function ee2(
|
|
1766
|
-
A3.resolve(
|
|
1767
|
-
|
|
1768
|
+
function ee2(oe2, a) {
|
|
1769
|
+
A3.resolve(oe2).then(u2, function(v2) {
|
|
1770
|
+
N3 || (N3 = true, D2.reject(Q3, v2));
|
|
1768
1771
|
});
|
|
1769
1772
|
function u2(v2) {
|
|
1770
|
-
H3[a] = v2, ++j2 === E3 && !
|
|
1773
|
+
H3[a] = v2, ++j2 === E3 && !N3 && (N3 = true, D2.resolve(Q3, H3));
|
|
1771
1774
|
}
|
|
1772
1775
|
}
|
|
1773
1776
|
}
|
|
@@ -1775,24 +1778,24 @@ var init_es4 = __esm({
|
|
|
1775
1778
|
function re2(h3) {
|
|
1776
1779
|
var A3 = this;
|
|
1777
1780
|
if (Object.prototype.toString.call(h3) !== "[object Array]") return this.reject(new TypeError("must be an array"));
|
|
1778
|
-
var E3 = h3.length,
|
|
1781
|
+
var E3 = h3.length, N3 = false;
|
|
1779
1782
|
if (!E3) return this.resolve([]);
|
|
1780
1783
|
for (var H3 = -1, j2 = new this(V2); ++H3 < E3; ) X3(h3[H3]);
|
|
1781
1784
|
return j2;
|
|
1782
1785
|
function X3(Q3) {
|
|
1783
1786
|
A3.resolve(Q3).then(function(ee2) {
|
|
1784
|
-
|
|
1787
|
+
N3 || (N3 = true, D2.resolve(j2, ee2));
|
|
1785
1788
|
}, function(ee2) {
|
|
1786
|
-
|
|
1789
|
+
N3 || (N3 = true, D2.reject(j2, ee2));
|
|
1787
1790
|
});
|
|
1788
1791
|
}
|
|
1789
1792
|
}
|
|
1790
|
-
}, { 1: 1 }], 3: [function(
|
|
1793
|
+
}, { 1: 1 }], 3: [function(C2, W2, Z3) {
|
|
1791
1794
|
(function(L3) {
|
|
1792
1795
|
"use strict";
|
|
1793
|
-
typeof L3.Promise != "function" && (L3.Promise =
|
|
1796
|
+
typeof L3.Promise != "function" && (L3.Promise = C2(2));
|
|
1794
1797
|
}).call(this, typeof global < "u" ? global : typeof self < "u" ? self : typeof window < "u" ? window : {});
|
|
1795
|
-
}, { 2: 2 }], 4: [function(
|
|
1798
|
+
}, { 2: 2 }], 4: [function(C2, W2, Z3) {
|
|
1796
1799
|
"use strict";
|
|
1797
1800
|
var L3 = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
|
|
1798
1801
|
return typeof e;
|
|
@@ -1833,7 +1836,7 @@ var init_es4 = __esm({
|
|
|
1833
1836
|
return o.getBlob(t.type);
|
|
1834
1837
|
}
|
|
1835
1838
|
}
|
|
1836
|
-
typeof Promise > "u" &&
|
|
1839
|
+
typeof Promise > "u" && C2(3);
|
|
1837
1840
|
var m3 = Promise;
|
|
1838
1841
|
function w2(e, t) {
|
|
1839
1842
|
t && e.then(function(r10) {
|
|
@@ -1869,7 +1872,7 @@ var init_es4 = __esm({
|
|
|
1869
1872
|
return false;
|
|
1870
1873
|
});
|
|
1871
1874
|
}
|
|
1872
|
-
function
|
|
1875
|
+
function N3(e) {
|
|
1873
1876
|
return typeof k2 == "boolean" ? m3.resolve(k2) : E3(e).then(function(t) {
|
|
1874
1877
|
return k2 = t, k2;
|
|
1875
1878
|
});
|
|
@@ -1918,7 +1921,7 @@ var init_es4 = __esm({
|
|
|
1918
1921
|
function ee2(e) {
|
|
1919
1922
|
return Q3(e, false);
|
|
1920
1923
|
}
|
|
1921
|
-
function
|
|
1924
|
+
function oe2(e) {
|
|
1922
1925
|
return Q3(e, true);
|
|
1923
1926
|
}
|
|
1924
1927
|
function a(e, t) {
|
|
@@ -1963,7 +1966,7 @@ var init_es4 = __esm({
|
|
|
1963
1966
|
i._dbInfo.db && (i._dbInfo.db.close(), i._dbInfo.db = null);
|
|
1964
1967
|
}
|
|
1965
1968
|
return e.db = null, ee2(e).then(function(n) {
|
|
1966
|
-
return e.db = n, a(e) ?
|
|
1969
|
+
return e.db = n, a(e) ? oe2(e) : n;
|
|
1967
1970
|
}).then(function(n) {
|
|
1968
1971
|
e.db = t.db = n;
|
|
1969
1972
|
for (var f3 = 0; f3 < r10.length; f3++) r10[f3]._dbInfo.db = n;
|
|
@@ -1978,7 +1981,7 @@ var init_es4 = __esm({
|
|
|
1978
1981
|
r10(null, i);
|
|
1979
1982
|
} catch (n) {
|
|
1980
1983
|
if (o > 0 && (!e.db || n.name === "InvalidStateError" || n.name === "NotFoundError")) return m3.resolve().then(function() {
|
|
1981
|
-
if (!e.db || n.name === "NotFoundError" && !e.db.objectStoreNames.contains(e.storeName) && e.version <= e.db.version) return e.db && (e.version = e.db.version + 1),
|
|
1984
|
+
if (!e.db || n.name === "NotFoundError" && !e.db.objectStoreNames.contains(e.storeName) && e.version <= e.db.version) return e.db && (e.version = e.db.version + 1), oe2(e);
|
|
1982
1985
|
}).then(function() {
|
|
1983
1986
|
return I2(e).then(function() {
|
|
1984
1987
|
R3(e, t, r10, o - 1);
|
|
@@ -1990,7 +1993,7 @@ var init_es4 = __esm({
|
|
|
1990
1993
|
function G2() {
|
|
1991
1994
|
return { forages: [], db: null, dbReady: null, deferredOperations: [] };
|
|
1992
1995
|
}
|
|
1993
|
-
function
|
|
1996
|
+
function fe2(e) {
|
|
1994
1997
|
var t = this, r10 = { db: null };
|
|
1995
1998
|
if (e) for (var o in e) r10[o] = e[o];
|
|
1996
1999
|
var i = M2[r10.name];
|
|
@@ -2007,7 +2010,7 @@ var init_es4 = __esm({
|
|
|
2007
2010
|
return m3.all(n).then(function() {
|
|
2008
2011
|
return r10.db = i.db, ee2(r10);
|
|
2009
2012
|
}).then(function(d) {
|
|
2010
|
-
return r10.db = d, a(r10, t._defaultConfig.version) ?
|
|
2013
|
+
return r10.db = d, a(r10, t._defaultConfig.version) ? oe2(r10) : d;
|
|
2011
2014
|
}).then(function(d) {
|
|
2012
2015
|
r10.db = i.db = d, t._dbInfo = r10;
|
|
2013
2016
|
for (var p2 = 0; p2 < l.length; p2++) {
|
|
@@ -2039,7 +2042,7 @@ var init_es4 = __esm({
|
|
|
2039
2042
|
});
|
|
2040
2043
|
return w2(o, t), o;
|
|
2041
2044
|
}
|
|
2042
|
-
function
|
|
2045
|
+
function ue(e, t) {
|
|
2043
2046
|
var r10 = this, o = new m3(function(i, n) {
|
|
2044
2047
|
r10.ready().then(function() {
|
|
2045
2048
|
R3(r10._dbInfo, re2, function(f3, s) {
|
|
@@ -2071,7 +2074,7 @@ var init_es4 = __esm({
|
|
|
2071
2074
|
var i = new m3(function(n, f3) {
|
|
2072
2075
|
var s;
|
|
2073
2076
|
o.ready().then(function() {
|
|
2074
|
-
return s = o._dbInfo, ae2.call(t) === "[object Blob]" ?
|
|
2077
|
+
return s = o._dbInfo, ae2.call(t) === "[object Blob]" ? N3(s.db).then(function(c) {
|
|
2075
2078
|
return c ? t : u2(t);
|
|
2076
2079
|
}) : t;
|
|
2077
2080
|
}).then(function(c) {
|
|
@@ -2296,11 +2299,11 @@ var init_es4 = __esm({
|
|
|
2296
2299
|
}
|
|
2297
2300
|
return w2(i, t), i;
|
|
2298
2301
|
}
|
|
2299
|
-
var ur2 = { _driver: "asyncStorage", _initStorage:
|
|
2302
|
+
var ur2 = { _driver: "asyncStorage", _initStorage: fe2, _support: K2(), iterate: ue, getItem: ie2, setItem: tr2, removeItem: nr2, clear: or2, length: ir2, key: ar2, keys: fr2, dropInstance: sr2 };
|
|
2300
2303
|
function cr2() {
|
|
2301
2304
|
return typeof openDatabase == "function";
|
|
2302
2305
|
}
|
|
2303
|
-
var te2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", lr2 = "~~local_forage_type~", Be2 = /^~~local_forage_type~([^~]+)~/,
|
|
2306
|
+
var te2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", lr2 = "~~local_forage_type~", Be2 = /^~~local_forage_type~([^~]+)~/, ve = "__lfsc__:", ge = ve.length, be = "arbf", _e = "blob", Ne2 = "si08", xe = "ui08", Oe2 = "uic8", Ce2 = "si16", Le2 = "si32", Pe2 = "ur16", Me2 = "ui32", Fe2 = "fl32", Ue2 = "fl64", We2 = ge + be.length, ze2 = Object.prototype.toString;
|
|
2304
2307
|
function Ye2(e) {
|
|
2305
2308
|
var t = e.length * 0.75, r10 = e.length, o, i = 0, n, f3, s, c;
|
|
2306
2309
|
e[e.length - 1] === "=" && (t--, e[e.length - 2] === "=" && t--);
|
|
@@ -2316,13 +2319,13 @@ var init_es4 = __esm({
|
|
|
2316
2319
|
function dr2(e, t) {
|
|
2317
2320
|
var r10 = "";
|
|
2318
2321
|
if (e && (r10 = ze2.call(e)), e && (r10 === "[object ArrayBuffer]" || e.buffer && ze2.call(e.buffer) === "[object ArrayBuffer]")) {
|
|
2319
|
-
var o, i =
|
|
2320
|
-
e instanceof ArrayBuffer ? (o = e, i +=
|
|
2322
|
+
var o, i = ve;
|
|
2323
|
+
e instanceof ArrayBuffer ? (o = e, i += be) : (o = e.buffer, r10 === "[object Int8Array]" ? i += Ne2 : r10 === "[object Uint8Array]" ? i += xe : r10 === "[object Uint8ClampedArray]" ? i += Oe2 : r10 === "[object Int16Array]" ? i += Ce2 : r10 === "[object Uint16Array]" ? i += Pe2 : r10 === "[object Int32Array]" ? i += Le2 : r10 === "[object Uint32Array]" ? i += Me2 : r10 === "[object Float32Array]" ? i += Fe2 : r10 === "[object Float64Array]" ? i += Ue2 : t(new Error("Failed to get type for BinaryArray"))), t(i + we2(o));
|
|
2321
2324
|
} else if (r10 === "[object Blob]") {
|
|
2322
2325
|
var n = new FileReader();
|
|
2323
2326
|
n.onload = function() {
|
|
2324
2327
|
var f3 = lr2 + e.type + "~" + we2(this.result);
|
|
2325
|
-
t(
|
|
2328
|
+
t(ve + _e + f3);
|
|
2326
2329
|
}, n.readAsArrayBuffer(e);
|
|
2327
2330
|
} else try {
|
|
2328
2331
|
t(JSON.stringify(e));
|
|
@@ -2331,31 +2334,31 @@ var init_es4 = __esm({
|
|
|
2331
2334
|
}
|
|
2332
2335
|
}
|
|
2333
2336
|
function vr2(e) {
|
|
2334
|
-
if (e.substring(0,
|
|
2335
|
-
var t = e.substring(We2), r10 = e.substring(
|
|
2336
|
-
if (r10 ===
|
|
2337
|
+
if (e.substring(0, ge) !== ve) return JSON.parse(e);
|
|
2338
|
+
var t = e.substring(We2), r10 = e.substring(ge, We2), o;
|
|
2339
|
+
if (r10 === _e && Be2.test(t)) {
|
|
2337
2340
|
var i = t.match(Be2);
|
|
2338
2341
|
o = i[1], t = t.substring(i[0].length);
|
|
2339
2342
|
}
|
|
2340
2343
|
var n = Ye2(t);
|
|
2341
2344
|
switch (r10) {
|
|
2342
|
-
case
|
|
2345
|
+
case be:
|
|
2343
2346
|
return n;
|
|
2344
|
-
case
|
|
2347
|
+
case _e:
|
|
2345
2348
|
return J3([n], { type: o });
|
|
2346
2349
|
case Ne2:
|
|
2347
2350
|
return new Int8Array(n);
|
|
2348
|
-
case
|
|
2351
|
+
case xe:
|
|
2349
2352
|
return new Uint8Array(n);
|
|
2350
2353
|
case Oe2:
|
|
2351
2354
|
return new Uint8ClampedArray(n);
|
|
2352
2355
|
case Ce2:
|
|
2353
2356
|
return new Int16Array(n);
|
|
2354
|
-
case
|
|
2357
|
+
case Pe2:
|
|
2355
2358
|
return new Uint16Array(n);
|
|
2356
2359
|
case Le2:
|
|
2357
2360
|
return new Int32Array(n);
|
|
2358
|
-
case
|
|
2361
|
+
case Me2:
|
|
2359
2362
|
return new Uint32Array(n);
|
|
2360
2363
|
case Fe2:
|
|
2361
2364
|
return new Float32Array(n);
|
|
@@ -2388,7 +2391,7 @@ var init_es4 = __esm({
|
|
|
2388
2391
|
});
|
|
2389
2392
|
return r10.serializer = Ie2, i;
|
|
2390
2393
|
}
|
|
2391
|
-
function
|
|
2394
|
+
function ne(e, t, r10, o, i, n) {
|
|
2392
2395
|
e.executeSql(r10, o, i, function(f3, s) {
|
|
2393
2396
|
s.code === s.SYNTAX_ERR ? f3.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?", [t.storeName], function(c, l) {
|
|
2394
2397
|
l.rows.length ? n(c, s) : Ke2(c, t, function() {
|
|
@@ -2404,7 +2407,7 @@ var init_es4 = __esm({
|
|
|
2404
2407
|
r10.ready().then(function() {
|
|
2405
2408
|
var f3 = r10._dbInfo;
|
|
2406
2409
|
f3.db.transaction(function(s) {
|
|
2407
|
-
|
|
2410
|
+
ne(s, f3, "SELECT * FROM " + f3.storeName + " WHERE key = ? LIMIT 1", [e], function(c, l) {
|
|
2408
2411
|
var d = l.rows.length ? l.rows.item(0).value : null;
|
|
2409
2412
|
d && (d = f3.serializer.deserialize(d)), i(d);
|
|
2410
2413
|
}, function(c, l) {
|
|
@@ -2420,7 +2423,7 @@ var init_es4 = __esm({
|
|
|
2420
2423
|
r10.ready().then(function() {
|
|
2421
2424
|
var f3 = r10._dbInfo;
|
|
2422
2425
|
f3.db.transaction(function(s) {
|
|
2423
|
-
|
|
2426
|
+
ne(s, f3, "SELECT * FROM " + f3.storeName, [], function(c, l) {
|
|
2424
2427
|
for (var d = l.rows, p2 = d.length, S3 = 0; S3 < p2; S3++) {
|
|
2425
2428
|
var B2 = d.item(S3), x2 = B2.value;
|
|
2426
2429
|
if (x2 && (x2 = f3.serializer.deserialize(x2)), x2 = e(x2, B2.key, S3 + 1), x2 !== void 0) {
|
|
@@ -2446,7 +2449,7 @@ var init_es4 = __esm({
|
|
|
2446
2449
|
var c = t, l = i._dbInfo;
|
|
2447
2450
|
l.serializer.serialize(t, function(d, p2) {
|
|
2448
2451
|
p2 ? s(p2) : l.db.transaction(function(S3) {
|
|
2449
|
-
|
|
2452
|
+
ne(S3, l, "INSERT OR REPLACE INTO " + l.storeName + " (key, value) VALUES (?, ?)", [e, d], function() {
|
|
2450
2453
|
f3(c);
|
|
2451
2454
|
}, function(B2, x2) {
|
|
2452
2455
|
s(x2);
|
|
@@ -2475,7 +2478,7 @@ var init_es4 = __esm({
|
|
|
2475
2478
|
r10.ready().then(function() {
|
|
2476
2479
|
var f3 = r10._dbInfo;
|
|
2477
2480
|
f3.db.transaction(function(s) {
|
|
2478
|
-
|
|
2481
|
+
ne(s, f3, "DELETE FROM " + f3.storeName + " WHERE key = ?", [e], function() {
|
|
2479
2482
|
i();
|
|
2480
2483
|
}, function(c, l) {
|
|
2481
2484
|
n(l);
|
|
@@ -2490,7 +2493,7 @@ var init_es4 = __esm({
|
|
|
2490
2493
|
t.ready().then(function() {
|
|
2491
2494
|
var n = t._dbInfo;
|
|
2492
2495
|
n.db.transaction(function(f3) {
|
|
2493
|
-
|
|
2496
|
+
ne(f3, n, "DELETE FROM " + n.storeName, [], function() {
|
|
2494
2497
|
o();
|
|
2495
2498
|
}, function(s, c) {
|
|
2496
2499
|
i(c);
|
|
@@ -2505,7 +2508,7 @@ var init_es4 = __esm({
|
|
|
2505
2508
|
t.ready().then(function() {
|
|
2506
2509
|
var n = t._dbInfo;
|
|
2507
2510
|
n.db.transaction(function(f3) {
|
|
2508
|
-
|
|
2511
|
+
ne(f3, n, "SELECT COUNT(key) as c FROM " + n.storeName, [], function(s, c) {
|
|
2509
2512
|
var l = c.rows.item(0).c;
|
|
2510
2513
|
o(l);
|
|
2511
2514
|
}, function(s, c) {
|
|
@@ -2521,7 +2524,7 @@ var init_es4 = __esm({
|
|
|
2521
2524
|
r10.ready().then(function() {
|
|
2522
2525
|
var f3 = r10._dbInfo;
|
|
2523
2526
|
f3.db.transaction(function(s) {
|
|
2524
|
-
|
|
2527
|
+
ne(s, f3, "SELECT key FROM " + f3.storeName + " WHERE id = ? LIMIT 1", [e + 1], function(c, l) {
|
|
2525
2528
|
var d = l.rows.length ? l.rows.item(0).key : null;
|
|
2526
2529
|
i(d);
|
|
2527
2530
|
}, function(c, l) {
|
|
@@ -2537,7 +2540,7 @@ var init_es4 = __esm({
|
|
|
2537
2540
|
t.ready().then(function() {
|
|
2538
2541
|
var n = t._dbInfo;
|
|
2539
2542
|
n.db.transaction(function(f3) {
|
|
2540
|
-
|
|
2543
|
+
ne(f3, n, "SELECT key FROM " + n.storeName, [], function(s, c) {
|
|
2541
2544
|
for (var l = [], d = 0; d < c.rows.length; d++) l.push(c.rows.item(d).key);
|
|
2542
2545
|
o(l);
|
|
2543
2546
|
}, function(s, c) {
|
|
@@ -2602,7 +2605,7 @@ var init_es4 = __esm({
|
|
|
2602
2605
|
return false;
|
|
2603
2606
|
}
|
|
2604
2607
|
}
|
|
2605
|
-
function
|
|
2608
|
+
function Ve2(e, t) {
|
|
2606
2609
|
var r10 = e.name + "/";
|
|
2607
2610
|
return e.storeName !== t.storeName && (r10 += e.storeName + "/"), r10;
|
|
2608
2611
|
}
|
|
@@ -2620,7 +2623,7 @@ var init_es4 = __esm({
|
|
|
2620
2623
|
function Br2(e) {
|
|
2621
2624
|
var t = this, r10 = {};
|
|
2622
2625
|
if (e) for (var o in e) r10[o] = e[o];
|
|
2623
|
-
return r10.keyPrefix =
|
|
2626
|
+
return r10.keyPrefix = Ve2(e, t._defaultConfig), Tr2() ? (t._dbInfo = r10, r10.serializer = Ie2, m3.resolve()) : m3.reject();
|
|
2624
2627
|
}
|
|
2625
2628
|
function Nr2(e) {
|
|
2626
2629
|
var t = this, r10 = t.ready().then(function() {
|
|
@@ -2716,7 +2719,7 @@ var init_es4 = __esm({
|
|
|
2716
2719
|
}
|
|
2717
2720
|
var o = this, i;
|
|
2718
2721
|
return e.name ? i = new m3(function(n) {
|
|
2719
|
-
e.storeName ? n(
|
|
2722
|
+
e.storeName ? n(Ve2(e, o._defaultConfig)) : n(e.name + "/");
|
|
2720
2723
|
}).then(function(n) {
|
|
2721
2724
|
for (var f3 = localStorage.length - 1; f3 >= 0; f3--) {
|
|
2722
2725
|
var s = localStorage.key(f3);
|
|
@@ -2732,9 +2735,9 @@ var init_es4 = __esm({
|
|
|
2732
2735
|
i++;
|
|
2733
2736
|
}
|
|
2734
2737
|
return false;
|
|
2735
|
-
},
|
|
2738
|
+
}, Ge = Array.isArray || function(e) {
|
|
2736
2739
|
return Object.prototype.toString.call(e) === "[object Array]";
|
|
2737
|
-
}, ce2 = {}, je2 = {}, se = { INDEXEDDB: ur2, WEBSQL: Ar2, LOCALSTORAGE: Wr2 }, Kr2 = [se.INDEXEDDB._driver, se.WEBSQL._driver, se.LOCALSTORAGE._driver], he2 = ["dropInstance"],
|
|
2740
|
+
}, ce2 = {}, je2 = {}, se = { INDEXEDDB: ur2, WEBSQL: Ar2, LOCALSTORAGE: Wr2 }, Kr2 = [se.INDEXEDDB._driver, se.WEBSQL._driver, se.LOCALSTORAGE._driver], he2 = ["dropInstance"], Ee = ["clear", "getItem", "iterate", "key", "keys", "length", "removeItem", "setItem"].concat(he2), Hr2 = { description: "", driver: Kr2.slice(), name: "localforage", size: 4980736, storeName: "keyvaluepairs", version: 1 };
|
|
2738
2741
|
function Vr(e, t) {
|
|
2739
2742
|
e[t] = function() {
|
|
2740
2743
|
var r10 = arguments;
|
|
@@ -2746,11 +2749,11 @@ var init_es4 = __esm({
|
|
|
2746
2749
|
function Se2() {
|
|
2747
2750
|
for (var e = 1; e < arguments.length; e++) {
|
|
2748
2751
|
var t = arguments[e];
|
|
2749
|
-
if (t) for (var r10 in t) t.hasOwnProperty(r10) && (
|
|
2752
|
+
if (t) for (var r10 in t) t.hasOwnProperty(r10) && (Ge(t[r10]) ? arguments[0][r10] = t[r10].slice() : arguments[0][r10] = t[r10]);
|
|
2750
2753
|
}
|
|
2751
2754
|
return arguments[0];
|
|
2752
2755
|
}
|
|
2753
|
-
var Gr2 = function() {
|
|
2756
|
+
var Gr2 = (function() {
|
|
2754
2757
|
function e(t) {
|
|
2755
2758
|
V2(this, e);
|
|
2756
2759
|
for (var r10 in se) if (se.hasOwnProperty(r10)) {
|
|
@@ -2777,7 +2780,7 @@ var init_es4 = __esm({
|
|
|
2777
2780
|
s(l);
|
|
2778
2781
|
return;
|
|
2779
2782
|
}
|
|
2780
|
-
for (var d =
|
|
2783
|
+
for (var d = Ee.concat("_initStorage"), p2 = 0, S3 = d.length; p2 < S3; p2++) {
|
|
2781
2784
|
var B2 = d[p2], x2 = !Yr2(he2, B2);
|
|
2782
2785
|
if ((x2 || r10[B2]) && typeof r10[B2] != "function") {
|
|
2783
2786
|
s(l);
|
|
@@ -2820,7 +2823,7 @@ var init_es4 = __esm({
|
|
|
2820
2823
|
return T3(i, r10, r10), i;
|
|
2821
2824
|
}, e.prototype.setDriver = function(r10, o, i) {
|
|
2822
2825
|
var n = this;
|
|
2823
|
-
|
|
2826
|
+
Ge(r10) || (r10 = [r10]);
|
|
2824
2827
|
var f3 = this._getSupportedDrivers(r10);
|
|
2825
2828
|
function s() {
|
|
2826
2829
|
n._config.driver = n.driver();
|
|
@@ -2867,19 +2870,19 @@ var init_es4 = __esm({
|
|
|
2867
2870
|
}
|
|
2868
2871
|
return o;
|
|
2869
2872
|
}, e.prototype._wrapLibraryMethodsWithReady = function() {
|
|
2870
|
-
for (var r10 = 0, o =
|
|
2873
|
+
for (var r10 = 0, o = Ee.length; r10 < o; r10++) Vr(this, Ee[r10]);
|
|
2871
2874
|
}, e.prototype.createInstance = function(r10) {
|
|
2872
2875
|
return new e(r10);
|
|
2873
2876
|
}, e;
|
|
2874
|
-
}(), jr = new Gr2();
|
|
2877
|
+
})(), jr = new Gr2();
|
|
2875
2878
|
W2.exports = jr;
|
|
2876
2879
|
}, { 3: 3 }] }, {}, [4])(4);
|
|
2877
2880
|
});
|
|
2878
2881
|
});
|
|
2879
|
-
er2 = Je2((me2,
|
|
2882
|
+
er2 = Je2((me2, ke2) => {
|
|
2880
2883
|
"use strict";
|
|
2881
2884
|
(function(_2, y3) {
|
|
2882
|
-
typeof me2 == "object" && typeof
|
|
2885
|
+
typeof me2 == "object" && typeof ke2 < "u" ? y3(me2) : typeof define == "function" && define.amd ? define("localforage-driver-memory", ["exports"], y3) : y3(_2.LocalforageDriverMemory = {});
|
|
2883
2886
|
})(typeof self < "u" ? self : me2, function(_2) {
|
|
2884
2887
|
"use strict";
|
|
2885
2888
|
var y3 = "localforage-driver-memory";
|
|
@@ -2889,7 +2892,7 @@ var init_es4 = __esm({
|
|
|
2889
2892
|
return a && v2 >= a.length && (a = void 0), { value: a && a[v2++], done: !a };
|
|
2890
2893
|
} };
|
|
2891
2894
|
}
|
|
2892
|
-
function
|
|
2895
|
+
function C2(a, u2) {
|
|
2893
2896
|
a = a || [], u2 = u2 || {};
|
|
2894
2897
|
try {
|
|
2895
2898
|
return new Blob(a, u2);
|
|
@@ -2904,8 +2907,8 @@ var init_es4 = __esm({
|
|
|
2904
2907
|
var u2 = a.length * 0.75, v2 = a.length;
|
|
2905
2908
|
a[a.length - 1] === "=" && (u2--, a[a.length - 2] === "=" && u2--);
|
|
2906
2909
|
for (var g2 = new ArrayBuffer(u2), b3 = new Uint8Array(g2), I2 = 0, R3 = 0; I2 < v2; I2 += 4) {
|
|
2907
|
-
var G2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I2]),
|
|
2908
|
-
b3[R3++] = G2 << 2 |
|
|
2910
|
+
var G2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I2]), fe2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I2 + 1]), ie2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I2 + 2]), ue = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I2 + 3]);
|
|
2911
|
+
b3[R3++] = G2 << 2 | fe2 >> 4, b3[R3++] = (fe2 & 15) << 4 | ie2 >> 2, b3[R3++] = (ie2 & 3) << 6 | ue & 63;
|
|
2909
2912
|
}
|
|
2910
2913
|
return g2;
|
|
2911
2914
|
}
|
|
@@ -2942,7 +2945,7 @@ var init_es4 = __esm({
|
|
|
2942
2945
|
case "arbf":
|
|
2943
2946
|
return I2;
|
|
2944
2947
|
case "blob":
|
|
2945
|
-
return
|
|
2948
|
+
return C2([I2], { type: g2 });
|
|
2946
2949
|
case "si08":
|
|
2947
2950
|
return new Int8Array(I2);
|
|
2948
2951
|
case "ui08":
|
|
@@ -3013,7 +3016,7 @@ var init_es4 = __esm({
|
|
|
3013
3016
|
function P2(a) {
|
|
3014
3017
|
return typeof a != "string" && (console.warn(a + " used as a key, but it is not a string."), a = String(a)), a;
|
|
3015
3018
|
}
|
|
3016
|
-
var k2 = { bufferToString: z3, deserialize: J3, serialize: K2, stringToBuffer: D2 }, M2 = {}, ae2 = function() {
|
|
3019
|
+
var k2 = { bufferToString: z3, deserialize: J3, serialize: K2, stringToBuffer: D2 }, M2 = {}, ae2 = (function() {
|
|
3017
3020
|
function a(u2) {
|
|
3018
3021
|
this.kp = u2, this.data = {};
|
|
3019
3022
|
}
|
|
@@ -3034,7 +3037,7 @@ var init_es4 = __esm({
|
|
|
3034
3037
|
}, a.prototype.set = function(u2, v2) {
|
|
3035
3038
|
this.data[u2] = v2;
|
|
3036
3039
|
}, a;
|
|
3037
|
-
}();
|
|
3040
|
+
})();
|
|
3038
3041
|
function re2(a) {
|
|
3039
3042
|
var u2 = a ? m3(a) : {}, v2 = w2(u2, this._defaultConfig), g2 = ae2.resolve(v2);
|
|
3040
3043
|
return this._dbInfo = u2, this._dbInfo.serializer = k2, this._dbInfo.keyPrefix = v2, this._dbInfo.mStore = g2, Promise.resolve();
|
|
@@ -3060,7 +3063,7 @@ var init_es4 = __esm({
|
|
|
3060
3063
|
});
|
|
3061
3064
|
return T3(g2, u2), g2;
|
|
3062
3065
|
}
|
|
3063
|
-
function
|
|
3066
|
+
function N3(a, u2) {
|
|
3064
3067
|
var v2 = this, g2 = this.ready().then(function() {
|
|
3065
3068
|
for (var b3 = v2._dbInfo.mStore, I2 = b3.keys(), R3 = 0; R3 < I2.length; R3++) {
|
|
3066
3069
|
var G2 = b3.get(I2[R3]);
|
|
@@ -3108,36 +3111,36 @@ var init_es4 = __esm({
|
|
|
3108
3111
|
u2 === void 0 && (u2 = null);
|
|
3109
3112
|
var I2 = u2;
|
|
3110
3113
|
return new Promise(function(R3, G2) {
|
|
3111
|
-
g2._dbInfo.serializer.serialize(u2, function(
|
|
3114
|
+
g2._dbInfo.serializer.serialize(u2, function(fe2, ie2) {
|
|
3112
3115
|
if (ie2) G2(ie2);
|
|
3113
3116
|
else try {
|
|
3114
|
-
g2._dbInfo.mStore.set(a,
|
|
3115
|
-
} catch (
|
|
3116
|
-
G2(
|
|
3117
|
+
g2._dbInfo.mStore.set(a, fe2), R3(I2);
|
|
3118
|
+
} catch (ue) {
|
|
3119
|
+
G2(ue);
|
|
3117
3120
|
}
|
|
3118
3121
|
});
|
|
3119
3122
|
});
|
|
3120
3123
|
});
|
|
3121
3124
|
return T3(b3, v2), b3;
|
|
3122
3125
|
}
|
|
3123
|
-
var
|
|
3124
|
-
_2._support =
|
|
3126
|
+
var oe2 = true;
|
|
3127
|
+
_2._support = oe2, _2._driver = y3, _2._initStorage = re2, _2.clear = h3, _2.dropInstance = A3, _2.getItem = E3, _2.iterate = N3, _2.key = H3, _2.keys = j2, _2.length = X3, _2.removeItem = Q3, _2.setItem = ee2, Object.defineProperty(_2, "__esModule", { value: true });
|
|
3125
3128
|
});
|
|
3126
3129
|
});
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
at2 = { display: "
|
|
3130
|
-
|
|
3130
|
+
pe2 = $e2(qe2());
|
|
3131
|
+
Te2 = $e2(er2());
|
|
3132
|
+
at2 = { display: "none", position: "fixed", top: "0", right: "0", width: "100%", height: "100%", borderRadius: "0", border: "none", opacity: "0", zIndex: "-1" };
|
|
3133
|
+
ye2 = class extends je {
|
|
3131
3134
|
activeElement = null;
|
|
3132
3135
|
iframe;
|
|
3133
|
-
relayerSrc =
|
|
3136
|
+
relayerSrc = Je(`/send?params=${encodeURIComponent(this.parameters)}`, this.endpoint).href;
|
|
3134
3137
|
init() {
|
|
3135
3138
|
this.test = "hello", this.iframe = new Promise((y3) => {
|
|
3136
3139
|
let O3 = () => {
|
|
3137
3140
|
if (st2(encodeURIComponent(this.parameters))) Bn().log();
|
|
3138
3141
|
else {
|
|
3139
|
-
let
|
|
3140
|
-
|
|
3142
|
+
let C2 = document.createElement("iframe");
|
|
3143
|
+
C2.classList.add("magic-iframe"), C2.dataset.magicIframeLabel = Je(this.endpoint).host, C2.title = "Secure Modal", C2.src = this.relayerSrc, C2.allow = "clipboard-read; clipboard-write", ft2(C2), document.body.appendChild(C2), y3(C2);
|
|
3141
3144
|
}
|
|
3142
3145
|
};
|
|
3143
3146
|
["loaded", "interactive", "complete"].includes(document.readyState) ? O3() : window.addEventListener("load", O3, false);
|
|
@@ -3156,11 +3159,11 @@ var init_es4 = __esm({
|
|
|
3156
3159
|
}
|
|
3157
3160
|
async showOverlay() {
|
|
3158
3161
|
let y3 = await this.iframe;
|
|
3159
|
-
y3.style.
|
|
3162
|
+
y3.style.display = "block", y3.style.zIndex = "2147483647", y3.style.opacity = "1", this.activeElement = document.activeElement, y3.focus();
|
|
3160
3163
|
}
|
|
3161
3164
|
async hideOverlay() {
|
|
3162
3165
|
let y3 = await this.iframe;
|
|
3163
|
-
y3.style.
|
|
3166
|
+
y3.style.display = "none", y3.style.zIndex = "-1", y3.style.opacity = "0", this.activeElement?.focus && this.activeElement.focus(), this.activeElement = null;
|
|
3164
3167
|
}
|
|
3165
3168
|
async _post(y3) {
|
|
3166
3169
|
let O3 = await this.iframe;
|
|
@@ -3169,7 +3172,7 @@ var init_es4 = __esm({
|
|
|
3169
3172
|
}
|
|
3170
3173
|
async checkRelayerExistsInDOM() {
|
|
3171
3174
|
let y3 = await this.iframe;
|
|
3172
|
-
return !y3 || !y3.contentWindow ? false : !![].slice.call(document.querySelectorAll(".magic-iframe")).find((
|
|
3175
|
+
return !y3 || !y3.contentWindow ? false : !![].slice.call(document.querySelectorAll(".magic-iframe")).find((C2) => C2.src.includes(encodeURIComponent(this.parameters)));
|
|
3173
3176
|
}
|
|
3174
3177
|
async reloadRelayer() {
|
|
3175
3178
|
let y3 = await this.iframe;
|
|
@@ -3184,28 +3187,28 @@ var init_es4 = __esm({
|
|
|
3184
3187
|
y3 && (y3.src = this.relayerSrc);
|
|
3185
3188
|
}
|
|
3186
3189
|
};
|
|
3187
|
-
wt2 = Hr(
|
|
3188
|
-
let _2 =
|
|
3189
|
-
return await _2.defineDriver(
|
|
3190
|
+
wt2 = Hr(Ke, { platform: "web", sdkName: "magic-sdk", version: "29.4.2", defaultEndpoint: "https://auth.magic.link/", ViewController: ye2, configureStorage: async () => {
|
|
3191
|
+
let _2 = pe2.default.createInstance({ name: "MagicAuthLocalStorageDB", storeName: "MagicAuthLocalStorage" });
|
|
3192
|
+
return await _2.defineDriver(Te2), await _2.setDriver([pe2.default.INDEXEDDB, pe2.default.LOCALSTORAGE, Te2._driver]), _2;
|
|
3190
3193
|
} });
|
|
3191
3194
|
}
|
|
3192
3195
|
});
|
|
3193
3196
|
|
|
3194
|
-
// ../../node_modules/.pnpm/@magic-ext+algorand@24.
|
|
3197
|
+
// ../../node_modules/.pnpm/@magic-ext+algorand@24.4.2/node_modules/@magic-ext/algorand/dist/es/index.mjs
|
|
3195
3198
|
var es_exports2 = {};
|
|
3196
3199
|
__export(es_exports2, {
|
|
3197
3200
|
AlgorandExtension: () => r9
|
|
3198
3201
|
});
|
|
3199
3202
|
var r9;
|
|
3200
3203
|
var init_es5 = __esm({
|
|
3201
|
-
"../../node_modules/.pnpm/@magic-ext+algorand@24.
|
|
3204
|
+
"../../node_modules/.pnpm/@magic-ext+algorand@24.4.2/node_modules/@magic-ext/algorand/dist/es/index.mjs"() {
|
|
3202
3205
|
"use strict";
|
|
3203
3206
|
init_es3();
|
|
3204
|
-
r9 = class extends
|
|
3207
|
+
r9 = class extends He.Internal {
|
|
3205
3208
|
constructor(n) {
|
|
3206
3209
|
super();
|
|
3207
3210
|
this.algorandConfig = n;
|
|
3208
|
-
this.config = { rpcUrl: n.rpcUrl, chainType: "
|
|
3211
|
+
this.config = { rpcUrl: n.rpcUrl, chainType: "ALGOD" };
|
|
3209
3212
|
}
|
|
3210
3213
|
name = "algod";
|
|
3211
3214
|
config = {};
|
|
@@ -3228,6 +3231,2231 @@ var init_es5 = __esm({
|
|
|
3228
3231
|
}
|
|
3229
3232
|
});
|
|
3230
3233
|
|
|
3234
|
+
// ../../node_modules/.pnpm/tweetnacl@1.0.3/node_modules/tweetnacl/nacl-fast.js
|
|
3235
|
+
var require_nacl_fast = __commonJS({
|
|
3236
|
+
"../../node_modules/.pnpm/tweetnacl@1.0.3/node_modules/tweetnacl/nacl-fast.js"(exports2, module2) {
|
|
3237
|
+
"use strict";
|
|
3238
|
+
(function(nacl) {
|
|
3239
|
+
"use strict";
|
|
3240
|
+
var gf = function(init) {
|
|
3241
|
+
var i, r10 = new Float64Array(16);
|
|
3242
|
+
if (init) for (i = 0; i < init.length; i++) r10[i] = init[i];
|
|
3243
|
+
return r10;
|
|
3244
|
+
};
|
|
3245
|
+
var randombytes = function() {
|
|
3246
|
+
throw new Error("no PRNG");
|
|
3247
|
+
};
|
|
3248
|
+
var _0 = new Uint8Array(16);
|
|
3249
|
+
var _9 = new Uint8Array(32);
|
|
3250
|
+
_9[0] = 9;
|
|
3251
|
+
var gf0 = gf(), gf1 = gf([1]), _121665 = gf([56129, 1]), D2 = gf([30883, 4953, 19914, 30187, 55467, 16705, 2637, 112, 59544, 30585, 16505, 36039, 65139, 11119, 27886, 20995]), D22 = gf([61785, 9906, 39828, 60374, 45398, 33411, 5274, 224, 53552, 61171, 33010, 6542, 64743, 22239, 55772, 9222]), X3 = gf([54554, 36645, 11616, 51542, 42930, 38181, 51040, 26924, 56412, 64982, 57905, 49316, 21502, 52590, 14035, 8553]), Y3 = gf([26200, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214, 26214]), I2 = gf([41136, 18958, 6951, 50414, 58488, 44335, 6150, 12099, 55207, 15867, 153, 11085, 57099, 20417, 9344, 11139]);
|
|
3252
|
+
function ts64(x2, i, h3, l) {
|
|
3253
|
+
x2[i] = h3 >> 24 & 255;
|
|
3254
|
+
x2[i + 1] = h3 >> 16 & 255;
|
|
3255
|
+
x2[i + 2] = h3 >> 8 & 255;
|
|
3256
|
+
x2[i + 3] = h3 & 255;
|
|
3257
|
+
x2[i + 4] = l >> 24 & 255;
|
|
3258
|
+
x2[i + 5] = l >> 16 & 255;
|
|
3259
|
+
x2[i + 6] = l >> 8 & 255;
|
|
3260
|
+
x2[i + 7] = l & 255;
|
|
3261
|
+
}
|
|
3262
|
+
function vn2(x2, xi, y3, yi, n) {
|
|
3263
|
+
var i, d = 0;
|
|
3264
|
+
for (i = 0; i < n; i++) d |= x2[xi + i] ^ y3[yi + i];
|
|
3265
|
+
return (1 & d - 1 >>> 8) - 1;
|
|
3266
|
+
}
|
|
3267
|
+
function crypto_verify_16(x2, xi, y3, yi) {
|
|
3268
|
+
return vn2(x2, xi, y3, yi, 16);
|
|
3269
|
+
}
|
|
3270
|
+
function crypto_verify_32(x2, xi, y3, yi) {
|
|
3271
|
+
return vn2(x2, xi, y3, yi, 32);
|
|
3272
|
+
}
|
|
3273
|
+
function core_salsa20(o, p2, k2, c) {
|
|
3274
|
+
var j0 = c[0] & 255 | (c[1] & 255) << 8 | (c[2] & 255) << 16 | (c[3] & 255) << 24, j1 = k2[0] & 255 | (k2[1] & 255) << 8 | (k2[2] & 255) << 16 | (k2[3] & 255) << 24, j2 = k2[4] & 255 | (k2[5] & 255) << 8 | (k2[6] & 255) << 16 | (k2[7] & 255) << 24, j3 = k2[8] & 255 | (k2[9] & 255) << 8 | (k2[10] & 255) << 16 | (k2[11] & 255) << 24, j4 = k2[12] & 255 | (k2[13] & 255) << 8 | (k2[14] & 255) << 16 | (k2[15] & 255) << 24, j5 = c[4] & 255 | (c[5] & 255) << 8 | (c[6] & 255) << 16 | (c[7] & 255) << 24, j6 = p2[0] & 255 | (p2[1] & 255) << 8 | (p2[2] & 255) << 16 | (p2[3] & 255) << 24, j7 = p2[4] & 255 | (p2[5] & 255) << 8 | (p2[6] & 255) << 16 | (p2[7] & 255) << 24, j8 = p2[8] & 255 | (p2[9] & 255) << 8 | (p2[10] & 255) << 16 | (p2[11] & 255) << 24, j9 = p2[12] & 255 | (p2[13] & 255) << 8 | (p2[14] & 255) << 16 | (p2[15] & 255) << 24, j10 = c[8] & 255 | (c[9] & 255) << 8 | (c[10] & 255) << 16 | (c[11] & 255) << 24, j11 = k2[16] & 255 | (k2[17] & 255) << 8 | (k2[18] & 255) << 16 | (k2[19] & 255) << 24, j12 = k2[20] & 255 | (k2[21] & 255) << 8 | (k2[22] & 255) << 16 | (k2[23] & 255) << 24, j13 = k2[24] & 255 | (k2[25] & 255) << 8 | (k2[26] & 255) << 16 | (k2[27] & 255) << 24, j14 = k2[28] & 255 | (k2[29] & 255) << 8 | (k2[30] & 255) << 16 | (k2[31] & 255) << 24, j15 = c[12] & 255 | (c[13] & 255) << 8 | (c[14] & 255) << 16 | (c[15] & 255) << 24;
|
|
3275
|
+
var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7, x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14, x15 = j15, u2;
|
|
3276
|
+
for (var i = 0; i < 20; i += 2) {
|
|
3277
|
+
u2 = x0 + x12 | 0;
|
|
3278
|
+
x4 ^= u2 << 7 | u2 >>> 32 - 7;
|
|
3279
|
+
u2 = x4 + x0 | 0;
|
|
3280
|
+
x8 ^= u2 << 9 | u2 >>> 32 - 9;
|
|
3281
|
+
u2 = x8 + x4 | 0;
|
|
3282
|
+
x12 ^= u2 << 13 | u2 >>> 32 - 13;
|
|
3283
|
+
u2 = x12 + x8 | 0;
|
|
3284
|
+
x0 ^= u2 << 18 | u2 >>> 32 - 18;
|
|
3285
|
+
u2 = x5 + x1 | 0;
|
|
3286
|
+
x9 ^= u2 << 7 | u2 >>> 32 - 7;
|
|
3287
|
+
u2 = x9 + x5 | 0;
|
|
3288
|
+
x13 ^= u2 << 9 | u2 >>> 32 - 9;
|
|
3289
|
+
u2 = x13 + x9 | 0;
|
|
3290
|
+
x1 ^= u2 << 13 | u2 >>> 32 - 13;
|
|
3291
|
+
u2 = x1 + x13 | 0;
|
|
3292
|
+
x5 ^= u2 << 18 | u2 >>> 32 - 18;
|
|
3293
|
+
u2 = x10 + x6 | 0;
|
|
3294
|
+
x14 ^= u2 << 7 | u2 >>> 32 - 7;
|
|
3295
|
+
u2 = x14 + x10 | 0;
|
|
3296
|
+
x2 ^= u2 << 9 | u2 >>> 32 - 9;
|
|
3297
|
+
u2 = x2 + x14 | 0;
|
|
3298
|
+
x6 ^= u2 << 13 | u2 >>> 32 - 13;
|
|
3299
|
+
u2 = x6 + x2 | 0;
|
|
3300
|
+
x10 ^= u2 << 18 | u2 >>> 32 - 18;
|
|
3301
|
+
u2 = x15 + x11 | 0;
|
|
3302
|
+
x3 ^= u2 << 7 | u2 >>> 32 - 7;
|
|
3303
|
+
u2 = x3 + x15 | 0;
|
|
3304
|
+
x7 ^= u2 << 9 | u2 >>> 32 - 9;
|
|
3305
|
+
u2 = x7 + x3 | 0;
|
|
3306
|
+
x11 ^= u2 << 13 | u2 >>> 32 - 13;
|
|
3307
|
+
u2 = x11 + x7 | 0;
|
|
3308
|
+
x15 ^= u2 << 18 | u2 >>> 32 - 18;
|
|
3309
|
+
u2 = x0 + x3 | 0;
|
|
3310
|
+
x1 ^= u2 << 7 | u2 >>> 32 - 7;
|
|
3311
|
+
u2 = x1 + x0 | 0;
|
|
3312
|
+
x2 ^= u2 << 9 | u2 >>> 32 - 9;
|
|
3313
|
+
u2 = x2 + x1 | 0;
|
|
3314
|
+
x3 ^= u2 << 13 | u2 >>> 32 - 13;
|
|
3315
|
+
u2 = x3 + x2 | 0;
|
|
3316
|
+
x0 ^= u2 << 18 | u2 >>> 32 - 18;
|
|
3317
|
+
u2 = x5 + x4 | 0;
|
|
3318
|
+
x6 ^= u2 << 7 | u2 >>> 32 - 7;
|
|
3319
|
+
u2 = x6 + x5 | 0;
|
|
3320
|
+
x7 ^= u2 << 9 | u2 >>> 32 - 9;
|
|
3321
|
+
u2 = x7 + x6 | 0;
|
|
3322
|
+
x4 ^= u2 << 13 | u2 >>> 32 - 13;
|
|
3323
|
+
u2 = x4 + x7 | 0;
|
|
3324
|
+
x5 ^= u2 << 18 | u2 >>> 32 - 18;
|
|
3325
|
+
u2 = x10 + x9 | 0;
|
|
3326
|
+
x11 ^= u2 << 7 | u2 >>> 32 - 7;
|
|
3327
|
+
u2 = x11 + x10 | 0;
|
|
3328
|
+
x8 ^= u2 << 9 | u2 >>> 32 - 9;
|
|
3329
|
+
u2 = x8 + x11 | 0;
|
|
3330
|
+
x9 ^= u2 << 13 | u2 >>> 32 - 13;
|
|
3331
|
+
u2 = x9 + x8 | 0;
|
|
3332
|
+
x10 ^= u2 << 18 | u2 >>> 32 - 18;
|
|
3333
|
+
u2 = x15 + x14 | 0;
|
|
3334
|
+
x12 ^= u2 << 7 | u2 >>> 32 - 7;
|
|
3335
|
+
u2 = x12 + x15 | 0;
|
|
3336
|
+
x13 ^= u2 << 9 | u2 >>> 32 - 9;
|
|
3337
|
+
u2 = x13 + x12 | 0;
|
|
3338
|
+
x14 ^= u2 << 13 | u2 >>> 32 - 13;
|
|
3339
|
+
u2 = x14 + x13 | 0;
|
|
3340
|
+
x15 ^= u2 << 18 | u2 >>> 32 - 18;
|
|
3341
|
+
}
|
|
3342
|
+
x0 = x0 + j0 | 0;
|
|
3343
|
+
x1 = x1 + j1 | 0;
|
|
3344
|
+
x2 = x2 + j2 | 0;
|
|
3345
|
+
x3 = x3 + j3 | 0;
|
|
3346
|
+
x4 = x4 + j4 | 0;
|
|
3347
|
+
x5 = x5 + j5 | 0;
|
|
3348
|
+
x6 = x6 + j6 | 0;
|
|
3349
|
+
x7 = x7 + j7 | 0;
|
|
3350
|
+
x8 = x8 + j8 | 0;
|
|
3351
|
+
x9 = x9 + j9 | 0;
|
|
3352
|
+
x10 = x10 + j10 | 0;
|
|
3353
|
+
x11 = x11 + j11 | 0;
|
|
3354
|
+
x12 = x12 + j12 | 0;
|
|
3355
|
+
x13 = x13 + j13 | 0;
|
|
3356
|
+
x14 = x14 + j14 | 0;
|
|
3357
|
+
x15 = x15 + j15 | 0;
|
|
3358
|
+
o[0] = x0 >>> 0 & 255;
|
|
3359
|
+
o[1] = x0 >>> 8 & 255;
|
|
3360
|
+
o[2] = x0 >>> 16 & 255;
|
|
3361
|
+
o[3] = x0 >>> 24 & 255;
|
|
3362
|
+
o[4] = x1 >>> 0 & 255;
|
|
3363
|
+
o[5] = x1 >>> 8 & 255;
|
|
3364
|
+
o[6] = x1 >>> 16 & 255;
|
|
3365
|
+
o[7] = x1 >>> 24 & 255;
|
|
3366
|
+
o[8] = x2 >>> 0 & 255;
|
|
3367
|
+
o[9] = x2 >>> 8 & 255;
|
|
3368
|
+
o[10] = x2 >>> 16 & 255;
|
|
3369
|
+
o[11] = x2 >>> 24 & 255;
|
|
3370
|
+
o[12] = x3 >>> 0 & 255;
|
|
3371
|
+
o[13] = x3 >>> 8 & 255;
|
|
3372
|
+
o[14] = x3 >>> 16 & 255;
|
|
3373
|
+
o[15] = x3 >>> 24 & 255;
|
|
3374
|
+
o[16] = x4 >>> 0 & 255;
|
|
3375
|
+
o[17] = x4 >>> 8 & 255;
|
|
3376
|
+
o[18] = x4 >>> 16 & 255;
|
|
3377
|
+
o[19] = x4 >>> 24 & 255;
|
|
3378
|
+
o[20] = x5 >>> 0 & 255;
|
|
3379
|
+
o[21] = x5 >>> 8 & 255;
|
|
3380
|
+
o[22] = x5 >>> 16 & 255;
|
|
3381
|
+
o[23] = x5 >>> 24 & 255;
|
|
3382
|
+
o[24] = x6 >>> 0 & 255;
|
|
3383
|
+
o[25] = x6 >>> 8 & 255;
|
|
3384
|
+
o[26] = x6 >>> 16 & 255;
|
|
3385
|
+
o[27] = x6 >>> 24 & 255;
|
|
3386
|
+
o[28] = x7 >>> 0 & 255;
|
|
3387
|
+
o[29] = x7 >>> 8 & 255;
|
|
3388
|
+
o[30] = x7 >>> 16 & 255;
|
|
3389
|
+
o[31] = x7 >>> 24 & 255;
|
|
3390
|
+
o[32] = x8 >>> 0 & 255;
|
|
3391
|
+
o[33] = x8 >>> 8 & 255;
|
|
3392
|
+
o[34] = x8 >>> 16 & 255;
|
|
3393
|
+
o[35] = x8 >>> 24 & 255;
|
|
3394
|
+
o[36] = x9 >>> 0 & 255;
|
|
3395
|
+
o[37] = x9 >>> 8 & 255;
|
|
3396
|
+
o[38] = x9 >>> 16 & 255;
|
|
3397
|
+
o[39] = x9 >>> 24 & 255;
|
|
3398
|
+
o[40] = x10 >>> 0 & 255;
|
|
3399
|
+
o[41] = x10 >>> 8 & 255;
|
|
3400
|
+
o[42] = x10 >>> 16 & 255;
|
|
3401
|
+
o[43] = x10 >>> 24 & 255;
|
|
3402
|
+
o[44] = x11 >>> 0 & 255;
|
|
3403
|
+
o[45] = x11 >>> 8 & 255;
|
|
3404
|
+
o[46] = x11 >>> 16 & 255;
|
|
3405
|
+
o[47] = x11 >>> 24 & 255;
|
|
3406
|
+
o[48] = x12 >>> 0 & 255;
|
|
3407
|
+
o[49] = x12 >>> 8 & 255;
|
|
3408
|
+
o[50] = x12 >>> 16 & 255;
|
|
3409
|
+
o[51] = x12 >>> 24 & 255;
|
|
3410
|
+
o[52] = x13 >>> 0 & 255;
|
|
3411
|
+
o[53] = x13 >>> 8 & 255;
|
|
3412
|
+
o[54] = x13 >>> 16 & 255;
|
|
3413
|
+
o[55] = x13 >>> 24 & 255;
|
|
3414
|
+
o[56] = x14 >>> 0 & 255;
|
|
3415
|
+
o[57] = x14 >>> 8 & 255;
|
|
3416
|
+
o[58] = x14 >>> 16 & 255;
|
|
3417
|
+
o[59] = x14 >>> 24 & 255;
|
|
3418
|
+
o[60] = x15 >>> 0 & 255;
|
|
3419
|
+
o[61] = x15 >>> 8 & 255;
|
|
3420
|
+
o[62] = x15 >>> 16 & 255;
|
|
3421
|
+
o[63] = x15 >>> 24 & 255;
|
|
3422
|
+
}
|
|
3423
|
+
function core_hsalsa20(o, p2, k2, c) {
|
|
3424
|
+
var j0 = c[0] & 255 | (c[1] & 255) << 8 | (c[2] & 255) << 16 | (c[3] & 255) << 24, j1 = k2[0] & 255 | (k2[1] & 255) << 8 | (k2[2] & 255) << 16 | (k2[3] & 255) << 24, j2 = k2[4] & 255 | (k2[5] & 255) << 8 | (k2[6] & 255) << 16 | (k2[7] & 255) << 24, j3 = k2[8] & 255 | (k2[9] & 255) << 8 | (k2[10] & 255) << 16 | (k2[11] & 255) << 24, j4 = k2[12] & 255 | (k2[13] & 255) << 8 | (k2[14] & 255) << 16 | (k2[15] & 255) << 24, j5 = c[4] & 255 | (c[5] & 255) << 8 | (c[6] & 255) << 16 | (c[7] & 255) << 24, j6 = p2[0] & 255 | (p2[1] & 255) << 8 | (p2[2] & 255) << 16 | (p2[3] & 255) << 24, j7 = p2[4] & 255 | (p2[5] & 255) << 8 | (p2[6] & 255) << 16 | (p2[7] & 255) << 24, j8 = p2[8] & 255 | (p2[9] & 255) << 8 | (p2[10] & 255) << 16 | (p2[11] & 255) << 24, j9 = p2[12] & 255 | (p2[13] & 255) << 8 | (p2[14] & 255) << 16 | (p2[15] & 255) << 24, j10 = c[8] & 255 | (c[9] & 255) << 8 | (c[10] & 255) << 16 | (c[11] & 255) << 24, j11 = k2[16] & 255 | (k2[17] & 255) << 8 | (k2[18] & 255) << 16 | (k2[19] & 255) << 24, j12 = k2[20] & 255 | (k2[21] & 255) << 8 | (k2[22] & 255) << 16 | (k2[23] & 255) << 24, j13 = k2[24] & 255 | (k2[25] & 255) << 8 | (k2[26] & 255) << 16 | (k2[27] & 255) << 24, j14 = k2[28] & 255 | (k2[29] & 255) << 8 | (k2[30] & 255) << 16 | (k2[31] & 255) << 24, j15 = c[12] & 255 | (c[13] & 255) << 8 | (c[14] & 255) << 16 | (c[15] & 255) << 24;
|
|
3425
|
+
var x0 = j0, x1 = j1, x2 = j2, x3 = j3, x4 = j4, x5 = j5, x6 = j6, x7 = j7, x8 = j8, x9 = j9, x10 = j10, x11 = j11, x12 = j12, x13 = j13, x14 = j14, x15 = j15, u2;
|
|
3426
|
+
for (var i = 0; i < 20; i += 2) {
|
|
3427
|
+
u2 = x0 + x12 | 0;
|
|
3428
|
+
x4 ^= u2 << 7 | u2 >>> 32 - 7;
|
|
3429
|
+
u2 = x4 + x0 | 0;
|
|
3430
|
+
x8 ^= u2 << 9 | u2 >>> 32 - 9;
|
|
3431
|
+
u2 = x8 + x4 | 0;
|
|
3432
|
+
x12 ^= u2 << 13 | u2 >>> 32 - 13;
|
|
3433
|
+
u2 = x12 + x8 | 0;
|
|
3434
|
+
x0 ^= u2 << 18 | u2 >>> 32 - 18;
|
|
3435
|
+
u2 = x5 + x1 | 0;
|
|
3436
|
+
x9 ^= u2 << 7 | u2 >>> 32 - 7;
|
|
3437
|
+
u2 = x9 + x5 | 0;
|
|
3438
|
+
x13 ^= u2 << 9 | u2 >>> 32 - 9;
|
|
3439
|
+
u2 = x13 + x9 | 0;
|
|
3440
|
+
x1 ^= u2 << 13 | u2 >>> 32 - 13;
|
|
3441
|
+
u2 = x1 + x13 | 0;
|
|
3442
|
+
x5 ^= u2 << 18 | u2 >>> 32 - 18;
|
|
3443
|
+
u2 = x10 + x6 | 0;
|
|
3444
|
+
x14 ^= u2 << 7 | u2 >>> 32 - 7;
|
|
3445
|
+
u2 = x14 + x10 | 0;
|
|
3446
|
+
x2 ^= u2 << 9 | u2 >>> 32 - 9;
|
|
3447
|
+
u2 = x2 + x14 | 0;
|
|
3448
|
+
x6 ^= u2 << 13 | u2 >>> 32 - 13;
|
|
3449
|
+
u2 = x6 + x2 | 0;
|
|
3450
|
+
x10 ^= u2 << 18 | u2 >>> 32 - 18;
|
|
3451
|
+
u2 = x15 + x11 | 0;
|
|
3452
|
+
x3 ^= u2 << 7 | u2 >>> 32 - 7;
|
|
3453
|
+
u2 = x3 + x15 | 0;
|
|
3454
|
+
x7 ^= u2 << 9 | u2 >>> 32 - 9;
|
|
3455
|
+
u2 = x7 + x3 | 0;
|
|
3456
|
+
x11 ^= u2 << 13 | u2 >>> 32 - 13;
|
|
3457
|
+
u2 = x11 + x7 | 0;
|
|
3458
|
+
x15 ^= u2 << 18 | u2 >>> 32 - 18;
|
|
3459
|
+
u2 = x0 + x3 | 0;
|
|
3460
|
+
x1 ^= u2 << 7 | u2 >>> 32 - 7;
|
|
3461
|
+
u2 = x1 + x0 | 0;
|
|
3462
|
+
x2 ^= u2 << 9 | u2 >>> 32 - 9;
|
|
3463
|
+
u2 = x2 + x1 | 0;
|
|
3464
|
+
x3 ^= u2 << 13 | u2 >>> 32 - 13;
|
|
3465
|
+
u2 = x3 + x2 | 0;
|
|
3466
|
+
x0 ^= u2 << 18 | u2 >>> 32 - 18;
|
|
3467
|
+
u2 = x5 + x4 | 0;
|
|
3468
|
+
x6 ^= u2 << 7 | u2 >>> 32 - 7;
|
|
3469
|
+
u2 = x6 + x5 | 0;
|
|
3470
|
+
x7 ^= u2 << 9 | u2 >>> 32 - 9;
|
|
3471
|
+
u2 = x7 + x6 | 0;
|
|
3472
|
+
x4 ^= u2 << 13 | u2 >>> 32 - 13;
|
|
3473
|
+
u2 = x4 + x7 | 0;
|
|
3474
|
+
x5 ^= u2 << 18 | u2 >>> 32 - 18;
|
|
3475
|
+
u2 = x10 + x9 | 0;
|
|
3476
|
+
x11 ^= u2 << 7 | u2 >>> 32 - 7;
|
|
3477
|
+
u2 = x11 + x10 | 0;
|
|
3478
|
+
x8 ^= u2 << 9 | u2 >>> 32 - 9;
|
|
3479
|
+
u2 = x8 + x11 | 0;
|
|
3480
|
+
x9 ^= u2 << 13 | u2 >>> 32 - 13;
|
|
3481
|
+
u2 = x9 + x8 | 0;
|
|
3482
|
+
x10 ^= u2 << 18 | u2 >>> 32 - 18;
|
|
3483
|
+
u2 = x15 + x14 | 0;
|
|
3484
|
+
x12 ^= u2 << 7 | u2 >>> 32 - 7;
|
|
3485
|
+
u2 = x12 + x15 | 0;
|
|
3486
|
+
x13 ^= u2 << 9 | u2 >>> 32 - 9;
|
|
3487
|
+
u2 = x13 + x12 | 0;
|
|
3488
|
+
x14 ^= u2 << 13 | u2 >>> 32 - 13;
|
|
3489
|
+
u2 = x14 + x13 | 0;
|
|
3490
|
+
x15 ^= u2 << 18 | u2 >>> 32 - 18;
|
|
3491
|
+
}
|
|
3492
|
+
o[0] = x0 >>> 0 & 255;
|
|
3493
|
+
o[1] = x0 >>> 8 & 255;
|
|
3494
|
+
o[2] = x0 >>> 16 & 255;
|
|
3495
|
+
o[3] = x0 >>> 24 & 255;
|
|
3496
|
+
o[4] = x5 >>> 0 & 255;
|
|
3497
|
+
o[5] = x5 >>> 8 & 255;
|
|
3498
|
+
o[6] = x5 >>> 16 & 255;
|
|
3499
|
+
o[7] = x5 >>> 24 & 255;
|
|
3500
|
+
o[8] = x10 >>> 0 & 255;
|
|
3501
|
+
o[9] = x10 >>> 8 & 255;
|
|
3502
|
+
o[10] = x10 >>> 16 & 255;
|
|
3503
|
+
o[11] = x10 >>> 24 & 255;
|
|
3504
|
+
o[12] = x15 >>> 0 & 255;
|
|
3505
|
+
o[13] = x15 >>> 8 & 255;
|
|
3506
|
+
o[14] = x15 >>> 16 & 255;
|
|
3507
|
+
o[15] = x15 >>> 24 & 255;
|
|
3508
|
+
o[16] = x6 >>> 0 & 255;
|
|
3509
|
+
o[17] = x6 >>> 8 & 255;
|
|
3510
|
+
o[18] = x6 >>> 16 & 255;
|
|
3511
|
+
o[19] = x6 >>> 24 & 255;
|
|
3512
|
+
o[20] = x7 >>> 0 & 255;
|
|
3513
|
+
o[21] = x7 >>> 8 & 255;
|
|
3514
|
+
o[22] = x7 >>> 16 & 255;
|
|
3515
|
+
o[23] = x7 >>> 24 & 255;
|
|
3516
|
+
o[24] = x8 >>> 0 & 255;
|
|
3517
|
+
o[25] = x8 >>> 8 & 255;
|
|
3518
|
+
o[26] = x8 >>> 16 & 255;
|
|
3519
|
+
o[27] = x8 >>> 24 & 255;
|
|
3520
|
+
o[28] = x9 >>> 0 & 255;
|
|
3521
|
+
o[29] = x9 >>> 8 & 255;
|
|
3522
|
+
o[30] = x9 >>> 16 & 255;
|
|
3523
|
+
o[31] = x9 >>> 24 & 255;
|
|
3524
|
+
}
|
|
3525
|
+
function crypto_core_salsa20(out, inp, k2, c) {
|
|
3526
|
+
core_salsa20(out, inp, k2, c);
|
|
3527
|
+
}
|
|
3528
|
+
function crypto_core_hsalsa20(out, inp, k2, c) {
|
|
3529
|
+
core_hsalsa20(out, inp, k2, c);
|
|
3530
|
+
}
|
|
3531
|
+
var sigma = new Uint8Array([101, 120, 112, 97, 110, 100, 32, 51, 50, 45, 98, 121, 116, 101, 32, 107]);
|
|
3532
|
+
function crypto_stream_salsa20_xor(c, cpos, m3, mpos, b3, n, k2) {
|
|
3533
|
+
var z3 = new Uint8Array(16), x2 = new Uint8Array(64);
|
|
3534
|
+
var u2, i;
|
|
3535
|
+
for (i = 0; i < 16; i++) z3[i] = 0;
|
|
3536
|
+
for (i = 0; i < 8; i++) z3[i] = n[i];
|
|
3537
|
+
while (b3 >= 64) {
|
|
3538
|
+
crypto_core_salsa20(x2, z3, k2, sigma);
|
|
3539
|
+
for (i = 0; i < 64; i++) c[cpos + i] = m3[mpos + i] ^ x2[i];
|
|
3540
|
+
u2 = 1;
|
|
3541
|
+
for (i = 8; i < 16; i++) {
|
|
3542
|
+
u2 = u2 + (z3[i] & 255) | 0;
|
|
3543
|
+
z3[i] = u2 & 255;
|
|
3544
|
+
u2 >>>= 8;
|
|
3545
|
+
}
|
|
3546
|
+
b3 -= 64;
|
|
3547
|
+
cpos += 64;
|
|
3548
|
+
mpos += 64;
|
|
3549
|
+
}
|
|
3550
|
+
if (b3 > 0) {
|
|
3551
|
+
crypto_core_salsa20(x2, z3, k2, sigma);
|
|
3552
|
+
for (i = 0; i < b3; i++) c[cpos + i] = m3[mpos + i] ^ x2[i];
|
|
3553
|
+
}
|
|
3554
|
+
return 0;
|
|
3555
|
+
}
|
|
3556
|
+
function crypto_stream_salsa20(c, cpos, b3, n, k2) {
|
|
3557
|
+
var z3 = new Uint8Array(16), x2 = new Uint8Array(64);
|
|
3558
|
+
var u2, i;
|
|
3559
|
+
for (i = 0; i < 16; i++) z3[i] = 0;
|
|
3560
|
+
for (i = 0; i < 8; i++) z3[i] = n[i];
|
|
3561
|
+
while (b3 >= 64) {
|
|
3562
|
+
crypto_core_salsa20(x2, z3, k2, sigma);
|
|
3563
|
+
for (i = 0; i < 64; i++) c[cpos + i] = x2[i];
|
|
3564
|
+
u2 = 1;
|
|
3565
|
+
for (i = 8; i < 16; i++) {
|
|
3566
|
+
u2 = u2 + (z3[i] & 255) | 0;
|
|
3567
|
+
z3[i] = u2 & 255;
|
|
3568
|
+
u2 >>>= 8;
|
|
3569
|
+
}
|
|
3570
|
+
b3 -= 64;
|
|
3571
|
+
cpos += 64;
|
|
3572
|
+
}
|
|
3573
|
+
if (b3 > 0) {
|
|
3574
|
+
crypto_core_salsa20(x2, z3, k2, sigma);
|
|
3575
|
+
for (i = 0; i < b3; i++) c[cpos + i] = x2[i];
|
|
3576
|
+
}
|
|
3577
|
+
return 0;
|
|
3578
|
+
}
|
|
3579
|
+
function crypto_stream(c, cpos, d, n, k2) {
|
|
3580
|
+
var s = new Uint8Array(32);
|
|
3581
|
+
crypto_core_hsalsa20(s, n, k2, sigma);
|
|
3582
|
+
var sn2 = new Uint8Array(8);
|
|
3583
|
+
for (var i = 0; i < 8; i++) sn2[i] = n[i + 16];
|
|
3584
|
+
return crypto_stream_salsa20(c, cpos, d, sn2, s);
|
|
3585
|
+
}
|
|
3586
|
+
function crypto_stream_xor(c, cpos, m3, mpos, d, n, k2) {
|
|
3587
|
+
var s = new Uint8Array(32);
|
|
3588
|
+
crypto_core_hsalsa20(s, n, k2, sigma);
|
|
3589
|
+
var sn2 = new Uint8Array(8);
|
|
3590
|
+
for (var i = 0; i < 8; i++) sn2[i] = n[i + 16];
|
|
3591
|
+
return crypto_stream_salsa20_xor(c, cpos, m3, mpos, d, sn2, s);
|
|
3592
|
+
}
|
|
3593
|
+
var poly1305 = function(key) {
|
|
3594
|
+
this.buffer = new Uint8Array(16);
|
|
3595
|
+
this.r = new Uint16Array(10);
|
|
3596
|
+
this.h = new Uint16Array(10);
|
|
3597
|
+
this.pad = new Uint16Array(8);
|
|
3598
|
+
this.leftover = 0;
|
|
3599
|
+
this.fin = 0;
|
|
3600
|
+
var t0, t1, t2, t3, t4, t5, t6, t7;
|
|
3601
|
+
t0 = key[0] & 255 | (key[1] & 255) << 8;
|
|
3602
|
+
this.r[0] = t0 & 8191;
|
|
3603
|
+
t1 = key[2] & 255 | (key[3] & 255) << 8;
|
|
3604
|
+
this.r[1] = (t0 >>> 13 | t1 << 3) & 8191;
|
|
3605
|
+
t2 = key[4] & 255 | (key[5] & 255) << 8;
|
|
3606
|
+
this.r[2] = (t1 >>> 10 | t2 << 6) & 7939;
|
|
3607
|
+
t3 = key[6] & 255 | (key[7] & 255) << 8;
|
|
3608
|
+
this.r[3] = (t2 >>> 7 | t3 << 9) & 8191;
|
|
3609
|
+
t4 = key[8] & 255 | (key[9] & 255) << 8;
|
|
3610
|
+
this.r[4] = (t3 >>> 4 | t4 << 12) & 255;
|
|
3611
|
+
this.r[5] = t4 >>> 1 & 8190;
|
|
3612
|
+
t5 = key[10] & 255 | (key[11] & 255) << 8;
|
|
3613
|
+
this.r[6] = (t4 >>> 14 | t5 << 2) & 8191;
|
|
3614
|
+
t6 = key[12] & 255 | (key[13] & 255) << 8;
|
|
3615
|
+
this.r[7] = (t5 >>> 11 | t6 << 5) & 8065;
|
|
3616
|
+
t7 = key[14] & 255 | (key[15] & 255) << 8;
|
|
3617
|
+
this.r[8] = (t6 >>> 8 | t7 << 8) & 8191;
|
|
3618
|
+
this.r[9] = t7 >>> 5 & 127;
|
|
3619
|
+
this.pad[0] = key[16] & 255 | (key[17] & 255) << 8;
|
|
3620
|
+
this.pad[1] = key[18] & 255 | (key[19] & 255) << 8;
|
|
3621
|
+
this.pad[2] = key[20] & 255 | (key[21] & 255) << 8;
|
|
3622
|
+
this.pad[3] = key[22] & 255 | (key[23] & 255) << 8;
|
|
3623
|
+
this.pad[4] = key[24] & 255 | (key[25] & 255) << 8;
|
|
3624
|
+
this.pad[5] = key[26] & 255 | (key[27] & 255) << 8;
|
|
3625
|
+
this.pad[6] = key[28] & 255 | (key[29] & 255) << 8;
|
|
3626
|
+
this.pad[7] = key[30] & 255 | (key[31] & 255) << 8;
|
|
3627
|
+
};
|
|
3628
|
+
poly1305.prototype.blocks = function(m3, mpos, bytes) {
|
|
3629
|
+
var hibit = this.fin ? 0 : 1 << 11;
|
|
3630
|
+
var t0, t1, t2, t3, t4, t5, t6, t7, c;
|
|
3631
|
+
var d0, d1, d2, d3, d4, d5, d6, d7, d8, d9;
|
|
3632
|
+
var h0 = this.h[0], h1 = this.h[1], h22 = this.h[2], h3 = this.h[3], h4 = this.h[4], h5 = this.h[5], h6 = this.h[6], h7 = this.h[7], h8 = this.h[8], h9 = this.h[9];
|
|
3633
|
+
var r0 = this.r[0], r1 = this.r[1], r22 = this.r[2], r32 = this.r[3], r42 = this.r[4], r52 = this.r[5], r62 = this.r[6], r72 = this.r[7], r82 = this.r[8], r92 = this.r[9];
|
|
3634
|
+
while (bytes >= 16) {
|
|
3635
|
+
t0 = m3[mpos + 0] & 255 | (m3[mpos + 1] & 255) << 8;
|
|
3636
|
+
h0 += t0 & 8191;
|
|
3637
|
+
t1 = m3[mpos + 2] & 255 | (m3[mpos + 3] & 255) << 8;
|
|
3638
|
+
h1 += (t0 >>> 13 | t1 << 3) & 8191;
|
|
3639
|
+
t2 = m3[mpos + 4] & 255 | (m3[mpos + 5] & 255) << 8;
|
|
3640
|
+
h22 += (t1 >>> 10 | t2 << 6) & 8191;
|
|
3641
|
+
t3 = m3[mpos + 6] & 255 | (m3[mpos + 7] & 255) << 8;
|
|
3642
|
+
h3 += (t2 >>> 7 | t3 << 9) & 8191;
|
|
3643
|
+
t4 = m3[mpos + 8] & 255 | (m3[mpos + 9] & 255) << 8;
|
|
3644
|
+
h4 += (t3 >>> 4 | t4 << 12) & 8191;
|
|
3645
|
+
h5 += t4 >>> 1 & 8191;
|
|
3646
|
+
t5 = m3[mpos + 10] & 255 | (m3[mpos + 11] & 255) << 8;
|
|
3647
|
+
h6 += (t4 >>> 14 | t5 << 2) & 8191;
|
|
3648
|
+
t6 = m3[mpos + 12] & 255 | (m3[mpos + 13] & 255) << 8;
|
|
3649
|
+
h7 += (t5 >>> 11 | t6 << 5) & 8191;
|
|
3650
|
+
t7 = m3[mpos + 14] & 255 | (m3[mpos + 15] & 255) << 8;
|
|
3651
|
+
h8 += (t6 >>> 8 | t7 << 8) & 8191;
|
|
3652
|
+
h9 += t7 >>> 5 | hibit;
|
|
3653
|
+
c = 0;
|
|
3654
|
+
d0 = c;
|
|
3655
|
+
d0 += h0 * r0;
|
|
3656
|
+
d0 += h1 * (5 * r92);
|
|
3657
|
+
d0 += h22 * (5 * r82);
|
|
3658
|
+
d0 += h3 * (5 * r72);
|
|
3659
|
+
d0 += h4 * (5 * r62);
|
|
3660
|
+
c = d0 >>> 13;
|
|
3661
|
+
d0 &= 8191;
|
|
3662
|
+
d0 += h5 * (5 * r52);
|
|
3663
|
+
d0 += h6 * (5 * r42);
|
|
3664
|
+
d0 += h7 * (5 * r32);
|
|
3665
|
+
d0 += h8 * (5 * r22);
|
|
3666
|
+
d0 += h9 * (5 * r1);
|
|
3667
|
+
c += d0 >>> 13;
|
|
3668
|
+
d0 &= 8191;
|
|
3669
|
+
d1 = c;
|
|
3670
|
+
d1 += h0 * r1;
|
|
3671
|
+
d1 += h1 * r0;
|
|
3672
|
+
d1 += h22 * (5 * r92);
|
|
3673
|
+
d1 += h3 * (5 * r82);
|
|
3674
|
+
d1 += h4 * (5 * r72);
|
|
3675
|
+
c = d1 >>> 13;
|
|
3676
|
+
d1 &= 8191;
|
|
3677
|
+
d1 += h5 * (5 * r62);
|
|
3678
|
+
d1 += h6 * (5 * r52);
|
|
3679
|
+
d1 += h7 * (5 * r42);
|
|
3680
|
+
d1 += h8 * (5 * r32);
|
|
3681
|
+
d1 += h9 * (5 * r22);
|
|
3682
|
+
c += d1 >>> 13;
|
|
3683
|
+
d1 &= 8191;
|
|
3684
|
+
d2 = c;
|
|
3685
|
+
d2 += h0 * r22;
|
|
3686
|
+
d2 += h1 * r1;
|
|
3687
|
+
d2 += h22 * r0;
|
|
3688
|
+
d2 += h3 * (5 * r92);
|
|
3689
|
+
d2 += h4 * (5 * r82);
|
|
3690
|
+
c = d2 >>> 13;
|
|
3691
|
+
d2 &= 8191;
|
|
3692
|
+
d2 += h5 * (5 * r72);
|
|
3693
|
+
d2 += h6 * (5 * r62);
|
|
3694
|
+
d2 += h7 * (5 * r52);
|
|
3695
|
+
d2 += h8 * (5 * r42);
|
|
3696
|
+
d2 += h9 * (5 * r32);
|
|
3697
|
+
c += d2 >>> 13;
|
|
3698
|
+
d2 &= 8191;
|
|
3699
|
+
d3 = c;
|
|
3700
|
+
d3 += h0 * r32;
|
|
3701
|
+
d3 += h1 * r22;
|
|
3702
|
+
d3 += h22 * r1;
|
|
3703
|
+
d3 += h3 * r0;
|
|
3704
|
+
d3 += h4 * (5 * r92);
|
|
3705
|
+
c = d3 >>> 13;
|
|
3706
|
+
d3 &= 8191;
|
|
3707
|
+
d3 += h5 * (5 * r82);
|
|
3708
|
+
d3 += h6 * (5 * r72);
|
|
3709
|
+
d3 += h7 * (5 * r62);
|
|
3710
|
+
d3 += h8 * (5 * r52);
|
|
3711
|
+
d3 += h9 * (5 * r42);
|
|
3712
|
+
c += d3 >>> 13;
|
|
3713
|
+
d3 &= 8191;
|
|
3714
|
+
d4 = c;
|
|
3715
|
+
d4 += h0 * r42;
|
|
3716
|
+
d4 += h1 * r32;
|
|
3717
|
+
d4 += h22 * r22;
|
|
3718
|
+
d4 += h3 * r1;
|
|
3719
|
+
d4 += h4 * r0;
|
|
3720
|
+
c = d4 >>> 13;
|
|
3721
|
+
d4 &= 8191;
|
|
3722
|
+
d4 += h5 * (5 * r92);
|
|
3723
|
+
d4 += h6 * (5 * r82);
|
|
3724
|
+
d4 += h7 * (5 * r72);
|
|
3725
|
+
d4 += h8 * (5 * r62);
|
|
3726
|
+
d4 += h9 * (5 * r52);
|
|
3727
|
+
c += d4 >>> 13;
|
|
3728
|
+
d4 &= 8191;
|
|
3729
|
+
d5 = c;
|
|
3730
|
+
d5 += h0 * r52;
|
|
3731
|
+
d5 += h1 * r42;
|
|
3732
|
+
d5 += h22 * r32;
|
|
3733
|
+
d5 += h3 * r22;
|
|
3734
|
+
d5 += h4 * r1;
|
|
3735
|
+
c = d5 >>> 13;
|
|
3736
|
+
d5 &= 8191;
|
|
3737
|
+
d5 += h5 * r0;
|
|
3738
|
+
d5 += h6 * (5 * r92);
|
|
3739
|
+
d5 += h7 * (5 * r82);
|
|
3740
|
+
d5 += h8 * (5 * r72);
|
|
3741
|
+
d5 += h9 * (5 * r62);
|
|
3742
|
+
c += d5 >>> 13;
|
|
3743
|
+
d5 &= 8191;
|
|
3744
|
+
d6 = c;
|
|
3745
|
+
d6 += h0 * r62;
|
|
3746
|
+
d6 += h1 * r52;
|
|
3747
|
+
d6 += h22 * r42;
|
|
3748
|
+
d6 += h3 * r32;
|
|
3749
|
+
d6 += h4 * r22;
|
|
3750
|
+
c = d6 >>> 13;
|
|
3751
|
+
d6 &= 8191;
|
|
3752
|
+
d6 += h5 * r1;
|
|
3753
|
+
d6 += h6 * r0;
|
|
3754
|
+
d6 += h7 * (5 * r92);
|
|
3755
|
+
d6 += h8 * (5 * r82);
|
|
3756
|
+
d6 += h9 * (5 * r72);
|
|
3757
|
+
c += d6 >>> 13;
|
|
3758
|
+
d6 &= 8191;
|
|
3759
|
+
d7 = c;
|
|
3760
|
+
d7 += h0 * r72;
|
|
3761
|
+
d7 += h1 * r62;
|
|
3762
|
+
d7 += h22 * r52;
|
|
3763
|
+
d7 += h3 * r42;
|
|
3764
|
+
d7 += h4 * r32;
|
|
3765
|
+
c = d7 >>> 13;
|
|
3766
|
+
d7 &= 8191;
|
|
3767
|
+
d7 += h5 * r22;
|
|
3768
|
+
d7 += h6 * r1;
|
|
3769
|
+
d7 += h7 * r0;
|
|
3770
|
+
d7 += h8 * (5 * r92);
|
|
3771
|
+
d7 += h9 * (5 * r82);
|
|
3772
|
+
c += d7 >>> 13;
|
|
3773
|
+
d7 &= 8191;
|
|
3774
|
+
d8 = c;
|
|
3775
|
+
d8 += h0 * r82;
|
|
3776
|
+
d8 += h1 * r72;
|
|
3777
|
+
d8 += h22 * r62;
|
|
3778
|
+
d8 += h3 * r52;
|
|
3779
|
+
d8 += h4 * r42;
|
|
3780
|
+
c = d8 >>> 13;
|
|
3781
|
+
d8 &= 8191;
|
|
3782
|
+
d8 += h5 * r32;
|
|
3783
|
+
d8 += h6 * r22;
|
|
3784
|
+
d8 += h7 * r1;
|
|
3785
|
+
d8 += h8 * r0;
|
|
3786
|
+
d8 += h9 * (5 * r92);
|
|
3787
|
+
c += d8 >>> 13;
|
|
3788
|
+
d8 &= 8191;
|
|
3789
|
+
d9 = c;
|
|
3790
|
+
d9 += h0 * r92;
|
|
3791
|
+
d9 += h1 * r82;
|
|
3792
|
+
d9 += h22 * r72;
|
|
3793
|
+
d9 += h3 * r62;
|
|
3794
|
+
d9 += h4 * r52;
|
|
3795
|
+
c = d9 >>> 13;
|
|
3796
|
+
d9 &= 8191;
|
|
3797
|
+
d9 += h5 * r42;
|
|
3798
|
+
d9 += h6 * r32;
|
|
3799
|
+
d9 += h7 * r22;
|
|
3800
|
+
d9 += h8 * r1;
|
|
3801
|
+
d9 += h9 * r0;
|
|
3802
|
+
c += d9 >>> 13;
|
|
3803
|
+
d9 &= 8191;
|
|
3804
|
+
c = (c << 2) + c | 0;
|
|
3805
|
+
c = c + d0 | 0;
|
|
3806
|
+
d0 = c & 8191;
|
|
3807
|
+
c = c >>> 13;
|
|
3808
|
+
d1 += c;
|
|
3809
|
+
h0 = d0;
|
|
3810
|
+
h1 = d1;
|
|
3811
|
+
h22 = d2;
|
|
3812
|
+
h3 = d3;
|
|
3813
|
+
h4 = d4;
|
|
3814
|
+
h5 = d5;
|
|
3815
|
+
h6 = d6;
|
|
3816
|
+
h7 = d7;
|
|
3817
|
+
h8 = d8;
|
|
3818
|
+
h9 = d9;
|
|
3819
|
+
mpos += 16;
|
|
3820
|
+
bytes -= 16;
|
|
3821
|
+
}
|
|
3822
|
+
this.h[0] = h0;
|
|
3823
|
+
this.h[1] = h1;
|
|
3824
|
+
this.h[2] = h22;
|
|
3825
|
+
this.h[3] = h3;
|
|
3826
|
+
this.h[4] = h4;
|
|
3827
|
+
this.h[5] = h5;
|
|
3828
|
+
this.h[6] = h6;
|
|
3829
|
+
this.h[7] = h7;
|
|
3830
|
+
this.h[8] = h8;
|
|
3831
|
+
this.h[9] = h9;
|
|
3832
|
+
};
|
|
3833
|
+
poly1305.prototype.finish = function(mac, macpos) {
|
|
3834
|
+
var g2 = new Uint16Array(10);
|
|
3835
|
+
var c, mask, f3, i;
|
|
3836
|
+
if (this.leftover) {
|
|
3837
|
+
i = this.leftover;
|
|
3838
|
+
this.buffer[i++] = 1;
|
|
3839
|
+
for (; i < 16; i++) this.buffer[i] = 0;
|
|
3840
|
+
this.fin = 1;
|
|
3841
|
+
this.blocks(this.buffer, 0, 16);
|
|
3842
|
+
}
|
|
3843
|
+
c = this.h[1] >>> 13;
|
|
3844
|
+
this.h[1] &= 8191;
|
|
3845
|
+
for (i = 2; i < 10; i++) {
|
|
3846
|
+
this.h[i] += c;
|
|
3847
|
+
c = this.h[i] >>> 13;
|
|
3848
|
+
this.h[i] &= 8191;
|
|
3849
|
+
}
|
|
3850
|
+
this.h[0] += c * 5;
|
|
3851
|
+
c = this.h[0] >>> 13;
|
|
3852
|
+
this.h[0] &= 8191;
|
|
3853
|
+
this.h[1] += c;
|
|
3854
|
+
c = this.h[1] >>> 13;
|
|
3855
|
+
this.h[1] &= 8191;
|
|
3856
|
+
this.h[2] += c;
|
|
3857
|
+
g2[0] = this.h[0] + 5;
|
|
3858
|
+
c = g2[0] >>> 13;
|
|
3859
|
+
g2[0] &= 8191;
|
|
3860
|
+
for (i = 1; i < 10; i++) {
|
|
3861
|
+
g2[i] = this.h[i] + c;
|
|
3862
|
+
c = g2[i] >>> 13;
|
|
3863
|
+
g2[i] &= 8191;
|
|
3864
|
+
}
|
|
3865
|
+
g2[9] -= 1 << 13;
|
|
3866
|
+
mask = (c ^ 1) - 1;
|
|
3867
|
+
for (i = 0; i < 10; i++) g2[i] &= mask;
|
|
3868
|
+
mask = ~mask;
|
|
3869
|
+
for (i = 0; i < 10; i++) this.h[i] = this.h[i] & mask | g2[i];
|
|
3870
|
+
this.h[0] = (this.h[0] | this.h[1] << 13) & 65535;
|
|
3871
|
+
this.h[1] = (this.h[1] >>> 3 | this.h[2] << 10) & 65535;
|
|
3872
|
+
this.h[2] = (this.h[2] >>> 6 | this.h[3] << 7) & 65535;
|
|
3873
|
+
this.h[3] = (this.h[3] >>> 9 | this.h[4] << 4) & 65535;
|
|
3874
|
+
this.h[4] = (this.h[4] >>> 12 | this.h[5] << 1 | this.h[6] << 14) & 65535;
|
|
3875
|
+
this.h[5] = (this.h[6] >>> 2 | this.h[7] << 11) & 65535;
|
|
3876
|
+
this.h[6] = (this.h[7] >>> 5 | this.h[8] << 8) & 65535;
|
|
3877
|
+
this.h[7] = (this.h[8] >>> 8 | this.h[9] << 5) & 65535;
|
|
3878
|
+
f3 = this.h[0] + this.pad[0];
|
|
3879
|
+
this.h[0] = f3 & 65535;
|
|
3880
|
+
for (i = 1; i < 8; i++) {
|
|
3881
|
+
f3 = (this.h[i] + this.pad[i] | 0) + (f3 >>> 16) | 0;
|
|
3882
|
+
this.h[i] = f3 & 65535;
|
|
3883
|
+
}
|
|
3884
|
+
mac[macpos + 0] = this.h[0] >>> 0 & 255;
|
|
3885
|
+
mac[macpos + 1] = this.h[0] >>> 8 & 255;
|
|
3886
|
+
mac[macpos + 2] = this.h[1] >>> 0 & 255;
|
|
3887
|
+
mac[macpos + 3] = this.h[1] >>> 8 & 255;
|
|
3888
|
+
mac[macpos + 4] = this.h[2] >>> 0 & 255;
|
|
3889
|
+
mac[macpos + 5] = this.h[2] >>> 8 & 255;
|
|
3890
|
+
mac[macpos + 6] = this.h[3] >>> 0 & 255;
|
|
3891
|
+
mac[macpos + 7] = this.h[3] >>> 8 & 255;
|
|
3892
|
+
mac[macpos + 8] = this.h[4] >>> 0 & 255;
|
|
3893
|
+
mac[macpos + 9] = this.h[4] >>> 8 & 255;
|
|
3894
|
+
mac[macpos + 10] = this.h[5] >>> 0 & 255;
|
|
3895
|
+
mac[macpos + 11] = this.h[5] >>> 8 & 255;
|
|
3896
|
+
mac[macpos + 12] = this.h[6] >>> 0 & 255;
|
|
3897
|
+
mac[macpos + 13] = this.h[6] >>> 8 & 255;
|
|
3898
|
+
mac[macpos + 14] = this.h[7] >>> 0 & 255;
|
|
3899
|
+
mac[macpos + 15] = this.h[7] >>> 8 & 255;
|
|
3900
|
+
};
|
|
3901
|
+
poly1305.prototype.update = function(m3, mpos, bytes) {
|
|
3902
|
+
var i, want;
|
|
3903
|
+
if (this.leftover) {
|
|
3904
|
+
want = 16 - this.leftover;
|
|
3905
|
+
if (want > bytes)
|
|
3906
|
+
want = bytes;
|
|
3907
|
+
for (i = 0; i < want; i++)
|
|
3908
|
+
this.buffer[this.leftover + i] = m3[mpos + i];
|
|
3909
|
+
bytes -= want;
|
|
3910
|
+
mpos += want;
|
|
3911
|
+
this.leftover += want;
|
|
3912
|
+
if (this.leftover < 16)
|
|
3913
|
+
return;
|
|
3914
|
+
this.blocks(this.buffer, 0, 16);
|
|
3915
|
+
this.leftover = 0;
|
|
3916
|
+
}
|
|
3917
|
+
if (bytes >= 16) {
|
|
3918
|
+
want = bytes - bytes % 16;
|
|
3919
|
+
this.blocks(m3, mpos, want);
|
|
3920
|
+
mpos += want;
|
|
3921
|
+
bytes -= want;
|
|
3922
|
+
}
|
|
3923
|
+
if (bytes) {
|
|
3924
|
+
for (i = 0; i < bytes; i++)
|
|
3925
|
+
this.buffer[this.leftover + i] = m3[mpos + i];
|
|
3926
|
+
this.leftover += bytes;
|
|
3927
|
+
}
|
|
3928
|
+
};
|
|
3929
|
+
function crypto_onetimeauth(out, outpos, m3, mpos, n, k2) {
|
|
3930
|
+
var s = new poly1305(k2);
|
|
3931
|
+
s.update(m3, mpos, n);
|
|
3932
|
+
s.finish(out, outpos);
|
|
3933
|
+
return 0;
|
|
3934
|
+
}
|
|
3935
|
+
function crypto_onetimeauth_verify(h3, hpos, m3, mpos, n, k2) {
|
|
3936
|
+
var x2 = new Uint8Array(16);
|
|
3937
|
+
crypto_onetimeauth(x2, 0, m3, mpos, n, k2);
|
|
3938
|
+
return crypto_verify_16(h3, hpos, x2, 0);
|
|
3939
|
+
}
|
|
3940
|
+
function crypto_secretbox(c, m3, d, n, k2) {
|
|
3941
|
+
var i;
|
|
3942
|
+
if (d < 32) return -1;
|
|
3943
|
+
crypto_stream_xor(c, 0, m3, 0, d, n, k2);
|
|
3944
|
+
crypto_onetimeauth(c, 16, c, 32, d - 32, c);
|
|
3945
|
+
for (i = 0; i < 16; i++) c[i] = 0;
|
|
3946
|
+
return 0;
|
|
3947
|
+
}
|
|
3948
|
+
function crypto_secretbox_open(m3, c, d, n, k2) {
|
|
3949
|
+
var i;
|
|
3950
|
+
var x2 = new Uint8Array(32);
|
|
3951
|
+
if (d < 32) return -1;
|
|
3952
|
+
crypto_stream(x2, 0, 32, n, k2);
|
|
3953
|
+
if (crypto_onetimeauth_verify(c, 16, c, 32, d - 32, x2) !== 0) return -1;
|
|
3954
|
+
crypto_stream_xor(m3, 0, c, 0, d, n, k2);
|
|
3955
|
+
for (i = 0; i < 32; i++) m3[i] = 0;
|
|
3956
|
+
return 0;
|
|
3957
|
+
}
|
|
3958
|
+
function set25519(r10, a) {
|
|
3959
|
+
var i;
|
|
3960
|
+
for (i = 0; i < 16; i++) r10[i] = a[i] | 0;
|
|
3961
|
+
}
|
|
3962
|
+
function car25519(o) {
|
|
3963
|
+
var i, v2, c = 1;
|
|
3964
|
+
for (i = 0; i < 16; i++) {
|
|
3965
|
+
v2 = o[i] + c + 65535;
|
|
3966
|
+
c = Math.floor(v2 / 65536);
|
|
3967
|
+
o[i] = v2 - c * 65536;
|
|
3968
|
+
}
|
|
3969
|
+
o[0] += c - 1 + 37 * (c - 1);
|
|
3970
|
+
}
|
|
3971
|
+
function sel25519(p2, q2, b3) {
|
|
3972
|
+
var t, c = ~(b3 - 1);
|
|
3973
|
+
for (var i = 0; i < 16; i++) {
|
|
3974
|
+
t = c & (p2[i] ^ q2[i]);
|
|
3975
|
+
p2[i] ^= t;
|
|
3976
|
+
q2[i] ^= t;
|
|
3977
|
+
}
|
|
3978
|
+
}
|
|
3979
|
+
function pack25519(o, n) {
|
|
3980
|
+
var i, j2, b3;
|
|
3981
|
+
var m3 = gf(), t = gf();
|
|
3982
|
+
for (i = 0; i < 16; i++) t[i] = n[i];
|
|
3983
|
+
car25519(t);
|
|
3984
|
+
car25519(t);
|
|
3985
|
+
car25519(t);
|
|
3986
|
+
for (j2 = 0; j2 < 2; j2++) {
|
|
3987
|
+
m3[0] = t[0] - 65517;
|
|
3988
|
+
for (i = 1; i < 15; i++) {
|
|
3989
|
+
m3[i] = t[i] - 65535 - (m3[i - 1] >> 16 & 1);
|
|
3990
|
+
m3[i - 1] &= 65535;
|
|
3991
|
+
}
|
|
3992
|
+
m3[15] = t[15] - 32767 - (m3[14] >> 16 & 1);
|
|
3993
|
+
b3 = m3[15] >> 16 & 1;
|
|
3994
|
+
m3[14] &= 65535;
|
|
3995
|
+
sel25519(t, m3, 1 - b3);
|
|
3996
|
+
}
|
|
3997
|
+
for (i = 0; i < 16; i++) {
|
|
3998
|
+
o[2 * i] = t[i] & 255;
|
|
3999
|
+
o[2 * i + 1] = t[i] >> 8;
|
|
4000
|
+
}
|
|
4001
|
+
}
|
|
4002
|
+
function neq25519(a, b3) {
|
|
4003
|
+
var c = new Uint8Array(32), d = new Uint8Array(32);
|
|
4004
|
+
pack25519(c, a);
|
|
4005
|
+
pack25519(d, b3);
|
|
4006
|
+
return crypto_verify_32(c, 0, d, 0);
|
|
4007
|
+
}
|
|
4008
|
+
function par25519(a) {
|
|
4009
|
+
var d = new Uint8Array(32);
|
|
4010
|
+
pack25519(d, a);
|
|
4011
|
+
return d[0] & 1;
|
|
4012
|
+
}
|
|
4013
|
+
function unpack25519(o, n) {
|
|
4014
|
+
var i;
|
|
4015
|
+
for (i = 0; i < 16; i++) o[i] = n[2 * i] + (n[2 * i + 1] << 8);
|
|
4016
|
+
o[15] &= 32767;
|
|
4017
|
+
}
|
|
4018
|
+
function A3(o, a, b3) {
|
|
4019
|
+
for (var i = 0; i < 16; i++) o[i] = a[i] + b3[i];
|
|
4020
|
+
}
|
|
4021
|
+
function Z3(o, a, b3) {
|
|
4022
|
+
for (var i = 0; i < 16; i++) o[i] = a[i] - b3[i];
|
|
4023
|
+
}
|
|
4024
|
+
function M2(o, a, b3) {
|
|
4025
|
+
var v2, c, t0 = 0, t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, t10 = 0, t11 = 0, t12 = 0, t13 = 0, t14 = 0, t15 = 0, t16 = 0, t17 = 0, t18 = 0, t19 = 0, t20 = 0, t21 = 0, t22 = 0, t23 = 0, t24 = 0, t25 = 0, t26 = 0, t27 = 0, t28 = 0, t29 = 0, t30 = 0, b0 = b3[0], b1 = b3[1], b22 = b3[2], b32 = b3[3], b4 = b3[4], b5 = b3[5], b6 = b3[6], b7 = b3[7], b8 = b3[8], b9 = b3[9], b10 = b3[10], b11 = b3[11], b12 = b3[12], b13 = b3[13], b14 = b3[14], b15 = b3[15];
|
|
4026
|
+
v2 = a[0];
|
|
4027
|
+
t0 += v2 * b0;
|
|
4028
|
+
t1 += v2 * b1;
|
|
4029
|
+
t2 += v2 * b22;
|
|
4030
|
+
t3 += v2 * b32;
|
|
4031
|
+
t4 += v2 * b4;
|
|
4032
|
+
t5 += v2 * b5;
|
|
4033
|
+
t6 += v2 * b6;
|
|
4034
|
+
t7 += v2 * b7;
|
|
4035
|
+
t8 += v2 * b8;
|
|
4036
|
+
t9 += v2 * b9;
|
|
4037
|
+
t10 += v2 * b10;
|
|
4038
|
+
t11 += v2 * b11;
|
|
4039
|
+
t12 += v2 * b12;
|
|
4040
|
+
t13 += v2 * b13;
|
|
4041
|
+
t14 += v2 * b14;
|
|
4042
|
+
t15 += v2 * b15;
|
|
4043
|
+
v2 = a[1];
|
|
4044
|
+
t1 += v2 * b0;
|
|
4045
|
+
t2 += v2 * b1;
|
|
4046
|
+
t3 += v2 * b22;
|
|
4047
|
+
t4 += v2 * b32;
|
|
4048
|
+
t5 += v2 * b4;
|
|
4049
|
+
t6 += v2 * b5;
|
|
4050
|
+
t7 += v2 * b6;
|
|
4051
|
+
t8 += v2 * b7;
|
|
4052
|
+
t9 += v2 * b8;
|
|
4053
|
+
t10 += v2 * b9;
|
|
4054
|
+
t11 += v2 * b10;
|
|
4055
|
+
t12 += v2 * b11;
|
|
4056
|
+
t13 += v2 * b12;
|
|
4057
|
+
t14 += v2 * b13;
|
|
4058
|
+
t15 += v2 * b14;
|
|
4059
|
+
t16 += v2 * b15;
|
|
4060
|
+
v2 = a[2];
|
|
4061
|
+
t2 += v2 * b0;
|
|
4062
|
+
t3 += v2 * b1;
|
|
4063
|
+
t4 += v2 * b22;
|
|
4064
|
+
t5 += v2 * b32;
|
|
4065
|
+
t6 += v2 * b4;
|
|
4066
|
+
t7 += v2 * b5;
|
|
4067
|
+
t8 += v2 * b6;
|
|
4068
|
+
t9 += v2 * b7;
|
|
4069
|
+
t10 += v2 * b8;
|
|
4070
|
+
t11 += v2 * b9;
|
|
4071
|
+
t12 += v2 * b10;
|
|
4072
|
+
t13 += v2 * b11;
|
|
4073
|
+
t14 += v2 * b12;
|
|
4074
|
+
t15 += v2 * b13;
|
|
4075
|
+
t16 += v2 * b14;
|
|
4076
|
+
t17 += v2 * b15;
|
|
4077
|
+
v2 = a[3];
|
|
4078
|
+
t3 += v2 * b0;
|
|
4079
|
+
t4 += v2 * b1;
|
|
4080
|
+
t5 += v2 * b22;
|
|
4081
|
+
t6 += v2 * b32;
|
|
4082
|
+
t7 += v2 * b4;
|
|
4083
|
+
t8 += v2 * b5;
|
|
4084
|
+
t9 += v2 * b6;
|
|
4085
|
+
t10 += v2 * b7;
|
|
4086
|
+
t11 += v2 * b8;
|
|
4087
|
+
t12 += v2 * b9;
|
|
4088
|
+
t13 += v2 * b10;
|
|
4089
|
+
t14 += v2 * b11;
|
|
4090
|
+
t15 += v2 * b12;
|
|
4091
|
+
t16 += v2 * b13;
|
|
4092
|
+
t17 += v2 * b14;
|
|
4093
|
+
t18 += v2 * b15;
|
|
4094
|
+
v2 = a[4];
|
|
4095
|
+
t4 += v2 * b0;
|
|
4096
|
+
t5 += v2 * b1;
|
|
4097
|
+
t6 += v2 * b22;
|
|
4098
|
+
t7 += v2 * b32;
|
|
4099
|
+
t8 += v2 * b4;
|
|
4100
|
+
t9 += v2 * b5;
|
|
4101
|
+
t10 += v2 * b6;
|
|
4102
|
+
t11 += v2 * b7;
|
|
4103
|
+
t12 += v2 * b8;
|
|
4104
|
+
t13 += v2 * b9;
|
|
4105
|
+
t14 += v2 * b10;
|
|
4106
|
+
t15 += v2 * b11;
|
|
4107
|
+
t16 += v2 * b12;
|
|
4108
|
+
t17 += v2 * b13;
|
|
4109
|
+
t18 += v2 * b14;
|
|
4110
|
+
t19 += v2 * b15;
|
|
4111
|
+
v2 = a[5];
|
|
4112
|
+
t5 += v2 * b0;
|
|
4113
|
+
t6 += v2 * b1;
|
|
4114
|
+
t7 += v2 * b22;
|
|
4115
|
+
t8 += v2 * b32;
|
|
4116
|
+
t9 += v2 * b4;
|
|
4117
|
+
t10 += v2 * b5;
|
|
4118
|
+
t11 += v2 * b6;
|
|
4119
|
+
t12 += v2 * b7;
|
|
4120
|
+
t13 += v2 * b8;
|
|
4121
|
+
t14 += v2 * b9;
|
|
4122
|
+
t15 += v2 * b10;
|
|
4123
|
+
t16 += v2 * b11;
|
|
4124
|
+
t17 += v2 * b12;
|
|
4125
|
+
t18 += v2 * b13;
|
|
4126
|
+
t19 += v2 * b14;
|
|
4127
|
+
t20 += v2 * b15;
|
|
4128
|
+
v2 = a[6];
|
|
4129
|
+
t6 += v2 * b0;
|
|
4130
|
+
t7 += v2 * b1;
|
|
4131
|
+
t8 += v2 * b22;
|
|
4132
|
+
t9 += v2 * b32;
|
|
4133
|
+
t10 += v2 * b4;
|
|
4134
|
+
t11 += v2 * b5;
|
|
4135
|
+
t12 += v2 * b6;
|
|
4136
|
+
t13 += v2 * b7;
|
|
4137
|
+
t14 += v2 * b8;
|
|
4138
|
+
t15 += v2 * b9;
|
|
4139
|
+
t16 += v2 * b10;
|
|
4140
|
+
t17 += v2 * b11;
|
|
4141
|
+
t18 += v2 * b12;
|
|
4142
|
+
t19 += v2 * b13;
|
|
4143
|
+
t20 += v2 * b14;
|
|
4144
|
+
t21 += v2 * b15;
|
|
4145
|
+
v2 = a[7];
|
|
4146
|
+
t7 += v2 * b0;
|
|
4147
|
+
t8 += v2 * b1;
|
|
4148
|
+
t9 += v2 * b22;
|
|
4149
|
+
t10 += v2 * b32;
|
|
4150
|
+
t11 += v2 * b4;
|
|
4151
|
+
t12 += v2 * b5;
|
|
4152
|
+
t13 += v2 * b6;
|
|
4153
|
+
t14 += v2 * b7;
|
|
4154
|
+
t15 += v2 * b8;
|
|
4155
|
+
t16 += v2 * b9;
|
|
4156
|
+
t17 += v2 * b10;
|
|
4157
|
+
t18 += v2 * b11;
|
|
4158
|
+
t19 += v2 * b12;
|
|
4159
|
+
t20 += v2 * b13;
|
|
4160
|
+
t21 += v2 * b14;
|
|
4161
|
+
t22 += v2 * b15;
|
|
4162
|
+
v2 = a[8];
|
|
4163
|
+
t8 += v2 * b0;
|
|
4164
|
+
t9 += v2 * b1;
|
|
4165
|
+
t10 += v2 * b22;
|
|
4166
|
+
t11 += v2 * b32;
|
|
4167
|
+
t12 += v2 * b4;
|
|
4168
|
+
t13 += v2 * b5;
|
|
4169
|
+
t14 += v2 * b6;
|
|
4170
|
+
t15 += v2 * b7;
|
|
4171
|
+
t16 += v2 * b8;
|
|
4172
|
+
t17 += v2 * b9;
|
|
4173
|
+
t18 += v2 * b10;
|
|
4174
|
+
t19 += v2 * b11;
|
|
4175
|
+
t20 += v2 * b12;
|
|
4176
|
+
t21 += v2 * b13;
|
|
4177
|
+
t22 += v2 * b14;
|
|
4178
|
+
t23 += v2 * b15;
|
|
4179
|
+
v2 = a[9];
|
|
4180
|
+
t9 += v2 * b0;
|
|
4181
|
+
t10 += v2 * b1;
|
|
4182
|
+
t11 += v2 * b22;
|
|
4183
|
+
t12 += v2 * b32;
|
|
4184
|
+
t13 += v2 * b4;
|
|
4185
|
+
t14 += v2 * b5;
|
|
4186
|
+
t15 += v2 * b6;
|
|
4187
|
+
t16 += v2 * b7;
|
|
4188
|
+
t17 += v2 * b8;
|
|
4189
|
+
t18 += v2 * b9;
|
|
4190
|
+
t19 += v2 * b10;
|
|
4191
|
+
t20 += v2 * b11;
|
|
4192
|
+
t21 += v2 * b12;
|
|
4193
|
+
t22 += v2 * b13;
|
|
4194
|
+
t23 += v2 * b14;
|
|
4195
|
+
t24 += v2 * b15;
|
|
4196
|
+
v2 = a[10];
|
|
4197
|
+
t10 += v2 * b0;
|
|
4198
|
+
t11 += v2 * b1;
|
|
4199
|
+
t12 += v2 * b22;
|
|
4200
|
+
t13 += v2 * b32;
|
|
4201
|
+
t14 += v2 * b4;
|
|
4202
|
+
t15 += v2 * b5;
|
|
4203
|
+
t16 += v2 * b6;
|
|
4204
|
+
t17 += v2 * b7;
|
|
4205
|
+
t18 += v2 * b8;
|
|
4206
|
+
t19 += v2 * b9;
|
|
4207
|
+
t20 += v2 * b10;
|
|
4208
|
+
t21 += v2 * b11;
|
|
4209
|
+
t22 += v2 * b12;
|
|
4210
|
+
t23 += v2 * b13;
|
|
4211
|
+
t24 += v2 * b14;
|
|
4212
|
+
t25 += v2 * b15;
|
|
4213
|
+
v2 = a[11];
|
|
4214
|
+
t11 += v2 * b0;
|
|
4215
|
+
t12 += v2 * b1;
|
|
4216
|
+
t13 += v2 * b22;
|
|
4217
|
+
t14 += v2 * b32;
|
|
4218
|
+
t15 += v2 * b4;
|
|
4219
|
+
t16 += v2 * b5;
|
|
4220
|
+
t17 += v2 * b6;
|
|
4221
|
+
t18 += v2 * b7;
|
|
4222
|
+
t19 += v2 * b8;
|
|
4223
|
+
t20 += v2 * b9;
|
|
4224
|
+
t21 += v2 * b10;
|
|
4225
|
+
t22 += v2 * b11;
|
|
4226
|
+
t23 += v2 * b12;
|
|
4227
|
+
t24 += v2 * b13;
|
|
4228
|
+
t25 += v2 * b14;
|
|
4229
|
+
t26 += v2 * b15;
|
|
4230
|
+
v2 = a[12];
|
|
4231
|
+
t12 += v2 * b0;
|
|
4232
|
+
t13 += v2 * b1;
|
|
4233
|
+
t14 += v2 * b22;
|
|
4234
|
+
t15 += v2 * b32;
|
|
4235
|
+
t16 += v2 * b4;
|
|
4236
|
+
t17 += v2 * b5;
|
|
4237
|
+
t18 += v2 * b6;
|
|
4238
|
+
t19 += v2 * b7;
|
|
4239
|
+
t20 += v2 * b8;
|
|
4240
|
+
t21 += v2 * b9;
|
|
4241
|
+
t22 += v2 * b10;
|
|
4242
|
+
t23 += v2 * b11;
|
|
4243
|
+
t24 += v2 * b12;
|
|
4244
|
+
t25 += v2 * b13;
|
|
4245
|
+
t26 += v2 * b14;
|
|
4246
|
+
t27 += v2 * b15;
|
|
4247
|
+
v2 = a[13];
|
|
4248
|
+
t13 += v2 * b0;
|
|
4249
|
+
t14 += v2 * b1;
|
|
4250
|
+
t15 += v2 * b22;
|
|
4251
|
+
t16 += v2 * b32;
|
|
4252
|
+
t17 += v2 * b4;
|
|
4253
|
+
t18 += v2 * b5;
|
|
4254
|
+
t19 += v2 * b6;
|
|
4255
|
+
t20 += v2 * b7;
|
|
4256
|
+
t21 += v2 * b8;
|
|
4257
|
+
t22 += v2 * b9;
|
|
4258
|
+
t23 += v2 * b10;
|
|
4259
|
+
t24 += v2 * b11;
|
|
4260
|
+
t25 += v2 * b12;
|
|
4261
|
+
t26 += v2 * b13;
|
|
4262
|
+
t27 += v2 * b14;
|
|
4263
|
+
t28 += v2 * b15;
|
|
4264
|
+
v2 = a[14];
|
|
4265
|
+
t14 += v2 * b0;
|
|
4266
|
+
t15 += v2 * b1;
|
|
4267
|
+
t16 += v2 * b22;
|
|
4268
|
+
t17 += v2 * b32;
|
|
4269
|
+
t18 += v2 * b4;
|
|
4270
|
+
t19 += v2 * b5;
|
|
4271
|
+
t20 += v2 * b6;
|
|
4272
|
+
t21 += v2 * b7;
|
|
4273
|
+
t22 += v2 * b8;
|
|
4274
|
+
t23 += v2 * b9;
|
|
4275
|
+
t24 += v2 * b10;
|
|
4276
|
+
t25 += v2 * b11;
|
|
4277
|
+
t26 += v2 * b12;
|
|
4278
|
+
t27 += v2 * b13;
|
|
4279
|
+
t28 += v2 * b14;
|
|
4280
|
+
t29 += v2 * b15;
|
|
4281
|
+
v2 = a[15];
|
|
4282
|
+
t15 += v2 * b0;
|
|
4283
|
+
t16 += v2 * b1;
|
|
4284
|
+
t17 += v2 * b22;
|
|
4285
|
+
t18 += v2 * b32;
|
|
4286
|
+
t19 += v2 * b4;
|
|
4287
|
+
t20 += v2 * b5;
|
|
4288
|
+
t21 += v2 * b6;
|
|
4289
|
+
t22 += v2 * b7;
|
|
4290
|
+
t23 += v2 * b8;
|
|
4291
|
+
t24 += v2 * b9;
|
|
4292
|
+
t25 += v2 * b10;
|
|
4293
|
+
t26 += v2 * b11;
|
|
4294
|
+
t27 += v2 * b12;
|
|
4295
|
+
t28 += v2 * b13;
|
|
4296
|
+
t29 += v2 * b14;
|
|
4297
|
+
t30 += v2 * b15;
|
|
4298
|
+
t0 += 38 * t16;
|
|
4299
|
+
t1 += 38 * t17;
|
|
4300
|
+
t2 += 38 * t18;
|
|
4301
|
+
t3 += 38 * t19;
|
|
4302
|
+
t4 += 38 * t20;
|
|
4303
|
+
t5 += 38 * t21;
|
|
4304
|
+
t6 += 38 * t22;
|
|
4305
|
+
t7 += 38 * t23;
|
|
4306
|
+
t8 += 38 * t24;
|
|
4307
|
+
t9 += 38 * t25;
|
|
4308
|
+
t10 += 38 * t26;
|
|
4309
|
+
t11 += 38 * t27;
|
|
4310
|
+
t12 += 38 * t28;
|
|
4311
|
+
t13 += 38 * t29;
|
|
4312
|
+
t14 += 38 * t30;
|
|
4313
|
+
c = 1;
|
|
4314
|
+
v2 = t0 + c + 65535;
|
|
4315
|
+
c = Math.floor(v2 / 65536);
|
|
4316
|
+
t0 = v2 - c * 65536;
|
|
4317
|
+
v2 = t1 + c + 65535;
|
|
4318
|
+
c = Math.floor(v2 / 65536);
|
|
4319
|
+
t1 = v2 - c * 65536;
|
|
4320
|
+
v2 = t2 + c + 65535;
|
|
4321
|
+
c = Math.floor(v2 / 65536);
|
|
4322
|
+
t2 = v2 - c * 65536;
|
|
4323
|
+
v2 = t3 + c + 65535;
|
|
4324
|
+
c = Math.floor(v2 / 65536);
|
|
4325
|
+
t3 = v2 - c * 65536;
|
|
4326
|
+
v2 = t4 + c + 65535;
|
|
4327
|
+
c = Math.floor(v2 / 65536);
|
|
4328
|
+
t4 = v2 - c * 65536;
|
|
4329
|
+
v2 = t5 + c + 65535;
|
|
4330
|
+
c = Math.floor(v2 / 65536);
|
|
4331
|
+
t5 = v2 - c * 65536;
|
|
4332
|
+
v2 = t6 + c + 65535;
|
|
4333
|
+
c = Math.floor(v2 / 65536);
|
|
4334
|
+
t6 = v2 - c * 65536;
|
|
4335
|
+
v2 = t7 + c + 65535;
|
|
4336
|
+
c = Math.floor(v2 / 65536);
|
|
4337
|
+
t7 = v2 - c * 65536;
|
|
4338
|
+
v2 = t8 + c + 65535;
|
|
4339
|
+
c = Math.floor(v2 / 65536);
|
|
4340
|
+
t8 = v2 - c * 65536;
|
|
4341
|
+
v2 = t9 + c + 65535;
|
|
4342
|
+
c = Math.floor(v2 / 65536);
|
|
4343
|
+
t9 = v2 - c * 65536;
|
|
4344
|
+
v2 = t10 + c + 65535;
|
|
4345
|
+
c = Math.floor(v2 / 65536);
|
|
4346
|
+
t10 = v2 - c * 65536;
|
|
4347
|
+
v2 = t11 + c + 65535;
|
|
4348
|
+
c = Math.floor(v2 / 65536);
|
|
4349
|
+
t11 = v2 - c * 65536;
|
|
4350
|
+
v2 = t12 + c + 65535;
|
|
4351
|
+
c = Math.floor(v2 / 65536);
|
|
4352
|
+
t12 = v2 - c * 65536;
|
|
4353
|
+
v2 = t13 + c + 65535;
|
|
4354
|
+
c = Math.floor(v2 / 65536);
|
|
4355
|
+
t13 = v2 - c * 65536;
|
|
4356
|
+
v2 = t14 + c + 65535;
|
|
4357
|
+
c = Math.floor(v2 / 65536);
|
|
4358
|
+
t14 = v2 - c * 65536;
|
|
4359
|
+
v2 = t15 + c + 65535;
|
|
4360
|
+
c = Math.floor(v2 / 65536);
|
|
4361
|
+
t15 = v2 - c * 65536;
|
|
4362
|
+
t0 += c - 1 + 37 * (c - 1);
|
|
4363
|
+
c = 1;
|
|
4364
|
+
v2 = t0 + c + 65535;
|
|
4365
|
+
c = Math.floor(v2 / 65536);
|
|
4366
|
+
t0 = v2 - c * 65536;
|
|
4367
|
+
v2 = t1 + c + 65535;
|
|
4368
|
+
c = Math.floor(v2 / 65536);
|
|
4369
|
+
t1 = v2 - c * 65536;
|
|
4370
|
+
v2 = t2 + c + 65535;
|
|
4371
|
+
c = Math.floor(v2 / 65536);
|
|
4372
|
+
t2 = v2 - c * 65536;
|
|
4373
|
+
v2 = t3 + c + 65535;
|
|
4374
|
+
c = Math.floor(v2 / 65536);
|
|
4375
|
+
t3 = v2 - c * 65536;
|
|
4376
|
+
v2 = t4 + c + 65535;
|
|
4377
|
+
c = Math.floor(v2 / 65536);
|
|
4378
|
+
t4 = v2 - c * 65536;
|
|
4379
|
+
v2 = t5 + c + 65535;
|
|
4380
|
+
c = Math.floor(v2 / 65536);
|
|
4381
|
+
t5 = v2 - c * 65536;
|
|
4382
|
+
v2 = t6 + c + 65535;
|
|
4383
|
+
c = Math.floor(v2 / 65536);
|
|
4384
|
+
t6 = v2 - c * 65536;
|
|
4385
|
+
v2 = t7 + c + 65535;
|
|
4386
|
+
c = Math.floor(v2 / 65536);
|
|
4387
|
+
t7 = v2 - c * 65536;
|
|
4388
|
+
v2 = t8 + c + 65535;
|
|
4389
|
+
c = Math.floor(v2 / 65536);
|
|
4390
|
+
t8 = v2 - c * 65536;
|
|
4391
|
+
v2 = t9 + c + 65535;
|
|
4392
|
+
c = Math.floor(v2 / 65536);
|
|
4393
|
+
t9 = v2 - c * 65536;
|
|
4394
|
+
v2 = t10 + c + 65535;
|
|
4395
|
+
c = Math.floor(v2 / 65536);
|
|
4396
|
+
t10 = v2 - c * 65536;
|
|
4397
|
+
v2 = t11 + c + 65535;
|
|
4398
|
+
c = Math.floor(v2 / 65536);
|
|
4399
|
+
t11 = v2 - c * 65536;
|
|
4400
|
+
v2 = t12 + c + 65535;
|
|
4401
|
+
c = Math.floor(v2 / 65536);
|
|
4402
|
+
t12 = v2 - c * 65536;
|
|
4403
|
+
v2 = t13 + c + 65535;
|
|
4404
|
+
c = Math.floor(v2 / 65536);
|
|
4405
|
+
t13 = v2 - c * 65536;
|
|
4406
|
+
v2 = t14 + c + 65535;
|
|
4407
|
+
c = Math.floor(v2 / 65536);
|
|
4408
|
+
t14 = v2 - c * 65536;
|
|
4409
|
+
v2 = t15 + c + 65535;
|
|
4410
|
+
c = Math.floor(v2 / 65536);
|
|
4411
|
+
t15 = v2 - c * 65536;
|
|
4412
|
+
t0 += c - 1 + 37 * (c - 1);
|
|
4413
|
+
o[0] = t0;
|
|
4414
|
+
o[1] = t1;
|
|
4415
|
+
o[2] = t2;
|
|
4416
|
+
o[3] = t3;
|
|
4417
|
+
o[4] = t4;
|
|
4418
|
+
o[5] = t5;
|
|
4419
|
+
o[6] = t6;
|
|
4420
|
+
o[7] = t7;
|
|
4421
|
+
o[8] = t8;
|
|
4422
|
+
o[9] = t9;
|
|
4423
|
+
o[10] = t10;
|
|
4424
|
+
o[11] = t11;
|
|
4425
|
+
o[12] = t12;
|
|
4426
|
+
o[13] = t13;
|
|
4427
|
+
o[14] = t14;
|
|
4428
|
+
o[15] = t15;
|
|
4429
|
+
}
|
|
4430
|
+
function S3(o, a) {
|
|
4431
|
+
M2(o, a, a);
|
|
4432
|
+
}
|
|
4433
|
+
function inv25519(o, i) {
|
|
4434
|
+
var c = gf();
|
|
4435
|
+
var a;
|
|
4436
|
+
for (a = 0; a < 16; a++) c[a] = i[a];
|
|
4437
|
+
for (a = 253; a >= 0; a--) {
|
|
4438
|
+
S3(c, c);
|
|
4439
|
+
if (a !== 2 && a !== 4) M2(c, c, i);
|
|
4440
|
+
}
|
|
4441
|
+
for (a = 0; a < 16; a++) o[a] = c[a];
|
|
4442
|
+
}
|
|
4443
|
+
function pow2523(o, i) {
|
|
4444
|
+
var c = gf();
|
|
4445
|
+
var a;
|
|
4446
|
+
for (a = 0; a < 16; a++) c[a] = i[a];
|
|
4447
|
+
for (a = 250; a >= 0; a--) {
|
|
4448
|
+
S3(c, c);
|
|
4449
|
+
if (a !== 1) M2(c, c, i);
|
|
4450
|
+
}
|
|
4451
|
+
for (a = 0; a < 16; a++) o[a] = c[a];
|
|
4452
|
+
}
|
|
4453
|
+
function crypto_scalarmult(q2, n, p2) {
|
|
4454
|
+
var z3 = new Uint8Array(32);
|
|
4455
|
+
var x2 = new Float64Array(80), r10, i;
|
|
4456
|
+
var a = gf(), b3 = gf(), c = gf(), d = gf(), e = gf(), f3 = gf();
|
|
4457
|
+
for (i = 0; i < 31; i++) z3[i] = n[i];
|
|
4458
|
+
z3[31] = n[31] & 127 | 64;
|
|
4459
|
+
z3[0] &= 248;
|
|
4460
|
+
unpack25519(x2, p2);
|
|
4461
|
+
for (i = 0; i < 16; i++) {
|
|
4462
|
+
b3[i] = x2[i];
|
|
4463
|
+
d[i] = a[i] = c[i] = 0;
|
|
4464
|
+
}
|
|
4465
|
+
a[0] = d[0] = 1;
|
|
4466
|
+
for (i = 254; i >= 0; --i) {
|
|
4467
|
+
r10 = z3[i >>> 3] >>> (i & 7) & 1;
|
|
4468
|
+
sel25519(a, b3, r10);
|
|
4469
|
+
sel25519(c, d, r10);
|
|
4470
|
+
A3(e, a, c);
|
|
4471
|
+
Z3(a, a, c);
|
|
4472
|
+
A3(c, b3, d);
|
|
4473
|
+
Z3(b3, b3, d);
|
|
4474
|
+
S3(d, e);
|
|
4475
|
+
S3(f3, a);
|
|
4476
|
+
M2(a, c, a);
|
|
4477
|
+
M2(c, b3, e);
|
|
4478
|
+
A3(e, a, c);
|
|
4479
|
+
Z3(a, a, c);
|
|
4480
|
+
S3(b3, a);
|
|
4481
|
+
Z3(c, d, f3);
|
|
4482
|
+
M2(a, c, _121665);
|
|
4483
|
+
A3(a, a, d);
|
|
4484
|
+
M2(c, c, a);
|
|
4485
|
+
M2(a, d, f3);
|
|
4486
|
+
M2(d, b3, x2);
|
|
4487
|
+
S3(b3, e);
|
|
4488
|
+
sel25519(a, b3, r10);
|
|
4489
|
+
sel25519(c, d, r10);
|
|
4490
|
+
}
|
|
4491
|
+
for (i = 0; i < 16; i++) {
|
|
4492
|
+
x2[i + 16] = a[i];
|
|
4493
|
+
x2[i + 32] = c[i];
|
|
4494
|
+
x2[i + 48] = b3[i];
|
|
4495
|
+
x2[i + 64] = d[i];
|
|
4496
|
+
}
|
|
4497
|
+
var x32 = x2.subarray(32);
|
|
4498
|
+
var x16 = x2.subarray(16);
|
|
4499
|
+
inv25519(x32, x32);
|
|
4500
|
+
M2(x16, x16, x32);
|
|
4501
|
+
pack25519(q2, x16);
|
|
4502
|
+
return 0;
|
|
4503
|
+
}
|
|
4504
|
+
function crypto_scalarmult_base(q2, n) {
|
|
4505
|
+
return crypto_scalarmult(q2, n, _9);
|
|
4506
|
+
}
|
|
4507
|
+
function crypto_box_keypair(y3, x2) {
|
|
4508
|
+
randombytes(x2, 32);
|
|
4509
|
+
return crypto_scalarmult_base(y3, x2);
|
|
4510
|
+
}
|
|
4511
|
+
function crypto_box_beforenm(k2, y3, x2) {
|
|
4512
|
+
var s = new Uint8Array(32);
|
|
4513
|
+
crypto_scalarmult(s, x2, y3);
|
|
4514
|
+
return crypto_core_hsalsa20(k2, _0, s, sigma);
|
|
4515
|
+
}
|
|
4516
|
+
var crypto_box_afternm = crypto_secretbox;
|
|
4517
|
+
var crypto_box_open_afternm = crypto_secretbox_open;
|
|
4518
|
+
function crypto_box(c, m3, d, n, y3, x2) {
|
|
4519
|
+
var k2 = new Uint8Array(32);
|
|
4520
|
+
crypto_box_beforenm(k2, y3, x2);
|
|
4521
|
+
return crypto_box_afternm(c, m3, d, n, k2);
|
|
4522
|
+
}
|
|
4523
|
+
function crypto_box_open(m3, c, d, n, y3, x2) {
|
|
4524
|
+
var k2 = new Uint8Array(32);
|
|
4525
|
+
crypto_box_beforenm(k2, y3, x2);
|
|
4526
|
+
return crypto_box_open_afternm(m3, c, d, n, k2);
|
|
4527
|
+
}
|
|
4528
|
+
var K2 = [
|
|
4529
|
+
1116352408,
|
|
4530
|
+
3609767458,
|
|
4531
|
+
1899447441,
|
|
4532
|
+
602891725,
|
|
4533
|
+
3049323471,
|
|
4534
|
+
3964484399,
|
|
4535
|
+
3921009573,
|
|
4536
|
+
2173295548,
|
|
4537
|
+
961987163,
|
|
4538
|
+
4081628472,
|
|
4539
|
+
1508970993,
|
|
4540
|
+
3053834265,
|
|
4541
|
+
2453635748,
|
|
4542
|
+
2937671579,
|
|
4543
|
+
2870763221,
|
|
4544
|
+
3664609560,
|
|
4545
|
+
3624381080,
|
|
4546
|
+
2734883394,
|
|
4547
|
+
310598401,
|
|
4548
|
+
1164996542,
|
|
4549
|
+
607225278,
|
|
4550
|
+
1323610764,
|
|
4551
|
+
1426881987,
|
|
4552
|
+
3590304994,
|
|
4553
|
+
1925078388,
|
|
4554
|
+
4068182383,
|
|
4555
|
+
2162078206,
|
|
4556
|
+
991336113,
|
|
4557
|
+
2614888103,
|
|
4558
|
+
633803317,
|
|
4559
|
+
3248222580,
|
|
4560
|
+
3479774868,
|
|
4561
|
+
3835390401,
|
|
4562
|
+
2666613458,
|
|
4563
|
+
4022224774,
|
|
4564
|
+
944711139,
|
|
4565
|
+
264347078,
|
|
4566
|
+
2341262773,
|
|
4567
|
+
604807628,
|
|
4568
|
+
2007800933,
|
|
4569
|
+
770255983,
|
|
4570
|
+
1495990901,
|
|
4571
|
+
1249150122,
|
|
4572
|
+
1856431235,
|
|
4573
|
+
1555081692,
|
|
4574
|
+
3175218132,
|
|
4575
|
+
1996064986,
|
|
4576
|
+
2198950837,
|
|
4577
|
+
2554220882,
|
|
4578
|
+
3999719339,
|
|
4579
|
+
2821834349,
|
|
4580
|
+
766784016,
|
|
4581
|
+
2952996808,
|
|
4582
|
+
2566594879,
|
|
4583
|
+
3210313671,
|
|
4584
|
+
3203337956,
|
|
4585
|
+
3336571891,
|
|
4586
|
+
1034457026,
|
|
4587
|
+
3584528711,
|
|
4588
|
+
2466948901,
|
|
4589
|
+
113926993,
|
|
4590
|
+
3758326383,
|
|
4591
|
+
338241895,
|
|
4592
|
+
168717936,
|
|
4593
|
+
666307205,
|
|
4594
|
+
1188179964,
|
|
4595
|
+
773529912,
|
|
4596
|
+
1546045734,
|
|
4597
|
+
1294757372,
|
|
4598
|
+
1522805485,
|
|
4599
|
+
1396182291,
|
|
4600
|
+
2643833823,
|
|
4601
|
+
1695183700,
|
|
4602
|
+
2343527390,
|
|
4603
|
+
1986661051,
|
|
4604
|
+
1014477480,
|
|
4605
|
+
2177026350,
|
|
4606
|
+
1206759142,
|
|
4607
|
+
2456956037,
|
|
4608
|
+
344077627,
|
|
4609
|
+
2730485921,
|
|
4610
|
+
1290863460,
|
|
4611
|
+
2820302411,
|
|
4612
|
+
3158454273,
|
|
4613
|
+
3259730800,
|
|
4614
|
+
3505952657,
|
|
4615
|
+
3345764771,
|
|
4616
|
+
106217008,
|
|
4617
|
+
3516065817,
|
|
4618
|
+
3606008344,
|
|
4619
|
+
3600352804,
|
|
4620
|
+
1432725776,
|
|
4621
|
+
4094571909,
|
|
4622
|
+
1467031594,
|
|
4623
|
+
275423344,
|
|
4624
|
+
851169720,
|
|
4625
|
+
430227734,
|
|
4626
|
+
3100823752,
|
|
4627
|
+
506948616,
|
|
4628
|
+
1363258195,
|
|
4629
|
+
659060556,
|
|
4630
|
+
3750685593,
|
|
4631
|
+
883997877,
|
|
4632
|
+
3785050280,
|
|
4633
|
+
958139571,
|
|
4634
|
+
3318307427,
|
|
4635
|
+
1322822218,
|
|
4636
|
+
3812723403,
|
|
4637
|
+
1537002063,
|
|
4638
|
+
2003034995,
|
|
4639
|
+
1747873779,
|
|
4640
|
+
3602036899,
|
|
4641
|
+
1955562222,
|
|
4642
|
+
1575990012,
|
|
4643
|
+
2024104815,
|
|
4644
|
+
1125592928,
|
|
4645
|
+
2227730452,
|
|
4646
|
+
2716904306,
|
|
4647
|
+
2361852424,
|
|
4648
|
+
442776044,
|
|
4649
|
+
2428436474,
|
|
4650
|
+
593698344,
|
|
4651
|
+
2756734187,
|
|
4652
|
+
3733110249,
|
|
4653
|
+
3204031479,
|
|
4654
|
+
2999351573,
|
|
4655
|
+
3329325298,
|
|
4656
|
+
3815920427,
|
|
4657
|
+
3391569614,
|
|
4658
|
+
3928383900,
|
|
4659
|
+
3515267271,
|
|
4660
|
+
566280711,
|
|
4661
|
+
3940187606,
|
|
4662
|
+
3454069534,
|
|
4663
|
+
4118630271,
|
|
4664
|
+
4000239992,
|
|
4665
|
+
116418474,
|
|
4666
|
+
1914138554,
|
|
4667
|
+
174292421,
|
|
4668
|
+
2731055270,
|
|
4669
|
+
289380356,
|
|
4670
|
+
3203993006,
|
|
4671
|
+
460393269,
|
|
4672
|
+
320620315,
|
|
4673
|
+
685471733,
|
|
4674
|
+
587496836,
|
|
4675
|
+
852142971,
|
|
4676
|
+
1086792851,
|
|
4677
|
+
1017036298,
|
|
4678
|
+
365543100,
|
|
4679
|
+
1126000580,
|
|
4680
|
+
2618297676,
|
|
4681
|
+
1288033470,
|
|
4682
|
+
3409855158,
|
|
4683
|
+
1501505948,
|
|
4684
|
+
4234509866,
|
|
4685
|
+
1607167915,
|
|
4686
|
+
987167468,
|
|
4687
|
+
1816402316,
|
|
4688
|
+
1246189591
|
|
4689
|
+
];
|
|
4690
|
+
function crypto_hashblocks_hl(hh, hl, m3, n) {
|
|
4691
|
+
var wh = new Int32Array(16), wl = new Int32Array(16), bh0, bh1, bh2, bh3, bh4, bh5, bh6, bh7, bl0, bl1, bl2, bl3, bl4, bl5, bl6, bl7, th, tl, i, j2, h3, l, a, b3, c, d;
|
|
4692
|
+
var ah0 = hh[0], ah1 = hh[1], ah2 = hh[2], ah3 = hh[3], ah4 = hh[4], ah5 = hh[5], ah6 = hh[6], ah7 = hh[7], al0 = hl[0], al1 = hl[1], al2 = hl[2], al3 = hl[3], al4 = hl[4], al5 = hl[5], al6 = hl[6], al7 = hl[7];
|
|
4693
|
+
var pos = 0;
|
|
4694
|
+
while (n >= 128) {
|
|
4695
|
+
for (i = 0; i < 16; i++) {
|
|
4696
|
+
j2 = 8 * i + pos;
|
|
4697
|
+
wh[i] = m3[j2 + 0] << 24 | m3[j2 + 1] << 16 | m3[j2 + 2] << 8 | m3[j2 + 3];
|
|
4698
|
+
wl[i] = m3[j2 + 4] << 24 | m3[j2 + 5] << 16 | m3[j2 + 6] << 8 | m3[j2 + 7];
|
|
4699
|
+
}
|
|
4700
|
+
for (i = 0; i < 80; i++) {
|
|
4701
|
+
bh0 = ah0;
|
|
4702
|
+
bh1 = ah1;
|
|
4703
|
+
bh2 = ah2;
|
|
4704
|
+
bh3 = ah3;
|
|
4705
|
+
bh4 = ah4;
|
|
4706
|
+
bh5 = ah5;
|
|
4707
|
+
bh6 = ah6;
|
|
4708
|
+
bh7 = ah7;
|
|
4709
|
+
bl0 = al0;
|
|
4710
|
+
bl1 = al1;
|
|
4711
|
+
bl2 = al2;
|
|
4712
|
+
bl3 = al3;
|
|
4713
|
+
bl4 = al4;
|
|
4714
|
+
bl5 = al5;
|
|
4715
|
+
bl6 = al6;
|
|
4716
|
+
bl7 = al7;
|
|
4717
|
+
h3 = ah7;
|
|
4718
|
+
l = al7;
|
|
4719
|
+
a = l & 65535;
|
|
4720
|
+
b3 = l >>> 16;
|
|
4721
|
+
c = h3 & 65535;
|
|
4722
|
+
d = h3 >>> 16;
|
|
4723
|
+
h3 = (ah4 >>> 14 | al4 << 32 - 14) ^ (ah4 >>> 18 | al4 << 32 - 18) ^ (al4 >>> 41 - 32 | ah4 << 32 - (41 - 32));
|
|
4724
|
+
l = (al4 >>> 14 | ah4 << 32 - 14) ^ (al4 >>> 18 | ah4 << 32 - 18) ^ (ah4 >>> 41 - 32 | al4 << 32 - (41 - 32));
|
|
4725
|
+
a += l & 65535;
|
|
4726
|
+
b3 += l >>> 16;
|
|
4727
|
+
c += h3 & 65535;
|
|
4728
|
+
d += h3 >>> 16;
|
|
4729
|
+
h3 = ah4 & ah5 ^ ~ah4 & ah6;
|
|
4730
|
+
l = al4 & al5 ^ ~al4 & al6;
|
|
4731
|
+
a += l & 65535;
|
|
4732
|
+
b3 += l >>> 16;
|
|
4733
|
+
c += h3 & 65535;
|
|
4734
|
+
d += h3 >>> 16;
|
|
4735
|
+
h3 = K2[i * 2];
|
|
4736
|
+
l = K2[i * 2 + 1];
|
|
4737
|
+
a += l & 65535;
|
|
4738
|
+
b3 += l >>> 16;
|
|
4739
|
+
c += h3 & 65535;
|
|
4740
|
+
d += h3 >>> 16;
|
|
4741
|
+
h3 = wh[i % 16];
|
|
4742
|
+
l = wl[i % 16];
|
|
4743
|
+
a += l & 65535;
|
|
4744
|
+
b3 += l >>> 16;
|
|
4745
|
+
c += h3 & 65535;
|
|
4746
|
+
d += h3 >>> 16;
|
|
4747
|
+
b3 += a >>> 16;
|
|
4748
|
+
c += b3 >>> 16;
|
|
4749
|
+
d += c >>> 16;
|
|
4750
|
+
th = c & 65535 | d << 16;
|
|
4751
|
+
tl = a & 65535 | b3 << 16;
|
|
4752
|
+
h3 = th;
|
|
4753
|
+
l = tl;
|
|
4754
|
+
a = l & 65535;
|
|
4755
|
+
b3 = l >>> 16;
|
|
4756
|
+
c = h3 & 65535;
|
|
4757
|
+
d = h3 >>> 16;
|
|
4758
|
+
h3 = (ah0 >>> 28 | al0 << 32 - 28) ^ (al0 >>> 34 - 32 | ah0 << 32 - (34 - 32)) ^ (al0 >>> 39 - 32 | ah0 << 32 - (39 - 32));
|
|
4759
|
+
l = (al0 >>> 28 | ah0 << 32 - 28) ^ (ah0 >>> 34 - 32 | al0 << 32 - (34 - 32)) ^ (ah0 >>> 39 - 32 | al0 << 32 - (39 - 32));
|
|
4760
|
+
a += l & 65535;
|
|
4761
|
+
b3 += l >>> 16;
|
|
4762
|
+
c += h3 & 65535;
|
|
4763
|
+
d += h3 >>> 16;
|
|
4764
|
+
h3 = ah0 & ah1 ^ ah0 & ah2 ^ ah1 & ah2;
|
|
4765
|
+
l = al0 & al1 ^ al0 & al2 ^ al1 & al2;
|
|
4766
|
+
a += l & 65535;
|
|
4767
|
+
b3 += l >>> 16;
|
|
4768
|
+
c += h3 & 65535;
|
|
4769
|
+
d += h3 >>> 16;
|
|
4770
|
+
b3 += a >>> 16;
|
|
4771
|
+
c += b3 >>> 16;
|
|
4772
|
+
d += c >>> 16;
|
|
4773
|
+
bh7 = c & 65535 | d << 16;
|
|
4774
|
+
bl7 = a & 65535 | b3 << 16;
|
|
4775
|
+
h3 = bh3;
|
|
4776
|
+
l = bl3;
|
|
4777
|
+
a = l & 65535;
|
|
4778
|
+
b3 = l >>> 16;
|
|
4779
|
+
c = h3 & 65535;
|
|
4780
|
+
d = h3 >>> 16;
|
|
4781
|
+
h3 = th;
|
|
4782
|
+
l = tl;
|
|
4783
|
+
a += l & 65535;
|
|
4784
|
+
b3 += l >>> 16;
|
|
4785
|
+
c += h3 & 65535;
|
|
4786
|
+
d += h3 >>> 16;
|
|
4787
|
+
b3 += a >>> 16;
|
|
4788
|
+
c += b3 >>> 16;
|
|
4789
|
+
d += c >>> 16;
|
|
4790
|
+
bh3 = c & 65535 | d << 16;
|
|
4791
|
+
bl3 = a & 65535 | b3 << 16;
|
|
4792
|
+
ah1 = bh0;
|
|
4793
|
+
ah2 = bh1;
|
|
4794
|
+
ah3 = bh2;
|
|
4795
|
+
ah4 = bh3;
|
|
4796
|
+
ah5 = bh4;
|
|
4797
|
+
ah6 = bh5;
|
|
4798
|
+
ah7 = bh6;
|
|
4799
|
+
ah0 = bh7;
|
|
4800
|
+
al1 = bl0;
|
|
4801
|
+
al2 = bl1;
|
|
4802
|
+
al3 = bl2;
|
|
4803
|
+
al4 = bl3;
|
|
4804
|
+
al5 = bl4;
|
|
4805
|
+
al6 = bl5;
|
|
4806
|
+
al7 = bl6;
|
|
4807
|
+
al0 = bl7;
|
|
4808
|
+
if (i % 16 === 15) {
|
|
4809
|
+
for (j2 = 0; j2 < 16; j2++) {
|
|
4810
|
+
h3 = wh[j2];
|
|
4811
|
+
l = wl[j2];
|
|
4812
|
+
a = l & 65535;
|
|
4813
|
+
b3 = l >>> 16;
|
|
4814
|
+
c = h3 & 65535;
|
|
4815
|
+
d = h3 >>> 16;
|
|
4816
|
+
h3 = wh[(j2 + 9) % 16];
|
|
4817
|
+
l = wl[(j2 + 9) % 16];
|
|
4818
|
+
a += l & 65535;
|
|
4819
|
+
b3 += l >>> 16;
|
|
4820
|
+
c += h3 & 65535;
|
|
4821
|
+
d += h3 >>> 16;
|
|
4822
|
+
th = wh[(j2 + 1) % 16];
|
|
4823
|
+
tl = wl[(j2 + 1) % 16];
|
|
4824
|
+
h3 = (th >>> 1 | tl << 32 - 1) ^ (th >>> 8 | tl << 32 - 8) ^ th >>> 7;
|
|
4825
|
+
l = (tl >>> 1 | th << 32 - 1) ^ (tl >>> 8 | th << 32 - 8) ^ (tl >>> 7 | th << 32 - 7);
|
|
4826
|
+
a += l & 65535;
|
|
4827
|
+
b3 += l >>> 16;
|
|
4828
|
+
c += h3 & 65535;
|
|
4829
|
+
d += h3 >>> 16;
|
|
4830
|
+
th = wh[(j2 + 14) % 16];
|
|
4831
|
+
tl = wl[(j2 + 14) % 16];
|
|
4832
|
+
h3 = (th >>> 19 | tl << 32 - 19) ^ (tl >>> 61 - 32 | th << 32 - (61 - 32)) ^ th >>> 6;
|
|
4833
|
+
l = (tl >>> 19 | th << 32 - 19) ^ (th >>> 61 - 32 | tl << 32 - (61 - 32)) ^ (tl >>> 6 | th << 32 - 6);
|
|
4834
|
+
a += l & 65535;
|
|
4835
|
+
b3 += l >>> 16;
|
|
4836
|
+
c += h3 & 65535;
|
|
4837
|
+
d += h3 >>> 16;
|
|
4838
|
+
b3 += a >>> 16;
|
|
4839
|
+
c += b3 >>> 16;
|
|
4840
|
+
d += c >>> 16;
|
|
4841
|
+
wh[j2] = c & 65535 | d << 16;
|
|
4842
|
+
wl[j2] = a & 65535 | b3 << 16;
|
|
4843
|
+
}
|
|
4844
|
+
}
|
|
4845
|
+
}
|
|
4846
|
+
h3 = ah0;
|
|
4847
|
+
l = al0;
|
|
4848
|
+
a = l & 65535;
|
|
4849
|
+
b3 = l >>> 16;
|
|
4850
|
+
c = h3 & 65535;
|
|
4851
|
+
d = h3 >>> 16;
|
|
4852
|
+
h3 = hh[0];
|
|
4853
|
+
l = hl[0];
|
|
4854
|
+
a += l & 65535;
|
|
4855
|
+
b3 += l >>> 16;
|
|
4856
|
+
c += h3 & 65535;
|
|
4857
|
+
d += h3 >>> 16;
|
|
4858
|
+
b3 += a >>> 16;
|
|
4859
|
+
c += b3 >>> 16;
|
|
4860
|
+
d += c >>> 16;
|
|
4861
|
+
hh[0] = ah0 = c & 65535 | d << 16;
|
|
4862
|
+
hl[0] = al0 = a & 65535 | b3 << 16;
|
|
4863
|
+
h3 = ah1;
|
|
4864
|
+
l = al1;
|
|
4865
|
+
a = l & 65535;
|
|
4866
|
+
b3 = l >>> 16;
|
|
4867
|
+
c = h3 & 65535;
|
|
4868
|
+
d = h3 >>> 16;
|
|
4869
|
+
h3 = hh[1];
|
|
4870
|
+
l = hl[1];
|
|
4871
|
+
a += l & 65535;
|
|
4872
|
+
b3 += l >>> 16;
|
|
4873
|
+
c += h3 & 65535;
|
|
4874
|
+
d += h3 >>> 16;
|
|
4875
|
+
b3 += a >>> 16;
|
|
4876
|
+
c += b3 >>> 16;
|
|
4877
|
+
d += c >>> 16;
|
|
4878
|
+
hh[1] = ah1 = c & 65535 | d << 16;
|
|
4879
|
+
hl[1] = al1 = a & 65535 | b3 << 16;
|
|
4880
|
+
h3 = ah2;
|
|
4881
|
+
l = al2;
|
|
4882
|
+
a = l & 65535;
|
|
4883
|
+
b3 = l >>> 16;
|
|
4884
|
+
c = h3 & 65535;
|
|
4885
|
+
d = h3 >>> 16;
|
|
4886
|
+
h3 = hh[2];
|
|
4887
|
+
l = hl[2];
|
|
4888
|
+
a += l & 65535;
|
|
4889
|
+
b3 += l >>> 16;
|
|
4890
|
+
c += h3 & 65535;
|
|
4891
|
+
d += h3 >>> 16;
|
|
4892
|
+
b3 += a >>> 16;
|
|
4893
|
+
c += b3 >>> 16;
|
|
4894
|
+
d += c >>> 16;
|
|
4895
|
+
hh[2] = ah2 = c & 65535 | d << 16;
|
|
4896
|
+
hl[2] = al2 = a & 65535 | b3 << 16;
|
|
4897
|
+
h3 = ah3;
|
|
4898
|
+
l = al3;
|
|
4899
|
+
a = l & 65535;
|
|
4900
|
+
b3 = l >>> 16;
|
|
4901
|
+
c = h3 & 65535;
|
|
4902
|
+
d = h3 >>> 16;
|
|
4903
|
+
h3 = hh[3];
|
|
4904
|
+
l = hl[3];
|
|
4905
|
+
a += l & 65535;
|
|
4906
|
+
b3 += l >>> 16;
|
|
4907
|
+
c += h3 & 65535;
|
|
4908
|
+
d += h3 >>> 16;
|
|
4909
|
+
b3 += a >>> 16;
|
|
4910
|
+
c += b3 >>> 16;
|
|
4911
|
+
d += c >>> 16;
|
|
4912
|
+
hh[3] = ah3 = c & 65535 | d << 16;
|
|
4913
|
+
hl[3] = al3 = a & 65535 | b3 << 16;
|
|
4914
|
+
h3 = ah4;
|
|
4915
|
+
l = al4;
|
|
4916
|
+
a = l & 65535;
|
|
4917
|
+
b3 = l >>> 16;
|
|
4918
|
+
c = h3 & 65535;
|
|
4919
|
+
d = h3 >>> 16;
|
|
4920
|
+
h3 = hh[4];
|
|
4921
|
+
l = hl[4];
|
|
4922
|
+
a += l & 65535;
|
|
4923
|
+
b3 += l >>> 16;
|
|
4924
|
+
c += h3 & 65535;
|
|
4925
|
+
d += h3 >>> 16;
|
|
4926
|
+
b3 += a >>> 16;
|
|
4927
|
+
c += b3 >>> 16;
|
|
4928
|
+
d += c >>> 16;
|
|
4929
|
+
hh[4] = ah4 = c & 65535 | d << 16;
|
|
4930
|
+
hl[4] = al4 = a & 65535 | b3 << 16;
|
|
4931
|
+
h3 = ah5;
|
|
4932
|
+
l = al5;
|
|
4933
|
+
a = l & 65535;
|
|
4934
|
+
b3 = l >>> 16;
|
|
4935
|
+
c = h3 & 65535;
|
|
4936
|
+
d = h3 >>> 16;
|
|
4937
|
+
h3 = hh[5];
|
|
4938
|
+
l = hl[5];
|
|
4939
|
+
a += l & 65535;
|
|
4940
|
+
b3 += l >>> 16;
|
|
4941
|
+
c += h3 & 65535;
|
|
4942
|
+
d += h3 >>> 16;
|
|
4943
|
+
b3 += a >>> 16;
|
|
4944
|
+
c += b3 >>> 16;
|
|
4945
|
+
d += c >>> 16;
|
|
4946
|
+
hh[5] = ah5 = c & 65535 | d << 16;
|
|
4947
|
+
hl[5] = al5 = a & 65535 | b3 << 16;
|
|
4948
|
+
h3 = ah6;
|
|
4949
|
+
l = al6;
|
|
4950
|
+
a = l & 65535;
|
|
4951
|
+
b3 = l >>> 16;
|
|
4952
|
+
c = h3 & 65535;
|
|
4953
|
+
d = h3 >>> 16;
|
|
4954
|
+
h3 = hh[6];
|
|
4955
|
+
l = hl[6];
|
|
4956
|
+
a += l & 65535;
|
|
4957
|
+
b3 += l >>> 16;
|
|
4958
|
+
c += h3 & 65535;
|
|
4959
|
+
d += h3 >>> 16;
|
|
4960
|
+
b3 += a >>> 16;
|
|
4961
|
+
c += b3 >>> 16;
|
|
4962
|
+
d += c >>> 16;
|
|
4963
|
+
hh[6] = ah6 = c & 65535 | d << 16;
|
|
4964
|
+
hl[6] = al6 = a & 65535 | b3 << 16;
|
|
4965
|
+
h3 = ah7;
|
|
4966
|
+
l = al7;
|
|
4967
|
+
a = l & 65535;
|
|
4968
|
+
b3 = l >>> 16;
|
|
4969
|
+
c = h3 & 65535;
|
|
4970
|
+
d = h3 >>> 16;
|
|
4971
|
+
h3 = hh[7];
|
|
4972
|
+
l = hl[7];
|
|
4973
|
+
a += l & 65535;
|
|
4974
|
+
b3 += l >>> 16;
|
|
4975
|
+
c += h3 & 65535;
|
|
4976
|
+
d += h3 >>> 16;
|
|
4977
|
+
b3 += a >>> 16;
|
|
4978
|
+
c += b3 >>> 16;
|
|
4979
|
+
d += c >>> 16;
|
|
4980
|
+
hh[7] = ah7 = c & 65535 | d << 16;
|
|
4981
|
+
hl[7] = al7 = a & 65535 | b3 << 16;
|
|
4982
|
+
pos += 128;
|
|
4983
|
+
n -= 128;
|
|
4984
|
+
}
|
|
4985
|
+
return n;
|
|
4986
|
+
}
|
|
4987
|
+
function crypto_hash(out, m3, n) {
|
|
4988
|
+
var hh = new Int32Array(8), hl = new Int32Array(8), x2 = new Uint8Array(256), i, b3 = n;
|
|
4989
|
+
hh[0] = 1779033703;
|
|
4990
|
+
hh[1] = 3144134277;
|
|
4991
|
+
hh[2] = 1013904242;
|
|
4992
|
+
hh[3] = 2773480762;
|
|
4993
|
+
hh[4] = 1359893119;
|
|
4994
|
+
hh[5] = 2600822924;
|
|
4995
|
+
hh[6] = 528734635;
|
|
4996
|
+
hh[7] = 1541459225;
|
|
4997
|
+
hl[0] = 4089235720;
|
|
4998
|
+
hl[1] = 2227873595;
|
|
4999
|
+
hl[2] = 4271175723;
|
|
5000
|
+
hl[3] = 1595750129;
|
|
5001
|
+
hl[4] = 2917565137;
|
|
5002
|
+
hl[5] = 725511199;
|
|
5003
|
+
hl[6] = 4215389547;
|
|
5004
|
+
hl[7] = 327033209;
|
|
5005
|
+
crypto_hashblocks_hl(hh, hl, m3, n);
|
|
5006
|
+
n %= 128;
|
|
5007
|
+
for (i = 0; i < n; i++) x2[i] = m3[b3 - n + i];
|
|
5008
|
+
x2[n] = 128;
|
|
5009
|
+
n = 256 - 128 * (n < 112 ? 1 : 0);
|
|
5010
|
+
x2[n - 9] = 0;
|
|
5011
|
+
ts64(x2, n - 8, b3 / 536870912 | 0, b3 << 3);
|
|
5012
|
+
crypto_hashblocks_hl(hh, hl, x2, n);
|
|
5013
|
+
for (i = 0; i < 8; i++) ts64(out, 8 * i, hh[i], hl[i]);
|
|
5014
|
+
return 0;
|
|
5015
|
+
}
|
|
5016
|
+
function add(p2, q2) {
|
|
5017
|
+
var a = gf(), b3 = gf(), c = gf(), d = gf(), e = gf(), f3 = gf(), g2 = gf(), h3 = gf(), t = gf();
|
|
5018
|
+
Z3(a, p2[1], p2[0]);
|
|
5019
|
+
Z3(t, q2[1], q2[0]);
|
|
5020
|
+
M2(a, a, t);
|
|
5021
|
+
A3(b3, p2[0], p2[1]);
|
|
5022
|
+
A3(t, q2[0], q2[1]);
|
|
5023
|
+
M2(b3, b3, t);
|
|
5024
|
+
M2(c, p2[3], q2[3]);
|
|
5025
|
+
M2(c, c, D22);
|
|
5026
|
+
M2(d, p2[2], q2[2]);
|
|
5027
|
+
A3(d, d, d);
|
|
5028
|
+
Z3(e, b3, a);
|
|
5029
|
+
Z3(f3, d, c);
|
|
5030
|
+
A3(g2, d, c);
|
|
5031
|
+
A3(h3, b3, a);
|
|
5032
|
+
M2(p2[0], e, f3);
|
|
5033
|
+
M2(p2[1], h3, g2);
|
|
5034
|
+
M2(p2[2], g2, f3);
|
|
5035
|
+
M2(p2[3], e, h3);
|
|
5036
|
+
}
|
|
5037
|
+
function cswap(p2, q2, b3) {
|
|
5038
|
+
var i;
|
|
5039
|
+
for (i = 0; i < 4; i++) {
|
|
5040
|
+
sel25519(p2[i], q2[i], b3);
|
|
5041
|
+
}
|
|
5042
|
+
}
|
|
5043
|
+
function pack(r10, p2) {
|
|
5044
|
+
var tx = gf(), ty = gf(), zi = gf();
|
|
5045
|
+
inv25519(zi, p2[2]);
|
|
5046
|
+
M2(tx, p2[0], zi);
|
|
5047
|
+
M2(ty, p2[1], zi);
|
|
5048
|
+
pack25519(r10, ty);
|
|
5049
|
+
r10[31] ^= par25519(tx) << 7;
|
|
5050
|
+
}
|
|
5051
|
+
function scalarmult(p2, q2, s) {
|
|
5052
|
+
var b3, i;
|
|
5053
|
+
set25519(p2[0], gf0);
|
|
5054
|
+
set25519(p2[1], gf1);
|
|
5055
|
+
set25519(p2[2], gf1);
|
|
5056
|
+
set25519(p2[3], gf0);
|
|
5057
|
+
for (i = 255; i >= 0; --i) {
|
|
5058
|
+
b3 = s[i / 8 | 0] >> (i & 7) & 1;
|
|
5059
|
+
cswap(p2, q2, b3);
|
|
5060
|
+
add(q2, p2);
|
|
5061
|
+
add(p2, p2);
|
|
5062
|
+
cswap(p2, q2, b3);
|
|
5063
|
+
}
|
|
5064
|
+
}
|
|
5065
|
+
function scalarbase(p2, s) {
|
|
5066
|
+
var q2 = [gf(), gf(), gf(), gf()];
|
|
5067
|
+
set25519(q2[0], X3);
|
|
5068
|
+
set25519(q2[1], Y3);
|
|
5069
|
+
set25519(q2[2], gf1);
|
|
5070
|
+
M2(q2[3], X3, Y3);
|
|
5071
|
+
scalarmult(p2, q2, s);
|
|
5072
|
+
}
|
|
5073
|
+
function crypto_sign_keypair(pk, sk, seeded) {
|
|
5074
|
+
var d = new Uint8Array(64);
|
|
5075
|
+
var p2 = [gf(), gf(), gf(), gf()];
|
|
5076
|
+
var i;
|
|
5077
|
+
if (!seeded) randombytes(sk, 32);
|
|
5078
|
+
crypto_hash(d, sk, 32);
|
|
5079
|
+
d[0] &= 248;
|
|
5080
|
+
d[31] &= 127;
|
|
5081
|
+
d[31] |= 64;
|
|
5082
|
+
scalarbase(p2, d);
|
|
5083
|
+
pack(pk, p2);
|
|
5084
|
+
for (i = 0; i < 32; i++) sk[i + 32] = pk[i];
|
|
5085
|
+
return 0;
|
|
5086
|
+
}
|
|
5087
|
+
var L3 = new Float64Array([237, 211, 245, 92, 26, 99, 18, 88, 214, 156, 247, 162, 222, 249, 222, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16]);
|
|
5088
|
+
function modL(r10, x2) {
|
|
5089
|
+
var carry, i, j2, k2;
|
|
5090
|
+
for (i = 63; i >= 32; --i) {
|
|
5091
|
+
carry = 0;
|
|
5092
|
+
for (j2 = i - 32, k2 = i - 12; j2 < k2; ++j2) {
|
|
5093
|
+
x2[j2] += carry - 16 * x2[i] * L3[j2 - (i - 32)];
|
|
5094
|
+
carry = Math.floor((x2[j2] + 128) / 256);
|
|
5095
|
+
x2[j2] -= carry * 256;
|
|
5096
|
+
}
|
|
5097
|
+
x2[j2] += carry;
|
|
5098
|
+
x2[i] = 0;
|
|
5099
|
+
}
|
|
5100
|
+
carry = 0;
|
|
5101
|
+
for (j2 = 0; j2 < 32; j2++) {
|
|
5102
|
+
x2[j2] += carry - (x2[31] >> 4) * L3[j2];
|
|
5103
|
+
carry = x2[j2] >> 8;
|
|
5104
|
+
x2[j2] &= 255;
|
|
5105
|
+
}
|
|
5106
|
+
for (j2 = 0; j2 < 32; j2++) x2[j2] -= carry * L3[j2];
|
|
5107
|
+
for (i = 0; i < 32; i++) {
|
|
5108
|
+
x2[i + 1] += x2[i] >> 8;
|
|
5109
|
+
r10[i] = x2[i] & 255;
|
|
5110
|
+
}
|
|
5111
|
+
}
|
|
5112
|
+
function reduce(r10) {
|
|
5113
|
+
var x2 = new Float64Array(64), i;
|
|
5114
|
+
for (i = 0; i < 64; i++) x2[i] = r10[i];
|
|
5115
|
+
for (i = 0; i < 64; i++) r10[i] = 0;
|
|
5116
|
+
modL(r10, x2);
|
|
5117
|
+
}
|
|
5118
|
+
function crypto_sign(sm, m3, n, sk) {
|
|
5119
|
+
var d = new Uint8Array(64), h3 = new Uint8Array(64), r10 = new Uint8Array(64);
|
|
5120
|
+
var i, j2, x2 = new Float64Array(64);
|
|
5121
|
+
var p2 = [gf(), gf(), gf(), gf()];
|
|
5122
|
+
crypto_hash(d, sk, 32);
|
|
5123
|
+
d[0] &= 248;
|
|
5124
|
+
d[31] &= 127;
|
|
5125
|
+
d[31] |= 64;
|
|
5126
|
+
var smlen = n + 64;
|
|
5127
|
+
for (i = 0; i < n; i++) sm[64 + i] = m3[i];
|
|
5128
|
+
for (i = 0; i < 32; i++) sm[32 + i] = d[32 + i];
|
|
5129
|
+
crypto_hash(r10, sm.subarray(32), n + 32);
|
|
5130
|
+
reduce(r10);
|
|
5131
|
+
scalarbase(p2, r10);
|
|
5132
|
+
pack(sm, p2);
|
|
5133
|
+
for (i = 32; i < 64; i++) sm[i] = sk[i];
|
|
5134
|
+
crypto_hash(h3, sm, n + 64);
|
|
5135
|
+
reduce(h3);
|
|
5136
|
+
for (i = 0; i < 64; i++) x2[i] = 0;
|
|
5137
|
+
for (i = 0; i < 32; i++) x2[i] = r10[i];
|
|
5138
|
+
for (i = 0; i < 32; i++) {
|
|
5139
|
+
for (j2 = 0; j2 < 32; j2++) {
|
|
5140
|
+
x2[i + j2] += h3[i] * d[j2];
|
|
5141
|
+
}
|
|
5142
|
+
}
|
|
5143
|
+
modL(sm.subarray(32), x2);
|
|
5144
|
+
return smlen;
|
|
5145
|
+
}
|
|
5146
|
+
function unpackneg(r10, p2) {
|
|
5147
|
+
var t = gf(), chk = gf(), num = gf(), den = gf(), den2 = gf(), den4 = gf(), den6 = gf();
|
|
5148
|
+
set25519(r10[2], gf1);
|
|
5149
|
+
unpack25519(r10[1], p2);
|
|
5150
|
+
S3(num, r10[1]);
|
|
5151
|
+
M2(den, num, D2);
|
|
5152
|
+
Z3(num, num, r10[2]);
|
|
5153
|
+
A3(den, r10[2], den);
|
|
5154
|
+
S3(den2, den);
|
|
5155
|
+
S3(den4, den2);
|
|
5156
|
+
M2(den6, den4, den2);
|
|
5157
|
+
M2(t, den6, num);
|
|
5158
|
+
M2(t, t, den);
|
|
5159
|
+
pow2523(t, t);
|
|
5160
|
+
M2(t, t, num);
|
|
5161
|
+
M2(t, t, den);
|
|
5162
|
+
M2(t, t, den);
|
|
5163
|
+
M2(r10[0], t, den);
|
|
5164
|
+
S3(chk, r10[0]);
|
|
5165
|
+
M2(chk, chk, den);
|
|
5166
|
+
if (neq25519(chk, num)) M2(r10[0], r10[0], I2);
|
|
5167
|
+
S3(chk, r10[0]);
|
|
5168
|
+
M2(chk, chk, den);
|
|
5169
|
+
if (neq25519(chk, num)) return -1;
|
|
5170
|
+
if (par25519(r10[0]) === p2[31] >> 7) Z3(r10[0], gf0, r10[0]);
|
|
5171
|
+
M2(r10[3], r10[0], r10[1]);
|
|
5172
|
+
return 0;
|
|
5173
|
+
}
|
|
5174
|
+
function crypto_sign_open(m3, sm, n, pk) {
|
|
5175
|
+
var i;
|
|
5176
|
+
var t = new Uint8Array(32), h3 = new Uint8Array(64);
|
|
5177
|
+
var p2 = [gf(), gf(), gf(), gf()], q2 = [gf(), gf(), gf(), gf()];
|
|
5178
|
+
if (n < 64) return -1;
|
|
5179
|
+
if (unpackneg(q2, pk)) return -1;
|
|
5180
|
+
for (i = 0; i < n; i++) m3[i] = sm[i];
|
|
5181
|
+
for (i = 0; i < 32; i++) m3[i + 32] = pk[i];
|
|
5182
|
+
crypto_hash(h3, m3, n);
|
|
5183
|
+
reduce(h3);
|
|
5184
|
+
scalarmult(p2, q2, h3);
|
|
5185
|
+
scalarbase(q2, sm.subarray(32));
|
|
5186
|
+
add(p2, q2);
|
|
5187
|
+
pack(t, p2);
|
|
5188
|
+
n -= 64;
|
|
5189
|
+
if (crypto_verify_32(sm, 0, t, 0)) {
|
|
5190
|
+
for (i = 0; i < n; i++) m3[i] = 0;
|
|
5191
|
+
return -1;
|
|
5192
|
+
}
|
|
5193
|
+
for (i = 0; i < n; i++) m3[i] = sm[i + 64];
|
|
5194
|
+
return n;
|
|
5195
|
+
}
|
|
5196
|
+
var crypto_secretbox_KEYBYTES = 32, crypto_secretbox_NONCEBYTES = 24, crypto_secretbox_ZEROBYTES = 32, crypto_secretbox_BOXZEROBYTES = 16, crypto_scalarmult_BYTES = 32, crypto_scalarmult_SCALARBYTES = 32, crypto_box_PUBLICKEYBYTES = 32, crypto_box_SECRETKEYBYTES = 32, crypto_box_BEFORENMBYTES = 32, crypto_box_NONCEBYTES = crypto_secretbox_NONCEBYTES, crypto_box_ZEROBYTES = crypto_secretbox_ZEROBYTES, crypto_box_BOXZEROBYTES = crypto_secretbox_BOXZEROBYTES, crypto_sign_BYTES = 64, crypto_sign_PUBLICKEYBYTES = 32, crypto_sign_SECRETKEYBYTES = 64, crypto_sign_SEEDBYTES = 32, crypto_hash_BYTES = 64;
|
|
5197
|
+
nacl.lowlevel = {
|
|
5198
|
+
crypto_core_hsalsa20,
|
|
5199
|
+
crypto_stream_xor,
|
|
5200
|
+
crypto_stream,
|
|
5201
|
+
crypto_stream_salsa20_xor,
|
|
5202
|
+
crypto_stream_salsa20,
|
|
5203
|
+
crypto_onetimeauth,
|
|
5204
|
+
crypto_onetimeauth_verify,
|
|
5205
|
+
crypto_verify_16,
|
|
5206
|
+
crypto_verify_32,
|
|
5207
|
+
crypto_secretbox,
|
|
5208
|
+
crypto_secretbox_open,
|
|
5209
|
+
crypto_scalarmult,
|
|
5210
|
+
crypto_scalarmult_base,
|
|
5211
|
+
crypto_box_beforenm,
|
|
5212
|
+
crypto_box_afternm,
|
|
5213
|
+
crypto_box,
|
|
5214
|
+
crypto_box_open,
|
|
5215
|
+
crypto_box_keypair,
|
|
5216
|
+
crypto_hash,
|
|
5217
|
+
crypto_sign,
|
|
5218
|
+
crypto_sign_keypair,
|
|
5219
|
+
crypto_sign_open,
|
|
5220
|
+
crypto_secretbox_KEYBYTES,
|
|
5221
|
+
crypto_secretbox_NONCEBYTES,
|
|
5222
|
+
crypto_secretbox_ZEROBYTES,
|
|
5223
|
+
crypto_secretbox_BOXZEROBYTES,
|
|
5224
|
+
crypto_scalarmult_BYTES,
|
|
5225
|
+
crypto_scalarmult_SCALARBYTES,
|
|
5226
|
+
crypto_box_PUBLICKEYBYTES,
|
|
5227
|
+
crypto_box_SECRETKEYBYTES,
|
|
5228
|
+
crypto_box_BEFORENMBYTES,
|
|
5229
|
+
crypto_box_NONCEBYTES,
|
|
5230
|
+
crypto_box_ZEROBYTES,
|
|
5231
|
+
crypto_box_BOXZEROBYTES,
|
|
5232
|
+
crypto_sign_BYTES,
|
|
5233
|
+
crypto_sign_PUBLICKEYBYTES,
|
|
5234
|
+
crypto_sign_SECRETKEYBYTES,
|
|
5235
|
+
crypto_sign_SEEDBYTES,
|
|
5236
|
+
crypto_hash_BYTES,
|
|
5237
|
+
gf,
|
|
5238
|
+
D: D2,
|
|
5239
|
+
L: L3,
|
|
5240
|
+
pack25519,
|
|
5241
|
+
unpack25519,
|
|
5242
|
+
M: M2,
|
|
5243
|
+
A: A3,
|
|
5244
|
+
S: S3,
|
|
5245
|
+
Z: Z3,
|
|
5246
|
+
pow2523,
|
|
5247
|
+
add,
|
|
5248
|
+
set25519,
|
|
5249
|
+
modL,
|
|
5250
|
+
scalarmult,
|
|
5251
|
+
scalarbase
|
|
5252
|
+
};
|
|
5253
|
+
function checkLengths(k2, n) {
|
|
5254
|
+
if (k2.length !== crypto_secretbox_KEYBYTES) throw new Error("bad key size");
|
|
5255
|
+
if (n.length !== crypto_secretbox_NONCEBYTES) throw new Error("bad nonce size");
|
|
5256
|
+
}
|
|
5257
|
+
function checkBoxLengths(pk, sk) {
|
|
5258
|
+
if (pk.length !== crypto_box_PUBLICKEYBYTES) throw new Error("bad public key size");
|
|
5259
|
+
if (sk.length !== crypto_box_SECRETKEYBYTES) throw new Error("bad secret key size");
|
|
5260
|
+
}
|
|
5261
|
+
function checkArrayTypes() {
|
|
5262
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
5263
|
+
if (!(arguments[i] instanceof Uint8Array))
|
|
5264
|
+
throw new TypeError("unexpected type, use Uint8Array");
|
|
5265
|
+
}
|
|
5266
|
+
}
|
|
5267
|
+
function cleanup(arr) {
|
|
5268
|
+
for (var i = 0; i < arr.length; i++) arr[i] = 0;
|
|
5269
|
+
}
|
|
5270
|
+
nacl.randomBytes = function(n) {
|
|
5271
|
+
var b3 = new Uint8Array(n);
|
|
5272
|
+
randombytes(b3, n);
|
|
5273
|
+
return b3;
|
|
5274
|
+
};
|
|
5275
|
+
nacl.secretbox = function(msg, nonce, key) {
|
|
5276
|
+
checkArrayTypes(msg, nonce, key);
|
|
5277
|
+
checkLengths(key, nonce);
|
|
5278
|
+
var m3 = new Uint8Array(crypto_secretbox_ZEROBYTES + msg.length);
|
|
5279
|
+
var c = new Uint8Array(m3.length);
|
|
5280
|
+
for (var i = 0; i < msg.length; i++) m3[i + crypto_secretbox_ZEROBYTES] = msg[i];
|
|
5281
|
+
crypto_secretbox(c, m3, m3.length, nonce, key);
|
|
5282
|
+
return c.subarray(crypto_secretbox_BOXZEROBYTES);
|
|
5283
|
+
};
|
|
5284
|
+
nacl.secretbox.open = function(box, nonce, key) {
|
|
5285
|
+
checkArrayTypes(box, nonce, key);
|
|
5286
|
+
checkLengths(key, nonce);
|
|
5287
|
+
var c = new Uint8Array(crypto_secretbox_BOXZEROBYTES + box.length);
|
|
5288
|
+
var m3 = new Uint8Array(c.length);
|
|
5289
|
+
for (var i = 0; i < box.length; i++) c[i + crypto_secretbox_BOXZEROBYTES] = box[i];
|
|
5290
|
+
if (c.length < 32) return null;
|
|
5291
|
+
if (crypto_secretbox_open(m3, c, c.length, nonce, key) !== 0) return null;
|
|
5292
|
+
return m3.subarray(crypto_secretbox_ZEROBYTES);
|
|
5293
|
+
};
|
|
5294
|
+
nacl.secretbox.keyLength = crypto_secretbox_KEYBYTES;
|
|
5295
|
+
nacl.secretbox.nonceLength = crypto_secretbox_NONCEBYTES;
|
|
5296
|
+
nacl.secretbox.overheadLength = crypto_secretbox_BOXZEROBYTES;
|
|
5297
|
+
nacl.scalarMult = function(n, p2) {
|
|
5298
|
+
checkArrayTypes(n, p2);
|
|
5299
|
+
if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error("bad n size");
|
|
5300
|
+
if (p2.length !== crypto_scalarmult_BYTES) throw new Error("bad p size");
|
|
5301
|
+
var q2 = new Uint8Array(crypto_scalarmult_BYTES);
|
|
5302
|
+
crypto_scalarmult(q2, n, p2);
|
|
5303
|
+
return q2;
|
|
5304
|
+
};
|
|
5305
|
+
nacl.scalarMult.base = function(n) {
|
|
5306
|
+
checkArrayTypes(n);
|
|
5307
|
+
if (n.length !== crypto_scalarmult_SCALARBYTES) throw new Error("bad n size");
|
|
5308
|
+
var q2 = new Uint8Array(crypto_scalarmult_BYTES);
|
|
5309
|
+
crypto_scalarmult_base(q2, n);
|
|
5310
|
+
return q2;
|
|
5311
|
+
};
|
|
5312
|
+
nacl.scalarMult.scalarLength = crypto_scalarmult_SCALARBYTES;
|
|
5313
|
+
nacl.scalarMult.groupElementLength = crypto_scalarmult_BYTES;
|
|
5314
|
+
nacl.box = function(msg, nonce, publicKey, secretKey) {
|
|
5315
|
+
var k2 = nacl.box.before(publicKey, secretKey);
|
|
5316
|
+
return nacl.secretbox(msg, nonce, k2);
|
|
5317
|
+
};
|
|
5318
|
+
nacl.box.before = function(publicKey, secretKey) {
|
|
5319
|
+
checkArrayTypes(publicKey, secretKey);
|
|
5320
|
+
checkBoxLengths(publicKey, secretKey);
|
|
5321
|
+
var k2 = new Uint8Array(crypto_box_BEFORENMBYTES);
|
|
5322
|
+
crypto_box_beforenm(k2, publicKey, secretKey);
|
|
5323
|
+
return k2;
|
|
5324
|
+
};
|
|
5325
|
+
nacl.box.after = nacl.secretbox;
|
|
5326
|
+
nacl.box.open = function(msg, nonce, publicKey, secretKey) {
|
|
5327
|
+
var k2 = nacl.box.before(publicKey, secretKey);
|
|
5328
|
+
return nacl.secretbox.open(msg, nonce, k2);
|
|
5329
|
+
};
|
|
5330
|
+
nacl.box.open.after = nacl.secretbox.open;
|
|
5331
|
+
nacl.box.keyPair = function() {
|
|
5332
|
+
var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
|
|
5333
|
+
var sk = new Uint8Array(crypto_box_SECRETKEYBYTES);
|
|
5334
|
+
crypto_box_keypair(pk, sk);
|
|
5335
|
+
return { publicKey: pk, secretKey: sk };
|
|
5336
|
+
};
|
|
5337
|
+
nacl.box.keyPair.fromSecretKey = function(secretKey) {
|
|
5338
|
+
checkArrayTypes(secretKey);
|
|
5339
|
+
if (secretKey.length !== crypto_box_SECRETKEYBYTES)
|
|
5340
|
+
throw new Error("bad secret key size");
|
|
5341
|
+
var pk = new Uint8Array(crypto_box_PUBLICKEYBYTES);
|
|
5342
|
+
crypto_scalarmult_base(pk, secretKey);
|
|
5343
|
+
return { publicKey: pk, secretKey: new Uint8Array(secretKey) };
|
|
5344
|
+
};
|
|
5345
|
+
nacl.box.publicKeyLength = crypto_box_PUBLICKEYBYTES;
|
|
5346
|
+
nacl.box.secretKeyLength = crypto_box_SECRETKEYBYTES;
|
|
5347
|
+
nacl.box.sharedKeyLength = crypto_box_BEFORENMBYTES;
|
|
5348
|
+
nacl.box.nonceLength = crypto_box_NONCEBYTES;
|
|
5349
|
+
nacl.box.overheadLength = nacl.secretbox.overheadLength;
|
|
5350
|
+
nacl.sign = function(msg, secretKey) {
|
|
5351
|
+
checkArrayTypes(msg, secretKey);
|
|
5352
|
+
if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
|
|
5353
|
+
throw new Error("bad secret key size");
|
|
5354
|
+
var signedMsg = new Uint8Array(crypto_sign_BYTES + msg.length);
|
|
5355
|
+
crypto_sign(signedMsg, msg, msg.length, secretKey);
|
|
5356
|
+
return signedMsg;
|
|
5357
|
+
};
|
|
5358
|
+
nacl.sign.open = function(signedMsg, publicKey) {
|
|
5359
|
+
checkArrayTypes(signedMsg, publicKey);
|
|
5360
|
+
if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
|
|
5361
|
+
throw new Error("bad public key size");
|
|
5362
|
+
var tmp = new Uint8Array(signedMsg.length);
|
|
5363
|
+
var mlen = crypto_sign_open(tmp, signedMsg, signedMsg.length, publicKey);
|
|
5364
|
+
if (mlen < 0) return null;
|
|
5365
|
+
var m3 = new Uint8Array(mlen);
|
|
5366
|
+
for (var i = 0; i < m3.length; i++) m3[i] = tmp[i];
|
|
5367
|
+
return m3;
|
|
5368
|
+
};
|
|
5369
|
+
nacl.sign.detached = function(msg, secretKey) {
|
|
5370
|
+
var signedMsg = nacl.sign(msg, secretKey);
|
|
5371
|
+
var sig = new Uint8Array(crypto_sign_BYTES);
|
|
5372
|
+
for (var i = 0; i < sig.length; i++) sig[i] = signedMsg[i];
|
|
5373
|
+
return sig;
|
|
5374
|
+
};
|
|
5375
|
+
nacl.sign.detached.verify = function(msg, sig, publicKey) {
|
|
5376
|
+
checkArrayTypes(msg, sig, publicKey);
|
|
5377
|
+
if (sig.length !== crypto_sign_BYTES)
|
|
5378
|
+
throw new Error("bad signature size");
|
|
5379
|
+
if (publicKey.length !== crypto_sign_PUBLICKEYBYTES)
|
|
5380
|
+
throw new Error("bad public key size");
|
|
5381
|
+
var sm = new Uint8Array(crypto_sign_BYTES + msg.length);
|
|
5382
|
+
var m3 = new Uint8Array(crypto_sign_BYTES + msg.length);
|
|
5383
|
+
var i;
|
|
5384
|
+
for (i = 0; i < crypto_sign_BYTES; i++) sm[i] = sig[i];
|
|
5385
|
+
for (i = 0; i < msg.length; i++) sm[i + crypto_sign_BYTES] = msg[i];
|
|
5386
|
+
return crypto_sign_open(m3, sm, sm.length, publicKey) >= 0;
|
|
5387
|
+
};
|
|
5388
|
+
nacl.sign.keyPair = function() {
|
|
5389
|
+
var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
|
|
5390
|
+
var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
|
|
5391
|
+
crypto_sign_keypair(pk, sk);
|
|
5392
|
+
return { publicKey: pk, secretKey: sk };
|
|
5393
|
+
};
|
|
5394
|
+
nacl.sign.keyPair.fromSecretKey = function(secretKey) {
|
|
5395
|
+
checkArrayTypes(secretKey);
|
|
5396
|
+
if (secretKey.length !== crypto_sign_SECRETKEYBYTES)
|
|
5397
|
+
throw new Error("bad secret key size");
|
|
5398
|
+
var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
|
|
5399
|
+
for (var i = 0; i < pk.length; i++) pk[i] = secretKey[32 + i];
|
|
5400
|
+
return { publicKey: pk, secretKey: new Uint8Array(secretKey) };
|
|
5401
|
+
};
|
|
5402
|
+
nacl.sign.keyPair.fromSeed = function(seed) {
|
|
5403
|
+
checkArrayTypes(seed);
|
|
5404
|
+
if (seed.length !== crypto_sign_SEEDBYTES)
|
|
5405
|
+
throw new Error("bad seed size");
|
|
5406
|
+
var pk = new Uint8Array(crypto_sign_PUBLICKEYBYTES);
|
|
5407
|
+
var sk = new Uint8Array(crypto_sign_SECRETKEYBYTES);
|
|
5408
|
+
for (var i = 0; i < 32; i++) sk[i] = seed[i];
|
|
5409
|
+
crypto_sign_keypair(pk, sk, true);
|
|
5410
|
+
return { publicKey: pk, secretKey: sk };
|
|
5411
|
+
};
|
|
5412
|
+
nacl.sign.publicKeyLength = crypto_sign_PUBLICKEYBYTES;
|
|
5413
|
+
nacl.sign.secretKeyLength = crypto_sign_SECRETKEYBYTES;
|
|
5414
|
+
nacl.sign.seedLength = crypto_sign_SEEDBYTES;
|
|
5415
|
+
nacl.sign.signatureLength = crypto_sign_BYTES;
|
|
5416
|
+
nacl.hash = function(msg) {
|
|
5417
|
+
checkArrayTypes(msg);
|
|
5418
|
+
var h3 = new Uint8Array(crypto_hash_BYTES);
|
|
5419
|
+
crypto_hash(h3, msg, msg.length);
|
|
5420
|
+
return h3;
|
|
5421
|
+
};
|
|
5422
|
+
nacl.hash.hashLength = crypto_hash_BYTES;
|
|
5423
|
+
nacl.verify = function(x2, y3) {
|
|
5424
|
+
checkArrayTypes(x2, y3);
|
|
5425
|
+
if (x2.length === 0 || y3.length === 0) return false;
|
|
5426
|
+
if (x2.length !== y3.length) return false;
|
|
5427
|
+
return vn2(x2, 0, y3, 0, x2.length) === 0 ? true : false;
|
|
5428
|
+
};
|
|
5429
|
+
nacl.setPRNG = function(fn) {
|
|
5430
|
+
randombytes = fn;
|
|
5431
|
+
};
|
|
5432
|
+
(function() {
|
|
5433
|
+
var crypto2 = typeof self !== "undefined" ? self.crypto || self.msCrypto : null;
|
|
5434
|
+
if (crypto2 && crypto2.getRandomValues) {
|
|
5435
|
+
var QUOTA = 65536;
|
|
5436
|
+
nacl.setPRNG(function(x2, n) {
|
|
5437
|
+
var i, v2 = new Uint8Array(n);
|
|
5438
|
+
for (i = 0; i < n; i += QUOTA) {
|
|
5439
|
+
crypto2.getRandomValues(v2.subarray(i, i + Math.min(n - i, QUOTA)));
|
|
5440
|
+
}
|
|
5441
|
+
for (i = 0; i < n; i++) x2[i] = v2[i];
|
|
5442
|
+
cleanup(v2);
|
|
5443
|
+
});
|
|
5444
|
+
} else if (typeof require !== "undefined") {
|
|
5445
|
+
crypto2 = require("crypto");
|
|
5446
|
+
if (crypto2 && crypto2.randomBytes) {
|
|
5447
|
+
nacl.setPRNG(function(x2, n) {
|
|
5448
|
+
var i, v2 = crypto2.randomBytes(n);
|
|
5449
|
+
for (i = 0; i < n; i++) x2[i] = v2[i];
|
|
5450
|
+
cleanup(v2);
|
|
5451
|
+
});
|
|
5452
|
+
}
|
|
5453
|
+
}
|
|
5454
|
+
})();
|
|
5455
|
+
})(typeof module2 !== "undefined" && module2.exports ? module2.exports : self.nacl = self.nacl || {});
|
|
5456
|
+
}
|
|
5457
|
+
});
|
|
5458
|
+
|
|
3231
5459
|
// src/index.ts
|
|
3232
5460
|
var index_exports = {};
|
|
3233
5461
|
__export(index_exports, {
|
|
@@ -3245,7 +5473,6 @@ __export(index_exports, {
|
|
|
3245
5473
|
KibisisWallet: () => KibisisWallet,
|
|
3246
5474
|
KmdWallet: () => KmdWallet,
|
|
3247
5475
|
LOCAL_STORAGE_MNEMONIC_KEY: () => LOCAL_STORAGE_MNEMONIC_KEY,
|
|
3248
|
-
LiquidWallet: () => LiquidWallet,
|
|
3249
5476
|
LogLevel: () => LogLevel,
|
|
3250
5477
|
LuteWallet: () => LuteWallet,
|
|
3251
5478
|
MagicAuth: () => MagicAuth,
|
|
@@ -3254,6 +5481,7 @@ __export(index_exports, {
|
|
|
3254
5481
|
NetworkId: () => NetworkId,
|
|
3255
5482
|
PeraWallet: () => PeraWallet,
|
|
3256
5483
|
ScopeType: () => ScopeType,
|
|
5484
|
+
SecureKeyContainer: () => SecureKeyContainer,
|
|
3257
5485
|
SessionError: () => SessionError,
|
|
3258
5486
|
SignDataError: () => SignDataError,
|
|
3259
5487
|
SignTxnsError: () => SignTxnsError,
|
|
@@ -3262,7 +5490,12 @@ __export(index_exports, {
|
|
|
3262
5490
|
WalletConnect: () => WalletConnect,
|
|
3263
5491
|
WalletId: () => WalletId,
|
|
3264
5492
|
WalletManager: () => WalletManager,
|
|
3265
|
-
|
|
5493
|
+
Web3AuthWallet: () => Web3AuthWallet,
|
|
5494
|
+
webpackFallback: () => webpackFallback,
|
|
5495
|
+
withSecureKey: () => withSecureKey,
|
|
5496
|
+
withSecureKeySync: () => withSecureKeySync,
|
|
5497
|
+
zeroMemory: () => zeroMemory,
|
|
5498
|
+
zeroString: () => zeroString
|
|
3266
5499
|
});
|
|
3267
5500
|
module.exports = __toCommonJS(index_exports);
|
|
3268
5501
|
|
|
@@ -3337,7 +5570,7 @@ var logger = Logger.getInstance();
|
|
|
3337
5570
|
|
|
3338
5571
|
// src/manager.ts
|
|
3339
5572
|
var import_store14 = require("@tanstack/store");
|
|
3340
|
-
var
|
|
5573
|
+
var import_algosdk14 = __toESM(require("algosdk"), 1);
|
|
3341
5574
|
|
|
3342
5575
|
// src/network.ts
|
|
3343
5576
|
var DEFAULT_NETWORK_CONFIG = {
|
|
@@ -3539,12 +5772,12 @@ var WalletId = /* @__PURE__ */ ((WalletId2) => {
|
|
|
3539
5772
|
WalletId2["EXODUS"] = "exodus";
|
|
3540
5773
|
WalletId2["KIBISIS"] = "kibisis";
|
|
3541
5774
|
WalletId2["KMD"] = "kmd";
|
|
3542
|
-
WalletId2["LIQUID"] = "liquid";
|
|
3543
5775
|
WalletId2["LUTE"] = "lute";
|
|
3544
5776
|
WalletId2["MAGIC"] = "magic";
|
|
3545
5777
|
WalletId2["MNEMONIC"] = "mnemonic";
|
|
3546
5778
|
WalletId2["PERA"] = "pera";
|
|
3547
5779
|
WalletId2["WALLETCONNECT"] = "walletconnect";
|
|
5780
|
+
WalletId2["WEB3AUTH"] = "web3auth";
|
|
3548
5781
|
WalletId2["W3_WALLET"] = "w3-wallet";
|
|
3549
5782
|
return WalletId2;
|
|
3550
5783
|
})(WalletId || {});
|
|
@@ -3684,7 +5917,7 @@ function isValidPersistedState(state) {
|
|
|
3684
5917
|
}
|
|
3685
5918
|
|
|
3686
5919
|
// src/utils.ts
|
|
3687
|
-
var
|
|
5920
|
+
var import_algosdk13 = __toESM(require("algosdk"), 1);
|
|
3688
5921
|
|
|
3689
5922
|
// src/wallets/walletconnect.ts
|
|
3690
5923
|
var import_algosdk2 = __toESM(require("algosdk"), 1);
|
|
@@ -5523,119 +7756,6 @@ var KmdWallet = class extends BaseWallet {
|
|
|
5523
7756
|
}
|
|
5524
7757
|
};
|
|
5525
7758
|
|
|
5526
|
-
// src/wallets/liquid.ts
|
|
5527
|
-
var ICON9 = `data:image/svg+xml;base64,${btoa(`
|
|
5528
|
-
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="249" height="249" viewBox="0 0 249 249" xml:space="preserve">
|
|
5529
|
-
<g transform="matrix(2.52 0 0 2.52 124.74 124.74)">
|
|
5530
|
-
<circle style="stroke: rgb(0,0,0); stroke-width: 19; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1;" cx="0" cy="0" r="40"/>
|
|
5531
|
-
</g>
|
|
5532
|
-
<g transform="matrix(-1.16 -0.01 0.01 -0.97 125.63 187.7)">
|
|
5533
|
-
<path style="stroke: rgb(0,0,0); stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(170,0,255); fill-rule: nonzero; opacity: 1;" transform=" translate(-57.95, -28.98)" d="m 0 57.952755 l 0 0 c 0 -32.006424 25.946333 -57.952755 57.952755 -57.952755 c 32.006428 0 57.952755 25.946333 57.952755 57.952755 l -28.97638 0 c 0 -16.003212 -12.97316 -28.976377 -28.976376 -28.976377 c -16.003212 0 -28.976377 12.9731655 -28.976377 28.976377 z" stroke-linecap="round"/>
|
|
5534
|
-
</g>
|
|
5535
|
-
<g transform="matrix(1.16 0 0 2.21 126.06 96.74)">
|
|
5536
|
-
<path style="stroke: rgb(255,4,233); stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(170,0,255); fill-rule: nonzero; opacity: 1;" transform=" translate(-57.95, -28.98)" d="m 0 57.952755 l 0 0 c 0 -32.006424 25.946333 -57.952755 57.952755 -57.952755 c 32.006428 0 57.952755 25.946333 57.952755 57.952755 l -28.97638 0 c 0 -16.003212 -12.97316 -28.976377 -28.976376 -28.976377 c -16.003212 0 -28.976377 12.9731655 -28.976377 28.976377 z" stroke-linecap="round"/>
|
|
5537
|
-
</g>
|
|
5538
|
-
</svg>
|
|
5539
|
-
`)}`;
|
|
5540
|
-
var LiquidWallet = class extends BaseWallet {
|
|
5541
|
-
store;
|
|
5542
|
-
authClient;
|
|
5543
|
-
options;
|
|
5544
|
-
constructor({
|
|
5545
|
-
id,
|
|
5546
|
-
store,
|
|
5547
|
-
subscribe,
|
|
5548
|
-
getAlgodClient,
|
|
5549
|
-
options,
|
|
5550
|
-
metadata = {}
|
|
5551
|
-
}) {
|
|
5552
|
-
super({ id, metadata, getAlgodClient, store, subscribe });
|
|
5553
|
-
this.store = store;
|
|
5554
|
-
this.options = options ?? {
|
|
5555
|
-
RTC_config_username: "username",
|
|
5556
|
-
RTC_config_credential: "credential"
|
|
5557
|
-
};
|
|
5558
|
-
}
|
|
5559
|
-
static defaultMetadata = {
|
|
5560
|
-
name: "Liquid",
|
|
5561
|
-
icon: ICON9
|
|
5562
|
-
};
|
|
5563
|
-
async initializeClient() {
|
|
5564
|
-
this.logger.info("Initializing client...");
|
|
5565
|
-
const { LiquidAuthClient } = await import("@algorandfoundation/liquid-auth-use-wallet-client");
|
|
5566
|
-
const client = new LiquidAuthClient(this.options);
|
|
5567
|
-
this.authClient = client;
|
|
5568
|
-
this.logger.info("Client initialized");
|
|
5569
|
-
return client;
|
|
5570
|
-
}
|
|
5571
|
-
connect = async (_args) => {
|
|
5572
|
-
this.logger.info("Connecting...");
|
|
5573
|
-
const authClient = this.authClient || await this.initializeClient();
|
|
5574
|
-
const account = await authClient.connect();
|
|
5575
|
-
if (!account || account.length === 0) {
|
|
5576
|
-
this.logger.error("No accounts found!");
|
|
5577
|
-
throw new Error("No accounts found!");
|
|
5578
|
-
}
|
|
5579
|
-
const walletAccounts = [
|
|
5580
|
-
{
|
|
5581
|
-
name: `${this.metadata.name} Account 1`,
|
|
5582
|
-
address: account.toString()
|
|
5583
|
-
}
|
|
5584
|
-
];
|
|
5585
|
-
const walletState = {
|
|
5586
|
-
accounts: walletAccounts,
|
|
5587
|
-
activeAccount: walletAccounts[0]
|
|
5588
|
-
};
|
|
5589
|
-
addWallet(this.store, {
|
|
5590
|
-
walletId: this.id,
|
|
5591
|
-
wallet: walletState
|
|
5592
|
-
});
|
|
5593
|
-
this.logger.info("Connected successfully", walletState);
|
|
5594
|
-
authClient.hideModal();
|
|
5595
|
-
return Promise.resolve(walletAccounts);
|
|
5596
|
-
};
|
|
5597
|
-
disconnect = async () => {
|
|
5598
|
-
this.logger.info("Disconnecting...");
|
|
5599
|
-
if (!this.authClient) {
|
|
5600
|
-
throw new Error("No auth client to disconnect");
|
|
5601
|
-
}
|
|
5602
|
-
await this.authClient.disconnect();
|
|
5603
|
-
this.onDisconnect();
|
|
5604
|
-
this.logger.info("Disconnected.");
|
|
5605
|
-
this.authClient = null;
|
|
5606
|
-
};
|
|
5607
|
-
resumeSession = async () => {
|
|
5608
|
-
try {
|
|
5609
|
-
const state = this.store.state;
|
|
5610
|
-
const walletState = state.wallets[this.id];
|
|
5611
|
-
if (walletState) {
|
|
5612
|
-
await this.disconnect();
|
|
5613
|
-
}
|
|
5614
|
-
} catch (error) {
|
|
5615
|
-
this.logger.error("Error resuming session", error);
|
|
5616
|
-
this.onDisconnect();
|
|
5617
|
-
throw error;
|
|
5618
|
-
}
|
|
5619
|
-
};
|
|
5620
|
-
signTransactions = async (txnGroup, indexesToSign) => {
|
|
5621
|
-
try {
|
|
5622
|
-
if (!this.activeAddress) {
|
|
5623
|
-
throw new Error("No active account");
|
|
5624
|
-
}
|
|
5625
|
-
this.logger.debug("Signing transactions...", { txnGroup, indexesToSign });
|
|
5626
|
-
const authClient = this.authClient || await this.initializeClient();
|
|
5627
|
-
if (!authClient.client.peerClient) {
|
|
5628
|
-
await authClient.connect();
|
|
5629
|
-
authClient.hideModal();
|
|
5630
|
-
}
|
|
5631
|
-
return authClient.signTransactions(txnGroup, this.activeAddress, indexesToSign);
|
|
5632
|
-
} catch (error) {
|
|
5633
|
-
this.logger.error("Error signing transactions", error);
|
|
5634
|
-
throw error;
|
|
5635
|
-
}
|
|
5636
|
-
};
|
|
5637
|
-
};
|
|
5638
|
-
|
|
5639
7759
|
// src/wallets/lute.ts
|
|
5640
7760
|
var import_algosdk7 = __toESM(require("algosdk"), 1);
|
|
5641
7761
|
function isSignTxnsError(error) {
|
|
@@ -5644,7 +7764,7 @@ function isSignTxnsError(error) {
|
|
|
5644
7764
|
function isSignDataError(error) {
|
|
5645
7765
|
return error instanceof Error && "code" in error;
|
|
5646
7766
|
}
|
|
5647
|
-
var
|
|
7767
|
+
var ICON9 = `data:image/svg+xml;base64,${btoa(`
|
|
5648
7768
|
<svg viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg">
|
|
5649
7769
|
<path fill="#AB47BC" d="M283.7,263.6c-0.6,0-1.3-0.1-1.8-0.4c-0.6-0.3-1.1-0.8-1.5-1.3c-0.4-0.6-0.7-1.3-0.8-2 c-0.1-0.8-0.1-1.7,0.1-2.5c0.2-0.9,0.6-1.8,1.2-2.6c0.6-0.8,1.4-1.7,2.2-2.3c0.9-0.7,2.1-1.2,3.2-1.6c1.2-0.4,2.7-0.5,4-0.5 c1.4,0,3,0.3,4.4,0.8c1.5,0.5,3.1,1.4,4.3,2.3c1.4,1,2.8,2.4,3.8,3.7c1.1,1.5,2.1,3.3,2.8,5.1c0.7,1.9,1.2,4.1,1.3,6.1 c0.2,2.1,0,4.6-0.4,6.7c-0.5,2.2-1.4,4.7-2.4,6.7c-1.1,2.1-2.8,4.4-4.4,6.2c-1.8,1.9-4.1,3.7-6.3,5c-2.3,1.4-5.2,2.6-7.9,3.3 c-2.8,0.7-6.1,1.1-8.9,1.1c-3,0-6.5-0.6-9.3-1.4c-3-0.9-6.4-2.4-9.1-4c-2.8-1.7-5.8-4.2-8-6.6c-2.3-2.5-4.6-5.8-6.2-8.9 c-1.7-3.2-3.1-7.1-3.8-10.7c-0.8-3.7-1.1-8-0.9-11.8c0.2-3.9,1.1-8.3,2.3-12c1.3-3.8,3.4-8.1,5.7-11.4c2.3-3.5,5.6-7.1,8.8-9.9 c3.3-2.8,7.5-5.6,11.5-7.5c4.1-1.9,9-3.5,13.5-4.3c4.6-0.8,10-1.1,14.6-0.7c4.8,0.4,10.2,1.6,14.7,3.3c4.7,1.7,9.7,4.4,13.8,7.3 c4.2,3,8.5,7,11.7,10.9c3.3,4.1,6.5,9.2,8.7,14c2.2,4.9,4,10.9,4.9,16.3c0.9,5.5,1,11.9,0.4,17.5c-0.6,5.7-2.2,12.1-4.3,17.4 c-2.1,5.5-5.4,11.4-8.9,16.1c-3.6,4.8-8.4,9.8-13.1,13.6c-4.8,3.8-11,7.5-16.6,9.9c-5.8,2.5-12.8,4.5-19.1,5.4 c-6.4,0.9-13.9,1-20.3,0.2c-6.6-0.8-14-2.7-20.1-5.2c-6.3-2.5-13.1-6.4-18.5-10.5c-5.5-4.2-11.2-9.8-15.4-15.3 c-4.3-5.6-8.4-12.7-11.2-19.2c-2.8-6.7-4.9-14.7-5.9-21.9c-0.9-5.9-2.8-12.6-5.2-18.1c-2.3-5.4-5.9-11.2-9.5-15.8 c-3.6-4.5-8.3-9-13-12.4c-4.5-3.3-10.1-6.4-15.3-8.3c-5-1.9-11.1-3.4-16.5-3.9c-5.2-0.5-11.3-0.3-16.5,0.5c-5,0.8-10.7,2.6-15.3,4.7 c-4.5,2.1-9.4,5.1-13.2,8.3c-3.7,3.1-7.5,7.2-10.2,11.1c-2.7,3.8-5.2,8.6-6.7,13c-1.5,4.2-2.6,9.3-3,13.8c-0.3,4.3-0.1,9.4,0.7,13.7 c0.8,4.1,2.3,8.8,4.2,12.5c1.8,3.6,4.4,7.6,7.1,10.6c2.6,2.9,6,5.9,9.3,8.1c3.1,2.1,7.1,4,10.6,5.1c3.4,1.1,7.5,1.9,11.1,2 c3.5,0.2,7.4-0.2,10.8-1c3.2-0.7,6.8-2.1,9.7-3.6c2.8-1.5,5.7-3.6,8-5.8c2.2-2.1,4.3-4.8,5.9-7.4c1.5-2.5,2.8-5.5,3.5-8.3 c0.7-2.6,1.1-5.7,1.1-8.5c0-2.6-0.5-5.5-1.2-8c-0.7-2.3-1.8-4.9-3.1-6.9c-1.2-1.9-2.9-3.9-4.6-5.4c-1.6-1.4-3.6-2.8-5.5-3.7 c-1.8-0.9-4-1.6-5.9-1.9c-1.8-0.3-3.9-0.4-5.8-0.1c-1.7,0.2-3.6,0.7-5.1,1.4c-1.4,0.6-2.9,1.6-4.1,2.6c-1.1,0.9-2.1,2.2-2.9,3.4 c-0.7,1.1-1.2,2.5-1.5,3.7c-0.3,1.1-0.4,2.4-0.3,3.6c0.1,1,0.4,2.2,0.8,3.1c0.4,0.8,1,1.7,1.6,2.3c0.6,0.5,1.3,1,2.1,1.3 c0.6,0.2,1.5,0.4,2.1,0.3c0.6-0.1,1.3-0.3,1.8-0.6c0.5-0.3,1-0.8,1.2-1.4c0.3-0.5,0.7-1,1.2-1.4c0.5-0.3,1.2-0.6,1.8-0.6 c0.7-0.1,1.5,0.1,2.1,0.3c0.7,0.3,1.5,0.8,2.1,1.3c0.6,0.6,1.3,1.5,1.6,2.3c0.4,0.9,0.7,2.1,0.8,3.1c0.1,1.1,0,2.5-0.3,3.6 c-0.3,1.2-0.9,2.6-1.5,3.7c-0.7,1.2-1.8,2.4-2.9,3.4c-1.2,1-2.7,2-4.1,2.6c-1.5,0.7-3.4,1.2-5.1,1.4c-1.8,0.2-4,0.2-5.8-0.1 c-2-0.3-4.1-1-5.9-1.9c-1.9-0.9-4-2.3-5.5-3.7c-1.7-1.5-3.4-3.5-4.6-5.4c-1.3-2-2.4-4.6-3.1-6.9c-0.7-2.5-1.2-5.4-1.2-8 c0-2.7,0.4-5.8,1.1-8.5c0.7-2.8,2-5.8,3.5-8.3c1.5-2.6,3.7-5.3,5.9-7.4c2.3-2.2,5.2-4.3,8-5.8c2.9-1.6,6.5-2.9,9.7-3.6 c3.4-0.8,7.4-1.1,10.8-1c3.6,0.2,7.7,0.9,11.1,2c3.6,1.2,7.5,3.1,10.6,5.1c3.3,2.1,6.7,5.1,9.3,8.1c2.7,3,5.3,7,7.1,10.6 c1.8,3.8,3.4,8.4,4.2,12.5c0.8,4.3,1.1,9.3,0.7,13.7c-0.4,4.5-1.5,9.6-3,13.8c-1.6,4.4-4.1,9.2-6.7,13c-2.8,3.9-6.5,8-10.2,11.1 c-3.8,3.2-8.7,6.2-13.2,8.3c-4.6,2.1-10.3,3.8-15.3,4.7c-5.2,0.9-11.3,1-16.5,0.5c-5.4-0.5-11.5-2-16.5-3.9 c-5.2-2-10.8-5.1-15.3-8.3c-4.6-3.4-9.4-7.9-13-12.4c-3.7-4.6-7.2-10.4-9.5-15.8c-2.4-5.5-4.3-12.2-5.2-18.1 c-0.9-6.1-1-13.2-0.3-19.3c0.7-6.3,2.5-13.4,4.9-19.2c2.4-6,6.1-12.5,10-17.7c4-5.3,9.3-10.7,14.6-14.8c5.3-4.2,12.1-8.1,18.3-10.7 c6.4-2.7,14.1-4.8,21-5.7c7-1,15.2-1,22.2-0.1c7.2,0.9,15.2,3.1,21.9,5.8c5.6,2.2,12.3,3.9,18.3,4.6c5.8,0.7,12.6,0.5,18.4-0.4 c5.6-0.9,12-2.7,17.2-5c5.1-2.3,10.6-5.6,14.9-9.1c4.2-3.4,8.5-8,11.7-12.3c3.1-4.3,6-9.6,7.8-14.5c1.8-4.8,3.1-10.5,3.6-15.6 c0.5-4.9,0.3-10.7-0.6-15.6c-0.8-4.7-2.5-10.1-4.5-14.4c-2-4.2-4.9-8.8-7.9-12.3c-2.9-3.4-6.8-6.9-10.5-9.5 c-3.6-2.5-8.1-4.8-12.2-6.2c-4-1.4-8.7-2.4-12.9-2.7c-4-0.3-8.7,0-12.7,0.8c-3.8,0.8-8.1,2.2-11.6,4c-3.4,1.7-7,4.1-9.7,6.6 c-2.7,2.4-5.4,5.6-7.3,8.6c-1.9,2.9-3.6,6.5-4.6,9.8c-1,3.2-1.6,6.9-1.7,10.2c-0.1,3.2,0.3,6.8,1,9.9c0.7,2.9,2,6.2,3.5,8.8 c1.4,2.5,3.4,5.1,5.4,7.2c1.9,1.9,4.4,3.8,6.8,5.2c2.2,1.3,5,2.4,7.5,3c2.3,0.6,5.1,0.9,7.6,0.8c2.3-0.1,4.9-0.5,7-1.3 c2-0.7,4.2-1.7,6-2.9c1.6-1.1,3.3-2.7,4.6-4.2c1.2-1.4,2.3-3.2,3-4.9c0.7-1.6,1.2-3.5,1.3-5.1c0.2-1.5,0.1-3.3-0.2-4.9 c-0.3-1.4-0.8-2.9-1.5-4.2c-0.6-1.1-1.5-2.3-2.4-3.2c-0.8-0.8-1.9-1.5-3-2c-0.9-0.4-2.1-0.7-3.1-0.8c-0.9-0.1-1.9,0-2.8,0.3 c-0.7,0.2-1.6,0.6-2.2,1.1c-0.5,0.4-1,1.1-1.3,1.7c-0.3,0.6-0.4,1.3-0.4,1.9c0,0.6,0.2,1.2,0.6,1.7c0.3,0.5,0.5,1.2,0.6,1.7 c0,0.6-0.1,1.3-0.4,1.9c-0.3,0.6-0.8,1.3-1.3,1.7c-0.6,0.5-1.4,0.9-2.2,1.1c-0.9,0.3-1.9,0.3-2.8,0.3c-1-0.1-2.2-0.4-3.1-0.8 c-1-0.5-2.1-1.2-3-2c-0.9-0.9-1.8-2.1-2.4-3.2c-0.7-1.2-1.2-2.8-1.5-4.2c-0.3-1.5-0.4-3.3-0.2-4.9c0.2-1.7,0.7-3.6,1.3-5.1 c0.7-1.7,1.8-3.5,3-4.9c1.3-1.5,3-3.1,4.6-4.2c1.8-1.2,4-2.3,6-2.9c2.2-0.7,4.8-1.2,7-1.3c2.4-0.1,5.2,0.2,7.6,0.8 c2.5,0.6,5.3,1.7,7.5,3c2.4,1.3,4.9,3.2,6.8,5.2c2,2,4,4.7,5.4,7.2c1.5,2.6,2.7,5.9,3.5,8.8c0.8,3.1,1.1,6.7,1,9.9 c-0.1,3.3-0.7,7.1-1.7,10.2c-1,3.3-2.7,6.9-4.6,9.8c-1.9,3-4.7,6.2-7.3,8.6c-2.8,2.5-6.4,5-9.7,6.6c-3.5,1.8-7.8,3.2-11.6,4 c-4,0.8-8.7,1.1-12.7,0.8c-4.2-0.3-9-1.3-12.9-2.7c-4.1-1.4-8.6-3.7-12.2-6.2c-3.7-2.6-7.6-6.1-10.5-9.5c-3-3.6-5.9-8.1-7.9-12.3 c-2-4.4-3.7-9.7-4.5-14.4c-0.8-4.9-1.1-10.6-0.6-15.6c0.5-5.1,1.8-10.8,3.6-15.6c1.8-4.9,4.7-10.3,7.8-14.5 c3.2-4.4,7.5-8.9,11.7-12.3c4.3-3.5,9.8-6.9,14.9-9.1c5.2-2.3,11.6-4.2,17.2-5c5.8-0.9,12.6-1,18.4-0.4c6,0.7,12.7,2.4,18.3,4.6 c5.7,2.3,12,5.7,16.9,9.4c5.1,3.8,10.3,8.9,14.2,13.8c4,5.1,7.8,11.5,10.3,17.5c2.6,6.1,4.6,13.5,5.5,20c0.9,6.7,1,14.5,0.1,21.2 c-0.9,6.9-2.9,14.6-5.5,21c-2.7,6.5-6.8,13.6-11,19.3c-4.4,5.7-10.3,11.7-16,16c-4.7,3.7-9.5,8.7-13.1,13.6 c-3.5,4.7-6.8,10.7-8.9,16.1c-2.1,5.3-3.6,11.7-4.3,17.4c-0.6,5.5-0.4,12,0.4,17.5c0.9,5.3,2.6,11.3,4.9,16.3c2.2,4.8,5.4,10,8.7,14 c3.2,3.9,7.6,8,11.7,10.9c4,2.9,9.1,5.6,13.8,7.3c4.5,1.7,9.9,2.9,14.7,3.3c4.6,0.4,10,0.2,14.6-0.7c4.4-0.8,9.4-2.4,13.5-4.3 c3.9-1.9,8.2-4.6,11.5-7.5c3.2-2.7,6.4-6.4,8.8-9.9c2.3-3.4,4.4-7.6,5.7-11.4c1.2-3.7,2.1-8.1,2.3-12c0.2-3.7-0.1-8.1-0.9-11.8 c-0.8-3.5-2.2-7.5-3.8-10.7c-1.6-3.1-3.9-6.3-6.2-8.9c-2.2-2.4-5.2-4.9-8-6.6c-2.7-1.7-6-3.2-9.1-4c-2.9-0.8-6.3-1.4-9.3-1.4 c-2.9,0-6.2,0.4-8.9,1.1c-2.6,0.7-5.5,1.9-7.9,3.3c-2.2,1.3-4.5,3.2-6.3,5c-1.7,1.8-3.3,4-4.4,6.2c-1.1,2-2,4.5-2.4,6.7 c-0.4,2.1-0.6,4.5-0.4,6.7c0.2,2,0.6,4.2,1.3,6.1c0.6,1.7,1.7,3.6,2.8,5.1c1,1.3,2.4,2.7,3.8,3.7c1.3,0.9,2.8,1.8,4.3,2.3 c1.3,0.5,2.9,0.8,4.4,0.8c1.3,0,2.7-0.1,4-0.5c1.1-0.3,2.3-0.9,3.2-1.6c0.8-0.6,1.7-1.4,2.2-2.3c0.5-0.7,0.9-1.7,1.2-2.6 c0.2-0.8,0.2-1.7,0.1-2.5c-0.1-0.7-0.4-1.4-0.8-2c-0.4-0.5-0.9-1-1.5-1.3C285,263.7,284.3,263.6,283.7,263.6L283.7,263.6z" />
|
|
5650
7770
|
</svg>
|
|
@@ -5667,7 +7787,7 @@ var LuteWallet = class extends BaseWallet {
|
|
|
5667
7787
|
}
|
|
5668
7788
|
static defaultMetadata = {
|
|
5669
7789
|
name: "Lute",
|
|
5670
|
-
icon:
|
|
7790
|
+
icon: ICON9
|
|
5671
7791
|
};
|
|
5672
7792
|
async initializeClient() {
|
|
5673
7793
|
this.logger.info("Initializing client...");
|
|
@@ -5815,7 +7935,7 @@ var LuteWallet = class extends BaseWallet {
|
|
|
5815
7935
|
|
|
5816
7936
|
// src/wallets/magic.ts
|
|
5817
7937
|
var import_algosdk8 = __toESM(require("algosdk"), 1);
|
|
5818
|
-
var
|
|
7938
|
+
var ICON10 = `data:image/svg+xml;base64,${btoa(`
|
|
5819
7939
|
<svg viewBox="0 0 47 47" xmlns="http://www.w3.org/2000/svg">
|
|
5820
7940
|
<path fill="#6851FF" d="M 23.960861 1.80769 C 25.835077 4.103153 27.902216 6.23489 30.137539 8.178169 C 28.647968 13.009323 27.846092 18.142094 27.846092 23.462154 C 27.846092 28.782307 28.648062 33.915169 30.13763 38.746368 C 27.902216 40.689724 25.835077 42.821476 23.960861 45.116985 C 22.086554 42.821476 20.019415 40.689632 17.783998 38.746368 C 19.273476 33.915169 20.075445 28.7824 20.075445 23.462337 C 20.075445 18.142277 19.273476 13.009506 17.783998 8.178318 C 20.019415 6.235001 22.086554 4.10321 23.960861 1.80769 Z M 13.511427 35.406403 C 11.145139 33.747814 8.633816 32.282063 6.000269 31.031937 C 6.730776 28.637476 7.123754 26.095783 7.123754 23.462429 C 7.123754 20.828892 6.730762 18.287201 6.000235 15.892738 C 8.633816 14.642616 11.145175 13.176861 13.511501 11.518276 C 14.416311 15.352554 14.895074 19.351414 14.895074 23.462154 C 14.895074 27.572985 14.416283 31.571938 13.511427 35.406403 Z M 33.027046 23.462337 C 33.027046 27.572985 33.505753 31.571846 34.410553 35.406124 C 36.776859 33.747631 39.288094 32.281876 41.921539 31.031845 C 41.191017 28.637384 40.798061 26.095692 40.798061 23.462246 C 40.798061 20.8288 41.191017 18.287201 41.921539 15.89283 C 39.288094 14.642708 36.776768 13.177048 34.410553 11.518555 C 33.505753 15.352831 33.027046 19.351692 33.027046 23.462337 Z" />
|
|
5821
7941
|
</svg>
|
|
@@ -5843,7 +7963,7 @@ var MagicAuth = class extends BaseWallet {
|
|
|
5843
7963
|
}
|
|
5844
7964
|
static defaultMetadata = {
|
|
5845
7965
|
name: "Magic",
|
|
5846
|
-
icon:
|
|
7966
|
+
icon: ICON10
|
|
5847
7967
|
};
|
|
5848
7968
|
async initializeClient() {
|
|
5849
7969
|
this.logger.info("Initializing client...");
|
|
@@ -6025,7 +8145,7 @@ var MagicAuth = class extends BaseWallet {
|
|
|
6025
8145
|
// src/wallets/mnemonic.ts
|
|
6026
8146
|
var import_algosdk9 = __toESM(require("algosdk"), 1);
|
|
6027
8147
|
var LOCAL_STORAGE_MNEMONIC_KEY = `${LOCAL_STORAGE_KEY}_mnemonic`;
|
|
6028
|
-
var
|
|
8148
|
+
var ICON11 = `data:image/svg+xml;base64,${btoa(`
|
|
6029
8149
|
<svg viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg">
|
|
6030
8150
|
<rect fill="#525252" width="400" height="400" />
|
|
6031
8151
|
<path fill="#FFFFFF" d="M309.2,309.3H275l-22.2-82.7l-47.9,82.7h-38.3l73.9-128l-11.9-44.5l-99.6,172.6H90.8L217.1,90.6 h33.5l14.7,54.3h34.6l-23.6,41L309.2,309.3z" />
|
|
@@ -6058,7 +8178,7 @@ var MnemonicWallet = class extends BaseWallet {
|
|
|
6058
8178
|
}
|
|
6059
8179
|
static defaultMetadata = {
|
|
6060
8180
|
name: "Mnemonic",
|
|
6061
|
-
icon:
|
|
8181
|
+
icon: ICON11
|
|
6062
8182
|
};
|
|
6063
8183
|
loadMnemonicFromStorage() {
|
|
6064
8184
|
return StorageAdapter.getItem(LOCAL_STORAGE_MNEMONIC_KEY);
|
|
@@ -6201,7 +8321,7 @@ var MnemonicWallet = class extends BaseWallet {
|
|
|
6201
8321
|
|
|
6202
8322
|
// src/wallets/pera.ts
|
|
6203
8323
|
var import_algosdk10 = __toESM(require("algosdk"), 1);
|
|
6204
|
-
var
|
|
8324
|
+
var ICON12 = `data:image/svg+xml;base64,${btoa(`
|
|
6205
8325
|
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
|
|
6206
8326
|
<rect fill="#FFEE55" width="200" height="200" />
|
|
6207
8327
|
<path fill="#1C1C1C" d="M106.1,64.3c2.2,9.1,1.5,17-1.7,17.8c-3.1,0.8-7.4-6-9.6-15c-2.2-9.1-1.5-17,1.7-17.8 C99.6,48.5,103.9,55.2,106.1,64.3z" />
|
|
@@ -6230,7 +8350,7 @@ var PeraWallet = class extends BaseWallet {
|
|
|
6230
8350
|
}
|
|
6231
8351
|
static defaultMetadata = {
|
|
6232
8352
|
name: "Pera",
|
|
6233
|
-
icon:
|
|
8353
|
+
icon: ICON12
|
|
6234
8354
|
};
|
|
6235
8355
|
async initializeClient() {
|
|
6236
8356
|
this.logger.info("Initializing client...");
|
|
@@ -6414,8 +8534,557 @@ var PeraWallet = class extends BaseWallet {
|
|
|
6414
8534
|
};
|
|
6415
8535
|
};
|
|
6416
8536
|
|
|
6417
|
-
// src/wallets/
|
|
8537
|
+
// src/wallets/web3auth.ts
|
|
6418
8538
|
var import_algosdk11 = __toESM(require("algosdk"), 1);
|
|
8539
|
+
|
|
8540
|
+
// src/secure-key.ts
|
|
8541
|
+
var secureLogger = logger.createScopedLogger("SecureKey");
|
|
8542
|
+
function zeroMemory(buffer) {
|
|
8543
|
+
if (!buffer || buffer.length === 0) return;
|
|
8544
|
+
try {
|
|
8545
|
+
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
8546
|
+
crypto.getRandomValues(buffer);
|
|
8547
|
+
}
|
|
8548
|
+
buffer.fill(0);
|
|
8549
|
+
} catch {
|
|
8550
|
+
for (let i = 0; i < buffer.length; i++) {
|
|
8551
|
+
buffer[i] = 0;
|
|
8552
|
+
}
|
|
8553
|
+
}
|
|
8554
|
+
}
|
|
8555
|
+
function zeroString(str) {
|
|
8556
|
+
if (!str) return "";
|
|
8557
|
+
const arr = new Uint8Array(str.length);
|
|
8558
|
+
for (let i = 0; i < str.length; i++) {
|
|
8559
|
+
arr[i] = str.charCodeAt(i);
|
|
8560
|
+
}
|
|
8561
|
+
zeroMemory(arr);
|
|
8562
|
+
return "";
|
|
8563
|
+
}
|
|
8564
|
+
var SecureKeyContainer = class {
|
|
8565
|
+
_secretKey = null;
|
|
8566
|
+
_isCleared = false;
|
|
8567
|
+
constructor(secretKey) {
|
|
8568
|
+
this._secretKey = new Uint8Array(secretKey);
|
|
8569
|
+
}
|
|
8570
|
+
/**
|
|
8571
|
+
* Check if the key has been cleared
|
|
8572
|
+
*/
|
|
8573
|
+
get isCleared() {
|
|
8574
|
+
return this._isCleared;
|
|
8575
|
+
}
|
|
8576
|
+
/**
|
|
8577
|
+
* Execute a callback with access to the secret key.
|
|
8578
|
+
* The key is automatically cleared if an error occurs.
|
|
8579
|
+
*/
|
|
8580
|
+
async useKey(callback) {
|
|
8581
|
+
if (this._isCleared || !this._secretKey) {
|
|
8582
|
+
throw new Error("SecureKeyContainer: Key has been cleared");
|
|
8583
|
+
}
|
|
8584
|
+
try {
|
|
8585
|
+
return await callback(this._secretKey);
|
|
8586
|
+
} catch (error) {
|
|
8587
|
+
this.clear();
|
|
8588
|
+
throw error;
|
|
8589
|
+
}
|
|
8590
|
+
}
|
|
8591
|
+
/**
|
|
8592
|
+
* Execute a synchronous callback with access to the secret key.
|
|
8593
|
+
*/
|
|
8594
|
+
useKeySync(callback) {
|
|
8595
|
+
if (this._isCleared || !this._secretKey) {
|
|
8596
|
+
throw new Error("SecureKeyContainer: Key has been cleared");
|
|
8597
|
+
}
|
|
8598
|
+
try {
|
|
8599
|
+
return callback(this._secretKey);
|
|
8600
|
+
} catch (error) {
|
|
8601
|
+
this.clear();
|
|
8602
|
+
throw error;
|
|
8603
|
+
}
|
|
8604
|
+
}
|
|
8605
|
+
/**
|
|
8606
|
+
* Securely clear the key from memory.
|
|
8607
|
+
* This should be called when the key is no longer needed.
|
|
8608
|
+
*/
|
|
8609
|
+
clear() {
|
|
8610
|
+
if (this._secretKey && !this._isCleared) {
|
|
8611
|
+
zeroMemory(this._secretKey);
|
|
8612
|
+
this._secretKey = null;
|
|
8613
|
+
this._isCleared = true;
|
|
8614
|
+
secureLogger.debug("Key material cleared from memory");
|
|
8615
|
+
}
|
|
8616
|
+
}
|
|
8617
|
+
};
|
|
8618
|
+
async function withSecureKey(secretKey, callback) {
|
|
8619
|
+
const container = new SecureKeyContainer(secretKey);
|
|
8620
|
+
try {
|
|
8621
|
+
return await callback(container);
|
|
8622
|
+
} finally {
|
|
8623
|
+
container.clear();
|
|
8624
|
+
}
|
|
8625
|
+
}
|
|
8626
|
+
function withSecureKeySync(secretKey, callback) {
|
|
8627
|
+
const container = new SecureKeyContainer(secretKey);
|
|
8628
|
+
try {
|
|
8629
|
+
return callback(container);
|
|
8630
|
+
} finally {
|
|
8631
|
+
container.clear();
|
|
8632
|
+
}
|
|
8633
|
+
}
|
|
8634
|
+
async function deriveAlgorandAccountFromEd25519(ed25519Seed) {
|
|
8635
|
+
if (ed25519Seed.length !== 32) {
|
|
8636
|
+
throw new Error(`Invalid ed25519 seed length: expected 32 bytes, got ${ed25519Seed.length}`);
|
|
8637
|
+
}
|
|
8638
|
+
const nacl = await Promise.resolve().then(() => __toESM(require_nacl_fast(), 1));
|
|
8639
|
+
const algosdk15 = await import("algosdk");
|
|
8640
|
+
const keyPair = nacl.sign.keyPair.fromSeed(ed25519Seed);
|
|
8641
|
+
const address = algosdk15.encodeAddress(keyPair.publicKey);
|
|
8642
|
+
return {
|
|
8643
|
+
addr: address,
|
|
8644
|
+
sk: keyPair.secretKey
|
|
8645
|
+
};
|
|
8646
|
+
}
|
|
8647
|
+
|
|
8648
|
+
// src/wallets/web3auth.ts
|
|
8649
|
+
var ICON13 = `data:image/svg+xml;base64,${btoa(`
|
|
8650
|
+
<svg viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg">
|
|
8651
|
+
<rect fill="#0364FF" width="40" height="40" rx="8"/>
|
|
8652
|
+
<path fill="#FFFFFF" d="M20 8c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12S26.627 8 20 8zm0 21.6c-5.302 0-9.6-4.298-9.6-9.6S14.698 10.4 20 10.4s9.6 4.298 9.6 9.6-4.298 9.6-9.6 9.6zm0-16.8c-3.976 0-7.2 3.224-7.2 7.2s3.224 7.2 7.2 7.2 7.2-3.224 7.2-7.2-3.224-7.2-7.2-7.2zm0 12c-2.651 0-4.8-2.149-4.8-4.8s2.149-4.8 4.8-4.8 4.8 2.149 4.8 4.8-2.149 4.8-4.8 4.8z"/>
|
|
8653
|
+
</svg>
|
|
8654
|
+
`)}`;
|
|
8655
|
+
var Web3AuthWallet = class extends BaseWallet {
|
|
8656
|
+
web3auth = null;
|
|
8657
|
+
web3authSFA = null;
|
|
8658
|
+
options;
|
|
8659
|
+
userInfo = null;
|
|
8660
|
+
/**
|
|
8661
|
+
* SECURITY: We store only the address, NEVER the private key.
|
|
8662
|
+
* Keys are fetched fresh from Web3Auth and immediately cleared after use.
|
|
8663
|
+
*/
|
|
8664
|
+
_address = null;
|
|
8665
|
+
/** Track which SDK is currently in use */
|
|
8666
|
+
usingSFA = false;
|
|
8667
|
+
store;
|
|
8668
|
+
constructor({
|
|
8669
|
+
id,
|
|
8670
|
+
store,
|
|
8671
|
+
subscribe,
|
|
8672
|
+
getAlgodClient,
|
|
8673
|
+
options,
|
|
8674
|
+
metadata = {}
|
|
8675
|
+
}) {
|
|
8676
|
+
super({ id, metadata, getAlgodClient, store, subscribe });
|
|
8677
|
+
if (!options?.clientId) {
|
|
8678
|
+
this.logger.error("Missing required option: clientId");
|
|
8679
|
+
throw new Error("Missing required option: clientId");
|
|
8680
|
+
}
|
|
8681
|
+
this.options = {
|
|
8682
|
+
web3AuthNetwork: "sapphire_mainnet",
|
|
8683
|
+
usePopup: true,
|
|
8684
|
+
...options
|
|
8685
|
+
};
|
|
8686
|
+
this.store = store;
|
|
8687
|
+
}
|
|
8688
|
+
static defaultMetadata = {
|
|
8689
|
+
name: "Web3Auth",
|
|
8690
|
+
icon: ICON13
|
|
8691
|
+
};
|
|
8692
|
+
/**
|
|
8693
|
+
* Initialize the Web3Auth client
|
|
8694
|
+
*/
|
|
8695
|
+
async initializeClient() {
|
|
8696
|
+
this.logger.info("Initializing Web3Auth client...");
|
|
8697
|
+
let Web3Auth;
|
|
8698
|
+
let CHAIN_NAMESPACES;
|
|
8699
|
+
let WEB3AUTH_NETWORK;
|
|
8700
|
+
let CommonPrivateKeyProvider;
|
|
8701
|
+
try {
|
|
8702
|
+
const modal = await import("@web3auth/modal");
|
|
8703
|
+
Web3Auth = modal.Web3Auth;
|
|
8704
|
+
const base = await import("@web3auth/base");
|
|
8705
|
+
CHAIN_NAMESPACES = base.CHAIN_NAMESPACES;
|
|
8706
|
+
WEB3AUTH_NETWORK = base.WEB3AUTH_NETWORK;
|
|
8707
|
+
const baseProvider = await import("@web3auth/base-provider");
|
|
8708
|
+
CommonPrivateKeyProvider = baseProvider.CommonPrivateKeyProvider;
|
|
8709
|
+
} catch {
|
|
8710
|
+
this.logger.error(
|
|
8711
|
+
"Failed to load Web3Auth. Make sure @web3auth/modal, @web3auth/base, and @web3auth/base-provider are installed."
|
|
8712
|
+
);
|
|
8713
|
+
throw new Error(
|
|
8714
|
+
"Web3Auth packages not found. Please install @web3auth/modal, @web3auth/base, and @web3auth/base-provider"
|
|
8715
|
+
);
|
|
8716
|
+
}
|
|
8717
|
+
const chainConfig = {
|
|
8718
|
+
chainNamespace: CHAIN_NAMESPACES.OTHER,
|
|
8719
|
+
chainId: "algorand",
|
|
8720
|
+
rpcTarget: "https://mainnet-api.algonode.cloud",
|
|
8721
|
+
// Required by Web3Auth, not actually used for signing
|
|
8722
|
+
displayName: "Algorand",
|
|
8723
|
+
blockExplorerUrl: "https://lora.algokit.io/mainnet",
|
|
8724
|
+
ticker: "ALGO",
|
|
8725
|
+
tickerName: "Algorand"
|
|
8726
|
+
};
|
|
8727
|
+
const networkMap = {
|
|
8728
|
+
mainnet: WEB3AUTH_NETWORK.MAINNET,
|
|
8729
|
+
testnet: WEB3AUTH_NETWORK.TESTNET,
|
|
8730
|
+
sapphire_mainnet: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET,
|
|
8731
|
+
sapphire_devnet: WEB3AUTH_NETWORK.SAPPHIRE_DEVNET,
|
|
8732
|
+
cyan: WEB3AUTH_NETWORK.CYAN,
|
|
8733
|
+
aqua: WEB3AUTH_NETWORK.AQUA
|
|
8734
|
+
};
|
|
8735
|
+
const privateKeyProvider = new CommonPrivateKeyProvider({
|
|
8736
|
+
config: { chainConfig }
|
|
8737
|
+
});
|
|
8738
|
+
const web3auth = new Web3Auth({
|
|
8739
|
+
clientId: this.options.clientId,
|
|
8740
|
+
web3AuthNetwork: networkMap[this.options.web3AuthNetwork || "sapphire_mainnet"],
|
|
8741
|
+
privateKeyProvider,
|
|
8742
|
+
uiConfig: this.options.uiConfig
|
|
8743
|
+
});
|
|
8744
|
+
await web3auth.initModal();
|
|
8745
|
+
this.web3auth = web3auth;
|
|
8746
|
+
this.logger.info("Web3Auth client initialized");
|
|
8747
|
+
return web3auth;
|
|
8748
|
+
}
|
|
8749
|
+
/**
|
|
8750
|
+
* Initialize the Web3Auth Single Factor Auth client for custom JWT authentication
|
|
8751
|
+
*/
|
|
8752
|
+
async initializeSFAClient() {
|
|
8753
|
+
this.logger.info("Initializing Web3Auth Single Factor Auth client...");
|
|
8754
|
+
let Web3Auth;
|
|
8755
|
+
let WEB3AUTH_NETWORK;
|
|
8756
|
+
let CommonPrivateKeyProvider;
|
|
8757
|
+
let CHAIN_NAMESPACES;
|
|
8758
|
+
try {
|
|
8759
|
+
const sfa = await import("@web3auth/single-factor-auth");
|
|
8760
|
+
Web3Auth = sfa.Web3Auth;
|
|
8761
|
+
const base = await import("@web3auth/base");
|
|
8762
|
+
WEB3AUTH_NETWORK = base.WEB3AUTH_NETWORK;
|
|
8763
|
+
CHAIN_NAMESPACES = base.CHAIN_NAMESPACES;
|
|
8764
|
+
const baseProvider = await import("@web3auth/base-provider");
|
|
8765
|
+
CommonPrivateKeyProvider = baseProvider.CommonPrivateKeyProvider;
|
|
8766
|
+
} catch {
|
|
8767
|
+
this.logger.error(
|
|
8768
|
+
"Failed to load Web3Auth SFA. Make sure @web3auth/single-factor-auth, @web3auth/base, and @web3auth/base-provider are installed."
|
|
8769
|
+
);
|
|
8770
|
+
throw new Error(
|
|
8771
|
+
"Web3Auth SFA packages not found. Please install @web3auth/single-factor-auth, @web3auth/base, and @web3auth/base-provider"
|
|
8772
|
+
);
|
|
8773
|
+
}
|
|
8774
|
+
const chainConfig = {
|
|
8775
|
+
chainNamespace: CHAIN_NAMESPACES.OTHER,
|
|
8776
|
+
chainId: "algorand",
|
|
8777
|
+
rpcTarget: "https://mainnet-api.algonode.cloud",
|
|
8778
|
+
// Required by Web3Auth, not actually used for signing
|
|
8779
|
+
displayName: "Algorand",
|
|
8780
|
+
blockExplorerUrl: "https://lora.algokit.io/mainnet",
|
|
8781
|
+
ticker: "ALGO",
|
|
8782
|
+
tickerName: "Algorand"
|
|
8783
|
+
};
|
|
8784
|
+
const networkMap = {
|
|
8785
|
+
mainnet: WEB3AUTH_NETWORK.MAINNET,
|
|
8786
|
+
testnet: WEB3AUTH_NETWORK.TESTNET,
|
|
8787
|
+
sapphire_mainnet: WEB3AUTH_NETWORK.SAPPHIRE_MAINNET,
|
|
8788
|
+
sapphire_devnet: WEB3AUTH_NETWORK.SAPPHIRE_DEVNET,
|
|
8789
|
+
cyan: WEB3AUTH_NETWORK.CYAN,
|
|
8790
|
+
aqua: WEB3AUTH_NETWORK.AQUA
|
|
8791
|
+
};
|
|
8792
|
+
const privateKeyProvider = new CommonPrivateKeyProvider({
|
|
8793
|
+
config: { chainConfig }
|
|
8794
|
+
});
|
|
8795
|
+
const web3authSFA = new Web3Auth({
|
|
8796
|
+
clientId: this.options.clientId,
|
|
8797
|
+
web3AuthNetwork: networkMap[this.options.web3AuthNetwork || "sapphire_mainnet"],
|
|
8798
|
+
privateKeyProvider
|
|
8799
|
+
});
|
|
8800
|
+
await web3authSFA.init();
|
|
8801
|
+
this.web3authSFA = web3authSFA;
|
|
8802
|
+
this.logger.info("Web3Auth SFA client initialized");
|
|
8803
|
+
return web3authSFA;
|
|
8804
|
+
}
|
|
8805
|
+
/**
|
|
8806
|
+
* SECURITY: Fetch the private key from Web3Auth and return it in a SecureKeyContainer.
|
|
8807
|
+
* The caller MUST call container.clear() when done.
|
|
8808
|
+
*
|
|
8809
|
+
* @returns SecureKeyContainer holding the private key
|
|
8810
|
+
*/
|
|
8811
|
+
async getSecureKey() {
|
|
8812
|
+
const provider = this.usingSFA ? this.web3authSFA?.provider : this.web3auth?.provider;
|
|
8813
|
+
if (!provider) {
|
|
8814
|
+
throw new Error("Web3Auth not connected");
|
|
8815
|
+
}
|
|
8816
|
+
this.logger.debug("Fetching private key from Web3Auth...");
|
|
8817
|
+
const privateKeyHex = await provider.request({
|
|
8818
|
+
method: "private_key"
|
|
8819
|
+
});
|
|
8820
|
+
if (!privateKeyHex || typeof privateKeyHex !== "string") {
|
|
8821
|
+
throw new Error("Failed to retrieve private key from Web3Auth");
|
|
8822
|
+
}
|
|
8823
|
+
const privateKeyBytes = this.hexToBytes(privateKeyHex);
|
|
8824
|
+
const container = new SecureKeyContainer(privateKeyBytes);
|
|
8825
|
+
zeroMemory(privateKeyBytes);
|
|
8826
|
+
this.logger.debug("Private key retrieved and secured");
|
|
8827
|
+
return container;
|
|
8828
|
+
}
|
|
8829
|
+
/**
|
|
8830
|
+
* Convert a hex string to Uint8Array
|
|
8831
|
+
*/
|
|
8832
|
+
hexToBytes(hex) {
|
|
8833
|
+
const cleanHex = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
8834
|
+
const bytes = new Uint8Array(cleanHex.length / 2);
|
|
8835
|
+
for (let i = 0; i < cleanHex.length; i += 2) {
|
|
8836
|
+
bytes[i / 2] = parseInt(cleanHex.slice(i, i + 2), 16);
|
|
8837
|
+
}
|
|
8838
|
+
return bytes;
|
|
8839
|
+
}
|
|
8840
|
+
/**
|
|
8841
|
+
* Connect to Web3Auth
|
|
8842
|
+
*
|
|
8843
|
+
* @param args - Optional connection arguments
|
|
8844
|
+
* @param args.idToken - JWT token for custom authentication (e.g., Firebase ID token)
|
|
8845
|
+
* @param args.verifierId - User identifier for custom authentication (e.g., email, uid)
|
|
8846
|
+
* @param args.verifier - Custom verifier name (uses options.verifier if not provided)
|
|
8847
|
+
*
|
|
8848
|
+
* @example
|
|
8849
|
+
* // Standard modal connection
|
|
8850
|
+
* await wallet.connect()
|
|
8851
|
+
*
|
|
8852
|
+
* @example
|
|
8853
|
+
* // Custom authentication with Firebase
|
|
8854
|
+
* await wallet.connect({
|
|
8855
|
+
* idToken: firebaseIdToken,
|
|
8856
|
+
* verifierId: user.email,
|
|
8857
|
+
* verifier: 'my-firebase-verifier'
|
|
8858
|
+
* })
|
|
8859
|
+
*/
|
|
8860
|
+
connect = async (args) => {
|
|
8861
|
+
this.logger.info("Connecting to Web3Auth...");
|
|
8862
|
+
try {
|
|
8863
|
+
let provider;
|
|
8864
|
+
const idToken = args?.idToken;
|
|
8865
|
+
const verifierId = args?.verifierId;
|
|
8866
|
+
const verifier = args?.verifier || this.options.verifier;
|
|
8867
|
+
if (idToken && verifierId) {
|
|
8868
|
+
if (!verifier) {
|
|
8869
|
+
throw new Error(
|
|
8870
|
+
"Custom authentication requires a verifier. Provide it in connect() args or options.verifier"
|
|
8871
|
+
);
|
|
8872
|
+
}
|
|
8873
|
+
this.logger.info("Connecting with custom authentication (SFA)...", { verifier, verifierId });
|
|
8874
|
+
const web3authSFA = this.web3authSFA || await this.initializeSFAClient();
|
|
8875
|
+
if (web3authSFA.connected) {
|
|
8876
|
+
this.logger.debug("SFA already connected, logging out first...");
|
|
8877
|
+
try {
|
|
8878
|
+
await web3authSFA.logout();
|
|
8879
|
+
} catch {
|
|
8880
|
+
}
|
|
8881
|
+
}
|
|
8882
|
+
provider = await web3authSFA.connect({
|
|
8883
|
+
verifier,
|
|
8884
|
+
verifierId,
|
|
8885
|
+
idToken
|
|
8886
|
+
});
|
|
8887
|
+
this.usingSFA = true;
|
|
8888
|
+
this.userInfo = { email: verifierId };
|
|
8889
|
+
} else {
|
|
8890
|
+
const web3auth = this.web3auth || await this.initializeClient();
|
|
8891
|
+
provider = await web3auth.connect();
|
|
8892
|
+
this.usingSFA = false;
|
|
8893
|
+
this.userInfo = await web3auth.getUserInfo();
|
|
8894
|
+
this.logger.debug("User info retrieved", { email: this.userInfo.email });
|
|
8895
|
+
}
|
|
8896
|
+
if (!provider) {
|
|
8897
|
+
throw new Error("Failed to connect to Web3Auth");
|
|
8898
|
+
}
|
|
8899
|
+
const keyContainer = await this.getSecureKey();
|
|
8900
|
+
try {
|
|
8901
|
+
const address = await keyContainer.useKey(async (secretKey) => {
|
|
8902
|
+
const account = await deriveAlgorandAccountFromEd25519(secretKey);
|
|
8903
|
+
const addr = account.addr;
|
|
8904
|
+
zeroMemory(account.sk);
|
|
8905
|
+
return addr;
|
|
8906
|
+
});
|
|
8907
|
+
this._address = address;
|
|
8908
|
+
} finally {
|
|
8909
|
+
keyContainer.clear();
|
|
8910
|
+
}
|
|
8911
|
+
const walletAccount = {
|
|
8912
|
+
name: this.userInfo.name || this.userInfo.email || `${this.metadata.name} Account`,
|
|
8913
|
+
address: this._address
|
|
8914
|
+
};
|
|
8915
|
+
const walletState = {
|
|
8916
|
+
accounts: [walletAccount],
|
|
8917
|
+
activeAccount: walletAccount
|
|
8918
|
+
};
|
|
8919
|
+
addWallet(this.store, {
|
|
8920
|
+
walletId: this.id,
|
|
8921
|
+
wallet: walletState
|
|
8922
|
+
});
|
|
8923
|
+
this.logger.info("Connected successfully", { address: this._address });
|
|
8924
|
+
return [walletAccount];
|
|
8925
|
+
} catch (error) {
|
|
8926
|
+
this.logger.error("Error connecting to Web3Auth:", error.message);
|
|
8927
|
+
throw error;
|
|
8928
|
+
}
|
|
8929
|
+
};
|
|
8930
|
+
/**
|
|
8931
|
+
* Disconnect from Web3Auth
|
|
8932
|
+
*/
|
|
8933
|
+
disconnect = async () => {
|
|
8934
|
+
this.logger.info("Disconnecting from Web3Auth...");
|
|
8935
|
+
try {
|
|
8936
|
+
if (this.usingSFA && this.web3authSFA?.connected) {
|
|
8937
|
+
await this.web3authSFA.logout();
|
|
8938
|
+
} else if (this.web3auth?.connected) {
|
|
8939
|
+
await this.web3auth.logout();
|
|
8940
|
+
}
|
|
8941
|
+
} catch (error) {
|
|
8942
|
+
this.logger.warn("Error during Web3Auth logout:", error.message);
|
|
8943
|
+
}
|
|
8944
|
+
this._address = null;
|
|
8945
|
+
this.userInfo = null;
|
|
8946
|
+
this.usingSFA = false;
|
|
8947
|
+
this.onDisconnect();
|
|
8948
|
+
this.logger.info("Disconnected");
|
|
8949
|
+
};
|
|
8950
|
+
/**
|
|
8951
|
+
* Resume session from Web3Auth
|
|
8952
|
+
*
|
|
8953
|
+
* SECURITY: We do NOT cache the private key. On resume, we only verify
|
|
8954
|
+
* the session is still valid and the address matches. The key is only
|
|
8955
|
+
* fetched when actually needed for signing.
|
|
8956
|
+
*/
|
|
8957
|
+
resumeSession = async () => {
|
|
8958
|
+
try {
|
|
8959
|
+
const state = this.store.state;
|
|
8960
|
+
const walletState = state.wallets[this.id];
|
|
8961
|
+
if (!walletState) {
|
|
8962
|
+
this.logger.info("No session to resume");
|
|
8963
|
+
return;
|
|
8964
|
+
}
|
|
8965
|
+
this.logger.info("Resuming Web3Auth session...");
|
|
8966
|
+
const web3auth = this.web3auth || await this.initializeClient();
|
|
8967
|
+
if (!web3auth.connected || !web3auth.provider) {
|
|
8968
|
+
this.logger.warn("Web3Auth session expired, please reconnect");
|
|
8969
|
+
this.onDisconnect();
|
|
8970
|
+
return;
|
|
8971
|
+
}
|
|
8972
|
+
this.userInfo = await web3auth.getUserInfo();
|
|
8973
|
+
const keyContainer = await this.getSecureKey();
|
|
8974
|
+
try {
|
|
8975
|
+
const currentAddress = await keyContainer.useKey(async (secretKey) => {
|
|
8976
|
+
const account = await deriveAlgorandAccountFromEd25519(secretKey);
|
|
8977
|
+
const addr = account.addr;
|
|
8978
|
+
zeroMemory(account.sk);
|
|
8979
|
+
return addr;
|
|
8980
|
+
});
|
|
8981
|
+
this._address = currentAddress;
|
|
8982
|
+
const storedAccount = walletState.accounts[0];
|
|
8983
|
+
if (storedAccount.address !== currentAddress) {
|
|
8984
|
+
this.logger.warn("Session address mismatch, updating", {
|
|
8985
|
+
stored: storedAccount.address,
|
|
8986
|
+
current: currentAddress
|
|
8987
|
+
});
|
|
8988
|
+
const walletAccount = {
|
|
8989
|
+
name: this.userInfo.name || this.userInfo.email || `${this.metadata.name} Account`,
|
|
8990
|
+
address: currentAddress
|
|
8991
|
+
};
|
|
8992
|
+
setAccounts(this.store, {
|
|
8993
|
+
walletId: this.id,
|
|
8994
|
+
accounts: [walletAccount]
|
|
8995
|
+
});
|
|
8996
|
+
}
|
|
8997
|
+
} finally {
|
|
8998
|
+
keyContainer.clear();
|
|
8999
|
+
}
|
|
9000
|
+
this.logger.info("Session resumed successfully");
|
|
9001
|
+
} catch (error) {
|
|
9002
|
+
this.logger.error("Error resuming session:", error.message);
|
|
9003
|
+
this.onDisconnect();
|
|
9004
|
+
throw error;
|
|
9005
|
+
}
|
|
9006
|
+
};
|
|
9007
|
+
/**
|
|
9008
|
+
* Process transactions for signing
|
|
9009
|
+
*/
|
|
9010
|
+
processTxns(txnGroup, indexesToSign) {
|
|
9011
|
+
const txnsToSign = [];
|
|
9012
|
+
txnGroup.forEach((txn, index) => {
|
|
9013
|
+
const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
|
|
9014
|
+
const signer = txn.sender.toString();
|
|
9015
|
+
const canSignTxn = signer === this._address;
|
|
9016
|
+
if (isIndexMatch && canSignTxn) {
|
|
9017
|
+
txnsToSign.push(txn);
|
|
9018
|
+
}
|
|
9019
|
+
});
|
|
9020
|
+
return txnsToSign;
|
|
9021
|
+
}
|
|
9022
|
+
/**
|
|
9023
|
+
* Process encoded transactions for signing
|
|
9024
|
+
*/
|
|
9025
|
+
processEncodedTxns(txnGroup, indexesToSign) {
|
|
9026
|
+
const txnsToSign = [];
|
|
9027
|
+
txnGroup.forEach((txnBuffer, index) => {
|
|
9028
|
+
const decodedObj = import_algosdk11.default.msgpackRawDecode(txnBuffer);
|
|
9029
|
+
const isSigned = isSignedTxn(decodedObj);
|
|
9030
|
+
const txn = isSigned ? import_algosdk11.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk11.default.decodeUnsignedTransaction(txnBuffer);
|
|
9031
|
+
const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
|
|
9032
|
+
const signer = txn.sender.toString();
|
|
9033
|
+
const canSignTxn = !isSigned && signer === this._address;
|
|
9034
|
+
if (isIndexMatch && canSignTxn) {
|
|
9035
|
+
txnsToSign.push(txn);
|
|
9036
|
+
}
|
|
9037
|
+
});
|
|
9038
|
+
return txnsToSign;
|
|
9039
|
+
}
|
|
9040
|
+
/**
|
|
9041
|
+
* Sign transactions
|
|
9042
|
+
*
|
|
9043
|
+
* SECURITY: The private key is fetched fresh, used for signing,
|
|
9044
|
+
* and immediately cleared from memory. The key is never stored
|
|
9045
|
+
* between signing operations.
|
|
9046
|
+
*/
|
|
9047
|
+
signTransactions = async (txnGroup, indexesToSign) => {
|
|
9048
|
+
try {
|
|
9049
|
+
this.logger.debug("Signing transactions...", { txnGroup, indexesToSign });
|
|
9050
|
+
let txnsToSign = [];
|
|
9051
|
+
if (isTransactionArray(txnGroup)) {
|
|
9052
|
+
const flatTxns = flattenTxnGroup(txnGroup);
|
|
9053
|
+
txnsToSign = this.processTxns(flatTxns, indexesToSign);
|
|
9054
|
+
} else {
|
|
9055
|
+
const flatTxns = flattenTxnGroup(txnGroup);
|
|
9056
|
+
txnsToSign = this.processEncodedTxns(flatTxns, indexesToSign);
|
|
9057
|
+
}
|
|
9058
|
+
if (txnsToSign.length === 0) {
|
|
9059
|
+
this.logger.debug("No transactions to sign");
|
|
9060
|
+
return [];
|
|
9061
|
+
}
|
|
9062
|
+
const keyContainer = await this.getSecureKey();
|
|
9063
|
+
let signedTxns = [];
|
|
9064
|
+
try {
|
|
9065
|
+
signedTxns = await keyContainer.useKey(async (secretKey) => {
|
|
9066
|
+
const account = await deriveAlgorandAccountFromEd25519(secretKey);
|
|
9067
|
+
try {
|
|
9068
|
+
const signed = txnsToSign.map((txn) => txn.signTxn(account.sk));
|
|
9069
|
+
return signed;
|
|
9070
|
+
} finally {
|
|
9071
|
+
zeroMemory(account.sk);
|
|
9072
|
+
}
|
|
9073
|
+
});
|
|
9074
|
+
} finally {
|
|
9075
|
+
keyContainer.clear();
|
|
9076
|
+
}
|
|
9077
|
+
this.logger.debug("Transactions signed successfully", { count: signedTxns.length });
|
|
9078
|
+
return signedTxns;
|
|
9079
|
+
} catch (error) {
|
|
9080
|
+
this.logger.error("Error signing transactions:", error.message);
|
|
9081
|
+
throw error;
|
|
9082
|
+
}
|
|
9083
|
+
};
|
|
9084
|
+
};
|
|
9085
|
+
|
|
9086
|
+
// src/wallets/w3wallet.ts
|
|
9087
|
+
var import_algosdk12 = __toESM(require("algosdk"), 1);
|
|
6419
9088
|
var ICON14 = `data:image/svg+xml;base64,${btoa(`
|
|
6420
9089
|
<svg width="860" height="860" viewBox="0 0 860 860" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
6421
9090
|
<rect width="860" height="860" rx="30" fill="#151923"/>
|
|
@@ -6510,9 +9179,9 @@ var W3Wallet = class extends BaseWallet {
|
|
|
6510
9179
|
processEncodedTxns(txnGroup, indexesToSign) {
|
|
6511
9180
|
const txnsToSign = [];
|
|
6512
9181
|
txnGroup.forEach((txnBuffer, index) => {
|
|
6513
|
-
const decodedObj =
|
|
9182
|
+
const decodedObj = import_algosdk12.default.msgpackRawDecode(txnBuffer);
|
|
6514
9183
|
const isSigned = isSignedTxn(decodedObj);
|
|
6515
|
-
const txn = isSigned ?
|
|
9184
|
+
const txn = isSigned ? import_algosdk12.default.decodeSignedTransaction(txnBuffer).txn : import_algosdk12.default.decodeUnsignedTransaction(txnBuffer);
|
|
6516
9185
|
const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
|
|
6517
9186
|
const signer = txn.sender.toString();
|
|
6518
9187
|
const canSignTxn = !isSigned && this.addresses.includes(signer);
|
|
@@ -6565,12 +9234,12 @@ function createWalletMap() {
|
|
|
6565
9234
|
["exodus" /* EXODUS */]: ExodusWallet,
|
|
6566
9235
|
["kibisis" /* KIBISIS */]: KibisisWallet,
|
|
6567
9236
|
["kmd" /* KMD */]: KmdWallet,
|
|
6568
|
-
["liquid" /* LIQUID */]: LiquidWallet,
|
|
6569
9237
|
["lute" /* LUTE */]: LuteWallet,
|
|
6570
9238
|
["magic" /* MAGIC */]: MagicAuth,
|
|
6571
9239
|
["mnemonic" /* MNEMONIC */]: MnemonicWallet,
|
|
6572
9240
|
["pera" /* PERA */]: PeraWallet,
|
|
6573
9241
|
["walletconnect" /* WALLETCONNECT */]: WalletConnect,
|
|
9242
|
+
["web3auth" /* WEB3AUTH */]: Web3AuthWallet,
|
|
6574
9243
|
["w3-wallet" /* W3_WALLET */]: W3Wallet
|
|
6575
9244
|
};
|
|
6576
9245
|
}
|
|
@@ -6617,7 +9286,7 @@ function isSignedTxn(txnObj) {
|
|
|
6617
9286
|
return hasRequiredProps;
|
|
6618
9287
|
}
|
|
6619
9288
|
function isTransaction(item) {
|
|
6620
|
-
return item && typeof item === "object" && "sender" in item && (item.sender instanceof
|
|
9289
|
+
return item && typeof item === "object" && "sender" in item && (item.sender instanceof import_algosdk13.default.Address || typeof item.sender === "string");
|
|
6621
9290
|
}
|
|
6622
9291
|
function isTransactionArray(txnGroup) {
|
|
6623
9292
|
if (!Array.isArray(txnGroup) || txnGroup.length === 0) {
|
|
@@ -6871,7 +9540,7 @@ var WalletManager = class {
|
|
|
6871
9540
|
createAlgodClient(config) {
|
|
6872
9541
|
this.logger.info(`Creating new Algodv2 client...`);
|
|
6873
9542
|
const { token = "", baseServer, port = "", headers = {} } = config;
|
|
6874
|
-
return new
|
|
9543
|
+
return new import_algosdk14.default.Algodv2(token, baseServer, port, headers);
|
|
6875
9544
|
}
|
|
6876
9545
|
getAlgodClient = () => {
|
|
6877
9546
|
return this.algodClient;
|
|
@@ -6998,7 +9667,6 @@ var WalletManager = class {
|
|
|
6998
9667
|
// src/webpack.ts
|
|
6999
9668
|
var webpackFallback = {
|
|
7000
9669
|
"@agoralabs-sh/avm-web-provider": false,
|
|
7001
|
-
"@algorandfoundation/liquid-auth-use-wallet-client": false,
|
|
7002
9670
|
"@blockshake/defly-connect": false,
|
|
7003
9671
|
"@magic-ext/algorand": false,
|
|
7004
9672
|
"@perawallet/connect": false,
|
|
@@ -7023,7 +9691,6 @@ var webpackFallback = {
|
|
|
7023
9691
|
KibisisWallet,
|
|
7024
9692
|
KmdWallet,
|
|
7025
9693
|
LOCAL_STORAGE_MNEMONIC_KEY,
|
|
7026
|
-
LiquidWallet,
|
|
7027
9694
|
LogLevel,
|
|
7028
9695
|
LuteWallet,
|
|
7029
9696
|
MagicAuth,
|
|
@@ -7032,6 +9699,7 @@ var webpackFallback = {
|
|
|
7032
9699
|
NetworkId,
|
|
7033
9700
|
PeraWallet,
|
|
7034
9701
|
ScopeType,
|
|
9702
|
+
SecureKeyContainer,
|
|
7035
9703
|
SessionError,
|
|
7036
9704
|
SignDataError,
|
|
7037
9705
|
SignTxnsError,
|
|
@@ -7040,6 +9708,11 @@ var webpackFallback = {
|
|
|
7040
9708
|
WalletConnect,
|
|
7041
9709
|
WalletId,
|
|
7042
9710
|
WalletManager,
|
|
7043
|
-
|
|
9711
|
+
Web3AuthWallet,
|
|
9712
|
+
webpackFallback,
|
|
9713
|
+
withSecureKey,
|
|
9714
|
+
withSecureKeySync,
|
|
9715
|
+
zeroMemory,
|
|
9716
|
+
zeroString
|
|
7044
9717
|
});
|
|
7045
9718
|
//# sourceMappingURL=index.cjs.map
|