@coinbase/cdp-core 0.0.53 → 0.0.54
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.native10.js +4 -4
- package/dist/esm/index.native100.js +13 -19
- package/dist/esm/index.native101.js +4 -8
- package/dist/esm/index.native102.js +2 -8
- package/dist/esm/index.native103.js +4 -71
- package/dist/esm/index.native104.js +12 -12
- package/dist/esm/index.native105.js +7 -3
- package/dist/esm/index.native106.js +3 -4
- package/dist/esm/index.native107.js +19 -4
- package/dist/esm/index.native108.js +8 -4
- package/dist/esm/index.native109.js +7 -19
- package/dist/esm/index.native11.js +3 -3
- package/dist/esm/index.native110.js +66 -47
- package/dist/esm/index.native111.js +18 -17
- package/dist/esm/index.native112.js +3 -20
- package/dist/esm/index.native113.js +4 -8
- package/dist/esm/index.native114.js +4 -30
- package/dist/esm/index.native115.js +4 -7
- package/dist/esm/index.native116.js +10 -11
- package/dist/esm/index.native117.js +50 -52
- package/dist/esm/index.native118.js +17 -10
- package/dist/esm/index.native119.js +21 -2
- package/dist/esm/index.native12.js +3 -3
- package/dist/esm/index.native120.js +9 -45
- package/dist/esm/index.native121.js +30 -13
- package/dist/esm/index.native122.js +7 -4
- package/dist/esm/index.native123.js +21 -2
- package/dist/esm/index.native125.js +1 -1
- package/dist/esm/index.native13.js +3 -3
- package/dist/esm/index.native132.js +3 -46
- package/dist/esm/index.native133.js +20 -3
- package/dist/esm/index.native134.js +10 -21
- package/dist/esm/index.native135.js +19 -9
- package/dist/esm/index.native136.js +89 -15
- package/dist/esm/index.native137.js +19 -92
- package/dist/esm/index.native138.js +115 -18
- package/dist/esm/index.native139.js +2 -118
- package/dist/esm/index.native14.js +3 -3
- package/dist/esm/index.native140.js +109 -2
- package/dist/esm/index.native141.js +2 -109
- package/dist/esm/index.native142.js +47 -2
- package/dist/esm/index.native15.js +3 -3
- package/dist/esm/index.native153.js +17 -14
- package/dist/esm/index.native154.js +28 -18
- package/dist/esm/index.native155.js +6 -26
- package/dist/esm/index.native156.js +9 -6
- package/dist/esm/index.native157.js +13 -11
- package/dist/esm/index.native158.js +8 -11
- package/dist/esm/index.native159.js +14 -7
- package/dist/esm/index.native16.js +3 -3
- package/dist/esm/index.native160.js +80 -16
- package/dist/esm/index.native161.js +14 -80
- package/dist/esm/index.native19.js +1 -1
- package/dist/esm/index.native22.js +28 -3
- package/dist/esm/index.native23.js +3 -51
- package/dist/esm/index.native24.js +53 -2
- package/dist/esm/index.native25.js +2 -86
- package/dist/esm/index.native26.js +87 -15
- package/dist/esm/index.native27.js +15 -17
- package/dist/esm/index.native28.js +15 -116
- package/dist/esm/index.native29.js +92 -34
- package/dist/esm/index.native3.js +48 -6
- package/dist/esm/index.native30.js +58 -12
- package/dist/esm/index.native31.js +15 -42
- package/dist/esm/index.native32.js +42 -28
- package/dist/esm/index.native44.js +1 -1
- package/dist/esm/index.native45.js +1 -1
- package/dist/esm/index.native46.js +3 -3
- package/dist/esm/index.native47.js +12 -12
- package/dist/esm/index.native48.js +12 -12
- package/dist/esm/index.native49.js +1 -1
- package/dist/esm/index.native51.js +4 -4
- package/dist/esm/index.native52.js +4 -2
- package/dist/esm/index.native53.js +2 -66
- package/dist/esm/index.native54.js +2 -367
- package/dist/esm/index.native55.js +66 -2
- package/dist/esm/index.native56.js +365 -2
- package/dist/esm/index.native7.js +11 -11
- package/dist/esm/index.native72.js +1 -1
- package/dist/esm/index.native8.js +4 -4
- package/dist/esm/index.native9.js +4 -4
- package/dist/esm/index.native96.js +54 -4
- package/dist/esm/index.native97.js +10 -18
- package/dist/esm/index.native98.js +2 -8
- package/dist/esm/index.native99.js +45 -4
- package/dist/esm/index.web100.js +8 -4
- package/dist/esm/index.web101.js +8 -2
- package/dist/esm/index.web102.js +71 -4
- package/dist/esm/index.web103.js +12 -12
- package/dist/esm/index.web104.js +3 -7
- package/dist/esm/index.web105.js +4 -3
- package/dist/esm/index.web106.js +4 -19
- package/dist/esm/index.web107.js +4 -8
- package/dist/esm/index.web108.js +19 -7
- package/dist/esm/index.web109.js +47 -66
- package/dist/esm/index.web110.js +17 -18
- package/dist/esm/index.web111.js +20 -3
- package/dist/esm/index.web112.js +8 -4
- package/dist/esm/index.web113.js +30 -4
- package/dist/esm/index.web114.js +7 -4
- package/dist/esm/index.web115.js +11 -10
- package/dist/esm/index.web116.js +4 -52
- package/dist/esm/index.web117.js +54 -17
- package/dist/esm/index.web118.js +10 -20
- package/dist/esm/index.web119.js +2 -9
- package/dist/esm/index.web120.js +44 -30
- package/dist/esm/index.web121.js +13 -7
- package/dist/esm/index.web122.js +2 -21
- package/dist/esm/index.web124.js +1 -1
- package/dist/esm/index.web127.js +1 -1
- package/dist/esm/index.web130.js +77 -19
- package/dist/esm/index.web131.js +4 -10
- package/dist/esm/index.web132.js +2 -20
- package/dist/esm/index.web133.js +104 -89
- package/dist/esm/index.web134.js +2 -21
- package/dist/esm/index.web135.js +20 -117
- package/dist/esm/index.web136.js +10 -2
- package/dist/esm/index.web137.js +18 -107
- package/dist/esm/index.web138.js +94 -2
- package/dist/esm/index.web139.js +20 -78
- package/dist/esm/index.web140.js +118 -4
- package/dist/esm/index.web141.js +1 -1
- package/dist/esm/index.web153.js +1 -1
- package/dist/esm/index.web158.js +1 -1
- package/dist/esm/index.web159.js +1 -1
- package/dist/esm/index.web24.js +33 -29
- package/dist/esm/index.web34.js +3 -3
- package/dist/esm/index.web40.js +2 -2
- package/dist/esm/index.web45.js +3 -3
- package/dist/esm/index.web46.js +31 -2
- package/dist/esm/index.web47.js +28 -65
- package/dist/esm/index.web48.js +2 -367
- package/dist/esm/index.web49.js +63 -14
- package/dist/esm/index.web50.js +360 -18
- package/dist/esm/index.web51.js +13 -47
- package/dist/esm/index.web52.js +22 -28
- package/dist/esm/index.web53.js +50 -28
- package/dist/esm/index.web71.js +1 -1
- package/dist/esm/index.web95.js +4 -54
- package/dist/esm/index.web96.js +18 -10
- package/dist/esm/index.web97.js +8 -2
- package/dist/esm/index.web98.js +4 -45
- package/dist/esm/index.web99.js +19 -13
- package/dist/native/index.native10.js +4 -4
- package/dist/native/index.native100.js +13 -19
- package/dist/native/index.native101.js +4 -8
- package/dist/native/index.native102.js +2 -8
- package/dist/native/index.native103.js +4 -71
- package/dist/native/index.native104.js +12 -12
- package/dist/native/index.native105.js +7 -3
- package/dist/native/index.native106.js +3 -4
- package/dist/native/index.native107.js +19 -4
- package/dist/native/index.native108.js +8 -4
- package/dist/native/index.native109.js +7 -19
- package/dist/native/index.native11.js +3 -3
- package/dist/native/index.native110.js +66 -47
- package/dist/native/index.native111.js +18 -17
- package/dist/native/index.native112.js +3 -20
- package/dist/native/index.native113.js +4 -8
- package/dist/native/index.native114.js +4 -30
- package/dist/native/index.native115.js +4 -7
- package/dist/native/index.native116.js +10 -11
- package/dist/native/index.native117.js +50 -52
- package/dist/native/index.native118.js +17 -10
- package/dist/native/index.native119.js +21 -2
- package/dist/native/index.native12.js +3 -3
- package/dist/native/index.native120.js +9 -45
- package/dist/native/index.native121.js +30 -13
- package/dist/native/index.native122.js +7 -4
- package/dist/native/index.native123.js +21 -2
- package/dist/native/index.native125.js +1 -1
- package/dist/native/index.native13.js +3 -3
- package/dist/native/index.native132.js +3 -46
- package/dist/native/index.native133.js +20 -3
- package/dist/native/index.native134.js +10 -21
- package/dist/native/index.native135.js +19 -9
- package/dist/native/index.native136.js +89 -15
- package/dist/native/index.native137.js +19 -92
- package/dist/native/index.native138.js +115 -18
- package/dist/native/index.native139.js +2 -118
- package/dist/native/index.native14.js +3 -3
- package/dist/native/index.native140.js +109 -2
- package/dist/native/index.native141.js +2 -109
- package/dist/native/index.native142.js +47 -2
- package/dist/native/index.native15.js +3 -3
- package/dist/native/index.native153.js +17 -14
- package/dist/native/index.native154.js +28 -18
- package/dist/native/index.native155.js +6 -26
- package/dist/native/index.native156.js +9 -6
- package/dist/native/index.native157.js +13 -11
- package/dist/native/index.native158.js +8 -11
- package/dist/native/index.native159.js +14 -7
- package/dist/native/index.native16.js +3 -3
- package/dist/native/index.native160.js +80 -16
- package/dist/native/index.native161.js +14 -80
- package/dist/native/index.native19.js +1 -1
- package/dist/native/index.native22.js +28 -3
- package/dist/native/index.native23.js +3 -51
- package/dist/native/index.native24.js +53 -2
- package/dist/native/index.native25.js +2 -86
- package/dist/native/index.native26.js +87 -15
- package/dist/native/index.native27.js +15 -17
- package/dist/native/index.native28.js +15 -116
- package/dist/native/index.native29.js +92 -34
- package/dist/native/index.native3.js +48 -6
- package/dist/native/index.native30.js +58 -12
- package/dist/native/index.native31.js +15 -42
- package/dist/native/index.native32.js +42 -28
- package/dist/native/index.native44.js +1 -1
- package/dist/native/index.native45.js +1 -1
- package/dist/native/index.native46.js +3 -3
- package/dist/native/index.native47.js +12 -12
- package/dist/native/index.native48.js +12 -12
- package/dist/native/index.native49.js +1 -1
- package/dist/native/index.native51.js +4 -4
- package/dist/native/index.native52.js +4 -2
- package/dist/native/index.native53.js +2 -66
- package/dist/native/index.native54.js +2 -367
- package/dist/native/index.native55.js +66 -2
- package/dist/native/index.native56.js +365 -2
- package/dist/native/index.native7.js +11 -11
- package/dist/native/index.native72.js +1 -1
- package/dist/native/index.native8.js +4 -4
- package/dist/native/index.native9.js +4 -4
- package/dist/native/index.native96.js +54 -4
- package/dist/native/index.native97.js +10 -18
- package/dist/native/index.native98.js +2 -8
- package/dist/native/index.native99.js +45 -4
- package/dist/native-types/auth/oAuthManager.d.ts +1 -1
- package/dist/native-types/auth/types.d.ts +1 -1
- package/dist/native-types/platform/types.d.ts +1 -1
- package/dist/native-types/types.d.ts +1 -0
- package/dist/types/auth/oAuthManager.d.ts +1 -1
- package/dist/types/auth/types.d.ts +1 -1
- package/dist/types/platform/types.d.ts +1 -1
- package/dist/types/types.d.ts +1 -0
- package/dist/web/index.web100.js +8 -4
- package/dist/web/index.web101.js +8 -2
- package/dist/web/index.web102.js +71 -4
- package/dist/web/index.web103.js +12 -12
- package/dist/web/index.web104.js +3 -7
- package/dist/web/index.web105.js +4 -3
- package/dist/web/index.web106.js +4 -19
- package/dist/web/index.web107.js +4 -8
- package/dist/web/index.web108.js +19 -7
- package/dist/web/index.web109.js +47 -66
- package/dist/web/index.web110.js +17 -18
- package/dist/web/index.web111.js +20 -3
- package/dist/web/index.web112.js +8 -4
- package/dist/web/index.web113.js +30 -4
- package/dist/web/index.web114.js +7 -4
- package/dist/web/index.web115.js +11 -10
- package/dist/web/index.web116.js +4 -52
- package/dist/web/index.web117.js +54 -17
- package/dist/web/index.web118.js +10 -20
- package/dist/web/index.web119.js +2 -9
- package/dist/web/index.web120.js +44 -30
- package/dist/web/index.web121.js +13 -7
- package/dist/web/index.web122.js +2 -21
- package/dist/web/index.web124.js +1 -1
- package/dist/web/index.web127.js +1 -1
- package/dist/web/index.web130.js +77 -19
- package/dist/web/index.web131.js +4 -10
- package/dist/web/index.web132.js +2 -20
- package/dist/web/index.web133.js +104 -89
- package/dist/web/index.web134.js +2 -21
- package/dist/web/index.web135.js +20 -117
- package/dist/web/index.web136.js +10 -2
- package/dist/web/index.web137.js +18 -107
- package/dist/web/index.web138.js +94 -2
- package/dist/web/index.web139.js +20 -78
- package/dist/web/index.web140.js +118 -4
- package/dist/web/index.web141.js +1 -1
- package/dist/web/index.web153.js +1 -1
- package/dist/web/index.web158.js +1 -1
- package/dist/web/index.web159.js +1 -1
- package/dist/web/index.web24.js +33 -29
- package/dist/web/index.web34.js +3 -3
- package/dist/web/index.web40.js +2 -2
- package/dist/web/index.web45.js +3 -3
- package/dist/web/index.web46.js +31 -2
- package/dist/web/index.web47.js +28 -65
- package/dist/web/index.web48.js +2 -367
- package/dist/web/index.web49.js +63 -14
- package/dist/web/index.web50.js +360 -18
- package/dist/web/index.web51.js +13 -47
- package/dist/web/index.web52.js +22 -28
- package/dist/web/index.web53.js +50 -28
- package/dist/web/index.web71.js +1 -1
- package/dist/web/index.web95.js +4 -54
- package/dist/web/index.web96.js +18 -10
- package/dist/web/index.web97.js +8 -2
- package/dist/web/index.web98.js +4 -45
- package/dist/web/index.web99.js +19 -13
- package/dist/web-types/auth/oAuthManager.d.ts +1 -1
- package/dist/web-types/auth/types.d.ts +1 -1
- package/dist/web-types/platform/types.d.ts +1 -1
- package/dist/web-types/types.d.ts +1 -0
- package/package.json +7 -3
|
@@ -1,86 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import "@coinbase/cdp-api-client";
|
|
4
|
-
import "viem";
|
|
5
|
-
class S {
|
|
6
|
-
oauthFlowState = null;
|
|
7
|
-
oauthStateChangeCallbacks = [];
|
|
8
|
-
/**
|
|
9
|
-
* Adds a callback to be called when the OAuth state changes.
|
|
10
|
-
*
|
|
11
|
-
* @param callback - The function to call when the OAuth state changes.
|
|
12
|
-
*/
|
|
13
|
-
async addOAuthStateChangeCallback(t) {
|
|
14
|
-
this.oauthStateChangeCallbacks.push(t), t(this.oauthFlowState);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Sets the OAuth flow state.
|
|
18
|
-
*
|
|
19
|
-
* @param oauthFlowState - The OAuth flow state.
|
|
20
|
-
*/
|
|
21
|
-
async setOAuthFlowState(t) {
|
|
22
|
-
this.oauthFlowState = t, this.oauthStateChangeCallbacks.forEach((a) => a(this.oauthFlowState));
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Clears the OAuth flow state.
|
|
26
|
-
*/
|
|
27
|
-
async clearOAuthFlowState() {
|
|
28
|
-
this.oauthFlowState = null, this.oauthStateChangeCallbacks.forEach((t) => t(null));
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Gets the OAuth flow state.
|
|
32
|
-
*
|
|
33
|
-
* @returns The OAuth flow state.
|
|
34
|
-
*/
|
|
35
|
-
async getOAuthFlowState() {
|
|
36
|
-
return this.oauthFlowState;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Handles the OAuth code.
|
|
40
|
-
*/
|
|
41
|
-
async handleOAuthCode() {
|
|
42
|
-
try {
|
|
43
|
-
const t = await s().getOAuthParams();
|
|
44
|
-
if (await s().cleanupOAuthParams(), !t)
|
|
45
|
-
return;
|
|
46
|
-
const { providerType: a, code: e, flowId: r, error: o, errorDescription: h } = t;
|
|
47
|
-
if (o || h) {
|
|
48
|
-
await this.setOAuthFlowState({
|
|
49
|
-
providerType: a,
|
|
50
|
-
status: "error",
|
|
51
|
-
errorDescription: o ?? h,
|
|
52
|
-
code: e,
|
|
53
|
-
flowId: r,
|
|
54
|
-
error: o
|
|
55
|
-
});
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (!e || !a || !r)
|
|
59
|
-
return;
|
|
60
|
-
await this.setOAuthFlowState({
|
|
61
|
-
providerType: a,
|
|
62
|
-
status: "pending",
|
|
63
|
-
code: e,
|
|
64
|
-
flowId: r
|
|
65
|
-
}), await u({
|
|
66
|
-
code: e,
|
|
67
|
-
providerType: a,
|
|
68
|
-
flowId: r
|
|
69
|
-
}), await this.setOAuthFlowState({
|
|
70
|
-
providerType: a,
|
|
71
|
-
status: "success",
|
|
72
|
-
code: e,
|
|
73
|
-
flowId: r
|
|
74
|
-
});
|
|
75
|
-
} catch (t) {
|
|
76
|
-
const a = t instanceof Error ? t.message : "Unknown error";
|
|
77
|
-
await s().cleanupOAuthParams(), await this.setOAuthFlowState({
|
|
78
|
-
status: "error",
|
|
79
|
-
errorDescription: a
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
export {
|
|
85
|
-
S as OAuthManager
|
|
86
|
-
};
|
|
1
|
+
import { __require as r } from "./index.native148.js";
|
|
2
|
+
r();
|
|
@@ -1,18 +1,90 @@
|
|
|
1
|
+
import { verifyOAuth as i } from "./index.native7.js";
|
|
2
|
+
import { getPlatformOAuth as h } from "./index.native6.js";
|
|
1
3
|
import "@coinbase/cdp-api-client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
import "viem";
|
|
5
|
+
class A {
|
|
6
|
+
oauthFlowState = null;
|
|
7
|
+
oauthStateChangeCallbacks = [];
|
|
8
|
+
/**
|
|
9
|
+
* Adds a callback to be called when the OAuth state changes.
|
|
10
|
+
*
|
|
11
|
+
* @param callback - The function to call when the OAuth state changes.
|
|
12
|
+
*/
|
|
13
|
+
async addOAuthStateChangeCallback(t) {
|
|
14
|
+
this.oauthStateChangeCallbacks.push(t), t(this.oauthFlowState);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Sets the OAuth flow state.
|
|
18
|
+
*
|
|
19
|
+
* @param oauthFlowState - The OAuth flow state.
|
|
20
|
+
*/
|
|
21
|
+
async setOAuthFlowState(t) {
|
|
22
|
+
this.oauthFlowState = t, this.oauthStateChangeCallbacks.forEach((a) => a(this.oauthFlowState));
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Clears the OAuth flow state.
|
|
26
|
+
*/
|
|
27
|
+
async clearOAuthFlowState() {
|
|
28
|
+
this.oauthFlowState = null, this.oauthStateChangeCallbacks.forEach((t) => t(null));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Gets the OAuth flow state.
|
|
32
|
+
*
|
|
33
|
+
* @returns The OAuth flow state.
|
|
34
|
+
*/
|
|
35
|
+
async getOAuthFlowState() {
|
|
36
|
+
return this.oauthFlowState;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Handles the OAuth code.
|
|
40
|
+
*
|
|
41
|
+
* @param url - The URL to handle.
|
|
42
|
+
* @returns A promise that resolves when the OAuth code is handled.
|
|
43
|
+
* @throws An error if the URL is required and not provided.
|
|
44
|
+
*/
|
|
45
|
+
async handleOAuthCode(t) {
|
|
46
|
+
try {
|
|
47
|
+
const a = await h().getOAuthParams(t);
|
|
48
|
+
if (await h().cleanupOAuthParams(), !a)
|
|
49
|
+
return;
|
|
50
|
+
const { providerType: e, code: r, flowId: o, error: s, errorDescription: u } = a;
|
|
51
|
+
if (s || u) {
|
|
52
|
+
await this.setOAuthFlowState({
|
|
53
|
+
providerType: e,
|
|
54
|
+
status: "error",
|
|
55
|
+
errorDescription: s ?? u,
|
|
56
|
+
code: r,
|
|
57
|
+
flowId: o,
|
|
58
|
+
error: s
|
|
59
|
+
});
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (!r || !e || !o)
|
|
63
|
+
return;
|
|
64
|
+
await this.setOAuthFlowState({
|
|
65
|
+
providerType: e,
|
|
66
|
+
status: "pending",
|
|
67
|
+
code: r,
|
|
68
|
+
flowId: o
|
|
69
|
+
}), await i({
|
|
70
|
+
code: r,
|
|
71
|
+
providerType: e,
|
|
72
|
+
flowId: o
|
|
73
|
+
}), await this.setOAuthFlowState({
|
|
74
|
+
providerType: e,
|
|
75
|
+
status: "success",
|
|
76
|
+
code: r,
|
|
77
|
+
flowId: o
|
|
78
|
+
});
|
|
79
|
+
} catch (a) {
|
|
80
|
+
const e = a instanceof Error ? a.message : "Unknown error";
|
|
81
|
+
await h().cleanupOAuthParams(), await this.setOAuthFlowState({
|
|
82
|
+
status: "error",
|
|
83
|
+
errorDescription: e
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
16
88
|
export {
|
|
17
|
-
|
|
89
|
+
A as OAuthManager
|
|
18
90
|
};
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import "@coinbase/cdp-api-client";
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
2
|
+
const m = (c, a, e) => {
|
|
3
|
+
const s = new Date(a).getTime(), u = {
|
|
4
|
+
userId: e.userId,
|
|
5
|
+
evmAccounts: e.evmAccounts?.map((t) => t) ?? [],
|
|
6
|
+
evmSmartAccounts: e.evmSmartAccounts?.map((t) => t) ?? [],
|
|
7
|
+
solanaAccounts: e.solanaAccounts?.map((t) => t) ?? [],
|
|
8
|
+
authenticationMethods: e.authenticationMethods.reduce((t, o) => (t[o.type] = o, t), {})
|
|
9
|
+
};
|
|
10
|
+
return {
|
|
11
|
+
accessToken: c,
|
|
12
|
+
expiresAt: s,
|
|
13
|
+
user: u
|
|
14
|
+
};
|
|
15
|
+
};
|
|
17
16
|
export {
|
|
18
|
-
|
|
19
|
-
f as withAuth
|
|
17
|
+
m as toAuthState
|
|
20
18
|
};
|
|
@@ -1,121 +1,20 @@
|
|
|
1
1
|
import "@coinbase/cdp-api-client";
|
|
2
2
|
import "viem";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*
|
|
17
|
-
* @returns A promise that resolves when the auth manager is ready to be used.
|
|
18
|
-
*/
|
|
19
|
-
async ensureInitialized() {
|
|
20
|
-
return Promise.resolve();
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Gets the current user, or null if there is no user signed in.
|
|
24
|
-
*
|
|
25
|
-
* @returns The current mock user if signed in, null otherwise.
|
|
26
|
-
*/
|
|
27
|
-
async getUser() {
|
|
28
|
-
return this.authState?.user ?? null;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Returns whether the user is signed in - i.e., whether there is an unexpired
|
|
32
|
-
* access token and user.
|
|
33
|
-
*
|
|
34
|
-
* @returns True if the mock user is signed in and token is not expired, false otherwise.
|
|
35
|
-
*/
|
|
36
|
-
async isSignedIn() {
|
|
37
|
-
return this.authState ? Promise.resolve(this.authState.expiresAt > Date.now()) : Promise.resolve(!1);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Signs out the user, clearing all authentication state.
|
|
41
|
-
* In the mock implementation, this simply clears the local auth state.
|
|
42
|
-
*/
|
|
43
|
-
async signOut() {
|
|
44
|
-
await this.clearAuthState();
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Sets a callback to be called when the auth state changes.
|
|
48
|
-
* The callback is immediately called with the current auth state.
|
|
49
|
-
*
|
|
50
|
-
* @param callback - The function to call when the auth state changes.
|
|
51
|
-
* Will be called with the current user or null.
|
|
52
|
-
*/
|
|
53
|
-
addAuthStateChangeCallback(t) {
|
|
54
|
-
this.authStateChangeCallback = t, t(this.authState?.user ?? null);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Gets the access token. For mock, this always returns a valid token if signed in.
|
|
58
|
-
* If the current token is expired, it will be refreshed automatically.
|
|
59
|
-
*
|
|
60
|
-
* @returns The mock access token if signed in, null otherwise.
|
|
61
|
-
*/
|
|
62
|
-
async getToken() {
|
|
63
|
-
return this.authState ? (this.authState.expiresAt <= Date.now() && await this.refreshToken(), this.authState?.accessToken ?? null) : null;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Gets the currentlly registered wallet secret ID.
|
|
67
|
-
*
|
|
68
|
-
* @returns The wallet secret ID.
|
|
69
|
-
*/
|
|
70
|
-
async getWalletSecretId() {
|
|
71
|
-
return "mock-wallet-secret-id";
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Gets the X-Wallet-Auth header value.
|
|
75
|
-
*
|
|
76
|
-
* @param _options - The options for the request.
|
|
77
|
-
* @param _options.requestMethod - The HTTP method of the request.
|
|
78
|
-
* @param _options.requestHost - The host of the request.
|
|
79
|
-
* @param _options.requestPath - The path of the request.
|
|
80
|
-
* @param _options.requestData - The data of the request.
|
|
81
|
-
* @returns The X-Wallet-Auth header value.
|
|
82
|
-
*/
|
|
83
|
-
async getXWalletAuth(t) {
|
|
84
|
-
if (!this.authState)
|
|
85
|
-
throw new Error("User not signed in");
|
|
86
|
-
return "x-wallet-auth";
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Sets the authentication state.
|
|
90
|
-
* This will trigger the auth state change callback if one is registered.
|
|
91
|
-
*
|
|
92
|
-
* @param authState - The new authentication state to set.
|
|
93
|
-
*/
|
|
94
|
-
async setAuthState(t) {
|
|
95
|
-
this.authState = t, this.authStateChangeCallback && this.authStateChangeCallback(this.authState?.user ?? null);
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Clears the authentication state.
|
|
99
|
-
* This will trigger the auth state change callback if one is registered.
|
|
100
|
-
*/
|
|
101
|
-
async clearAuthState() {
|
|
102
|
-
this.authState = null, this.authStateChangeCallback && this.authStateChangeCallback(null);
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Refreshes the mock token.
|
|
106
|
-
* Only refreshes if there is an existing auth state (user is signed in).
|
|
107
|
-
* Sets a new mock token with a 24-hour expiration.
|
|
108
|
-
*
|
|
109
|
-
* @private
|
|
110
|
-
*/
|
|
111
|
-
async refreshToken() {
|
|
112
|
-
this.authState && await this.setAuthState({
|
|
113
|
-
accessToken: "mock-access-token",
|
|
114
|
-
expiresAt: Date.now() + 1e3 * 60 * 60 * 24,
|
|
115
|
-
user: e
|
|
116
|
-
});
|
|
117
|
-
}
|
|
3
|
+
const i = async (n) => await n.isSignedIn();
|
|
4
|
+
async function f(n, r, o) {
|
|
5
|
+
if (!await i(r))
|
|
6
|
+
throw new Error("User not signed in");
|
|
7
|
+
const c = await r.getUser();
|
|
8
|
+
if ("evmAccount" in n && !c.evmAccounts?.find((t) => t === n.evmAccount))
|
|
9
|
+
throw new Error("EVM account not found");
|
|
10
|
+
if ("evmSmartAccount" in n && !c.evmSmartAccounts?.find((t) => t === n.evmSmartAccount))
|
|
11
|
+
throw new Error("EVM Smart Account not found");
|
|
12
|
+
if ("solanaAccount" in n && !c.solanaAccounts?.find((t) => t === n.solanaAccount))
|
|
13
|
+
throw new Error("Solana account not found");
|
|
14
|
+
const e = await r.getWalletSecretId();
|
|
15
|
+
return o({ ...n, user: c, walletSecretId: e });
|
|
118
16
|
}
|
|
119
17
|
export {
|
|
120
|
-
|
|
18
|
+
i as isSignedIn,
|
|
19
|
+
f as withAuth
|
|
121
20
|
};
|
|
@@ -1,63 +1,121 @@
|
|
|
1
1
|
import "@coinbase/cdp-api-client";
|
|
2
2
|
import "viem";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
oauthStateChangeCallbacks = [];
|
|
3
|
+
import { mockUser as e } from "./index.native31.js";
|
|
4
|
+
class r {
|
|
5
|
+
authState = null;
|
|
6
|
+
authStateChangeCallback = null;
|
|
8
7
|
/**
|
|
9
|
-
* Initializes the mock
|
|
8
|
+
* Initializes the mock auth manager.
|
|
9
|
+
*
|
|
10
|
+
* @param _projectId - The project ID (unused in mock implementation).
|
|
10
11
|
*/
|
|
11
|
-
constructor() {
|
|
12
|
-
|
|
12
|
+
constructor(t) {
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Awaitable method whose promise only resolves when the auth manager is ready to be used.
|
|
16
|
+
*
|
|
17
|
+
* @returns A promise that resolves when the auth manager is ready to be used.
|
|
18
|
+
*/
|
|
19
|
+
async ensureInitialized() {
|
|
20
|
+
return Promise.resolve();
|
|
13
21
|
}
|
|
14
22
|
/**
|
|
15
23
|
* Gets the current user, or null if there is no user signed in.
|
|
16
24
|
*
|
|
17
25
|
* @returns The current mock user if signed in, null otherwise.
|
|
18
26
|
*/
|
|
19
|
-
async
|
|
20
|
-
return this.
|
|
27
|
+
async getUser() {
|
|
28
|
+
return this.authState?.user ?? null;
|
|
21
29
|
}
|
|
22
30
|
/**
|
|
23
|
-
*
|
|
31
|
+
* Returns whether the user is signed in - i.e., whether there is an unexpired
|
|
32
|
+
* access token and user.
|
|
24
33
|
*
|
|
25
|
-
* @
|
|
34
|
+
* @returns True if the mock user is signed in and token is not expired, false otherwise.
|
|
26
35
|
*/
|
|
27
|
-
async
|
|
28
|
-
this.
|
|
36
|
+
async isSignedIn() {
|
|
37
|
+
return this.authState ? Promise.resolve(this.authState.expiresAt > Date.now()) : Promise.resolve(!1);
|
|
29
38
|
}
|
|
30
39
|
/**
|
|
31
|
-
*
|
|
40
|
+
* Signs out the user, clearing all authentication state.
|
|
41
|
+
* In the mock implementation, this simply clears the local auth state.
|
|
42
|
+
*/
|
|
43
|
+
async signOut() {
|
|
44
|
+
await this.clearAuthState();
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Sets a callback to be called when the auth state changes.
|
|
48
|
+
* The callback is immediately called with the current auth state.
|
|
49
|
+
*
|
|
50
|
+
* @param callback - The function to call when the auth state changes.
|
|
51
|
+
* Will be called with the current user or null.
|
|
52
|
+
*/
|
|
53
|
+
addAuthStateChangeCallback(t) {
|
|
54
|
+
this.authStateChangeCallback = t, t(this.authState?.user ?? null);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Gets the access token. For mock, this always returns a valid token if signed in.
|
|
58
|
+
* If the current token is expired, it will be refreshed automatically.
|
|
32
59
|
*
|
|
33
|
-
* @
|
|
60
|
+
* @returns The mock access token if signed in, null otherwise.
|
|
34
61
|
*/
|
|
35
|
-
async
|
|
36
|
-
this.
|
|
62
|
+
async getToken() {
|
|
63
|
+
return this.authState ? (this.authState.expiresAt <= Date.now() && await this.refreshToken(), this.authState?.accessToken ?? null) : null;
|
|
37
64
|
}
|
|
38
65
|
/**
|
|
39
|
-
*
|
|
66
|
+
* Gets the currentlly registered wallet secret ID.
|
|
67
|
+
*
|
|
68
|
+
* @returns The wallet secret ID.
|
|
40
69
|
*/
|
|
41
|
-
async
|
|
42
|
-
|
|
70
|
+
async getWalletSecretId() {
|
|
71
|
+
return "mock-wallet-secret-id";
|
|
43
72
|
}
|
|
44
73
|
/**
|
|
45
|
-
*
|
|
74
|
+
* Gets the X-Wallet-Auth header value.
|
|
75
|
+
*
|
|
76
|
+
* @param _options - The options for the request.
|
|
77
|
+
* @param _options.requestMethod - The HTTP method of the request.
|
|
78
|
+
* @param _options.requestHost - The host of the request.
|
|
79
|
+
* @param _options.requestPath - The path of the request.
|
|
80
|
+
* @param _options.requestData - The data of the request.
|
|
81
|
+
* @returns The X-Wallet-Auth header value.
|
|
82
|
+
*/
|
|
83
|
+
async getXWalletAuth(t) {
|
|
84
|
+
if (!this.authState)
|
|
85
|
+
throw new Error("User not signed in");
|
|
86
|
+
return "x-wallet-auth";
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Sets the authentication state.
|
|
90
|
+
* This will trigger the auth state change callback if one is registered.
|
|
91
|
+
*
|
|
92
|
+
* @param authState - The new authentication state to set.
|
|
93
|
+
*/
|
|
94
|
+
async setAuthState(t) {
|
|
95
|
+
this.authState = t, this.authStateChangeCallback && this.authStateChangeCallback(this.authState?.user ?? null);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Clears the authentication state.
|
|
99
|
+
* This will trigger the auth state change callback if one is registered.
|
|
100
|
+
*/
|
|
101
|
+
async clearAuthState() {
|
|
102
|
+
this.authState = null, this.authStateChangeCallback && this.authStateChangeCallback(null);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Refreshes the mock token.
|
|
106
|
+
* Only refreshes if there is an existing auth state (user is signed in).
|
|
107
|
+
* Sets a new mock token with a 24-hour expiration.
|
|
108
|
+
*
|
|
109
|
+
* @private
|
|
46
110
|
*/
|
|
47
|
-
async
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
flowId: "mock-flow-id"
|
|
53
|
-
}), await o({ code: "mock-oauth-code", providerType: "google", flowId: "mock-flow-id" }), await this.setOAuthFlowState({
|
|
54
|
-
providerType: "google",
|
|
55
|
-
status: "success",
|
|
56
|
-
code: "mock-oauth-code",
|
|
57
|
-
flowId: "mock-flow-id"
|
|
111
|
+
async refreshToken() {
|
|
112
|
+
this.authState && await this.setAuthState({
|
|
113
|
+
accessToken: "mock-access-token",
|
|
114
|
+
expiresAt: Date.now() + 1e3 * 60 * 60 * 24,
|
|
115
|
+
user: e
|
|
58
116
|
});
|
|
59
117
|
}
|
|
60
118
|
}
|
|
61
119
|
export {
|
|
62
|
-
|
|
120
|
+
r as MockAuthManager
|
|
63
121
|
};
|
|
@@ -1,14 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
import * as u from "expo-web-browser";
|
|
2
|
+
import { WebBrowserResultType as o } from "expo-web-browser";
|
|
3
|
+
import { getCoreOAuthManager as s, getConfig as l } from "./index.native22.js";
|
|
4
|
+
const d = {
|
|
2
5
|
getRedirectUrl: () => {
|
|
3
|
-
|
|
6
|
+
const e = l().nativeOAuthCallback;
|
|
7
|
+
if (!e)
|
|
8
|
+
throw new Error("nativeOAuthCallback must be configured in order to use native OAuth");
|
|
9
|
+
return e;
|
|
10
|
+
},
|
|
11
|
+
getOAuthParams: (e) => {
|
|
12
|
+
if (!e)
|
|
13
|
+
return null;
|
|
14
|
+
const r = new URL(e), t = r.searchParams.get("code") ?? void 0, a = r.searchParams.get("provider_type") ?? void 0, i = r.searchParams.get("flow_id") ?? void 0, c = r.searchParams.get("error") ?? void 0, n = r.searchParams.get("error_description") ?? void 0;
|
|
15
|
+
return (!t || !a || !i) && !c && !n ? null : { code: t, providerType: a, flowId: i, error: c, errorDescription: n };
|
|
4
16
|
},
|
|
5
|
-
getOAuthParams: () => null,
|
|
6
17
|
cleanupOAuthParams: () => {
|
|
7
18
|
},
|
|
8
|
-
initiateOAuthFlow: () => {
|
|
9
|
-
|
|
19
|
+
initiateOAuthFlow: async (e) => {
|
|
20
|
+
const r = d.getRedirectUrl(), t = await u.openAuthSessionAsync(e, r);
|
|
21
|
+
switch (t.type) {
|
|
22
|
+
case "success":
|
|
23
|
+
if (!t.url)
|
|
24
|
+
throw new Error("URL is required for success result");
|
|
25
|
+
s().handleOAuthCode(t.url);
|
|
26
|
+
break;
|
|
27
|
+
case o.CANCEL:
|
|
28
|
+
s().setOAuthFlowState({
|
|
29
|
+
status: "error",
|
|
30
|
+
errorDescription: "User cancelled the OAuth flow"
|
|
31
|
+
});
|
|
32
|
+
break;
|
|
33
|
+
case o.DISMISS:
|
|
34
|
+
s().setOAuthFlowState({
|
|
35
|
+
status: "error",
|
|
36
|
+
errorDescription: "User dismissed the OAuth flow"
|
|
37
|
+
});
|
|
38
|
+
break;
|
|
39
|
+
case o.LOCKED:
|
|
40
|
+
s().setOAuthFlowState({
|
|
41
|
+
status: "error",
|
|
42
|
+
errorDescription: "The browser was locked"
|
|
43
|
+
});
|
|
44
|
+
break;
|
|
45
|
+
case o.OPENED:
|
|
46
|
+
break;
|
|
47
|
+
default:
|
|
48
|
+
throw new Error(
|
|
49
|
+
`Unexpected WebBrowser result type: ${t.type}`
|
|
50
|
+
);
|
|
51
|
+
}
|
|
10
52
|
}
|
|
11
53
|
};
|
|
12
54
|
export {
|
|
13
|
-
|
|
55
|
+
d as nativeOAuth
|
|
14
56
|
};
|
|
@@ -1,17 +1,63 @@
|
|
|
1
1
|
import "@coinbase/cdp-api-client";
|
|
2
2
|
import "viem";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
import { verifyOAuth as o } from "./index.native7.js";
|
|
4
|
+
import { getPlatformOAuth as e } from "./index.native6.js";
|
|
5
|
+
class i {
|
|
6
|
+
oauthFlowState = null;
|
|
7
|
+
oauthStateChangeCallbacks = [];
|
|
8
|
+
/**
|
|
9
|
+
* Initializes the mock OAuth manager.
|
|
10
|
+
*/
|
|
11
|
+
constructor() {
|
|
12
|
+
this.handleOAuthCode();
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Gets the current user, or null if there is no user signed in.
|
|
16
|
+
*
|
|
17
|
+
* @returns The current mock user if signed in, null otherwise.
|
|
18
|
+
*/
|
|
19
|
+
async getOAuthFlowState() {
|
|
20
|
+
return this.oauthFlowState ?? null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Sets the OAuth flow state.
|
|
24
|
+
*
|
|
25
|
+
* @param oauthFlowState - The OAuth flow state to set.
|
|
26
|
+
*/
|
|
27
|
+
async setOAuthFlowState(t) {
|
|
28
|
+
this.oauthFlowState = t, this.oauthStateChangeCallbacks.forEach((a) => a(this.oauthFlowState));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Adds a callback to be called when the OAuth state changes.
|
|
32
|
+
*
|
|
33
|
+
* @param callback - The function to call when the OAuth state changes.
|
|
34
|
+
*/
|
|
35
|
+
async addOAuthStateChangeCallback(t) {
|
|
36
|
+
this.oauthStateChangeCallbacks.push(t), t(this.oauthFlowState);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Clears the OAuth flow state.
|
|
40
|
+
*/
|
|
41
|
+
async clearOAuthFlowState() {
|
|
42
|
+
this.oauthFlowState = null, this.oauthStateChangeCallbacks.forEach((t) => t(null));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Awaitable method whose promise only resolves when the OAuth manager is ready to be used.
|
|
46
|
+
*/
|
|
47
|
+
async handleOAuthCode() {
|
|
48
|
+
await e()?.cleanupOAuthParams(), await this.setOAuthFlowState({
|
|
49
|
+
providerType: "google",
|
|
50
|
+
status: "pending",
|
|
51
|
+
code: "mock-oauth-code",
|
|
52
|
+
flowId: "mock-flow-id"
|
|
53
|
+
}), await o({ code: "mock-oauth-code", providerType: "google", flowId: "mock-flow-id" }), await this.setOAuthFlowState({
|
|
54
|
+
providerType: "google",
|
|
55
|
+
status: "success",
|
|
56
|
+
code: "mock-oauth-code",
|
|
57
|
+
flowId: "mock-flow-id"
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
14
61
|
export {
|
|
15
|
-
|
|
16
|
-
s as mockUser
|
|
62
|
+
i as MockOAuthManager
|
|
17
63
|
};
|