@hexclave/shared 1.0.39 → 1.0.40
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/ai/unified-prompts/reminders.js +1 -1
- package/dist/config/schema.d.ts +36 -36
- package/dist/esm/ai/unified-prompts/reminders.js +1 -1
- package/dist/esm/config/schema.d.ts +36 -36
- package/dist/esm/interface/admin-interface.js +1 -1
- package/dist/esm/interface/admin-metrics.d.ts +25 -25
- package/dist/esm/interface/client-interface.js +1 -1
- package/dist/esm/interface/conversations.d.ts +10 -10
- package/dist/esm/interface/crud/current-user.d.ts +9 -9
- package/dist/esm/interface/crud/email-outbox.d.ts +206 -206
- package/dist/esm/interface/crud/products.d.ts +5 -5
- package/dist/esm/interface/crud/project-api-keys.d.ts +4 -4
- package/dist/esm/interface/crud/team-member-profiles.d.ts +16 -16
- package/dist/esm/interface/crud/transactions.d.ts +2 -2
- package/dist/esm/interface/crud/users.d.ts +12 -12
- package/dist/esm/interface/plan-usage.d.ts +2 -2
- package/dist/esm/interface/server-interface.d.ts +1 -0
- package/dist/esm/interface/server-interface.d.ts.map +1 -1
- package/dist/esm/interface/server-interface.js +2 -1
- package/dist/esm/interface/server-interface.js.map +1 -1
- package/dist/esm/interface/webhooks.d.ts +2 -2
- package/dist/esm/known-errors.d.ts +2 -2
- package/dist/esm/schema-fields.d.ts +1 -1
- package/dist/esm/sessions.d.ts +1 -1
- package/dist/esm/utils/promises.js +1 -1
- package/dist/interface/admin-interface.js +1 -1
- package/dist/interface/admin-metrics.d.ts +25 -25
- package/dist/interface/client-interface.js +1 -1
- package/dist/interface/conversations.d.ts +10 -10
- package/dist/interface/crud/current-user.d.ts +9 -9
- package/dist/interface/crud/email-outbox.d.ts +206 -206
- package/dist/interface/crud/products.d.ts +5 -5
- package/dist/interface/crud/project-api-keys.d.ts +4 -4
- package/dist/interface/crud/team-member-profiles.d.ts +16 -16
- package/dist/interface/crud/transactions.d.ts +2 -2
- package/dist/interface/crud/users.d.ts +12 -12
- package/dist/interface/plan-usage.d.ts +2 -2
- package/dist/interface/server-interface.d.ts +1 -0
- package/dist/interface/server-interface.d.ts.map +1 -1
- package/dist/interface/server-interface.js +2 -1
- package/dist/interface/server-interface.js.map +1 -1
- package/dist/interface/webhooks.d.ts +2 -2
- package/dist/known-errors.d.ts +2 -2
- package/dist/schema-fields.d.ts +1 -1
- package/dist/sessions.d.ts +1 -1
- package/dist/utils/promises.js +1 -1
- package/package.json +1 -1
- package/src/interface/server-interface.ts +2 -0
|
@@ -10,7 +10,6 @@ declare const customerProductReadSchema: yup$1.ObjectSchema<{
|
|
|
10
10
|
client_metadata?: {} | null | undefined;
|
|
11
11
|
client_read_only_metadata?: {} | null | undefined;
|
|
12
12
|
server_metadata?: {} | null | undefined;
|
|
13
|
-
display_name: string;
|
|
14
13
|
server_only: boolean;
|
|
15
14
|
customer_type: "team" | "user" | "custom";
|
|
16
15
|
stackable: boolean;
|
|
@@ -25,6 +24,7 @@ declare const customerProductReadSchema: yup$1.ObjectSchema<{
|
|
|
25
24
|
interval?: ______utils_dates0.DayInterval | undefined;
|
|
26
25
|
free_trial?: ______utils_dates0.DayInterval | undefined;
|
|
27
26
|
}>;
|
|
27
|
+
display_name: string;
|
|
28
28
|
included_items: Record<string, {
|
|
29
29
|
quantity?: number | undefined;
|
|
30
30
|
repeat?: "never" | ______utils_dates0.DayInterval | undefined;
|
|
@@ -45,7 +45,6 @@ declare const customerProductReadSchema: yup$1.ObjectSchema<{
|
|
|
45
45
|
client_metadata?: {} | null | undefined;
|
|
46
46
|
client_read_only_metadata?: {} | null | undefined;
|
|
47
47
|
server_metadata?: {} | null | undefined;
|
|
48
|
-
display_name: string;
|
|
49
48
|
server_only: boolean;
|
|
50
49
|
customer_type: "team" | "user" | "custom";
|
|
51
50
|
stackable: boolean;
|
|
@@ -60,6 +59,7 @@ declare const customerProductReadSchema: yup$1.ObjectSchema<{
|
|
|
60
59
|
interval?: ______utils_dates0.DayInterval | undefined;
|
|
61
60
|
free_trial?: ______utils_dates0.DayInterval | undefined;
|
|
62
61
|
}>;
|
|
62
|
+
display_name: string;
|
|
63
63
|
included_items: Record<string, {
|
|
64
64
|
quantity?: number | undefined;
|
|
65
65
|
repeat?: "never" | ______utils_dates0.DayInterval | undefined;
|
|
@@ -108,7 +108,6 @@ declare const customerProductsListResponseSchema: yup$1.ObjectSchema<{
|
|
|
108
108
|
client_metadata?: {} | null | undefined;
|
|
109
109
|
client_read_only_metadata?: {} | null | undefined;
|
|
110
110
|
server_metadata?: {} | null | undefined;
|
|
111
|
-
display_name: string;
|
|
112
111
|
server_only: boolean;
|
|
113
112
|
customer_type: "team" | "user" | "custom";
|
|
114
113
|
stackable: boolean;
|
|
@@ -123,6 +122,7 @@ declare const customerProductsListResponseSchema: yup$1.ObjectSchema<{
|
|
|
123
122
|
interval?: ______utils_dates0.DayInterval | undefined;
|
|
124
123
|
free_trial?: ______utils_dates0.DayInterval | undefined;
|
|
125
124
|
}>;
|
|
125
|
+
display_name: string;
|
|
126
126
|
included_items: Record<string, {
|
|
127
127
|
quantity?: number | undefined;
|
|
128
128
|
repeat?: "never" | ______utils_dates0.DayInterval | undefined;
|
|
@@ -130,14 +130,12 @@ declare const customerProductsListResponseSchema: yup$1.ObjectSchema<{
|
|
|
130
130
|
}>;
|
|
131
131
|
};
|
|
132
132
|
}[] | undefined;
|
|
133
|
-
id: string | null;
|
|
134
133
|
quantity: number;
|
|
135
134
|
product: {
|
|
136
135
|
free_trial?: ______utils_dates0.DayInterval | undefined;
|
|
137
136
|
client_metadata?: {} | null | undefined;
|
|
138
137
|
client_read_only_metadata?: {} | null | undefined;
|
|
139
138
|
server_metadata?: {} | null | undefined;
|
|
140
|
-
display_name: string;
|
|
141
139
|
server_only: boolean;
|
|
142
140
|
customer_type: "team" | "user" | "custom";
|
|
143
141
|
stackable: boolean;
|
|
@@ -152,12 +150,14 @@ declare const customerProductsListResponseSchema: yup$1.ObjectSchema<{
|
|
|
152
150
|
interval?: ______utils_dates0.DayInterval | undefined;
|
|
153
151
|
free_trial?: ______utils_dates0.DayInterval | undefined;
|
|
154
152
|
}>;
|
|
153
|
+
display_name: string;
|
|
155
154
|
included_items: Record<string, {
|
|
156
155
|
quantity?: number | undefined;
|
|
157
156
|
repeat?: "never" | ______utils_dates0.DayInterval | undefined;
|
|
158
157
|
expires?: "never" | "when-purchase-expires" | "when-repeated" | undefined;
|
|
159
158
|
}>;
|
|
160
159
|
};
|
|
160
|
+
id: string | null;
|
|
161
161
|
}[];
|
|
162
162
|
is_paginated: boolean;
|
|
163
163
|
pagination: {
|
|
@@ -79,12 +79,12 @@ declare const userApiKeysCrud: ______crud0.CrudSchemaFromOptions<{
|
|
|
79
79
|
is_public: undefined;
|
|
80
80
|
user_id: undefined;
|
|
81
81
|
}, "">, userApiKeysCreateOutputSchema: yup$1.ObjectSchema<{
|
|
82
|
+
user_id: string;
|
|
82
83
|
type: "user";
|
|
84
|
+
description: string;
|
|
83
85
|
id: string;
|
|
84
86
|
created_at_millis: number;
|
|
85
87
|
expires_at_millis: number | undefined;
|
|
86
|
-
user_id: string;
|
|
87
|
-
description: string;
|
|
88
88
|
manually_revoked_at_millis: number | undefined;
|
|
89
89
|
is_public: boolean;
|
|
90
90
|
} & {
|
|
@@ -178,11 +178,11 @@ declare const teamApiKeysCrud: ______crud0.CrudSchemaFromOptions<{
|
|
|
178
178
|
team_id: undefined;
|
|
179
179
|
}, "">, teamApiKeysCreateOutputSchema: yup$1.ObjectSchema<{
|
|
180
180
|
type: "team";
|
|
181
|
+
team_id: string;
|
|
182
|
+
description: string;
|
|
181
183
|
id: string;
|
|
182
184
|
created_at_millis: number;
|
|
183
185
|
expires_at_millis: number | undefined;
|
|
184
|
-
team_id: string;
|
|
185
|
-
description: string;
|
|
186
186
|
manually_revoked_at_millis: number | undefined;
|
|
187
187
|
is_public: boolean;
|
|
188
188
|
} & {
|
|
@@ -21,32 +21,32 @@ declare const teamMemberProfilesCrudServerReadSchema: yup$1.ObjectSchema<{
|
|
|
21
21
|
profile_image_url: string | null;
|
|
22
22
|
} & {
|
|
23
23
|
user: {
|
|
24
|
-
id: string;
|
|
25
|
-
country_code: string | null;
|
|
26
|
-
display_name: string | null;
|
|
27
|
-
primary_email: string | null;
|
|
28
|
-
profile_image_url: string | null;
|
|
29
|
-
signed_up_at_millis: number;
|
|
30
|
-
last_active_at_millis: number;
|
|
31
24
|
restricted_reason: {
|
|
32
25
|
type: "anonymous" | "email_not_verified" | "restricted_by_administrator";
|
|
33
26
|
} | null;
|
|
27
|
+
primary_email: string | null;
|
|
28
|
+
display_name: string | null;
|
|
34
29
|
client_metadata: {} | null;
|
|
35
30
|
client_read_only_metadata: {} | null;
|
|
36
31
|
server_metadata: {} | null;
|
|
32
|
+
id: string;
|
|
37
33
|
selected_team_id: string | null;
|
|
38
34
|
is_anonymous: boolean;
|
|
39
35
|
is_restricted: boolean;
|
|
40
36
|
requires_totp_mfa: boolean;
|
|
37
|
+
country_code: string | null;
|
|
38
|
+
profile_image_url: string | null;
|
|
39
|
+
signed_up_at_millis: number;
|
|
40
|
+
last_active_at_millis: number;
|
|
41
41
|
primary_email_verified: boolean;
|
|
42
42
|
primary_email_auth_enabled: boolean;
|
|
43
43
|
selected_team: {
|
|
44
44
|
client_metadata?: {} | null | undefined;
|
|
45
45
|
client_read_only_metadata?: {} | null | undefined;
|
|
46
46
|
server_metadata?: {} | null | undefined;
|
|
47
|
+
display_name: string;
|
|
47
48
|
id: string;
|
|
48
49
|
created_at_millis: number;
|
|
49
|
-
display_name: string;
|
|
50
50
|
profile_image_url: string | null;
|
|
51
51
|
} | null;
|
|
52
52
|
has_password: boolean;
|
|
@@ -144,32 +144,32 @@ declare const teamMemberProfilesCrud: ______crud0.CrudSchemaFromOptions<{
|
|
|
144
144
|
profile_image_url: string | null;
|
|
145
145
|
} & {
|
|
146
146
|
user: {
|
|
147
|
-
id: string;
|
|
148
|
-
country_code: string | null;
|
|
149
|
-
display_name: string | null;
|
|
150
|
-
primary_email: string | null;
|
|
151
|
-
profile_image_url: string | null;
|
|
152
|
-
signed_up_at_millis: number;
|
|
153
|
-
last_active_at_millis: number;
|
|
154
147
|
restricted_reason: {
|
|
155
148
|
type: "anonymous" | "email_not_verified" | "restricted_by_administrator";
|
|
156
149
|
} | null;
|
|
150
|
+
primary_email: string | null;
|
|
151
|
+
display_name: string | null;
|
|
157
152
|
client_metadata: {} | null;
|
|
158
153
|
client_read_only_metadata: {} | null;
|
|
159
154
|
server_metadata: {} | null;
|
|
155
|
+
id: string;
|
|
160
156
|
selected_team_id: string | null;
|
|
161
157
|
is_anonymous: boolean;
|
|
162
158
|
is_restricted: boolean;
|
|
163
159
|
requires_totp_mfa: boolean;
|
|
160
|
+
country_code: string | null;
|
|
161
|
+
profile_image_url: string | null;
|
|
162
|
+
signed_up_at_millis: number;
|
|
163
|
+
last_active_at_millis: number;
|
|
164
164
|
primary_email_verified: boolean;
|
|
165
165
|
primary_email_auth_enabled: boolean;
|
|
166
166
|
selected_team: {
|
|
167
167
|
client_metadata?: {} | null | undefined;
|
|
168
168
|
client_read_only_metadata?: {} | null | undefined;
|
|
169
169
|
server_metadata?: {} | null | undefined;
|
|
170
|
+
display_name: string;
|
|
170
171
|
id: string;
|
|
171
172
|
created_at_millis: number;
|
|
172
|
-
display_name: string;
|
|
173
173
|
profile_image_url: string | null;
|
|
174
174
|
} | null;
|
|
175
175
|
has_password: boolean;
|
|
@@ -42,7 +42,6 @@ declare const transactionEntrySchema: yup$1.MixedSchema<{
|
|
|
42
42
|
client_metadata?: {} | null | undefined;
|
|
43
43
|
client_read_only_metadata?: {} | null | undefined;
|
|
44
44
|
server_metadata?: {} | null | undefined;
|
|
45
|
-
display_name: string;
|
|
46
45
|
server_only: boolean;
|
|
47
46
|
customer_type: "team" | "user" | "custom";
|
|
48
47
|
stackable: boolean;
|
|
@@ -57,6 +56,7 @@ declare const transactionEntrySchema: yup$1.MixedSchema<{
|
|
|
57
56
|
interval?: ______utils_dates0.DayInterval | undefined;
|
|
58
57
|
free_trial?: ______utils_dates0.DayInterval | undefined;
|
|
59
58
|
}>;
|
|
59
|
+
display_name: string;
|
|
60
60
|
included_items: Record<string, {
|
|
61
61
|
quantity?: number | undefined;
|
|
62
62
|
repeat?: "never" | ______utils_dates0.DayInterval | undefined;
|
|
@@ -126,7 +126,6 @@ declare const transactionSchema: yup$1.ObjectSchema<{
|
|
|
126
126
|
client_metadata?: {} | null | undefined;
|
|
127
127
|
client_read_only_metadata?: {} | null | undefined;
|
|
128
128
|
server_metadata?: {} | null | undefined;
|
|
129
|
-
display_name: string;
|
|
130
129
|
server_only: boolean;
|
|
131
130
|
customer_type: "team" | "user" | "custom";
|
|
132
131
|
stackable: boolean;
|
|
@@ -141,6 +140,7 @@ declare const transactionSchema: yup$1.ObjectSchema<{
|
|
|
141
140
|
interval?: ______utils_dates0.DayInterval | undefined;
|
|
142
141
|
free_trial?: ______utils_dates0.DayInterval | undefined;
|
|
143
142
|
}>;
|
|
143
|
+
display_name: string;
|
|
144
144
|
included_items: Record<string, {
|
|
145
145
|
quantity?: number | undefined;
|
|
146
146
|
repeat?: "never" | ______utils_dates0.DayInterval | undefined;
|
|
@@ -81,9 +81,9 @@ declare const usersCrudServerReadSchema: yup$1.ObjectSchema<{
|
|
|
81
81
|
client_metadata?: {} | null | undefined;
|
|
82
82
|
client_read_only_metadata?: {} | null | undefined;
|
|
83
83
|
server_metadata?: {} | null | undefined;
|
|
84
|
+
display_name: string;
|
|
84
85
|
id: string;
|
|
85
86
|
created_at_millis: number;
|
|
86
|
-
display_name: string;
|
|
87
87
|
profile_image_url: string | null;
|
|
88
88
|
} | null;
|
|
89
89
|
selected_team_id: string | null;
|
|
@@ -163,14 +163,14 @@ declare const usersCrudServerReadSchema: yup$1.ObjectSchema<{
|
|
|
163
163
|
requires_totp_mfa: undefined;
|
|
164
164
|
}, "">;
|
|
165
165
|
declare const usersCrudServerCreateSchema: yup$1.ObjectSchema<{
|
|
166
|
-
country_code: string | null | undefined;
|
|
167
|
-
display_name: string | null | undefined;
|
|
168
166
|
primary_email: string | null | undefined;
|
|
169
|
-
|
|
167
|
+
display_name: string | null | undefined;
|
|
170
168
|
client_metadata: {} | null | undefined;
|
|
171
169
|
client_read_only_metadata: {} | null | undefined;
|
|
172
170
|
server_metadata: {} | null | undefined;
|
|
173
171
|
is_anonymous: boolean | undefined;
|
|
172
|
+
country_code: string | null | undefined;
|
|
173
|
+
profile_image_url: string | null | undefined;
|
|
174
174
|
password: string | null | undefined;
|
|
175
175
|
primary_email_verified: boolean | undefined;
|
|
176
176
|
primary_email_auth_enabled: boolean | undefined;
|
|
@@ -189,8 +189,8 @@ declare const usersCrudServerCreateSchema: yup$1.ObjectSchema<{
|
|
|
189
189
|
totp_secret_base64: string | null | undefined;
|
|
190
190
|
} & {
|
|
191
191
|
oauth_providers: {
|
|
192
|
-
id: string;
|
|
193
192
|
email: string | null;
|
|
193
|
+
id: string;
|
|
194
194
|
account_id: string;
|
|
195
195
|
}[] | undefined;
|
|
196
196
|
is_anonymous: boolean | undefined;
|
|
@@ -234,9 +234,9 @@ declare const usersCrud: ______crud0.CrudSchemaFromOptions<{
|
|
|
234
234
|
client_metadata?: {} | null | undefined;
|
|
235
235
|
client_read_only_metadata?: {} | null | undefined;
|
|
236
236
|
server_metadata?: {} | null | undefined;
|
|
237
|
+
display_name: string;
|
|
237
238
|
id: string;
|
|
238
239
|
created_at_millis: number;
|
|
239
|
-
display_name: string;
|
|
240
240
|
profile_image_url: string | null;
|
|
241
241
|
} | null;
|
|
242
242
|
selected_team_id: string | null;
|
|
@@ -369,14 +369,14 @@ declare const usersCrud: ______crud0.CrudSchemaFromOptions<{
|
|
|
369
369
|
};
|
|
370
370
|
}, "">;
|
|
371
371
|
serverCreateSchema: yup$1.ObjectSchema<{
|
|
372
|
-
country_code: string | null | undefined;
|
|
373
|
-
display_name: string | null | undefined;
|
|
374
372
|
primary_email: string | null | undefined;
|
|
375
|
-
|
|
373
|
+
display_name: string | null | undefined;
|
|
376
374
|
client_metadata: {} | null | undefined;
|
|
377
375
|
client_read_only_metadata: {} | null | undefined;
|
|
378
376
|
server_metadata: {} | null | undefined;
|
|
379
377
|
is_anonymous: boolean | undefined;
|
|
378
|
+
country_code: string | null | undefined;
|
|
379
|
+
profile_image_url: string | null | undefined;
|
|
380
380
|
password: string | null | undefined;
|
|
381
381
|
primary_email_verified: boolean | undefined;
|
|
382
382
|
primary_email_auth_enabled: boolean | undefined;
|
|
@@ -395,8 +395,8 @@ declare const usersCrud: ______crud0.CrudSchemaFromOptions<{
|
|
|
395
395
|
totp_secret_base64: string | null | undefined;
|
|
396
396
|
} & {
|
|
397
397
|
oauth_providers: {
|
|
398
|
-
id: string;
|
|
399
398
|
email: string | null;
|
|
399
|
+
id: string;
|
|
400
400
|
account_id: string;
|
|
401
401
|
}[] | undefined;
|
|
402
402
|
is_anonymous: boolean | undefined;
|
|
@@ -468,9 +468,9 @@ declare const userCreatedWebhookEvent: WebhookEvent<yup$1.ObjectSchema<{
|
|
|
468
468
|
client_metadata?: {} | null | undefined;
|
|
469
469
|
client_read_only_metadata?: {} | null | undefined;
|
|
470
470
|
server_metadata?: {} | null | undefined;
|
|
471
|
+
display_name: string;
|
|
471
472
|
id: string;
|
|
472
473
|
created_at_millis: number;
|
|
473
|
-
display_name: string;
|
|
474
474
|
profile_image_url: string | null;
|
|
475
475
|
} | null;
|
|
476
476
|
selected_team_id: string | null;
|
|
@@ -559,9 +559,9 @@ declare const userUpdatedWebhookEvent: WebhookEvent<yup$1.ObjectSchema<{
|
|
|
559
559
|
client_metadata?: {} | null | undefined;
|
|
560
560
|
client_read_only_metadata?: {} | null | undefined;
|
|
561
561
|
server_metadata?: {} | null | undefined;
|
|
562
|
+
display_name: string;
|
|
562
563
|
id: string;
|
|
563
564
|
created_at_millis: number;
|
|
564
|
-
display_name: string;
|
|
565
565
|
profile_image_url: string | null;
|
|
566
566
|
} | null;
|
|
567
567
|
selected_team_id: string | null;
|
|
@@ -24,15 +24,15 @@ declare const planUsageRowSchema: yup$1.ObjectSchema<{
|
|
|
24
24
|
declare const planUsageResponseSchema: yup$1.ObjectSchema<{
|
|
25
25
|
owner_team_id: string;
|
|
26
26
|
owner_team_display_name: string;
|
|
27
|
-
plan_id: "
|
|
27
|
+
plan_id: "team" | "free" | "growth";
|
|
28
28
|
plan_display_name: string;
|
|
29
29
|
period_start_millis: number;
|
|
30
30
|
period_end_millis: number;
|
|
31
31
|
next_plan_id: "team" | "growth" | null;
|
|
32
32
|
rows: {
|
|
33
|
+
item_id: "dashboard_admins" | "auth_users" | "emails_per_month" | "analytics_timeout_seconds" | "analytics_events" | "session_replays" | "onboarding_call";
|
|
33
34
|
display_name: string;
|
|
34
35
|
kind: "current" | "metered" | "capability";
|
|
35
|
-
item_id: "dashboard_admins" | "auth_users" | "emails_per_month" | "analytics_timeout_seconds" | "analytics_events" | "session_replays" | "onboarding_call";
|
|
36
36
|
used: number | null;
|
|
37
37
|
limit: number | null;
|
|
38
38
|
remaining: number | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-interface.d.ts","names":[],"sources":["../../../src/interface/server-interface.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;KA4BY,4BAAA,IACR,sBAAA;EAAA,SAGW,eAAA;AAAA;EAAA,SAGA,mBAAA,EAAqB,eAAA,UAAyB,OAAA;AAAA;AAAA,cAKhD,uBAAA,SAAgC,uBAAA;EACf,OAAA,EAAS,4BAAA;cAAT,OAAA,EAAS,4BAAA;EAAA,UAIrB,iBAAA,CAAkB,IAAA,UAAc,OAAA,EAAS,WAAA,EAAa,OAAA,EAAS,eAAA,SAAwB,WAAA,wBAA0C,OAAA,CAAA,QAAA;;;;;;EAgBlI,kBAAA,CACb,YAAA,mBACA,UAAA,UACA,OAAA,EAAS,eAAA,UACR,OAAA;IACD,YAAA;IACA,sBAAA;MACE,EAAA;MACA,KAAA;MACA,KAAA;MACA,SAAA;MACA,QAAA;IAAA;EAAA;EAWW,sCAAA,CACb,YA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AA,EAAM,iBAAA,uBACL,OAAA,CAAQ,iBAAA;EAgBL,wBAAA,CACJ,OAAA;IACE,OAAA;EAAA,IAED,OAAA,CAAQ,iBAAA;EAaL,yBAAA,CACJ,MAAA,UACA,UAAA,UACA,IAAA,EAAM,iBAAA,uBACL,OAAA,CAAQ,iBAAA;EAeL,yBAAA,CACJ,MAAA,UACA,UAAA,WACC,OAAA;EAWG,SAAA,CAAU,OAAA;IACd,OAAA;IACA,QAAA;IACA,OAAA;IACA,IAAA;IACA,OAAA;IACA,wBAAA;IACA,UAAA;IACA,SAAA,GAAY,MAAA;IACZ,OAAA;IACA,WAAA,GAAc,IAAA;EAAA,IACZ,OAAA,CAAQ,MAAA,OAAa,WAAA,gCAA2C,WAAA,kBAA6B,WAAA;
|
|
1
|
+
{"version":3,"file":"server-interface.d.ts","names":[],"sources":["../../../src/interface/server-interface.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;KA4BY,4BAAA,IACR,sBAAA;EAAA,SAGW,eAAA;AAAA;EAAA,SAGA,mBAAA,EAAqB,eAAA,UAAyB,OAAA;AAAA;AAAA,cAKhD,uBAAA,SAAgC,uBAAA;EACf,OAAA,EAAS,4BAAA;cAAT,OAAA,EAAS,4BAAA;EAAA,UAIrB,iBAAA,CAAkB,IAAA,UAAc,OAAA,EAAS,WAAA,EAAa,OAAA,EAAS,eAAA,SAAwB,WAAA,wBAA0C,OAAA,CAAA,QAAA;;;;;;EAgBlI,kBAAA,CACb,YAAA,mBACA,UAAA,UACA,OAAA,EAAS,eAAA,UACR,OAAA;IACD,YAAA;IACA,sBAAA;MACE,EAAA;MACA,KAAA;MACA,KAAA;MACA,SAAA;MACA,QAAA;IAAA;EAAA;EAWW,sCAAA,CACb,YAAA,mBACA,UAAA,UACA,OAAA,EAAS,eAAA,UACR,OAAA;IACD,aAAA;IACA,iBAAA;EAAA;EAgBa,8CAAA,CACb,YAAA,mBACA,UAAA,UACA,aAAA,UACA,OAAA,EAAS,eAAA,UACR,OAAA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AAS,YAAA;IAAmB,IAAA;EAAA,GAAgB,WAAA;AAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { HexclaveAssertionError } from "../utils/errors.js";
|
|
2
2
|
import { filterUndefined } from "../utils/objects.js";
|
|
3
3
|
import { Result } from "../utils/results.js";
|
|
4
|
-
import { KnownErrors } from "../known-errors.js";
|
|
5
4
|
import { urlString } from "../utils/urls.js";
|
|
5
|
+
import { KnownErrors } from "../known-errors.js";
|
|
6
6
|
import { InternalSession } from "../sessions.js";
|
|
7
7
|
import { HexclaveClientInterface } from "./client-interface.js";
|
|
8
8
|
import { decryptValue, encryptValue, hashKey } from "../helpers/vault/client-side.js";
|
|
@@ -355,6 +355,7 @@ var HexclaveServerInterface = class extends HexclaveClientInterface {
|
|
|
355
355
|
body: JSON.stringify({
|
|
356
356
|
user_ids: options.userIds,
|
|
357
357
|
all_users: options.allUsers,
|
|
358
|
+
emails: options.emails,
|
|
358
359
|
theme_id: options.themeId,
|
|
359
360
|
html: options.html,
|
|
360
361
|
subject: options.subject,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-interface.js","names":[],"sources":["../../../src/interface/server-interface.ts"],"sourcesContent":["import * as yup from \"yup\";\nimport { decryptValue, encryptValue, hashKey } from \"../helpers/vault/client-side\";\nimport { KnownErrors } from \"../known-errors\";\nimport { inlineProductSchema } from \"../schema-fields\";\nimport { AccessToken, InternalSession, RefreshToken } from \"../sessions\";\nimport { HexclaveAssertionError } from \"../utils/errors\";\nimport { filterUndefined } from \"../utils/objects\";\nimport { Result } from \"../utils/results\";\nimport { urlString } from \"../utils/urls\";\nimport {\n ClientInterfaceOptions,\n HexclaveClientInterface\n} from \"./client-interface\";\nimport { ConnectedAccountAccessTokenCrud, ConnectedAccountCrud } from \"./crud/connected-accounts\";\nimport { ContactChannelsCrud } from \"./crud/contact-channels\";\nimport { CurrentUserCrud } from \"./crud/current-user\";\nimport { ItemCrud } from \"./crud/items\";\nimport { NotificationPreferenceCrud } from \"./crud/notification-preferences\";\nimport { OAuthProviderCrud } from \"./crud/oauth-providers\";\nimport { ProjectPermissionsCrud } from \"./crud/project-permissions\";\nimport { SessionsCrud } from \"./crud/sessions\";\nimport { TeamInvitationCrud } from \"./crud/team-invitation\";\nimport { TeamMemberProfilesCrud } from \"./crud/team-member-profiles\";\nimport { TeamMembershipsCrud } from \"./crud/team-memberships\";\nimport { TeamPermissionsCrud } from \"./crud/team-permissions\";\nimport { TeamsCrud } from \"./crud/teams\";\nimport { UsersCrud } from \"./crud/users\";\n\nexport type ServerAuthApplicationOptions = (\n & ClientInterfaceOptions\n & (\n | {\n readonly secretServerKey: string,\n }\n | {\n readonly projectOwnerSession: InternalSession | (() => Promise<string | null>),\n }\n )\n);\n\nexport class HexclaveServerInterface extends HexclaveClientInterface {\n constructor(public override options: ServerAuthApplicationOptions) {\n super(options);\n }\n\n protected async sendServerRequest(path: string, options: RequestInit, session: InternalSession | null, requestType: \"server\" | \"admin\" = \"server\") {\n return await this.sendClientRequest(\n path,\n {\n ...options,\n headers: {\n // Hexclave rebrand: emit x-hexclave-* request header; the backend proxy dual-accepts both names.\n \"x-hexclave-secret-server-key\": \"secretServerKey\" in this.options ? this.options.secretServerKey : \"\",\n ...options.headers,\n },\n },\n session,\n requestType,\n );\n }\n\n override async getCustomerBilling(\n customerType: \"user\" | \"team\",\n customerId: string,\n session: InternalSession | null,\n ): Promise<{\n has_customer: boolean,\n default_payment_method: {\n id: string,\n brand: string | null,\n last4: string | null,\n exp_month: number | null,\n exp_year: number | null,\n } | null,\n }> {\n const response = await this.sendServerRequest(\n urlString`/payments/billing/${customerType}/${customerId}`,\n {},\n session,\n );\n return await response.json();\n }\n\n override async createCustomerPaymentMethodSetupIntent(\n customerType: \"user\" | \"team\",\n customerId: string,\n session: InternalSession | null,\n ): Promise<{\n client_secret: string,\n stripe_account_id: string,\n }> {\n const response = await this.sendServerRequest(\n urlString`/payments/payment-method/${customerType}/${customerId}/setup-intent`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n session,\n );\n return await response.json();\n }\n\n override async setDefaultCustomerPaymentMethodFromSetupIntent(\n customerType: \"user\" | \"team\",\n customerId: string,\n setupIntentId: string,\n session: InternalSession | null,\n ): Promise<{\n default_payment_method: {\n id: string,\n brand: string | null,\n last4: string | null,\n exp_month: number | null,\n exp_year: number | null,\n },\n }> {\n const response = await this.sendServerRequest(\n urlString`/payments/payment-method/${customerType}/${customerId}/set-default`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({\n setup_intent_id: setupIntentId,\n }),\n },\n session,\n );\n return await response.json();\n }\n\n\n protected async sendServerRequestAndCatchKnownError<E extends typeof KnownErrors[keyof KnownErrors]>(\n path: string,\n requestOptions: RequestInit,\n tokenStoreOrNull: InternalSession | null,\n errorsToCatch: readonly E[],\n ): Promise<Result<\n Response & {\n usedTokens: {\n accessToken: AccessToken,\n refreshToken: RefreshToken | null,\n } | null,\n },\n InstanceType<E>\n >> {\n try {\n return Result.ok(await this.sendServerRequest(path, requestOptions, tokenStoreOrNull));\n } catch (e) {\n for (const errorType of errorsToCatch) {\n if (errorType.isInstance(e)) {\n return Result.error(e as InstanceType<E>);\n }\n }\n throw e;\n }\n }\n\n async createServerUser(data: UsersCrud['Server']['Create']): Promise<UsersCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n \"/users\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n null,\n );\n return await response.json();\n }\n\n async getServerUserByToken(session: InternalSession): Promise<CurrentUserCrud['Server']['Read'] | null> {\n const responseOrError = await this.sendServerRequestAndCatchKnownError(\n \"/users/me\",\n {},\n session,\n [KnownErrors.CannotGetOwnUserWithoutUser],\n );\n if (responseOrError.status === \"error\") {\n if (KnownErrors.CannotGetOwnUserWithoutUser.isInstance(responseOrError.error)) {\n return null;\n } else {\n throw new HexclaveAssertionError(\"Unexpected uncaught error\", { cause: responseOrError.error });\n }\n }\n const response = responseOrError.data;\n const user: CurrentUserCrud['Server']['Read'] = await response.json();\n if (!(user as any)) throw new HexclaveAssertionError(\"User endpoint returned null; this should never happen\");\n return user;\n }\n\n async getServerUserById(userId: string): Promise<Result<UsersCrud['Server']['Read']>> {\n const responseOrError = await this.sendServerRequestAndCatchKnownError(\n urlString`/users/${userId}`,\n {},\n null,\n [KnownErrors.UserNotFound],\n );\n if (responseOrError.status === \"error\") {\n return Result.error(responseOrError.error);\n }\n const user: UsersCrud['Server']['Read'] = await responseOrError.data.json();\n return Result.ok(user);\n }\n\n async listServerTeamInvitations(options: {\n teamId: string,\n }): Promise<TeamInvitationCrud['Server']['Read'][]> {\n const response = await this.sendServerRequest(\n urlString`/team-invitations?team_id=${options.teamId}`,\n {},\n null,\n );\n const result = await response.json() as TeamInvitationCrud['Server']['List'];\n return result.items;\n }\n\n async revokeServerTeamInvitation(invitationId: string, teamId: string) {\n await this.sendServerRequest(\n urlString`/team-invitations/${invitationId}?team_id=${teamId}`,\n { method: \"DELETE\" },\n null,\n );\n }\n\n async listServerTeamMemberProfiles(\n options: {\n teamId: string,\n },\n ): Promise<TeamMemberProfilesCrud['Server']['Read'][]> {\n const response = await this.sendServerRequest(\n urlString`/team-member-profiles?team_id=${options.teamId}`,\n {},\n null,\n );\n const result = await response.json() as TeamMemberProfilesCrud['Server']['List'];\n return result.items;\n }\n\n async getServerTeamMemberProfile(\n options: {\n teamId: string,\n userId: string,\n },\n ): Promise<TeamMemberProfilesCrud['Client']['Read']> {\n const response = await this.sendServerRequest(\n urlString`/team-member-profiles/${options.teamId}/${options.userId}`,\n {},\n null,\n );\n return await response.json();\n }\n\n async listServerTeamPermissions(\n options: {\n userId?: string,\n teamId?: string,\n recursive: boolean,\n },\n session: InternalSession | null,\n ): Promise<TeamPermissionsCrud['Server']['Read'][]> {\n const response = await this.sendServerRequest(\n `/team-permissions?${new URLSearchParams(filterUndefined({\n user_id: options.userId,\n team_id: options.teamId,\n recursive: options.recursive.toString(),\n }))}`,\n {},\n session,\n );\n const result = await response.json() as TeamPermissionsCrud['Server']['List'];\n return result.items;\n }\n\n async listServerProjectPermissions(\n options: {\n userId?: string,\n recursive: boolean,\n },\n session: InternalSession | null,\n ): Promise<ProjectPermissionsCrud['Server']['Read'][]> {\n const response = await this.sendServerRequest(\n `/project-permissions?${new URLSearchParams(filterUndefined({\n user_id: options.userId,\n recursive: options.recursive.toString(),\n }))}`,\n {},\n session,\n );\n const result = await response.json() as ProjectPermissionsCrud['Server']['List'];\n return result.items;\n }\n\n async listServerUsers(options: (\n & {\n cursor?: string,\n limit?: number,\n orderBy?: 'signedUpAt' | 'lastActiveAt',\n desc?: boolean,\n query?: string,\n excludedEmailDomains?: string[],\n includeRestricted?: boolean,\n teamId?: string,\n }\n & (\n {\n includeAnonymous?: boolean,\n onlyAnonymous?: false,\n }\n | {\n includeAnonymous: true,\n onlyAnonymous: true,\n }\n )\n )): Promise<UsersCrud['Server']['List']> {\n const searchParams = new URLSearchParams(filterUndefined({\n cursor: options.cursor,\n limit: options.limit?.toString(),\n desc: options.desc?.toString(),\n team_id: options.teamId,\n ...options.orderBy ? {\n order_by: {\n signedUpAt: \"signed_up_at\",\n lastActiveAt: \"last_active_at\",\n }[options.orderBy],\n } : {},\n ...options.query ? {\n query: options.query,\n } : {},\n ...options.excludedEmailDomains && options.excludedEmailDomains.length > 0 ? {\n excluded_email_domains: options.excludedEmailDomains.join(\",\"), // backend expects comma-separated list of domains.\n } : {},\n ...options.includeRestricted ? {\n include_restricted: 'true',\n } : {},\n ...options.includeAnonymous ? {\n include_anonymous: 'true',\n } : {},\n ...options.onlyAnonymous ? {\n only_anonymous: 'true',\n } : {},\n }));\n const response = await this.sendServerRequest(\"/users?\" + searchParams.toString(), {}, null);\n return await response.json();\n }\n\n async listServerTeams(options?: {\n userId?: string,\n }): Promise<TeamsCrud['Server']['Read'][]> {\n const result = await this.listServerTeamsPaginated(options);\n return result.items;\n }\n\n async listServerTeamsPaginated(options?: {\n userId?: string,\n orderBy?: 'createdAt',\n desc?: boolean,\n cursor?: string,\n limit?: number,\n query?: string,\n }): Promise<TeamsCrud['Server']['List']> {\n const response = await this.sendServerRequest(\n `/teams?${new URLSearchParams(filterUndefined({\n user_id: options?.userId,\n // SDK option uses camelCase `createdAt`; backend uses snake_case.\n order_by: options?.orderBy === 'createdAt' ? 'created_at' : options?.orderBy,\n desc: options?.desc !== undefined ? String(options.desc) : undefined,\n cursor: options?.cursor,\n limit: options?.limit?.toString(),\n query: options?.query,\n }))}`,\n {},\n null\n );\n return await response.json() as TeamsCrud['Server']['List'];\n }\n\n async getServerTeam(teamId: string): Promise<TeamsCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n `/teams/${teamId}`,\n {},\n null\n );\n return await response.json();\n }\n\n async listServerTeamUsers(teamId: string): Promise<UsersCrud['Server']['Read'][]> {\n const response = await this.sendServerRequest(`/users?team_id=${teamId}`, {}, null);\n const result = await response.json() as UsersCrud['Server']['List'];\n return result.items;\n }\n\n /* when passing a session, the user will be added to the team */\n async createServerTeam(data: TeamsCrud['Server']['Create']): Promise<TeamsCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n \"/teams\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n null\n );\n return await response.json();\n }\n\n async updateServerTeam(teamId: string, data: TeamsCrud['Server']['Update']): Promise<TeamsCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n urlString`/teams/${teamId}`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n null,\n );\n return await response.json();\n }\n\n async deleteServerTeam(teamId: string): Promise<void> {\n await this.sendServerRequest(\n urlString`/teams/${teamId}`,\n { method: \"DELETE\" },\n null,\n );\n }\n\n async addServerUserToTeam(options: {\n userId: string,\n teamId: string,\n }): Promise<TeamMembershipsCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n urlString`/team-memberships/${options.teamId}/${options.userId}`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n null,\n );\n return await response.json();\n }\n\n async removeServerUserFromTeam(options: {\n userId: string,\n teamId: string,\n }) {\n await this.sendServerRequest(\n urlString`/team-memberships/${options.teamId}/${options.userId}`,\n {\n method: \"DELETE\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n null,\n );\n }\n\n async listServerUserTeamInvitations(userId: string): Promise<TeamInvitationCrud['Server']['Read'][]> {\n const response = await this.sendServerRequest(\n \"/team-invitations?\" + new URLSearchParams({ user_id: userId }),\n {},\n null,\n );\n const result = await response.json() as TeamInvitationCrud['Server']['List'];\n return result.items;\n }\n\n async acceptServerTeamInvitationById(\n invitationId: string,\n userId: string,\n ) {\n await this.sendServerRequest(\n urlString`/team-invitations/${invitationId}/accept` + \"?\" + new URLSearchParams({ user_id: userId }),\n { method: \"POST\" },\n null,\n );\n }\n\n async updateServerUser(userId: string, update: UsersCrud['Server']['Update']): Promise<UsersCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n urlString`/users/${userId}`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(update),\n },\n null,\n );\n return await response.json();\n }\n\n async createServerProviderAccessToken(\n userId: string,\n provider: string,\n scope: string,\n ): Promise<ConnectedAccountAccessTokenCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n urlString`/connected-accounts/${userId}/${provider}/access-token`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({ scope }),\n },\n null,\n );\n return await response.json();\n }\n\n /**\n * Get access token for a specific connected account by provider ID and provider account ID.\n * This is the preferred method when dealing with multiple accounts of the same provider.\n */\n async createServerProviderAccessTokenByAccount(\n userId: string,\n providerId: string,\n providerAccountId: string,\n scope: string,\n ): Promise<ConnectedAccountAccessTokenCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n urlString`/connected-accounts/${userId}/${providerId}/${providerAccountId}/access-token`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({ scope }),\n },\n null,\n );\n return await response.json();\n }\n\n /**\n * List all connected accounts for a user.\n */\n async listServerConnectedAccounts(\n userId: string,\n ): Promise<ConnectedAccountCrud['Server']['List']> {\n const response = await this.sendServerRequest(\n urlString`/connected-accounts/${userId}`,\n { method: \"GET\" },\n null,\n );\n return await response.json();\n }\n\n async createServerUserSession(userId: string, expiresInMillis: number, isImpersonation: boolean): Promise<{ accessToken: string, refreshToken: string }> {\n const response = await this.sendServerRequest(\n \"/auth/sessions\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({\n user_id: userId,\n expires_in_millis: expiresInMillis,\n is_impersonation: isImpersonation,\n }),\n },\n null,\n );\n const result = await response.json();\n return {\n accessToken: result.access_token,\n refreshToken: result.refresh_token,\n };\n }\n\n async leaveServerTeam(\n options: {\n teamId: string,\n userId: string,\n },\n ) {\n await this.sendClientRequest(\n urlString`/team-memberships/${options.teamId}/${options.userId}`,\n {\n method: \"DELETE\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n null,\n );\n }\n\n async updateServerTeamMemberProfile(options: {\n teamId: string,\n userId: string,\n profile: TeamMemberProfilesCrud['Server']['Update'],\n }) {\n await this.sendServerRequest(\n urlString`/team-member-profiles/${options.teamId}/${options.userId}`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(options.profile),\n },\n null,\n );\n }\n\n async grantServerTeamUserPermission(teamId: string, userId: string, permissionId: string) {\n await this.sendServerRequest(\n urlString`/team-permissions/${teamId}/${userId}/${permissionId}`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n null,\n );\n }\n\n async grantServerProjectPermission(userId: string, permissionId: string) {\n await this.sendServerRequest(\n urlString`/project-permissions/${userId}/${permissionId}`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n null,\n );\n }\n\n async revokeServerTeamUserPermission(teamId: string, userId: string, permissionId: string) {\n await this.sendServerRequest(\n urlString`/team-permissions/${teamId}/${userId}/${permissionId}`,\n {\n method: \"DELETE\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n null,\n );\n }\n\n async revokeServerProjectPermission(userId: string, permissionId: string) {\n await this.sendServerRequest(\n urlString`/project-permissions/${userId}/${permissionId}`,\n {\n method: \"DELETE\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n null,\n );\n }\n\n async deleteServerUser(userId: string) {\n await this.sendServerRequest(\n urlString`/users/${userId}`,\n {\n method: \"DELETE\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n null,\n );\n }\n\n async createServerContactChannel(\n data: ContactChannelsCrud['Server']['Create'],\n ): Promise<ContactChannelsCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n \"/contact-channels\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n null,\n );\n return await response.json();\n }\n\n async updateServerContactChannel(\n userId: string,\n contactChannelId: string,\n data: ContactChannelsCrud['Server']['Update'],\n ): Promise<ContactChannelsCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n urlString`/contact-channels/${userId}/${contactChannelId}`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n null,\n );\n return await response.json();\n }\n\n async deleteServerContactChannel(\n userId: string,\n contactChannelId: string,\n ): Promise<void> {\n await this.sendServerRequest(\n urlString`/contact-channels/${userId}/${contactChannelId}`,\n {\n method: \"DELETE\",\n },\n null,\n );\n }\n\n async listServerContactChannels(\n userId: string,\n ): Promise<ContactChannelsCrud['Server']['Read'][]> {\n const response = await this.sendServerRequest(\n urlString`/contact-channels?user_id=${userId}`,\n {\n method: \"GET\",\n },\n null,\n );\n const json = await response.json() as ContactChannelsCrud['Server']['List'];\n return json.items;\n }\n\n async listServerNotificationCategories(\n userId: string,\n ): Promise<NotificationPreferenceCrud['Server']['Read'][]> {\n const response = await this.sendServerRequest(\n urlString`/emails/notification-preference/${userId}`,\n {\n method: \"GET\",\n },\n null,\n );\n const json = await response.json() as NotificationPreferenceCrud['Server']['List'];\n return json.items;\n }\n\n async setServerNotificationsEnabled(\n userId: string,\n notificationCategoryId: string,\n enabled: boolean,\n ): Promise<void> {\n await this.sendServerRequest(\n urlString`/emails/notification-preference/${userId}/${notificationCategoryId}`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({\n enabled,\n }),\n },\n null,\n );\n }\n\n async sendServerContactChannelVerificationEmail(\n userId: string,\n contactChannelId: string,\n callbackUrl: string,\n ): Promise<void> {\n await this.sendServerRequest(\n urlString`/contact-channels/${userId}/${contactChannelId}/send-verification-code`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({ callback_url: callbackUrl }),\n },\n null,\n );\n }\n\n\n async listServerSessions(userId: string): Promise<SessionsCrud['Server']['List']> {\n const response = await this.sendServerRequest(\n urlString`/auth/sessions?user_id=${userId}`,\n {\n method: \"GET\",\n },\n null,\n );\n return await response.json();\n }\n\n async deleteServerSession(sessionId: string) {\n await this.sendServerRequest(\n urlString`/auth/sessions/${sessionId}`,\n {\n method: \"DELETE\",\n },\n null,\n );\n }\n\n\n async sendServerTeamInvitation(options: {\n email: string,\n teamId: string,\n callbackUrl: string,\n }): Promise<void> {\n await this.sendServerRequest(\n \"/team-invitations/send-code\",\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify({\n email: options.email,\n team_id: options.teamId,\n callback_url: options.callbackUrl,\n }),\n },\n null,\n );\n }\n\n async updatePassword(\n options: { oldPassword: string, newPassword: string },\n ): Promise<KnownErrors[\"PasswordConfirmationMismatch\"] | KnownErrors[\"PasswordRequirementsNotMet\"] | undefined> {\n const res = await this.sendServerRequestAndCatchKnownError(\n \"/auth/password/update\",\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify({\n old_password: options.oldPassword,\n new_password: options.newPassword,\n }),\n },\n null,\n [KnownErrors.PasswordConfirmationMismatch, KnownErrors.PasswordRequirementsNotMet]\n );\n\n if (res.status === \"error\") {\n return res.error;\n }\n }\n\n // OAuth Providers CRUD operations\n async createServerOAuthProvider(\n data: OAuthProviderCrud['Server']['Create'],\n ): Promise<OAuthProviderCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n \"/oauth-providers\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n null,\n );\n return await response.json();\n }\n\n\n async listServerOAuthProviders(\n options: {\n user_id?: string,\n } = {},\n ): Promise<OAuthProviderCrud['Server']['Read'][]> {\n const queryParams = new URLSearchParams(filterUndefined(options));\n const response = await this.sendServerRequest(\n `/oauth-providers${queryParams.toString() ? `?${queryParams.toString()}` : ''}`,\n {\n method: \"GET\",\n },\n null,\n );\n const result = await response.json();\n return result.items;\n }\n\n async updateServerOAuthProvider(\n userId: string,\n providerId: string,\n data: OAuthProviderCrud['Server']['Update'],\n ): Promise<OAuthProviderCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n urlString`/oauth-providers/${userId}/${providerId}`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n null,\n );\n return await response.json();\n }\n\n async deleteServerOAuthProvider(\n userId: string,\n providerId: string,\n ): Promise<void> {\n const response = await this.sendServerRequest(\n urlString`/oauth-providers/${userId}/${providerId}`,\n {\n method: \"DELETE\",\n },\n null,\n );\n return await response.json();\n }\n\n async sendEmail(options: {\n userIds?: string[],\n allUsers?: true,\n themeId?: string | null | false,\n html?: string,\n subject?: string,\n notificationCategoryName?: string,\n templateId?: string,\n variables?: Record<string, any>,\n draftId?: string,\n scheduledAt?: Date,\n }): Promise<Result<void, KnownErrors[\"RequiresCustomEmailServer\"] | KnownErrors[\"SchemaError\"] | KnownErrors[\"UserIdDoesNotExist\"]>> {\n const res = await this.sendServerRequest(\n \"/emails/send-email\",\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify({\n user_ids: options.userIds,\n all_users: options.allUsers,\n theme_id: options.themeId,\n html: options.html,\n subject: options.subject,\n notification_category_name: options.notificationCategoryName,\n template_id: options.templateId,\n variables: options.variables,\n draft_id: options.draftId,\n scheduled_at_millis: options.scheduledAt?.getTime(),\n }),\n },\n null,\n );\n return Result.ok(undefined);\n }\n\n async getEmailDeliveryInfo(): Promise<{\n stats: {\n hour: { sent: number, bounced: number, marked_as_spam: number },\n day: { sent: number, bounced: number, marked_as_spam: number },\n week: { sent: number, bounced: number, marked_as_spam: number },\n month: { sent: number, bounced: number, marked_as_spam: number },\n },\n capacity: {\n rate_per_second: number,\n boost_multiplier: number,\n penalty_factor: number,\n is_boost_active: boolean,\n boost_expires_at: string | null,\n },\n }> {\n const res = await this.sendServerRequest(\n \"/emails/delivery-info\",\n {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n },\n null,\n );\n return await res.json();\n }\n\n async activateEmailCapacityBoost(): Promise<{ expires_at: string }> {\n const res = await this.sendServerRequest(\n \"/emails/capacity-boost\",\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify({}),\n },\n null,\n );\n return await res.json();\n }\n\n async updateItemQuantity(\n options: (\n { itemId: string, userId: string } |\n { itemId: string, teamId: string } |\n { itemId: string, customCustomerId: string }\n ),\n data: ItemCrud['Server']['Update'],\n ): Promise<void> {\n let customerType: \"user\" | \"team\" | \"custom\";\n let customerId: string;\n const itemId: string = options.itemId;\n\n if (\"userId\" in options) {\n customerType = \"user\";\n customerId = options.userId;\n } else if (\"teamId\" in options) {\n customerType = \"team\";\n customerId = options.teamId;\n } else if (\"customCustomerId\" in options) {\n customerType = \"custom\";\n customerId = options.customCustomerId;\n } else {\n throw new HexclaveAssertionError(\"updateItemQuantity requires one of userId, teamId, or customCustomerId\");\n }\n\n const queryParams = new URLSearchParams({ allow_negative: (data.allow_negative ?? false).toString() });\n await this.sendServerRequest(\n `/payments/items/${customerType}/${customerId}/${itemId}/update-quantity?${queryParams.toString()}`,\n {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ delta: data.delta, expires_at: data.expires_at, description: data.description }),\n },\n null\n );\n }\n\n async grantProduct(\n options: {\n customerType: \"user\" | \"team\" | \"custom\",\n customerId: string,\n productId?: string,\n product?: yup.InferType<typeof inlineProductSchema>,\n quantity?: number,\n },\n ): Promise<void> {\n if (!options.productId && !options.product) {\n throw new HexclaveAssertionError(\"grantProduct requires either productId or product\");\n }\n if (options.productId && options.product) {\n throw new HexclaveAssertionError(\"grantProduct should not receive both productId and product\");\n }\n const body = filterUndefined({\n product_id: options.productId,\n product_inline: options.product,\n quantity: options.quantity,\n });\n await this.sendServerRequest(\n urlString`/payments/products/${options.customerType}/${options.customerId}`,\n {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify(body),\n },\n null,\n );\n }\n\n async getDataVaultStoreValue(secret: string, storeId: string, key: string) {\n const hashedKey = await hashKey(secret, key);\n const response = await this.sendServerRequestAndCatchKnownError(\n `/data-vault/stores/${storeId}/get`,\n {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ hashed_key: hashedKey }),\n },\n null,\n [KnownErrors.DataVaultStoreHashedKeyDoesNotExist] as const,\n );\n if (response.status === \"error\") {\n if (KnownErrors.DataVaultStoreHashedKeyDoesNotExist.isInstance(response.error)) {\n return null;\n } else {\n throw new HexclaveAssertionError(\"Unexpected uncaught error\", { cause: response.error });\n }\n }\n const json = await response.data.json();\n const encryptedValue = json.encrypted_value;\n if (typeof encryptedValue !== \"string\") throw new HexclaveAssertionError(\"encrypted_value is not a string\", { type: typeof encryptedValue });\n return await decryptValue(secret, key, encryptedValue);\n }\n\n async setDataVaultStoreValue(secret: string, storeId: string, key: string, value: string) {\n const hashedKey = await hashKey(secret, key);\n const encryptedValue = await encryptValue(secret, key, value);\n await this.sendServerRequest(\n `/data-vault/stores/${storeId}/set`,\n {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ hashed_key: hashedKey, encrypted_value: encryptedValue }),\n },\n null,\n );\n }\n\n async initiateServerPasskeyRegistration(userId: string): Promise<Result<{ options_json: any, code: string }, KnownErrors[]>> {\n // Create a temporary session for this user to use for passkey registration\n // TODO instead of creating a new session, this should just call the endpoint in a way in which it doesn't require a session\n // (currently this shows up on session history etc... not ideal)\n const { accessToken, refreshToken } = await this.createServerUserSession(userId, 60000 * 2, false); // 2 minute session\n const tempSession = new InternalSession({\n accessToken,\n refreshToken,\n refreshAccessTokenCallback: async () => null, // No refresh for temporary sessions\n });\n\n // Use the existing initiatePasskeyRegistration method with the temporary session\n return await this.initiatePasskeyRegistration({}, tempSession);\n }\n}\n"],"mappings":";;;;;;;;;;AAwCA,IAAa,0BAAb,cAA6C,wBAAwB;CACnE,YAAY,AAAgB,SAAuC;AACjE,QAAM,QAAQ;EADY;;CAI5B,MAAgB,kBAAkB,MAAc,SAAsB,SAAiC,cAAkC,UAAU;AACjJ,SAAO,MAAM,KAAK,kBAChB,MACA;GACE,GAAG;GACH,SAAS;IAEP,gCAAgC,qBAAqB,KAAK,UAAU,KAAK,QAAQ,kBAAkB;IACnG,GAAG,QAAQ;IACZ;GACF,EACD,SACA,YACD;;CAGH,MAAe,mBACb,cACA,YACA,SAUC;AAMD,SAAO,OALU,MAAM,KAAK,kBAC1B,SAAS,qBAAqB,aAAa,GAAG,cAC9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AM,IAAI,uBAAuB,6BAA6B,EAAE,OAAO,SAAS,OAAO,CAAC;EAI5F,MAAM,kBADO,MAAM,SAAS,KAAK,MAAM,EACX;AAC5B,MAAI,OAAO,mBAAmB,SAAU,OAAM,IAAI,uBAAuB,mCAAmC,EAAE,MAAM,OAAO,gBAAgB,CAAC;AAC5I,SAAO,MAAM,aAAa,QAAQ,KAAK,eAAe;;CAGxD,MAAM,uBAAuB,QAAgB,SAAiB,KAAa,OAAe;EACxF,MAAM,YAAY,MAAM,QAAQ,QAAQ,IAAI;EAC5C,MAAM,iBAAiB,MAAM,aAAa,QAAQ,KAAK,MAAM;AAC7D,QAAM,KAAK,kBACT,sBAAsB,QAAQ,OAC9B;GACE,QAAQ;GACR,SAAS,EAAE,gBAAgB,oBAAoB;GAC/C,MAAM,KAAK,UAAU;IAAE,YAAY;IAAW,iBAAiB;IAAgB,CAAC;GACjF,EACD,KACD;;CAGH,MAAM,kCAAkC,QAAqF;EAI3H,MAAM,EAAE,aAAa,iBAAiB,MAAM,KAAK,wBAAwB,QAAQ,MAAQ,GAAG,MAAM;EAClG,MAAM,cAAc,IAAI,gBAAgB;GACtC;GACA;GACA,4BAA4B,YAAY;GACzC,CAAC;AAGF,SAAO,MAAM,KAAK,4BAA4B,EAAE,EAAE,YAAY"}
|
|
1
|
+
{"version":3,"file":"server-interface.js","names":[],"sources":["../../../src/interface/server-interface.ts"],"sourcesContent":["import * as yup from \"yup\";\nimport { decryptValue, encryptValue, hashKey } from \"../helpers/vault/client-side\";\nimport { KnownErrors } from \"../known-errors\";\nimport { inlineProductSchema } from \"../schema-fields\";\nimport { AccessToken, InternalSession, RefreshToken } from \"../sessions\";\nimport { HexclaveAssertionError } from \"../utils/errors\";\nimport { filterUndefined } from \"../utils/objects\";\nimport { Result } from \"../utils/results\";\nimport { urlString } from \"../utils/urls\";\nimport {\n ClientInterfaceOptions,\n HexclaveClientInterface\n} from \"./client-interface\";\nimport { ConnectedAccountAccessTokenCrud, ConnectedAccountCrud } from \"./crud/connected-accounts\";\nimport { ContactChannelsCrud } from \"./crud/contact-channels\";\nimport { CurrentUserCrud } from \"./crud/current-user\";\nimport { ItemCrud } from \"./crud/items\";\nimport { NotificationPreferenceCrud } from \"./crud/notification-preferences\";\nimport { OAuthProviderCrud } from \"./crud/oauth-providers\";\nimport { ProjectPermissionsCrud } from \"./crud/project-permissions\";\nimport { SessionsCrud } from \"./crud/sessions\";\nimport { TeamInvitationCrud } from \"./crud/team-invitation\";\nimport { TeamMemberProfilesCrud } from \"./crud/team-member-profiles\";\nimport { TeamMembershipsCrud } from \"./crud/team-memberships\";\nimport { TeamPermissionsCrud } from \"./crud/team-permissions\";\nimport { TeamsCrud } from \"./crud/teams\";\nimport { UsersCrud } from \"./crud/users\";\n\nexport type ServerAuthApplicationOptions = (\n & ClientInterfaceOptions\n & (\n | {\n readonly secretServerKey: string,\n }\n | {\n readonly projectOwnerSession: InternalSession | (() => Promise<string | null>),\n }\n )\n);\n\nexport class HexclaveServerInterface extends HexclaveClientInterface {\n constructor(public override options: ServerAuthApplicationOptions) {\n super(options);\n }\n\n protected async sendServerRequest(path: string, options: RequestInit, session: InternalSession | null, requestType: \"server\" | \"admin\" = \"server\") {\n return await this.sendClientRequest(\n path,\n {\n ...options,\n headers: {\n // Hexclave rebrand: emit x-hexclave-* request header; the backend proxy dual-accepts both names.\n \"x-hexclave-secret-server-key\": \"secretServerKey\" in this.options ? this.options.secretServerKey : \"\",\n ...options.headers,\n },\n },\n session,\n requestType,\n );\n }\n\n override async getCustomerBilling(\n customerType: \"user\" | \"team\",\n customerId: string,\n session: InternalSession | null,\n ): Promise<{\n has_customer: boolean,\n default_payment_method: {\n id: string,\n brand: string | null,\n last4: string | null,\n exp_month: number | null,\n exp_year: number | null,\n } | null,\n }> {\n const response = await this.sendServerRequest(\n urlString`/payments/billing/${customerType}/${customerId}`,\n {},\n session,\n );\n return await response.json();\n }\n\n override async createCustomerPaymentMethodSetupIntent(\n customerType: \"user\" | \"team\",\n customerId: string,\n session: InternalSession | null,\n ): Promise<{\n client_secret: string,\n stripe_account_id: string,\n }> {\n const response = await this.sendServerRequest(\n urlString`/payments/payment-method/${customerType}/${customerId}/setup-intent`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n session,\n );\n return await response.json();\n }\n\n override async setDefaultCustomerPaymentMethodFromSetupIntent(\n customerType: \"user\" | \"team\",\n customerId: string,\n setupIntentId: string,\n session: InternalSession | null,\n ): Promise<{\n default_payment_method: {\n id: string,\n brand: string | null,\n last4: string | null,\n exp_month: number | null,\n exp_year: number | null,\n },\n }> {\n const response = await this.sendServerRequest(\n urlString`/payments/payment-method/${customerType}/${customerId}/set-default`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({\n setup_intent_id: setupIntentId,\n }),\n },\n session,\n );\n return await response.json();\n }\n\n\n protected async sendServerRequestAndCatchKnownError<E extends typeof KnownErrors[keyof KnownErrors]>(\n path: string,\n requestOptions: RequestInit,\n tokenStoreOrNull: InternalSession | null,\n errorsToCatch: readonly E[],\n ): Promise<Result<\n Response & {\n usedTokens: {\n accessToken: AccessToken,\n refreshToken: RefreshToken | null,\n } | null,\n },\n InstanceType<E>\n >> {\n try {\n return Result.ok(await this.sendServerRequest(path, requestOptions, tokenStoreOrNull));\n } catch (e) {\n for (const errorType of errorsToCatch) {\n if (errorType.isInstance(e)) {\n return Result.error(e as InstanceType<E>);\n }\n }\n throw e;\n }\n }\n\n async createServerUser(data: UsersCrud['Server']['Create']): Promise<UsersCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n \"/users\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n null,\n );\n return await response.json();\n }\n\n async getServerUserByToken(session: InternalSession): Promise<CurrentUserCrud['Server']['Read'] | null> {\n const responseOrError = await this.sendServerRequestAndCatchKnownError(\n \"/users/me\",\n {},\n session,\n [KnownErrors.CannotGetOwnUserWithoutUser],\n );\n if (responseOrError.status === \"error\") {\n if (KnownErrors.CannotGetOwnUserWithoutUser.isInstance(responseOrError.error)) {\n return null;\n } else {\n throw new HexclaveAssertionError(\"Unexpected uncaught error\", { cause: responseOrError.error });\n }\n }\n const response = responseOrError.data;\n const user: CurrentUserCrud['Server']['Read'] = await response.json();\n if (!(user as any)) throw new HexclaveAssertionError(\"User endpoint returned null; this should never happen\");\n return user;\n }\n\n async getServerUserById(userId: string): Promise<Result<UsersCrud['Server']['Read']>> {\n const responseOrError = await this.sendServerRequestAndCatchKnownError(\n urlString`/users/${userId}`,\n {},\n null,\n [KnownErrors.UserNotFound],\n );\n if (responseOrError.status === \"error\") {\n return Result.error(responseOrError.error);\n }\n const user: UsersCrud['Server']['Read'] = await responseOrError.data.json();\n return Result.ok(user);\n }\n\n async listServerTeamInvitations(options: {\n teamId: string,\n }): Promise<TeamInvitationCrud['Server']['Read'][]> {\n const response = await this.sendServerRequest(\n urlString`/team-invitations?team_id=${options.teamId}`,\n {},\n null,\n );\n const result = await response.json() as TeamInvitationCrud['Server']['List'];\n return result.items;\n }\n\n async revokeServerTeamInvitation(invitationId: string, teamId: string) {\n await this.sendServerRequest(\n urlString`/team-invitations/${invitationId}?team_id=${teamId}`,\n { method: \"DELETE\" },\n null,\n );\n }\n\n async listServerTeamMemberProfiles(\n options: {\n teamId: string,\n },\n ): Promise<TeamMemberProfilesCrud['Server']['Read'][]> {\n const response = await this.sendServerRequest(\n urlString`/team-member-profiles?team_id=${options.teamId}`,\n {},\n null,\n );\n const result = await response.json() as TeamMemberProfilesCrud['Server']['List'];\n return result.items;\n }\n\n async getServerTeamMemberProfile(\n options: {\n teamId: string,\n userId: string,\n },\n ): Promise<TeamMemberProfilesCrud['Client']['Read']> {\n const response = await this.sendServerRequest(\n urlString`/team-member-profiles/${options.teamId}/${options.userId}`,\n {},\n null,\n );\n return await response.json();\n }\n\n async listServerTeamPermissions(\n options: {\n userId?: string,\n teamId?: string,\n recursive: boolean,\n },\n session: InternalSession | null,\n ): Promise<TeamPermissionsCrud['Server']['Read'][]> {\n const response = await this.sendServerRequest(\n `/team-permissions?${new URLSearchParams(filterUndefined({\n user_id: options.userId,\n team_id: options.teamId,\n recursive: options.recursive.toString(),\n }))}`,\n {},\n session,\n );\n const result = await response.json() as TeamPermissionsCrud['Server']['List'];\n return result.items;\n }\n\n async listServerProjectPermissions(\n options: {\n userId?: string,\n recursive: boolean,\n },\n session: InternalSession | null,\n ): Promise<ProjectPermissionsCrud['Server']['Read'][]> {\n const response = await this.sendServerRequest(\n `/project-permissions?${new URLSearchParams(filterUndefined({\n user_id: options.userId,\n recursive: options.recursive.toString(),\n }))}`,\n {},\n session,\n );\n const result = await response.json() as ProjectPermissionsCrud['Server']['List'];\n return result.items;\n }\n\n async listServerUsers(options: (\n & {\n cursor?: string,\n limit?: number,\n orderBy?: 'signedUpAt' | 'lastActiveAt',\n desc?: boolean,\n query?: string,\n excludedEmailDomains?: string[],\n includeRestricted?: boolean,\n teamId?: string,\n }\n & (\n {\n includeAnonymous?: boolean,\n onlyAnonymous?: false,\n }\n | {\n includeAnonymous: true,\n onlyAnonymous: true,\n }\n )\n )): Promise<UsersCrud['Server']['List']> {\n const searchParams = new URLSearchParams(filterUndefined({\n cursor: options.cursor,\n limit: options.limit?.toString(),\n desc: options.desc?.toString(),\n team_id: options.teamId,\n ...options.orderBy ? {\n order_by: {\n signedUpAt: \"signed_up_at\",\n lastActiveAt: \"last_active_at\",\n }[options.orderBy],\n } : {},\n ...options.query ? {\n query: options.query,\n } : {},\n ...options.excludedEmailDomains && options.excludedEmailDomains.length > 0 ? {\n excluded_email_domains: options.excludedEmailDomains.join(\",\"), // backend expects comma-separated list of domains.\n } : {},\n ...options.includeRestricted ? {\n include_restricted: 'true',\n } : {},\n ...options.includeAnonymous ? {\n include_anonymous: 'true',\n } : {},\n ...options.onlyAnonymous ? {\n only_anonymous: 'true',\n } : {},\n }));\n const response = await this.sendServerRequest(\"/users?\" + searchParams.toString(), {}, null);\n return await response.json();\n }\n\n async listServerTeams(options?: {\n userId?: string,\n }): Promise<TeamsCrud['Server']['Read'][]> {\n const result = await this.listServerTeamsPaginated(options);\n return result.items;\n }\n\n async listServerTeamsPaginated(options?: {\n userId?: string,\n orderBy?: 'createdAt',\n desc?: boolean,\n cursor?: string,\n limit?: number,\n query?: string,\n }): Promise<TeamsCrud['Server']['List']> {\n const response = await this.sendServerRequest(\n `/teams?${new URLSearchParams(filterUndefined({\n user_id: options?.userId,\n // SDK option uses camelCase `createdAt`; backend uses snake_case.\n order_by: options?.orderBy === 'createdAt' ? 'created_at' : options?.orderBy,\n desc: options?.desc !== undefined ? String(options.desc) : undefined,\n cursor: options?.cursor,\n limit: options?.limit?.toString(),\n query: options?.query,\n }))}`,\n {},\n null\n );\n return await response.json() as TeamsCrud['Server']['List'];\n }\n\n async getServerTeam(teamId: string): Promise<TeamsCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n `/teams/${teamId}`,\n {},\n null\n );\n return await response.json();\n }\n\n async listServerTeamUsers(teamId: string): Promise<UsersCrud['Server']['Read'][]> {\n const response = await this.sendServerRequest(`/users?team_id=${teamId}`, {}, null);\n const result = await response.json() as UsersCrud['Server']['List'];\n return result.items;\n }\n\n /* when passing a session, the user will be added to the team */\n async createServerTeam(data: TeamsCrud['Server']['Create']): Promise<TeamsCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n \"/teams\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n null\n );\n return await response.json();\n }\n\n async updateServerTeam(teamId: string, data: TeamsCrud['Server']['Update']): Promise<TeamsCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n urlString`/teams/${teamId}`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n null,\n );\n return await response.json();\n }\n\n async deleteServerTeam(teamId: string): Promise<void> {\n await this.sendServerRequest(\n urlString`/teams/${teamId}`,\n { method: \"DELETE\" },\n null,\n );\n }\n\n async addServerUserToTeam(options: {\n userId: string,\n teamId: string,\n }): Promise<TeamMembershipsCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n urlString`/team-memberships/${options.teamId}/${options.userId}`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n null,\n );\n return await response.json();\n }\n\n async removeServerUserFromTeam(options: {\n userId: string,\n teamId: string,\n }) {\n await this.sendServerRequest(\n urlString`/team-memberships/${options.teamId}/${options.userId}`,\n {\n method: \"DELETE\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n null,\n );\n }\n\n async listServerUserTeamInvitations(userId: string): Promise<TeamInvitationCrud['Server']['Read'][]> {\n const response = await this.sendServerRequest(\n \"/team-invitations?\" + new URLSearchParams({ user_id: userId }),\n {},\n null,\n );\n const result = await response.json() as TeamInvitationCrud['Server']['List'];\n return result.items;\n }\n\n async acceptServerTeamInvitationById(\n invitationId: string,\n userId: string,\n ) {\n await this.sendServerRequest(\n urlString`/team-invitations/${invitationId}/accept` + \"?\" + new URLSearchParams({ user_id: userId }),\n { method: \"POST\" },\n null,\n );\n }\n\n async updateServerUser(userId: string, update: UsersCrud['Server']['Update']): Promise<UsersCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n urlString`/users/${userId}`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(update),\n },\n null,\n );\n return await response.json();\n }\n\n async createServerProviderAccessToken(\n userId: string,\n provider: string,\n scope: string,\n ): Promise<ConnectedAccountAccessTokenCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n urlString`/connected-accounts/${userId}/${provider}/access-token`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({ scope }),\n },\n null,\n );\n return await response.json();\n }\n\n /**\n * Get access token for a specific connected account by provider ID and provider account ID.\n * This is the preferred method when dealing with multiple accounts of the same provider.\n */\n async createServerProviderAccessTokenByAccount(\n userId: string,\n providerId: string,\n providerAccountId: string,\n scope: string,\n ): Promise<ConnectedAccountAccessTokenCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n urlString`/connected-accounts/${userId}/${providerId}/${providerAccountId}/access-token`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({ scope }),\n },\n null,\n );\n return await response.json();\n }\n\n /**\n * List all connected accounts for a user.\n */\n async listServerConnectedAccounts(\n userId: string,\n ): Promise<ConnectedAccountCrud['Server']['List']> {\n const response = await this.sendServerRequest(\n urlString`/connected-accounts/${userId}`,\n { method: \"GET\" },\n null,\n );\n return await response.json();\n }\n\n async createServerUserSession(userId: string, expiresInMillis: number, isImpersonation: boolean): Promise<{ accessToken: string, refreshToken: string }> {\n const response = await this.sendServerRequest(\n \"/auth/sessions\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({\n user_id: userId,\n expires_in_millis: expiresInMillis,\n is_impersonation: isImpersonation,\n }),\n },\n null,\n );\n const result = await response.json();\n return {\n accessToken: result.access_token,\n refreshToken: result.refresh_token,\n };\n }\n\n async leaveServerTeam(\n options: {\n teamId: string,\n userId: string,\n },\n ) {\n await this.sendClientRequest(\n urlString`/team-memberships/${options.teamId}/${options.userId}`,\n {\n method: \"DELETE\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n null,\n );\n }\n\n async updateServerTeamMemberProfile(options: {\n teamId: string,\n userId: string,\n profile: TeamMemberProfilesCrud['Server']['Update'],\n }) {\n await this.sendServerRequest(\n urlString`/team-member-profiles/${options.teamId}/${options.userId}`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(options.profile),\n },\n null,\n );\n }\n\n async grantServerTeamUserPermission(teamId: string, userId: string, permissionId: string) {\n await this.sendServerRequest(\n urlString`/team-permissions/${teamId}/${userId}/${permissionId}`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n null,\n );\n }\n\n async grantServerProjectPermission(userId: string, permissionId: string) {\n await this.sendServerRequest(\n urlString`/project-permissions/${userId}/${permissionId}`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n null,\n );\n }\n\n async revokeServerTeamUserPermission(teamId: string, userId: string, permissionId: string) {\n await this.sendServerRequest(\n urlString`/team-permissions/${teamId}/${userId}/${permissionId}`,\n {\n method: \"DELETE\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n null,\n );\n }\n\n async revokeServerProjectPermission(userId: string, permissionId: string) {\n await this.sendServerRequest(\n urlString`/project-permissions/${userId}/${permissionId}`,\n {\n method: \"DELETE\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n null,\n );\n }\n\n async deleteServerUser(userId: string) {\n await this.sendServerRequest(\n urlString`/users/${userId}`,\n {\n method: \"DELETE\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({}),\n },\n null,\n );\n }\n\n async createServerContactChannel(\n data: ContactChannelsCrud['Server']['Create'],\n ): Promise<ContactChannelsCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n \"/contact-channels\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n null,\n );\n return await response.json();\n }\n\n async updateServerContactChannel(\n userId: string,\n contactChannelId: string,\n data: ContactChannelsCrud['Server']['Update'],\n ): Promise<ContactChannelsCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n urlString`/contact-channels/${userId}/${contactChannelId}`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n null,\n );\n return await response.json();\n }\n\n async deleteServerContactChannel(\n userId: string,\n contactChannelId: string,\n ): Promise<void> {\n await this.sendServerRequest(\n urlString`/contact-channels/${userId}/${contactChannelId}`,\n {\n method: \"DELETE\",\n },\n null,\n );\n }\n\n async listServerContactChannels(\n userId: string,\n ): Promise<ContactChannelsCrud['Server']['Read'][]> {\n const response = await this.sendServerRequest(\n urlString`/contact-channels?user_id=${userId}`,\n {\n method: \"GET\",\n },\n null,\n );\n const json = await response.json() as ContactChannelsCrud['Server']['List'];\n return json.items;\n }\n\n async listServerNotificationCategories(\n userId: string,\n ): Promise<NotificationPreferenceCrud['Server']['Read'][]> {\n const response = await this.sendServerRequest(\n urlString`/emails/notification-preference/${userId}`,\n {\n method: \"GET\",\n },\n null,\n );\n const json = await response.json() as NotificationPreferenceCrud['Server']['List'];\n return json.items;\n }\n\n async setServerNotificationsEnabled(\n userId: string,\n notificationCategoryId: string,\n enabled: boolean,\n ): Promise<void> {\n await this.sendServerRequest(\n urlString`/emails/notification-preference/${userId}/${notificationCategoryId}`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({\n enabled,\n }),\n },\n null,\n );\n }\n\n async sendServerContactChannelVerificationEmail(\n userId: string,\n contactChannelId: string,\n callbackUrl: string,\n ): Promise<void> {\n await this.sendServerRequest(\n urlString`/contact-channels/${userId}/${contactChannelId}/send-verification-code`,\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify({ callback_url: callbackUrl }),\n },\n null,\n );\n }\n\n\n async listServerSessions(userId: string): Promise<SessionsCrud['Server']['List']> {\n const response = await this.sendServerRequest(\n urlString`/auth/sessions?user_id=${userId}`,\n {\n method: \"GET\",\n },\n null,\n );\n return await response.json();\n }\n\n async deleteServerSession(sessionId: string) {\n await this.sendServerRequest(\n urlString`/auth/sessions/${sessionId}`,\n {\n method: \"DELETE\",\n },\n null,\n );\n }\n\n\n async sendServerTeamInvitation(options: {\n email: string,\n teamId: string,\n callbackUrl: string,\n }): Promise<void> {\n await this.sendServerRequest(\n \"/team-invitations/send-code\",\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify({\n email: options.email,\n team_id: options.teamId,\n callback_url: options.callbackUrl,\n }),\n },\n null,\n );\n }\n\n async updatePassword(\n options: { oldPassword: string, newPassword: string },\n ): Promise<KnownErrors[\"PasswordConfirmationMismatch\"] | KnownErrors[\"PasswordRequirementsNotMet\"] | undefined> {\n const res = await this.sendServerRequestAndCatchKnownError(\n \"/auth/password/update\",\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify({\n old_password: options.oldPassword,\n new_password: options.newPassword,\n }),\n },\n null,\n [KnownErrors.PasswordConfirmationMismatch, KnownErrors.PasswordRequirementsNotMet]\n );\n\n if (res.status === \"error\") {\n return res.error;\n }\n }\n\n // OAuth Providers CRUD operations\n async createServerOAuthProvider(\n data: OAuthProviderCrud['Server']['Create'],\n ): Promise<OAuthProviderCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n \"/oauth-providers\",\n {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n null,\n );\n return await response.json();\n }\n\n\n async listServerOAuthProviders(\n options: {\n user_id?: string,\n } = {},\n ): Promise<OAuthProviderCrud['Server']['Read'][]> {\n const queryParams = new URLSearchParams(filterUndefined(options));\n const response = await this.sendServerRequest(\n `/oauth-providers${queryParams.toString() ? `?${queryParams.toString()}` : ''}`,\n {\n method: \"GET\",\n },\n null,\n );\n const result = await response.json();\n return result.items;\n }\n\n async updateServerOAuthProvider(\n userId: string,\n providerId: string,\n data: OAuthProviderCrud['Server']['Update'],\n ): Promise<OAuthProviderCrud['Server']['Read']> {\n const response = await this.sendServerRequest(\n urlString`/oauth-providers/${userId}/${providerId}`,\n {\n method: \"PATCH\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(data),\n },\n null,\n );\n return await response.json();\n }\n\n async deleteServerOAuthProvider(\n userId: string,\n providerId: string,\n ): Promise<void> {\n const response = await this.sendServerRequest(\n urlString`/oauth-providers/${userId}/${providerId}`,\n {\n method: \"DELETE\",\n },\n null,\n );\n return await response.json();\n }\n\n async sendEmail(options: {\n userIds?: string[],\n allUsers?: true,\n emails?: string[],\n themeId?: string | null | false,\n html?: string,\n subject?: string,\n notificationCategoryName?: string,\n templateId?: string,\n variables?: Record<string, any>,\n draftId?: string,\n scheduledAt?: Date,\n }): Promise<Result<void, KnownErrors[\"RequiresCustomEmailServer\"] | KnownErrors[\"SchemaError\"] | KnownErrors[\"UserIdDoesNotExist\"]>> {\n const res = await this.sendServerRequest(\n \"/emails/send-email\",\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify({\n user_ids: options.userIds,\n all_users: options.allUsers,\n emails: options.emails,\n theme_id: options.themeId,\n html: options.html,\n subject: options.subject,\n notification_category_name: options.notificationCategoryName,\n template_id: options.templateId,\n variables: options.variables,\n draft_id: options.draftId,\n scheduled_at_millis: options.scheduledAt?.getTime(),\n }),\n },\n null,\n );\n return Result.ok(undefined);\n }\n\n async getEmailDeliveryInfo(): Promise<{\n stats: {\n hour: { sent: number, bounced: number, marked_as_spam: number },\n day: { sent: number, bounced: number, marked_as_spam: number },\n week: { sent: number, bounced: number, marked_as_spam: number },\n month: { sent: number, bounced: number, marked_as_spam: number },\n },\n capacity: {\n rate_per_second: number,\n boost_multiplier: number,\n penalty_factor: number,\n is_boost_active: boolean,\n boost_expires_at: string | null,\n },\n }> {\n const res = await this.sendServerRequest(\n \"/emails/delivery-info\",\n {\n method: \"GET\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n },\n null,\n );\n return await res.json();\n }\n\n async activateEmailCapacityBoost(): Promise<{ expires_at: string }> {\n const res = await this.sendServerRequest(\n \"/emails/capacity-boost\",\n {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\"\n },\n body: JSON.stringify({}),\n },\n null,\n );\n return await res.json();\n }\n\n async updateItemQuantity(\n options: (\n { itemId: string, userId: string } |\n { itemId: string, teamId: string } |\n { itemId: string, customCustomerId: string }\n ),\n data: ItemCrud['Server']['Update'],\n ): Promise<void> {\n let customerType: \"user\" | \"team\" | \"custom\";\n let customerId: string;\n const itemId: string = options.itemId;\n\n if (\"userId\" in options) {\n customerType = \"user\";\n customerId = options.userId;\n } else if (\"teamId\" in options) {\n customerType = \"team\";\n customerId = options.teamId;\n } else if (\"customCustomerId\" in options) {\n customerType = \"custom\";\n customerId = options.customCustomerId;\n } else {\n throw new HexclaveAssertionError(\"updateItemQuantity requires one of userId, teamId, or customCustomerId\");\n }\n\n const queryParams = new URLSearchParams({ allow_negative: (data.allow_negative ?? false).toString() });\n await this.sendServerRequest(\n `/payments/items/${customerType}/${customerId}/${itemId}/update-quantity?${queryParams.toString()}`,\n {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ delta: data.delta, expires_at: data.expires_at, description: data.description }),\n },\n null\n );\n }\n\n async grantProduct(\n options: {\n customerType: \"user\" | \"team\" | \"custom\",\n customerId: string,\n productId?: string,\n product?: yup.InferType<typeof inlineProductSchema>,\n quantity?: number,\n },\n ): Promise<void> {\n if (!options.productId && !options.product) {\n throw new HexclaveAssertionError(\"grantProduct requires either productId or product\");\n }\n if (options.productId && options.product) {\n throw new HexclaveAssertionError(\"grantProduct should not receive both productId and product\");\n }\n const body = filterUndefined({\n product_id: options.productId,\n product_inline: options.product,\n quantity: options.quantity,\n });\n await this.sendServerRequest(\n urlString`/payments/products/${options.customerType}/${options.customerId}`,\n {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify(body),\n },\n null,\n );\n }\n\n async getDataVaultStoreValue(secret: string, storeId: string, key: string) {\n const hashedKey = await hashKey(secret, key);\n const response = await this.sendServerRequestAndCatchKnownError(\n `/data-vault/stores/${storeId}/get`,\n {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ hashed_key: hashedKey }),\n },\n null,\n [KnownErrors.DataVaultStoreHashedKeyDoesNotExist] as const,\n );\n if (response.status === \"error\") {\n if (KnownErrors.DataVaultStoreHashedKeyDoesNotExist.isInstance(response.error)) {\n return null;\n } else {\n throw new HexclaveAssertionError(\"Unexpected uncaught error\", { cause: response.error });\n }\n }\n const json = await response.data.json();\n const encryptedValue = json.encrypted_value;\n if (typeof encryptedValue !== \"string\") throw new HexclaveAssertionError(\"encrypted_value is not a string\", { type: typeof encryptedValue });\n return await decryptValue(secret, key, encryptedValue);\n }\n\n async setDataVaultStoreValue(secret: string, storeId: string, key: string, value: string) {\n const hashedKey = await hashKey(secret, key);\n const encryptedValue = await encryptValue(secret, key, value);\n await this.sendServerRequest(\n `/data-vault/stores/${storeId}/set`,\n {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ hashed_key: hashedKey, encrypted_value: encryptedValue }),\n },\n null,\n );\n }\n\n async initiateServerPasskeyRegistration(userId: string): Promise<Result<{ options_json: any, code: string }, KnownErrors[]>> {\n // Create a temporary session for this user to use for passkey registration\n // TODO instead of creating a new session, this should just call the endpoint in a way in which it doesn't require a session\n // (currently this shows up on session history etc... not ideal)\n const { accessToken, refreshToken } = await this.createServerUserSession(userId, 60000 * 2, false); // 2 minute session\n const tempSession = new InternalSession({\n accessToken,\n refreshToken,\n refreshAccessTokenCallback: async () => null, // No refresh for temporary sessions\n });\n\n // Use the existing initiatePasskeyRegistration method with the temporary session\n return await this.initiatePasskeyRegistration({}, tempSession);\n }\n}\n"],"mappings":";;;;;;;;;;AAwCA,IAAa,0BAAb,cAA6C,wBAAwB;CACnE,YAAY,AAAgB,SAAuC;AACjE,QAAM,QAAQ;EADY;;CAI5B,MAAgB,kBAAkB,MAAc,SAAsB,SAAiC,cAAkC,UAAU;AACjJ,SAAO,MAAM,KAAK,kBAChB,MACA;GACE,GAAG;GACH,SAAS;IAEP,gCAAgC,qBAAqB,KAAK,UAAU,KAAK,QAAQ,kBAAkB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