@linagora/ldap-rest-client 1.0.2 → 1.0.3
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/README.md +47 -1
- package/dist/index.d.mts +141 -0
- package/dist/index.d.ts +141 -0
- package/dist/index.js +15 -0
- package/dist/index.mjs +15 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -66,6 +66,11 @@ client.organizations.createAdmin(orgId, { username, mail })
|
|
|
66
66
|
client.organizations.list()
|
|
67
67
|
client.organizations.get(orgId)
|
|
68
68
|
client.organizations.update(orgId, updates)
|
|
69
|
+
|
|
70
|
+
// Organization ownership management
|
|
71
|
+
client.organizations.getOwner(orgId)
|
|
72
|
+
client.organizations.setOwner(orgId, { username, mail })
|
|
73
|
+
client.organizations.transferOwnership(orgId, { newOwnerUsername })
|
|
69
74
|
```
|
|
70
75
|
|
|
71
76
|
### B2B Users (within Organizations)
|
|
@@ -75,8 +80,10 @@ client.organizations.updateUser(orgId, userId, updates)
|
|
|
75
80
|
client.organizations.disableUser(orgId, userId)
|
|
76
81
|
client.organizations.deleteUser(orgId, userId)
|
|
77
82
|
client.organizations.getUser(orgId, { by, value })
|
|
78
|
-
client.organizations.listUsers(orgId, { page, limit, status, search })
|
|
83
|
+
client.organizations.listUsers(orgId, { page, limit, status, search, sortBy, sortOrder })
|
|
79
84
|
client.organizations.checkUserAvailability(orgId, { field, value })
|
|
85
|
+
|
|
86
|
+
// User role management ('owner', 'admin', 'moderator', 'member')
|
|
80
87
|
client.organizations.changeUserRole(orgId, userId, { role })
|
|
81
88
|
```
|
|
82
89
|
|
|
@@ -91,6 +98,45 @@ client.groups.addMembers(orgId, groupId, { usernames })
|
|
|
91
98
|
client.groups.removeMember(orgId, groupId, userId)
|
|
92
99
|
```
|
|
93
100
|
|
|
101
|
+
## Configuration
|
|
102
|
+
|
|
103
|
+
### Client Options
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
const client = new LdapRestClient({
|
|
107
|
+
baseUrl: 'https://ldap-rest.example.com',
|
|
108
|
+
auth: {
|
|
109
|
+
type: 'hmac',
|
|
110
|
+
serviceId: 'my-service',
|
|
111
|
+
secret: 'your-secret-key-at-least-32-chars-long',
|
|
112
|
+
},
|
|
113
|
+
timeout: 30000, // Request timeout in milliseconds (default: 30000)
|
|
114
|
+
logger: {
|
|
115
|
+
// Optional tslog configuration for custom logging
|
|
116
|
+
minLevel: 'info',
|
|
117
|
+
},
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Authentication Types
|
|
122
|
+
|
|
123
|
+
**HMAC (Backend Services)**
|
|
124
|
+
```typescript
|
|
125
|
+
auth: {
|
|
126
|
+
type: 'hmac',
|
|
127
|
+
serviceId: 'registration-service',
|
|
128
|
+
secret: 'your-secret-key', // Minimum 32 characters recommended
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**Cookie (Browser/SSO)**
|
|
133
|
+
```typescript
|
|
134
|
+
auth: {
|
|
135
|
+
type: 'cookie', // Uses cookies set by authentication service
|
|
136
|
+
}
|
|
137
|
+
// Or omit auth entirely (defaults to cookie)
|
|
138
|
+
```
|
|
139
|
+
|
|
94
140
|
## Error Handling
|
|
95
141
|
|
|
96
142
|
```typescript
|
package/dist/index.d.mts
CHANGED
|
@@ -2,16 +2,22 @@ import { ISettingsParam, Logger } from 'tslog';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* HMAC authentication configuration for backend services
|
|
5
|
+
* Uses HMAC-SHA256 signatures as per ADR-024
|
|
5
6
|
*/
|
|
6
7
|
interface HmacAuthConfig {
|
|
8
|
+
/** Authentication type */
|
|
7
9
|
type: 'hmac';
|
|
10
|
+
/** Service identifier (e.g., 'registration-service') */
|
|
8
11
|
serviceId: string;
|
|
12
|
+
/** Shared secret key (minimum 32 characters recommended) */
|
|
9
13
|
secret: string;
|
|
10
14
|
}
|
|
11
15
|
/**
|
|
12
16
|
* SSO Cookie authentication configuration for browser requests
|
|
17
|
+
* Relies on cookies set by the authentication service
|
|
13
18
|
*/
|
|
14
19
|
interface CookieAuthConfig {
|
|
20
|
+
/** Authentication type */
|
|
15
21
|
type: 'cookie';
|
|
16
22
|
}
|
|
17
23
|
/**
|
|
@@ -22,16 +28,23 @@ type AuthConfig = HmacAuthConfig | CookieAuthConfig;
|
|
|
22
28
|
* Configuration for LDAP-REST client
|
|
23
29
|
*/
|
|
24
30
|
interface ClientConfig {
|
|
31
|
+
/** Base URL of the LDAP-REST API (e.g., 'https://ldap-rest.example.com') */
|
|
25
32
|
baseUrl: string;
|
|
33
|
+
/** Authentication configuration (defaults to cookie auth if not provided) */
|
|
26
34
|
auth?: AuthConfig;
|
|
35
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
27
36
|
timeout?: number;
|
|
37
|
+
/** tslog logger configuration for custom logging */
|
|
28
38
|
logger?: ISettingsParam<unknown>;
|
|
29
39
|
}
|
|
30
40
|
/**
|
|
31
41
|
* HTTP client configuration
|
|
42
|
+
* Subset of configuration passed to the HTTP client
|
|
32
43
|
*/
|
|
33
44
|
interface HttpConfig {
|
|
45
|
+
/** Base URL of the API */
|
|
34
46
|
baseUrl: string;
|
|
47
|
+
/** Request timeout in milliseconds */
|
|
35
48
|
timeout: number;
|
|
36
49
|
}
|
|
37
50
|
|
|
@@ -209,112 +222,236 @@ declare abstract class BaseResource {
|
|
|
209
222
|
protected buildQueryString: (params: Record<string, string | number | boolean | undefined>) => string;
|
|
210
223
|
}
|
|
211
224
|
|
|
225
|
+
/**
|
|
226
|
+
* Email address with optional type and label
|
|
227
|
+
*/
|
|
212
228
|
interface EmailAddress {
|
|
229
|
+
/** Email address */
|
|
213
230
|
address: string;
|
|
231
|
+
/** Type of email (e.g., 'work', 'personal') */
|
|
214
232
|
type?: string;
|
|
233
|
+
/** Custom label for the email */
|
|
215
234
|
label?: string;
|
|
235
|
+
/** Whether this is the primary email */
|
|
216
236
|
primary?: string;
|
|
217
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Instant messaging contact information
|
|
240
|
+
*/
|
|
218
241
|
interface InstantMessaging {
|
|
242
|
+
/** IM protocol URI (e.g., 'xmpp:user@example.com', 'skype:username') */
|
|
219
243
|
uri: string;
|
|
244
|
+
/** Protocol name (e.g., 'xmpp', 'skype', 'slack') */
|
|
220
245
|
protocol?: string;
|
|
246
|
+
/** Custom label for the IM account */
|
|
221
247
|
label?: string;
|
|
248
|
+
/** Whether this is the primary IM contact */
|
|
222
249
|
primary?: string;
|
|
223
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* Phone number with optional type and label
|
|
253
|
+
*/
|
|
224
254
|
interface PhoneNumber {
|
|
255
|
+
/** Phone number (preferably in international format, e.g., '+33612345678') */
|
|
225
256
|
number: string;
|
|
257
|
+
/** Type of phone (e.g., 'mobile', 'home', 'work', 'fax') */
|
|
226
258
|
type?: string;
|
|
259
|
+
/** Custom label for the phone number */
|
|
227
260
|
label?: string;
|
|
261
|
+
/** Whether this is the primary phone number */
|
|
228
262
|
primary?: boolean;
|
|
229
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* Extended address details for buildings and apartments
|
|
266
|
+
*/
|
|
230
267
|
interface ExtendedAddress {
|
|
268
|
+
/** Locality or neighborhood name */
|
|
231
269
|
locality?: string;
|
|
270
|
+
/** Building name or number */
|
|
232
271
|
building?: string;
|
|
272
|
+
/** Staircase identifier */
|
|
233
273
|
stairs?: string;
|
|
274
|
+
/** Floor number */
|
|
234
275
|
floor?: string;
|
|
276
|
+
/** Apartment number */
|
|
235
277
|
apartment?: string;
|
|
278
|
+
/** Entry code or access code */
|
|
236
279
|
entrycode?: string;
|
|
237
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* Geographic location with coordinates
|
|
283
|
+
*/
|
|
238
284
|
interface GeoLocation {
|
|
285
|
+
/** Geographic coordinates as [latitude, longitude] */
|
|
239
286
|
geo?: [number, number];
|
|
287
|
+
/** Category for Cozy Cloud integration */
|
|
240
288
|
cozyCategory?: string;
|
|
241
289
|
}
|
|
290
|
+
/**
|
|
291
|
+
* Physical address with comprehensive location details
|
|
292
|
+
*/
|
|
242
293
|
interface Address {
|
|
294
|
+
/** Unique identifier for the address */
|
|
243
295
|
id?: string;
|
|
296
|
+
/** Street name */
|
|
244
297
|
street?: string;
|
|
298
|
+
/** Post office box number */
|
|
245
299
|
pobox?: string;
|
|
300
|
+
/** City name */
|
|
246
301
|
city?: string;
|
|
302
|
+
/** State, province, or region */
|
|
247
303
|
region?: string;
|
|
304
|
+
/** Street number */
|
|
248
305
|
number?: string;
|
|
306
|
+
/** Postal or ZIP code */
|
|
249
307
|
code?: string;
|
|
308
|
+
/** Country name or code */
|
|
250
309
|
country?: string;
|
|
310
|
+
/** Type of address (e.g., 'home', 'work', 'billing') */
|
|
251
311
|
type?: string;
|
|
312
|
+
/** Custom label for the address */
|
|
252
313
|
label?: string;
|
|
314
|
+
/** Whether this is the primary address */
|
|
253
315
|
primary?: boolean;
|
|
316
|
+
/** Extended address details (building, floor, apartment, etc.) */
|
|
254
317
|
extendedAddress?: ExtendedAddress;
|
|
318
|
+
/** Single-line formatted address string */
|
|
255
319
|
formattedAddress?: string;
|
|
320
|
+
/** Geographic location with coordinates */
|
|
256
321
|
geo?: GeoLocation;
|
|
257
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* Structured name components for a user
|
|
325
|
+
*/
|
|
258
326
|
interface UserName {
|
|
327
|
+
/** Family name or last name */
|
|
259
328
|
familyName?: string;
|
|
329
|
+
/** Given name or first name */
|
|
260
330
|
givenName?: string;
|
|
331
|
+
/** Middle name or additional names */
|
|
261
332
|
additionalName?: string;
|
|
333
|
+
/** Name prefix (e.g., 'Dr.', 'Mr.', 'Ms.') */
|
|
262
334
|
namePrefix?: string;
|
|
335
|
+
/** Name suffix (e.g., 'Jr.', 'Sr.', 'III') */
|
|
263
336
|
nameSuffix?: string;
|
|
337
|
+
/** Surname (alternative to familyName) */
|
|
264
338
|
surname?: string;
|
|
265
339
|
}
|
|
340
|
+
/**
|
|
341
|
+
* Complete user model with all profile fields, credentials, and encryption keys
|
|
342
|
+
*/
|
|
266
343
|
interface User {
|
|
344
|
+
/** Common name (username) */
|
|
267
345
|
cn: string;
|
|
346
|
+
/** Surname or last name */
|
|
268
347
|
sn: string;
|
|
348
|
+
/** Given name or first name */
|
|
269
349
|
givenName: string;
|
|
350
|
+
/** Display name shown in UI */
|
|
270
351
|
displayName: string;
|
|
352
|
+
/** Primary email address */
|
|
271
353
|
mail: string;
|
|
354
|
+
/** Primary mobile phone number */
|
|
272
355
|
mobile: string;
|
|
356
|
+
/** Encrypted user password */
|
|
273
357
|
userPassword: string;
|
|
358
|
+
/** Scrypt parameter: block size */
|
|
274
359
|
scryptR: number;
|
|
360
|
+
/** Scrypt parameter: CPU/memory cost */
|
|
275
361
|
scryptN: number;
|
|
362
|
+
/** Scrypt parameter: parallelization */
|
|
276
363
|
scryptP: number;
|
|
364
|
+
/** Salt for password encryption */
|
|
277
365
|
scryptSalt: string;
|
|
366
|
+
/** Derived key length for scrypt */
|
|
278
367
|
scryptDKLength: number;
|
|
368
|
+
/** Number of iterations for key derivation */
|
|
279
369
|
iterations: number;
|
|
370
|
+
/** User's domain */
|
|
280
371
|
domain: string;
|
|
372
|
+
/** User's public encryption key */
|
|
281
373
|
publicKey: string;
|
|
374
|
+
/** User's private encryption key */
|
|
282
375
|
privateKey: string;
|
|
376
|
+
/** Protected encryption key */
|
|
283
377
|
protectedKey: string;
|
|
378
|
+
/** Whether two-factor authentication is enabled */
|
|
284
379
|
twoFactorEnabled?: string;
|
|
380
|
+
/** URL of user's workspace */
|
|
285
381
|
workspaceUrl?: string;
|
|
382
|
+
/** Recovery email for account recovery */
|
|
286
383
|
recoveryEmail?: string;
|
|
384
|
+
/** Timestamp when password account was locked */
|
|
287
385
|
pwdAccountLockedTime?: string;
|
|
386
|
+
/** User's role in Twake organization ('owner', 'admin', 'moderator', 'member') */
|
|
288
387
|
twakeOrganizationRole?: string;
|
|
388
|
+
/** Full name as a single string */
|
|
289
389
|
fullname?: string;
|
|
390
|
+
/** Structured name components */
|
|
290
391
|
name?: UserName;
|
|
392
|
+
/** Birthday in ISO 8601 format (YYYY-MM-DD) */
|
|
291
393
|
birthday?: string;
|
|
394
|
+
/** Gender */
|
|
292
395
|
gender?: string;
|
|
396
|
+
/** Personal note or description */
|
|
293
397
|
note?: string;
|
|
398
|
+
/** Array of email addresses */
|
|
294
399
|
email?: EmailAddress[];
|
|
400
|
+
/** Array of instant messaging contacts */
|
|
295
401
|
impp?: InstantMessaging[];
|
|
402
|
+
/** Place of birth */
|
|
296
403
|
birthplace?: string;
|
|
404
|
+
/** Job title or position */
|
|
297
405
|
jobTitle?: string;
|
|
406
|
+
/** Company or organization name */
|
|
298
407
|
company?: string;
|
|
408
|
+
/** Array of phone numbers */
|
|
299
409
|
phone?: PhoneNumber[];
|
|
410
|
+
/** Array of physical addresses */
|
|
300
411
|
address?: Address[];
|
|
301
412
|
}
|
|
413
|
+
/**
|
|
414
|
+
* User password credentials with scrypt encryption parameters
|
|
415
|
+
*/
|
|
302
416
|
interface UserCredentials {
|
|
417
|
+
/** Encrypted password */
|
|
303
418
|
userPassword: string;
|
|
419
|
+
/** Scrypt CPU/memory cost parameter (power of 2, e.g., 16384) */
|
|
304
420
|
scryptN: number;
|
|
421
|
+
/** Scrypt parallelization parameter (typically 1) */
|
|
305
422
|
scryptP: number;
|
|
423
|
+
/** Scrypt block size parameter (typically 8) */
|
|
306
424
|
scryptR: number;
|
|
425
|
+
/** Random salt for password hashing */
|
|
307
426
|
scryptSalt: string;
|
|
427
|
+
/** Derived key length in bytes (typically 32) */
|
|
308
428
|
scryptDKLength: number;
|
|
429
|
+
/** Number of PBKDF2 iterations */
|
|
309
430
|
iterations: number;
|
|
310
431
|
}
|
|
432
|
+
/**
|
|
433
|
+
* User's cryptographic keys for end-to-end encryption
|
|
434
|
+
*/
|
|
311
435
|
interface UserKeys {
|
|
436
|
+
/** User's private encryption key */
|
|
312
437
|
privateKey: string;
|
|
438
|
+
/** User's public encryption key */
|
|
313
439
|
publicKey: string;
|
|
440
|
+
/** Password-protected version of the private key */
|
|
314
441
|
protectedKey: string;
|
|
315
442
|
}
|
|
443
|
+
/**
|
|
444
|
+
* User account status
|
|
445
|
+
*/
|
|
316
446
|
type UserStatus = 'active' | 'disabled';
|
|
447
|
+
/**
|
|
448
|
+
* Fields that can be used to search for users
|
|
449
|
+
*/
|
|
317
450
|
type UserSearchField = 'username' | 'phone' | 'email' | 'recoveryEmail';
|
|
451
|
+
/**
|
|
452
|
+
* Request payload for creating a new B2C user
|
|
453
|
+
* Includes all required fields plus optional profile information
|
|
454
|
+
*/
|
|
318
455
|
interface CreateUserRequest extends UserCredentials, UserKeys {
|
|
319
456
|
cn: string;
|
|
320
457
|
uid: string;
|
|
@@ -342,6 +479,10 @@ interface CreateUserRequest extends UserCredentials, UserKeys {
|
|
|
342
479
|
phone?: PhoneNumber[];
|
|
343
480
|
address?: Address[];
|
|
344
481
|
}
|
|
482
|
+
/**
|
|
483
|
+
* Request payload for updating a user's profile
|
|
484
|
+
* All fields are optional and only provided fields will be updated
|
|
485
|
+
*/
|
|
345
486
|
interface UpdateUserRequest {
|
|
346
487
|
mobile?: string;
|
|
347
488
|
userPassword?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,16 +2,22 @@ import { ISettingsParam, Logger } from 'tslog';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* HMAC authentication configuration for backend services
|
|
5
|
+
* Uses HMAC-SHA256 signatures as per ADR-024
|
|
5
6
|
*/
|
|
6
7
|
interface HmacAuthConfig {
|
|
8
|
+
/** Authentication type */
|
|
7
9
|
type: 'hmac';
|
|
10
|
+
/** Service identifier (e.g., 'registration-service') */
|
|
8
11
|
serviceId: string;
|
|
12
|
+
/** Shared secret key (minimum 32 characters recommended) */
|
|
9
13
|
secret: string;
|
|
10
14
|
}
|
|
11
15
|
/**
|
|
12
16
|
* SSO Cookie authentication configuration for browser requests
|
|
17
|
+
* Relies on cookies set by the authentication service
|
|
13
18
|
*/
|
|
14
19
|
interface CookieAuthConfig {
|
|
20
|
+
/** Authentication type */
|
|
15
21
|
type: 'cookie';
|
|
16
22
|
}
|
|
17
23
|
/**
|
|
@@ -22,16 +28,23 @@ type AuthConfig = HmacAuthConfig | CookieAuthConfig;
|
|
|
22
28
|
* Configuration for LDAP-REST client
|
|
23
29
|
*/
|
|
24
30
|
interface ClientConfig {
|
|
31
|
+
/** Base URL of the LDAP-REST API (e.g., 'https://ldap-rest.example.com') */
|
|
25
32
|
baseUrl: string;
|
|
33
|
+
/** Authentication configuration (defaults to cookie auth if not provided) */
|
|
26
34
|
auth?: AuthConfig;
|
|
35
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
27
36
|
timeout?: number;
|
|
37
|
+
/** tslog logger configuration for custom logging */
|
|
28
38
|
logger?: ISettingsParam<unknown>;
|
|
29
39
|
}
|
|
30
40
|
/**
|
|
31
41
|
* HTTP client configuration
|
|
42
|
+
* Subset of configuration passed to the HTTP client
|
|
32
43
|
*/
|
|
33
44
|
interface HttpConfig {
|
|
45
|
+
/** Base URL of the API */
|
|
34
46
|
baseUrl: string;
|
|
47
|
+
/** Request timeout in milliseconds */
|
|
35
48
|
timeout: number;
|
|
36
49
|
}
|
|
37
50
|
|
|
@@ -209,112 +222,236 @@ declare abstract class BaseResource {
|
|
|
209
222
|
protected buildQueryString: (params: Record<string, string | number | boolean | undefined>) => string;
|
|
210
223
|
}
|
|
211
224
|
|
|
225
|
+
/**
|
|
226
|
+
* Email address with optional type and label
|
|
227
|
+
*/
|
|
212
228
|
interface EmailAddress {
|
|
229
|
+
/** Email address */
|
|
213
230
|
address: string;
|
|
231
|
+
/** Type of email (e.g., 'work', 'personal') */
|
|
214
232
|
type?: string;
|
|
233
|
+
/** Custom label for the email */
|
|
215
234
|
label?: string;
|
|
235
|
+
/** Whether this is the primary email */
|
|
216
236
|
primary?: string;
|
|
217
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Instant messaging contact information
|
|
240
|
+
*/
|
|
218
241
|
interface InstantMessaging {
|
|
242
|
+
/** IM protocol URI (e.g., 'xmpp:user@example.com', 'skype:username') */
|
|
219
243
|
uri: string;
|
|
244
|
+
/** Protocol name (e.g., 'xmpp', 'skype', 'slack') */
|
|
220
245
|
protocol?: string;
|
|
246
|
+
/** Custom label for the IM account */
|
|
221
247
|
label?: string;
|
|
248
|
+
/** Whether this is the primary IM contact */
|
|
222
249
|
primary?: string;
|
|
223
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* Phone number with optional type and label
|
|
253
|
+
*/
|
|
224
254
|
interface PhoneNumber {
|
|
255
|
+
/** Phone number (preferably in international format, e.g., '+33612345678') */
|
|
225
256
|
number: string;
|
|
257
|
+
/** Type of phone (e.g., 'mobile', 'home', 'work', 'fax') */
|
|
226
258
|
type?: string;
|
|
259
|
+
/** Custom label for the phone number */
|
|
227
260
|
label?: string;
|
|
261
|
+
/** Whether this is the primary phone number */
|
|
228
262
|
primary?: boolean;
|
|
229
263
|
}
|
|
264
|
+
/**
|
|
265
|
+
* Extended address details for buildings and apartments
|
|
266
|
+
*/
|
|
230
267
|
interface ExtendedAddress {
|
|
268
|
+
/** Locality or neighborhood name */
|
|
231
269
|
locality?: string;
|
|
270
|
+
/** Building name or number */
|
|
232
271
|
building?: string;
|
|
272
|
+
/** Staircase identifier */
|
|
233
273
|
stairs?: string;
|
|
274
|
+
/** Floor number */
|
|
234
275
|
floor?: string;
|
|
276
|
+
/** Apartment number */
|
|
235
277
|
apartment?: string;
|
|
278
|
+
/** Entry code or access code */
|
|
236
279
|
entrycode?: string;
|
|
237
280
|
}
|
|
281
|
+
/**
|
|
282
|
+
* Geographic location with coordinates
|
|
283
|
+
*/
|
|
238
284
|
interface GeoLocation {
|
|
285
|
+
/** Geographic coordinates as [latitude, longitude] */
|
|
239
286
|
geo?: [number, number];
|
|
287
|
+
/** Category for Cozy Cloud integration */
|
|
240
288
|
cozyCategory?: string;
|
|
241
289
|
}
|
|
290
|
+
/**
|
|
291
|
+
* Physical address with comprehensive location details
|
|
292
|
+
*/
|
|
242
293
|
interface Address {
|
|
294
|
+
/** Unique identifier for the address */
|
|
243
295
|
id?: string;
|
|
296
|
+
/** Street name */
|
|
244
297
|
street?: string;
|
|
298
|
+
/** Post office box number */
|
|
245
299
|
pobox?: string;
|
|
300
|
+
/** City name */
|
|
246
301
|
city?: string;
|
|
302
|
+
/** State, province, or region */
|
|
247
303
|
region?: string;
|
|
304
|
+
/** Street number */
|
|
248
305
|
number?: string;
|
|
306
|
+
/** Postal or ZIP code */
|
|
249
307
|
code?: string;
|
|
308
|
+
/** Country name or code */
|
|
250
309
|
country?: string;
|
|
310
|
+
/** Type of address (e.g., 'home', 'work', 'billing') */
|
|
251
311
|
type?: string;
|
|
312
|
+
/** Custom label for the address */
|
|
252
313
|
label?: string;
|
|
314
|
+
/** Whether this is the primary address */
|
|
253
315
|
primary?: boolean;
|
|
316
|
+
/** Extended address details (building, floor, apartment, etc.) */
|
|
254
317
|
extendedAddress?: ExtendedAddress;
|
|
318
|
+
/** Single-line formatted address string */
|
|
255
319
|
formattedAddress?: string;
|
|
320
|
+
/** Geographic location with coordinates */
|
|
256
321
|
geo?: GeoLocation;
|
|
257
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* Structured name components for a user
|
|
325
|
+
*/
|
|
258
326
|
interface UserName {
|
|
327
|
+
/** Family name or last name */
|
|
259
328
|
familyName?: string;
|
|
329
|
+
/** Given name or first name */
|
|
260
330
|
givenName?: string;
|
|
331
|
+
/** Middle name or additional names */
|
|
261
332
|
additionalName?: string;
|
|
333
|
+
/** Name prefix (e.g., 'Dr.', 'Mr.', 'Ms.') */
|
|
262
334
|
namePrefix?: string;
|
|
335
|
+
/** Name suffix (e.g., 'Jr.', 'Sr.', 'III') */
|
|
263
336
|
nameSuffix?: string;
|
|
337
|
+
/** Surname (alternative to familyName) */
|
|
264
338
|
surname?: string;
|
|
265
339
|
}
|
|
340
|
+
/**
|
|
341
|
+
* Complete user model with all profile fields, credentials, and encryption keys
|
|
342
|
+
*/
|
|
266
343
|
interface User {
|
|
344
|
+
/** Common name (username) */
|
|
267
345
|
cn: string;
|
|
346
|
+
/** Surname or last name */
|
|
268
347
|
sn: string;
|
|
348
|
+
/** Given name or first name */
|
|
269
349
|
givenName: string;
|
|
350
|
+
/** Display name shown in UI */
|
|
270
351
|
displayName: string;
|
|
352
|
+
/** Primary email address */
|
|
271
353
|
mail: string;
|
|
354
|
+
/** Primary mobile phone number */
|
|
272
355
|
mobile: string;
|
|
356
|
+
/** Encrypted user password */
|
|
273
357
|
userPassword: string;
|
|
358
|
+
/** Scrypt parameter: block size */
|
|
274
359
|
scryptR: number;
|
|
360
|
+
/** Scrypt parameter: CPU/memory cost */
|
|
275
361
|
scryptN: number;
|
|
362
|
+
/** Scrypt parameter: parallelization */
|
|
276
363
|
scryptP: number;
|
|
364
|
+
/** Salt for password encryption */
|
|
277
365
|
scryptSalt: string;
|
|
366
|
+
/** Derived key length for scrypt */
|
|
278
367
|
scryptDKLength: number;
|
|
368
|
+
/** Number of iterations for key derivation */
|
|
279
369
|
iterations: number;
|
|
370
|
+
/** User's domain */
|
|
280
371
|
domain: string;
|
|
372
|
+
/** User's public encryption key */
|
|
281
373
|
publicKey: string;
|
|
374
|
+
/** User's private encryption key */
|
|
282
375
|
privateKey: string;
|
|
376
|
+
/** Protected encryption key */
|
|
283
377
|
protectedKey: string;
|
|
378
|
+
/** Whether two-factor authentication is enabled */
|
|
284
379
|
twoFactorEnabled?: string;
|
|
380
|
+
/** URL of user's workspace */
|
|
285
381
|
workspaceUrl?: string;
|
|
382
|
+
/** Recovery email for account recovery */
|
|
286
383
|
recoveryEmail?: string;
|
|
384
|
+
/** Timestamp when password account was locked */
|
|
287
385
|
pwdAccountLockedTime?: string;
|
|
386
|
+
/** User's role in Twake organization ('owner', 'admin', 'moderator', 'member') */
|
|
288
387
|
twakeOrganizationRole?: string;
|
|
388
|
+
/** Full name as a single string */
|
|
289
389
|
fullname?: string;
|
|
390
|
+
/** Structured name components */
|
|
290
391
|
name?: UserName;
|
|
392
|
+
/** Birthday in ISO 8601 format (YYYY-MM-DD) */
|
|
291
393
|
birthday?: string;
|
|
394
|
+
/** Gender */
|
|
292
395
|
gender?: string;
|
|
396
|
+
/** Personal note or description */
|
|
293
397
|
note?: string;
|
|
398
|
+
/** Array of email addresses */
|
|
294
399
|
email?: EmailAddress[];
|
|
400
|
+
/** Array of instant messaging contacts */
|
|
295
401
|
impp?: InstantMessaging[];
|
|
402
|
+
/** Place of birth */
|
|
296
403
|
birthplace?: string;
|
|
404
|
+
/** Job title or position */
|
|
297
405
|
jobTitle?: string;
|
|
406
|
+
/** Company or organization name */
|
|
298
407
|
company?: string;
|
|
408
|
+
/** Array of phone numbers */
|
|
299
409
|
phone?: PhoneNumber[];
|
|
410
|
+
/** Array of physical addresses */
|
|
300
411
|
address?: Address[];
|
|
301
412
|
}
|
|
413
|
+
/**
|
|
414
|
+
* User password credentials with scrypt encryption parameters
|
|
415
|
+
*/
|
|
302
416
|
interface UserCredentials {
|
|
417
|
+
/** Encrypted password */
|
|
303
418
|
userPassword: string;
|
|
419
|
+
/** Scrypt CPU/memory cost parameter (power of 2, e.g., 16384) */
|
|
304
420
|
scryptN: number;
|
|
421
|
+
/** Scrypt parallelization parameter (typically 1) */
|
|
305
422
|
scryptP: number;
|
|
423
|
+
/** Scrypt block size parameter (typically 8) */
|
|
306
424
|
scryptR: number;
|
|
425
|
+
/** Random salt for password hashing */
|
|
307
426
|
scryptSalt: string;
|
|
427
|
+
/** Derived key length in bytes (typically 32) */
|
|
308
428
|
scryptDKLength: number;
|
|
429
|
+
/** Number of PBKDF2 iterations */
|
|
309
430
|
iterations: number;
|
|
310
431
|
}
|
|
432
|
+
/**
|
|
433
|
+
* User's cryptographic keys for end-to-end encryption
|
|
434
|
+
*/
|
|
311
435
|
interface UserKeys {
|
|
436
|
+
/** User's private encryption key */
|
|
312
437
|
privateKey: string;
|
|
438
|
+
/** User's public encryption key */
|
|
313
439
|
publicKey: string;
|
|
440
|
+
/** Password-protected version of the private key */
|
|
314
441
|
protectedKey: string;
|
|
315
442
|
}
|
|
443
|
+
/**
|
|
444
|
+
* User account status
|
|
445
|
+
*/
|
|
316
446
|
type UserStatus = 'active' | 'disabled';
|
|
447
|
+
/**
|
|
448
|
+
* Fields that can be used to search for users
|
|
449
|
+
*/
|
|
317
450
|
type UserSearchField = 'username' | 'phone' | 'email' | 'recoveryEmail';
|
|
451
|
+
/**
|
|
452
|
+
* Request payload for creating a new B2C user
|
|
453
|
+
* Includes all required fields plus optional profile information
|
|
454
|
+
*/
|
|
318
455
|
interface CreateUserRequest extends UserCredentials, UserKeys {
|
|
319
456
|
cn: string;
|
|
320
457
|
uid: string;
|
|
@@ -342,6 +479,10 @@ interface CreateUserRequest extends UserCredentials, UserKeys {
|
|
|
342
479
|
phone?: PhoneNumber[];
|
|
343
480
|
address?: Address[];
|
|
344
481
|
}
|
|
482
|
+
/**
|
|
483
|
+
* Request payload for updating a user's profile
|
|
484
|
+
* All fields are optional and only provided fields will be updated
|
|
485
|
+
*/
|
|
345
486
|
interface UpdateUserRequest {
|
|
346
487
|
mobile?: string;
|
|
347
488
|
userPassword?: string;
|
package/dist/index.js
CHANGED
|
@@ -38,6 +38,11 @@ module.exports = __toCommonJS(index_exports);
|
|
|
38
38
|
|
|
39
39
|
// src/config/ClientConfig.ts
|
|
40
40
|
var ConfigValidator = class {
|
|
41
|
+
/**
|
|
42
|
+
* Validates the client configuration
|
|
43
|
+
* @param {ClientConfig} config - Configuration to validate
|
|
44
|
+
* @throws {Error} If configuration is invalid
|
|
45
|
+
*/
|
|
41
46
|
static validate(config) {
|
|
42
47
|
if (!config.baseUrl || config.baseUrl.trim().length === 0) {
|
|
43
48
|
throw new Error("baseUrl is required");
|
|
@@ -64,6 +69,11 @@ var ConfigValidator = class {
|
|
|
64
69
|
throw new Error("timeout must be a positive number");
|
|
65
70
|
}
|
|
66
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Normalizes the client configuration by applying defaults
|
|
74
|
+
* @param {ClientConfig} config - Configuration to normalize
|
|
75
|
+
* @returns {NormalizedClientConfig} Normalized configuration with defaults applied
|
|
76
|
+
*/
|
|
67
77
|
static normalize(config) {
|
|
68
78
|
return {
|
|
69
79
|
baseUrl: config.baseUrl.replace(/\/$/, ""),
|
|
@@ -72,6 +82,11 @@ var ConfigValidator = class {
|
|
|
72
82
|
logger: config.logger
|
|
73
83
|
};
|
|
74
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Extracts HTTP-specific configuration from normalized config
|
|
87
|
+
* @param {NormalizedClientConfig} config - Normalized configuration
|
|
88
|
+
* @returns {HttpConfig} HTTP client configuration
|
|
89
|
+
*/
|
|
75
90
|
static toHttpConfig(config) {
|
|
76
91
|
return {
|
|
77
92
|
baseUrl: config.baseUrl,
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
// src/config/ClientConfig.ts
|
|
2
2
|
var ConfigValidator = class {
|
|
3
|
+
/**
|
|
4
|
+
* Validates the client configuration
|
|
5
|
+
* @param {ClientConfig} config - Configuration to validate
|
|
6
|
+
* @throws {Error} If configuration is invalid
|
|
7
|
+
*/
|
|
3
8
|
static validate(config) {
|
|
4
9
|
if (!config.baseUrl || config.baseUrl.trim().length === 0) {
|
|
5
10
|
throw new Error("baseUrl is required");
|
|
@@ -26,6 +31,11 @@ var ConfigValidator = class {
|
|
|
26
31
|
throw new Error("timeout must be a positive number");
|
|
27
32
|
}
|
|
28
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Normalizes the client configuration by applying defaults
|
|
36
|
+
* @param {ClientConfig} config - Configuration to normalize
|
|
37
|
+
* @returns {NormalizedClientConfig} Normalized configuration with defaults applied
|
|
38
|
+
*/
|
|
29
39
|
static normalize(config) {
|
|
30
40
|
return {
|
|
31
41
|
baseUrl: config.baseUrl.replace(/\/$/, ""),
|
|
@@ -34,6 +44,11 @@ var ConfigValidator = class {
|
|
|
34
44
|
logger: config.logger
|
|
35
45
|
};
|
|
36
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Extracts HTTP-specific configuration from normalized config
|
|
49
|
+
* @param {NormalizedClientConfig} config - Normalized configuration
|
|
50
|
+
* @returns {HttpConfig} HTTP client configuration
|
|
51
|
+
*/
|
|
37
52
|
static toHttpConfig(config) {
|
|
38
53
|
return {
|
|
39
54
|
baseUrl: config.baseUrl,
|