@pear-protocol/types 1.22.0 → 1.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,7 @@ export declare const LoginMethod: z.ZodEnum<{
3
3
  email: "email";
4
4
  evm_wallet: "evm_wallet";
5
5
  oauth: "oauth";
6
+ x: "x";
6
7
  }>;
7
8
  export declare const AuthenticatedUser: z.ZodObject<{
8
9
  id: z.ZodUUID;
@@ -15,7 +16,26 @@ export declare const AuthenticatedUser: z.ZodObject<{
15
16
  email: "email";
16
17
  evm_wallet: "evm_wallet";
17
18
  oauth: "oauth";
19
+ x: "x";
18
20
  }>;
19
21
  }, z.core.$strip>;
22
+ /**
23
+ * One provider identity connected to the account.
24
+ *
25
+ * Identity only: every entry reports the immutable id the provider knows the account by.
26
+ * Mutable display data - the X handle, name and avatar - is published by the profile
27
+ * endpoints that own it, so it never goes stale in two places at once.
28
+ */
29
+ export declare const ConnectedIdentity: z.ZodObject<{
30
+ provider: z.ZodEnum<{
31
+ email: "email";
32
+ evm_wallet: "evm_wallet";
33
+ oauth: "oauth";
34
+ x: "x";
35
+ }>;
36
+ externalId: z.ZodString;
37
+ connectedAt: z.ZodString;
38
+ }, z.core.$strip>;
20
39
  export type LoginMethod = z.infer<typeof LoginMethod>;
21
40
  export type AuthenticatedUser = z.infer<typeof AuthenticatedUser>;
41
+ export type ConnectedIdentity = z.infer<typeof ConnectedIdentity>;
@@ -1,11 +1,16 @@
1
1
  import { z } from 'zod';
2
2
 
3
- const LoginMethod = z.enum(["email", "evm_wallet", "oauth"]).describe("Authentication provider used for the current session");
3
+ const LoginMethod = z.enum(["email", "evm_wallet", "oauth", "x"]).describe("Authentication provider used for the current session");
4
4
  const AuthenticatedUser = z.object({
5
5
  id: z.uuid().describe("User UUID"),
6
6
  role: z.enum(["basic", "pro"]).describe("User role"),
7
7
  providerId: z.string().nullable().describe("Provider identifier (wallet address or email)"),
8
8
  loginMethod: LoginMethod.describe("Authentication provider used for the current session")
9
9
  }).describe("Current authenticated user info");
10
+ const ConnectedIdentity = z.object({
11
+ provider: LoginMethod.describe("Provider that owns this identity"),
12
+ externalId: z.string().describe("Immutable id the provider knows the account by: wallet address, email, or X numeric id"),
13
+ connectedAt: z.string().describe("ISO-8601 timestamp of when the identity was connected")
14
+ }).describe("One provider identity connected to the account");
10
15
 
11
- export { AuthenticatedUser, LoginMethod };
16
+ export { AuthenticatedUser, ConnectedIdentity, LoginMethod };
@@ -15,6 +15,12 @@ export declare const LinkWalletRequest: z.ZodObject<{
15
15
  signature: z.ZodString;
16
16
  nonce: z.ZodOptional<z.ZodString>;
17
17
  }, z.core.$strip>;
18
+ export declare const StartXLinkRequest: z.ZodObject<{
19
+ returnTo: z.ZodOptional<z.ZodString>;
20
+ }, z.core.$strip>;
21
+ export declare const StartXLoginRequest: z.ZodObject<{
22
+ returnTo: z.ZodOptional<z.ZodString>;
23
+ }, z.core.$strip>;
18
24
  export declare const WalletLoginRequest: z.ZodObject<{
19
25
  method: z.ZodLiteral<"wallet">;
20
26
  address: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
@@ -70,6 +76,8 @@ export type WalletLoginRequest = z.infer<typeof WalletLoginRequest>;
70
76
  export type EmailRegisterRequest = z.infer<typeof EmailRegisterRequest>;
71
77
  export type LinkEmailRequest = z.infer<typeof LinkEmailRequest>;
72
78
  export type LinkWalletRequest = z.infer<typeof LinkWalletRequest>;
79
+ export type StartXLinkRequest = z.infer<typeof StartXLinkRequest>;
80
+ export type StartXLoginRequest = z.infer<typeof StartXLoginRequest>;
73
81
  export type EmailLoginRequest = z.infer<typeof EmailLoginRequest>;
74
82
  export type LoginRequest = z.infer<typeof LoginRequest>;
75
83
  export type RefreshTokenRequest = z.infer<typeof RefreshTokenRequest>;
@@ -21,6 +21,16 @@ const LinkWalletRequest = z.object({
21
21
  signature: z.string().min(1, "Signature is required").describe("Signature of the nonce message"),
22
22
  nonce: SignedNonce
23
23
  }).describe("Link wallet credentials to the authenticated account");
24
+ const StartXLinkRequest = z.object({
25
+ returnTo: z.string().optional().describe(
26
+ "Page to send the browser back to once the link finishes, normally the page the user is on. Must be on the calling origin; defaults to that origin."
27
+ )
28
+ }).describe("Start of the X account link flow");
29
+ const StartXLoginRequest = z.object({
30
+ returnTo: z.string().optional().describe(
31
+ "Page to send the browser back to once the sign-in finishes, normally the page the user is on. Must be on the calling origin; defaults to that origin."
32
+ )
33
+ }).describe("Start of the X sign-in flow");
24
34
  const WalletLoginRequest = z.object({
25
35
  method: z.literal("wallet").describe('Must be "wallet" for wallet authentication'),
26
36
  address: EthereumAddress,
@@ -64,4 +74,4 @@ const OauthInteractionConfirmRequest = z.object({
64
74
  )
65
75
  }).describe("Consent confirmation body \u2014 the granted scope set");
66
76
 
67
- export { ChangePasswordRequest, EmailLoginRequest, EmailRegisterRequest, ForgotPasswordRequest, LinkEmailRequest, LinkWalletRequest, LoginRequest, LogoutRequest, OauthInteractionConfirmRequest, RefreshTokenRequest, RequestNonceRequest, ResendVerificationForRegisterRequest, ResetPasswordRequest, VerifyEmailRequest, WalletLoginRequest };
77
+ export { ChangePasswordRequest, EmailLoginRequest, EmailRegisterRequest, ForgotPasswordRequest, LinkEmailRequest, LinkWalletRequest, LoginRequest, LogoutRequest, OauthInteractionConfirmRequest, RefreshTokenRequest, RequestNonceRequest, ResendVerificationForRegisterRequest, ResetPasswordRequest, StartXLinkRequest, StartXLoginRequest, VerifyEmailRequest, WalletLoginRequest };
@@ -13,6 +13,7 @@ export declare const LoginResponse: z.ZodObject<{
13
13
  email: "email";
14
14
  evm_wallet: "evm_wallet";
15
15
  oauth: "oauth";
16
+ x: "x";
16
17
  }>;
17
18
  }, z.core.$strip>;
18
19
  }, z.core.$strip>;
@@ -50,11 +51,24 @@ export declare const VerifyEmailResponse: z.ZodObject<{
50
51
  }, z.core.$strip>;
51
52
  export declare const LinkEmailResponse: z.ZodVoid;
52
53
  export declare const LinkWalletResponse: z.ZodVoid;
54
+ export declare const StartXLinkResponse: z.ZodObject<{
55
+ authorizeUrl: z.ZodString;
56
+ }, z.core.$strip>;
57
+ export declare const DisconnectXResponse: z.ZodVoid;
58
+ export declare const StartXLoginResponse: z.ZodObject<{
59
+ authorizeUrl: z.ZodString;
60
+ }, z.core.$strip>;
53
61
  export declare const RequestNonceResponse: z.ZodObject<{
54
62
  nonce: z.ZodString;
55
63
  message: z.ZodString;
56
64
  expiresAt: z.ZodNumber;
57
65
  }, z.core.$strip>;
66
+ /**
67
+ * The session endpoint answers for the whole account, not just the credential in play:
68
+ * `providerId`/`loginMethod` describe the current session, `identities` lists every login
69
+ * the account can be reached by - which is what a client needs to offer "connect" and
70
+ * "disconnect" for the rest.
71
+ */
58
72
  export declare const MeResponse: z.ZodObject<{
59
73
  id: z.ZodUUID;
60
74
  role: z.ZodEnum<{
@@ -66,7 +80,18 @@ export declare const MeResponse: z.ZodObject<{
66
80
  email: "email";
67
81
  evm_wallet: "evm_wallet";
68
82
  oauth: "oauth";
83
+ x: "x";
69
84
  }>;
85
+ identities: z.ZodArray<z.ZodObject<{
86
+ provider: z.ZodEnum<{
87
+ email: "email";
88
+ evm_wallet: "evm_wallet";
89
+ oauth: "oauth";
90
+ x: "x";
91
+ }>;
92
+ externalId: z.ZodString;
93
+ connectedAt: z.ZodString;
94
+ }, z.core.$strip>>;
70
95
  }, z.core.$strip>;
71
96
  export declare const OauthGrant: z.ZodObject<{
72
97
  id: z.ZodString;
@@ -111,6 +136,9 @@ export type LogoutResponse = z.infer<typeof LogoutResponse>;
111
136
  export type RegisterEmailResponse = z.infer<typeof RegisterEmailResponse>;
112
137
  export type LinkEmailResponse = z.infer<typeof LinkEmailResponse>;
113
138
  export type LinkWalletResponse = z.infer<typeof LinkWalletResponse>;
139
+ export type StartXLinkResponse = z.infer<typeof StartXLinkResponse>;
140
+ export type DisconnectXResponse = z.infer<typeof DisconnectXResponse>;
141
+ export type StartXLoginResponse = z.infer<typeof StartXLoginResponse>;
114
142
  export type MeResponse = z.infer<typeof MeResponse>;
115
143
  export type OauthGrant = z.infer<typeof OauthGrant>;
116
144
  export type OauthGrantsResponse = z.infer<typeof OauthGrantsResponse>;
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { AuthenticatedUser } from './entities';
2
+ import { AuthenticatedUser, ConnectedIdentity } from './entities';
3
3
 
4
4
  const LoginResponse = z.object({
5
5
  accessToken: z.string().describe("New JWT access token"),
@@ -31,12 +31,21 @@ const VerifyEmailResponse = z.object({
31
31
  }).describe("Successful email verification response");
32
32
  const LinkEmailResponse = z.void().describe("Successful email verification response");
33
33
  const LinkWalletResponse = z.void().describe("Successful wallet link response");
34
+ const StartXLinkResponse = z.object({
35
+ authorizeUrl: z.string().describe("X authorization URL to send the browser to. Expires with the flow's state.")
36
+ }).describe("Start of the X account link flow");
37
+ const DisconnectXResponse = z.void().describe("Successful X account disconnect response");
38
+ const StartXLoginResponse = z.object({
39
+ authorizeUrl: z.string().describe("X authorization URL to send the browser to. Expires with the flow's state.")
40
+ }).describe("Start of the X sign-in flow");
34
41
  const RequestNonceResponse = z.object({
35
42
  nonce: z.string().describe("Nonce to sign with wallet"),
36
43
  message: z.string().describe("Domain-bound wallet sign-in message"),
37
44
  expiresAt: z.number().int().positive().describe("Unix timestamp when nonce expires")
38
45
  }).describe("Nonce response for wallet authentication");
39
- const MeResponse = AuthenticatedUser.describe("Current authenticated user info");
46
+ const MeResponse = AuthenticatedUser.extend({
47
+ identities: z.array(ConnectedIdentity).describe("Every provider identity connected to this account, oldest first")
48
+ }).describe("Current authenticated user info");
40
49
  const OauthGrant = z.object({
41
50
  id: z.string().describe("OAuth grant id \u2014 used to revoke this grant"),
42
51
  name: z.string().describe("Human-readable client name, falling back to the client id when unnamed"),
@@ -64,4 +73,4 @@ const OauthInteractionRedirectResponse = z.object({
64
73
  returnTo: z.string().describe("Provider URL to redirect the browser back to")
65
74
  }).describe("OAuth interaction redirect target after login/confirm/abort");
66
75
 
67
- export { ChangePasswordResponse, ForgotPasswordResponse, LinkEmailResponse, LinkWalletResponse, LoginResponse, LogoutResponse, MeResponse, OauthGrant, OauthGrantsResponse, OauthInteractionClient, OauthInteractionDetailsResponse, OauthInteractionRedirectResponse, RefreshSessionResponse, RefreshTokenResponse, RegisterEmailResponse, RequestNonceResponse, ResendVerificationResponse, ResetPasswordResponse, VerifyEmailResponse };
76
+ export { ChangePasswordResponse, DisconnectXResponse, ForgotPasswordResponse, LinkEmailResponse, LinkWalletResponse, LoginResponse, LogoutResponse, MeResponse, OauthGrant, OauthGrantsResponse, OauthInteractionClient, OauthInteractionDetailsResponse, OauthInteractionRedirectResponse, RefreshSessionResponse, RefreshTokenResponse, RegisterEmailResponse, RequestNonceResponse, ResendVerificationResponse, ResetPasswordResponse, StartXLinkResponse, StartXLoginResponse, VerifyEmailResponse };
@@ -17,6 +17,10 @@ export declare const LeaderboardRow: z.ZodObject<{
17
17
  pearFee: z.ZodString;
18
18
  tradeFee: z.ZodString;
19
19
  totalTrades: z.ZodNumber;
20
+ xHandle: z.ZodOptional<z.ZodString>;
21
+ xName: z.ZodOptional<z.ZodString>;
22
+ xAvatarUrl: z.ZodOptional<z.ZodString>;
23
+ xUserId: z.ZodOptional<z.ZodString>;
20
24
  }, z.core.$strip>;
21
25
  export type LeaderboardRow = z.output<typeof LeaderboardRow>;
22
26
  export declare const VolumeStatistics: z.ZodObject<{
@@ -20,7 +20,21 @@ const LeaderboardRow = z.object({
20
20
  // V2 calls this builderFee; V3 names it for the column it comes from.
21
21
  pearFee: z.string(),
22
22
  tradeFee: z.string(),
23
- totalTrades: z.number()
23
+ totalTrades: z.number(),
24
+ // The trader's linked X account. Absent for an account whose owner has connected no X
25
+ // account, and absent for an anonymous caller: the board itself is public, but pairing a
26
+ // real name with a wallet address and a PnL for the open internet is a wider promise than
27
+ // the one the user accepted when connecting X. Never null-with-a-key: absence is the
28
+ // signal.
29
+ //
30
+ // Whatever X reported at the owner's last authorization. Nothing re-reads X in between,
31
+ // so a trader who renamed and has not signed in since is named by their old handle.
32
+ xHandle: z.string().optional(),
33
+ xName: z.string().optional(),
34
+ xAvatarUrl: z.string().optional(),
35
+ // Immutable X numeric id. Link by this, never by the handle: X frees a renamed handle
36
+ // for anyone to claim immediately, so a cached handle can point at a stranger.
37
+ xUserId: z.string().optional()
24
38
  });
25
39
  const VolumeStatistics = z.object({
26
40
  timestamp: z.number(),
@@ -18,6 +18,10 @@ export declare const LeaderboardResponse: z.ZodObject<{
18
18
  pearFee: z.ZodString;
19
19
  tradeFee: z.ZodString;
20
20
  totalTrades: z.ZodNumber;
21
+ xHandle: z.ZodOptional<z.ZodString>;
22
+ xName: z.ZodOptional<z.ZodString>;
23
+ xAvatarUrl: z.ZodOptional<z.ZodString>;
24
+ xUserId: z.ZodOptional<z.ZodString>;
21
25
  }, z.core.$strip>>;
22
26
  }, z.core.$strip>;
23
27
  export type LeaderboardResponse = z.output<typeof LeaderboardResponse>;
@@ -12,6 +12,9 @@ export declare const UserProfile: z.ZodObject<{
12
12
  address: z.ZodNullable<z.ZodString>;
13
13
  email: z.ZodNullable<z.ZodString>;
14
14
  emailVerified: z.ZodBoolean;
15
+ xHandle: z.ZodNullable<z.ZodString>;
16
+ xName: z.ZodNullable<z.ZodString>;
17
+ xAvatarUrl: z.ZodNullable<z.ZodString>;
15
18
  }, z.core.$strip>;
16
19
  export type UserPreferences = z.infer<typeof UserPreferences>;
17
20
  export type UserProfile = z.infer<typeof UserProfile>;
@@ -10,7 +10,12 @@ const UserProfile = z.object({
10
10
  role: z.enum(["basic", "pro"]).describe("User role"),
11
11
  address: z.string().nullable().describe("Linked wallet address (for evm_wallet provider)"),
12
12
  email: z.string().nullable().describe("Linked email address (for email provider)"),
13
- emailVerified: z.boolean().describe("Whether the email is verified")
13
+ emailVerified: z.boolean().describe("Whether the email is verified"),
14
+ // Nullable rather than optional to match `address` and `email` above. Splitting
15
+ // conventions inside one object costs more than following its neighbours.
16
+ xHandle: z.string().nullable().describe('Linked X handle, without the leading "@" (for x provider)'),
17
+ xName: z.string().nullable().describe("Linked X display name"),
18
+ xAvatarUrl: z.string().nullable().describe("Linked X avatar URL")
14
19
  }).describe("User profile of the authenticated user");
15
20
  const ReferralReferee = z.object({
16
21
  address: EthereumAddress.optional().describe("Linked EVM wallet address when the referee has one"),
@@ -10,6 +10,9 @@ export declare const ProfileResponse: z.ZodObject<{
10
10
  address: z.ZodNullable<z.ZodString>;
11
11
  email: z.ZodNullable<z.ZodString>;
12
12
  emailVerified: z.ZodBoolean;
13
+ xHandle: z.ZodNullable<z.ZodString>;
14
+ xName: z.ZodNullable<z.ZodString>;
15
+ xAvatarUrl: z.ZodNullable<z.ZodString>;
13
16
  }, z.core.$strip>;
14
17
  preferences: z.ZodObject<{
15
18
  slippageToleranceBps: z.ZodInt;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pear-protocol/types",
3
- "version": "1.22.0",
3
+ "version": "1.24.0",
4
4
  "description": "Pear Protocol Types definitions",
5
5
  "private": false,
6
6
  "type": "module",