@extrahorizon/javascript-sdk 8.2.0 → 8.2.1-dev-48-41fd1f1

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 (152) hide show
  1. package/CHANGELOG.md +1177 -1161
  2. package/README.md +108 -119
  3. package/build/index.cjs.js +1 -1
  4. package/build/index.mjs +1 -1
  5. package/build/types/btoa.d.ts +6 -6
  6. package/build/types/client.d.ts +136 -136
  7. package/build/types/constants.d.ts +15 -15
  8. package/build/types/errorHandler.d.ts +2 -2
  9. package/build/types/errors.d.ts +332 -332
  10. package/build/types/http/client.d.ts +2 -2
  11. package/build/types/http/index.d.ts +4 -4
  12. package/build/types/http/interceptors.d.ts +9 -9
  13. package/build/types/http/oAuth1Signature.d.ts +14 -14
  14. package/build/types/http/oauth1.d.ts +3 -3
  15. package/build/types/http/oauth2.d.ts +3 -3
  16. package/build/types/http/proxy.d.ts +3 -3
  17. package/build/types/http/types.d.ts +331 -331
  18. package/build/types/http/utils.d.ts +21 -21
  19. package/build/types/index.d.ts +9 -9
  20. package/build/types/mock.d.ts +43 -43
  21. package/build/types/mockType.d.ts +1547 -1511
  22. package/build/types/parseStoredCredentials.d.ts +11 -11
  23. package/build/types/rql/index.d.ts +16 -16
  24. package/build/types/rql/parser.d.ts +1 -1
  25. package/build/types/rql/types.d.ts +168 -168
  26. package/build/types/services/auth/applications/index.d.ts +5 -5
  27. package/build/types/services/auth/applications/types.d.ts +260 -190
  28. package/build/types/services/auth/index.d.ts +3 -3
  29. package/build/types/services/auth/oauth1/index.d.ts +5 -5
  30. package/build/types/services/auth/oauth1/types.d.ts +63 -63
  31. package/build/types/services/auth/oauth2/index.d.ts +5 -5
  32. package/build/types/services/auth/oauth2/types.d.ts +52 -52
  33. package/build/types/services/auth/oidc/index.d.ts +5 -5
  34. package/build/types/services/auth/oidc/loginAttempts/index.d.ts +5 -5
  35. package/build/types/services/auth/oidc/loginAttempts/types.d.ts +67 -67
  36. package/build/types/services/auth/oidc/providers/index.d.ts +5 -5
  37. package/build/types/services/auth/oidc/providers/types.d.ts +144 -144
  38. package/build/types/services/auth/oidc/types.d.ts +40 -40
  39. package/build/types/services/auth/types.d.ts +39 -39
  40. package/build/types/services/auth/users/index.d.ts +5 -5
  41. package/build/types/services/auth/users/types.d.ts +121 -121
  42. package/build/types/services/configurations/general.d.ts +5 -5
  43. package/build/types/services/configurations/groups.d.ts +5 -5
  44. package/build/types/services/configurations/index.d.ts +10 -10
  45. package/build/types/services/configurations/patients.d.ts +5 -5
  46. package/build/types/services/configurations/staff.d.ts +5 -5
  47. package/build/types/services/configurations/types.d.ts +222 -222
  48. package/build/types/services/configurations/users.d.ts +5 -5
  49. package/build/types/services/data/comments.d.ts +5 -5
  50. package/build/types/services/data/documents.d.ts +5 -5
  51. package/build/types/services/data/index.d.ts +13 -13
  52. package/build/types/services/data/indexes.d.ts +5 -5
  53. package/build/types/services/data/infrastructure.d.ts +10 -10
  54. package/build/types/services/data/json-schema.d.ts +121 -121
  55. package/build/types/services/data/properties.d.ts +5 -5
  56. package/build/types/services/data/schemas.d.ts +5 -5
  57. package/build/types/services/data/statuses.d.ts +5 -5
  58. package/build/types/services/data/transitions.d.ts +5 -5
  59. package/build/types/services/data/types.d.ts +899 -899
  60. package/build/types/services/dispatchers/actions/index.d.ts +5 -5
  61. package/build/types/services/dispatchers/actions/types.d.ts +78 -78
  62. package/build/types/services/dispatchers/dispatchers/index.d.ts +5 -5
  63. package/build/types/services/dispatchers/dispatchers/types.d.ts +111 -111
  64. package/build/types/services/dispatchers/index.d.ts +7 -7
  65. package/build/types/services/dispatchers/types.d.ts +2 -2
  66. package/build/types/services/events/events.d.ts +5 -5
  67. package/build/types/services/events/health.d.ts +9 -9
  68. package/build/types/services/events/index.d.ts +6 -6
  69. package/build/types/services/events/subscriptions.d.ts +5 -5
  70. package/build/types/services/events/types.d.ts +90 -90
  71. package/build/types/services/files/files.d.ts +5 -5
  72. package/build/types/services/files/formHelpers.d.ts +3 -3
  73. package/build/types/services/files/index.d.ts +6 -6
  74. package/build/types/services/files/settings/index.d.ts +5 -5
  75. package/build/types/services/files/settings/types.d.ts +38 -38
  76. package/build/types/services/files/tokens.d.ts +5 -5
  77. package/build/types/services/files/types.d.ts +185 -185
  78. package/build/types/services/helpers.d.ts +7 -7
  79. package/build/types/services/http-client.d.ts +22 -22
  80. package/build/types/services/index.d.ts +15 -15
  81. package/build/types/services/localizations/countries.d.ts +5 -5
  82. package/build/types/services/localizations/health.d.ts +9 -9
  83. package/build/types/services/localizations/index.d.ts +4 -4
  84. package/build/types/services/localizations/languages.d.ts +5 -5
  85. package/build/types/services/localizations/localizations.d.ts +5 -5
  86. package/build/types/services/localizations/types.d.ts +145 -145
  87. package/build/types/services/logs/access/index.d.ts +5 -5
  88. package/build/types/services/logs/access/types.d.ts +41 -41
  89. package/build/types/services/logs/index.d.ts +3 -3
  90. package/build/types/services/logs/types.d.ts +4 -4
  91. package/build/types/services/mails/index.d.ts +3 -3
  92. package/build/types/services/mails/mails.d.ts +5 -5
  93. package/build/types/services/mails/types.d.ts +141 -141
  94. package/build/types/services/notifications/health.d.ts +9 -9
  95. package/build/types/services/notifications/index.d.ts +7 -7
  96. package/build/types/services/notifications/notifications.d.ts +5 -5
  97. package/build/types/services/notifications/settings.d.ts +5 -5
  98. package/build/types/services/notifications/types.d.ts +222 -222
  99. package/build/types/services/payments/appStore.d.ts +5 -5
  100. package/build/types/services/payments/appStoreSubscriptions.d.ts +5 -5
  101. package/build/types/services/payments/health.d.ts +9 -9
  102. package/build/types/services/payments/index.d.ts +15 -15
  103. package/build/types/services/payments/orders.d.ts +5 -5
  104. package/build/types/services/payments/playStore.d.ts +5 -5
  105. package/build/types/services/payments/playStoreHistory.d.ts +5 -5
  106. package/build/types/services/payments/playStoreSubscriptions.d.ts +5 -5
  107. package/build/types/services/payments/products.d.ts +5 -5
  108. package/build/types/services/payments/stripe.d.ts +5 -5
  109. package/build/types/services/payments/subscriptions.d.ts +5 -5
  110. package/build/types/services/payments/types.d.ts +1189 -1189
  111. package/build/types/services/profiles/groups.d.ts +5 -5
  112. package/build/types/services/profiles/health.d.ts +9 -9
  113. package/build/types/services/profiles/index.d.ts +9 -9
  114. package/build/types/services/profiles/logs.d.ts +5 -5
  115. package/build/types/services/profiles/profiles.d.ts +5 -5
  116. package/build/types/services/profiles/types.d.ts +370 -369
  117. package/build/types/services/tasks/api/index.d.ts +5 -5
  118. package/build/types/services/tasks/api/types.d.ts +146 -146
  119. package/build/types/services/tasks/apiRequests/index.d.ts +5 -5
  120. package/build/types/services/tasks/apiRequests/logs/index.d.ts +5 -5
  121. package/build/types/services/tasks/apiRequests/logs/types.d.ts +25 -25
  122. package/build/types/services/tasks/apiRequests/types.d.ts +83 -83
  123. package/build/types/services/tasks/functions/index.d.ts +5 -5
  124. package/build/types/services/tasks/functions/types.d.ts +27 -27
  125. package/build/types/services/tasks/index.d.ts +15 -15
  126. package/build/types/services/tasks/logs/index.d.ts +5 -5
  127. package/build/types/services/tasks/logs/types.d.ts +28 -28
  128. package/build/types/services/tasks/schedules/index.d.ts +5 -5
  129. package/build/types/services/tasks/schedules/types.d.ts +88 -88
  130. package/build/types/services/tasks/tasks.d.ts +5 -5
  131. package/build/types/services/tasks/types.d.ts +107 -107
  132. package/build/types/services/templates/index.d.ts +3 -3
  133. package/build/types/services/templates/templates.d.ts +5 -5
  134. package/build/types/services/templates/types.d.ts +202 -202
  135. package/build/types/services/types.d.ts +77 -77
  136. package/build/types/services/users/activationRequests/index.d.ts +4 -4
  137. package/build/types/services/users/activationRequests/types.d.ts +70 -70
  138. package/build/types/services/users/forgotPasswordRequests/index.d.ts +4 -4
  139. package/build/types/services/users/forgotPasswordRequests/types.d.ts +70 -70
  140. package/build/types/services/users/globalRoles.d.ts +5 -5
  141. package/build/types/services/users/groupRoles.d.ts +5 -5
  142. package/build/types/services/users/health.d.ts +9 -9
  143. package/build/types/services/users/index.d.ts +16 -16
  144. package/build/types/services/users/settings/index.d.ts +4 -4
  145. package/build/types/services/users/settings/types.d.ts +47 -47
  146. package/build/types/services/users/types.d.ts +1116 -1055
  147. package/build/types/services/users/users.d.ts +5 -5
  148. package/build/types/sha1.d.ts +11 -11
  149. package/build/types/types.d.ts +102 -102
  150. package/build/types/utils.d.ts +4 -4
  151. package/build/types/version.d.ts +1 -1
  152. package/package.json +62 -62
@@ -1,331 +1,331 @@
1
- import { AxiosError, AxiosInstance, AxiosInterceptorManager, AxiosPromise, AxiosRequestConfig, AxiosResponse } from 'axios';
2
- export declare type HttpResponse<T = any> = AxiosResponse<T> & {
3
- config: HttpRequestConfig;
4
- };
5
- export declare type HttpRequestConfig = AxiosRequestConfig & {
6
- interceptors?: {
7
- skipCamelizeResponseData?: boolean;
8
- skipTransformResponseData?: boolean;
9
- skipTransformKeysResponseData?: boolean;
10
- };
11
- retry?: {
12
- tries: number;
13
- retryTimeInMs: number;
14
- current: number;
15
- retryCondition: (error: HttpResponseError) => boolean;
16
- };
17
- normalizeCustomData?: boolean;
18
- customKeys?: string[];
19
- /**
20
- * Overrides values provided in {@Link customKeys}
21
- */
22
- customRequestKeys?: string[];
23
- /**
24
- * Overrides values provided in {@Link customKeys}
25
- */
26
- customResponseKeys?: string[];
27
- };
28
- export declare type HttpResponseError = AxiosError & {
29
- config: HttpRequestConfig;
30
- };
31
- export interface HttpInstance {
32
- (config: AxiosRequestConfig): AxiosPromise;
33
- (url: string, config?: AxiosRequestConfig): AxiosPromise;
34
- normalizeCustomData?: boolean;
35
- defaults: AxiosInstance['defaults'];
36
- interceptors: {
37
- request: AxiosInterceptorManager<AxiosRequestConfig>;
38
- response: AxiosInterceptorManager<AxiosResponse>;
39
- };
40
- getUri(config?: HttpRequestConfig): string;
41
- request<T = any, R = AxiosResponse<T>>(config: HttpRequestConfig): Promise<R>;
42
- get<T = any, R = AxiosResponse<T>>(url: string, config?: HttpRequestConfig): Promise<R>;
43
- delete<T = any, R = AxiosResponse<T>>(url: string, config?: HttpRequestConfig): Promise<R>;
44
- head<T = any, R = AxiosResponse<T>>(url: string, config?: HttpRequestConfig): Promise<R>;
45
- options<T = any, R = AxiosResponse<T>>(url: string, config?: HttpRequestConfig): Promise<R>;
46
- post<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: HttpRequestConfig): Promise<R>;
47
- put<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: HttpRequestConfig): Promise<R>;
48
- patch<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: HttpRequestConfig): Promise<R>;
49
- }
50
- export interface TokenDataOauth2 {
51
- tokenType: string;
52
- accessToken: string;
53
- expiresIn: number;
54
- refreshToken: string;
55
- applicationId: string;
56
- userId: string;
57
- creationTimestamp: Date;
58
- }
59
- export interface TokenDataOauth1 {
60
- id?: string;
61
- key: string;
62
- secret: string;
63
- token?: string;
64
- tokenSecret?: string;
65
- applicationId?: string;
66
- userId?: string;
67
- updateTimestamp?: Date;
68
- creationTimestamp?: Date;
69
- }
70
- export interface OidcAuthenticationUrlRequest {
71
- /** The state parameter to be included in the authentication URL */
72
- state?: string;
73
- }
74
- export interface OidcAuthenticationUrl {
75
- /** The authentication URL the user should be directed to */
76
- authenticationUrl: string;
77
- }
78
- export interface OidcAuthenticateRequest {
79
- /** The authorizationCode received from the provider via the redirect after the user authenticated with the provider */
80
- authorizationCode: string;
81
- }
82
- export interface OAuth2HttpClient extends HttpInstance {
83
- extraAuthMethods: {
84
- /**
85
- * Use OAuth2 Authorization Code Grant flow with callback
86
- * @example
87
- * await exh.auth.authenticate({
88
- * code: '',
89
- * });
90
- * @throws {InvalidRequestError}
91
- * @throws {InvalidGrantError}
92
- * @throws {UnsupportedGrantTypeError}
93
- * @throws {MfaRequiredError}
94
- * @throws {InvalidClientError}
95
- */
96
- authenticate(oauth: {
97
- code: string;
98
- }): Promise<TokenDataOauth2>;
99
- /**
100
- * Use OAuth2 Password Grant flow
101
- * @example
102
- * await exh.auth.authenticate({
103
- * password: '',
104
- * username: '',
105
- * });
106
- * @throws {InvalidRequestError}
107
- * @throws {InvalidGrantError}
108
- * @throws {UnsupportedGrantTypeError}
109
- * @throws {MfaRequiredError}
110
- * @throws {InvalidClientError}
111
- */
112
- authenticate(oauth: {
113
- username: string;
114
- password: string;
115
- }): Promise<TokenDataOauth2>;
116
- /**
117
- * Use OAuth2 Refresh Token Grant flow
118
- * @example
119
- * await exh.auth.authenticate({
120
- * refreshToken: '',
121
- * });
122
- * @throws {InvalidRequestError}
123
- * @throws {InvalidGrantError}
124
- * @throws {UnsupportedGrantTypeError}
125
- * @throws {MfaRequiredError}
126
- * @throws {InvalidClientError}
127
- */
128
- authenticate(oauth: {
129
- refreshToken: string;
130
- }): Promise<TokenDataOauth2>;
131
- /**
132
- * Confirm MFA method with token, methodId and code
133
- * @example
134
- * try {
135
- * await exh.auth.authenticate({
136
- * username: '',
137
- * password: '',
138
- * });
139
- * } catch (error) {
140
- * if (error instanceof MfaRequiredError) {
141
- * const { mfa } = error;
142
- *
143
- * // Your logic to request which method the user want to use in case of multiple methods
144
- * const methodId = mfa.methods[0].id;
145
- *
146
- * await exh.auth.confirmMfa({
147
- * token: mfa.token,
148
- * methodId,
149
- * code: '', // code from ie. Google Authenticator
150
- * });
151
- * }
152
- * }
153
- */
154
- confirmMfa(data: MfaConfig): Promise<TokenDataOauth2>;
155
- /**
156
- * ## Generate an OIDC authentication URL
157
- * You can use this endpoint to generate a fully configured OIDC authentication URL.
158
- * You can use the authentication URL to redirect the user to the specified OIDC provider to initiate the authentication process.
159
- *
160
- * Once the user is authenticated, the OIDC provider will redirect the user to the configured `redirectUri` with an authorization code.
161
- * The authorization code can then be used to login (see `auth.authenticateWithOidc()`).
162
- *
163
- * A state parameter can be added to the URL.
164
- * Supply the `state` property to this function and the state parameter will be included in the URL.
165
- * If supplied, the provider will add the same state parameter and value again to the URL when redirecting the user is back to your application (the configured `redirectUri`).
166
- * This can (and should) be used to protect against Cross-Site Request Forgery (CSRF) attacks.
167
- *
168
- * A `nonce` parameter is automatically added and will be validated during the authorization code exchange by ExH.
169
- *
170
- * #### Example URL
171
- * An example of a fully configured authentication URL: (new lines added for readability)
172
- * ```txt
173
- * https://accounts.google.com/o/oauth2/auth
174
- * ?response_type=code
175
- * &client_id=123456789-abcdefghijklw.apps.googleusercontent.com
176
- * &scope=openid%20email%20profile
177
- * &redirect_uri=https%3A%2F%2Fapi.dev.yourapp.com%2Fcallback
178
- * &nonce=608c038a830f40d7fe028a3f05c85b84f9040d37
179
- * ```
180
- *
181
- * #### Function details
182
- * @param providerName The name of the OIDC provider to generate an authentication URL for
183
- * @param data {@link OidcAuthenticationUrlRequest}
184
- *
185
- * @returns An object containing the authentication URL
186
- *
187
- * @throws {@link IllegalStateError} When targeting a disabled provider. A provider must be enabled to allow users to use this endpoint.
188
- */
189
- generateOidcAuthenticationUrl(providerName: string, data?: OidcAuthenticationUrlRequest): Promise<OidcAuthenticationUrl>;
190
- /**
191
- * ## Authenticate a user with OIDC
192
- * You can use this method to authenticate a user after obtaining a authorization code from an OIDC provider.
193
- * The authorization code is obtained when an OIDC provider redirects a user back to your application after a successful authentication.
194
- * The authorization code may be URL encoded, so make sure the authorization code is in the correct format before providing it here.
195
- * See `auth.generateOidcAuthenticationUrl()` to initiate the authentication process.
196
- *
197
- * Like the `auth.authenticate()` method, the SDK uses the returned access token and refresh token to authenticate successive requests.
198
- *
199
- * All (successful and failed) login attempts are logged. See `auth.oidc.getLoginAttempts()`.
200
- *
201
- * #### Function details
202
- * @param providerName The name of the OIDC provider to login with
203
- * @param data {@link OidcAuthenticateRequest}
204
- *
205
- * @returns The OAuth2 tokens generated for the user.
206
- *
207
- * @throws {@link IllegalStateError} When targeting a disabled provider. A provider must be enabled to allow users to use this endpoint.
208
- * @throws {@link OAuth2MissingClientCredentialsError} When no client credentials are specified or, for a confidential application, the `clientSecret` is missing.
209
- * @throws {@link OidcProviderResponseError} When the provider is incorrectly configured or the provider gave us an unexpected response. Please check the provider configuration.
210
- * @throws {@link OidcInvalidAuthorizationCodeError} When the provided `authorizationCode` is not accepted or recognized by the provider.
211
- * @throws {@link EmailUsedError} When a new ExH account is being created for the user trying to login with an email address which is already in use by an existing ExH account.
212
- * @throws {@link OAuth2ClientIdError} When the supplied `clientId` could not be found.
213
- * @throws {@link OAuth2ClientSecretError} When the supplied `clientSecret` is incorrect.
214
- * @throws {@link OidcIdTokenError} When we understood the response of the provider but the id token returned is invalid.
215
- */
216
- authenticateWithOidc(providerName: string, data: OidcAuthenticateRequest): Promise<TokenDataOauth2>;
217
- /**
218
- * Logout
219
- * @returns {boolean} Success
220
- * @example
221
- * try {
222
- * await exh.auth.authenticate({
223
- * username: '',
224
- * password: '',
225
- * });
226
- * exh.auth.logout();
227
- * } catch (error) {
228
- * console.log(error)
229
- * }
230
- */
231
- logout(): boolean;
232
- };
233
- userId: Promise<string | undefined>;
234
- }
235
- export interface OAuth1HttpClient extends HttpInstance {
236
- extraAuthMethods: {
237
- /**
238
- * Use OAuth1 Token authentication
239
- * @example
240
- * await exh.auth.authenticate({
241
- * token: '',
242
- * tokenSecret: '',
243
- * });
244
- * @throws {ApplicationNotAuthenticatedError}
245
- * @throws {AuthenticationError}
246
- * @throws {LoginTimeoutError}
247
- * @throws {LoginFreezeError}
248
- * @throws {TooManyFailedAttemptsError}
249
- * @throws {MfaRequiredError}
250
- */
251
- authenticate(oauth: {
252
- token: string;
253
- tokenSecret: string;
254
- skipTokenCheck?: boolean;
255
- }): Promise<TokenDataOauth1>;
256
- /**
257
- * Use OAuth1 Password authentication
258
- * @example
259
- * await exh.auth.authenticate({
260
- * email: '',
261
- * password: '',
262
- * });
263
- * @throws {ApplicationNotAuthenticatedError}
264
- * @throws {AuthenticationError}
265
- * @throws {LoginTimeoutError}
266
- * @throws {LoginFreezeError}
267
- * @throws {TooManyFailedAttemptsError}
268
- * @throws {MfaRequiredError}
269
- */
270
- authenticate(oauth: {
271
- email: string;
272
- password: string;
273
- }): Promise<TokenDataOauth1>;
274
- /**
275
- * Confirm MFA method with token, methodId and code
276
- * @example
277
- * try {
278
- * await exh.auth.authenticate({
279
- * email: '',
280
- * password: '',
281
- * });
282
- * } catch (error) {
283
- * if (error instanceof MfaRequiredError) {
284
- * const { mfa } = error;
285
- *
286
- * // Your logic to request which method the user want to use in case of multiple methods
287
- * const methodId = mfa.methods[0].id;
288
- *
289
- * await exh.auth.confirmMfa({
290
- * token: mfa.token,
291
- * methodId,
292
- * code: '', // code from ie. Google Authenticator
293
- * });
294
- * }
295
- * }
296
- */
297
- confirmMfa(data: MfaConfig): Promise<TokenDataOauth1>;
298
- /**
299
- * Logout
300
- * @returns {boolean} Success
301
- * @example
302
- * try {
303
- * await exh.auth.authenticate({
304
- * email: '',
305
- * password: '',
306
- * });
307
- * exh.auth.logout();
308
- * } catch (error) {
309
- * console.log(error)
310
- * }
311
- */
312
- logout(): boolean;
313
- };
314
- userId: Promise<string | undefined>;
315
- }
316
- export interface ProxyInstance extends HttpInstance {
317
- extraAuthMethods: {
318
- /**
319
- * Logout
320
- * @returns {boolean} Success
321
- */
322
- logout(): Promise<boolean>;
323
- };
324
- userId: Promise<string | undefined>;
325
- }
326
- export declare type AuthHttpClient = OAuth1HttpClient | OAuth2HttpClient | ProxyInstance;
327
- export interface MfaConfig {
328
- token: string;
329
- methodId: string;
330
- code: string;
331
- }
1
+ import { AxiosError, AxiosInstance, AxiosInterceptorManager, AxiosPromise, AxiosRequestConfig, AxiosResponse } from 'axios';
2
+ export declare type HttpResponse<T = any> = AxiosResponse<T> & {
3
+ config: HttpRequestConfig;
4
+ };
5
+ export declare type HttpRequestConfig = AxiosRequestConfig & {
6
+ interceptors?: {
7
+ skipCamelizeResponseData?: boolean;
8
+ skipTransformResponseData?: boolean;
9
+ skipTransformKeysResponseData?: boolean;
10
+ };
11
+ retry?: {
12
+ tries: number;
13
+ retryTimeInMs: number;
14
+ current: number;
15
+ retryCondition: (error: HttpResponseError) => boolean;
16
+ };
17
+ normalizeCustomData?: boolean;
18
+ customKeys?: string[];
19
+ /**
20
+ * Overrides values provided in {@Link customKeys}
21
+ */
22
+ customRequestKeys?: string[];
23
+ /**
24
+ * Overrides values provided in {@Link customKeys}
25
+ */
26
+ customResponseKeys?: string[];
27
+ };
28
+ export declare type HttpResponseError = AxiosError & {
29
+ config: HttpRequestConfig;
30
+ };
31
+ export interface HttpInstance {
32
+ (config: AxiosRequestConfig): AxiosPromise;
33
+ (url: string, config?: AxiosRequestConfig): AxiosPromise;
34
+ normalizeCustomData?: boolean;
35
+ defaults: AxiosInstance['defaults'];
36
+ interceptors: {
37
+ request: AxiosInterceptorManager<AxiosRequestConfig>;
38
+ response: AxiosInterceptorManager<AxiosResponse>;
39
+ };
40
+ getUri(config?: HttpRequestConfig): string;
41
+ request<T = any, R = AxiosResponse<T>>(config: HttpRequestConfig): Promise<R>;
42
+ get<T = any, R = AxiosResponse<T>>(url: string, config?: HttpRequestConfig): Promise<R>;
43
+ delete<T = any, R = AxiosResponse<T>>(url: string, config?: HttpRequestConfig): Promise<R>;
44
+ head<T = any, R = AxiosResponse<T>>(url: string, config?: HttpRequestConfig): Promise<R>;
45
+ options<T = any, R = AxiosResponse<T>>(url: string, config?: HttpRequestConfig): Promise<R>;
46
+ post<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: HttpRequestConfig): Promise<R>;
47
+ put<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: HttpRequestConfig): Promise<R>;
48
+ patch<T = any, R = AxiosResponse<T>>(url: string, data?: any, config?: HttpRequestConfig): Promise<R>;
49
+ }
50
+ export interface TokenDataOauth2 {
51
+ tokenType: string;
52
+ accessToken: string;
53
+ expiresIn: number;
54
+ refreshToken: string;
55
+ applicationId: string;
56
+ userId: string;
57
+ creationTimestamp: Date;
58
+ }
59
+ export interface TokenDataOauth1 {
60
+ id?: string;
61
+ key: string;
62
+ secret: string;
63
+ token?: string;
64
+ tokenSecret?: string;
65
+ applicationId?: string;
66
+ userId?: string;
67
+ updateTimestamp?: Date;
68
+ creationTimestamp?: Date;
69
+ }
70
+ export interface OidcAuthenticationUrlRequest {
71
+ /** The state parameter to be included in the authentication URL */
72
+ state?: string;
73
+ }
74
+ export interface OidcAuthenticationUrl {
75
+ /** The authentication URL the user should be directed to */
76
+ authenticationUrl: string;
77
+ }
78
+ export interface OidcAuthenticateRequest {
79
+ /** The authorizationCode received from the provider via the redirect after the user authenticated with the provider */
80
+ authorizationCode: string;
81
+ }
82
+ export interface OAuth2HttpClient extends HttpInstance {
83
+ extraAuthMethods: {
84
+ /**
85
+ * Use OAuth2 Authorization Code Grant flow with callback
86
+ * @example
87
+ * await exh.auth.authenticate({
88
+ * code: '',
89
+ * });
90
+ * @throws {InvalidRequestError}
91
+ * @throws {InvalidGrantError}
92
+ * @throws {UnsupportedGrantTypeError}
93
+ * @throws {MfaRequiredError}
94
+ * @throws {InvalidClientError}
95
+ */
96
+ authenticate(oauth: {
97
+ code: string;
98
+ }): Promise<TokenDataOauth2>;
99
+ /**
100
+ * Use OAuth2 Password Grant flow
101
+ * @example
102
+ * await exh.auth.authenticate({
103
+ * password: '',
104
+ * username: '',
105
+ * });
106
+ * @throws {InvalidRequestError}
107
+ * @throws {InvalidGrantError}
108
+ * @throws {UnsupportedGrantTypeError}
109
+ * @throws {MfaRequiredError}
110
+ * @throws {InvalidClientError}
111
+ */
112
+ authenticate(oauth: {
113
+ username: string;
114
+ password: string;
115
+ }): Promise<TokenDataOauth2>;
116
+ /**
117
+ * Use OAuth2 Refresh Token Grant flow
118
+ * @example
119
+ * await exh.auth.authenticate({
120
+ * refreshToken: '',
121
+ * });
122
+ * @throws {InvalidRequestError}
123
+ * @throws {InvalidGrantError}
124
+ * @throws {UnsupportedGrantTypeError}
125
+ * @throws {MfaRequiredError}
126
+ * @throws {InvalidClientError}
127
+ */
128
+ authenticate(oauth: {
129
+ refreshToken: string;
130
+ }): Promise<TokenDataOauth2>;
131
+ /**
132
+ * Confirm MFA method with token, methodId and code
133
+ * @example
134
+ * try {
135
+ * await exh.auth.authenticate({
136
+ * username: '',
137
+ * password: '',
138
+ * });
139
+ * } catch (error) {
140
+ * if (error instanceof MfaRequiredError) {
141
+ * const { mfa } = error;
142
+ *
143
+ * // Your logic to request which method the user want to use in case of multiple methods
144
+ * const methodId = mfa.methods[0].id;
145
+ *
146
+ * await exh.auth.confirmMfa({
147
+ * token: mfa.token,
148
+ * methodId,
149
+ * code: '', // code from ie. Google Authenticator
150
+ * });
151
+ * }
152
+ * }
153
+ */
154
+ confirmMfa(data: MfaConfig): Promise<TokenDataOauth2>;
155
+ /**
156
+ * ## Generate an OIDC authentication URL
157
+ * You can use this endpoint to generate a fully configured OIDC authentication URL.
158
+ * You can use the authentication URL to redirect the user to the specified OIDC provider to initiate the authentication process.
159
+ *
160
+ * Once the user is authenticated, the OIDC provider will redirect the user to the configured `redirectUri` with an authorization code.
161
+ * The authorization code can then be used to login (see `auth.authenticateWithOidc()`).
162
+ *
163
+ * A state parameter can be added to the URL.
164
+ * Supply the `state` property to this function and the state parameter will be included in the URL.
165
+ * If supplied, the provider will add the same state parameter and value again to the URL when redirecting the user is back to your application (the configured `redirectUri`).
166
+ * This can (and should) be used to protect against Cross-Site Request Forgery (CSRF) attacks.
167
+ *
168
+ * A `nonce` parameter is automatically added and will be validated during the authorization code exchange by ExH.
169
+ *
170
+ * #### Example URL
171
+ * An example of a fully configured authentication URL: (new lines added for readability)
172
+ * ```txt
173
+ * https://accounts.google.com/o/oauth2/auth
174
+ * ?response_type=code
175
+ * &client_id=123456789-abcdefghijklw.apps.googleusercontent.com
176
+ * &scope=openid%20email%20profile
177
+ * &redirect_uri=https%3A%2F%2Fapi.dev.yourapp.com%2Fcallback
178
+ * &nonce=608c038a830f40d7fe028a3f05c85b84f9040d37
179
+ * ```
180
+ *
181
+ * #### Function details
182
+ * @param providerName The name of the OIDC provider to generate an authentication URL for
183
+ * @param data {@link OidcAuthenticationUrlRequest}
184
+ *
185
+ * @returns An object containing the authentication URL
186
+ *
187
+ * @throws {@link IllegalStateError} When targeting a disabled provider. A provider must be enabled to allow users to use this endpoint.
188
+ */
189
+ generateOidcAuthenticationUrl(providerName: string, data?: OidcAuthenticationUrlRequest): Promise<OidcAuthenticationUrl>;
190
+ /**
191
+ * ## Authenticate a user with OIDC
192
+ * You can use this method to authenticate a user after obtaining a authorization code from an OIDC provider.
193
+ * The authorization code is obtained when an OIDC provider redirects a user back to your application after a successful authentication.
194
+ * The authorization code may be URL encoded, so make sure the authorization code is in the correct format before providing it here.
195
+ * See `auth.generateOidcAuthenticationUrl()` to initiate the authentication process.
196
+ *
197
+ * Like the `auth.authenticate()` method, the SDK uses the returned access token and refresh token to authenticate successive requests.
198
+ *
199
+ * All (successful and failed) login attempts are logged. See `auth.oidc.getLoginAttempts()`.
200
+ *
201
+ * #### Function details
202
+ * @param providerName The name of the OIDC provider to login with
203
+ * @param data {@link OidcAuthenticateRequest}
204
+ *
205
+ * @returns The OAuth2 tokens generated for the user.
206
+ *
207
+ * @throws {@link IllegalStateError} When targeting a disabled provider. A provider must be enabled to allow users to use this endpoint.
208
+ * @throws {@link OAuth2MissingClientCredentialsError} When no client credentials are specified or, for a confidential application, the `clientSecret` is missing.
209
+ * @throws {@link OidcProviderResponseError} When the provider is incorrectly configured or the provider gave us an unexpected response. Please check the provider configuration.
210
+ * @throws {@link OidcInvalidAuthorizationCodeError} When the provided `authorizationCode` is not accepted or recognized by the provider.
211
+ * @throws {@link EmailUsedError} When a new ExH account is being created for the user trying to login with an email address which is already in use by an existing ExH account.
212
+ * @throws {@link OAuth2ClientIdError} When the supplied `clientId` could not be found.
213
+ * @throws {@link OAuth2ClientSecretError} When the supplied `clientSecret` is incorrect.
214
+ * @throws {@link OidcIdTokenError} When we understood the response of the provider but the id token returned is invalid.
215
+ */
216
+ authenticateWithOidc(providerName: string, data: OidcAuthenticateRequest): Promise<TokenDataOauth2>;
217
+ /**
218
+ * Logout
219
+ * @returns {boolean} Success
220
+ * @example
221
+ * try {
222
+ * await exh.auth.authenticate({
223
+ * username: '',
224
+ * password: '',
225
+ * });
226
+ * exh.auth.logout();
227
+ * } catch (error) {
228
+ * console.log(error)
229
+ * }
230
+ */
231
+ logout(): boolean;
232
+ };
233
+ userId: Promise<string | undefined>;
234
+ }
235
+ export interface OAuth1HttpClient extends HttpInstance {
236
+ extraAuthMethods: {
237
+ /**
238
+ * Use OAuth1 Token authentication
239
+ * @example
240
+ * await exh.auth.authenticate({
241
+ * token: '',
242
+ * tokenSecret: '',
243
+ * });
244
+ * @throws {ApplicationNotAuthenticatedError}
245
+ * @throws {AuthenticationError}
246
+ * @throws {LoginTimeoutError}
247
+ * @throws {LoginFreezeError}
248
+ * @throws {TooManyFailedAttemptsError}
249
+ * @throws {MfaRequiredError}
250
+ */
251
+ authenticate(oauth: {
252
+ token: string;
253
+ tokenSecret: string;
254
+ skipTokenCheck?: boolean;
255
+ }): Promise<TokenDataOauth1>;
256
+ /**
257
+ * Use OAuth1 Password authentication
258
+ * @example
259
+ * await exh.auth.authenticate({
260
+ * email: '',
261
+ * password: '',
262
+ * });
263
+ * @throws {ApplicationNotAuthenticatedError}
264
+ * @throws {AuthenticationError}
265
+ * @throws {LoginTimeoutError}
266
+ * @throws {LoginFreezeError}
267
+ * @throws {TooManyFailedAttemptsError}
268
+ * @throws {MfaRequiredError}
269
+ */
270
+ authenticate(oauth: {
271
+ email: string;
272
+ password: string;
273
+ }): Promise<TokenDataOauth1>;
274
+ /**
275
+ * Confirm MFA method with token, methodId and code
276
+ * @example
277
+ * try {
278
+ * await exh.auth.authenticate({
279
+ * email: '',
280
+ * password: '',
281
+ * });
282
+ * } catch (error) {
283
+ * if (error instanceof MfaRequiredError) {
284
+ * const { mfa } = error;
285
+ *
286
+ * // Your logic to request which method the user want to use in case of multiple methods
287
+ * const methodId = mfa.methods[0].id;
288
+ *
289
+ * await exh.auth.confirmMfa({
290
+ * token: mfa.token,
291
+ * methodId,
292
+ * code: '', // code from ie. Google Authenticator
293
+ * });
294
+ * }
295
+ * }
296
+ */
297
+ confirmMfa(data: MfaConfig): Promise<TokenDataOauth1>;
298
+ /**
299
+ * Logout
300
+ * @returns {boolean} Success
301
+ * @example
302
+ * try {
303
+ * await exh.auth.authenticate({
304
+ * email: '',
305
+ * password: '',
306
+ * });
307
+ * exh.auth.logout();
308
+ * } catch (error) {
309
+ * console.log(error)
310
+ * }
311
+ */
312
+ logout(): boolean;
313
+ };
314
+ userId: Promise<string | undefined>;
315
+ }
316
+ export interface ProxyInstance extends HttpInstance {
317
+ extraAuthMethods: {
318
+ /**
319
+ * Logout
320
+ * @returns {boolean} Success
321
+ */
322
+ logout(): Promise<boolean>;
323
+ };
324
+ userId: Promise<string | undefined>;
325
+ }
326
+ export declare type AuthHttpClient = OAuth1HttpClient | OAuth2HttpClient | ProxyInstance;
327
+ export interface MfaConfig {
328
+ token: string;
329
+ methodId: string;
330
+ code: string;
331
+ }