@greensecurity/javascript-sdk 0.40.8-beta.30 → 0.40.8-beta.31

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.
Files changed (45) hide show
  1. package/.devcontainer/README.md +35 -0
  2. package/dist/commonjs/__tests__/webhooks.test.js +1 -1
  3. package/dist/commonjs/__tests__/webhooks.test.js.map +1 -1
  4. package/dist/commonjs/__tests__/zones.test.js +5 -19
  5. package/dist/commonjs/__tests__/zones.test.js.map +1 -1
  6. package/dist/commonjs/lib/config.d.ts +2 -2
  7. package/dist/commonjs/lib/config.js +2 -2
  8. package/dist/commonjs/models/components/vendor.d.ts +2 -0
  9. package/dist/commonjs/models/components/vendor.d.ts.map +1 -1
  10. package/dist/commonjs/models/components/vendor.js +4 -0
  11. package/dist/commonjs/models/components/vendor.js.map +1 -1
  12. package/dist/esm/__tests__/webhooks.test.js +1 -1
  13. package/dist/esm/__tests__/webhooks.test.js.map +1 -1
  14. package/dist/esm/__tests__/zones.test.js +5 -19
  15. package/dist/esm/__tests__/zones.test.js.map +1 -1
  16. package/dist/esm/lib/config.d.ts +2 -2
  17. package/dist/esm/lib/config.js +2 -2
  18. package/dist/esm/models/components/vendor.d.ts +2 -0
  19. package/dist/esm/models/components/vendor.d.ts.map +1 -1
  20. package/dist/esm/models/components/vendor.js +4 -0
  21. package/dist/esm/models/components/vendor.js.map +1 -1
  22. package/docs/sdks/alerts/README.md +219 -0
  23. package/docs/sdks/companies/README.md +126 -0
  24. package/docs/sdks/datarequests/README.md +302 -0
  25. package/docs/sdks/events/README.md +1126 -0
  26. package/docs/sdks/fhirconfigs/README.md +551 -0
  27. package/docs/sdks/greensecurity/README.md +14 -0
  28. package/docs/sdks/invoices/README.md +324 -0
  29. package/docs/sdks/mobiledevices/README.md +100 -0
  30. package/docs/sdks/organizations/README.md +508 -0
  31. package/docs/sdks/supportarticles/README.md +249 -0
  32. package/docs/sdks/systems/README.md +136 -0
  33. package/docs/sdks/users/README.md +831 -0
  34. package/docs/sdks/vendors/README.md +4904 -0
  35. package/docs/sdks/vendorscans/README.md +104 -0
  36. package/docs/sdks/webhooks/README.md +352 -0
  37. package/docs/sdks/zones/README.md +344 -0
  38. package/examples/README.md +31 -0
  39. package/examples/package-lock.json +1 -1
  40. package/jsr.json +1 -1
  41. package/package.json +1 -1
  42. package/src/__tests__/webhooks.test.ts +1 -1
  43. package/src/__tests__/zones.test.ts +5 -19
  44. package/src/lib/config.ts +2 -2
  45. package/src/models/components/vendor.ts +6 -0
@@ -0,0 +1,831 @@
1
+ # Users
2
+ (*users*)
3
+
4
+ ## Overview
5
+
6
+ Operations about users
7
+
8
+ ### Available Operations
9
+
10
+ * [getCurrentUser](#getcurrentuser) - Get current user
11
+ * [getUserById](#getuserbyid) - Get user by id
12
+ * [postAuthenticate](#postauthenticate) - Logs user into the system
13
+ * [rotateApiKey](#rotateapikey) - Rotate API key
14
+ * [magiclink](#magiclink) - Magic link
15
+ * [passwordResetRequest](#passwordresetrequest) - Password reset request
16
+ * [password](#password) - Password reset
17
+ * [changePassword](#changepassword) - Change password
18
+
19
+ ## getCurrentUser
20
+
21
+ Returns a user object for the user represented by the authorization token
22
+
23
+ ### Example Usage
24
+
25
+ <!-- UsageSnippet language="typescript" operationID="getCurrentUser" method="get" path="/users/me" -->
26
+ ```typescript
27
+ import { GreenSecurity } from "@greensecurity/javascript-sdk";
28
+
29
+ const greenSecurity = new GreenSecurity({
30
+ security: {
31
+ token: process.env["GREEN_SECURITY_TOKEN"] ?? "",
32
+ },
33
+ });
34
+
35
+ async function run() {
36
+ const result = await greenSecurity.users.getCurrentUser();
37
+
38
+ console.log(result);
39
+ }
40
+
41
+ run();
42
+ ```
43
+
44
+ ### Standalone function
45
+
46
+ The standalone function version of this method:
47
+
48
+ ```typescript
49
+ import { GreenSecurityCore } from "@greensecurity/javascript-sdk/core.js";
50
+ import { usersGetCurrentUser } from "@greensecurity/javascript-sdk/funcs/usersGetCurrentUser.js";
51
+
52
+ // Use `GreenSecurityCore` for best tree-shaking performance.
53
+ // You can create one instance of it to use across an application.
54
+ const greenSecurity = new GreenSecurityCore({
55
+ security: {
56
+ token: process.env["GREEN_SECURITY_TOKEN"] ?? "",
57
+ },
58
+ });
59
+
60
+ async function run() {
61
+ const res = await usersGetCurrentUser(greenSecurity);
62
+ if (res.ok) {
63
+ const { value: result } = res;
64
+ console.log(result);
65
+ } else {
66
+ console.log("usersGetCurrentUser failed:", res.error);
67
+ }
68
+ }
69
+
70
+ run();
71
+ ```
72
+
73
+ ### React hooks and utilities
74
+
75
+ This method can be used in React components through the following hooks and
76
+ associated utilities.
77
+
78
+ > Check out [this guide][hook-guide] for information about each of the utilities
79
+ > below and how to get started using React hooks.
80
+
81
+ [hook-guide]: ../../../REACT_QUERY.md
82
+
83
+ ```tsx
84
+ import {
85
+ // Query hooks for fetching data.
86
+ useUsersGetCurrentUser,
87
+ useUsersGetCurrentUserSuspense,
88
+
89
+ // Utility for prefetching data during server-side rendering and in React
90
+ // Server Components that will be immediately available to client components
91
+ // using the hooks.
92
+ prefetchUsersGetCurrentUser,
93
+
94
+ // Utility to invalidate the query cache for this query in response to
95
+ // mutations and other user actions.
96
+ invalidateAllUsersGetCurrentUser,
97
+ } from "@greensecurity/javascript-sdk/react-query/usersGetCurrentUser.js";
98
+ ```
99
+
100
+ ### Parameters
101
+
102
+ | Parameter | Type | Required | Description |
103
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
104
+ | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
105
+ | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
106
+ | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
107
+
108
+ ### Response
109
+
110
+ **Promise\<[components.User](../../models/components/user.md)\>**
111
+
112
+ ### Errors
113
+
114
+ | Error Type | Status Code | Content Type |
115
+ | ----------------------- | ----------------------- | ----------------------- |
116
+ | errors.ApiErrorResponse | 400, 401, 403, 404 | application/json |
117
+ | errors.ApiErrorResponse | 500 | application/json |
118
+ | errors.APIError | 4XX, 5XX | \*/\* |
119
+
120
+ ## getUserById
121
+
122
+ Returns a user object for the user represented by the identifier in the path.
123
+
124
+ ### Example Usage
125
+
126
+ <!-- UsageSnippet language="typescript" operationID="getUserById" method="get" path="/users/{id}" -->
127
+ ```typescript
128
+ import { GreenSecurity } from "@greensecurity/javascript-sdk";
129
+
130
+ const greenSecurity = new GreenSecurity({
131
+ security: {
132
+ token: process.env["GREEN_SECURITY_TOKEN"] ?? "",
133
+ },
134
+ });
135
+
136
+ async function run() {
137
+ const result = await greenSecurity.users.getUserById({
138
+ id: 161328,
139
+ });
140
+
141
+ console.log(result);
142
+ }
143
+
144
+ run();
145
+ ```
146
+
147
+ ### Standalone function
148
+
149
+ The standalone function version of this method:
150
+
151
+ ```typescript
152
+ import { GreenSecurityCore } from "@greensecurity/javascript-sdk/core.js";
153
+ import { usersGetUserById } from "@greensecurity/javascript-sdk/funcs/usersGetUserById.js";
154
+
155
+ // Use `GreenSecurityCore` for best tree-shaking performance.
156
+ // You can create one instance of it to use across an application.
157
+ const greenSecurity = new GreenSecurityCore({
158
+ security: {
159
+ token: process.env["GREEN_SECURITY_TOKEN"] ?? "",
160
+ },
161
+ });
162
+
163
+ async function run() {
164
+ const res = await usersGetUserById(greenSecurity, {
165
+ id: 161328,
166
+ });
167
+ if (res.ok) {
168
+ const { value: result } = res;
169
+ console.log(result);
170
+ } else {
171
+ console.log("usersGetUserById failed:", res.error);
172
+ }
173
+ }
174
+
175
+ run();
176
+ ```
177
+
178
+ ### React hooks and utilities
179
+
180
+ This method can be used in React components through the following hooks and
181
+ associated utilities.
182
+
183
+ > Check out [this guide][hook-guide] for information about each of the utilities
184
+ > below and how to get started using React hooks.
185
+
186
+ [hook-guide]: ../../../REACT_QUERY.md
187
+
188
+ ```tsx
189
+ import {
190
+ // Query hooks for fetching data.
191
+ useUsersGetUserById,
192
+ useUsersGetUserByIdSuspense,
193
+
194
+ // Utility for prefetching data during server-side rendering and in React
195
+ // Server Components that will be immediately available to client components
196
+ // using the hooks.
197
+ prefetchUsersGetUserById,
198
+
199
+ // Utilities to invalidate the query cache for this query in response to
200
+ // mutations and other user actions.
201
+ invalidateUsersGetUserById,
202
+ invalidateAllUsersGetUserById,
203
+ } from "@greensecurity/javascript-sdk/react-query/usersGetUserById.js";
204
+ ```
205
+
206
+ ### Parameters
207
+
208
+ | Parameter | Type | Required | Description |
209
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
210
+ | `request` | [operations.GetUserByIdRequest](../../models/operations/getuserbyidrequest.md) | :heavy_check_mark: | The request object to use for the request. |
211
+ | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
212
+ | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
213
+ | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
214
+
215
+ ### Response
216
+
217
+ **Promise\<[components.User](../../models/components/user.md)\>**
218
+
219
+ ### Errors
220
+
221
+ | Error Type | Status Code | Content Type |
222
+ | ----------------------- | ----------------------- | ----------------------- |
223
+ | errors.ApiErrorResponse | 400, 401, 403, 404 | application/json |
224
+ | errors.ApiErrorResponse | 500 | application/json |
225
+ | errors.APIError | 4XX, 5XX | \*/\* |
226
+
227
+ ## postAuthenticate
228
+
229
+ This endpoint allows a user to authenticate themselves and retrieve a permanent token for access.
230
+
231
+ Permanent tokens should only ever be stored in an encrypted storage because they represent a fully logged in user.
232
+
233
+ Users may log in with `email/password`, `SAML`, `magic link` or `mfa`. The application should handle all of the above as equally valid login methods.
234
+
235
+ The most common way to authenticate a user is to log in with an email and password. If the user provides valid credentials, the server will either respond with a full user object including the token.
236
+
237
+ When the user's account is protected via MFA, the server will send a 6 digit code to the user via their default MFA provider. You should collect that code and resend the email, password and mfa_code together to get a successful authentication.
238
+
239
+ The ideal flow for a login sequence is the following:
240
+
241
+ 1. Present an email address field only and allow the user to submit
242
+ 2. Send `email` and `return_url` payload to this endpoint
243
+ 3. Follow the flow based on the response `requires` field
244
+
245
+ Requires: `password`
246
+
247
+ 1. Show a password field for the user to fill out
248
+ 2. Submit the `email` and `password` to this endpoint
249
+ 3. If the response is `200`, the login is done. If the response is `201`, then check if `requires: mfa_code` is returned and show MFA flow
250
+ 4. Submit `email`, `password`, `mfa_code` to this endpoint
251
+ 5. If the response is `200`, the login is done. Otherwise, show the appropriate error to the user and go back to step 1 or 3 depending on the error.
252
+
253
+ Requires: `saml_login`
254
+
255
+ 1. [Open a browser](https://docs.expo.dev/versions/latest/sdk/webbrowser/#webbrowseropenauthsessionasyncurl-redirecturl-options) to the url returned in `sso_url`
256
+ 2. User completes sign-in using their configured SAML IdP
257
+ 3. Site redirects to your selected `return_url`
258
+ 4. The `user_token` will be appended as a query string parameter to your `return_url` - you must parse this token and store it
259
+ 5. Fetch the user object from `/users/me` using the token
260
+
261
+ ### Example Usage
262
+
263
+ <!-- UsageSnippet language="typescript" operationID="postAuthenticate" method="post" path="/users/authenticate" -->
264
+ ```typescript
265
+ import { GreenSecurity } from "@greensecurity/javascript-sdk";
266
+
267
+ const greenSecurity = new GreenSecurity();
268
+
269
+ async function run() {
270
+ const result = await greenSecurity.users.postAuthenticate({
271
+ email: "john@example.com",
272
+ returnUrl: "appid://login/callback",
273
+ });
274
+
275
+ console.log(result);
276
+ }
277
+
278
+ run();
279
+ ```
280
+
281
+ ### Standalone function
282
+
283
+ The standalone function version of this method:
284
+
285
+ ```typescript
286
+ import { GreenSecurityCore } from "@greensecurity/javascript-sdk/core.js";
287
+ import { usersPostAuthenticate } from "@greensecurity/javascript-sdk/funcs/usersPostAuthenticate.js";
288
+
289
+ // Use `GreenSecurityCore` for best tree-shaking performance.
290
+ // You can create one instance of it to use across an application.
291
+ const greenSecurity = new GreenSecurityCore();
292
+
293
+ async function run() {
294
+ const res = await usersPostAuthenticate(greenSecurity, {
295
+ email: "john@example.com",
296
+ returnUrl: "appid://login/callback",
297
+ });
298
+ if (res.ok) {
299
+ const { value: result } = res;
300
+ console.log(result);
301
+ } else {
302
+ console.log("usersPostAuthenticate failed:", res.error);
303
+ }
304
+ }
305
+
306
+ run();
307
+ ```
308
+
309
+ ### React hooks and utilities
310
+
311
+ This method can be used in React components through the following hooks and
312
+ associated utilities.
313
+
314
+ > Check out [this guide][hook-guide] for information about each of the utilities
315
+ > below and how to get started using React hooks.
316
+
317
+ [hook-guide]: ../../../REACT_QUERY.md
318
+
319
+ ```tsx
320
+ import {
321
+ // Mutation hook for triggering the API call.
322
+ useUsersPostAuthenticateMutation
323
+ } from "@greensecurity/javascript-sdk/react-query/usersPostAuthenticate.js";
324
+ ```
325
+
326
+ ### Parameters
327
+
328
+ | Parameter | Type | Required | Description |
329
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
330
+ | `request` | [operations.PostAuthenticateRequestBody](../../models/operations/postauthenticaterequestbody.md) | :heavy_check_mark: | The request object to use for the request. |
331
+ | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
332
+ | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
333
+ | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
334
+
335
+ ### Response
336
+
337
+ **Promise\<[operations.PostAuthenticateResponse](../../models/operations/postauthenticateresponse.md)\>**
338
+
339
+ ### Errors
340
+
341
+ | Error Type | Status Code | Content Type |
342
+ | ----------------------- | ----------------------- | ----------------------- |
343
+ | errors.ApiErrorResponse | 400, 401, 403, 404 | application/json |
344
+ | errors.ApiErrorResponse | 500 | application/json |
345
+ | errors.APIError | 4XX, 5XX | \*/\* |
346
+
347
+ ## rotateApiKey
348
+
349
+ Allows an API user to rotate their own API key. Note, the key rotation happens immediately so the user should be prepared to update their API key in their application for all subsequent requests.
350
+
351
+ ### Example Usage
352
+
353
+ <!-- UsageSnippet language="typescript" operationID="rotateApiKey" method="post" path="/users/api_key_rotator" -->
354
+ ```typescript
355
+ import { GreenSecurity } from "@greensecurity/javascript-sdk";
356
+
357
+ const greenSecurity = new GreenSecurity({
358
+ security: {
359
+ token: process.env["GREEN_SECURITY_TOKEN"] ?? "",
360
+ },
361
+ });
362
+
363
+ async function run() {
364
+ const result = await greenSecurity.users.rotateApiKey();
365
+
366
+ console.log(result);
367
+ }
368
+
369
+ run();
370
+ ```
371
+
372
+ ### Standalone function
373
+
374
+ The standalone function version of this method:
375
+
376
+ ```typescript
377
+ import { GreenSecurityCore } from "@greensecurity/javascript-sdk/core.js";
378
+ import { usersRotateApiKey } from "@greensecurity/javascript-sdk/funcs/usersRotateApiKey.js";
379
+
380
+ // Use `GreenSecurityCore` for best tree-shaking performance.
381
+ // You can create one instance of it to use across an application.
382
+ const greenSecurity = new GreenSecurityCore({
383
+ security: {
384
+ token: process.env["GREEN_SECURITY_TOKEN"] ?? "",
385
+ },
386
+ });
387
+
388
+ async function run() {
389
+ const res = await usersRotateApiKey(greenSecurity);
390
+ if (res.ok) {
391
+ const { value: result } = res;
392
+ console.log(result);
393
+ } else {
394
+ console.log("usersRotateApiKey failed:", res.error);
395
+ }
396
+ }
397
+
398
+ run();
399
+ ```
400
+
401
+ ### React hooks and utilities
402
+
403
+ This method can be used in React components through the following hooks and
404
+ associated utilities.
405
+
406
+ > Check out [this guide][hook-guide] for information about each of the utilities
407
+ > below and how to get started using React hooks.
408
+
409
+ [hook-guide]: ../../../REACT_QUERY.md
410
+
411
+ ```tsx
412
+ import {
413
+ // Mutation hook for triggering the API call.
414
+ useUsersRotateApiKeyMutation
415
+ } from "@greensecurity/javascript-sdk/react-query/usersRotateApiKey.js";
416
+ ```
417
+
418
+ ### Parameters
419
+
420
+ | Parameter | Type | Required | Description |
421
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
422
+ | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
423
+ | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
424
+ | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
425
+
426
+ ### Response
427
+
428
+ **Promise\<[operations.RotateApiKeyRotateApiKeyOk](../../models/operations/rotateapikeyrotateapikeyok.md)\>**
429
+
430
+ ### Errors
431
+
432
+ | Error Type | Status Code | Content Type |
433
+ | ----------------------- | ----------------------- | ----------------------- |
434
+ | errors.ApiErrorResponse | 400, 401, 403 | application/json |
435
+ | errors.ApiErrorResponse | 500 | application/json |
436
+ | errors.APIError | 4XX, 5XX | \*/\* |
437
+
438
+ ## magiclink
439
+
440
+ It sends an email with a magic link to allow the user to log in.
441
+
442
+ ### Example Usage
443
+
444
+ <!-- UsageSnippet language="typescript" operationID="magiclink" method="post" path="/users/magiclink" -->
445
+ ```typescript
446
+ import { GreenSecurity } from "@greensecurity/javascript-sdk";
447
+
448
+ const greenSecurity = new GreenSecurity({
449
+ security: {
450
+ token: process.env["GREEN_SECURITY_TOKEN"] ?? "",
451
+ },
452
+ });
453
+
454
+ async function run() {
455
+ const result = await greenSecurity.users.magiclink({
456
+ email: "Abby.Altenwerth@gmail.com",
457
+ });
458
+
459
+ console.log(result);
460
+ }
461
+
462
+ run();
463
+ ```
464
+
465
+ ### Standalone function
466
+
467
+ The standalone function version of this method:
468
+
469
+ ```typescript
470
+ import { GreenSecurityCore } from "@greensecurity/javascript-sdk/core.js";
471
+ import { usersMagiclink } from "@greensecurity/javascript-sdk/funcs/usersMagiclink.js";
472
+
473
+ // Use `GreenSecurityCore` for best tree-shaking performance.
474
+ // You can create one instance of it to use across an application.
475
+ const greenSecurity = new GreenSecurityCore({
476
+ security: {
477
+ token: process.env["GREEN_SECURITY_TOKEN"] ?? "",
478
+ },
479
+ });
480
+
481
+ async function run() {
482
+ const res = await usersMagiclink(greenSecurity, {
483
+ email: "Abby.Altenwerth@gmail.com",
484
+ });
485
+ if (res.ok) {
486
+ const { value: result } = res;
487
+ console.log(result);
488
+ } else {
489
+ console.log("usersMagiclink failed:", res.error);
490
+ }
491
+ }
492
+
493
+ run();
494
+ ```
495
+
496
+ ### React hooks and utilities
497
+
498
+ This method can be used in React components through the following hooks and
499
+ associated utilities.
500
+
501
+ > Check out [this guide][hook-guide] for information about each of the utilities
502
+ > below and how to get started using React hooks.
503
+
504
+ [hook-guide]: ../../../REACT_QUERY.md
505
+
506
+ ```tsx
507
+ import {
508
+ // Mutation hook for triggering the API call.
509
+ useUsersMagiclinkMutation
510
+ } from "@greensecurity/javascript-sdk/react-query/usersMagiclink.js";
511
+ ```
512
+
513
+ ### Parameters
514
+
515
+ | Parameter | Type | Required | Description |
516
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
517
+ | `request` | [operations.MagiclinkRequestBody](../../models/operations/magiclinkrequestbody.md) | :heavy_check_mark: | The request object to use for the request. |
518
+ | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
519
+ | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
520
+ | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
521
+
522
+ ### Response
523
+
524
+ **Promise\<[operations.MagiclinkMagiclinkOk](../../models/operations/magiclinkmagiclinkok.md)\>**
525
+
526
+ ### Errors
527
+
528
+ | Error Type | Status Code | Content Type |
529
+ | ----------------------- | ----------------------- | ----------------------- |
530
+ | errors.ApiErrorResponse | 404 | application/json |
531
+ | errors.ApiErrorResponse | 500 | application/json |
532
+ | errors.APIError | 4XX, 5XX | \*/\* |
533
+
534
+ ## passwordResetRequest
535
+
536
+ It sends an email with a link for resetting a user's password.
537
+
538
+ ### Example Usage
539
+
540
+ <!-- UsageSnippet language="typescript" operationID="passwordResetRequest" method="post" path="/users/passwordresetrequest" -->
541
+ ```typescript
542
+ import { GreenSecurity } from "@greensecurity/javascript-sdk";
543
+
544
+ const greenSecurity = new GreenSecurity({
545
+ security: {
546
+ token: process.env["GREEN_SECURITY_TOKEN"] ?? "",
547
+ },
548
+ });
549
+
550
+ async function run() {
551
+ const result = await greenSecurity.users.passwordResetRequest({
552
+ email: "Sally_Okuneva@gmail.com",
553
+ });
554
+
555
+ console.log(result);
556
+ }
557
+
558
+ run();
559
+ ```
560
+
561
+ ### Standalone function
562
+
563
+ The standalone function version of this method:
564
+
565
+ ```typescript
566
+ import { GreenSecurityCore } from "@greensecurity/javascript-sdk/core.js";
567
+ import { usersPasswordResetRequest } from "@greensecurity/javascript-sdk/funcs/usersPasswordResetRequest.js";
568
+
569
+ // Use `GreenSecurityCore` for best tree-shaking performance.
570
+ // You can create one instance of it to use across an application.
571
+ const greenSecurity = new GreenSecurityCore({
572
+ security: {
573
+ token: process.env["GREEN_SECURITY_TOKEN"] ?? "",
574
+ },
575
+ });
576
+
577
+ async function run() {
578
+ const res = await usersPasswordResetRequest(greenSecurity, {
579
+ email: "Sally_Okuneva@gmail.com",
580
+ });
581
+ if (res.ok) {
582
+ const { value: result } = res;
583
+ console.log(result);
584
+ } else {
585
+ console.log("usersPasswordResetRequest failed:", res.error);
586
+ }
587
+ }
588
+
589
+ run();
590
+ ```
591
+
592
+ ### React hooks and utilities
593
+
594
+ This method can be used in React components through the following hooks and
595
+ associated utilities.
596
+
597
+ > Check out [this guide][hook-guide] for information about each of the utilities
598
+ > below and how to get started using React hooks.
599
+
600
+ [hook-guide]: ../../../REACT_QUERY.md
601
+
602
+ ```tsx
603
+ import {
604
+ // Mutation hook for triggering the API call.
605
+ useUsersPasswordResetRequestMutation
606
+ } from "@greensecurity/javascript-sdk/react-query/usersPasswordResetRequest.js";
607
+ ```
608
+
609
+ ### Parameters
610
+
611
+ | Parameter | Type | Required | Description |
612
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
613
+ | `request` | [operations.PasswordResetRequestRequestBody](../../models/operations/passwordresetrequestrequestbody.md) | :heavy_check_mark: | The request object to use for the request. |
614
+ | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
615
+ | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
616
+ | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
617
+
618
+ ### Response
619
+
620
+ **Promise\<[operations.PasswordResetRequestPasswordResetRequestOk](../../models/operations/passwordresetrequestpasswordresetrequestok.md)\>**
621
+
622
+ ### Errors
623
+
624
+ | Error Type | Status Code | Content Type |
625
+ | ----------------------- | ----------------------- | ----------------------- |
626
+ | errors.ApiErrorResponse | 400, 404 | application/json |
627
+ | errors.ApiErrorResponse | 500 | application/json |
628
+ | errors.APIError | 4XX, 5XX | \*/\* |
629
+
630
+ ## password
631
+
632
+ Resets the a user's password using a password_reset_id that was sent to them via email.
633
+ See /users/passwordresetrequest to initiate a password reset flow.
634
+
635
+ ### Example Usage
636
+
637
+ <!-- UsageSnippet language="typescript" operationID="password" method="post" path="/users/password" -->
638
+ ```typescript
639
+ import { GreenSecurity } from "@greensecurity/javascript-sdk";
640
+
641
+ const greenSecurity = new GreenSecurity({
642
+ security: {
643
+ token: process.env["GREEN_SECURITY_TOKEN"] ?? "",
644
+ },
645
+ });
646
+
647
+ async function run() {
648
+ const result = await greenSecurity.users.password({
649
+ paswordResetToken: "<value>",
650
+ password: "4FD2iSyGM2b97CT",
651
+ });
652
+
653
+ console.log(result);
654
+ }
655
+
656
+ run();
657
+ ```
658
+
659
+ ### Standalone function
660
+
661
+ The standalone function version of this method:
662
+
663
+ ```typescript
664
+ import { GreenSecurityCore } from "@greensecurity/javascript-sdk/core.js";
665
+ import { usersPassword } from "@greensecurity/javascript-sdk/funcs/usersPassword.js";
666
+
667
+ // Use `GreenSecurityCore` for best tree-shaking performance.
668
+ // You can create one instance of it to use across an application.
669
+ const greenSecurity = new GreenSecurityCore({
670
+ security: {
671
+ token: process.env["GREEN_SECURITY_TOKEN"] ?? "",
672
+ },
673
+ });
674
+
675
+ async function run() {
676
+ const res = await usersPassword(greenSecurity, {
677
+ paswordResetToken: "<value>",
678
+ password: "4FD2iSyGM2b97CT",
679
+ });
680
+ if (res.ok) {
681
+ const { value: result } = res;
682
+ console.log(result);
683
+ } else {
684
+ console.log("usersPassword failed:", res.error);
685
+ }
686
+ }
687
+
688
+ run();
689
+ ```
690
+
691
+ ### React hooks and utilities
692
+
693
+ This method can be used in React components through the following hooks and
694
+ associated utilities.
695
+
696
+ > Check out [this guide][hook-guide] for information about each of the utilities
697
+ > below and how to get started using React hooks.
698
+
699
+ [hook-guide]: ../../../REACT_QUERY.md
700
+
701
+ ```tsx
702
+ import {
703
+ // Mutation hook for triggering the API call.
704
+ useUsersPasswordMutation
705
+ } from "@greensecurity/javascript-sdk/react-query/usersPassword.js";
706
+ ```
707
+
708
+ ### Parameters
709
+
710
+ | Parameter | Type | Required | Description |
711
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
712
+ | `request` | [operations.PasswordRequestBody](../../models/operations/passwordrequestbody.md) | :heavy_check_mark: | The request object to use for the request. |
713
+ | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
714
+ | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
715
+ | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
716
+
717
+ ### Response
718
+
719
+ **Promise\<[operations.PasswordPasswordOk](../../models/operations/passwordpasswordok.md)\>**
720
+
721
+ ### Errors
722
+
723
+ | Error Type | Status Code | Content Type |
724
+ | ----------------------- | ----------------------- | ----------------------- |
725
+ | errors.ApiErrorResponse | 400, 401, 403 | application/json |
726
+ | errors.ApiErrorResponse | 500 | application/json |
727
+ | errors.APIError | 4XX, 5XX | \*/\* |
728
+
729
+ ## changePassword
730
+
731
+ Change the user's password to the new passed as parameter
732
+
733
+ ### Example Usage
734
+
735
+ <!-- UsageSnippet language="typescript" operationID="changePassword" method="post" path="/users/{id_or_me}/password" -->
736
+ ```typescript
737
+ import { GreenSecurity } from "@greensecurity/javascript-sdk";
738
+
739
+ const greenSecurity = new GreenSecurity({
740
+ security: {
741
+ token: process.env["GREEN_SECURITY_TOKEN"] ?? "",
742
+ },
743
+ });
744
+
745
+ async function run() {
746
+ const result = await greenSecurity.users.changePassword({
747
+ idOrMe: "<value>",
748
+ requestBody: {
749
+ oldPassword: "<value>",
750
+ newPassword: "<value>",
751
+ },
752
+ });
753
+
754
+ console.log(result);
755
+ }
756
+
757
+ run();
758
+ ```
759
+
760
+ ### Standalone function
761
+
762
+ The standalone function version of this method:
763
+
764
+ ```typescript
765
+ import { GreenSecurityCore } from "@greensecurity/javascript-sdk/core.js";
766
+ import { usersChangePassword } from "@greensecurity/javascript-sdk/funcs/usersChangePassword.js";
767
+
768
+ // Use `GreenSecurityCore` for best tree-shaking performance.
769
+ // You can create one instance of it to use across an application.
770
+ const greenSecurity = new GreenSecurityCore({
771
+ security: {
772
+ token: process.env["GREEN_SECURITY_TOKEN"] ?? "",
773
+ },
774
+ });
775
+
776
+ async function run() {
777
+ const res = await usersChangePassword(greenSecurity, {
778
+ idOrMe: "<value>",
779
+ requestBody: {
780
+ oldPassword: "<value>",
781
+ newPassword: "<value>",
782
+ },
783
+ });
784
+ if (res.ok) {
785
+ const { value: result } = res;
786
+ console.log(result);
787
+ } else {
788
+ console.log("usersChangePassword failed:", res.error);
789
+ }
790
+ }
791
+
792
+ run();
793
+ ```
794
+
795
+ ### React hooks and utilities
796
+
797
+ This method can be used in React components through the following hooks and
798
+ associated utilities.
799
+
800
+ > Check out [this guide][hook-guide] for information about each of the utilities
801
+ > below and how to get started using React hooks.
802
+
803
+ [hook-guide]: ../../../REACT_QUERY.md
804
+
805
+ ```tsx
806
+ import {
807
+ // Mutation hook for triggering the API call.
808
+ useUsersChangePasswordMutation
809
+ } from "@greensecurity/javascript-sdk/react-query/usersChangePassword.js";
810
+ ```
811
+
812
+ ### Parameters
813
+
814
+ | Parameter | Type | Required | Description |
815
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
816
+ | `request` | [operations.ChangePasswordRequest](../../models/operations/changepasswordrequest.md) | :heavy_check_mark: | The request object to use for the request. |
817
+ | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
818
+ | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
819
+ | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
820
+
821
+ ### Response
822
+
823
+ **Promise\<[operations.ChangePasswordChangePasswordOk](../../models/operations/changepasswordchangepasswordok.md)\>**
824
+
825
+ ### Errors
826
+
827
+ | Error Type | Status Code | Content Type |
828
+ | ----------------------- | ----------------------- | ----------------------- |
829
+ | errors.ApiErrorResponse | 400, 401, 403 | application/json |
830
+ | errors.ApiErrorResponse | 500 | application/json |
831
+ | errors.APIError | 4XX, 5XX | \*/\* |