@extrahorizon/javascript-sdk 8.2.0-test
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1161 -0
- package/LICENSE +21 -0
- package/README.md +119 -0
- package/build/index.cjs.js +1 -0
- package/build/index.mjs +1 -0
- package/build/types/btoa.d.ts +6 -0
- package/build/types/client.d.ts +136 -0
- package/build/types/constants.d.ts +15 -0
- package/build/types/errorHandler.d.ts +2 -0
- package/build/types/errors.d.ts +332 -0
- package/build/types/http/client.d.ts +2 -0
- package/build/types/http/index.d.ts +4 -0
- package/build/types/http/interceptors.d.ts +9 -0
- package/build/types/http/oAuth1Signature.d.ts +14 -0
- package/build/types/http/oauth1.d.ts +3 -0
- package/build/types/http/oauth2.d.ts +3 -0
- package/build/types/http/proxy.d.ts +3 -0
- package/build/types/http/types.d.ts +331 -0
- package/build/types/http/utils.d.ts +21 -0
- package/build/types/index.d.ts +9 -0
- package/build/types/mock.d.ts +43 -0
- package/build/types/mockType.d.ts +1511 -0
- package/build/types/parseStoredCredentials.d.ts +11 -0
- package/build/types/rql/index.d.ts +16 -0
- package/build/types/rql/parser.d.ts +1 -0
- package/build/types/rql/types.d.ts +168 -0
- package/build/types/services/auth/applications/index.d.ts +5 -0
- package/build/types/services/auth/applications/types.d.ts +190 -0
- package/build/types/services/auth/index.d.ts +3 -0
- package/build/types/services/auth/oauth1/index.d.ts +5 -0
- package/build/types/services/auth/oauth1/types.d.ts +63 -0
- package/build/types/services/auth/oauth2/index.d.ts +5 -0
- package/build/types/services/auth/oauth2/types.d.ts +52 -0
- package/build/types/services/auth/oidc/index.d.ts +5 -0
- package/build/types/services/auth/oidc/loginAttempts/index.d.ts +5 -0
- package/build/types/services/auth/oidc/loginAttempts/types.d.ts +67 -0
- package/build/types/services/auth/oidc/providers/index.d.ts +5 -0
- package/build/types/services/auth/oidc/providers/types.d.ts +144 -0
- package/build/types/services/auth/oidc/types.d.ts +40 -0
- package/build/types/services/auth/types.d.ts +39 -0
- package/build/types/services/auth/users/index.d.ts +5 -0
- package/build/types/services/auth/users/types.d.ts +121 -0
- package/build/types/services/configurations/general.d.ts +5 -0
- package/build/types/services/configurations/groups.d.ts +5 -0
- package/build/types/services/configurations/index.d.ts +10 -0
- package/build/types/services/configurations/patients.d.ts +5 -0
- package/build/types/services/configurations/staff.d.ts +5 -0
- package/build/types/services/configurations/types.d.ts +222 -0
- package/build/types/services/configurations/users.d.ts +5 -0
- package/build/types/services/data/comments.d.ts +5 -0
- package/build/types/services/data/documents.d.ts +5 -0
- package/build/types/services/data/index.d.ts +13 -0
- package/build/types/services/data/indexes.d.ts +5 -0
- package/build/types/services/data/infrastructure.d.ts +10 -0
- package/build/types/services/data/json-schema.d.ts +121 -0
- package/build/types/services/data/properties.d.ts +5 -0
- package/build/types/services/data/schemas.d.ts +5 -0
- package/build/types/services/data/statuses.d.ts +5 -0
- package/build/types/services/data/transitions.d.ts +5 -0
- package/build/types/services/data/types.d.ts +899 -0
- package/build/types/services/dispatchers/actions/index.d.ts +5 -0
- package/build/types/services/dispatchers/actions/types.d.ts +78 -0
- package/build/types/services/dispatchers/dispatchers/index.d.ts +5 -0
- package/build/types/services/dispatchers/dispatchers/types.d.ts +111 -0
- package/build/types/services/dispatchers/index.d.ts +7 -0
- package/build/types/services/dispatchers/types.d.ts +2 -0
- package/build/types/services/events/events.d.ts +5 -0
- package/build/types/services/events/health.d.ts +9 -0
- package/build/types/services/events/index.d.ts +6 -0
- package/build/types/services/events/subscriptions.d.ts +5 -0
- package/build/types/services/events/types.d.ts +90 -0
- package/build/types/services/files/files.d.ts +5 -0
- package/build/types/services/files/formHelpers.d.ts +3 -0
- package/build/types/services/files/index.d.ts +6 -0
- package/build/types/services/files/settings/index.d.ts +5 -0
- package/build/types/services/files/settings/types.d.ts +38 -0
- package/build/types/services/files/tokens.d.ts +5 -0
- package/build/types/services/files/types.d.ts +185 -0
- package/build/types/services/helpers.d.ts +7 -0
- package/build/types/services/http-client.d.ts +22 -0
- package/build/types/services/index.d.ts +15 -0
- package/build/types/services/localizations/countries.d.ts +5 -0
- package/build/types/services/localizations/health.d.ts +9 -0
- package/build/types/services/localizations/index.d.ts +4 -0
- package/build/types/services/localizations/languages.d.ts +5 -0
- package/build/types/services/localizations/localizations.d.ts +5 -0
- package/build/types/services/localizations/types.d.ts +145 -0
- package/build/types/services/logs/access/index.d.ts +5 -0
- package/build/types/services/logs/access/types.d.ts +41 -0
- package/build/types/services/logs/index.d.ts +3 -0
- package/build/types/services/logs/types.d.ts +4 -0
- package/build/types/services/mails/index.d.ts +3 -0
- package/build/types/services/mails/mails.d.ts +5 -0
- package/build/types/services/mails/types.d.ts +141 -0
- package/build/types/services/notifications/health.d.ts +9 -0
- package/build/types/services/notifications/index.d.ts +7 -0
- package/build/types/services/notifications/notifications.d.ts +5 -0
- package/build/types/services/notifications/settings.d.ts +5 -0
- package/build/types/services/notifications/types.d.ts +222 -0
- package/build/types/services/payments/appStore.d.ts +5 -0
- package/build/types/services/payments/appStoreSubscriptions.d.ts +5 -0
- package/build/types/services/payments/health.d.ts +9 -0
- package/build/types/services/payments/index.d.ts +15 -0
- package/build/types/services/payments/orders.d.ts +5 -0
- package/build/types/services/payments/playStore.d.ts +5 -0
- package/build/types/services/payments/playStoreHistory.d.ts +5 -0
- package/build/types/services/payments/playStoreSubscriptions.d.ts +5 -0
- package/build/types/services/payments/products.d.ts +5 -0
- package/build/types/services/payments/stripe.d.ts +5 -0
- package/build/types/services/payments/subscriptions.d.ts +5 -0
- package/build/types/services/payments/types.d.ts +1189 -0
- package/build/types/services/profiles/groups.d.ts +5 -0
- package/build/types/services/profiles/health.d.ts +9 -0
- package/build/types/services/profiles/index.d.ts +9 -0
- package/build/types/services/profiles/logs.d.ts +5 -0
- package/build/types/services/profiles/profiles.d.ts +5 -0
- package/build/types/services/profiles/types.d.ts +369 -0
- package/build/types/services/tasks/api/index.d.ts +5 -0
- package/build/types/services/tasks/api/types.d.ts +146 -0
- package/build/types/services/tasks/apiRequests/index.d.ts +5 -0
- package/build/types/services/tasks/apiRequests/logs/index.d.ts +5 -0
- package/build/types/services/tasks/apiRequests/logs/types.d.ts +25 -0
- package/build/types/services/tasks/apiRequests/types.d.ts +83 -0
- package/build/types/services/tasks/functions/index.d.ts +5 -0
- package/build/types/services/tasks/functions/types.d.ts +27 -0
- package/build/types/services/tasks/index.d.ts +15 -0
- package/build/types/services/tasks/logs/index.d.ts +5 -0
- package/build/types/services/tasks/logs/types.d.ts +28 -0
- package/build/types/services/tasks/schedules/index.d.ts +5 -0
- package/build/types/services/tasks/schedules/types.d.ts +88 -0
- package/build/types/services/tasks/tasks.d.ts +5 -0
- package/build/types/services/tasks/types.d.ts +107 -0
- package/build/types/services/templates/index.d.ts +3 -0
- package/build/types/services/templates/templates.d.ts +5 -0
- package/build/types/services/templates/types.d.ts +202 -0
- package/build/types/services/types.d.ts +77 -0
- package/build/types/services/users/activationRequests/index.d.ts +4 -0
- package/build/types/services/users/activationRequests/types.d.ts +70 -0
- package/build/types/services/users/forgotPasswordRequests/index.d.ts +4 -0
- package/build/types/services/users/forgotPasswordRequests/types.d.ts +70 -0
- package/build/types/services/users/globalRoles.d.ts +5 -0
- package/build/types/services/users/groupRoles.d.ts +5 -0
- package/build/types/services/users/health.d.ts +9 -0
- package/build/types/services/users/index.d.ts +16 -0
- package/build/types/services/users/settings/index.d.ts +4 -0
- package/build/types/services/users/settings/types.d.ts +47 -0
- package/build/types/services/users/types.d.ts +1055 -0
- package/build/types/services/users/users.d.ts +5 -0
- package/build/types/sha1.d.ts +11 -0
- package/build/types/types.d.ts +102 -0
- package/build/types/utils.d.ts +4 -0
- package/build/types/version.d.ts +1 -0
- package/package.json +57 -0
|
@@ -0,0 +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
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare function mapObjIndexed(fn: any, object: any): Record<string, unknown>;
|
|
2
|
+
export declare const recursiveMap: (fn: any, obj: any, ignoreKeys?: any[], skipData?: boolean) => any;
|
|
3
|
+
/**
|
|
4
|
+
* Recursively renames keys in an object using a provided function.
|
|
5
|
+
* @param fn A function that takes a string (key) and returns a string (new key).
|
|
6
|
+
* @param obj The object to rename they keys in.
|
|
7
|
+
* @param ignoreKeys An array of keys to ignore during the renaming process.
|
|
8
|
+
* @returns An object with keys renamed according to the provided function.
|
|
9
|
+
*/
|
|
10
|
+
export declare function recursiveRenameKeys(fn: {
|
|
11
|
+
(arg: string): string;
|
|
12
|
+
}, obj: any, ignoreKeys?: string[]): any;
|
|
13
|
+
export declare function camelize(string: string): string;
|
|
14
|
+
export declare function decamelize(string: string): string;
|
|
15
|
+
export declare function camelizeKeys(object: Record<string, unknown>, ignoreKeys?: string[]): Record<string, unknown>;
|
|
16
|
+
export declare function decamelizeKeys(object: Record<string, unknown>, ignoreKeys?: string[]): Record<string, unknown>;
|
|
17
|
+
/**
|
|
18
|
+
* Composes a `User-Agent` like header value which looks something like
|
|
19
|
+
* `'Node/14.4.0 SDK/3.0.0'`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function composeUserAgent(packageVersion: string): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { rqlBuilder, rqlParser, RQLString } from './rql';
|
|
2
|
+
export * from './errors';
|
|
3
|
+
export * from './types';
|
|
4
|
+
export { recursiveMap } from './http/utils';
|
|
5
|
+
export { parseGlobalPermissions } from './utils';
|
|
6
|
+
export { findAllGeneric, findAllIterator } from './services/helpers';
|
|
7
|
+
export { getMockSdkOAuth1, getMockSdkOAuth2, getMockSdkProxy, getMockSdkOAuth2 as getMockSdk, } from './mock';
|
|
8
|
+
export { createClient, createOAuth1Client, createOAuth2Client, createProxyClient, Client, OAuth1Client, OAuth2Client, ProxyClient, } from './client';
|
|
9
|
+
export { parseStoredCredentials, ExHCredentials, } from './parseStoredCredentials';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { MockClientOAuth1, MockClientOAuth2, MockClientProxy } from './mockType';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a mocked version of the Proxy SDK. Requires a mocking function like `jest.fn`
|
|
4
|
+
* @param fn mocking function
|
|
5
|
+
* @returns {MockClientProxy} mockSdk
|
|
6
|
+
* @example
|
|
7
|
+
* import { getMockSdkProxy } from "@extrahorizon/javascript-sdk";
|
|
8
|
+
* describe("mock SDK", () => {
|
|
9
|
+
* const exh = getMockSdkProxy(jest.fn);
|
|
10
|
+
* it("should be valid mock", async () => {
|
|
11
|
+
* expect(exh.data).toBeDefined();
|
|
12
|
+
* });
|
|
13
|
+
* });
|
|
14
|
+
*/
|
|
15
|
+
export declare const getMockSdkProxy: <MockFn>(fn: () => MockFn) => MockClientProxy<MockFn>;
|
|
16
|
+
/**
|
|
17
|
+
* Returns a mocked version of the OAuth2 SDK. Requires a mocking function like `jest.fn`
|
|
18
|
+
* @param fn mocking function
|
|
19
|
+
* @returns {MockClientOAuth2} mockSdk
|
|
20
|
+
* @example
|
|
21
|
+
* import { getMockSdkOAuth2 } from "@extrahorizon/javascript-sdk";
|
|
22
|
+
* describe("mock SDK", () => {
|
|
23
|
+
* const exh = getMockSdkOAuth2(jest.fn);
|
|
24
|
+
* it("should be valid mock", async () => {
|
|
25
|
+
* expect(exh.data).toBeDefined();
|
|
26
|
+
* });
|
|
27
|
+
* });
|
|
28
|
+
*/
|
|
29
|
+
export declare const getMockSdkOAuth2: <MockFn>(fn: () => MockFn) => MockClientOAuth2<MockFn>;
|
|
30
|
+
/**
|
|
31
|
+
* Returns a mocked version of the OAuth1 SDK. Requires a mocking function like `jest.fn`
|
|
32
|
+
* @param fn mocking function
|
|
33
|
+
* @returns {MockClientOAuth1} mockSdk
|
|
34
|
+
* @example
|
|
35
|
+
* import { getMockSdkOAuth1 } from "@extrahorizon/javascript-sdk";
|
|
36
|
+
* describe("mock SDK", () => {
|
|
37
|
+
* const exh = getMockSdkOAuth1(jest.fn);
|
|
38
|
+
* it("should be valid mock", async () => {
|
|
39
|
+
* expect(exh.data).toBeDefined();
|
|
40
|
+
* });
|
|
41
|
+
* });
|
|
42
|
+
*/
|
|
43
|
+
export declare const getMockSdkOAuth1: <MockFn>(fn: () => MockFn) => MockClientOAuth1<MockFn>;
|