@workos-inc/node 6.8.0 → 7.0.0

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.
@@ -1,4 +1,5 @@
1
1
  export * from './generic-server.exception';
2
+ export * from './bad-request.exception';
2
3
  export * from './no-api-key-provided.exception';
3
4
  export * from './not-found.exception';
4
5
  export * from './oauth.exception';
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./generic-server.exception"), exports);
18
+ __exportStar(require("./bad-request.exception"), exports);
18
19
  __exportStar(require("./no-api-key-provided.exception"), exports);
19
20
  __exportStar(require("./not-found.exception"), exports);
20
21
  __exportStar(require("./oauth.exception"), exports);
@@ -0,0 +1,4 @@
1
+ export interface AppInfo {
2
+ name: string;
3
+ version: string;
4
+ }
@@ -1,6 +1,8 @@
1
+ import { AppInfo } from './app-info.interface';
1
2
  export interface WorkOSOptions {
2
3
  apiHostname?: string;
3
4
  https?: boolean;
4
5
  port?: number;
5
6
  config?: RequestInit;
7
+ appInfo?: AppInfo;
6
8
  }
@@ -128,11 +128,9 @@ describe('DirectorySync', () => {
128
128
  };
129
129
  (0, test_utils_1.fetchOnce)(directoryListResponse);
130
130
  const subject = yield workos.directorySync.listDirectories({
131
- domain: 'google.com',
132
131
  organizationId: 'org_1234',
133
132
  });
134
133
  expect((0, test_utils_1.fetchSearchParams)()).toMatchObject({
135
- domain: 'google.com',
136
134
  organization_id: 'org_1234',
137
135
  });
138
136
  expect(subject).toMatchObject({
@@ -143,9 +141,6 @@ describe('DirectorySync', () => {
143
141
  listMetadata: {},
144
142
  },
145
143
  apiCall: expect.any(Function),
146
- options: {
147
- domain: 'google.com',
148
- },
149
144
  });
150
145
  }));
151
146
  });
@@ -1,11 +1,9 @@
1
1
  import { PaginationOptions } from '../../common/interfaces/pagination-options.interface';
2
2
  export interface ListDirectoriesOptions extends PaginationOptions {
3
- domain?: string;
4
3
  organizationId?: string;
5
4
  search?: string;
6
5
  }
7
6
  export interface SerializedListDirectoriesOptions extends PaginationOptions {
8
- domain?: string;
9
7
  organization_id?: string;
10
8
  search?: string;
11
9
  }
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.serializeListDirectoriesOptions = void 0;
4
4
  const serializeListDirectoriesOptions = (options) => ({
5
- domain: options.domain,
6
5
  organization_id: options.organizationId,
7
6
  search: options.search,
8
7
  limit: options.limit,
@@ -83,18 +83,6 @@ describe('Event', () => {
83
83
  });
84
84
  }));
85
85
  });
86
- it(`requests Events`, () => __awaiter(void 0, void 0, void 0, function* () {
87
- (0, test_utils_1.fetchOnce)(eventsListResponse);
88
- const subject = yield workos.events.listEvents({
89
- rangeStart: '2020-05-05',
90
- rangeEnd: '2020-05-07',
91
- });
92
- expect(subject).toEqual({
93
- object: 'list',
94
- data: [event],
95
- listMetadata: {},
96
- });
97
- }));
98
86
  it(`requests Events with a valid event name`, () => __awaiter(void 0, void 0, void 0, function* () {
99
87
  (0, test_utils_1.fetchOnce)(eventsListResponse);
100
88
  const list = yield workos.events.listEvents({
@@ -1,13 +1,13 @@
1
1
  import { EventName } from '../../common/interfaces';
2
2
  export interface ListEventOptions {
3
- events?: EventName[];
3
+ events: EventName[];
4
4
  rangeStart?: string;
5
5
  rangeEnd?: string;
6
6
  limit?: number;
7
7
  after?: string;
8
8
  }
9
9
  export interface SerializedListEventOptions {
10
- events?: EventName[];
10
+ events: EventName[];
11
11
  range_start?: string;
12
12
  range_end?: string;
13
13
  limit?: number;
@@ -1,6 +1,8 @@
1
1
  export interface CreateUserOptions {
2
2
  email: string;
3
3
  password?: string;
4
+ passwordHash?: string;
5
+ passwordHashType?: 'bcrypt' | 'firebase-scrypt' | 'ssha';
4
6
  firstName?: string;
5
7
  lastName?: string;
6
8
  emailVerified?: boolean;
@@ -8,6 +10,8 @@ export interface CreateUserOptions {
8
10
  export interface SerializedCreateUserOptions {
9
11
  email: string;
10
12
  password?: string;
13
+ password_hash?: string;
14
+ password_hash_type?: 'bcrypt' | 'firebase-scrypt' | 'ssha';
11
15
  first_name?: string;
12
16
  last_name?: string;
13
17
  email_verified?: boolean;
@@ -1,19 +1,35 @@
1
1
  export * from './authenticate-with-magic-auth-options.interface';
2
2
  export * from './authenticate-with-password-options.interface';
3
3
  export * from './authenticate-with-code-options.interface';
4
+ export * from './authenticate-with-email-verification-options.interface';
5
+ export * from './authenticate-with-magic-auth-options.interface';
6
+ export * from './authenticate-with-options-base.interface';
7
+ export * from './authenticate-with-organization-selection.interface';
8
+ export * from './authenticate-with-password-options.interface';
4
9
  export * from './authenticate-with-refresh-token-options.interface';
5
10
  export * from './authenticate-with-totp-options.interface';
6
11
  export * from './authentication-response.interface';
7
- export * from './reset-password-options.interface';
8
- export * from './send-password-reset-email-options.interface';
12
+ export * from './create-organization-membership-options.interface';
9
13
  export * from './create-user-options.interface';
10
14
  export * from './enroll-auth-factor.interface';
11
- export * from './list-users-options.interface';
15
+ export * from './factor.interface';
16
+ export * from './impersonator.interface';
17
+ export * from './invitation.interface';
12
18
  export * from './list-auth-factors-options.interface';
19
+ export * from './list-invitations-options.interface';
20
+ export * from './list-organization-memberships-options.interface';
21
+ export * from './list-users-options.interface';
22
+ export * from './organization-membership.interface';
23
+ export * from './reset-password-options.interface';
24
+ export * from './revoke-session-options.interface';
25
+ export * from './role.interface';
26
+ export * from './send-invitation-options.interface';
13
27
  export * from './send-magic-auth-code-options.interface';
14
- export * from './send-verification-email-options';
28
+ export * from './send-password-reset-email-options.interface';
29
+ export * from './send-verification-email-options.interface';
30
+ export * from './session.interface';
31
+ export * from './update-organization-membership-options.interface';
15
32
  export * from './update-user-options.interface';
16
33
  export * from './update-user-password-options.interface';
17
34
  export * from './user.interface';
18
- export * from './session.interface';
19
35
  export * from './verify-email-options.interface';
@@ -17,19 +17,35 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./authenticate-with-magic-auth-options.interface"), exports);
18
18
  __exportStar(require("./authenticate-with-password-options.interface"), exports);
19
19
  __exportStar(require("./authenticate-with-code-options.interface"), exports);
20
+ __exportStar(require("./authenticate-with-email-verification-options.interface"), exports);
21
+ __exportStar(require("./authenticate-with-magic-auth-options.interface"), exports);
22
+ __exportStar(require("./authenticate-with-options-base.interface"), exports);
23
+ __exportStar(require("./authenticate-with-organization-selection.interface"), exports);
24
+ __exportStar(require("./authenticate-with-password-options.interface"), exports);
20
25
  __exportStar(require("./authenticate-with-refresh-token-options.interface"), exports);
21
26
  __exportStar(require("./authenticate-with-totp-options.interface"), exports);
22
27
  __exportStar(require("./authentication-response.interface"), exports);
23
- __exportStar(require("./reset-password-options.interface"), exports);
24
- __exportStar(require("./send-password-reset-email-options.interface"), exports);
28
+ __exportStar(require("./create-organization-membership-options.interface"), exports);
25
29
  __exportStar(require("./create-user-options.interface"), exports);
26
30
  __exportStar(require("./enroll-auth-factor.interface"), exports);
27
- __exportStar(require("./list-users-options.interface"), exports);
31
+ __exportStar(require("./factor.interface"), exports);
32
+ __exportStar(require("./impersonator.interface"), exports);
33
+ __exportStar(require("./invitation.interface"), exports);
28
34
  __exportStar(require("./list-auth-factors-options.interface"), exports);
35
+ __exportStar(require("./list-invitations-options.interface"), exports);
36
+ __exportStar(require("./list-organization-memberships-options.interface"), exports);
37
+ __exportStar(require("./list-users-options.interface"), exports);
38
+ __exportStar(require("./organization-membership.interface"), exports);
39
+ __exportStar(require("./reset-password-options.interface"), exports);
40
+ __exportStar(require("./revoke-session-options.interface"), exports);
41
+ __exportStar(require("./role.interface"), exports);
42
+ __exportStar(require("./send-invitation-options.interface"), exports);
29
43
  __exportStar(require("./send-magic-auth-code-options.interface"), exports);
30
- __exportStar(require("./send-verification-email-options"), exports);
44
+ __exportStar(require("./send-password-reset-email-options.interface"), exports);
45
+ __exportStar(require("./send-verification-email-options.interface"), exports);
46
+ __exportStar(require("./session.interface"), exports);
47
+ __exportStar(require("./update-organization-membership-options.interface"), exports);
31
48
  __exportStar(require("./update-user-options.interface"), exports);
32
49
  __exportStar(require("./update-user-password-options.interface"), exports);
33
50
  __exportStar(require("./user.interface"), exports);
34
- __exportStar(require("./session.interface"), exports);
35
51
  __exportStar(require("./verify-email-options.interface"), exports);
@@ -3,10 +3,12 @@ export interface SendInvitationOptions {
3
3
  organizationId?: string;
4
4
  expiresInDays?: number;
5
5
  inviterUserId?: string;
6
+ roleSlug?: string;
6
7
  }
7
8
  export interface SerializedSendInvitationOptions {
8
9
  email: string;
9
10
  organization_id?: string;
10
11
  expires_in_days?: number;
11
12
  inviter_user_id?: string;
13
+ role_slug?: string;
12
14
  }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -4,6 +4,8 @@ exports.serializeCreateUserOptions = void 0;
4
4
  const serializeCreateUserOptions = (options) => ({
5
5
  email: options.email,
6
6
  password: options.password,
7
+ password_hash: options.passwordHash,
8
+ password_hash_type: options.passwordHashType,
7
9
  first_name: options.firstName,
8
10
  last_name: options.lastName,
9
11
  email_verified: options.emailVerified,
@@ -6,5 +6,6 @@ const serializeSendInvitationOptions = (options) => ({
6
6
  organization_id: options.organizationId,
7
7
  expires_in_days: options.expiresInDays,
8
8
  inviter_user_id: options.inviterUserId,
9
+ role_slug: options.roleSlug,
9
10
  });
10
11
  exports.serializeSendInvitationOptions = serializeSendInvitationOptions;
package/lib/workos.js CHANGED
@@ -24,7 +24,7 @@ const audit_logs_1 = require("./audit-logs/audit-logs");
24
24
  const user_management_1 = require("./user-management/user-management");
25
25
  const bad_request_exception_1 = require("./common/exceptions/bad-request.exception");
26
26
  const fetch_client_1 = require("./common/utils/fetch-client");
27
- const VERSION = '6.8.0';
27
+ const VERSION = '7.0.0';
28
28
  const DEFAULT_HOSTNAME = 'api.workos.com';
29
29
  class WorkOS {
30
30
  constructor(key, options = {}) {
@@ -59,7 +59,12 @@ class WorkOS {
59
59
  if (port) {
60
60
  this.baseURL = this.baseURL + `:${port}`;
61
61
  }
62
- this.client = new fetch_client_1.FetchClient(this.baseURL, Object.assign(Object.assign({}, options.config), { headers: Object.assign(Object.assign({}, (_a = options.config) === null || _a === void 0 ? void 0 : _a.headers), { Authorization: `Bearer ${this.key}`, 'User-Agent': `workos-node/${VERSION}` }) }));
62
+ let userAgent = `workos-node/${VERSION}`;
63
+ if (options.appInfo) {
64
+ const { name, version } = options.appInfo;
65
+ userAgent += ` ${name}: ${version}`;
66
+ }
67
+ this.client = new fetch_client_1.FetchClient(this.baseURL, Object.assign(Object.assign({}, options.config), { headers: Object.assign(Object.assign({}, (_a = options.config) === null || _a === void 0 ? void 0 : _a.headers), { Authorization: `Bearer ${this.key}`, 'User-Agent': userAgent }) }));
63
68
  }
64
69
  get version() {
65
70
  return VERSION;
@@ -82,6 +82,22 @@ describe('WorkOS', () => {
82
82
  });
83
83
  }));
84
84
  });
85
+ describe('when the `appInfo` option is provided', () => {
86
+ it('applies the configuration to the fetch client user-agent', () => __awaiter(void 0, void 0, void 0, function* () {
87
+ (0, test_utils_1.fetchOnce)('{}');
88
+ const packageJson = JSON.parse(yield promises_1.default.readFile('package.json', 'utf8'));
89
+ const workos = new workos_1.WorkOS('sk_test', {
90
+ appInfo: {
91
+ name: 'fooApp',
92
+ version: '1.0.0',
93
+ },
94
+ });
95
+ yield workos.post('/somewhere', {});
96
+ expect((0, test_utils_1.fetchHeaders)()).toMatchObject({
97
+ 'User-Agent': `workos-node/${packageJson.version} fooApp: 1.0.0`,
98
+ });
99
+ }));
100
+ });
85
101
  });
86
102
  describe('version', () => {
87
103
  it('matches the version in `package.json`', () => __awaiter(void 0, void 0, void 0, function* () {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "6.8.0",
2
+ "version": "7.0.0",
3
3
  "name": "@workos-inc/node",
4
4
  "author": "WorkOS",
5
5
  "description": "A Node wrapper for the WorkOS API",
@@ -12,6 +12,10 @@
12
12
  "node": "14.21.3",
13
13
  "yarn": "1.22.19"
14
14
  },
15
+ "engines": {
16
+ "node": ">=19"
17
+ },
18
+ "engineStrict": true,
15
19
  "main": "lib/index.js",
16
20
  "typings": "lib/index.d.ts",
17
21
  "files": [
@@ -45,7 +49,7 @@
45
49
  "jest-fetch-mock": "^3.0.3",
46
50
  "prettier": "2.8.8",
47
51
  "supertest": "6.3.3",
48
- "ts-jest": "29.1.1",
52
+ "ts-jest": "29.1.2",
49
53
  "tslint": "6.1.3",
50
54
  "typescript": "5.1.6"
51
55
  }