@workos-inc/node 2.8.1 → 2.10.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.
- package/lib/audit-logs/audit-logs.d.ts +4 -0
- package/lib/audit-logs/audit-logs.js +12 -0
- package/lib/audit-logs/audit-logs.spec.js +73 -0
- package/lib/audit-logs/interfaces/audit-log-export-options.interface.d.ts +5 -0
- package/lib/audit-logs/interfaces/audit-log-export-options.interface.js +2 -0
- package/lib/audit-logs/interfaces/audit-log-export.interface.d.ts +8 -0
- package/lib/audit-logs/interfaces/audit-log-export.interface.js +2 -0
- package/lib/audit-logs/interfaces/index.d.ts +2 -0
- package/lib/audit-logs/interfaces/index.js +16 -0
- package/lib/directory-sync/directory-sync.spec.js +2 -0
- package/lib/directory-sync/interfaces/group.interface.d.ts +1 -0
- package/lib/directory-sync/interfaces/user.interface.d.ts +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/webhooks/interfaces/webhook-directory-group.interface.d.ts +1 -0
- package/lib/workos.js +1 -1
- package/package.json +2 -2
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { WorkOS } from '../workos';
|
|
2
2
|
import { CreateAuditLogEventOptions, CreateAuditLogEventRequestOptions } from './interfaces';
|
|
3
|
+
import { AuditLogExportOptions } from './interfaces/audit-log-export-options.interface';
|
|
4
|
+
import { AuditLogExport } from './interfaces/audit-log-export.interface';
|
|
3
5
|
export declare class AuditLogs {
|
|
4
6
|
private readonly workos;
|
|
5
7
|
constructor(workos: WorkOS);
|
|
6
8
|
createEvent(organization: string, event: CreateAuditLogEventOptions, options?: CreateAuditLogEventRequestOptions): Promise<void>;
|
|
9
|
+
createExport(options: AuditLogExportOptions): Promise<AuditLogExport>;
|
|
10
|
+
getExport(auditLogExportId: string): Promise<AuditLogExport>;
|
|
7
11
|
}
|
|
@@ -22,5 +22,17 @@ class AuditLogs {
|
|
|
22
22
|
}, options);
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
+
createExport(options) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const { data } = yield this.workos.post('/audit_logs/exports', options);
|
|
28
|
+
return data;
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
getExport(auditLogExportId) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const { data } = yield this.workos.get(`/audit_logs/exports/${auditLogExportId}`);
|
|
34
|
+
return data;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
25
37
|
}
|
|
26
38
|
exports.AuditLogs = AuditLogs;
|
|
@@ -107,4 +107,77 @@ describe('AuditLogs', () => {
|
|
|
107
107
|
}));
|
|
108
108
|
});
|
|
109
109
|
});
|
|
110
|
+
describe('createExport', () => {
|
|
111
|
+
const serializeExportOptions = (options) => ({
|
|
112
|
+
organization_id: options.organization_id,
|
|
113
|
+
range_start: options.range_start.toISOString(),
|
|
114
|
+
range_end: options.range_end.toISOString(),
|
|
115
|
+
});
|
|
116
|
+
describe('when the api responds with a 201', () => {
|
|
117
|
+
it('returns `audit_log_export`', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
118
|
+
const options = {
|
|
119
|
+
organization_id: 'org_123',
|
|
120
|
+
range_start: new Date(),
|
|
121
|
+
range_end: new Date(),
|
|
122
|
+
};
|
|
123
|
+
const auditLogExport = {
|
|
124
|
+
object: 'audit_log_export',
|
|
125
|
+
id: 'audit_log_export_1234',
|
|
126
|
+
state: 'pending',
|
|
127
|
+
url: undefined,
|
|
128
|
+
created_at: new Date().toISOString(),
|
|
129
|
+
updated_at: new Date().toISOString(),
|
|
130
|
+
};
|
|
131
|
+
mock
|
|
132
|
+
.onPost('/audit_logs/exports', serializeExportOptions(options))
|
|
133
|
+
.replyOnce(201, auditLogExport);
|
|
134
|
+
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
135
|
+
yield expect(workos.auditLogs.createExport(options)).resolves.toEqual(auditLogExport);
|
|
136
|
+
}));
|
|
137
|
+
});
|
|
138
|
+
describe('when the api responds with a 401', () => {
|
|
139
|
+
it('throws an UnauthorizedException', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
140
|
+
const options = {
|
|
141
|
+
organization_id: 'org_123',
|
|
142
|
+
range_start: new Date(),
|
|
143
|
+
range_end: new Date(),
|
|
144
|
+
};
|
|
145
|
+
mock
|
|
146
|
+
.onPost('/audit_logs/exports', serializeExportOptions(options))
|
|
147
|
+
.replyOnce(401, {
|
|
148
|
+
message: 'Unauthorized',
|
|
149
|
+
}, { 'X-Request-ID': 'a-request-id' });
|
|
150
|
+
const workos = new workos_1.WorkOS('invalid apikey');
|
|
151
|
+
yield expect(workos.auditLogs.createExport(options)).rejects.toStrictEqual(new exceptions_1.UnauthorizedException('a-request-id'));
|
|
152
|
+
}));
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
describe('getExport', () => {
|
|
156
|
+
describe('when the api responds with a 201', () => {
|
|
157
|
+
it('returns `audit_log_export`', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
158
|
+
const auditLogExport = {
|
|
159
|
+
object: 'audit_log_export',
|
|
160
|
+
id: 'audit_log_export_1234',
|
|
161
|
+
state: 'pending',
|
|
162
|
+
url: undefined,
|
|
163
|
+
created_at: new Date().toISOString(),
|
|
164
|
+
updated_at: new Date().toISOString(),
|
|
165
|
+
};
|
|
166
|
+
mock
|
|
167
|
+
.onGet(`/audit_logs/exports/${auditLogExport.id}`)
|
|
168
|
+
.replyOnce(200, auditLogExport);
|
|
169
|
+
const workos = new workos_1.WorkOS('sk_test_Sz3IQjepeSWaI4cMS4ms4sMuU');
|
|
170
|
+
yield expect(workos.auditLogs.getExport(auditLogExport.id)).resolves.toEqual(auditLogExport);
|
|
171
|
+
}));
|
|
172
|
+
});
|
|
173
|
+
describe('when the api responds with a 401', () => {
|
|
174
|
+
it('throws an UnauthorizedException', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
175
|
+
mock.onGet('/audit_logs/exports/audit_log_export_1234').replyOnce(401, {
|
|
176
|
+
message: 'Unauthorized',
|
|
177
|
+
}, { 'X-Request-ID': 'a-request-id' });
|
|
178
|
+
const workos = new workos_1.WorkOS('invalid apikey');
|
|
179
|
+
yield expect(workos.auditLogs.getExport('audit_log_export_1234')).rejects.toStrictEqual(new exceptions_1.UnauthorizedException('a-request-id'));
|
|
180
|
+
}));
|
|
181
|
+
});
|
|
182
|
+
});
|
|
110
183
|
});
|
|
@@ -1,2 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./audit-log-export-options.interface"), exports);
|
|
18
|
+
__exportStar(require("./audit-log-export.interface"), exports);
|
|
@@ -35,6 +35,7 @@ describe('DirectorySync', () => {
|
|
|
35
35
|
id: 'dir_grp_123',
|
|
36
36
|
idp_id: '123',
|
|
37
37
|
directory_id: 'dir_123',
|
|
38
|
+
organization_id: 'org_123',
|
|
38
39
|
name: 'Foo Group',
|
|
39
40
|
created_at: `2021-10-27 15:21:50.640958`,
|
|
40
41
|
updated_at: '2021-10-27 15:21:50.640959',
|
|
@@ -48,6 +49,7 @@ describe('DirectorySync', () => {
|
|
|
48
49
|
custom: true,
|
|
49
50
|
},
|
|
50
51
|
directory_id: 'dir_123',
|
|
52
|
+
organization_id: 'org_123',
|
|
51
53
|
emails: [
|
|
52
54
|
{
|
|
53
55
|
primary: true,
|
|
@@ -3,6 +3,7 @@ export declare type DefaultCustomAttributes = Record<string, unknown>;
|
|
|
3
3
|
export interface User<TCustomAttributes extends object = DefaultCustomAttributes, TRawAttributes = any> {
|
|
4
4
|
id: string;
|
|
5
5
|
directory_id: string;
|
|
6
|
+
organization_id: string | null;
|
|
6
7
|
raw_attributes: TRawAttributes;
|
|
7
8
|
custom_attributes: TCustomAttributes;
|
|
8
9
|
idp_id: string;
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.WorkOS = void 0;
|
|
18
18
|
const workos_1 = require("./workos");
|
|
19
19
|
Object.defineProperty(exports, "WorkOS", { enumerable: true, get: function () { return workos_1.WorkOS; } });
|
|
20
|
+
__exportStar(require("./audit-logs/interfaces"), exports);
|
|
20
21
|
__exportStar(require("./audit-trail/interfaces"), exports);
|
|
21
22
|
__exportStar(require("./common/exceptions"), exports);
|
|
22
23
|
__exportStar(require("./common/interfaces"), exports);
|
package/lib/workos.js
CHANGED
|
@@ -25,7 +25,7 @@ const webhooks_1 = require("./webhooks/webhooks");
|
|
|
25
25
|
const mfa_1 = require("./mfa/mfa");
|
|
26
26
|
const audit_logs_1 = require("./audit-logs/audit-logs");
|
|
27
27
|
const bad_request_exception_1 = require("./common/exceptions/bad-request.exception");
|
|
28
|
-
const VERSION = '2.
|
|
28
|
+
const VERSION = '2.10.0';
|
|
29
29
|
const DEFAULT_HOSTNAME = 'api.workos.com';
|
|
30
30
|
class WorkOS {
|
|
31
31
|
constructor(key, options = {}) {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.
|
|
2
|
+
"version": "2.10.0",
|
|
3
3
|
"name": "@workos-inc/node",
|
|
4
4
|
"author": "WorkOS",
|
|
5
5
|
"description": "A Node wrapper for the WorkOS API",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/jest": "27.5.2",
|
|
43
|
-
"@types/node": "14.18.
|
|
43
|
+
"@types/node": "14.18.22",
|
|
44
44
|
"@types/pluralize": "0.0.29",
|
|
45
45
|
"axios-mock-adapter": "1.21.1",
|
|
46
46
|
"jest": "27.5.1",
|