-
Notifications
You must be signed in to change notification settings - Fork 338
/
Copy pathSignUpAttempt.ts
87 lines (80 loc) · 2.87 KB
/
SignUpAttempt.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import type { SignUpStatus } from '@clerk/types';
import type { SignUpVerificationNextAction } from './Enums';
import type { SignUpJSON, SignUpVerificationJSON, SignUpVerificationsJSON } from './JSON';
export class SignUpAttemptVerification {
constructor(
readonly nextAction: SignUpVerificationNextAction,
readonly supportedStrategies: string[],
) {}
static fromJSON(data: SignUpVerificationJSON): SignUpAttemptVerification {
return new SignUpAttemptVerification(data.next_action, data.supported_strategies);
}
}
export class SignUpAttemptVerifications {
constructor(
readonly emailAddress: SignUpAttemptVerification | null,
readonly phoneNumber: SignUpAttemptVerification | null,
readonly web3Wallet: SignUpAttemptVerification | null,
readonly externalAccount: object | null,
) {}
static fromJSON(data: SignUpVerificationsJSON): SignUpAttemptVerifications {
return new SignUpAttemptVerifications(
data.email_address && SignUpAttemptVerification.fromJSON(data.email_address),
data.phone_number && SignUpAttemptVerification.fromJSON(data.phone_number),
data.web3_wallet && SignUpAttemptVerification.fromJSON(data.web3_wallet),
data.external_account,
);
}
}
export class SignUpAttempt {
constructor(
readonly id: string,
readonly status: SignUpStatus,
readonly requiredFields: string[],
readonly optionalFields: string[],
readonly missingFields: string[],
readonly unverifiedFields: string[],
readonly verifications: SignUpAttemptVerifications | null,
readonly username: string | null,
readonly emailAddress: string | null,
readonly phoneNumber: string | null,
readonly web3Wallet: string | null,
readonly passwordEnabled: boolean,
readonly firstName: string | null,
readonly lastName: string | null,
readonly customAction: boolean,
readonly externalId: string | null,
readonly createdSessionId: string | null,
readonly createdUserId: string | null,
readonly abandonAt: number | null,
readonly legalAcceptedAt: number | null,
readonly publicMetadata?: Record<string, unknown> | null,
readonly unsafeMetadata?: Record<string, unknown> | null,
) {}
static fromJSON(data: SignUpJSON): SignUpAttempt {
return new SignUpAttempt(
data.id,
data.status,
data.required_fields,
data.optional_fields,
data.missing_fields,
data.unverified_fields,
data.verifications ? SignUpAttemptVerifications.fromJSON(data.verifications) : null,
data.username,
data.email_address,
data.phone_number,
data.web3_wallet,
data.password_enabled,
data.first_name,
data.last_name,
data.custom_action,
data.external_id,
data.created_session_id,
data.created_user_id,
data.abandon_at,
data.legal_accepted_at,
data.public_metadata,
data.unsafe_metadata,
);
}
}