@greensecurity/javascript-sdk 0.9.1 → 0.10.2

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 (115) hide show
  1. package/README.md +14 -5
  2. package/funcs/organizationsGetFacility.d.ts +2 -1
  3. package/funcs/organizationsGetFacility.d.ts.map +1 -1
  4. package/funcs/organizationsGetFacility.js +11 -7
  5. package/funcs/organizationsGetFacility.js.map +1 -1
  6. package/funcs/organizationsListOrSearchFacilities.d.ts +2 -1
  7. package/funcs/organizationsListOrSearchFacilities.d.ts.map +1 -1
  8. package/funcs/organizationsListOrSearchFacilities.js +11 -7
  9. package/funcs/organizationsListOrSearchFacilities.js.map +1 -1
  10. package/funcs/userGetCurrentUser.d.ts +2 -1
  11. package/funcs/userGetCurrentUser.d.ts.map +1 -1
  12. package/funcs/userGetCurrentUser.js +10 -6
  13. package/funcs/userGetCurrentUser.js.map +1 -1
  14. package/funcs/userGetUserById.d.ts +2 -1
  15. package/funcs/userGetUserById.d.ts.map +1 -1
  16. package/funcs/userGetUserById.js +11 -7
  17. package/funcs/userGetUserById.js.map +1 -1
  18. package/funcs/userLogsUserIntoTheSystem.d.ts +2 -1
  19. package/funcs/userLogsUserIntoTheSystem.d.ts.map +1 -1
  20. package/funcs/userLogsUserIntoTheSystem.js +11 -7
  21. package/funcs/userLogsUserIntoTheSystem.js.map +1 -1
  22. package/funcs/userMagiclink.d.ts +17 -0
  23. package/funcs/userMagiclink.d.ts.map +1 -0
  24. package/funcs/userMagiclink.js +115 -0
  25. package/funcs/userMagiclink.js.map +1 -0
  26. package/funcs/userPassword.d.ts +18 -0
  27. package/funcs/userPassword.d.ts.map +1 -0
  28. package/funcs/userPassword.js +116 -0
  29. package/funcs/userPassword.js.map +1 -0
  30. package/funcs/userPasswordResetRequest.d.ts +17 -0
  31. package/funcs/userPasswordResetRequest.d.ts.map +1 -0
  32. package/funcs/userPasswordResetRequest.js +115 -0
  33. package/funcs/userPasswordResetRequest.js.map +1 -0
  34. package/funcs/vendorsCreateVendorRegistration.d.ts +2 -1
  35. package/funcs/vendorsCreateVendorRegistration.d.ts.map +1 -1
  36. package/funcs/vendorsCreateVendorRegistration.js +11 -7
  37. package/funcs/vendorsCreateVendorRegistration.js.map +1 -1
  38. package/funcs/vendorsListVendorJobTitles.d.ts +2 -1
  39. package/funcs/vendorsListVendorJobTitles.d.ts.map +1 -1
  40. package/funcs/vendorsListVendorJobTitles.js +11 -7
  41. package/funcs/vendorsListVendorJobTitles.js.map +1 -1
  42. package/jsr.json +1 -1
  43. package/lib/config.d.ts +3 -3
  44. package/lib/config.js +3 -3
  45. package/lib/config.js.map +1 -1
  46. package/lib/sdks.d.ts +1 -1
  47. package/lib/sdks.d.ts.map +1 -1
  48. package/models/operations/index.d.ts +3 -0
  49. package/models/operations/index.d.ts.map +1 -1
  50. package/models/operations/index.js +3 -0
  51. package/models/operations/index.js.map +1 -1
  52. package/models/operations/magiclink.d.ts +57 -0
  53. package/models/operations/magiclink.d.ts.map +1 -0
  54. package/models/operations/magiclink.js +96 -0
  55. package/models/operations/magiclink.js.map +1 -0
  56. package/models/operations/password.d.ts +59 -0
  57. package/models/operations/password.d.ts.map +1 -0
  58. package/models/operations/password.js +107 -0
  59. package/models/operations/password.js.map +1 -0
  60. package/models/operations/passwordresetrequest.d.ts +57 -0
  61. package/models/operations/passwordresetrequest.d.ts.map +1 -0
  62. package/models/operations/passwordresetrequest.js +96 -0
  63. package/models/operations/passwordresetrequest.js.map +1 -0
  64. package/package.json +1 -1
  65. package/react-query/index.d.ts +3 -0
  66. package/react-query/index.d.ts.map +1 -1
  67. package/react-query/index.js +3 -0
  68. package/react-query/index.js.map +1 -1
  69. package/react-query/userMagiclink.d.ts +23 -0
  70. package/react-query/userMagiclink.d.ts.map +1 -0
  71. package/react-query/userMagiclink.js +47 -0
  72. package/react-query/userMagiclink.js.map +1 -0
  73. package/react-query/userPassword.d.ts +24 -0
  74. package/react-query/userPassword.d.ts.map +1 -0
  75. package/react-query/userPassword.js +48 -0
  76. package/react-query/userPassword.js.map +1 -0
  77. package/react-query/userPasswordResetRequest.d.ts +23 -0
  78. package/react-query/userPasswordResetRequest.d.ts.map +1 -0
  79. package/react-query/userPasswordResetRequest.js +47 -0
  80. package/react-query/userPasswordResetRequest.js.map +1 -0
  81. package/sdk/user.d.ts +22 -0
  82. package/sdk/user.d.ts.map +1 -1
  83. package/sdk/user.js +31 -0
  84. package/sdk/user.js.map +1 -1
  85. package/src/funcs/organizationsGetFacility.ts +37 -8
  86. package/src/funcs/organizationsListOrSearchFacilities.ts +35 -8
  87. package/src/funcs/userGetCurrentUser.ts +33 -7
  88. package/src/funcs/userGetUserById.ts +36 -8
  89. package/src/funcs/userLogsUserIntoTheSystem.ts +36 -8
  90. package/src/funcs/userMagiclink.ts +162 -0
  91. package/src/funcs/userPassword.ts +163 -0
  92. package/src/funcs/userPasswordResetRequest.ts +163 -0
  93. package/src/funcs/vendorsCreateVendorRegistration.ts +36 -8
  94. package/src/funcs/vendorsListVendorJobTitles.ts +37 -8
  95. package/src/lib/config.ts +3 -3
  96. package/src/lib/sdks.ts +1 -1
  97. package/src/models/operations/index.ts +3 -0
  98. package/src/models/operations/magiclink.ts +127 -0
  99. package/src/models/operations/password.ts +140 -0
  100. package/src/models/operations/passwordresetrequest.ts +131 -0
  101. package/src/react-query/index.ts +3 -0
  102. package/src/react-query/userMagiclink.ts +88 -0
  103. package/src/react-query/userPassword.ts +89 -0
  104. package/src/react-query/userPasswordResetRequest.ts +89 -0
  105. package/src/sdk/user.ts +55 -0
  106. package/src/types/async.ts +68 -0
  107. package/types/async.d.ts +23 -0
  108. package/types/async.d.ts.map +1 -0
  109. package/types/async.js +44 -0
  110. package/types/async.js.map +1 -0
  111. package/.devcontainer/README.md +0 -35
  112. package/docs/sdks/greensecurity/README.md +0 -14
  113. package/docs/sdks/organizations/README.md +0 -252
  114. package/docs/sdks/user/README.md +0 -348
  115. package/docs/sdks/vendors/README.md +0 -219
@@ -1,252 +0,0 @@
1
- # Organizations
2
- (*organizations*)
3
-
4
- ## Overview
5
-
6
- Organizations includes `Hospital Systems` and their component parts (such as `Facilities`, `Zones` and `Departments`)
7
-
8
- ### Available Operations
9
-
10
- * [listOrSearchFacilities](#listorsearchfacilities) - List or search facilities
11
- * [getFacility](#getfacility) - Get facility
12
-
13
- ## listOrSearchFacilities
14
-
15
- List or search facilities.
16
-
17
- Available `expand` scopes are:
18
-
19
- - facility.appointment_policy
20
- - facility.contacts
21
- - facility.vendor_counts
22
- - facility.flu_credential
23
- - facility.scrubs_policy
24
- - facility.system
25
- - facility.vendor_guest_policy
26
- - facility.vendor_policy
27
- - facility.visitor_policy
28
- - facility.workflow
29
-
30
- ### Example Usage
31
-
32
- ```typescript
33
- import { GreenSecurity } from "@greensecurity/javascript-sdk";
34
-
35
- const greenSecurity = new GreenSecurity({
36
- security: {
37
- token: process.env["GREEN_SECURITY_TOKEN"] ?? "",
38
- },
39
- });
40
-
41
- async function run() {
42
- const result = await greenSecurity.organizations.listOrSearchFacilities({
43
- sort: "job",
44
- desc: true,
45
- itemsPerPage: 25,
46
- expand: [
47
- "facility.system",
48
- ],
49
- });
50
-
51
- // Handle the result
52
- console.log(result);
53
- }
54
-
55
- run();
56
- ```
57
-
58
- ### Standalone function
59
-
60
- The standalone function version of this method:
61
-
62
- ```typescript
63
- import { GreenSecurityCore } from "@greensecurity/javascript-sdk/core.js";
64
- import { organizationsListOrSearchFacilities } from "@greensecurity/javascript-sdk/funcs/organizationsListOrSearchFacilities.js";
65
-
66
- // Use `GreenSecurityCore` for best tree-shaking performance.
67
- // You can create one instance of it to use across an application.
68
- const greenSecurity = new GreenSecurityCore({
69
- security: {
70
- token: process.env["GREEN_SECURITY_TOKEN"] ?? "",
71
- },
72
- });
73
-
74
- async function run() {
75
- const res = await organizationsListOrSearchFacilities(greenSecurity, {
76
- sort: "job",
77
- desc: true,
78
- itemsPerPage: 25,
79
- expand: [
80
- "facility.system",
81
- ],
82
- });
83
-
84
- if (!res.ok) {
85
- throw res.error;
86
- }
87
-
88
- const { value: result } = res;
89
-
90
- // Handle the result
91
- console.log(result);
92
- }
93
-
94
- run();
95
- ```
96
-
97
- ### React hooks and utilities
98
-
99
- This method can be used in React components through the following hooks and
100
- associated utilities.
101
-
102
- > Check out [this guide][hook-guide] for information about each of the utilities
103
- > below and how to get started using React hooks.
104
-
105
- [hook-guide]: ../../../REACT_QUERY.md
106
-
107
- ```tsx
108
- import {
109
- // Query hooks for fetching data.
110
- useOrganizationsListOrSearchFacilities,
111
- useOrganizationsListOrSearchFacilitiesSuspense,
112
-
113
- // Utility for prefetching data during server-side rendering and in React
114
- // Server Components that will be immediately available to client components
115
- // using the hooks.
116
- prefetchOrganizationsListOrSearchFacilities,
117
-
118
- // Utilities to invalidate the query cache for this query in response to
119
- // mutations and other user actions.
120
- invalidateOrganizationsListOrSearchFacilities,
121
- invalidateAllOrganizationsListOrSearchFacilities,
122
- } from "@greensecurity/javascript-sdk/react-query/organizationsListOrSearchFacilities.js";
123
- ```
124
-
125
- ### Parameters
126
-
127
- | Parameter | Type | Required | Description |
128
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
129
- | `request` | [operations.ListOrSearchFacilitiesRequest](../../models/operations/listorsearchfacilitiesrequest.md) | :heavy_check_mark: | The request object to use for the request. |
130
- | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
131
- | `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. |
132
- | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
133
-
134
- ### Response
135
-
136
- **Promise\<[operations.ListOrSearchFacilitiesResponseBody](../../models/operations/listorsearchfacilitiesresponsebody.md)\>**
137
-
138
- ### Errors
139
-
140
- | Error Type | Status Code | Content Type |
141
- | --------------- | --------------- | --------------- |
142
- | errors.APIError | 4XX, 5XX | \*/\* |
143
-
144
- ## getFacility
145
-
146
- Retrieve an individual facility.
147
-
148
- ### Example Usage
149
-
150
- ```typescript
151
- import { GreenSecurity } from "@greensecurity/javascript-sdk";
152
-
153
- const greenSecurity = new GreenSecurity({
154
- security: {
155
- token: process.env["GREEN_SECURITY_TOKEN"] ?? "",
156
- },
157
- });
158
-
159
- async function run() {
160
- const result = await greenSecurity.organizations.getFacility({
161
- id: 924512,
162
- });
163
-
164
- // Handle the result
165
- console.log(result);
166
- }
167
-
168
- run();
169
- ```
170
-
171
- ### Standalone function
172
-
173
- The standalone function version of this method:
174
-
175
- ```typescript
176
- import { GreenSecurityCore } from "@greensecurity/javascript-sdk/core.js";
177
- import { organizationsGetFacility } from "@greensecurity/javascript-sdk/funcs/organizationsGetFacility.js";
178
-
179
- // Use `GreenSecurityCore` for best tree-shaking performance.
180
- // You can create one instance of it to use across an application.
181
- const greenSecurity = new GreenSecurityCore({
182
- security: {
183
- token: process.env["GREEN_SECURITY_TOKEN"] ?? "",
184
- },
185
- });
186
-
187
- async function run() {
188
- const res = await organizationsGetFacility(greenSecurity, {
189
- id: 924512,
190
- });
191
-
192
- if (!res.ok) {
193
- throw res.error;
194
- }
195
-
196
- const { value: result } = res;
197
-
198
- // Handle the result
199
- console.log(result);
200
- }
201
-
202
- run();
203
- ```
204
-
205
- ### React hooks and utilities
206
-
207
- This method can be used in React components through the following hooks and
208
- associated utilities.
209
-
210
- > Check out [this guide][hook-guide] for information about each of the utilities
211
- > below and how to get started using React hooks.
212
-
213
- [hook-guide]: ../../../REACT_QUERY.md
214
-
215
- ```tsx
216
- import {
217
- // Query hooks for fetching data.
218
- useOrganizationsGetFacility,
219
- useOrganizationsGetFacilitySuspense,
220
-
221
- // Utility for prefetching data during server-side rendering and in React
222
- // Server Components that will be immediately available to client components
223
- // using the hooks.
224
- prefetchOrganizationsGetFacility,
225
-
226
- // Utilities to invalidate the query cache for this query in response to
227
- // mutations and other user actions.
228
- invalidateOrganizationsGetFacility,
229
- invalidateAllOrganizationsGetFacility,
230
- } from "@greensecurity/javascript-sdk/react-query/organizationsGetFacility.js";
231
- ```
232
-
233
- ### Parameters
234
-
235
- | Parameter | Type | Required | Description |
236
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
237
- | `request` | [operations.GetFacilityRequest](../../models/operations/getfacilityrequest.md) | :heavy_check_mark: | The request object to use for the request. |
238
- | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
239
- | `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. |
240
- | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
241
-
242
- ### Response
243
-
244
- **Promise\<[components.Facility](../../models/components/facility.md)\>**
245
-
246
- ### Errors
247
-
248
- | Error Type | Status Code | Content Type |
249
- | ----------------------- | ----------------------- | ----------------------- |
250
- | errors.ApiErrorResponse | 401, 403, 404 | application/json |
251
- | errors.ApiErrorResponse | 500 | application/json |
252
- | errors.APIError | 4XX, 5XX | \*/\* |
@@ -1,348 +0,0 @@
1
- # User
2
- (*user*)
3
-
4
- ## Overview
5
-
6
- Operations about user
7
-
8
- ### Available Operations
9
-
10
- * [getCurrentUser](#getcurrentuser) - Get current user
11
- * [getUserById](#getuserbyid) - Get user by id
12
- * [logsUserIntoTheSystem](#logsuserintothesystem) - Logs user into the system
13
-
14
- ## getCurrentUser
15
-
16
- Returns a user object for the user represented by the authorization token
17
-
18
- ### Example Usage
19
-
20
- ```typescript
21
- import { GreenSecurity } from "@greensecurity/javascript-sdk";
22
-
23
- const greenSecurity = new GreenSecurity({
24
- security: {
25
- token: process.env["GREEN_SECURITY_TOKEN"] ?? "",
26
- },
27
- });
28
-
29
- async function run() {
30
- const result = await greenSecurity.user.getCurrentUser();
31
-
32
- // Handle the result
33
- console.log(result);
34
- }
35
-
36
- run();
37
- ```
38
-
39
- ### Standalone function
40
-
41
- The standalone function version of this method:
42
-
43
- ```typescript
44
- import { GreenSecurityCore } from "@greensecurity/javascript-sdk/core.js";
45
- import { userGetCurrentUser } from "@greensecurity/javascript-sdk/funcs/userGetCurrentUser.js";
46
-
47
- // Use `GreenSecurityCore` for best tree-shaking performance.
48
- // You can create one instance of it to use across an application.
49
- const greenSecurity = new GreenSecurityCore({
50
- security: {
51
- token: process.env["GREEN_SECURITY_TOKEN"] ?? "",
52
- },
53
- });
54
-
55
- async function run() {
56
- const res = await userGetCurrentUser(greenSecurity);
57
-
58
- if (!res.ok) {
59
- throw res.error;
60
- }
61
-
62
- const { value: result } = res;
63
-
64
- // Handle the result
65
- console.log(result);
66
- }
67
-
68
- run();
69
- ```
70
-
71
- ### React hooks and utilities
72
-
73
- This method can be used in React components through the following hooks and
74
- associated utilities.
75
-
76
- > Check out [this guide][hook-guide] for information about each of the utilities
77
- > below and how to get started using React hooks.
78
-
79
- [hook-guide]: ../../../REACT_QUERY.md
80
-
81
- ```tsx
82
- import {
83
- // Query hooks for fetching data.
84
- useUserGetCurrentUser,
85
- useUserGetCurrentUserSuspense,
86
-
87
- // Utility for prefetching data during server-side rendering and in React
88
- // Server Components that will be immediately available to client components
89
- // using the hooks.
90
- prefetchUserGetCurrentUser,
91
-
92
- // Utility to invalidate the query cache for this query in response to
93
- // mutations and other user actions.
94
- invalidateAllUserGetCurrentUser,
95
- } from "@greensecurity/javascript-sdk/react-query/userGetCurrentUser.js";
96
- ```
97
-
98
- ### Parameters
99
-
100
- | Parameter | Type | Required | Description |
101
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
102
- | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
103
- | `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. |
104
- | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
105
-
106
- ### Response
107
-
108
- **Promise\<[components.User](../../models/components/user.md)\>**
109
-
110
- ### Errors
111
-
112
- | Error Type | Status Code | Content Type |
113
- | ----------------------- | ----------------------- | ----------------------- |
114
- | errors.ApiErrorResponse | 400, 401, 403, 404 | application/json |
115
- | errors.APIError | 4XX, 5XX | \*/\* |
116
-
117
- ## getUserById
118
-
119
- Returns a user object for the user represented by the identifier in the path.
120
-
121
- ### Example Usage
122
-
123
- ```typescript
124
- import { GreenSecurity } from "@greensecurity/javascript-sdk";
125
-
126
- const greenSecurity = new GreenSecurity({
127
- security: {
128
- token: process.env["GREEN_SECURITY_TOKEN"] ?? "",
129
- },
130
- });
131
-
132
- async function run() {
133
- const result = await greenSecurity.user.getUserById({
134
- id: 923873,
135
- });
136
-
137
- // Handle the result
138
- console.log(result);
139
- }
140
-
141
- run();
142
- ```
143
-
144
- ### Standalone function
145
-
146
- The standalone function version of this method:
147
-
148
- ```typescript
149
- import { GreenSecurityCore } from "@greensecurity/javascript-sdk/core.js";
150
- import { userGetUserById } from "@greensecurity/javascript-sdk/funcs/userGetUserById.js";
151
-
152
- // Use `GreenSecurityCore` for best tree-shaking performance.
153
- // You can create one instance of it to use across an application.
154
- const greenSecurity = new GreenSecurityCore({
155
- security: {
156
- token: process.env["GREEN_SECURITY_TOKEN"] ?? "",
157
- },
158
- });
159
-
160
- async function run() {
161
- const res = await userGetUserById(greenSecurity, {
162
- id: 923873,
163
- });
164
-
165
- if (!res.ok) {
166
- throw res.error;
167
- }
168
-
169
- const { value: result } = res;
170
-
171
- // Handle the result
172
- console.log(result);
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
- useUserGetUserById,
192
- useUserGetUserByIdSuspense,
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
- prefetchUserGetUserById,
198
-
199
- // Utilities to invalidate the query cache for this query in response to
200
- // mutations and other user actions.
201
- invalidateUserGetUserById,
202
- invalidateAllUserGetUserById,
203
- } from "@greensecurity/javascript-sdk/react-query/userGetUserById.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.APIError | 4XX, 5XX | \*/\* |
225
-
226
- ## logsUserIntoTheSystem
227
-
228
- This endpoint allows a user to authenticate themselves and retrieve a permanent token for access.
229
-
230
- Permanent tokens should only ever be stored in an encrypted storage because they represent a fully logged in user.
231
-
232
- 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.
233
-
234
- 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.
235
-
236
- 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.
237
-
238
- The ideal flow for a login sequence is the following:
239
-
240
- 1. Present an email address field only and allow the user to submit
241
- 2. Send `email` and `return_url` payload to this endpoint
242
- 3. Follow the flow based on the response `requires` field
243
-
244
- Requires: `password`
245
-
246
- 1. Show a password field for the user to fill out
247
- 2. Submit the `email` and `password` to this endpoint
248
- 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
249
- 4. Submit `email`, `password`, `mfa_code` to this endpoint
250
- 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.
251
-
252
- Requires: `saml_login`
253
-
254
- 1. [Open a browser](https://docs.expo.dev/versions/latest/sdk/webbrowser/#webbrowseropenauthsessionasyncurl-redirecturl-options) to the url returned in `sso_url`
255
- 2. User completes sign-in using their configured SAML IdP
256
- 3. Site redirects to your selected `return_url`
257
- 4. The `user_token` will be appended as a query string parameter to your `return_url` - you must parse this token and store it
258
- 5. Fetch the user object from `/users/me` using the token
259
-
260
- ### Example Usage
261
-
262
- ```typescript
263
- import { GreenSecurity } from "@greensecurity/javascript-sdk";
264
-
265
- const greenSecurity = new GreenSecurity();
266
-
267
- async function run() {
268
- const result = await greenSecurity.user.logsUserIntoTheSystem({
269
- email: "user@example.com",
270
- mfaCode: "123456",
271
- password: "Hunter2",
272
- });
273
-
274
- // Handle the result
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 { userLogsUserIntoTheSystem } from "@greensecurity/javascript-sdk/funcs/userLogsUserIntoTheSystem.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 userLogsUserIntoTheSystem(greenSecurity, {
295
- email: "user@example.com",
296
- mfaCode: "123456",
297
- password: "Hunter2",
298
- });
299
-
300
- if (!res.ok) {
301
- throw res.error;
302
- }
303
-
304
- const { value: result } = res;
305
-
306
- // Handle the result
307
- console.log(result);
308
- }
309
-
310
- run();
311
- ```
312
-
313
- ### React hooks and utilities
314
-
315
- This method can be used in React components through the following hooks and
316
- associated utilities.
317
-
318
- > Check out [this guide][hook-guide] for information about each of the utilities
319
- > below and how to get started using React hooks.
320
-
321
- [hook-guide]: ../../../REACT_QUERY.md
322
-
323
- ```tsx
324
- import {
325
- // Mutation hook for triggering the API call.
326
- useUserLogsUserIntoTheSystemMutation
327
- } from "@greensecurity/javascript-sdk/react-query/userLogsUserIntoTheSystem.js";
328
- ```
329
-
330
- ### Parameters
331
-
332
- | Parameter | Type | Required | Description |
333
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
334
- | `request` | [operations.LogsUserIntoTheSystemRequestBody](../../models/operations/logsuserintothesystemrequestbody.md) | :heavy_check_mark: | The request object to use for the request. |
335
- | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
336
- | `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. |
337
- | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
338
-
339
- ### Response
340
-
341
- **Promise\<[operations.LogsUserIntoTheSystemResponse](../../models/operations/logsuserintothesystemresponse.md)\>**
342
-
343
- ### Errors
344
-
345
- | Error Type | Status Code | Content Type |
346
- | ----------------------- | ----------------------- | ----------------------- |
347
- | errors.ApiErrorResponse | 400, 401, 404 | application/json |
348
- | errors.APIError | 4XX, 5XX | \*/\* |