@coinbase/cdp-core 0.0.117 → 0.0.119
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.web10.js +49 -44
- package/dist/esm/index.web107.js +3 -3
- package/dist/esm/index.web110.js +2 -2
- package/dist/esm/index.web114.js +3 -3
- package/dist/esm/index.web126.js +12 -12
- package/dist/esm/index.web127.js +13 -373
- package/dist/esm/index.web128.js +25 -2
- package/dist/esm/index.web129.js +48 -63
- package/dist/esm/index.web130.js +189 -177
- package/dist/esm/index.web131.js +2 -31
- package/dist/esm/index.web132.js +65 -28
- package/dist/esm/index.web133.js +360 -12
- package/dist/esm/index.web134.js +28 -22
- package/dist/esm/index.web135.js +28 -50
- package/dist/esm/index.web138.js +1 -1
- package/dist/esm/index.web139.js +1 -1
- package/dist/esm/index.web140.js +12 -4
- package/dist/esm/index.web141.js +11 -54
- package/dist/esm/index.web142.js +54 -10
- package/dist/esm/index.web143.js +11 -2
- package/dist/esm/index.web144.js +2 -45
- package/dist/esm/index.web145.js +44 -13
- package/dist/esm/index.web146.js +13 -12
- package/dist/esm/index.web147.js +4 -11
- package/dist/esm/index.web148.js +1 -1
- package/dist/esm/index.web150.js +13 -14
- package/dist/esm/index.web151.js +54 -27
- package/dist/esm/index.web152.js +6 -7
- package/dist/esm/index.web153.js +21 -3
- package/dist/esm/index.web154.js +16 -27
- package/dist/esm/index.web155.js +45 -8
- package/dist/esm/index.web156.js +3 -7
- package/dist/esm/index.web157.js +3 -80
- package/dist/esm/index.web158.js +32 -26
- package/dist/esm/index.web159.js +12 -3
- package/dist/esm/index.web160.js +4 -15
- package/dist/esm/index.web161.js +28 -4
- package/dist/esm/index.web162.js +6 -14
- package/dist/esm/index.web163.js +31 -18
- package/dist/esm/index.web164.js +9 -58
- package/dist/esm/index.web165.js +55 -17
- package/dist/esm/index.web166.js +41 -22
- package/dist/esm/index.web167.js +127 -8
- package/dist/esm/index.web168.js +102 -40
- package/dist/esm/index.web169.js +6 -7
- package/dist/esm/index.web170.js +3 -21
- package/dist/esm/index.web171.js +79 -2
- package/dist/esm/index.web172.js +2 -2
- package/dist/esm/index.web173.js +2 -14
- package/dist/esm/index.web174.js +33 -51
- package/dist/esm/index.web175.js +6 -6
- package/dist/esm/index.web176.js +32 -19
- package/dist/esm/index.web177.js +14 -17
- package/dist/esm/index.web178.js +30 -41
- package/dist/esm/index.web179.js +18 -3
- package/dist/esm/index.web180.js +8 -3
- package/dist/esm/index.web181.js +9 -33
- package/dist/esm/index.web182.js +11 -12
- package/dist/esm/index.web183.js +13 -4
- package/dist/esm/index.web184.js +5 -28
- package/dist/esm/index.web185.js +5 -7
- package/dist/esm/index.web186.js +10 -32
- package/dist/esm/index.web187.js +2 -13
- package/dist/esm/index.web188.js +2 -56
- package/dist/esm/index.web189.js +14 -42
- package/dist/esm/index.web190.js +27 -126
- package/dist/esm/index.web191.js +7 -104
- package/dist/esm/index.web192.js +3 -6
- package/dist/esm/index.web193.js +29 -3
- package/dist/esm/index.web194.js +8 -78
- package/dist/esm/index.web195.js +8 -2
- package/dist/esm/index.web196.js +81 -2
- package/dist/esm/index.web197.js +26 -35
- package/dist/esm/index.web198.js +3 -6
- package/dist/esm/index.web199.js +15 -34
- package/dist/esm/index.web200.js +4 -14
- package/dist/esm/index.web201.js +14 -34
- package/dist/esm/index.web202.js +18 -17
- package/dist/esm/index.web203.js +61 -8
- package/dist/esm/index.web204.js +17 -10
- package/dist/esm/index.web205.js +23 -11
- package/dist/esm/index.web206.js +8 -13
- package/dist/esm/index.web207.js +42 -5
- package/dist/esm/index.web208.js +8 -5
- package/dist/esm/index.web209.js +20 -10
- package/dist/esm/index.web21.js +16 -5
- package/dist/esm/index.web210.js +104 -2
- package/dist/esm/index.web211.js +77 -107
- package/dist/esm/index.web212.js +79 -2
- package/dist/esm/index.web213.js +1 -1
- package/dist/esm/index.web217.js +1 -1
- package/dist/esm/index.web219.js +106 -101
- package/dist/esm/index.web220.js +2 -79
- package/dist/esm/index.web221.js +2 -79
- package/dist/esm/index.web222.js +20 -7
- package/dist/esm/index.web223.js +2 -2
- package/dist/esm/index.web224.js +19 -360
- package/dist/esm/index.web225.js +32 -852
- package/dist/esm/index.web226.js +6 -38
- package/dist/esm/index.web227.js +39 -2
- package/dist/esm/index.web228.js +2 -70
- package/dist/esm/index.web229.js +66 -31
- package/dist/esm/index.web230.js +33 -13
- package/dist/esm/index.web231.js +12 -18
- package/dist/esm/index.web232.js +8 -2
- package/dist/esm/index.web233.js +2 -20
- package/dist/esm/index.web234.js +356 -28
- package/dist/esm/index.web235.js +852 -6
- package/dist/esm/index.web236.js +1 -1
- package/dist/esm/index.web239.js +1 -1
- package/dist/esm/index.web244.js +1 -1
- package/dist/esm/index.web245.js +1 -1
- package/dist/esm/index.web246.js +2 -2
- package/dist/esm/index.web247.js +2 -2
- package/dist/esm/index.web248.js +2 -2
- package/dist/esm/index.web3.js +1 -1
- package/dist/esm/index.web64.js +24 -22
- package/dist/esm/index.web65.js +13 -17
- package/dist/esm/index.web8.js +26 -12
- package/dist/esm/index.web9.js +1 -1
- package/dist/native/index.native11.js +1 -1
- package/dist/native/index.native112.js +2 -2
- package/dist/native/index.native116.js +3 -3
- package/dist/native/index.native12.js +50 -45
- package/dist/native/index.native129.js +371 -100
- package/dist/native/index.native130.js +2 -379
- package/dist/native/index.native131.js +65 -28
- package/dist/native/index.native132.js +364 -28
- package/dist/native/index.native133.js +108 -2
- package/dist/native/index.native134.js +28 -65
- package/dist/native/index.native135.js +28 -364
- package/dist/native/index.native136.js +1 -1
- package/dist/native/index.native138.js +4 -4
- package/dist/native/index.native141.js +1 -1
- package/dist/native/index.native142.js +1 -1
- package/dist/native/index.native143.js +1 -1
- package/dist/native/index.native145.js +5 -2
- package/dist/native/index.native146.js +13 -2
- package/dist/native/index.native147.js +11 -4
- package/dist/native/index.native148.js +53 -11
- package/dist/native/index.native149.js +10 -11
- package/dist/native/index.native150.js +2 -55
- package/dist/native/index.native151.js +45 -11
- package/dist/native/index.native152.js +14 -2
- package/dist/native/index.native153.js +2 -45
- package/dist/native/index.native154.js +2 -14
- package/dist/native/index.native162.js +1 -1
- package/dist/native/index.native174.js +1 -1
- package/dist/native/index.native199.js +2 -2
- package/dist/native/index.native207.js +2 -2
- package/dist/native/index.native221.js +1 -1
- package/dist/native/index.native23.js +16 -5
- package/dist/native/index.native241.js +46 -3
- package/dist/native/index.native242.js +3 -46
- package/dist/native/index.native249.js +1 -1
- package/dist/native/index.native252.js +1 -1
- package/dist/native/index.native255.js +78 -14
- package/dist/native/index.native256.js +14 -78
- package/dist/native/index.native66.js +24 -22
- package/dist/native/index.native67.js +15 -19
- package/dist/native/index.native8.js +16 -3
- package/dist/native/index.native86.js +1 -1
- package/dist/native/index.native9.js +21 -8
- package/dist/native-types/actions/createBitcoinAccount.d.ts +5 -2
- package/dist/native-types/actions/getCurrentUser.d.ts +18 -1
- package/dist/native-types/actions/signBitcoinHash.d.ts +7 -5
- package/dist/native-types/core.d.ts +1 -1
- package/dist/native-types/platform/types.d.ts +25 -0
- package/dist/native-types/types.d.ts +2 -2
- package/dist/native-types/version.d.ts +1 -1
- package/dist/types/actions/createBitcoinAccount.d.ts +5 -2
- package/dist/types/actions/getCurrentUser.d.ts +18 -1
- package/dist/types/actions/signBitcoinHash.d.ts +7 -5
- package/dist/types/core.d.ts +1 -1
- package/dist/types/platform/types.d.ts +25 -0
- package/dist/types/types.d.ts +2 -2
- package/dist/types/version.d.ts +1 -1
- package/dist/web/index.web10.js +49 -44
- package/dist/web/index.web107.js +3 -3
- package/dist/web/index.web110.js +2 -2
- package/dist/web/index.web114.js +3 -3
- package/dist/web/index.web126.js +12 -12
- package/dist/web/index.web127.js +13 -373
- package/dist/web/index.web128.js +25 -2
- package/dist/web/index.web129.js +48 -63
- package/dist/web/index.web130.js +189 -177
- package/dist/web/index.web131.js +2 -31
- package/dist/web/index.web132.js +65 -28
- package/dist/web/index.web133.js +360 -12
- package/dist/web/index.web134.js +28 -22
- package/dist/web/index.web135.js +28 -50
- package/dist/web/index.web138.js +1 -1
- package/dist/web/index.web139.js +1 -1
- package/dist/web/index.web140.js +12 -4
- package/dist/web/index.web141.js +11 -54
- package/dist/web/index.web142.js +54 -10
- package/dist/web/index.web143.js +11 -2
- package/dist/web/index.web144.js +2 -45
- package/dist/web/index.web145.js +44 -13
- package/dist/web/index.web146.js +13 -12
- package/dist/web/index.web147.js +4 -11
- package/dist/web/index.web148.js +1 -1
- package/dist/web/index.web150.js +13 -14
- package/dist/web/index.web151.js +54 -27
- package/dist/web/index.web152.js +6 -7
- package/dist/web/index.web153.js +21 -3
- package/dist/web/index.web154.js +16 -27
- package/dist/web/index.web155.js +45 -8
- package/dist/web/index.web156.js +3 -7
- package/dist/web/index.web157.js +3 -80
- package/dist/web/index.web158.js +32 -26
- package/dist/web/index.web159.js +12 -3
- package/dist/web/index.web160.js +4 -15
- package/dist/web/index.web161.js +28 -4
- package/dist/web/index.web162.js +6 -14
- package/dist/web/index.web163.js +31 -18
- package/dist/web/index.web164.js +9 -58
- package/dist/web/index.web165.js +55 -17
- package/dist/web/index.web166.js +41 -22
- package/dist/web/index.web167.js +127 -8
- package/dist/web/index.web168.js +102 -40
- package/dist/web/index.web169.js +6 -7
- package/dist/web/index.web170.js +3 -21
- package/dist/web/index.web171.js +79 -2
- package/dist/web/index.web172.js +2 -2
- package/dist/web/index.web173.js +2 -14
- package/dist/web/index.web174.js +33 -51
- package/dist/web/index.web175.js +6 -6
- package/dist/web/index.web176.js +32 -19
- package/dist/web/index.web177.js +14 -17
- package/dist/web/index.web178.js +30 -41
- package/dist/web/index.web179.js +18 -3
- package/dist/web/index.web180.js +8 -3
- package/dist/web/index.web181.js +9 -33
- package/dist/web/index.web182.js +11 -12
- package/dist/web/index.web183.js +13 -4
- package/dist/web/index.web184.js +5 -28
- package/dist/web/index.web185.js +5 -7
- package/dist/web/index.web186.js +10 -32
- package/dist/web/index.web187.js +2 -13
- package/dist/web/index.web188.js +2 -56
- package/dist/web/index.web189.js +14 -42
- package/dist/web/index.web190.js +27 -126
- package/dist/web/index.web191.js +7 -104
- package/dist/web/index.web192.js +3 -6
- package/dist/web/index.web193.js +29 -3
- package/dist/web/index.web194.js +8 -78
- package/dist/web/index.web195.js +8 -2
- package/dist/web/index.web196.js +81 -2
- package/dist/web/index.web197.js +26 -35
- package/dist/web/index.web198.js +3 -6
- package/dist/web/index.web199.js +15 -34
- package/dist/web/index.web200.js +4 -14
- package/dist/web/index.web201.js +14 -34
- package/dist/web/index.web202.js +18 -17
- package/dist/web/index.web203.js +61 -8
- package/dist/web/index.web204.js +17 -10
- package/dist/web/index.web205.js +23 -11
- package/dist/web/index.web206.js +8 -13
- package/dist/web/index.web207.js +42 -5
- package/dist/web/index.web208.js +8 -5
- package/dist/web/index.web209.js +20 -10
- package/dist/web/index.web21.js +16 -5
- package/dist/web/index.web210.js +104 -2
- package/dist/web/index.web211.js +77 -107
- package/dist/web/index.web212.js +79 -2
- package/dist/web/index.web213.js +1 -1
- package/dist/web/index.web217.js +1 -1
- package/dist/web/index.web219.js +106 -101
- package/dist/web/index.web220.js +2 -79
- package/dist/web/index.web221.js +2 -79
- package/dist/web/index.web222.js +20 -7
- package/dist/web/index.web223.js +2 -2
- package/dist/web/index.web224.js +19 -360
- package/dist/web/index.web225.js +32 -852
- package/dist/web/index.web226.js +6 -38
- package/dist/web/index.web227.js +39 -2
- package/dist/web/index.web228.js +2 -70
- package/dist/web/index.web229.js +66 -31
- package/dist/web/index.web230.js +33 -13
- package/dist/web/index.web231.js +12 -18
- package/dist/web/index.web232.js +8 -2
- package/dist/web/index.web233.js +2 -20
- package/dist/web/index.web234.js +356 -28
- package/dist/web/index.web235.js +852 -6
- package/dist/web/index.web236.js +1 -1
- package/dist/web/index.web239.js +1 -1
- package/dist/web/index.web244.js +1 -1
- package/dist/web/index.web245.js +1 -1
- package/dist/web/index.web246.js +2 -2
- package/dist/web/index.web247.js +2 -2
- package/dist/web/index.web248.js +2 -2
- package/dist/web/index.web3.js +1 -1
- package/dist/web/index.web64.js +24 -22
- package/dist/web/index.web65.js +13 -17
- package/dist/web/index.web8.js +26 -12
- package/dist/web/index.web9.js +1 -1
- package/dist/web-types/actions/createBitcoinAccount.d.ts +5 -2
- package/dist/web-types/actions/getCurrentUser.d.ts +18 -1
- package/dist/web-types/actions/signBitcoinHash.d.ts +7 -5
- package/dist/web-types/core.d.ts +1 -1
- package/dist/web-types/platform/types.d.ts +25 -0
- package/dist/web-types/types.d.ts +2 -2
- package/dist/web-types/version.d.ts +1 -1
- package/package.json +2 -2
package/dist/web/index.web236.js
CHANGED
package/dist/web/index.web239.js
CHANGED
package/dist/web/index.web244.js
CHANGED
package/dist/web/index.web245.js
CHANGED
package/dist/web/index.web246.js
CHANGED
package/dist/web/index.web247.js
CHANGED
package/dist/web/index.web248.js
CHANGED
package/dist/web/index.web3.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { __require as r } from "./index.
|
|
1
|
+
import { __require as r } from "./index.web232.js";
|
|
2
2
|
r();
|
package/dist/web/index.web64.js
CHANGED
|
@@ -1,37 +1,39 @@
|
|
|
1
|
-
import { createEndUserBtcAccount as
|
|
2
|
-
import { Analytics as
|
|
1
|
+
import { createEndUserBtcAccount as h } from "@coinbase/cdp-api-client";
|
|
2
|
+
import { Analytics as p } from "./index.web2.js";
|
|
3
3
|
import "./index.web3.js";
|
|
4
4
|
import { toAuthStateUser as m } from "./index.web101.js";
|
|
5
|
-
import { InternalError as
|
|
6
|
-
import { validateUserAuthState as
|
|
7
|
-
import { getCoreAuthManager as
|
|
8
|
-
async function U(
|
|
9
|
-
|
|
10
|
-
const t =
|
|
5
|
+
import { InternalError as o } from "./index.web88.js";
|
|
6
|
+
import { validateUserAuthState as w } from "./index.web102.js";
|
|
7
|
+
import { getCoreAuthManager as b, getConfig as A } from "./index.web74.js";
|
|
8
|
+
async function U(r) {
|
|
9
|
+
p.sendActionCallEvent({ name: "create_bitcoin_account" });
|
|
10
|
+
const t = b(), { user: c, authState: s } = w(
|
|
11
11
|
t.getUser(),
|
|
12
12
|
t.getAuthState()
|
|
13
|
-
),
|
|
13
|
+
), n = await h(
|
|
14
14
|
c.userId,
|
|
15
15
|
{
|
|
16
16
|
walletSecretId: await t.getWalletSecretId(),
|
|
17
|
-
addressType:
|
|
18
|
-
network:
|
|
17
|
+
addressType: r?.addressType ?? "segwit",
|
|
18
|
+
network: r?.network ?? "bitcoin-testnet"
|
|
19
19
|
},
|
|
20
|
-
{ projectID:
|
|
21
|
-
|
|
22
|
-
),
|
|
20
|
+
{ projectID: A().projectId },
|
|
21
|
+
r?.idempotencyKey
|
|
22
|
+
), i = m(n), u = t.getAuthState() ?? s;
|
|
23
23
|
await t.setAuthState({
|
|
24
|
-
...
|
|
25
|
-
user:
|
|
24
|
+
...u,
|
|
25
|
+
user: i
|
|
26
26
|
});
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (!o)
|
|
31
|
-
throw new l(
|
|
27
|
+
const d = new Set(c.btcAccountObjects?.map((a) => a.xpubHash) ?? []), e = (n.btcAccountObjects ?? []).find((a) => !d.has(a.xpubHash));
|
|
28
|
+
if (!e)
|
|
29
|
+
throw new o(
|
|
32
30
|
"Bitcoin account was not created. Check the network log for more details."
|
|
33
31
|
);
|
|
34
|
-
|
|
32
|
+
if (!e.xpub)
|
|
33
|
+
throw new o(
|
|
34
|
+
"Bitcoin account was created but the server did not return its extended public key (xpub)."
|
|
35
|
+
);
|
|
36
|
+
return { ...e, xpub: e.xpub };
|
|
35
37
|
}
|
|
36
38
|
export {
|
|
37
39
|
U as createBitcoinAccount
|
package/dist/web/index.web65.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { signBtcHashWithEndUserAccount as
|
|
2
|
-
import { Analytics as
|
|
1
|
+
import { signBtcHashWithEndUserAccount as c } from "@coinbase/cdp-api-client";
|
|
2
|
+
import { Analytics as i } from "./index.web2.js";
|
|
3
3
|
import "./index.web3.js";
|
|
4
|
-
import { withAuth as
|
|
5
|
-
import { getConfig as
|
|
4
|
+
import { withAuth as s } from "./index.web97.js";
|
|
5
|
+
import { getConfig as e, getCoreAuthManager as o } from "./index.web74.js";
|
|
6
6
|
import "viem";
|
|
7
|
-
import { withMfa as
|
|
7
|
+
import { withMfa as h } from "./index.web82.js";
|
|
8
8
|
import "jose";
|
|
9
9
|
import "./index.web98.js";
|
|
10
10
|
import "./index.web99.js";
|
|
@@ -12,26 +12,22 @@ import "@solana/web3.js";
|
|
|
12
12
|
import "bs58";
|
|
13
13
|
import "./index.web93.js";
|
|
14
14
|
const j = async (t) => {
|
|
15
|
-
if (
|
|
15
|
+
if (i.sendActionCallEvent({ name: "sign_bitcoin_hash" }), !/^[0-9a-fA-F]{64}$/.test(t.hash))
|
|
16
16
|
throw new Error("hash must be a 64-character hex string with no 0x prefix");
|
|
17
|
-
return
|
|
18
|
-
() =>
|
|
19
|
-
|
|
20
|
-
if (!e.btcAccountObjects?.find(
|
|
21
|
-
(s) => s.network === r && s.addressType === n
|
|
22
|
-
))
|
|
17
|
+
return e().useMock ? { signature: "3045022100" + "a".repeat(64) + "0220" + "b".repeat(64) } : h(
|
|
18
|
+
() => s(t, o(), async ({ user: r, walletSecretId: a }) => {
|
|
19
|
+
if (!r.btcAccountObjects?.find((n) => n.xpubHash === t.xpubHash))
|
|
23
20
|
throw new Error("Bitcoin account not found");
|
|
24
|
-
return { signature: (await
|
|
25
|
-
|
|
21
|
+
return { signature: (await c(
|
|
22
|
+
r.userId,
|
|
26
23
|
{
|
|
27
24
|
walletSecretId: a,
|
|
28
|
-
|
|
29
|
-
network: r,
|
|
25
|
+
xpubHash: t.xpubHash,
|
|
30
26
|
change: t.change,
|
|
31
27
|
addressIndex: t.addressIndex,
|
|
32
28
|
hash: t.hash
|
|
33
29
|
},
|
|
34
|
-
{ projectID:
|
|
30
|
+
{ projectID: e().projectId },
|
|
35
31
|
t.idempotencyKey
|
|
36
32
|
)).signature };
|
|
37
33
|
})
|
package/dist/web/index.web8.js
CHANGED
|
@@ -7,11 +7,25 @@ const l = {
|
|
|
7
7
|
* @param key - The storage key.
|
|
8
8
|
* @returns Promise that resolves to the value.
|
|
9
9
|
*/
|
|
10
|
-
async getItem(
|
|
10
|
+
async getItem(t) {
|
|
11
|
+
return (await this.getItemWithOutcome(t)).value;
|
|
12
|
+
},
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves a value from localStorage with read outcome metadata.
|
|
15
|
+
*
|
|
16
|
+
* @param key - The storage key.
|
|
17
|
+
* @returns Promise that resolves to the stored value and read outcome.
|
|
18
|
+
*/
|
|
19
|
+
async getItemWithOutcome(t) {
|
|
11
20
|
try {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
21
|
+
const e = localStorage.getItem(t);
|
|
22
|
+
return e === null ? { value: null, outcome: "not_found" } : { value: e, outcome: "found" };
|
|
23
|
+
} catch (e) {
|
|
24
|
+
return console.warn(`Failed to get item from localStorage: ${e}`), {
|
|
25
|
+
value: null,
|
|
26
|
+
outcome: "error",
|
|
27
|
+
errorMessage: e instanceof Error ? e.message : String(e)
|
|
28
|
+
};
|
|
15
29
|
}
|
|
16
30
|
},
|
|
17
31
|
/**
|
|
@@ -21,9 +35,9 @@ const l = {
|
|
|
21
35
|
* @param value - The value to store.
|
|
22
36
|
* @returns Promise that resolves when the value is stored.
|
|
23
37
|
*/
|
|
24
|
-
async setItem(
|
|
38
|
+
async setItem(t, e) {
|
|
25
39
|
try {
|
|
26
|
-
localStorage.setItem(
|
|
40
|
+
localStorage.setItem(t, e);
|
|
27
41
|
} catch (o) {
|
|
28
42
|
throw console.warn(`Failed to set item in localStorage: ${o}`), o;
|
|
29
43
|
}
|
|
@@ -34,11 +48,11 @@ const l = {
|
|
|
34
48
|
* @param key - The storage key.
|
|
35
49
|
* @returns Promise that resolves when the value is removed.
|
|
36
50
|
*/
|
|
37
|
-
async removeItem(
|
|
51
|
+
async removeItem(t) {
|
|
38
52
|
try {
|
|
39
|
-
localStorage.removeItem(
|
|
40
|
-
} catch (
|
|
41
|
-
throw console.warn(`Failed to remove item from localStorage: ${
|
|
53
|
+
localStorage.removeItem(t);
|
|
54
|
+
} catch (e) {
|
|
55
|
+
throw console.warn(`Failed to remove item from localStorage: ${e}`), e;
|
|
42
56
|
}
|
|
43
57
|
},
|
|
44
58
|
/**
|
|
@@ -49,8 +63,8 @@ const l = {
|
|
|
49
63
|
async clear() {
|
|
50
64
|
try {
|
|
51
65
|
localStorage.clear();
|
|
52
|
-
} catch (
|
|
53
|
-
throw console.warn(`Failed to clear localStorage: ${
|
|
66
|
+
} catch (t) {
|
|
67
|
+
throw console.warn(`Failed to clear localStorage: ${t}`), t;
|
|
54
68
|
}
|
|
55
69
|
}
|
|
56
70
|
};
|
package/dist/web/index.web9.js
CHANGED
|
@@ -11,9 +11,12 @@ export type CreateBitcoinAccountOptions = {
|
|
|
11
11
|
idempotencyKey?: string;
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
|
-
* The result of creating a Bitcoin HD account.
|
|
14
|
+
* The result of creating a Bitcoin HD account. The extended public key (xpub) is always present,
|
|
15
|
+
* since the create response includes it and the caller needs it to derive child addresses.
|
|
15
16
|
*/
|
|
16
|
-
export type CreateBitcoinAccountResult = EndUserBtcAccount
|
|
17
|
+
export type CreateBitcoinAccountResult = EndUserBtcAccount & {
|
|
18
|
+
xpub: string;
|
|
19
|
+
};
|
|
17
20
|
/**
|
|
18
21
|
* Creates a Bitcoin HD (Hierarchical Deterministic) account for the current user.
|
|
19
22
|
* The account uses BIP-84 derivation (segwit) and returns an extended public key (xpub)
|
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
import { User } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Options for getting the current user.
|
|
4
|
+
*/
|
|
5
|
+
export type GetCurrentUserOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* When true, re-fetches the user from the API with each Bitcoin account's raw extended public
|
|
8
|
+
* key (xpub) included in `btcAccountObjects`. By default the xpubs are omitted (hash-only), so
|
|
9
|
+
* request this when you need to derive child addresses. Ignored if no user is signed in.
|
|
10
|
+
*/
|
|
11
|
+
includeBtcXpubs?: boolean;
|
|
12
|
+
};
|
|
2
13
|
/**
|
|
3
14
|
* Gets the currently signed-in user, if any.
|
|
4
15
|
*
|
|
5
16
|
* @example
|
|
6
17
|
* ```typescript lines
|
|
7
18
|
* const user = await getCurrentUser();
|
|
19
|
+
*
|
|
20
|
+
* // Include Bitcoin xpubs so addresses can be derived:
|
|
21
|
+
* const userWithXpubs = await getCurrentUser({ includeBtcXpubs: true });
|
|
8
22
|
* ```
|
|
23
|
+
* @param options - Optional settings controlling what is returned.
|
|
9
24
|
* @returns The currently signed-in user, or null if no user is signed in.
|
|
25
|
+
* @throws When `includeBtcXpubs` is true and the network request to re-fetch the user fails.
|
|
26
|
+
* The default (cached) read never throws.
|
|
10
27
|
*/
|
|
11
|
-
export declare const getCurrentUser: () => Promise<User | null>;
|
|
28
|
+
export declare const getCurrentUser: (options?: GetCurrentUserOptions) => Promise<User | null>;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SignBtcHashWithEndUserAccountBodyChange } from '@coinbase/cdp-api-client';
|
|
2
2
|
/**
|
|
3
3
|
* Options for signing a Bitcoin sighash.
|
|
4
4
|
*/
|
|
5
5
|
export type SignBitcoinHashOptions = {
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Selects which Bitcoin account to sign with, as the `xpubHash` from the account's entry in
|
|
8
|
+
* `btcAccountObjects`. Resolved server-side against the user's own accounts; an unmatched hash
|
|
9
|
+
* fails with a not-found error (there is no fallback to a default account).
|
|
10
|
+
*/
|
|
11
|
+
xpubHash: string;
|
|
10
12
|
/** BIP-32 change level: 0 for external (receive) addresses, 1 for internal (change) addresses. */
|
|
11
13
|
change: SignBtcHashWithEndUserAccountBodyChange;
|
|
12
14
|
/** BIP-32 address index — must match the index used to derive the address controlling the UTXO. */
|
package/dist/web-types/core.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export { verifyOAuth } from './actions/verifyOAuth.js';
|
|
|
9
9
|
export { verifySiweSignature, type VerifySiweSignatureOptions, type VerifySiweSignatureResult, } from './actions/verifySiweSignature.js';
|
|
10
10
|
export { verifyTelegramOAuth } from './actions/verifyTelegramOAuth.js';
|
|
11
11
|
export { authenticateWithJWT } from './actions/authenticateWithJWT.js';
|
|
12
|
-
export { getCurrentUser } from './actions/getCurrentUser.js';
|
|
12
|
+
export { getCurrentUser, type GetCurrentUserOptions } from './actions/getCurrentUser.js';
|
|
13
13
|
export { isSignedIn } from './actions/isSignedIn.js';
|
|
14
14
|
export { signOut } from './actions/signOut.js';
|
|
15
15
|
export { getAccessToken } from './actions/getAccessToken.js';
|
|
@@ -58,6 +58,13 @@ export interface PlatformStorage {
|
|
|
58
58
|
* @returns Promise that resolves to the stored value or null if not found.
|
|
59
59
|
*/
|
|
60
60
|
getItem(key: string): Promise<string | null>;
|
|
61
|
+
/**
|
|
62
|
+
* Retrieves a value from storage with read outcome metadata.
|
|
63
|
+
*
|
|
64
|
+
* @param key - The storage key.
|
|
65
|
+
* @returns Promise that resolves to the stored value and read outcome.
|
|
66
|
+
*/
|
|
67
|
+
getItemWithOutcome(key: string): Promise<StorageReadResult>;
|
|
61
68
|
/**
|
|
62
69
|
* Stores a value in storage.
|
|
63
70
|
*
|
|
@@ -94,6 +101,13 @@ export interface PlatformSecureStorage {
|
|
|
94
101
|
* @returns Promise that resolves to the stored value or null if not found.
|
|
95
102
|
*/
|
|
96
103
|
getItem(key: string): Promise<string | null>;
|
|
104
|
+
/**
|
|
105
|
+
* Retrieves a value from secure storage with read outcome metadata.
|
|
106
|
+
*
|
|
107
|
+
* @param key - The storage key.
|
|
108
|
+
* @returns Promise that resolves to the stored value and read outcome.
|
|
109
|
+
*/
|
|
110
|
+
getItemWithOutcome(key: string): Promise<StorageReadResult>;
|
|
97
111
|
/**
|
|
98
112
|
* Stores a value in secure storage.
|
|
99
113
|
*
|
|
@@ -116,6 +130,17 @@ export interface PlatformSecureStorage {
|
|
|
116
130
|
*/
|
|
117
131
|
clear(): Promise<void>;
|
|
118
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Result of reading a value from storage.
|
|
135
|
+
*/
|
|
136
|
+
export interface StorageReadResult {
|
|
137
|
+
/** The stored value, or null if not found or on error. */
|
|
138
|
+
value: string | null;
|
|
139
|
+
/** The outcome of the read: found, not found, or error. */
|
|
140
|
+
outcome: "found" | "not_found" | "error";
|
|
141
|
+
/** The error message when the read failed. */
|
|
142
|
+
errorMessage?: string;
|
|
143
|
+
}
|
|
119
144
|
/**
|
|
120
145
|
* Credential returned by a native Apple Sign In flow.
|
|
121
146
|
*/
|
|
@@ -23,7 +23,7 @@ type MFAMethods,
|
|
|
23
23
|
type EndUserEvmAccount,
|
|
24
24
|
/** Solana account object with address and createdAt */
|
|
25
25
|
type EndUserSolanaAccount,
|
|
26
|
-
/** Bitcoin HD account object with
|
|
26
|
+
/** Bitcoin HD account object with xpubHash, network, addressType, and optional xpub */
|
|
27
27
|
type EndUserBtcAccount,
|
|
28
28
|
/** Bitcoin network for account creation */
|
|
29
29
|
type CreateEndUserBtcAccountBodyNetwork,
|
|
@@ -203,7 +203,7 @@ export type User = {
|
|
|
203
203
|
evmSmartAccountObjects?: EndUserEvmSmartAccount[];
|
|
204
204
|
/** The Solana account objects associated with the user. Users can have up to 10 Solana accounts. */
|
|
205
205
|
solanaAccountObjects?: EndUserSolanaAccount[];
|
|
206
|
-
/** The Bitcoin HD account objects associated with the user.
|
|
206
|
+
/** The Bitcoin HD account objects associated with the user. Up to 10 per user. */
|
|
207
207
|
btcAccountObjects?: EndUserBtcAccount[];
|
|
208
208
|
/** The MFA methods enrolled for the user. */
|
|
209
209
|
mfaMethods?: MFAMethods;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coinbase/cdp-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.119",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/**",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"ox": "0.8.1",
|
|
30
30
|
"viem": "^2.47.0",
|
|
31
31
|
"zustand": "^5.0.6",
|
|
32
|
-
"@coinbase/cdp-api-client": "^0.0.
|
|
32
|
+
"@coinbase/cdp-api-client": "^0.0.119"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@react-native-async-storage/async-storage": "^2.0.0",
|