@pear-protocol/core-sdk 1.17.0 → 1.17.2

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.
@@ -20,15 +20,38 @@ declare class Auth {
20
20
  }>;
21
21
  /**
22
22
  * Begin signing in with X. Send the browser to the returned `authorizeUrl`; X redirects
23
- * back to the backend callback, which signs in the Pear account that has this X account
23
+ * back to the backend callback, which settles the Pear account that has this X account
24
24
  * connected. It never creates one - connect X from a signed-in session first.
25
25
  *
26
26
  * Pass `returnTo` as the page the user is on - normally `location.href` - and the
27
27
  * callback returns them there with the outcome on the query string.
28
+ *
29
+ * `handoffChallenge` is the base64url SHA-256 of a random 32-byte verifier this browser
30
+ * keeps. Store the verifier under the returned `handoffId`; the return URL names that id
31
+ * in `x_handoff` and carries the ticket in its fragment, and `exchangeXLogin` below
32
+ * trades the two for a session. Nothing signs the user in until that call.
28
33
  */
29
- startXLogin(body?: HttpTypes.StartXLoginRequest, headers?: ClientHeaders): Promise<{
34
+ startXLogin(body: HttpTypes.StartXLoginRequest, headers?: ClientHeaders): Promise<{
30
35
  authorizeUrl: string;
31
36
  }>;
37
+ /**
38
+ * Redeem a finished X sign-in for a session.
39
+ *
40
+ * Read `x_ticket` from the return URL's fragment and the verifier you filed under the
41
+ * `x_handoff` query parameter, then call this. Returns the same token pair every other
42
+ * login returns and sets the session cookies, so it serves bearer and cookie clients
43
+ * alike. The ticket is single-use and expires in 60 seconds.
44
+ */
45
+ exchangeXLogin(body: HttpTypes.ExchangeXLoginRequest, headers?: ClientHeaders): Promise<{
46
+ accessToken: string;
47
+ refreshToken: string;
48
+ user: {
49
+ id: string;
50
+ role: "basic" | "pro";
51
+ providerId: string | null;
52
+ loginMethod: "email" | "evm_wallet" | "oauth" | "x";
53
+ };
54
+ }>;
32
55
  /**
33
56
  * Unlink the authenticated user's X account. Removes the public handle immediately.
34
57
  */
@@ -1,4 +1,9 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
1
3
  class Auth {
4
+ static {
5
+ __name(this, "Auth");
6
+ }
2
7
  client;
3
8
  constructor(client) {
4
9
  this.client = client;
@@ -18,12 +23,12 @@ class Auth {
18
23
  });
19
24
  }
20
25
  /**
21
- * Begin linking an X account. Send the browser to the returned `authorizeUrl`;
22
- * X redirects back to the backend callback, which finishes the link.
23
- *
24
- * Pass `returnTo` as the page the user is on - normally `location.href` - and the
25
- * callback returns them there with the outcome on the query string.
26
- */
26
+ * Begin linking an X account. Send the browser to the returned `authorizeUrl`;
27
+ * X redirects back to the backend callback, which finishes the link.
28
+ *
29
+ * Pass `returnTo` as the page the user is on - normally `location.href` - and the
30
+ * callback returns them there with the outcome on the query string.
31
+ */
27
32
  async startXLink(body = {}, headers) {
28
33
  return await this.client.fetch(`/auth/link/x/start`, {
29
34
  method: "POST",
@@ -32,14 +37,19 @@ class Auth {
32
37
  });
33
38
  }
34
39
  /**
35
- * Begin signing in with X. Send the browser to the returned `authorizeUrl`; X redirects
36
- * back to the backend callback, which signs in the Pear account that has this X account
37
- * connected. It never creates one - connect X from a signed-in session first.
38
- *
39
- * Pass `returnTo` as the page the user is on - normally `location.href` - and the
40
- * callback returns them there with the outcome on the query string.
41
- */
42
- async startXLogin(body = {}, headers) {
40
+ * Begin signing in with X. Send the browser to the returned `authorizeUrl`; X redirects
41
+ * back to the backend callback, which settles the Pear account that has this X account
42
+ * connected. It never creates one - connect X from a signed-in session first.
43
+ *
44
+ * Pass `returnTo` as the page the user is on - normally `location.href` - and the
45
+ * callback returns them there with the outcome on the query string.
46
+ *
47
+ * `handoffChallenge` is the base64url SHA-256 of a random 32-byte verifier this browser
48
+ * keeps. Store the verifier under the returned `handoffId`; the return URL names that id
49
+ * in `x_handoff` and carries the ticket in its fragment, and `exchangeXLogin` below
50
+ * trades the two for a session. Nothing signs the user in until that call.
51
+ */
52
+ async startXLogin(body, headers) {
43
53
  return await this.client.fetch(`/auth/login/x/start`, {
44
54
  method: "POST",
45
55
  headers,
@@ -47,8 +57,23 @@ class Auth {
47
57
  });
48
58
  }
49
59
  /**
50
- * Unlink the authenticated user's X account. Removes the public handle immediately.
51
- */
60
+ * Redeem a finished X sign-in for a session.
61
+ *
62
+ * Read `x_ticket` from the return URL's fragment and the verifier you filed under the
63
+ * `x_handoff` query parameter, then call this. Returns the same token pair every other
64
+ * login returns and sets the session cookies, so it serves bearer and cookie clients
65
+ * alike. The ticket is single-use and expires in 60 seconds.
66
+ */
67
+ async exchangeXLogin(body, headers) {
68
+ return await this.client.fetch(`/auth/login/x/exchange`, {
69
+ method: "POST",
70
+ headers,
71
+ body
72
+ });
73
+ }
74
+ /**
75
+ * Unlink the authenticated user's X account. Removes the public handle immediately.
76
+ */
52
77
  async disconnectX(headers) {
53
78
  return await this.client.fetch(`/auth/link/x`, {
54
79
  method: "DELETE",
@@ -187,7 +187,7 @@ declare class Core {
187
187
  get: (query?: HttpTypes.QuoteFeeParamsInput, headers?: ClientHeaders) => Promise<{
188
188
  baseBps: string;
189
189
  discounts: {
190
- scope: "connector" | "all" | "user" | "client_id";
190
+ scope: "user" | "connector" | "all" | "client_id";
191
191
  rate: string;
192
192
  }[];
193
193
  finalBps: string;
@@ -5167,6 +5167,7 @@ declare class Core {
5167
5167
  pearFee: string;
5168
5168
  tradeFee: string;
5169
5169
  totalTrades: number;
5170
+ roi?: string | undefined;
5170
5171
  xHandle?: string | undefined;
5171
5172
  xName?: string | undefined;
5172
5173
  xAvatarUrl?: string | undefined;