@workos-inc/node 5.0.1 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/common/utils/pagination.d.ts +4 -0
- package/lib/common/utils/pagination.js +23 -22
- package/lib/directory-sync/directory-sync.d.ts +2 -3
- package/lib/user-management/interfaces/authenticate-with-code-options.interface.d.ts +2 -0
- package/lib/user-management/interfaces/authenticate-with-magic-auth-options.interface.d.ts +2 -0
- package/lib/user-management/interfaces/authenticate-with-password-options.interface.d.ts +2 -0
- package/lib/user-management/serializers/authenticate-with-code-options.serializer.js +1 -0
- package/lib/user-management/serializers/authenticate-with-magic-auth-options.serializer.js +1 -0
- package/lib/user-management/serializers/authenticate-with-password-options.serializer.js +1 -0
- package/lib/workos.js +1 -1
- package/package.json +1 -1
|
@@ -11,5 +11,9 @@ export declare class AutoPaginatable<T> {
|
|
|
11
11
|
after?: string | undefined;
|
|
12
12
|
};
|
|
13
13
|
private generatePages;
|
|
14
|
+
/**
|
|
15
|
+
* Automatically paginates over the list of results, returning the complete data set.
|
|
16
|
+
* Returns the first result if `options.limit` is passed to the first request.
|
|
17
|
+
*/
|
|
14
18
|
autoPagination(): Promise<T[]>;
|
|
15
19
|
}
|
|
@@ -49,7 +49,7 @@ class AutoPaginatable {
|
|
|
49
49
|
}
|
|
50
50
|
generatePages(params) {
|
|
51
51
|
return __asyncGenerator(this, arguments, function* generatePages_1() {
|
|
52
|
-
const result = yield __await(this.apiCall(Object.assign(Object.assign({}, this.options), { after: params.after })));
|
|
52
|
+
const result = yield __await(this.apiCall(Object.assign(Object.assign({}, this.options), { limit: 100, after: params.after })));
|
|
53
53
|
yield yield __await(result.data);
|
|
54
54
|
if (result.listMetadata.after) {
|
|
55
55
|
// Delay of 4rps to respect list users rate limits
|
|
@@ -58,34 +58,35 @@ class AutoPaginatable {
|
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* Automatically paginates over the list of results, returning the complete data set.
|
|
63
|
+
* Returns the first result if `options.limit` is passed to the first request.
|
|
64
|
+
*/
|
|
61
65
|
autoPagination() {
|
|
62
66
|
var _a, e_1, _b, _c;
|
|
63
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
-
if (
|
|
65
|
-
|
|
68
|
+
if (this.options.limit) {
|
|
69
|
+
return this.data;
|
|
70
|
+
}
|
|
71
|
+
const results = [];
|
|
72
|
+
try {
|
|
73
|
+
for (var _d = true, _e = __asyncValues(this.generatePages({
|
|
66
74
|
after: this.options.after,
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
_d = false;
|
|
73
|
-
const page = _c;
|
|
74
|
-
results.push(...page);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
78
|
-
finally {
|
|
79
|
-
try {
|
|
80
|
-
if (!_d && !_a && (_b = generatePages_2.return)) yield _b.call(generatePages_2);
|
|
81
|
-
}
|
|
82
|
-
finally { if (e_1) throw e_1.error; }
|
|
75
|
+
})), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
|
|
76
|
+
_c = _f.value;
|
|
77
|
+
_d = false;
|
|
78
|
+
const page = _c;
|
|
79
|
+
results.push(...page);
|
|
83
80
|
}
|
|
84
|
-
return results;
|
|
85
81
|
}
|
|
86
|
-
|
|
87
|
-
|
|
82
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
83
|
+
finally {
|
|
84
|
+
try {
|
|
85
|
+
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
86
|
+
}
|
|
87
|
+
finally { if (e_1) throw e_1.error; }
|
|
88
88
|
}
|
|
89
|
+
return results;
|
|
89
90
|
});
|
|
90
91
|
}
|
|
91
92
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { WorkOS } from '../workos';
|
|
2
2
|
import { AutoPaginatable } from '../common/utils/pagination';
|
|
3
3
|
import { DefaultCustomAttributes, Directory, DirectoryGroup, DirectoryUserWithGroups, ListDirectoriesOptions, ListDirectoryGroupsOptions, ListDirectoryUsersOptions } from './interfaces';
|
|
4
|
-
import { List } from '../common/interfaces';
|
|
5
4
|
export declare class DirectorySync {
|
|
6
5
|
private readonly workos;
|
|
7
6
|
constructor(workos: WorkOS);
|
|
8
7
|
listDirectories(options?: ListDirectoriesOptions): Promise<AutoPaginatable<Directory>>;
|
|
9
8
|
getDirectory(id: string): Promise<Directory>;
|
|
10
9
|
deleteDirectory(id: string): Promise<void>;
|
|
11
|
-
listGroups(options: ListDirectoryGroupsOptions): Promise<
|
|
12
|
-
listUsers<TCustomAttributes extends object = DefaultCustomAttributes>(options: ListDirectoryUsersOptions): Promise<
|
|
10
|
+
listGroups(options: ListDirectoryGroupsOptions): Promise<AutoPaginatable<DirectoryGroup>>;
|
|
11
|
+
listUsers<TCustomAttributes extends object = DefaultCustomAttributes>(options: ListDirectoryUsersOptions): Promise<AutoPaginatable<DirectoryUserWithGroups<TCustomAttributes>>>;
|
|
13
12
|
getUser<TCustomAttributes extends object = DefaultCustomAttributes>(user: string): Promise<DirectoryUserWithGroups<TCustomAttributes>>;
|
|
14
13
|
getGroup(group: string): Promise<DirectoryGroup>;
|
|
15
14
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AuthenticateWithOptionsBase, SerializedAuthenticateWithOptionsBase } from './authenticate-with-options-base.interface';
|
|
2
2
|
export interface AuthenticateWithCodeOptions extends AuthenticateWithOptionsBase {
|
|
3
3
|
code: string;
|
|
4
|
+
invitationToken?: string;
|
|
4
5
|
}
|
|
5
6
|
export interface AuthenticateUserWithCodeCredentials {
|
|
6
7
|
clientSecret: string | undefined;
|
|
@@ -8,4 +9,5 @@ export interface AuthenticateUserWithCodeCredentials {
|
|
|
8
9
|
export interface SerializedAuthenticateWithCodeOptions extends SerializedAuthenticateWithOptionsBase {
|
|
9
10
|
grant_type: 'authorization_code';
|
|
10
11
|
code: string;
|
|
12
|
+
invitation_token?: string;
|
|
11
13
|
}
|
|
@@ -2,6 +2,7 @@ import { AuthenticateWithOptionsBase, SerializedAuthenticateWithOptionsBase } fr
|
|
|
2
2
|
export interface AuthenticateWithMagicAuthOptions extends AuthenticateWithOptionsBase {
|
|
3
3
|
code: string;
|
|
4
4
|
email: string;
|
|
5
|
+
invitationToken?: string;
|
|
5
6
|
linkAuthorizationCode?: string;
|
|
6
7
|
}
|
|
7
8
|
export interface AuthenticateUserWithMagicAuthCredentials {
|
|
@@ -11,5 +12,6 @@ export interface SerializedAuthenticateWithMagicAuthOptions extends SerializedAu
|
|
|
11
12
|
grant_type: 'urn:workos:oauth:grant-type:magic-auth:code';
|
|
12
13
|
code: string;
|
|
13
14
|
email: string;
|
|
15
|
+
invitation_token?: string;
|
|
14
16
|
link_authorization_code?: string;
|
|
15
17
|
}
|
|
@@ -2,6 +2,7 @@ import { AuthenticateWithOptionsBase, SerializedAuthenticateWithOptionsBase } fr
|
|
|
2
2
|
export interface AuthenticateWithPasswordOptions extends AuthenticateWithOptionsBase {
|
|
3
3
|
email: string;
|
|
4
4
|
password: string;
|
|
5
|
+
invitationToken?: string;
|
|
5
6
|
}
|
|
6
7
|
export interface AuthenticateUserWithPasswordCredentials {
|
|
7
8
|
clientSecret: string | undefined;
|
|
@@ -10,4 +11,5 @@ export interface SerializedAuthenticateWithPasswordOptions extends SerializedAut
|
|
|
10
11
|
grant_type: 'password';
|
|
11
12
|
email: string;
|
|
12
13
|
password: string;
|
|
14
|
+
invitation_token?: string;
|
|
13
15
|
}
|
|
@@ -6,6 +6,7 @@ const serializeAuthenticateWithCodeOptions = (options) => ({
|
|
|
6
6
|
client_id: options.clientId,
|
|
7
7
|
client_secret: options.clientSecret,
|
|
8
8
|
code: options.code,
|
|
9
|
+
invitation_token: options.invitationToken,
|
|
9
10
|
ip_address: options.ipAddress,
|
|
10
11
|
user_agent: options.userAgent,
|
|
11
12
|
});
|
|
@@ -7,6 +7,7 @@ const serializeAuthenticateWithMagicAuthOptions = (options) => ({
|
|
|
7
7
|
client_secret: options.clientSecret,
|
|
8
8
|
code: options.code,
|
|
9
9
|
email: options.email,
|
|
10
|
+
invitation_token: options.invitationToken,
|
|
10
11
|
link_authorization_code: options.linkAuthorizationCode,
|
|
11
12
|
ip_address: options.ipAddress,
|
|
12
13
|
user_agent: options.userAgent,
|
|
@@ -7,6 +7,7 @@ const serializeAuthenticateWithPasswordOptions = (options) => ({
|
|
|
7
7
|
client_secret: options.clientSecret,
|
|
8
8
|
email: options.email,
|
|
9
9
|
password: options.password,
|
|
10
|
+
invitation_token: options.invitationToken,
|
|
10
11
|
ip_address: options.ipAddress,
|
|
11
12
|
user_agent: options.userAgent,
|
|
12
13
|
});
|
package/lib/workos.js
CHANGED
|
@@ -27,7 +27,7 @@ const mfa_1 = require("./mfa/mfa");
|
|
|
27
27
|
const audit_logs_1 = require("./audit-logs/audit-logs");
|
|
28
28
|
const user_management_1 = require("./user-management/user-management");
|
|
29
29
|
const bad_request_exception_1 = require("./common/exceptions/bad-request.exception");
|
|
30
|
-
const VERSION = '5.
|
|
30
|
+
const VERSION = '5.1.1';
|
|
31
31
|
const DEFAULT_HOSTNAME = 'api.workos.com';
|
|
32
32
|
class WorkOS {
|
|
33
33
|
constructor(key, options = {}) {
|
package/package.json
CHANGED