@greensecurity/javascript-sdk 0.13.0 → 0.14.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/bin/mcp-server.js +6 -6
- package/bin/mcp-server.js.map +4 -4
- package/jsr.json +1 -1
- package/lib/config.d.ts +3 -3
- package/lib/config.js +3 -3
- package/mcp-server/mcp-server.js +1 -1
- package/mcp-server/server.js +1 -1
- package/package.json +5 -1
- package/src/__tests__/assertions.ts +13 -0
- package/src/__tests__/files.ts +56 -0
- package/src/__tests__/organizations.test.ts +248 -0
- package/src/__tests__/testclient.ts +48 -0
- package/src/__tests__/user.test.ts +212 -0
- package/src/__tests__/vendors.test.ts +69 -0
- package/src/lib/config.ts +3 -3
- package/src/mcp-server/mcp-server.ts +1 -1
- package/src/mcp-server/server.ts +1 -1
- package/src/vitest.config.js +0 -5
- package/vitest.config.d.ts +0 -7
- package/vitest.config.d.ts.map +0 -1
- package/vitest.config.js +0 -8
- package/vitest.config.js.map +0 -1
package/jsr.json
CHANGED
package/lib/config.d.ts
CHANGED
|
@@ -31,8 +31,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
|
|
|
31
31
|
export declare const SDK_METADATA: {
|
|
32
32
|
readonly language: "typescript";
|
|
33
33
|
readonly openapiDocVersion: "0.0.3";
|
|
34
|
-
readonly sdkVersion: "0.
|
|
35
|
-
readonly genVersion: "2.
|
|
36
|
-
readonly userAgent: "speakeasy-sdk/typescript 0.
|
|
34
|
+
readonly sdkVersion: "0.14.0";
|
|
35
|
+
readonly genVersion: "2.536.0";
|
|
36
|
+
readonly userAgent: "speakeasy-sdk/typescript 0.14.0 2.536.0 0.0.3 @greensecurity/javascript-sdk";
|
|
37
37
|
};
|
|
38
38
|
//# sourceMappingURL=config.d.ts.map
|
package/lib/config.js
CHANGED
|
@@ -39,8 +39,8 @@ function serverURLFromOptions(options) {
|
|
|
39
39
|
exports.SDK_METADATA = {
|
|
40
40
|
language: "typescript",
|
|
41
41
|
openapiDocVersion: "0.0.3",
|
|
42
|
-
sdkVersion: "0.
|
|
43
|
-
genVersion: "2.
|
|
44
|
-
userAgent: "speakeasy-sdk/typescript 0.
|
|
42
|
+
sdkVersion: "0.14.0",
|
|
43
|
+
genVersion: "2.536.0",
|
|
44
|
+
userAgent: "speakeasy-sdk/typescript 0.14.0 2.536.0 0.0.3 @greensecurity/javascript-sdk",
|
|
45
45
|
};
|
|
46
46
|
//# sourceMappingURL=config.js.map
|
package/mcp-server/mcp-server.js
CHANGED
|
@@ -22,7 +22,7 @@ const routes = (0, core_1.buildRouteMap)({
|
|
|
22
22
|
exports.app = (0, core_1.buildApplication)(routes, {
|
|
23
23
|
name: "mcp",
|
|
24
24
|
versionInfo: {
|
|
25
|
-
currentVersion: "0.
|
|
25
|
+
currentVersion: "0.14.0",
|
|
26
26
|
},
|
|
27
27
|
});
|
|
28
28
|
(0, core_1.run)(exports.app, node_process_1.default.argv.slice(2), (0, cli_js_1.buildContext)(node_process_1.default));
|
package/mcp-server/server.js
CHANGED
|
@@ -21,7 +21,7 @@ const vendorsListVendorJobTitles_js_1 = require("./tools/vendorsListVendorJobTit
|
|
|
21
21
|
function createMCPServer(deps) {
|
|
22
22
|
const server = new mcp_js_1.McpServer({
|
|
23
23
|
name: "GreenSecurity",
|
|
24
|
-
version: "0.
|
|
24
|
+
version: "0.14.0",
|
|
25
25
|
});
|
|
26
26
|
const client = new core_js_1.GreenSecurityCore({
|
|
27
27
|
security: deps.security,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@greensecurity/javascript-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"author": "Green Security LLC",
|
|
5
5
|
"bin": {
|
|
6
6
|
"mcp": "bin/mcp-server.js"
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
"directory": "api-docs-sdks"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
|
+
"test": "vitest run src --reporter=junit --outputFile=.speakeasy/reports/tests.xml --reporter=default",
|
|
17
|
+
"check": "npm run test && npm run lint",
|
|
16
18
|
"lint": "eslint --cache --max-warnings=0 src",
|
|
17
19
|
"build:mcp": "bun src/mcp-server/build.mts",
|
|
18
20
|
"build": "npm run build:mcp && tsc",
|
|
@@ -37,6 +39,7 @@
|
|
|
37
39
|
"@stricli/core": "^1.1.1",
|
|
38
40
|
"@tanstack/react-query": "^5.61.4",
|
|
39
41
|
"@types/express": "^4.17.21",
|
|
42
|
+
"@types/node": "^18.19.3",
|
|
40
43
|
"@types/react": "^18.3.12",
|
|
41
44
|
"bun": "^1.2.2",
|
|
42
45
|
"bun-types": "^1.2.2",
|
|
@@ -45,6 +48,7 @@
|
|
|
45
48
|
"globals": "^15.14.0",
|
|
46
49
|
"typescript": "^5.4.5",
|
|
47
50
|
"typescript-eslint": "^8.22.0",
|
|
51
|
+
"vitest": "^3.0.2",
|
|
48
52
|
"zod": "^3.23.4"
|
|
49
53
|
},
|
|
50
54
|
"dependencies": {
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { createReadStream } from "node:fs";
|
|
6
|
+
import { readFile } from "node:fs/promises";
|
|
7
|
+
import { Readable } from "node:stream";
|
|
8
|
+
|
|
9
|
+
export function filesToStream(filePath: string): ReadableStream<Uint8Array> {
|
|
10
|
+
return Readable.toWeb(
|
|
11
|
+
createReadStream(filePath),
|
|
12
|
+
) as unknown as ReadableStream<Uint8Array>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function filesToByteArray(filePath: string): Promise<Uint8Array> {
|
|
16
|
+
return new Uint8Array(await readFile(filePath));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export async function filesToString(filePath: string): Promise<string> {
|
|
20
|
+
return readFile(filePath, "utf8");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function streamToByteArray(
|
|
24
|
+
stream?: ReadableStream<Uint8Array>,
|
|
25
|
+
): Promise<Buffer> {
|
|
26
|
+
if (!stream) {
|
|
27
|
+
return Buffer.from("");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const chunks = [];
|
|
31
|
+
const reader = stream.getReader();
|
|
32
|
+
|
|
33
|
+
let done = false;
|
|
34
|
+
while (!done) {
|
|
35
|
+
const res = await reader.read();
|
|
36
|
+
done = res.done;
|
|
37
|
+
if (res.value) {
|
|
38
|
+
chunks.push(res.value);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return Buffer.concat(chunks);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function bytesToStream(bytes: Uint8Array): ReadableStream<Uint8Array> {
|
|
46
|
+
return new ReadableStream({
|
|
47
|
+
start(controller) {
|
|
48
|
+
controller.enqueue(bytes);
|
|
49
|
+
},
|
|
50
|
+
pull(controller) {
|
|
51
|
+
controller.close();
|
|
52
|
+
},
|
|
53
|
+
cancel() {
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { expect, test } from "vitest";
|
|
6
|
+
import { GreenSecurity } from "../index.js";
|
|
7
|
+
import { createTestHTTPClient } from "./testclient.js";
|
|
8
|
+
|
|
9
|
+
test("Organizations List Or Search Facilities", async () => {
|
|
10
|
+
const testHttpClient = createTestHTTPClient("listOrSearchFacilities");
|
|
11
|
+
|
|
12
|
+
const greenSecurity = new GreenSecurity({
|
|
13
|
+
serverURL: "https://dev.repconnex.com:3000/api",
|
|
14
|
+
security: {
|
|
15
|
+
bearerJwt: "",
|
|
16
|
+
},
|
|
17
|
+
httpClient: testHttpClient,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const result = await greenSecurity.organizations.listOrSearchFacilities({
|
|
21
|
+
sort: "job",
|
|
22
|
+
desc: true,
|
|
23
|
+
itemsPerPage: 25,
|
|
24
|
+
expand: [
|
|
25
|
+
"facility.system",
|
|
26
|
+
],
|
|
27
|
+
});
|
|
28
|
+
expect(result).toBeDefined();
|
|
29
|
+
expect(result).toEqual({
|
|
30
|
+
pager: {
|
|
31
|
+
baseUrl: "api/vendors/job_titles",
|
|
32
|
+
sort: "job,title",
|
|
33
|
+
desc: 1,
|
|
34
|
+
itemCount: 228,
|
|
35
|
+
itemsPerPage: 513604,
|
|
36
|
+
page: 1,
|
|
37
|
+
useUrlParams: true,
|
|
38
|
+
},
|
|
39
|
+
items: [
|
|
40
|
+
{
|
|
41
|
+
contacts: {
|
|
42
|
+
contact: {
|
|
43
|
+
status: "Inactive",
|
|
44
|
+
department: {
|
|
45
|
+
id: 741158,
|
|
46
|
+
name: "<value>",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
adminContact: {
|
|
50
|
+
status: "Deleted",
|
|
51
|
+
department: 123,
|
|
52
|
+
},
|
|
53
|
+
techContact: {
|
|
54
|
+
status: "Deleted",
|
|
55
|
+
department: 123,
|
|
56
|
+
},
|
|
57
|
+
greenSecurityCsm: {
|
|
58
|
+
status: "Inactive",
|
|
59
|
+
department: 123,
|
|
60
|
+
},
|
|
61
|
+
accountManager: {
|
|
62
|
+
status: "Active",
|
|
63
|
+
department: {
|
|
64
|
+
id: 602669,
|
|
65
|
+
name: "<value>",
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
imageUrls: {
|
|
70
|
+
tiny:
|
|
71
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_tiny.jpeg?1538765266",
|
|
72
|
+
thumb:
|
|
73
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_thumb.jpeg?1538765266",
|
|
74
|
+
large:
|
|
75
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_large.jpeg?1538765266",
|
|
76
|
+
original:
|
|
77
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_original.jpeg?1538765266",
|
|
78
|
+
},
|
|
79
|
+
vendorGuestPolicy: {
|
|
80
|
+
enabled: true,
|
|
81
|
+
vendorGuestLimitAndOr: "and",
|
|
82
|
+
vendorGuestRequireEmail: true,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
contacts: {
|
|
87
|
+
contact: {
|
|
88
|
+
status: "Deleted",
|
|
89
|
+
department: 123,
|
|
90
|
+
},
|
|
91
|
+
adminContact: {
|
|
92
|
+
status: "Inactive",
|
|
93
|
+
department: {
|
|
94
|
+
id: 295998,
|
|
95
|
+
name: "<value>",
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
techContact: {
|
|
99
|
+
status: "Inactive",
|
|
100
|
+
department: {
|
|
101
|
+
id: 344138,
|
|
102
|
+
name: "<value>",
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
greenSecurityCsm: {
|
|
106
|
+
status: "Inactive",
|
|
107
|
+
department: {
|
|
108
|
+
id: 499522,
|
|
109
|
+
name: "<value>",
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
accountManager: {
|
|
113
|
+
status: "Deleted",
|
|
114
|
+
department: 123,
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
imageUrls: {
|
|
118
|
+
tiny:
|
|
119
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_tiny.jpeg?1538765266",
|
|
120
|
+
thumb:
|
|
121
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_thumb.jpeg?1538765266",
|
|
122
|
+
large:
|
|
123
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_large.jpeg?1538765266",
|
|
124
|
+
original:
|
|
125
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_original.jpeg?1538765266",
|
|
126
|
+
},
|
|
127
|
+
vendorGuestPolicy: {
|
|
128
|
+
enabled: true,
|
|
129
|
+
vendorGuestLimitAndOr: "and",
|
|
130
|
+
vendorGuestRequireEmail: false,
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
contacts: {
|
|
135
|
+
contact: {
|
|
136
|
+
status: "Active",
|
|
137
|
+
department: {
|
|
138
|
+
id: 674036,
|
|
139
|
+
name: "<value>",
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
adminContact: {
|
|
143
|
+
status: "Deleted",
|
|
144
|
+
department: 123,
|
|
145
|
+
},
|
|
146
|
+
techContact: {
|
|
147
|
+
status: "Inactive",
|
|
148
|
+
department: {
|
|
149
|
+
id: 800811,
|
|
150
|
+
name: "<value>",
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
greenSecurityCsm: {
|
|
154
|
+
status: "Inactive",
|
|
155
|
+
department: 123,
|
|
156
|
+
},
|
|
157
|
+
accountManager: {
|
|
158
|
+
status: "Inactive",
|
|
159
|
+
department: {
|
|
160
|
+
id: 603414,
|
|
161
|
+
name: "<value>",
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
imageUrls: {
|
|
166
|
+
tiny:
|
|
167
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_tiny.jpeg?1538765266",
|
|
168
|
+
thumb:
|
|
169
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_thumb.jpeg?1538765266",
|
|
170
|
+
large:
|
|
171
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_large.jpeg?1538765266",
|
|
172
|
+
original:
|
|
173
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_original.jpeg?1538765266",
|
|
174
|
+
},
|
|
175
|
+
vendorGuestPolicy: {
|
|
176
|
+
enabled: true,
|
|
177
|
+
vendorGuestLimitAndOr: "and",
|
|
178
|
+
vendorGuestRequireEmail: true,
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
test("Organizations Get Facility", async () => {
|
|
186
|
+
const testHttpClient = createTestHTTPClient("getFacility");
|
|
187
|
+
|
|
188
|
+
const greenSecurity = new GreenSecurity({
|
|
189
|
+
serverURL: "https://dev.repconnex.com:3000/api",
|
|
190
|
+
security: {
|
|
191
|
+
bearerJwt: "",
|
|
192
|
+
},
|
|
193
|
+
httpClient: testHttpClient,
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
const result = await greenSecurity.organizations.getFacility({
|
|
197
|
+
id: 924512,
|
|
198
|
+
});
|
|
199
|
+
expect(result).toBeDefined();
|
|
200
|
+
expect(result).toEqual({
|
|
201
|
+
contacts: {
|
|
202
|
+
contact: {
|
|
203
|
+
status: "Inactive",
|
|
204
|
+
department: 123,
|
|
205
|
+
},
|
|
206
|
+
adminContact: {
|
|
207
|
+
status: "Deleted",
|
|
208
|
+
department: {
|
|
209
|
+
id: 97343,
|
|
210
|
+
name: "<value>",
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
techContact: {
|
|
214
|
+
status: "Deleted",
|
|
215
|
+
department: {
|
|
216
|
+
id: 790655,
|
|
217
|
+
name: "<value>",
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
greenSecurityCsm: {
|
|
221
|
+
status: "Deleted",
|
|
222
|
+
department: 123,
|
|
223
|
+
},
|
|
224
|
+
accountManager: {
|
|
225
|
+
status: "Inactive",
|
|
226
|
+
department: {
|
|
227
|
+
id: 976324,
|
|
228
|
+
name: "<value>",
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
imageUrls: {
|
|
233
|
+
tiny:
|
|
234
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_tiny.jpeg?1538765266",
|
|
235
|
+
thumb:
|
|
236
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_thumb.jpeg?1538765266",
|
|
237
|
+
large:
|
|
238
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_large.jpeg?1538765266",
|
|
239
|
+
original:
|
|
240
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_original.jpeg?1538765266",
|
|
241
|
+
},
|
|
242
|
+
vendorGuestPolicy: {
|
|
243
|
+
enabled: true,
|
|
244
|
+
vendorGuestLimitAndOr: "and",
|
|
245
|
+
vendorGuestRequireEmail: true,
|
|
246
|
+
},
|
|
247
|
+
});
|
|
248
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { getRandomValues } from "crypto";
|
|
6
|
+
import { HTTPClient } from "../lib/http.js";
|
|
7
|
+
|
|
8
|
+
export function createTestHTTPClient(testName: string): HTTPClient {
|
|
9
|
+
const httpClient = new HTTPClient({
|
|
10
|
+
fetcher: (request: URL | RequestInfo) => {
|
|
11
|
+
return fetch(request);
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const testInstanceId = genTestId();
|
|
16
|
+
|
|
17
|
+
httpClient.addHook("beforeRequest", (request: Request) => {
|
|
18
|
+
const nextRequest = new Request(request, {
|
|
19
|
+
signal: request.signal || AbortSignal.timeout(5000),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
nextRequest.headers.set("x-speakeasy-test-name", testName);
|
|
23
|
+
nextRequest.headers.set("x-speakeasy-test-instance-id", testInstanceId);
|
|
24
|
+
|
|
25
|
+
return nextRequest;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return httpClient;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function genTestId(): string {
|
|
32
|
+
const b = new Uint8Array(16);
|
|
33
|
+
getRandomValues(b);
|
|
34
|
+
|
|
35
|
+
return `${buf2hex(b.slice(0, 4))}-${buf2hex(b.slice(4, 6))}-${
|
|
36
|
+
buf2hex(
|
|
37
|
+
b.slice(6, 8),
|
|
38
|
+
)
|
|
39
|
+
}-${buf2hex(b.slice(8, 10))}-${buf2hex(b.slice(10))}`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Helper function to convert buffer to hex string
|
|
43
|
+
function buf2hex(buffer: Uint8Array): string {
|
|
44
|
+
return [...buffer]
|
|
45
|
+
.map((x) => x.toString(16).padStart(2, "0"))
|
|
46
|
+
.join("")
|
|
47
|
+
.toUpperCase();
|
|
48
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { expect, test } from "vitest";
|
|
6
|
+
import { GreenSecurity } from "../index.js";
|
|
7
|
+
import { createTestHTTPClient } from "./testclient.js";
|
|
8
|
+
|
|
9
|
+
test("User Get User By Id", async () => {
|
|
10
|
+
const testHttpClient = createTestHTTPClient("getUserById");
|
|
11
|
+
|
|
12
|
+
const greenSecurity = new GreenSecurity({
|
|
13
|
+
serverURL: "https://dev.repconnex.com:3000/api",
|
|
14
|
+
security: {
|
|
15
|
+
bearerJwt: "",
|
|
16
|
+
},
|
|
17
|
+
httpClient: testHttpClient,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const result = await greenSecurity.user.getUserById({
|
|
21
|
+
id: 13226,
|
|
22
|
+
});
|
|
23
|
+
expect(result).toBeDefined();
|
|
24
|
+
expect(result).toEqual({
|
|
25
|
+
isGatekeeper: false,
|
|
26
|
+
success: true,
|
|
27
|
+
user: {
|
|
28
|
+
id: 13226,
|
|
29
|
+
firstName: "testFirstName",
|
|
30
|
+
lastName: "testLastName",
|
|
31
|
+
email: "testemail@test.com",
|
|
32
|
+
phone: "112233445566",
|
|
33
|
+
userType: "Vendor",
|
|
34
|
+
timezone: "Eastern Time (US & Canada)",
|
|
35
|
+
imageUrls: {
|
|
36
|
+
tiny: "",
|
|
37
|
+
thumb: "",
|
|
38
|
+
large: "",
|
|
39
|
+
original: "",
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
userToken: {
|
|
43
|
+
token: "",
|
|
44
|
+
tokenType: "permanent",
|
|
45
|
+
},
|
|
46
|
+
contact: {
|
|
47
|
+
status: "Deleted",
|
|
48
|
+
department: {
|
|
49
|
+
id: 112233,
|
|
50
|
+
name: "<value>",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("User Get Current User", async () => {
|
|
57
|
+
const testHttpClient = createTestHTTPClient("getCurrentUser");
|
|
58
|
+
|
|
59
|
+
const greenSecurity = new GreenSecurity({
|
|
60
|
+
serverURL: "https://dev.repconnex.com:3000/api",
|
|
61
|
+
security: {
|
|
62
|
+
bearerJwt: "",
|
|
63
|
+
},
|
|
64
|
+
httpClient: testHttpClient,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const result = await greenSecurity.user.getCurrentUser();
|
|
68
|
+
expect(result).toBeDefined();
|
|
69
|
+
expect(result).toEqual({
|
|
70
|
+
isGatekeeper: false,
|
|
71
|
+
success: true,
|
|
72
|
+
user: {
|
|
73
|
+
id: 123,
|
|
74
|
+
firstName: "John",
|
|
75
|
+
lastName: "Doe",
|
|
76
|
+
email: "john@example.com",
|
|
77
|
+
phone: "5555555555",
|
|
78
|
+
userType: "Facility User",
|
|
79
|
+
timezone: "UTC",
|
|
80
|
+
imageUrls: {
|
|
81
|
+
tiny:
|
|
82
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_tiny.jpeg?1538765266",
|
|
83
|
+
thumb:
|
|
84
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_thumb.jpeg?1538765266",
|
|
85
|
+
large:
|
|
86
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_large.jpeg?1538765266",
|
|
87
|
+
original:
|
|
88
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_original.jpeg?1538765266",
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
userToken: {
|
|
92
|
+
token: "WDCINRKRKYQ3TUEUEUEHEGWN6WKXP7N12345C8CSHQVJD7D6I",
|
|
93
|
+
tokenType: "permanent",
|
|
94
|
+
},
|
|
95
|
+
contact: {
|
|
96
|
+
facility: {
|
|
97
|
+
id: 233571,
|
|
98
|
+
name: "<value>",
|
|
99
|
+
},
|
|
100
|
+
system: 141123,
|
|
101
|
+
status: "Deleted",
|
|
102
|
+
department: 123,
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test("User Logs User Into The System", async () => {
|
|
108
|
+
const testHttpClient = createTestHTTPClient("logsUserIntoTheSystem");
|
|
109
|
+
|
|
110
|
+
const greenSecurity = new GreenSecurity({
|
|
111
|
+
serverURL: "https://dev.repconnex.com:3000/api",
|
|
112
|
+
security: {
|
|
113
|
+
bearerJwt: "",
|
|
114
|
+
},
|
|
115
|
+
httpClient: testHttpClient,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const result = await greenSecurity.user.logsUserIntoTheSystem({
|
|
119
|
+
email: "user@example.com",
|
|
120
|
+
mfaCode: "123456",
|
|
121
|
+
password: "Hunter2",
|
|
122
|
+
});
|
|
123
|
+
expect(result).toBeDefined();
|
|
124
|
+
expect(result).toEqual({
|
|
125
|
+
isGatekeeper: true,
|
|
126
|
+
success: true,
|
|
127
|
+
user: {
|
|
128
|
+
id: 123,
|
|
129
|
+
firstName: "John",
|
|
130
|
+
lastName: "Doe",
|
|
131
|
+
email: "john@example.com",
|
|
132
|
+
phone: "5555555555",
|
|
133
|
+
userType: "Facility User",
|
|
134
|
+
timezone: "Pacific Time (US & Canada)",
|
|
135
|
+
imageUrls: {
|
|
136
|
+
tiny:
|
|
137
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_tiny.jpeg?1538765266",
|
|
138
|
+
thumb:
|
|
139
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_thumb.jpeg?1538765266",
|
|
140
|
+
large:
|
|
141
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_large.jpeg?1538765266",
|
|
142
|
+
original:
|
|
143
|
+
"https://d37hfq3t37fvvd.cloudfront.net/users/13226_original.jpeg?1538765266",
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
userToken: {
|
|
147
|
+
token: "WDCINRKRKYQ3TUEUEUEHEGWN6WKXP7N12345C8CSHQVJD7D6I",
|
|
148
|
+
tokenType: "permanent",
|
|
149
|
+
},
|
|
150
|
+
contact: {
|
|
151
|
+
facility: {
|
|
152
|
+
id: 128492,
|
|
153
|
+
name: "<value>",
|
|
154
|
+
},
|
|
155
|
+
system: 851061,
|
|
156
|
+
status: "Inactive",
|
|
157
|
+
department: 123,
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
test("User Magiclink", async () => {
|
|
163
|
+
const testHttpClient = createTestHTTPClient("magiclink");
|
|
164
|
+
|
|
165
|
+
const greenSecurity = new GreenSecurity({
|
|
166
|
+
serverURL: "https://dev.repconnex.com:3000/api",
|
|
167
|
+
security: {
|
|
168
|
+
bearerJwt: "",
|
|
169
|
+
},
|
|
170
|
+
httpClient: testHttpClient,
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
const result = await greenSecurity.user.magiclink({
|
|
174
|
+
email: "Ethel.Schroeder9@yahoo.com",
|
|
175
|
+
});
|
|
176
|
+
expect(result).toBeDefined();
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
test("User Password Reset Request", async () => {
|
|
180
|
+
const testHttpClient = createTestHTTPClient("passwordResetRequest");
|
|
181
|
+
|
|
182
|
+
const greenSecurity = new GreenSecurity({
|
|
183
|
+
serverURL: "https://dev.repconnex.com:3000/api",
|
|
184
|
+
security: {
|
|
185
|
+
bearerJwt: "",
|
|
186
|
+
},
|
|
187
|
+
httpClient: testHttpClient,
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
const result = await greenSecurity.user.passwordResetRequest({
|
|
191
|
+
email: "Deon76@yahoo.com",
|
|
192
|
+
});
|
|
193
|
+
expect(result).toBeDefined();
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
test("User Password", async () => {
|
|
197
|
+
const testHttpClient = createTestHTTPClient("password");
|
|
198
|
+
|
|
199
|
+
const greenSecurity = new GreenSecurity({
|
|
200
|
+
serverURL: "https://dev.repconnex.com:3000/api",
|
|
201
|
+
security: {
|
|
202
|
+
bearerJwt: "",
|
|
203
|
+
},
|
|
204
|
+
httpClient: testHttpClient,
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
const result = await greenSecurity.user.password({
|
|
208
|
+
paswordResetToken: "<value>",
|
|
209
|
+
password: "BT_1LEAfXTRpaLs",
|
|
210
|
+
});
|
|
211
|
+
expect(result).toBeDefined();
|
|
212
|
+
});
|