@coinbase/cdp-core 0.0.43 → 0.0.44
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/esm/index.native34.js +1 -1
- package/dist/esm/index.native6.js +119 -122
- package/dist/esm/index.native94.js +1 -1
- package/dist/esm/index.native97.js +10 -79
- package/dist/esm/index.native98.js +79 -10
- package/dist/esm/index.web100.js +92 -19
- package/dist/esm/index.web101.js +18 -115
- package/dist/esm/index.web102.js +117 -9
- package/dist/esm/index.web103.js +10 -79
- package/dist/esm/index.web33.js +1 -1
- package/dist/esm/index.web5.js +119 -122
- package/dist/esm/index.web84.js +6 -6
- package/dist/esm/index.web93.js +1 -1
- package/dist/esm/index.web96.js +77 -19
- package/dist/esm/index.web97.js +21 -10
- package/dist/esm/index.web98.js +9 -19
- package/dist/esm/index.web99.js +15 -89
- package/dist/native/index.native34.js +1 -1
- package/dist/native/index.native6.js +119 -122
- package/dist/native/index.native94.js +1 -1
- package/dist/native/index.native97.js +10 -79
- package/dist/native/index.native98.js +79 -10
- package/dist/web/index.web100.js +92 -19
- package/dist/web/index.web101.js +18 -115
- package/dist/web/index.web102.js +117 -9
- package/dist/web/index.web103.js +10 -79
- package/dist/web/index.web33.js +1 -1
- package/dist/web/index.web5.js +119 -122
- package/dist/web/index.web84.js +6 -6
- package/dist/web/index.web93.js +1 -1
- package/dist/web/index.web96.js +77 -19
- package/dist/web/index.web97.js +21 -10
- package/dist/web/index.web98.js +9 -19
- package/dist/web/index.web99.js +15 -89
- package/package.json +2 -2
package/dist/esm/index.web99.js
CHANGED
|
@@ -1,96 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
break;
|
|
12
|
-
case "encrypt":
|
|
13
|
-
case "decrypt":
|
|
14
|
-
i = "enc";
|
|
15
|
-
break;
|
|
1
|
+
const a = (...o) => {
|
|
2
|
+
const t = o.filter(Boolean);
|
|
3
|
+
if (t.length === 0 || t.length === 1)
|
|
4
|
+
return !0;
|
|
5
|
+
let e;
|
|
6
|
+
for (const s of t) {
|
|
7
|
+
const r = Object.keys(s);
|
|
8
|
+
if (!e || e.size === 0) {
|
|
9
|
+
e = new Set(r);
|
|
10
|
+
continue;
|
|
16
11
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
throw new TypeError(`Invalid key for this operation, its "alg" must be "${r}" when present`);
|
|
22
|
-
if (Array.isArray(e.key_ops)) {
|
|
23
|
-
let i;
|
|
24
|
-
switch (!0) {
|
|
25
|
-
case t === "sign":
|
|
26
|
-
case r === "dir":
|
|
27
|
-
case r.includes("CBC-HS"):
|
|
28
|
-
i = t;
|
|
29
|
-
break;
|
|
30
|
-
case r.startsWith("PBES2"):
|
|
31
|
-
i = "deriveBits";
|
|
32
|
-
break;
|
|
33
|
-
case /^A\d{3}(?:GCM)?(?:KW)?$/.test(r):
|
|
34
|
-
!r.includes("GCM") && r.endsWith("KW") ? i = "unwrapKey" : i = t;
|
|
35
|
-
break;
|
|
36
|
-
case t === "encrypt":
|
|
37
|
-
i = "wrapKey";
|
|
38
|
-
break;
|
|
39
|
-
case t === "decrypt":
|
|
40
|
-
i = r.startsWith("RSA") ? "unwrapKey" : "deriveBits";
|
|
41
|
-
break;
|
|
12
|
+
for (const n of r) {
|
|
13
|
+
if (e.has(n))
|
|
14
|
+
return !1;
|
|
15
|
+
e.add(n);
|
|
42
16
|
}
|
|
43
|
-
if (i && e.key_ops?.includes?.(i) === !1)
|
|
44
|
-
throw new TypeError(`Invalid key for this operation, its "key_ops" must include "${i}" when present`);
|
|
45
17
|
}
|
|
46
18
|
return !0;
|
|
47
|
-
}, h = (r, e, t) => {
|
|
48
|
-
if (!(e instanceof Uint8Array)) {
|
|
49
|
-
if (p(e)) {
|
|
50
|
-
if (a(e) && o(r, e, t))
|
|
51
|
-
return;
|
|
52
|
-
throw new TypeError('JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present');
|
|
53
|
-
}
|
|
54
|
-
if (!c(e))
|
|
55
|
-
throw new TypeError(n(r, e, "CryptoKey", "KeyObject", "JSON Web Key", "Uint8Array"));
|
|
56
|
-
if (e.type !== "secret")
|
|
57
|
-
throw new TypeError(`${s(e)} instances for symmetric algorithms must be of type "secret"`);
|
|
58
|
-
}
|
|
59
|
-
}, m = (r, e, t) => {
|
|
60
|
-
if (p(e))
|
|
61
|
-
switch (t) {
|
|
62
|
-
case "decrypt":
|
|
63
|
-
case "sign":
|
|
64
|
-
if (f(e) && o(r, e, t))
|
|
65
|
-
return;
|
|
66
|
-
throw new TypeError("JSON Web Key for this operation be a private JWK");
|
|
67
|
-
case "encrypt":
|
|
68
|
-
case "verify":
|
|
69
|
-
if (y(e) && o(r, e, t))
|
|
70
|
-
return;
|
|
71
|
-
throw new TypeError("JSON Web Key for this operation be a public JWK");
|
|
72
|
-
}
|
|
73
|
-
if (!c(e))
|
|
74
|
-
throw new TypeError(n(r, e, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
75
|
-
if (e.type === "secret")
|
|
76
|
-
throw new TypeError(`${s(e)} instances for asymmetric algorithms must not be of type "secret"`);
|
|
77
|
-
if (e.type === "public")
|
|
78
|
-
switch (t) {
|
|
79
|
-
case "sign":
|
|
80
|
-
throw new TypeError(`${s(e)} instances for asymmetric algorithm signing must be of type "private"`);
|
|
81
|
-
case "decrypt":
|
|
82
|
-
throw new TypeError(`${s(e)} instances for asymmetric algorithm decryption must be of type "private"`);
|
|
83
|
-
}
|
|
84
|
-
if (e.type === "private")
|
|
85
|
-
switch (t) {
|
|
86
|
-
case "verify":
|
|
87
|
-
throw new TypeError(`${s(e)} instances for asymmetric algorithm verifying must be of type "public"`);
|
|
88
|
-
case "encrypt":
|
|
89
|
-
throw new TypeError(`${s(e)} instances for asymmetric algorithm encryption must be of type "public"`);
|
|
90
|
-
}
|
|
91
|
-
}, d = (r, e, t) => {
|
|
92
|
-
r.startsWith("HS") || r === "dir" || r.startsWith("PBES2") || /^A(?:128|192|256)(?:GCM)?(?:KW)?$/.test(r) || /^A(?:128|192|256)CBC-HS(?:256|384|512)$/.test(r) ? h(r, e, t) : m(r, e, t);
|
|
93
19
|
};
|
|
94
20
|
export {
|
|
95
|
-
|
|
21
|
+
a as default
|
|
96
22
|
};
|
|
@@ -1,106 +1,103 @@
|
|
|
1
1
|
import { b as m } from "./index.native14.js";
|
|
2
|
-
import { configureCdpApiClient as
|
|
3
|
-
import { Keypair as
|
|
4
|
-
import
|
|
5
|
-
import { AuthManager as
|
|
2
|
+
import { configureCdpApiClient as E, setAuthManager as U, initiateAuthentication as T, createEndUserEvmAccount as M, createEndUserEvmSmartAccount as f, createEndUserSolanaAccount as P, verifyEmailAuthentication as j, verifySmsAuthentication as K, signEvmHashWithEndUserAccount as O, signEvmTransactionWithEndUserAccount as x, signSolanaTransactionWithEndUserAccount as b, sendEvmTransactionWithEndUserAccount as C, sendSolanaTransactionWithEndUserAccount as W, signEvmMessageWithEndUserAccount as H, signSolanaMessageWithEndUserAccount as _, signEvmTypedDataWithEndUserAccount as B, sendUserOperationWithEndUserAccount as D, getUserOperationWithEndUserAccount as N, exportEndUserEvmAccount as L, exportEndUserSolanaAccount as z } from "@coinbase/cdp-api-client";
|
|
3
|
+
import { Keypair as y } from "@solana/web3.js";
|
|
4
|
+
import l from "bs58";
|
|
5
|
+
import { AuthManager as F } from "./index.native8.js";
|
|
6
6
|
import { toAuthState as g } from "./index.native15.js";
|
|
7
7
|
import { withAuth as u } from "./index.native16.js";
|
|
8
|
-
import { MockAuthManager as
|
|
8
|
+
import { MockAuthManager as $ } from "./index.native17.js";
|
|
9
9
|
import { mockUser as h } from "./index.native18.js";
|
|
10
|
-
import { getPlatformServices as
|
|
11
|
-
import { isChainSupportedForCDPSends as
|
|
12
|
-
import { getConfig as
|
|
10
|
+
import { getPlatformServices as R, getPlatformCrypto as k } from "./index.native5.js";
|
|
11
|
+
import { isChainSupportedForCDPSends as V } from "./index.native19.js";
|
|
12
|
+
import { getConfig as s, setCoreAuthManager as w, getCoreAuthManager as c, setConfig as q } from "./index.native20.js";
|
|
13
13
|
import "viem";
|
|
14
|
-
import { serializeTransaction as
|
|
14
|
+
import { serializeTransaction as A } from "./index.native21.js";
|
|
15
15
|
const de = async (e) => {
|
|
16
16
|
if (!e.projectId)
|
|
17
17
|
throw new Error("Project ID is required");
|
|
18
18
|
let t;
|
|
19
19
|
try {
|
|
20
|
-
t =
|
|
20
|
+
t = s().projectId !== e.projectId;
|
|
21
21
|
} catch {
|
|
22
22
|
t = !0;
|
|
23
23
|
}
|
|
24
|
-
if (
|
|
25
|
-
w(new
|
|
24
|
+
if (q(e), s().useMock) {
|
|
25
|
+
w(new $(s().projectId));
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
28
|
let r;
|
|
29
29
|
try {
|
|
30
|
-
const
|
|
31
|
-
r =
|
|
32
|
-
getRefreshToken: () =>
|
|
33
|
-
setRefreshToken: (a) =>
|
|
34
|
-
removeRefreshToken: () =>
|
|
35
|
-
} :
|
|
30
|
+
const n = R();
|
|
31
|
+
r = n.secureStorage ? {
|
|
32
|
+
getRefreshToken: () => n.secureStorage.getItem("cdp_refresh_token"),
|
|
33
|
+
setRefreshToken: (a) => n.secureStorage.setItem("cdp_refresh_token", a),
|
|
34
|
+
removeRefreshToken: () => n.secureStorage.removeItem("cdp_refresh_token")
|
|
35
|
+
} : (
|
|
36
|
+
// This is used only in WebKit browsers by virtue of the API
|
|
37
|
+
{
|
|
38
|
+
getRefreshToken: () => n.storage.getItem("cdp_refresh_token"),
|
|
39
|
+
setRefreshToken: (a) => n.storage.setItem("cdp_refresh_token", a),
|
|
40
|
+
removeRefreshToken: () => n.storage.removeItem("cdp_refresh_token")
|
|
41
|
+
}
|
|
42
|
+
);
|
|
36
43
|
} catch {
|
|
37
44
|
r = void 0;
|
|
38
45
|
}
|
|
39
|
-
if (
|
|
40
|
-
debugging:
|
|
41
|
-
basePath:
|
|
46
|
+
if (E({
|
|
47
|
+
debugging: s().debugging,
|
|
48
|
+
basePath: s().basePath,
|
|
42
49
|
refreshTokenStorage: r
|
|
43
50
|
}), t) {
|
|
44
|
-
const
|
|
45
|
-
w(
|
|
51
|
+
const n = new F(s().projectId);
|
|
52
|
+
w(n), U(n);
|
|
46
53
|
}
|
|
47
54
|
await c().ensureInitialized();
|
|
48
|
-
}, me = async (e) =>
|
|
55
|
+
}, me = async (e) => S({
|
|
49
56
|
email: e.email,
|
|
50
57
|
type: "email"
|
|
51
|
-
}), ge = async (e) =>
|
|
58
|
+
}), ge = async (e) => S({
|
|
52
59
|
phoneNumber: e.phoneNumber,
|
|
53
60
|
type: "sms"
|
|
54
|
-
}), pe = async (e) =>
|
|
61
|
+
}), pe = async (e) => v(
|
|
55
62
|
e,
|
|
56
63
|
"Mock email OTP verified",
|
|
57
|
-
(t, r) =>
|
|
58
|
-
),
|
|
64
|
+
(t, r) => j(t, r)
|
|
65
|
+
), fe = async (e) => v(
|
|
59
66
|
e,
|
|
60
67
|
"Mock SMS OTP verified",
|
|
61
|
-
(t, r) =>
|
|
62
|
-
),
|
|
63
|
-
if (
|
|
68
|
+
(t, r) => K(t, r)
|
|
69
|
+
), ye = async () => c().getUser(), le = async () => c().isSignedIn(), he = async () => {
|
|
70
|
+
if (s().useMock) {
|
|
64
71
|
await c().signOut();
|
|
65
72
|
return;
|
|
66
73
|
}
|
|
67
74
|
if (!await c().isSignedIn())
|
|
68
75
|
throw new Error("User not signed in");
|
|
69
76
|
await c().signOut();
|
|
70
|
-
try {
|
|
71
|
-
const t = S();
|
|
72
|
-
if (t.secureStorage)
|
|
73
|
-
try {
|
|
74
|
-
await t.secureStorage.removeItem("cdp_refresh_token");
|
|
75
|
-
} catch (r) {
|
|
76
|
-
console.warn("Failed to clear stored refresh token:", r);
|
|
77
|
-
}
|
|
78
|
-
} catch {
|
|
79
|
-
}
|
|
80
77
|
}, we = async () => c().getToken(), Ie = (e) => {
|
|
81
78
|
c().addAuthStateChangeCallback(e);
|
|
82
|
-
},
|
|
83
|
-
signature: (await
|
|
79
|
+
}, ke = async (e) => s().useMock ? { signature: "0x0" } : u(e, c(), async ({ user: t, walletSecretId: r }) => ({
|
|
80
|
+
signature: (await O(s().projectId, t.userId, {
|
|
84
81
|
hash: e.hash,
|
|
85
82
|
address: e.evmAccount,
|
|
86
83
|
walletSecretId: r
|
|
87
84
|
})).signature
|
|
88
|
-
})), Ae = async (e) =>
|
|
89
|
-
const
|
|
85
|
+
})), Ae = async (e) => s().useMock ? { signedTransaction: "0x0" } : u(e, c(), async ({ user: t, walletSecretId: r }) => {
|
|
86
|
+
const n = A(e.transaction);
|
|
90
87
|
return {
|
|
91
|
-
signedTransaction: (await
|
|
92
|
-
|
|
88
|
+
signedTransaction: (await x(
|
|
89
|
+
s().projectId,
|
|
93
90
|
t.userId,
|
|
94
91
|
{
|
|
95
|
-
transaction:
|
|
92
|
+
transaction: n,
|
|
96
93
|
address: e.evmAccount,
|
|
97
94
|
walletSecretId: r
|
|
98
95
|
}
|
|
99
96
|
)).signedTransaction
|
|
100
97
|
};
|
|
101
|
-
}),
|
|
102
|
-
signedTransaction: (await
|
|
103
|
-
|
|
98
|
+
}), Se = async (e) => s().useMock ? { signedTransaction: "mock-signed-transaction" } : u(e, c(), async ({ user: t, walletSecretId: r }) => ({
|
|
99
|
+
signedTransaction: (await b(
|
|
100
|
+
s().projectId,
|
|
104
101
|
t.userId,
|
|
105
102
|
{
|
|
106
103
|
transaction: e.transaction,
|
|
@@ -108,27 +105,27 @@ const de = async (e) => {
|
|
|
108
105
|
walletSecretId: r
|
|
109
106
|
}
|
|
110
107
|
)).signedTransaction
|
|
111
|
-
})),
|
|
112
|
-
if (!
|
|
108
|
+
})), ve = async (e) => {
|
|
109
|
+
if (!V(e.network))
|
|
113
110
|
throw new Error(`Chain ${e.network} is not supported by the CDP Apis`);
|
|
114
|
-
if (
|
|
111
|
+
if (s().useMock)
|
|
115
112
|
return { transactionHash: "0x0" };
|
|
116
|
-
const t =
|
|
117
|
-
return u(e, c(), async ({ user: r, walletSecretId:
|
|
118
|
-
transactionHash: (await
|
|
119
|
-
|
|
113
|
+
const t = A(e.transaction);
|
|
114
|
+
return u(e, c(), async ({ user: r, walletSecretId: n }) => ({
|
|
115
|
+
transactionHash: (await C(
|
|
116
|
+
s().projectId,
|
|
120
117
|
r.userId,
|
|
121
118
|
{
|
|
122
119
|
transaction: t,
|
|
123
120
|
address: e.evmAccount,
|
|
124
|
-
walletSecretId:
|
|
121
|
+
walletSecretId: n,
|
|
125
122
|
network: e.network
|
|
126
123
|
}
|
|
127
124
|
)).transactionHash
|
|
128
125
|
}));
|
|
129
|
-
}, Ee = async (e) =>
|
|
130
|
-
transactionSignature: (await
|
|
131
|
-
|
|
126
|
+
}, Ee = async (e) => s().useMock ? { transactionSignature: "mock-signature" } : u(e, c(), async ({ user: t, walletSecretId: r }) => ({
|
|
127
|
+
transactionSignature: (await W(
|
|
128
|
+
s().projectId,
|
|
132
129
|
t.userId,
|
|
133
130
|
{
|
|
134
131
|
transaction: e.transaction,
|
|
@@ -137,15 +134,15 @@ const de = async (e) => {
|
|
|
137
134
|
network: e.network
|
|
138
135
|
}
|
|
139
136
|
)).transactionSignature
|
|
140
|
-
})), Ue = async (e) =>
|
|
141
|
-
signature: (await
|
|
137
|
+
})), Ue = async (e) => s().useMock ? { signature: "0x0" } : u(e, c(), async ({ user: t, walletSecretId: r }) => ({
|
|
138
|
+
signature: (await H(s().projectId, t.userId, {
|
|
142
139
|
message: e.message,
|
|
143
140
|
address: e.evmAccount,
|
|
144
141
|
walletSecretId: r
|
|
145
142
|
})).signature
|
|
146
|
-
})), Te = async (e) =>
|
|
147
|
-
signature: (await
|
|
148
|
-
|
|
143
|
+
})), Te = async (e) => s().useMock ? { signature: "mockSignature" } : u(e, c(), async ({ user: t, walletSecretId: r }) => ({
|
|
144
|
+
signature: (await _(
|
|
145
|
+
s().projectId,
|
|
149
146
|
t.userId,
|
|
150
147
|
{
|
|
151
148
|
message: e.message,
|
|
@@ -153,17 +150,17 @@ const de = async (e) => {
|
|
|
153
150
|
walletSecretId: r
|
|
154
151
|
}
|
|
155
152
|
)).signature
|
|
156
|
-
})), Me = async (e) =>
|
|
157
|
-
signature: (await
|
|
153
|
+
})), Me = async (e) => s().useMock ? { signature: "0x0" } : u(e, c(), async ({ user: t, walletSecretId: r }) => ({
|
|
154
|
+
signature: (await B(s().projectId, t.userId, {
|
|
158
155
|
typedData: e.typedData,
|
|
159
156
|
address: e.evmAccount,
|
|
160
157
|
walletSecretId: r
|
|
161
158
|
})).signature
|
|
162
|
-
})), Pe = async (e) =>
|
|
159
|
+
})), Pe = async (e) => s().useMock ? {
|
|
163
160
|
userOperationHash: "0x1234567890123456789012345678901234567890123456789012345678901234"
|
|
164
161
|
} : u(e, c(), async ({ user: t, walletSecretId: r }) => ({
|
|
165
|
-
userOperationHash: (await
|
|
166
|
-
|
|
162
|
+
userOperationHash: (await D(
|
|
163
|
+
s().projectId,
|
|
167
164
|
t.userId,
|
|
168
165
|
e.evmSmartAccount,
|
|
169
166
|
{
|
|
@@ -178,7 +175,7 @@ const de = async (e) => {
|
|
|
178
175
|
paymasterUrl: e.paymasterUrl
|
|
179
176
|
}
|
|
180
177
|
)).userOpHash
|
|
181
|
-
})), je = async (e) =>
|
|
178
|
+
})), je = async (e) => s().useMock ? {
|
|
182
179
|
userOpHash: e.userOperationHash,
|
|
183
180
|
network: e.network,
|
|
184
181
|
calls: [
|
|
@@ -191,19 +188,19 @@ const de = async (e) => {
|
|
|
191
188
|
status: "complete",
|
|
192
189
|
transactionHash: "0x9876543210987654321098765432109876543210987654321098765432109876",
|
|
193
190
|
receipts: []
|
|
194
|
-
} : u(e, c(), async ({ user: t }) => await
|
|
195
|
-
|
|
191
|
+
} : u(e, c(), async ({ user: t }) => await N(
|
|
192
|
+
s().projectId,
|
|
196
193
|
t.userId,
|
|
197
194
|
e.evmSmartAccount,
|
|
198
195
|
e.userOperationHash
|
|
199
196
|
)), Ke = async (e) => {
|
|
200
|
-
if (
|
|
197
|
+
if (s().useMock)
|
|
201
198
|
return {
|
|
202
199
|
privateKey: m.Buffer.from("mock-private-key").toString("hex")
|
|
203
200
|
};
|
|
204
|
-
const t =
|
|
205
|
-
return u(e, c(), async ({ user:
|
|
206
|
-
const o = await
|
|
201
|
+
const t = k(), r = await t.createExportKeyPair();
|
|
202
|
+
return u(e, c(), async ({ user: n, walletSecretId: a }) => {
|
|
203
|
+
const o = await L(s().projectId, n.userId, {
|
|
207
204
|
address: e.evmAccount,
|
|
208
205
|
walletSecretId: a,
|
|
209
206
|
exportEncryptionKey: r.publicKeyBase64
|
|
@@ -216,43 +213,43 @@ const de = async (e) => {
|
|
|
216
213
|
};
|
|
217
214
|
});
|
|
218
215
|
}, Oe = async (e) => {
|
|
219
|
-
if (
|
|
220
|
-
const
|
|
221
|
-
|
|
222
|
-
const o =
|
|
216
|
+
if (s().useMock) {
|
|
217
|
+
const n = m.Buffer.from("mock-private-key").subarray(0, 32), a = m.Buffer.alloc(32);
|
|
218
|
+
n.copy(a);
|
|
219
|
+
const o = y.fromSeed(a), i = m.Buffer.concat([o.secretKey.subarray(0, 32), o.publicKey.toBytes()]);
|
|
223
220
|
return {
|
|
224
|
-
privateKey:
|
|
221
|
+
privateKey: l.encode(i)
|
|
225
222
|
};
|
|
226
223
|
}
|
|
227
|
-
const t =
|
|
228
|
-
return u(e, c(), async ({ user:
|
|
229
|
-
const o = await
|
|
224
|
+
const t = k(), r = await t.createExportKeyPair();
|
|
225
|
+
return u(e, c(), async ({ user: n, walletSecretId: a }) => {
|
|
226
|
+
const o = await z(s().projectId, n.userId, {
|
|
230
227
|
address: e.solanaAccount,
|
|
231
228
|
walletSecretId: a,
|
|
232
229
|
exportEncryptionKey: r.publicKeyBase64
|
|
233
230
|
}), i = await t.decryptWithPrivateKey(
|
|
234
231
|
r.privateKey,
|
|
235
232
|
o.encryptedPrivateKey
|
|
236
|
-
), d =
|
|
233
|
+
), d = y.fromSeed(new Uint8Array(i)), p = m.Buffer.concat([d.secretKey.subarray(0, 32), d.publicKey.toBytes()]);
|
|
237
234
|
return {
|
|
238
|
-
privateKey:
|
|
235
|
+
privateKey: l.encode(p)
|
|
239
236
|
};
|
|
240
237
|
});
|
|
241
|
-
},
|
|
242
|
-
if (
|
|
238
|
+
}, S = async (e) => {
|
|
239
|
+
if (s().useMock)
|
|
243
240
|
return {
|
|
244
241
|
message: "Mock sign in initiated",
|
|
245
242
|
flowId: "mock-flow-id"
|
|
246
243
|
};
|
|
247
244
|
if (await c().isSignedIn())
|
|
248
245
|
throw new Error("User is already authenticated. Please sign out first.");
|
|
249
|
-
const r = await
|
|
246
|
+
const r = await T(s().projectId, e);
|
|
250
247
|
return {
|
|
251
248
|
flowId: r.flowId,
|
|
252
|
-
message: r.message
|
|
249
|
+
message: "message" in r ? r.message : ""
|
|
253
250
|
};
|
|
254
|
-
},
|
|
255
|
-
if (
|
|
251
|
+
}, v = async (e, t, r) => {
|
|
252
|
+
if (s().useMock)
|
|
256
253
|
return await c().setAuthState({
|
|
257
254
|
accessToken: "mock-access-token",
|
|
258
255
|
expiresAt: Date.now() + 1e3 * 60 * 60 * 24,
|
|
@@ -264,7 +261,7 @@ const de = async (e) => {
|
|
|
264
261
|
};
|
|
265
262
|
if (await c().isSignedIn())
|
|
266
263
|
throw new Error("User is already authenticated. Please sign out first.");
|
|
267
|
-
const a = await r(
|
|
264
|
+
const a = await r(s().projectId, {
|
|
268
265
|
flowId: e.flowId,
|
|
269
266
|
otp: e.otp
|
|
270
267
|
});
|
|
@@ -274,12 +271,12 @@ const de = async (e) => {
|
|
|
274
271
|
a.endUser
|
|
275
272
|
);
|
|
276
273
|
await c().setAuthState(o);
|
|
277
|
-
const i =
|
|
274
|
+
const i = s();
|
|
278
275
|
i.ethereum?.createOnLogin && (o = await I(
|
|
279
276
|
a,
|
|
280
277
|
o,
|
|
281
278
|
i.ethereum.createOnLogin
|
|
282
|
-
)), i.solana?.createOnLogin && (o = await
|
|
279
|
+
)), i.solana?.createOnLogin && (o = await G(a, o)), !i.ethereum?.createOnLogin && !i.solana?.createOnLogin && (o = await I(a, o, "eoa"));
|
|
283
280
|
const d = await c().getUser();
|
|
284
281
|
return {
|
|
285
282
|
message: a.message,
|
|
@@ -287,18 +284,18 @@ const de = async (e) => {
|
|
|
287
284
|
isNewUser: a.isNewEndUser
|
|
288
285
|
};
|
|
289
286
|
}, I = async (e, t, r) => {
|
|
290
|
-
let
|
|
287
|
+
let n = t;
|
|
291
288
|
if (!t.user.evmAccounts || t.user.evmAccounts.length === 0)
|
|
292
289
|
try {
|
|
293
290
|
const a = await c().getWalletSecretId();
|
|
294
|
-
let o = await
|
|
291
|
+
let o = await M(s().projectId, t.user.userId, {
|
|
295
292
|
walletSecretId: a
|
|
296
293
|
}), i = !1;
|
|
297
|
-
const d =
|
|
294
|
+
const d = s().ethereum;
|
|
298
295
|
if (d?.createOnLogin === "smart" && (i = d.enableSpendPermissions ?? !1), r === "smart") {
|
|
299
296
|
const [p] = o.evmAccounts;
|
|
300
|
-
o = await
|
|
301
|
-
|
|
297
|
+
o = await f(
|
|
298
|
+
s().projectId,
|
|
302
299
|
t.user.userId,
|
|
303
300
|
{
|
|
304
301
|
owner: p,
|
|
@@ -306,40 +303,40 @@ const de = async (e) => {
|
|
|
306
303
|
}
|
|
307
304
|
);
|
|
308
305
|
}
|
|
309
|
-
|
|
306
|
+
n = g(e.accessToken, e.validUntil, o), await c().setAuthState(n);
|
|
310
307
|
} catch (a) {
|
|
311
308
|
throw new Error(`Failed to create EVM account: ${a}`);
|
|
312
309
|
}
|
|
313
|
-
if (r === "smart" && (!
|
|
310
|
+
if (r === "smart" && (!n.user.evmSmartAccounts || n.user.evmSmartAccounts.length === 0))
|
|
314
311
|
try {
|
|
315
|
-
const [a] =
|
|
316
|
-
|
|
317
|
-
|
|
312
|
+
const [a] = n.user.evmAccounts, o = await f(
|
|
313
|
+
s().projectId,
|
|
314
|
+
n.user.userId,
|
|
318
315
|
{
|
|
319
316
|
owner: a,
|
|
320
317
|
enableSpendPermissions: !1
|
|
321
318
|
// Defaulting to false until the feature is ready.
|
|
322
319
|
}
|
|
323
320
|
);
|
|
324
|
-
|
|
321
|
+
n = g(e.accessToken, e.validUntil, o), await c().setAuthState(n);
|
|
325
322
|
} catch (a) {
|
|
326
323
|
throw new Error(`Failed to create EVM Smart Account: ${a}`);
|
|
327
324
|
}
|
|
328
|
-
return
|
|
329
|
-
},
|
|
325
|
+
return n;
|
|
326
|
+
}, G = async (e, t) => {
|
|
330
327
|
let r = t;
|
|
331
328
|
if (!t.user.solanaAccounts || t.user.solanaAccounts.length === 0)
|
|
332
329
|
try {
|
|
333
|
-
const
|
|
334
|
-
|
|
330
|
+
const n = await c().getWalletSecretId(), a = await P(
|
|
331
|
+
s().projectId,
|
|
335
332
|
t.user.userId,
|
|
336
333
|
{
|
|
337
|
-
walletSecretId:
|
|
334
|
+
walletSecretId: n
|
|
338
335
|
}
|
|
339
336
|
);
|
|
340
337
|
r = g(e.accessToken, e.validUntil, a), await c().setAuthState(r);
|
|
341
|
-
} catch (
|
|
342
|
-
throw new Error(`Failed to create Solana account: ${
|
|
338
|
+
} catch (n) {
|
|
339
|
+
throw new Error(`Failed to create Solana account: ${n}`);
|
|
343
340
|
}
|
|
344
341
|
return r;
|
|
345
342
|
};
|
|
@@ -347,15 +344,15 @@ export {
|
|
|
347
344
|
Ke as exportEvmAccount,
|
|
348
345
|
Oe as exportSolanaAccount,
|
|
349
346
|
we as getAccessToken,
|
|
350
|
-
|
|
347
|
+
ye as getCurrentUser,
|
|
351
348
|
je as getUserOperation,
|
|
352
349
|
de as initialize,
|
|
353
|
-
|
|
350
|
+
le as isSignedIn,
|
|
354
351
|
Ie as onAuthStateChange,
|
|
355
|
-
|
|
352
|
+
ve as sendEvmTransaction,
|
|
356
353
|
Ee as sendSolanaTransaction,
|
|
357
354
|
Pe as sendUserOperation,
|
|
358
|
-
|
|
355
|
+
ke as signEvmHash,
|
|
359
356
|
Ue as signEvmMessage,
|
|
360
357
|
Ae as signEvmTransaction,
|
|
361
358
|
Me as signEvmTypedData,
|
|
@@ -363,7 +360,7 @@ export {
|
|
|
363
360
|
ge as signInWithSms,
|
|
364
361
|
he as signOut,
|
|
365
362
|
Te as signSolanaMessage,
|
|
366
|
-
|
|
363
|
+
Se as signSolanaTransaction,
|
|
367
364
|
pe as verifyEmailOTP,
|
|
368
|
-
|
|
365
|
+
fe as verifySmsOTP
|
|
369
366
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HashMD as D, SHA256_IV as b, Chi as g, Maj as p } from "./index.
|
|
1
|
+
import { HashMD as D, SHA256_IV as b, Chi as g, Maj as p } from "./index.native98.js";
|
|
2
2
|
import { createHasher as u, clean as C, rotr as i } from "./index.native93.js";
|
|
3
3
|
const B = /* @__PURE__ */ Uint32Array.from([
|
|
4
4
|
1116352408,
|