@wacht/types 0.0.1-alpha.1
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/package.json +13 -0
- package/src/auth.ts +40 -0
- package/src/client.ts +60 -0
- package/src/deployment.ts +196 -0
- package/src/index.ts +7 -0
- package/src/organization.ts +139 -0
- package/src/profile.ts +32 -0
- package/src/session.ts +98 -0
- package/src/user.ts +82 -0
package/package.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wacht/types",
|
|
3
|
+
"version": "0.0.1-alpha.1",
|
|
4
|
+
"description": "Shared TypeScript types for wacht libraries",
|
|
5
|
+
"main": "./src/index.ts",
|
|
6
|
+
"types": "./src/index.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"src"
|
|
9
|
+
],
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"typescript": "^5.8.3"
|
|
12
|
+
}
|
|
13
|
+
}
|
package/src/auth.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface SignUpParams {
|
|
2
|
+
first_name?: string;
|
|
3
|
+
last_name?: string;
|
|
4
|
+
username?: string;
|
|
5
|
+
phone_number?: string;
|
|
6
|
+
email?: string;
|
|
7
|
+
password?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface SSOResponse {
|
|
11
|
+
oauth_url: string;
|
|
12
|
+
session: unknown;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface SignInParams {
|
|
16
|
+
email?: string;
|
|
17
|
+
username?: string;
|
|
18
|
+
password?: string;
|
|
19
|
+
phone?: string;
|
|
20
|
+
strategy?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface SignInResponse {
|
|
24
|
+
session: unknown;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface SSOCallbackResponse {
|
|
28
|
+
session: unknown;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type SocialConnectionProvider =
|
|
32
|
+
| "x_oauth"
|
|
33
|
+
| "github_oauth"
|
|
34
|
+
| "gitlab_oauth"
|
|
35
|
+
| "google_oauth"
|
|
36
|
+
| "facebook_oauth"
|
|
37
|
+
| "microsoft_oauth"
|
|
38
|
+
| "linkedin_oauth"
|
|
39
|
+
| "discord_oauth"
|
|
40
|
+
| "apple_oauth"
|
package/src/client.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export type Client = (
|
|
2
|
+
url: URL | string,
|
|
3
|
+
options?: RequestInit
|
|
4
|
+
) => Promise<Response>;
|
|
5
|
+
|
|
6
|
+
export type ClinetReponse<T> = {
|
|
7
|
+
status: number;
|
|
8
|
+
message: string;
|
|
9
|
+
data: T;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type ErrorInterface = {
|
|
13
|
+
message: string;
|
|
14
|
+
code: ErrorCode;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export enum ErrorCode {
|
|
18
|
+
Unknown = "unknown",
|
|
19
|
+
UserNotFound = "USER_NOT_FOUND",
|
|
20
|
+
UserDisabled = "USER_DISABLED",
|
|
21
|
+
MissingVerificationCode = "missing_verification_code",
|
|
22
|
+
VerificationCodeExpired = "verification_code_expired",
|
|
23
|
+
UsernameExists = "USERNAME_EXISTS",
|
|
24
|
+
EmailExists = "EMAIL_EXISTS",
|
|
25
|
+
InvalidCredentials = "INVALID_CREDENTIALS",
|
|
26
|
+
UserAlreadySignedIn = "USER_ALREADY_SIGNED_IN",
|
|
27
|
+
PhoneNumberExists = "PHONE_NUMBER_EXISTS",
|
|
28
|
+
OauthCompletionFailed = "OAUTH_COMPLETION_FAILED",
|
|
29
|
+
ProviderRequired = "PROVIDER_REQUIRED",
|
|
30
|
+
CodeRequired = "CODE_REQUIRED",
|
|
31
|
+
VerificationStrategyRequired = "VERIFICATION_STRATEGY_REQUIRED",
|
|
32
|
+
InvalidState = "INVALID_STATE",
|
|
33
|
+
InvalidCode = "INVALID_CODE",
|
|
34
|
+
RequiredField = "REQUIRED_FIELD",
|
|
35
|
+
BadRequestBody = "BAD_REQUEST_BODY",
|
|
36
|
+
ProviderNotConfigured = "PROVIDER_NOT_CONFIGURED",
|
|
37
|
+
SignupRestricted = "SIGNUP_RESTRICTED",
|
|
38
|
+
SignupWaitlistOnly = "SIGNUP_WAITLIST_ONLY",
|
|
39
|
+
EmailNotAllowed = "EMAIL_NOT_ALLOWED",
|
|
40
|
+
EmailBlocked = "EMAIL_BLOCKED",
|
|
41
|
+
DisposableEmailBlocked = "DISPOSABLE_EMAIL_BLOCKED",
|
|
42
|
+
CountryRestricted = "COUNTRY_RESTRICTED",
|
|
43
|
+
VoipNumberBlocked = "VOIP_NUMBER_BLOCKED",
|
|
44
|
+
BannedKeyword = "BANNED_KEYWORD",
|
|
45
|
+
NoAlternativeAuthMethod = "NO_ALTERNATIVE_AUTH_METHOD",
|
|
46
|
+
Internal = "INTERNAL",
|
|
47
|
+
BadSignInAttempt = "BAD_SIGN_IN_ATTEMPT",
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type ResultInterface<T, E> =
|
|
51
|
+
| {
|
|
52
|
+
data: never;
|
|
53
|
+
errors: E[];
|
|
54
|
+
}
|
|
55
|
+
| {
|
|
56
|
+
data: T;
|
|
57
|
+
errors: never;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export type ApiResult<T, E = ErrorInterface> = ResultInterface<T, E>;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
export interface B2BSettings {
|
|
2
|
+
id: number;
|
|
3
|
+
created_at: string;
|
|
4
|
+
updated_at: string;
|
|
5
|
+
deleted_at: null;
|
|
6
|
+
deployment_id: number;
|
|
7
|
+
organizations_enabled: boolean;
|
|
8
|
+
workspaces_enabled: boolean;
|
|
9
|
+
ip_allowlist_per_org_enabled: boolean;
|
|
10
|
+
allow_users_to_create_orgs: boolean;
|
|
11
|
+
max_orgs_per_user: number;
|
|
12
|
+
max_allowed_org_members: number;
|
|
13
|
+
max_allowed_workspace_members: number;
|
|
14
|
+
allow_org_deletion: boolean;
|
|
15
|
+
allow_workspace_deletion: boolean;
|
|
16
|
+
custom_org_role_enabled: boolean;
|
|
17
|
+
limit_org_creation_per_user: boolean;
|
|
18
|
+
limit_workspace_creation_per_org: boolean;
|
|
19
|
+
org_creation_per_user_count: number;
|
|
20
|
+
workspaces_per_org_count: number;
|
|
21
|
+
custom_workspace_role_enabled: boolean;
|
|
22
|
+
default_workspace_creator_role_id: number;
|
|
23
|
+
default_workspace_member_role_id: number;
|
|
24
|
+
default_org_creator_role_id: number;
|
|
25
|
+
default_org_member_role_id: number;
|
|
26
|
+
workspace_permissions: string[];
|
|
27
|
+
organization_permissions: string[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface AuthFactorsEnabled {
|
|
31
|
+
email_password: boolean;
|
|
32
|
+
username_password: boolean;
|
|
33
|
+
email_magic_link: boolean;
|
|
34
|
+
email_otp: boolean;
|
|
35
|
+
phone_otp: boolean;
|
|
36
|
+
web3_wallet: boolean;
|
|
37
|
+
backup_code: boolean;
|
|
38
|
+
authenticator: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface VerificationPolicy {
|
|
42
|
+
phone_number: boolean;
|
|
43
|
+
email: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface AuthField {
|
|
47
|
+
enabled: boolean;
|
|
48
|
+
required: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type SecondFactor =
|
|
52
|
+
| "none"
|
|
53
|
+
| "phone_otp"
|
|
54
|
+
| "backup_code"
|
|
55
|
+
| "authenticator";
|
|
56
|
+
export type FirstFactor =
|
|
57
|
+
| "email_password"
|
|
58
|
+
| "username_password"
|
|
59
|
+
| "email_otp"
|
|
60
|
+
| "email_magic_link"
|
|
61
|
+
| "phone_otp";
|
|
62
|
+
|
|
63
|
+
export type SecondFactorPolicy = "none" | "optional" | "enforced";
|
|
64
|
+
|
|
65
|
+
export interface MultiSessionSupport {
|
|
66
|
+
enabled: boolean;
|
|
67
|
+
max_accounts_per_session: number;
|
|
68
|
+
max_sessions_per_account: number;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface AuthSettings {
|
|
72
|
+
id: number;
|
|
73
|
+
created_at: string;
|
|
74
|
+
updated_at: string;
|
|
75
|
+
deleted_at: null;
|
|
76
|
+
email_address: AuthField;
|
|
77
|
+
phone_number: AuthField;
|
|
78
|
+
username: AuthField;
|
|
79
|
+
first_name: AuthField;
|
|
80
|
+
last_name: AuthField;
|
|
81
|
+
password: AuthField;
|
|
82
|
+
backup_code: AuthField;
|
|
83
|
+
web3_wallet: AuthField;
|
|
84
|
+
password_policy: AuthField;
|
|
85
|
+
magic_link: AuthField;
|
|
86
|
+
passkey: AuthField;
|
|
87
|
+
auth_factors_enabled: AuthFactorsEnabled;
|
|
88
|
+
verification_policy: VerificationPolicy;
|
|
89
|
+
second_factor_policy: SecondFactorPolicy;
|
|
90
|
+
first_factor: FirstFactor;
|
|
91
|
+
second_factor: SecondFactor | null;
|
|
92
|
+
alternate_first_factors: FirstFactor[] | null;
|
|
93
|
+
alternate_second_factors: SecondFactor[] | null;
|
|
94
|
+
multi_session_support: MultiSessionSupport;
|
|
95
|
+
deployment_id: number;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface DeploymentSocialConnection {
|
|
99
|
+
id: number;
|
|
100
|
+
created_at: string;
|
|
101
|
+
updated_at: string;
|
|
102
|
+
deleted_at: null;
|
|
103
|
+
deployment_id: number;
|
|
104
|
+
provider: string;
|
|
105
|
+
enabled: boolean;
|
|
106
|
+
user_defined_scopes: null;
|
|
107
|
+
custom_credentials_set: boolean;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface CountryRestriction {
|
|
111
|
+
enabled: boolean;
|
|
112
|
+
country_codes: string[];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export type SignUpMode = "public" | "restricted" | "waitlist";
|
|
116
|
+
|
|
117
|
+
export interface DeploymentRestrictions {
|
|
118
|
+
id: number;
|
|
119
|
+
created_at: string;
|
|
120
|
+
updated_at: string;
|
|
121
|
+
deleted_at: null;
|
|
122
|
+
deployment_id: number;
|
|
123
|
+
allowlist_enabled: boolean;
|
|
124
|
+
blocklist_enabled: boolean;
|
|
125
|
+
block_subaddresses: boolean;
|
|
126
|
+
block_disposable_emails: boolean;
|
|
127
|
+
block_voip_numbers: boolean;
|
|
128
|
+
country_restrictions: CountryRestriction;
|
|
129
|
+
banned_keywords: string[];
|
|
130
|
+
allowlisted_resources: string[];
|
|
131
|
+
blocklisted_resources: string[];
|
|
132
|
+
sign_up_mode: SignUpMode;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface LightModeSettings {
|
|
136
|
+
primary_color: string;
|
|
137
|
+
background_color: string;
|
|
138
|
+
text_color: string;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export interface DarkModeSettings {
|
|
142
|
+
primary_color: string;
|
|
143
|
+
background_color: string;
|
|
144
|
+
text_color: string;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface DeploymentUISettings {
|
|
148
|
+
deployment_id: number;
|
|
149
|
+
app_name: string;
|
|
150
|
+
privacy_policy_url: string;
|
|
151
|
+
tos_page_url: string;
|
|
152
|
+
sign_in_page_url: string;
|
|
153
|
+
sign_up_page_url: string;
|
|
154
|
+
waitlist_page_url: string;
|
|
155
|
+
support_page_url: string;
|
|
156
|
+
after_logo_click_url: string;
|
|
157
|
+
user_profile_url: string;
|
|
158
|
+
organization_profile_url: string;
|
|
159
|
+
create_organization_url: string;
|
|
160
|
+
after_sign_out_one_page_url: string;
|
|
161
|
+
after_sign_out_all_page_url: string;
|
|
162
|
+
after_signup_redirect_url: string;
|
|
163
|
+
after_signin_redirect_url: string;
|
|
164
|
+
after_create_organization_redirect_url: string;
|
|
165
|
+
favicon_image_url: string;
|
|
166
|
+
default_user_profile_image_url: string;
|
|
167
|
+
default_organization_profile_image_url: string;
|
|
168
|
+
default_workspace_profile_image_url: string;
|
|
169
|
+
use_initials_for_user_profile_image: boolean;
|
|
170
|
+
use_initials_for_organization_profile_image: boolean;
|
|
171
|
+
logo_image_url: string;
|
|
172
|
+
signup_terms_statement: string;
|
|
173
|
+
signup_terms_statement_shown: boolean;
|
|
174
|
+
light_mode_settings: LightModeSettings;
|
|
175
|
+
dark_mode_settings: DarkModeSettings;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export interface Deployment {
|
|
179
|
+
id: number;
|
|
180
|
+
created_at: string;
|
|
181
|
+
updated_at: string;
|
|
182
|
+
deleted_at: null;
|
|
183
|
+
maintenance_mode: boolean;
|
|
184
|
+
backend_host: string;
|
|
185
|
+
frontend_host: string;
|
|
186
|
+
mail_from_host: string;
|
|
187
|
+
publishable_key: string;
|
|
188
|
+
b2b_settings: B2BSettings;
|
|
189
|
+
auth_settings: AuthSettings;
|
|
190
|
+
restrictions: DeploymentRestrictions;
|
|
191
|
+
social_connections: DeploymentSocialConnection[];
|
|
192
|
+
ui_settings: DeploymentUISettings;
|
|
193
|
+
project_id: number;
|
|
194
|
+
mode: "production" | "staging";
|
|
195
|
+
}
|
|
196
|
+
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import type { PublicUserData } from "./user";
|
|
2
|
+
|
|
3
|
+
export interface Organization {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
image_url: string;
|
|
7
|
+
description: string;
|
|
8
|
+
member_count: number;
|
|
9
|
+
public_metadata: Record<string, unknown>;
|
|
10
|
+
private_metadata: Record<string, unknown>;
|
|
11
|
+
enforce_mfa: boolean;
|
|
12
|
+
enable_ip_restriction: boolean;
|
|
13
|
+
whitelisted_ips: string[];
|
|
14
|
+
auto_assigned_workspace_id: string;
|
|
15
|
+
created_at: string;
|
|
16
|
+
updated_at: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface OrganizationRole {
|
|
20
|
+
id: string;
|
|
21
|
+
organization_id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
permissions: string[];
|
|
24
|
+
created_at: string;
|
|
25
|
+
updated_at: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface OrganizationMembershipWithOrganization {
|
|
29
|
+
id: string;
|
|
30
|
+
organization: Organization;
|
|
31
|
+
user_id: string;
|
|
32
|
+
role: OrganizationRole[];
|
|
33
|
+
created_at: string;
|
|
34
|
+
updated_at: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface OrganizationMembership {
|
|
38
|
+
id: string;
|
|
39
|
+
organization: Organization;
|
|
40
|
+
user: PublicUserData;
|
|
41
|
+
roles: OrganizationRole[];
|
|
42
|
+
created_at: string;
|
|
43
|
+
updated_at: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface OrganizationInvitation {
|
|
47
|
+
id: string;
|
|
48
|
+
created_at: string;
|
|
49
|
+
updated_at: string;
|
|
50
|
+
organization_id: string;
|
|
51
|
+
email: string;
|
|
52
|
+
initial_organization_role: OrganizationRole;
|
|
53
|
+
inviter: OrganizationMembership;
|
|
54
|
+
workspace: Workspace;
|
|
55
|
+
initial_workspace_role: WorkspaceRole;
|
|
56
|
+
expired: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface OrganizationDomain {
|
|
60
|
+
id: string;
|
|
61
|
+
organization_id: string;
|
|
62
|
+
fqdn: string;
|
|
63
|
+
verified: boolean;
|
|
64
|
+
verification_dns_record_type: string;
|
|
65
|
+
verification_dns_record_name: string;
|
|
66
|
+
verification_dns_record_data: string;
|
|
67
|
+
verification_attempts: number;
|
|
68
|
+
created_at: string;
|
|
69
|
+
updated_at: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface Workspace {
|
|
73
|
+
id: string;
|
|
74
|
+
name: string;
|
|
75
|
+
image_url: string;
|
|
76
|
+
description: string;
|
|
77
|
+
member_count: number;
|
|
78
|
+
public_metadata: Record<string, unknown>;
|
|
79
|
+
private_metadata: Record<string, unknown>;
|
|
80
|
+
created_at: string;
|
|
81
|
+
updated_at: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface WorkspaceWithOrganization extends Workspace {
|
|
85
|
+
organization: Organization;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface WorkspaceRole {
|
|
89
|
+
id: string;
|
|
90
|
+
name: string;
|
|
91
|
+
permissions: string[];
|
|
92
|
+
created_at: string;
|
|
93
|
+
updated_at: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface WorkspaceMembership {
|
|
97
|
+
id: string;
|
|
98
|
+
workspace: Workspace;
|
|
99
|
+
organization_id: string;
|
|
100
|
+
user_id: string;
|
|
101
|
+
role: WorkspaceRole[];
|
|
102
|
+
organization: Organization;
|
|
103
|
+
created_at: string;
|
|
104
|
+
updated_at: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface OrganizationUpdate {
|
|
108
|
+
image?: File;
|
|
109
|
+
name?: string;
|
|
110
|
+
description?: string;
|
|
111
|
+
whitelisted_ips?: string[];
|
|
112
|
+
auto_assigned_workspace_id?: string;
|
|
113
|
+
enable_ip_restriction?: boolean;
|
|
114
|
+
enforce_mfa_setup?: boolean;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface RoleCreate {
|
|
118
|
+
name: string;
|
|
119
|
+
permissions?: string[];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export type RoleUpdate = Partial<RoleCreate>;
|
|
123
|
+
|
|
124
|
+
export interface NewOrgnization {
|
|
125
|
+
name: string;
|
|
126
|
+
description?: string;
|
|
127
|
+
image?: File;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface NewDomain {
|
|
131
|
+
fqdn: string;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export interface OrganizationInvitationPayload {
|
|
135
|
+
email: string;
|
|
136
|
+
organizationRole: OrganizationRole;
|
|
137
|
+
workspace?: Workspace;
|
|
138
|
+
workspaceRole?: WorkspaceRole;
|
|
139
|
+
}
|
package/src/profile.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { SigninAttempt, Session } from './session';
|
|
2
|
+
import { ApiResult } from './client';
|
|
3
|
+
|
|
4
|
+
export interface ProfileCompletionData {
|
|
5
|
+
first_name?: string;
|
|
6
|
+
last_name?: string;
|
|
7
|
+
username?: string;
|
|
8
|
+
phone_number?: string;
|
|
9
|
+
phone_country_code?: string;
|
|
10
|
+
email?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Match the actual VerificationParams type from use-signin
|
|
14
|
+
type VerificationParams =
|
|
15
|
+
| { strategy: "email_otp"; redirectUri?: string }
|
|
16
|
+
| { strategy: "phone_otp"; lastDigits?: string }
|
|
17
|
+
| { strategy: "magic_link"; redirectUri?: string };
|
|
18
|
+
|
|
19
|
+
type PrepareVerificationResponse = {
|
|
20
|
+
otp_sent?: boolean;
|
|
21
|
+
masked_phone?: string;
|
|
22
|
+
masked_email?: string;
|
|
23
|
+
verification_method?: string;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export interface ProfileCompletionProps {
|
|
27
|
+
attempt: SigninAttempt;
|
|
28
|
+
onBack?: () => void;
|
|
29
|
+
completeProfile: (data: ProfileCompletionData) => Promise<Session>;
|
|
30
|
+
completeVerification: (code: string) => Promise<Session>;
|
|
31
|
+
prepareVerification: (params: VerificationParams) => Promise<ApiResult<PrepareVerificationResponse>>;
|
|
32
|
+
}
|
package/src/session.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { CurrentUser } from "./user";
|
|
2
|
+
import type { ProfileCompletionData } from "./profile";
|
|
3
|
+
|
|
4
|
+
export interface SignIn {
|
|
5
|
+
id: string;
|
|
6
|
+
user_id: string;
|
|
7
|
+
active_organization_membership_id: string;
|
|
8
|
+
active_workspace_membership_id: string;
|
|
9
|
+
user: CurrentUser;
|
|
10
|
+
expiresAt: string;
|
|
11
|
+
lastActiveAt: string;
|
|
12
|
+
ipAddress: string;
|
|
13
|
+
browser: string;
|
|
14
|
+
device: string;
|
|
15
|
+
city: string;
|
|
16
|
+
region: string;
|
|
17
|
+
regionCode: string;
|
|
18
|
+
country: string;
|
|
19
|
+
countryCode: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type SignInMethod = "plain" | "sso" | "passkey";
|
|
23
|
+
|
|
24
|
+
export type SSOProvider =
|
|
25
|
+
| "x_oauth"
|
|
26
|
+
| "github_oauth"
|
|
27
|
+
| "gitlab_oauth"
|
|
28
|
+
| "google_oauth"
|
|
29
|
+
| "facebook_oauth"
|
|
30
|
+
| "microsoft_oauth"
|
|
31
|
+
| "linkedin_oauth"
|
|
32
|
+
| "discord_oauth";
|
|
33
|
+
|
|
34
|
+
export type CurrentSessionStep =
|
|
35
|
+
| "verify_password"
|
|
36
|
+
| "verify_email"
|
|
37
|
+
| "verify_email_link"
|
|
38
|
+
| "verify_email_otp"
|
|
39
|
+
| "verify_phone"
|
|
40
|
+
| "verify_phone_otp"
|
|
41
|
+
| "verify_second_factor"
|
|
42
|
+
| "add_second_factor"
|
|
43
|
+
| "complete_profile";
|
|
44
|
+
|
|
45
|
+
export interface SigninAttempt {
|
|
46
|
+
id: string;
|
|
47
|
+
email: string;
|
|
48
|
+
session_id: number;
|
|
49
|
+
method: SignInMethod;
|
|
50
|
+
sso_provider: SSOProvider;
|
|
51
|
+
expires_at: string;
|
|
52
|
+
first_method_authenticated: boolean;
|
|
53
|
+
second_method_authenticated: boolean;
|
|
54
|
+
second_method_authentication_required: boolean;
|
|
55
|
+
available_2fa_methods?: string[];
|
|
56
|
+
user_id: number;
|
|
57
|
+
last_active_org_id: number;
|
|
58
|
+
current_step: CurrentSessionStep;
|
|
59
|
+
completed: boolean;
|
|
60
|
+
requires_completion?: boolean;
|
|
61
|
+
missing_fields?: string[];
|
|
62
|
+
required_fields?: string[];
|
|
63
|
+
profile_completion_data?: ProfileCompletionData;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type SignupAttemptStep =
|
|
67
|
+
| "verify_email"
|
|
68
|
+
| "verify_phone"
|
|
69
|
+
| "verify_authenticator";
|
|
70
|
+
|
|
71
|
+
export interface SignupAttempt {
|
|
72
|
+
id: string;
|
|
73
|
+
session_id: number;
|
|
74
|
+
first_name: string;
|
|
75
|
+
last_name: string;
|
|
76
|
+
email: string;
|
|
77
|
+
username: string;
|
|
78
|
+
phone_number: string;
|
|
79
|
+
password: string;
|
|
80
|
+
required_fields: string[];
|
|
81
|
+
missing_fields: string[];
|
|
82
|
+
current_step: SignupAttemptStep;
|
|
83
|
+
remaining_steps: SignupAttemptStep[];
|
|
84
|
+
completed: boolean;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface Session {
|
|
88
|
+
id: number;
|
|
89
|
+
active_signin: SignIn | null;
|
|
90
|
+
signins?: SignIn[];
|
|
91
|
+
signin_attempts?: SigninAttempt[];
|
|
92
|
+
signup_attempts?: SignupAttempt[];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface SessionToken {
|
|
96
|
+
token: string;
|
|
97
|
+
expires: number;
|
|
98
|
+
}
|
package/src/user.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { SocialConnectionProvider } from "./auth";
|
|
2
|
+
import type { SecondFactorPolicy } from "./deployment";
|
|
3
|
+
|
|
4
|
+
export type VerificationStrategy =
|
|
5
|
+
| "otp"
|
|
6
|
+
| "oath_google"
|
|
7
|
+
| "oath_github"
|
|
8
|
+
| "oauth_microsoft"
|
|
9
|
+
| "oauth_facebook"
|
|
10
|
+
| "oauth_linkedin"
|
|
11
|
+
| "oauth_discord"
|
|
12
|
+
| "oauth_apple";
|
|
13
|
+
|
|
14
|
+
export interface SocialConnection {
|
|
15
|
+
id: number;
|
|
16
|
+
provider: SocialConnectionProvider;
|
|
17
|
+
email_address: string;
|
|
18
|
+
first_name: string;
|
|
19
|
+
last_name: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface UserEmailAddress {
|
|
23
|
+
id: string;
|
|
24
|
+
email: string;
|
|
25
|
+
is_primary: boolean;
|
|
26
|
+
verified: boolean;
|
|
27
|
+
verified_at: string;
|
|
28
|
+
verification_strategy: VerificationStrategy;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface UserPhoneNumber {
|
|
32
|
+
id: string;
|
|
33
|
+
phone_number: string;
|
|
34
|
+
country_code: string;
|
|
35
|
+
verified: boolean;
|
|
36
|
+
verified_at: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface UserAuthenticator {
|
|
40
|
+
id: string;
|
|
41
|
+
created_at: string;
|
|
42
|
+
totp_secret?: string;
|
|
43
|
+
otp_url?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface CurrentUser {
|
|
47
|
+
id: string;
|
|
48
|
+
first_name: string;
|
|
49
|
+
last_name: string;
|
|
50
|
+
username: string;
|
|
51
|
+
availability: "available" | "busy" | "away";
|
|
52
|
+
has_profile_picture: string;
|
|
53
|
+
profile_picture_url: string;
|
|
54
|
+
primary_email_address_id: string;
|
|
55
|
+
primary_phone_number_id: string;
|
|
56
|
+
primary_email_address: UserEmailAddress;
|
|
57
|
+
primary_phone_number?: UserPhoneNumber;
|
|
58
|
+
second_factor_policy: SecondFactorPolicy;
|
|
59
|
+
user_email_addresses: UserEmailAddress[];
|
|
60
|
+
user_phone_numbers: UserPhoneNumber[];
|
|
61
|
+
email_addresses?: UserEmailAddress[];
|
|
62
|
+
phone_numbers?: UserPhoneNumber[];
|
|
63
|
+
social_connections: SocialConnection[];
|
|
64
|
+
user_authenticator?: UserAuthenticator;
|
|
65
|
+
authenticators?: UserAuthenticator[];
|
|
66
|
+
backup_codes_generated?: boolean;
|
|
67
|
+
backup_codes?: string[];
|
|
68
|
+
has_password: boolean;
|
|
69
|
+
public_metadata: Record<string, unknown>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface PublicUserData {
|
|
73
|
+
id: string;
|
|
74
|
+
first_name: string;
|
|
75
|
+
last_name: string;
|
|
76
|
+
username: string;
|
|
77
|
+
availability: "available" | "busy" | "away";
|
|
78
|
+
has_profile_picture: string;
|
|
79
|
+
profile_picture_url: string;
|
|
80
|
+
primary_phone_number: UserPhoneNumber;
|
|
81
|
+
primary_email_address: UserEmailAddress;
|
|
82
|
+
}
|