@pear-protocol/types 0.0.5 → 0.0.7
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/auth/payloads.d.ts +14 -0
- package/dist/auth/payloads.js +12 -1
- package/dist/auth/response.d.ts +7 -0
- package/dist/auth/response.js +5 -1
- package/dist/instrument/entities.js +1 -1
- package/dist/schedule/payloads.d.ts +8 -8
- package/dist/schedule/payloads.js +9 -5
- package/dist/users/payloads.d.ts +4 -0
- package/dist/users/payloads.js +20 -1
- package/dist/users/response.d.ts +4 -0
- package/dist/users/response.js +4 -1
- package/package.json +1 -1
package/dist/auth/payloads.d.ts
CHANGED
|
@@ -27,6 +27,17 @@ export declare const VerifyEmailRequest: z.ZodObject<{
|
|
|
27
27
|
token: z.ZodString;
|
|
28
28
|
password: z.ZodOptional<z.ZodString>;
|
|
29
29
|
}, z.core.$strip>;
|
|
30
|
+
export declare const ChangePasswordRequest: z.ZodObject<{
|
|
31
|
+
currentPassword: z.ZodString;
|
|
32
|
+
newPassword: z.ZodString;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export declare const ForgotPasswordRequest: z.ZodObject<{
|
|
35
|
+
email: z.ZodPipe<z.ZodEmail, z.ZodTransform<string, string>>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
export declare const ResetPasswordRequest: z.ZodObject<{
|
|
38
|
+
token: z.ZodString;
|
|
39
|
+
password: z.ZodString;
|
|
40
|
+
}, z.core.$strip>;
|
|
30
41
|
export declare const LoginRequest: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
31
42
|
method: z.ZodLiteral<"wallet">;
|
|
32
43
|
address: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
@@ -56,3 +67,6 @@ export type RefreshTokenRequest = z.infer<typeof RefreshTokenRequest>;
|
|
|
56
67
|
export type LogoutRequest = z.infer<typeof LogoutRequest>;
|
|
57
68
|
export type VerifyEmailRequest = z.infer<typeof VerifyEmailRequest>;
|
|
58
69
|
export type ResendVerificationForRegisterRequest = z.infer<typeof ResendVerificationForRegisterRequest>;
|
|
70
|
+
export type ChangePasswordRequest = z.infer<typeof ChangePasswordRequest>;
|
|
71
|
+
export type ForgotPasswordRequest = z.infer<typeof ForgotPasswordRequest>;
|
|
72
|
+
export type ResetPasswordRequest = z.infer<typeof ResetPasswordRequest>;
|
package/dist/auth/payloads.js
CHANGED
|
@@ -31,6 +31,17 @@ const VerifyEmailRequest = z.object({
|
|
|
31
31
|
token: z.string().min(1, "Token is required").describe("Verification token"),
|
|
32
32
|
password: Password.optional().describe("Password for the email claim if using link-flow")
|
|
33
33
|
}).describe("Verify email claim using the token from the verification email");
|
|
34
|
+
const ChangePasswordRequest = z.object({
|
|
35
|
+
currentPassword: Password.describe("Current password for the authenticated user"),
|
|
36
|
+
newPassword: Password.describe("New password to set")
|
|
37
|
+
}).describe("Change password for an authenticated user");
|
|
38
|
+
const ForgotPasswordRequest = z.object({
|
|
39
|
+
email: Email
|
|
40
|
+
}).describe("Request a password reset link by email");
|
|
41
|
+
const ResetPasswordRequest = z.object({
|
|
42
|
+
token: z.string().min(1, "Token is required").describe("Password reset token"),
|
|
43
|
+
password: Password.describe("New password to set")
|
|
44
|
+
}).describe("Reset password using a password reset token");
|
|
34
45
|
const LoginRequest = z.discriminatedUnion("method", [WalletLoginRequest, EmailLoginRequest]);
|
|
35
46
|
const RefreshTokenRequest = z.object({
|
|
36
47
|
refreshToken: z.string().min(1, "Refresh token is required").describe("Refresh token")
|
|
@@ -42,4 +53,4 @@ const LogoutRequest = z.object({
|
|
|
42
53
|
refreshToken: z.string().min(1, "Refresh token is required").describe("Refresh token to revoke")
|
|
43
54
|
}).describe("Logout and revoke refresh token");
|
|
44
55
|
|
|
45
|
-
export { EmailLoginRequest, EmailRegisterRequest, LinkEmailRequest, LinkWalletRequest, LoginRequest, LogoutRequest, RefreshTokenRequest, RequestNonceRequest, ResendVerificationForRegisterRequest, VerifyEmailRequest, WalletLoginRequest };
|
|
56
|
+
export { ChangePasswordRequest, EmailLoginRequest, EmailRegisterRequest, ForgotPasswordRequest, LinkEmailRequest, LinkWalletRequest, LoginRequest, LogoutRequest, RefreshTokenRequest, RequestNonceRequest, ResendVerificationForRegisterRequest, ResetPasswordRequest, VerifyEmailRequest, WalletLoginRequest };
|
package/dist/auth/response.d.ts
CHANGED
|
@@ -20,6 +20,9 @@ export declare const LogoutResponse: z.ZodVoid;
|
|
|
20
20
|
export declare const RegisterEmailResponse: z.ZodVoid;
|
|
21
21
|
export declare const VerifyEmailResponse: z.ZodVoid;
|
|
22
22
|
export declare const ResendVerificationResponse: z.ZodVoid;
|
|
23
|
+
export declare const ChangePasswordResponse: z.ZodVoid;
|
|
24
|
+
export declare const ForgotPasswordResponse: z.ZodVoid;
|
|
25
|
+
export declare const ResetPasswordResponse: z.ZodVoid;
|
|
23
26
|
export declare const LinkEmailResponse: z.ZodVoid;
|
|
24
27
|
export declare const LinkWalletResponse: z.ZodObject<{
|
|
25
28
|
user: z.ZodObject<{
|
|
@@ -33,6 +36,7 @@ export declare const LinkWalletResponse: z.ZodObject<{
|
|
|
33
36
|
}, z.core.$strip>;
|
|
34
37
|
export declare const RequestNonceResponse: z.ZodObject<{
|
|
35
38
|
nonce: z.ZodString;
|
|
39
|
+
message: z.ZodString;
|
|
36
40
|
expiresAt: z.ZodNumber;
|
|
37
41
|
}, z.core.$strip>;
|
|
38
42
|
export declare const MeResponse: z.ZodObject<{
|
|
@@ -54,3 +58,6 @@ export type LinkWalletResponse = z.infer<typeof LinkWalletResponse>;
|
|
|
54
58
|
export type MeResponse = z.infer<typeof MeResponse>;
|
|
55
59
|
export type ResendVerificationResponse = z.infer<typeof ResendVerificationResponse>;
|
|
56
60
|
export type VerifyEmailResponse = z.infer<typeof VerifyEmailResponse>;
|
|
61
|
+
export type ChangePasswordResponse = z.infer<typeof ChangePasswordResponse>;
|
|
62
|
+
export type ForgotPasswordResponse = z.infer<typeof ForgotPasswordResponse>;
|
|
63
|
+
export type ResetPasswordResponse = z.infer<typeof ResetPasswordResponse>;
|
package/dist/auth/response.js
CHANGED
|
@@ -13,12 +13,16 @@ const LogoutResponse = z.void().describe("Successful logout response");
|
|
|
13
13
|
const RegisterEmailResponse = z.void().describe("Successful email registration response");
|
|
14
14
|
const VerifyEmailResponse = z.void().describe("Successful email verification response");
|
|
15
15
|
const ResendVerificationResponse = z.void().describe("Successful resend verification email response");
|
|
16
|
+
const ChangePasswordResponse = z.void().describe("Successful password change response");
|
|
17
|
+
const ForgotPasswordResponse = z.void().describe("Successful password reset request response");
|
|
18
|
+
const ResetPasswordResponse = z.void().describe("Successful password reset response");
|
|
16
19
|
const LinkEmailResponse = z.void().describe("Successful email verification response");
|
|
17
20
|
const LinkWalletResponse = z.object({ user: AuthenticatedUser }).describe("Successful link response");
|
|
18
21
|
const RequestNonceResponse = z.object({
|
|
19
22
|
nonce: z.string().describe("Nonce to sign with wallet"),
|
|
23
|
+
message: z.string().describe("Domain-bound wallet sign-in message"),
|
|
20
24
|
expiresAt: z.number().int().positive().describe("Unix timestamp when nonce expires")
|
|
21
25
|
}).describe("Nonce response for wallet authentication");
|
|
22
26
|
const MeResponse = AuthenticatedUser.describe("Current authenticated user info");
|
|
23
27
|
|
|
24
|
-
export { LinkEmailResponse, LinkWalletResponse, LoginResponse, LogoutResponse, MeResponse, RefreshSessionResponse, RefreshTokenResponse, RegisterEmailResponse, RequestNonceResponse, ResendVerificationResponse, VerifyEmailResponse };
|
|
28
|
+
export { ChangePasswordResponse, ForgotPasswordResponse, LinkEmailResponse, LinkWalletResponse, LoginResponse, LogoutResponse, MeResponse, RefreshSessionResponse, RefreshTokenResponse, RegisterEmailResponse, RequestNonceResponse, ResendVerificationResponse, ResetPasswordResponse, VerifyEmailResponse };
|
|
@@ -2,7 +2,7 @@ import { z } from 'zod';
|
|
|
2
2
|
import { Connector } from '../connector';
|
|
3
3
|
import { InstrumentPrecision } from '../instrument-precision';
|
|
4
4
|
|
|
5
|
-
const InstrumentId = z.string();
|
|
5
|
+
const InstrumentId = z.string().trim().min(1, "Instrument ID is required").max(64, "Instrument ID must be at most 64 characters").regex(/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/, "Instrument ID contains invalid characters");
|
|
6
6
|
const InstrumentType = z.enum(["spot", "perp", "hip3"]);
|
|
7
7
|
const Instrument = z.object({
|
|
8
8
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
declare const CreateTWAPOpen: z.ZodObject<{
|
|
3
|
-
startAt: z.
|
|
4
|
-
endAt: z.
|
|
3
|
+
startAt: z.ZodPipe<z.ZodOptional<z.ZodCoercedDate<unknown>>, z.ZodTransform<Date, Date | undefined>>;
|
|
4
|
+
endAt: z.ZodPipe<z.ZodOptional<z.ZodCoercedDate<unknown>>, z.ZodTransform<Date, Date | undefined>>;
|
|
5
5
|
strategy: z.ZodLiteral<"TWAP">;
|
|
6
6
|
intent: z.ZodLiteral<"OPEN">;
|
|
7
7
|
executionType: z.ZodLiteral<"MARKET">;
|
|
@@ -21,8 +21,8 @@ declare const CreateTWAPOpen: z.ZodObject<{
|
|
|
21
21
|
sliceIntervalMs: z.ZodInt;
|
|
22
22
|
}, z.core.$strip>;
|
|
23
23
|
declare const CreateTWAPClose: z.ZodObject<{
|
|
24
|
-
startAt: z.
|
|
25
|
-
endAt: z.
|
|
24
|
+
startAt: z.ZodPipe<z.ZodOptional<z.ZodCoercedDate<unknown>>, z.ZodTransform<Date, Date | undefined>>;
|
|
25
|
+
endAt: z.ZodPipe<z.ZodOptional<z.ZodCoercedDate<unknown>>, z.ZodTransform<Date, Date | undefined>>;
|
|
26
26
|
strategy: z.ZodLiteral<"TWAP">;
|
|
27
27
|
intent: z.ZodLiteral<"CLOSE">;
|
|
28
28
|
executionType: z.ZodLiteral<"MARKET">;
|
|
@@ -34,8 +34,8 @@ declare const CreateTWAPClose: z.ZodObject<{
|
|
|
34
34
|
sliceIntervalMs: z.ZodInt;
|
|
35
35
|
}, z.core.$strip>;
|
|
36
36
|
export declare const CreateSchedule: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
37
|
-
startAt: z.
|
|
38
|
-
endAt: z.
|
|
37
|
+
startAt: z.ZodPipe<z.ZodOptional<z.ZodCoercedDate<unknown>>, z.ZodTransform<Date, Date | undefined>>;
|
|
38
|
+
endAt: z.ZodPipe<z.ZodOptional<z.ZodCoercedDate<unknown>>, z.ZodTransform<Date, Date | undefined>>;
|
|
39
39
|
strategy: z.ZodLiteral<"TWAP">;
|
|
40
40
|
intent: z.ZodLiteral<"OPEN">;
|
|
41
41
|
executionType: z.ZodLiteral<"MARKET">;
|
|
@@ -54,8 +54,8 @@ export declare const CreateSchedule: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
54
54
|
targetNotional: z.ZodString;
|
|
55
55
|
sliceIntervalMs: z.ZodInt;
|
|
56
56
|
}, z.core.$strip>, z.ZodObject<{
|
|
57
|
-
startAt: z.
|
|
58
|
-
endAt: z.
|
|
57
|
+
startAt: z.ZodPipe<z.ZodOptional<z.ZodCoercedDate<unknown>>, z.ZodTransform<Date, Date | undefined>>;
|
|
58
|
+
endAt: z.ZodPipe<z.ZodOptional<z.ZodCoercedDate<unknown>>, z.ZodTransform<Date, Date | undefined>>;
|
|
59
59
|
strategy: z.ZodLiteral<"TWAP">;
|
|
60
60
|
intent: z.ZodLiteral<"CLOSE">;
|
|
61
61
|
executionType: z.ZodLiteral<"MARKET">;
|
|
@@ -4,6 +4,9 @@ import { InstrumentId } from '../instrument';
|
|
|
4
4
|
import { ScheduleSliceMode } from './entities';
|
|
5
5
|
|
|
6
6
|
const SliceInterval = z.int().min(6e4).max(26784e5);
|
|
7
|
+
const THIRTY_DAYS_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
8
|
+
const DefaultStartAt = z.coerce.date().optional().transform((value) => value ?? /* @__PURE__ */ new Date());
|
|
9
|
+
const DefaultEndAt = z.coerce.date().optional().transform((value) => value ?? new Date(Date.now() + THIRTY_DAYS_MS));
|
|
7
10
|
const TWAPSliceOpenLeg = z.object({
|
|
8
11
|
/**
|
|
9
12
|
* Instrument ID
|
|
@@ -38,14 +41,15 @@ const BaseSchedule = z.object({
|
|
|
38
41
|
/**
|
|
39
42
|
* Start at date
|
|
40
43
|
*/
|
|
41
|
-
startAt:
|
|
44
|
+
startAt: DefaultStartAt,
|
|
42
45
|
/**
|
|
43
46
|
* End at date
|
|
44
47
|
*/
|
|
45
|
-
endAt:
|
|
46
|
-
|
|
48
|
+
endAt: DefaultEndAt
|
|
49
|
+
}).refine((data) => data.startAt && data.endAt && data.startAt < data.endAt, {
|
|
50
|
+
message: "Start at date must be before end at date"
|
|
47
51
|
});
|
|
48
|
-
const CreateTWAPOpen = BaseSchedule.
|
|
52
|
+
const CreateTWAPOpen = BaseSchedule.safeExtend({
|
|
49
53
|
/**
|
|
50
54
|
* Strategy
|
|
51
55
|
*/
|
|
@@ -71,7 +75,7 @@ const CreateTWAPOpen = BaseSchedule.extend({
|
|
|
71
75
|
*/
|
|
72
76
|
sliceIntervalMs: SliceInterval
|
|
73
77
|
});
|
|
74
|
-
const CreateTWAPClose = BaseSchedule.
|
|
78
|
+
const CreateTWAPClose = BaseSchedule.safeExtend({
|
|
75
79
|
/**
|
|
76
80
|
* Strategy
|
|
77
81
|
*/
|
package/dist/users/payloads.d.ts
CHANGED
|
@@ -3,3 +3,7 @@ export declare const UpdateUserPreferences: z.ZodObject<{
|
|
|
3
3
|
slippageToleranceBps: z.ZodOptional<z.ZodInt>;
|
|
4
4
|
}, z.core.$strip>;
|
|
5
5
|
export type UpdateUserPreferences = z.infer<typeof UpdateUserPreferences>;
|
|
6
|
+
export declare const UpdateUserDisplayName: z.ZodObject<{
|
|
7
|
+
displayName: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodString>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export type UpdateUserDisplayName = z.infer<typeof UpdateUserDisplayName>;
|
package/dist/users/payloads.js
CHANGED
|
@@ -3,5 +3,24 @@ import { z } from 'zod';
|
|
|
3
3
|
const UpdateUserPreferences = z.object({
|
|
4
4
|
slippageToleranceBps: z.int().min(1).max(1e4).optional().describe("User slippage preference in basis points")
|
|
5
5
|
}).describe("Payload to update user preferences");
|
|
6
|
+
const DISPLAY_NAME_REGEX = /^[\p{L}\p{N} .'-]+$/u;
|
|
7
|
+
const DisplayNameSchema = z.preprocess(
|
|
8
|
+
(value) => {
|
|
9
|
+
if (typeof value !== "string") return value;
|
|
10
|
+
return value.normalize("NFKC").trim().replace(/\s+/g, " ");
|
|
11
|
+
},
|
|
12
|
+
z.string().min(1, "Display name must be at least 1 character").max(40, "Display name must be at most 40 characters").refine((value) => !/[\u200B-\u200D\uFEFF]/.test(value), {
|
|
13
|
+
message: "Display name contains invisible characters"
|
|
14
|
+
}).refine((value) => DISPLAY_NAME_REGEX.test(value), {
|
|
15
|
+
message: "Display name may only contain letters, numbers, spaces, apostrophes, hyphens, and periods"
|
|
16
|
+
}).refine((value) => /[\p{L}\p{N}]/u.test(value), {
|
|
17
|
+
message: "Display name must contain at least one letter or number"
|
|
18
|
+
}).refine((value) => !/^[ .'-]|[ .'-]$/.test(value), {
|
|
19
|
+
message: "Display name cannot start or end with punctuation"
|
|
20
|
+
}).refine((value) => !/[ .'-]{2,}/.test(value), {
|
|
21
|
+
message: "Display name cannot contain repeated separators"
|
|
22
|
+
})
|
|
23
|
+
);
|
|
24
|
+
const UpdateUserDisplayName = z.object({ displayName: DisplayNameSchema }).describe("Payload to update user display name");
|
|
6
25
|
|
|
7
|
-
export { UpdateUserPreferences };
|
|
26
|
+
export { UpdateUserDisplayName, UpdateUserPreferences };
|
package/dist/users/response.d.ts
CHANGED
|
@@ -22,3 +22,7 @@ export declare const UpdateUserPreferencesResponse: z.ZodObject<{
|
|
|
22
22
|
}, z.core.$strip>;
|
|
23
23
|
}, z.core.$strip>;
|
|
24
24
|
export type UpdateUserPreferencesResponse = z.infer<typeof UpdateUserPreferencesResponse>;
|
|
25
|
+
export declare const UpdateUserDisplayNameResponse: z.ZodObject<{
|
|
26
|
+
displayName: z.ZodString;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
export type UpdateUserDisplayNameResponse = z.infer<typeof UpdateUserDisplayNameResponse>;
|
package/dist/users/response.js
CHANGED
|
@@ -8,5 +8,8 @@ const ProfileResponse = z.object({
|
|
|
8
8
|
const UpdateUserPreferencesResponse = z.object({
|
|
9
9
|
preferences: UserPreferences
|
|
10
10
|
});
|
|
11
|
+
const UpdateUserDisplayNameResponse = z.object({
|
|
12
|
+
displayName: z.string().describe("Updated user display name")
|
|
13
|
+
});
|
|
11
14
|
|
|
12
|
-
export { ProfileResponse, UpdateUserPreferencesResponse };
|
|
15
|
+
export { ProfileResponse, UpdateUserDisplayNameResponse, UpdateUserPreferencesResponse };
|