@theholocron/clerk-client 1.58.0-alpha.3 → 1.58.0-alpha.4
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/index.d.mts +114 -0
- package/dist/index.mjs +1 -0
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "@theholocron/http-client";
|
|
2
2
|
import { ErrorSink, Logger } from "@theholocron/observability/core";
|
|
3
|
+
/** Options for `createClerkClient`. */
|
|
3
4
|
interface ClerkClientOptions {
|
|
4
5
|
/** Clerk secret key (sk_live_... or sk_test_...). */
|
|
5
6
|
token: string;
|
|
@@ -12,142 +13,254 @@ interface ClerkClientOptions {
|
|
|
12
13
|
/** Reports transport failures and unexpected 5xx. Defaults to a no-op. */
|
|
13
14
|
errors?: ErrorSink;
|
|
14
15
|
}
|
|
16
|
+
/** The Clerk instance the secret key belongs to. */
|
|
15
17
|
interface ClerkInstance {
|
|
18
|
+
/** The instance's identifier. */
|
|
16
19
|
id?: string;
|
|
20
|
+
/** The object type Clerk reports for the instance. */
|
|
17
21
|
object?: string;
|
|
22
|
+
/** Whether the instance is a development, production or staging one; other values pass through as a string. */
|
|
18
23
|
environment_type?: "development" | "production" | "staging" | string;
|
|
19
24
|
}
|
|
25
|
+
/** An email address attached to a Clerk user. */
|
|
20
26
|
interface ClerkEmailAddress {
|
|
27
|
+
/** The email address record's identifier. */
|
|
21
28
|
id: string;
|
|
29
|
+
/** The object type, always `"email_address"`. */
|
|
22
30
|
object: "email_address";
|
|
31
|
+
/** The email address itself. */
|
|
23
32
|
email_address: string;
|
|
33
|
+
/** The verification state (status and strategy), or `null` when none is recorded. */
|
|
24
34
|
verification: {
|
|
25
35
|
status: string;
|
|
26
36
|
strategy: string;
|
|
27
37
|
} | null;
|
|
38
|
+
/** The identities this address is linked to, each with an id and type. */
|
|
28
39
|
linked_to: Array<{
|
|
29
40
|
id: string;
|
|
30
41
|
type: string;
|
|
31
42
|
}>;
|
|
43
|
+
/** When the address was created, as a Unix timestamp in milliseconds. */
|
|
32
44
|
created_at: number;
|
|
45
|
+
/** When the address was last updated, as a Unix timestamp in milliseconds. */
|
|
33
46
|
updated_at: number;
|
|
34
47
|
}
|
|
48
|
+
/** A phone number attached to a Clerk user. */
|
|
35
49
|
interface ClerkPhoneNumber {
|
|
50
|
+
/** The phone number record's identifier. */
|
|
36
51
|
id: string;
|
|
52
|
+
/** The object type, always `"phone_number"`. */
|
|
37
53
|
object: "phone_number";
|
|
54
|
+
/** The phone number itself. */
|
|
38
55
|
phone_number: string;
|
|
56
|
+
/** Whether the number is reserved for second-factor authentication. */
|
|
39
57
|
reserved_for_second_factor: boolean;
|
|
58
|
+
/** Whether the number is the default second factor. */
|
|
40
59
|
default_second_factor: boolean;
|
|
60
|
+
/** The verification state of the number, or `null` when none is recorded. */
|
|
41
61
|
verification: {
|
|
42
62
|
status: string;
|
|
43
63
|
strategy: string;
|
|
44
64
|
} | null;
|
|
65
|
+
/** The identities this number is linked to, each with an id and type. */
|
|
45
66
|
linked_to: Array<{
|
|
46
67
|
id: string;
|
|
47
68
|
type: string;
|
|
48
69
|
}>;
|
|
70
|
+
/** When the number was created, as a Unix timestamp in milliseconds. */
|
|
49
71
|
created_at: number;
|
|
72
|
+
/** When the number was last updated, as a Unix timestamp in milliseconds. */
|
|
50
73
|
updated_at: number;
|
|
51
74
|
}
|
|
75
|
+
/** A user as the Clerk Backend API returns it. */
|
|
52
76
|
interface ClerkUser {
|
|
77
|
+
/** The user's identifier. */
|
|
53
78
|
id: string;
|
|
79
|
+
/** The object type, always `"user"`. */
|
|
54
80
|
object: "user";
|
|
81
|
+
/** The identifier the user has in your own system, or `null` when unset. */
|
|
55
82
|
external_id: string | null;
|
|
83
|
+
/** The id of the user's primary email address, or `null` when there is none. */
|
|
56
84
|
primary_email_address_id: string | null;
|
|
85
|
+
/** The id of the user's primary phone number, or `null` when there is none. */
|
|
57
86
|
primary_phone_number_id: string | null;
|
|
87
|
+
/** The id of the user's primary web3 wallet, or `null` when there is none. */
|
|
58
88
|
primary_web3_wallet_id: string | null;
|
|
89
|
+
/** The user's username, or `null` when unset. */
|
|
59
90
|
username: string | null;
|
|
91
|
+
/** The user's first name, or `null` when unset. */
|
|
60
92
|
first_name: string | null;
|
|
93
|
+
/** The user's last name, or `null` when unset. */
|
|
61
94
|
last_name: string | null;
|
|
95
|
+
/** The URL of the user's profile image. */
|
|
62
96
|
profile_image_url: string;
|
|
97
|
+
/** The URL of the user's image. */
|
|
63
98
|
image_url: string;
|
|
99
|
+
/** Whether the user has uploaded an image. */
|
|
64
100
|
has_image: boolean;
|
|
101
|
+
/** Metadata readable from the frontend and backend, writable only from the backend. */
|
|
65
102
|
public_metadata: Record<string, unknown>;
|
|
103
|
+
/** Metadata readable and writable only from the backend. */
|
|
66
104
|
private_metadata: Record<string, unknown>;
|
|
105
|
+
/** Metadata that the frontend can also read and write. */
|
|
67
106
|
unsafe_metadata: Record<string, unknown>;
|
|
107
|
+
/** The user's email addresses. */
|
|
68
108
|
email_addresses: ClerkEmailAddress[];
|
|
109
|
+
/** The user's phone numbers. */
|
|
69
110
|
phone_numbers: ClerkPhoneNumber[];
|
|
111
|
+
/** When the user last signed in, as a Unix timestamp in milliseconds, or `null` if they never have. */
|
|
70
112
|
last_sign_in_at: number | null;
|
|
113
|
+
/** Whether the user is banned. */
|
|
71
114
|
banned: boolean;
|
|
115
|
+
/** Whether the user is locked out. */
|
|
72
116
|
locked: boolean;
|
|
117
|
+
/** Seconds until the lockout ends, or `null` when the user is not locked. */
|
|
73
118
|
lockout_expires_in_seconds: number | null;
|
|
119
|
+
/** How many verification attempts the user has left, or `null` when not limited. */
|
|
74
120
|
verification_attempts_remaining: number | null;
|
|
121
|
+
/** When the user was created, as a Unix timestamp in milliseconds. */
|
|
75
122
|
created_at: number;
|
|
123
|
+
/** When the user was last updated, as a Unix timestamp in milliseconds. */
|
|
76
124
|
updated_at: number;
|
|
125
|
+
/** Whether the user has a password set. */
|
|
77
126
|
password_enabled: boolean;
|
|
127
|
+
/** Whether two-factor authentication is enabled for the user. */
|
|
78
128
|
two_factor_enabled: boolean;
|
|
129
|
+
/** Whether authenticator-app (TOTP) two-factor is enabled for the user. */
|
|
79
130
|
totp_enabled: boolean;
|
|
131
|
+
/** Whether backup codes are enabled for the user. */
|
|
80
132
|
backup_code_enabled: boolean;
|
|
81
133
|
}
|
|
134
|
+
/** The result of counting users. */
|
|
82
135
|
interface ClerkUserCount {
|
|
136
|
+
/** The object type, always `"total_count"`. */
|
|
83
137
|
object: "total_count";
|
|
138
|
+
/** How many users matched. */
|
|
84
139
|
total_count: number;
|
|
85
140
|
}
|
|
141
|
+
/** What Clerk returns after deleting an object. */
|
|
86
142
|
interface ClerkDeletedObject {
|
|
143
|
+
/** The type of the deleted object. */
|
|
87
144
|
object: string;
|
|
145
|
+
/** The identifier of the deleted object. */
|
|
88
146
|
id: string;
|
|
147
|
+
/** The slug of the deleted object, when it has one. */
|
|
89
148
|
slug?: string;
|
|
149
|
+
/** Whether the object was deleted. */
|
|
90
150
|
deleted: boolean;
|
|
91
151
|
}
|
|
152
|
+
/** Filters and paging for listing users; each array filter is sent as a repeated query parameter. */
|
|
92
153
|
interface ClerkUsersListParams {
|
|
154
|
+
/** The maximum number of users to return. */
|
|
93
155
|
limit?: number;
|
|
156
|
+
/** How many users to skip before returning results. */
|
|
94
157
|
offset?: number;
|
|
158
|
+
/** Only users with one of these email addresses. */
|
|
95
159
|
email_address?: string[];
|
|
160
|
+
/** Only users with one of these phone numbers. */
|
|
96
161
|
phone_number?: string[];
|
|
162
|
+
/** Only users with one of these usernames. */
|
|
97
163
|
username?: string[];
|
|
164
|
+
/** Only users with one of these external ids. */
|
|
98
165
|
external_id?: string[];
|
|
166
|
+
/** Only users with one of these user ids. */
|
|
99
167
|
user_id?: string[];
|
|
168
|
+
/** A search term matched against the user's fields. */
|
|
100
169
|
query?: string;
|
|
170
|
+
/** Only users active since this Unix timestamp in milliseconds. */
|
|
101
171
|
last_active_at_since?: number;
|
|
172
|
+
/** The sort order, as Clerk's `order_by` value (for example `-created_at`). */
|
|
102
173
|
order_by?: string;
|
|
103
174
|
}
|
|
175
|
+
/** The fields accepted when creating a Clerk user. */
|
|
104
176
|
interface CreateClerkUserInput {
|
|
177
|
+
/** The identifier the user has in your own system. */
|
|
105
178
|
external_id?: string;
|
|
179
|
+
/** The user's first name. */
|
|
106
180
|
first_name?: string;
|
|
181
|
+
/** The user's last name. */
|
|
107
182
|
last_name?: string;
|
|
183
|
+
/** Email addresses to attach to the user. */
|
|
108
184
|
email_address?: string[];
|
|
185
|
+
/** Phone numbers to attach to the user. */
|
|
109
186
|
phone_number?: string[];
|
|
187
|
+
/** Web3 wallets to attach to the user. */
|
|
110
188
|
web3_wallet?: string[];
|
|
189
|
+
/** The user's username. */
|
|
111
190
|
username?: string;
|
|
191
|
+
/** The user's password in plain text. */
|
|
112
192
|
password?: string;
|
|
193
|
+
/** A password hash to import, used together with `password_hasher`. */
|
|
113
194
|
password_digest?: string;
|
|
195
|
+
/** The algorithm that produced `password_digest`. */
|
|
114
196
|
password_hasher?: string;
|
|
197
|
+
/** Whether to skip Clerk's password strength checks. */
|
|
115
198
|
skip_password_checks?: boolean;
|
|
199
|
+
/** Whether to allow creating the user without a password. */
|
|
116
200
|
skip_password_requirement?: boolean;
|
|
201
|
+
/** A TOTP secret to enroll the user in authenticator-app two-factor. */
|
|
117
202
|
totp_secret?: string;
|
|
203
|
+
/** Backup codes to set for the user. */
|
|
118
204
|
backup_codes?: string[];
|
|
205
|
+
/** Metadata readable from the frontend and backend, writable only from the backend. */
|
|
119
206
|
public_metadata?: Record<string, unknown>;
|
|
207
|
+
/** Metadata readable and writable only from the backend. */
|
|
120
208
|
private_metadata?: Record<string, unknown>;
|
|
209
|
+
/** Metadata that the frontend can also read and write. */
|
|
121
210
|
unsafe_metadata?: Record<string, unknown>;
|
|
211
|
+
/** The creation date to record for the user, as an ISO 8601 string. */
|
|
122
212
|
created_at?: string;
|
|
123
213
|
}
|
|
214
|
+
/** The fields accepted when updating a Clerk user; only the ones given are changed. */
|
|
124
215
|
interface UpdateClerkUserInput {
|
|
216
|
+
/** The identifier the user has in your own system. */
|
|
125
217
|
external_id?: string;
|
|
218
|
+
/** The user's first name. */
|
|
126
219
|
first_name?: string;
|
|
220
|
+
/** The user's last name. */
|
|
127
221
|
last_name?: string;
|
|
222
|
+
/** The user's username. */
|
|
128
223
|
username?: string;
|
|
224
|
+
/** The user's new password in plain text. */
|
|
129
225
|
password?: string;
|
|
226
|
+
/** The id of the email address to make primary. */
|
|
130
227
|
primary_email_address_id?: string;
|
|
228
|
+
/** Whether to notify the user when their primary email address changes. */
|
|
131
229
|
notify_primary_email_address_changed?: boolean;
|
|
230
|
+
/** The id of the phone number to make primary. */
|
|
132
231
|
primary_phone_number_id?: string;
|
|
232
|
+
/** The id of the web3 wallet to make primary. */
|
|
133
233
|
primary_web3_wallet_id?: string;
|
|
234
|
+
/** The id of the uploaded image to use as the profile image. */
|
|
134
235
|
profile_image_id?: string;
|
|
236
|
+
/** Metadata readable from the frontend and backend, writable only from the backend. */
|
|
135
237
|
public_metadata?: Record<string, unknown>;
|
|
238
|
+
/** Metadata readable and writable only from the backend. */
|
|
136
239
|
private_metadata?: Record<string, unknown>;
|
|
240
|
+
/** Metadata that the frontend can also read and write. */
|
|
137
241
|
unsafe_metadata?: Record<string, unknown>;
|
|
242
|
+
/** A TOTP secret to enroll the user in authenticator-app two-factor. */
|
|
138
243
|
totp_secret?: string;
|
|
244
|
+
/** Backup codes to set for the user. */
|
|
139
245
|
backup_codes?: string[];
|
|
246
|
+
/** Whether the user may delete their own account. */
|
|
140
247
|
delete_self_enabled?: boolean;
|
|
248
|
+
/** Whether the user may create organizations. */
|
|
141
249
|
create_organization_enabled?: boolean;
|
|
142
250
|
}
|
|
251
|
+
/** The Svix application Clerk keeps for the instance's webhooks. */
|
|
143
252
|
interface ClerkSvixApp {
|
|
253
|
+
/** The identifier of the Svix application. */
|
|
144
254
|
svix_app_id?: string;
|
|
145
255
|
}
|
|
146
256
|
/** Older Clerk instances return `svix_url`; newer return `url`. */
|
|
147
257
|
interface ClerkSvixUrl {
|
|
258
|
+
/** The Svix dashboard URL, as returned by newer Clerk instances. */
|
|
148
259
|
url?: string;
|
|
260
|
+
/** The Svix dashboard URL, as returned by older Clerk instances. */
|
|
149
261
|
svix_url?: string;
|
|
150
262
|
}
|
|
263
|
+
/** Creates a Clerk Backend API client with `instance`, `users` and `webhooks` groups, all sharing one REST transport. */
|
|
151
264
|
export declare function createClerkClient(opts: ClerkClientOptions): {
|
|
152
265
|
instance: {
|
|
153
266
|
get: () => Promise<ClerkInstance>;
|
|
@@ -169,5 +282,6 @@ export declare function createClerkClient(opts: ClerkClientOptions): {
|
|
|
169
282
|
getSvixUrl: () => Promise<ClerkSvixUrl>;
|
|
170
283
|
};
|
|
171
284
|
};
|
|
285
|
+
/** The client returned by `createClerkClient`. */
|
|
172
286
|
export type ClerkClient = ReturnType<typeof createClerkClient>;
|
|
173
287
|
export type { ClerkClientOptions, ClerkDeletedObject, ClerkEmailAddress, ClerkInstance, ClerkPhoneNumber, ClerkSvixApp, ClerkSvixUrl, ClerkUser, ClerkUserCount, ClerkUsersListParams, CreateClerkUserInput, UpdateClerkUserInput };
|
package/dist/index.mjs
CHANGED
|
@@ -65,6 +65,7 @@ function webhooks(rest) {
|
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
// src/index.ts
|
|
68
|
+
/** Creates a Clerk Backend API client with `instance`, `users` and `webhooks` groups, all sharing one REST transport. */
|
|
68
69
|
function createClerkClient(opts) {
|
|
69
70
|
const rest = createClerkRestClient(opts);
|
|
70
71
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/clerk-client",
|
|
3
|
-
"version": "1.58.0-alpha.
|
|
3
|
+
"version": "1.58.0-alpha.4",
|
|
4
4
|
"description": "A TypeScript client for the Clerk Backend API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"clerk",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@theholocron/
|
|
36
|
-
"@theholocron/
|
|
35
|
+
"@theholocron/http-client": "^1.58.0-alpha.4",
|
|
36
|
+
"@theholocron/observability": "^0.6.1-alpha.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^26",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"tsdown": "^0.23.3",
|
|
46
46
|
"typescript": "^5.9.3",
|
|
47
47
|
"vitest": "^5.0.5",
|
|
48
|
-
"@theholocron/
|
|
49
|
-
"@theholocron/
|
|
50
|
-
"@theholocron/
|
|
51
|
-
"@theholocron/
|
|
48
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.5",
|
|
49
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.5",
|
|
50
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.5",
|
|
51
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.5"
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|
|
54
54
|
"node": ">=22.0.0"
|