@asgardeo/javascript 0.0.1

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 (57) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +57 -0
  3. package/dist/AsgardeoJavaScriptClient.d.ts +81 -0
  4. package/dist/IsomorphicCrypto.d.ts +73 -0
  5. package/dist/__legacy__/client.d.ts +488 -0
  6. package/dist/__legacy__/core/authentication-core.d.ts +51 -0
  7. package/dist/__legacy__/core/index.d.ts +18 -0
  8. package/dist/__legacy__/data/data-layer.d.ts +64 -0
  9. package/dist/__legacy__/data/index.d.ts +18 -0
  10. package/dist/__legacy__/exception/exception.d.ts +23 -0
  11. package/dist/__legacy__/exception/index.d.ts +18 -0
  12. package/dist/__legacy__/helpers/authentication-helper.d.ts +37 -0
  13. package/dist/__legacy__/helpers/index.d.ts +18 -0
  14. package/dist/__legacy__/models/authorization-url.d.ts +23 -0
  15. package/dist/__legacy__/models/client-config.d.ts +60 -0
  16. package/dist/__legacy__/models/custom-grant.d.ts +26 -0
  17. package/dist/__legacy__/models/data.d.ts +27 -0
  18. package/dist/__legacy__/models/fetch.d.ts +55 -0
  19. package/dist/__legacy__/models/index.d.ts +23 -0
  20. package/dist/__legacy__/models/user.d.ts +85 -0
  21. package/dist/api/oidc/getUserInfo.d.ts +37 -0
  22. package/dist/cjs/index.js +2227 -0
  23. package/dist/cjs/index.js.map +7 -0
  24. package/dist/constants/OIDCDiscoveryConstants.d.ts +153 -0
  25. package/dist/constants/OIDCRequestConstants.d.ts +66 -0
  26. package/dist/constants/PKCEConstants.d.ts +58 -0
  27. package/dist/constants/ScopeConstants.d.ts +45 -0
  28. package/dist/constants/TokenConstants.d.ts +76 -0
  29. package/dist/constants/TokenExchangeConstants.d.ts +68 -0
  30. package/dist/errors/AsgardeoAPIError.d.ts +52 -0
  31. package/dist/errors/AsgardeoError.d.ts +49 -0
  32. package/dist/errors/AsgardeoRuntimeError.d.ts +50 -0
  33. package/dist/index.d.ts +45 -0
  34. package/dist/index.js +2186 -0
  35. package/dist/index.js.map +7 -0
  36. package/dist/models/client.d.ts +84 -0
  37. package/dist/models/config.d.ts +81 -0
  38. package/dist/models/crypto.d.ts +100 -0
  39. package/dist/models/id-token.d.ts +55 -0
  40. package/dist/models/oauth-response.d.ts +34 -0
  41. package/dist/models/oidc-discovery.d.ts +369 -0
  42. package/dist/models/oidc-endpoints.d.ts +70 -0
  43. package/dist/models/scim2-schema.d.ts +62 -0
  44. package/dist/models/store.d.ts +81 -0
  45. package/dist/models/token.d.ts +121 -0
  46. package/dist/models/user.d.ts +106 -0
  47. package/dist/models/utility-types.d.ts +20 -0
  48. package/dist/theme/createTheme.d.ts +21 -0
  49. package/dist/theme/types.d.ts +59 -0
  50. package/dist/utils/cryptoUtils.d.ts +0 -0
  51. package/dist/utils/extractPkceStorageKeyFromState.d.ts +32 -0
  52. package/dist/utils/extractTenantDomainFromIdTokenPayload.d.ts +31 -0
  53. package/dist/utils/extractUserClaimsFromIdToken.d.ts +44 -0
  54. package/dist/utils/generatePkceStorageKey.d.ts +34 -0
  55. package/dist/utils/generateStateParamForRequestCorrelation.d.ts +34 -0
  56. package/dist/utils/removeTrailingSlash.d.ts +31 -0
  57. package/package.json +61 -0
@@ -0,0 +1,488 @@
1
+ /**
2
+ * Copyright (c) 2020, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ import { DataLayer } from './data';
19
+ import { AuthClientConfig, BasicUserInfo, CustomGrantConfig, FetchResponse, GetAuthURLConfig } from './models';
20
+ import { Crypto } from '../models/crypto';
21
+ import { TokenResponse } from '../models/token';
22
+ import { IdTokenPayload } from '../models/id-token';
23
+ import { OIDCEndpoints } from '../models/oidc-endpoints';
24
+ import { Store } from '../models/store';
25
+ import { IsomorphicCrypto } from '../IsomorphicCrypto';
26
+ /**
27
+ * This class provides the necessary methods needed to implement authentication.
28
+ */
29
+ export declare class AsgardeoAuthClient<T> {
30
+ private _dataLayer;
31
+ private _authenticationCore;
32
+ private static _instanceID;
33
+ static _authenticationCore: any;
34
+ /**
35
+ * This is the constructor method that returns an instance of the .
36
+ *
37
+ * @param store - The store object.
38
+ *
39
+ * @example
40
+ * ```
41
+ * const _store: Store = new DataStore();
42
+ * const auth = new AsgardeoAuthClient<CustomClientConfig>(_store);
43
+ * ```
44
+ *
45
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#constructor}
46
+ *
47
+ * @preserve
48
+ */
49
+ constructor();
50
+ /**
51
+ *
52
+ * This method initializes the SDK with the config data.
53
+ *
54
+ * @param config - The config object to initialize with.
55
+ *
56
+ * @example
57
+ * const config = \{
58
+ * signInRedirectURL: "http://localhost:3000/sign-in",
59
+ * clientID: "client ID",
60
+ * baseUrl: "https://localhost:9443"
61
+ * \}
62
+ *
63
+ * await auth.initialize(config);
64
+ *
65
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#initialize}
66
+ *
67
+ * @preserve
68
+ */
69
+ initialize(config: AuthClientConfig<T>, store: Store, cryptoUtils: Crypto, instanceID?: number): Promise<void>;
70
+ /**
71
+ * This method returns the `DataLayer` object that allows you to access authentication data.
72
+ *
73
+ * @returns - The `DataLayer` object.
74
+ *
75
+ * @example
76
+ * ```
77
+ * const data = auth.getDataLayer();
78
+ * ```
79
+ *
80
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getDataLayer}
81
+ *
82
+ * @preserve
83
+ */
84
+ getDataLayer(): DataLayer<T>;
85
+ /**
86
+ * This method returns the `instanceID` variable of the given instance.
87
+ *
88
+ * @returns - The `instanceID` number.
89
+ *
90
+ * @example
91
+ * ```
92
+ * const instanceId = auth.getInstanceID();
93
+ * ```
94
+ *
95
+ * @preserve
96
+ */
97
+ getInstanceID(): number;
98
+ /**
99
+ * This is an async method that returns a Promise that resolves with the authorization URL parameters.
100
+ *
101
+ * @param config - (Optional) A config object to force initialization and pass
102
+ * custom path parameters such as the `fidp` parameter.
103
+ * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
104
+ * scenarios where each user should be uniquely identified.
105
+ *
106
+ * @returns - A promise that resolves with the authorization URL parameters.
107
+ *
108
+ * @example
109
+ * ```
110
+ * auth.getAuthorizationURLParams().then((params)=>{
111
+ * // console.log(params);
112
+ * }).catch((error)=>{
113
+ * // console.error(error);
114
+ * });
115
+ * ```
116
+ *
117
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getAuthorizationURLParams}
118
+ *
119
+ * @preserve
120
+ */
121
+ getAuthorizationURLParams(config?: GetAuthURLConfig, userID?: string): Promise<Map<string, string>>;
122
+ /**
123
+ * This is an async method that returns a Promise that resolves with the authorization URL.
124
+ *
125
+ * @param config - (Optional) A config object to force initialization and pass
126
+ * custom path parameters such as the fidp parameter.
127
+ * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
128
+ * scenarios where each user should be uniquely identified.
129
+ *
130
+ * @returns - A promise that resolves with the authorization URL.
131
+ *
132
+ * @example
133
+ * ```
134
+ * auth.getAuthorizationURL().then((url)=>{
135
+ * // console.log(url);
136
+ * }).catch((error)=>{
137
+ * // console.error(error);
138
+ * });
139
+ * ```
140
+ *
141
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getAuthorizationURL}
142
+ *
143
+ * @preserve
144
+ */
145
+ getAuthorizationURL(config?: GetAuthURLConfig, userID?: string): Promise<string>;
146
+ /**
147
+ * This is an async method that sends a request to obtain the access token and returns a Promise
148
+ * that resolves with the token and other relevant data.
149
+ *
150
+ * @param authorizationCode - The authorization code.
151
+ * @param sessionState - The session state.
152
+ * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
153
+ * scenarios where each user should be uniquely identified.
154
+ *
155
+ * @returns - A Promise that resolves with the token response.
156
+ *
157
+ * @example
158
+ * ```
159
+ * auth.requestAccessToken(authCode, sessionState).then((token)=>{
160
+ * // console.log(token);
161
+ * }).catch((error)=>{
162
+ * // console.error(error);
163
+ * });
164
+ * ```
165
+ *
166
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#requestAccessToken}
167
+ *
168
+ *
169
+ * @preserve
170
+ */
171
+ requestAccessToken(authorizationCode: string, sessionState: string, state: string, userID?: string, tokenRequestConfig?: {
172
+ params: Record<string, unknown>;
173
+ }): Promise<TokenResponse>;
174
+ /**
175
+ * This method returns the sign-out URL.
176
+ *
177
+ * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
178
+ * scenarios where each user should be uniquely identified.
179
+ *
180
+ * **This doesn't clear the authentication data.**
181
+ *
182
+ * @returns - A Promise that resolves with the sign-out URL.
183
+ *
184
+ * @example
185
+ * ```
186
+ * const signOutUrl = await auth.getSignOutURL();
187
+ * ```
188
+ *
189
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getSignOutURL}
190
+ *
191
+ * @preserve
192
+ */
193
+ getSignOutURL(userID?: string): Promise<string>;
194
+ /**
195
+ * This method returns OIDC service endpoints that are fetched from the `.well-known` endpoint.
196
+ *
197
+ * @returns - A Promise that resolves with an object containing the OIDC service endpoints.
198
+ *
199
+ * @example
200
+ * ```
201
+ * const endpoints = await auth.getOIDCServiceEndpoints();
202
+ * ```
203
+ *
204
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getOIDCServiceEndpoints}
205
+ *
206
+ * @preserve
207
+ */
208
+ getOIDCServiceEndpoints(): Promise<Partial<OIDCEndpoints>>;
209
+ /**
210
+ * This method decodes the payload of the ID token and returns it.
211
+ *
212
+ * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
213
+ * scenarios where each user should be uniquely identified.
214
+ *
215
+ * @returns - A Promise that resolves with the decoded ID token payload.
216
+ *
217
+ * @example
218
+ * ```
219
+ * const decodedIdToken = await auth.getDecodedIDToken();
220
+ * ```
221
+ *
222
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getDecodedIDToken}
223
+ *
224
+ * @preserve
225
+ */
226
+ getDecodedIDToken(userID?: string): Promise<IdTokenPayload>;
227
+ /**
228
+ * This method returns the ID token.
229
+ *
230
+ * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
231
+ * scenarios where each user should be uniquely identified.
232
+ *
233
+ * @returns - A Promise that resolves with the ID token.
234
+ *
235
+ * @example
236
+ * ```
237
+ * const idToken = await auth.getIDToken();
238
+ * ```
239
+ *
240
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getIDToken}
241
+ *
242
+ * @preserve
243
+ */
244
+ getIDToken(userID?: string): Promise<string>;
245
+ /**
246
+ * This method returns the basic user information obtained from the ID token.
247
+ *
248
+ * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
249
+ * scenarios where each user should be uniquely identified.
250
+ *
251
+ * @returns - A Promise that resolves with an object containing the basic user information.
252
+ *
253
+ * @example
254
+ * ```
255
+ * const userInfo = await auth.getBasicUserInfo();
256
+ * ```
257
+ *
258
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getBasicUserInfo}
259
+ *
260
+ * @preserve
261
+ */
262
+ getBasicUserInfo(userID?: string): Promise<BasicUserInfo>;
263
+ /**
264
+ * This method returns the crypto helper object.
265
+ *
266
+ * @returns - A Promise that resolves with a IsomorphicCrypto object.
267
+ *
268
+ * @example
269
+ * ```
270
+ * const cryptoHelper = await auth.IsomorphicCrypto();
271
+ * ```
272
+ *
273
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getCryptoHelper}
274
+ *
275
+ * @preserve
276
+ */
277
+ getCryptoHelper(): Promise<IsomorphicCrypto>;
278
+ /**
279
+ * This method revokes the access token.
280
+ *
281
+ * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
282
+ * scenarios where each user should be uniquely identified.
283
+ *
284
+ * **This method also clears the authentication data.**
285
+ *
286
+ * @returns - A Promise that returns the response of the revoke-access-token request.
287
+ *
288
+ * @example
289
+ * ```
290
+ * auth.revokeAccessToken().then((response)=>{
291
+ * // console.log(response);
292
+ * }).catch((error)=>{
293
+ * // console.error(error);
294
+ * });
295
+ * ```
296
+ *
297
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#revokeAccessToken}
298
+ *
299
+ * @preserve
300
+ */
301
+ revokeAccessToken(userID?: string): Promise<FetchResponse>;
302
+ /**
303
+ * This method refreshes the access token and returns a Promise that resolves with the new access
304
+ * token and other relevant data.
305
+ *
306
+ * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
307
+ * scenarios where each user should be uniquely identified.
308
+ *
309
+ * @returns - A Promise that resolves with the token response.
310
+ *
311
+ * @example
312
+ * ```
313
+ * auth.refreshAccessToken().then((response)=>{
314
+ * // console.log(response);
315
+ * }).catch((error)=>{
316
+ * // console.error(error);
317
+ * });
318
+ * ```
319
+ *
320
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#refreshAccessToken}
321
+ *
322
+ * @preserve
323
+ */
324
+ refreshAccessToken(userID?: string): Promise<TokenResponse>;
325
+ /**
326
+ * This method returns the access token.
327
+ *
328
+ * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
329
+ * scenarios where each user should be uniquely identified.
330
+ *
331
+ * @returns - A Promise that resolves with the access token.
332
+ *
333
+ * @example
334
+ * ```
335
+ * const accessToken = await auth.getAccessToken();
336
+ * ```
337
+ *
338
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getAccessToken}
339
+ *
340
+ * @preserve
341
+ */
342
+ getAccessToken(userID?: string): Promise<string>;
343
+ /**
344
+ * This method sends a custom-grant request and returns a Promise that resolves with the response
345
+ * depending on the config passed.
346
+ *
347
+ * @param config - A config object containing the custom grant configurations.
348
+ * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
349
+ * scenarios where each user should be uniquely identified.
350
+ *
351
+ * @returns - A Promise that resolves with the response depending
352
+ * on your configurations.
353
+ *
354
+ * @example
355
+ * ```
356
+ * const config = {
357
+ * attachToken: false,
358
+ * data: {
359
+ * client_id: "{{clientID}}",
360
+ * grant_type: "account_switch",
361
+ * scope: "{{scope}}",
362
+ * token: "{{token}}",
363
+ * },
364
+ * id: "account-switch",
365
+ * returnResponse: true,
366
+ * returnsSession: true,
367
+ * signInRequired: true
368
+ * }
369
+ *
370
+ * auth.requestCustomGrant(config).then((response)=>{
371
+ * // console.log(response);
372
+ * }).catch((error)=>{
373
+ * // console.error(error);
374
+ * });
375
+ * ```
376
+ *
377
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#requestCustomGrant}
378
+ *
379
+ * @preserve
380
+ */
381
+ requestCustomGrant(config: CustomGrantConfig, userID?: string): Promise<TokenResponse | FetchResponse>;
382
+ /**
383
+ * This method returns if the user is authenticated or not.
384
+ *
385
+ * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
386
+ * scenarios where each user should be uniquely identified.
387
+ *
388
+ * @returns - A Promise that resolves with `true` if the user is authenticated, `false` otherwise.
389
+ *
390
+ * @example
391
+ * ```
392
+ * await auth.isAuthenticated();
393
+ * ```
394
+ *
395
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#isAuthenticated}
396
+ *
397
+ * @preserve
398
+ */
399
+ isAuthenticated(userID?: string): Promise<boolean>;
400
+ /**
401
+ * This method returns the PKCE code generated during the generation of the authentication URL.
402
+ *
403
+ * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
404
+ * scenarios where each user should be uniquely identified.
405
+ * @param state - The state parameter that was passed in the authentication URL.
406
+ *
407
+ * @returns - A Promise that resolves with the PKCE code.
408
+ *
409
+ * @example
410
+ * ```
411
+ * const pkce = await getPKCECode();
412
+ * ```
413
+ *
414
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getPKCECode}
415
+ *
416
+ * @preserve
417
+ */
418
+ getPKCECode(state: string, userID?: string): Promise<string>;
419
+ /**
420
+ * This method sets the PKCE code to the data store.
421
+ *
422
+ * @param pkce - The PKCE code.
423
+ * @param state - The state parameter that was passed in the authentication URL.
424
+ * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
425
+ * scenarios where each user should be uniquely identified.
426
+ *
427
+ * @example
428
+ * ```
429
+ * await auth.setPKCECode("pkce_code")
430
+ * ```
431
+ *
432
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#setPKCECode}
433
+ *
434
+ * @preserve
435
+ */
436
+ setPKCECode(pkce: string, state: string, userID?: string): Promise<void>;
437
+ /**
438
+ * This method returns if the sign-out is successful or not.
439
+ *
440
+ * @param signOutRedirectUrl - The URL to which the user has been redirected to after signing-out.
441
+ *
442
+ * **The server appends path parameters to the `signOutRedirectURL` and these path parameters
443
+ * are required for this method to function.**
444
+ *
445
+ * @returns - `true` if successful, `false` otherwise.
446
+ *
447
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#isSignOutSuccessful}
448
+ *
449
+ * @preserve
450
+ */
451
+ static isSignOutSuccessful(signOutRedirectURL: string): boolean;
452
+ /**
453
+ * This method returns if the sign-out has failed or not.
454
+ *
455
+ * @param signOutRedirectUrl - The URL to which the user has been redirected to after signing-out.
456
+ *
457
+ * **The server appends path parameters to the `signOutRedirectURL` and these path parameters
458
+ * are required for this method to function.**
459
+ *
460
+ * @returns - `true` if successful, `false` otherwise.
461
+ *
462
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#didSignOutFail}
463
+ *
464
+ * @preserve
465
+ */
466
+ static didSignOutFail(signOutRedirectURL: string): boolean;
467
+ /**
468
+ * This method updates the configuration that was passed into the constructor when instantiating this class.
469
+ *
470
+ * @param config - A config object to update the SDK configurations with.
471
+ *
472
+ * @example
473
+ * ```
474
+ * const config = {
475
+ * signInRedirectURL: "http://localhost:3000/sign-in",
476
+ * clientID: "client ID",
477
+ * baseUrl: "https://localhost:9443"
478
+ * }
479
+ *
480
+ * await auth.updateConfig(config);
481
+ * ```
482
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#updateConfig}
483
+ *
484
+ * @preserve
485
+ */
486
+ updateConfig(config: Partial<AuthClientConfig<T>>): Promise<void>;
487
+ static clearUserSessionData(userID?: string): Promise<void>;
488
+ }
@@ -0,0 +1,51 @@
1
+ import { DataLayer } from '../data';
2
+ import { AuthClientConfig, AuthorizationURLParams, BasicUserInfo, CustomGrantConfig, FetchResponse } from '../models';
3
+ import { TokenResponse } from '../../models/token';
4
+ import { Crypto } from '../../models/crypto';
5
+ import { IdTokenPayload } from '../../models/id-token';
6
+ import { OIDCEndpoints } from '../../models/oidc-endpoints';
7
+ import { IsomorphicCrypto } from '../../IsomorphicCrypto';
8
+ export declare class AuthenticationCore<T> {
9
+ private _dataLayer;
10
+ private _config;
11
+ private _oidcProviderMetaData;
12
+ private _authenticationHelper;
13
+ private _cryptoUtils;
14
+ private _cryptoHelper;
15
+ constructor(dataLayer: DataLayer<T>, cryptoUtils: Crypto);
16
+ getAuthorizationURLParams(config?: AuthorizationURLParams, userID?: string): Promise<Map<string, string>>;
17
+ getAuthorizationURL(config?: AuthorizationURLParams, userID?: string): Promise<string>;
18
+ requestAccessToken(authorizationCode: string, sessionState: string, state: string, userID?: string, tokenRequestConfig?: {
19
+ params: Record<string, unknown>;
20
+ }): Promise<TokenResponse>;
21
+ refreshAccessToken(userID?: string): Promise<TokenResponse>;
22
+ revokeAccessToken(userID?: string): Promise<FetchResponse>;
23
+ requestCustomGrant(customGrantParams: CustomGrantConfig, userID?: string): Promise<TokenResponse | FetchResponse>;
24
+ getBasicUserInfo(userID?: string): Promise<BasicUserInfo>;
25
+ getDecodedIDToken(userID?: string): Promise<IdTokenPayload>;
26
+ getCryptoHelper(): Promise<IsomorphicCrypto>;
27
+ getIDToken(userID?: string): Promise<string>;
28
+ getOIDCProviderMetaData(forceInit: boolean): Promise<void>;
29
+ getOIDCServiceEndpoints(): Promise<Partial<OIDCEndpoints>>;
30
+ getSignOutURL(userID?: string): Promise<string>;
31
+ clearUserSessionData(userID?: string): Promise<void>;
32
+ getAccessToken(userID?: string): Promise<string>;
33
+ /**
34
+ * The created timestamp of the token response in milliseconds.
35
+ *
36
+ * @param userID - User ID
37
+ * @returns Created at timestamp of the token response in milliseconds.
38
+ */
39
+ getCreatedAt(userID?: string): Promise<number>;
40
+ /**
41
+ * The expires timestamp of the token response in seconds.
42
+ *
43
+ * @param userID - User ID
44
+ * @returns Expires in timestamp of the token response in seconds.
45
+ */
46
+ getExpiresIn(userID?: string): Promise<string>;
47
+ isAuthenticated(userID?: string): Promise<boolean>;
48
+ getPKCECode(state: string, userID?: string): Promise<string>;
49
+ setPKCECode(pkce: string, state: string, userID?: string): Promise<void>;
50
+ updateConfig(config: Partial<AuthClientConfig<T>>): Promise<void>;
51
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2020, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ export * from "./authentication-core";
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Copyright (c) 2020, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ import { Stores } from '../../models/store';
19
+ import { Store } from '../../models/store';
20
+ import { AuthClientConfig, SessionData } from '../models';
21
+ import { TemporaryStore, TemporaryStoreValue } from '../../models/store';
22
+ import { OIDCDiscoveryApiResponse } from '../../models/oidc-discovery';
23
+ type PartialData<T> = Partial<AuthClientConfig<T> | OIDCDiscoveryApiResponse | SessionData | TemporaryStore>;
24
+ export declare const ASGARDEO_SESSION_ACTIVE: string;
25
+ export declare class DataLayer<T> {
26
+ protected _id: string;
27
+ protected _store: Store;
28
+ constructor(instanceID: string, store: Store);
29
+ protected setDataInBulk(key: string, data: PartialData<T>): Promise<void>;
30
+ protected setValue(key: string, attribute: keyof AuthClientConfig<T> | keyof OIDCDiscoveryApiResponse | keyof SessionData | keyof TemporaryStore, value: TemporaryStoreValue): Promise<void>;
31
+ protected removeValue(key: string, attribute: keyof AuthClientConfig<T> | keyof OIDCDiscoveryApiResponse | keyof SessionData | keyof TemporaryStore): Promise<void>;
32
+ protected _resolveKey(store: Stores | string, userID?: string): string;
33
+ protected isLocalStorageAvailable(): boolean;
34
+ setConfigData(config: Partial<AuthClientConfig<T>>): Promise<void>;
35
+ setOIDCProviderMetaData(oidcProviderMetaData: Partial<OIDCDiscoveryApiResponse>): Promise<void>;
36
+ setTemporaryData(temporaryData: Partial<TemporaryStore>, userID?: string): Promise<void>;
37
+ setSessionData(sessionData: Partial<SessionData>, userID?: string): Promise<void>;
38
+ setCustomData<K>(key: string, customData: Partial<K>, userID?: string): Promise<void>;
39
+ getConfigData(): Promise<AuthClientConfig<T>>;
40
+ getOIDCProviderMetaData(): Promise<OIDCDiscoveryApiResponse>;
41
+ getTemporaryData(userID?: string): Promise<TemporaryStore>;
42
+ getSessionData(userID?: string): Promise<SessionData>;
43
+ getCustomData<K>(key: string, userID?: string): Promise<K>;
44
+ setSessionStatus(status: string): void;
45
+ getSessionStatus(): string;
46
+ removeSessionStatus(): void;
47
+ removeConfigData(): Promise<void>;
48
+ removeOIDCProviderMetaData(): Promise<void>;
49
+ removeTemporaryData(userID?: string): Promise<void>;
50
+ removeSessionData(userID?: string): Promise<void>;
51
+ getConfigDataParameter(key: keyof AuthClientConfig<T>): Promise<TemporaryStoreValue>;
52
+ getOIDCProviderMetaDataParameter(key: keyof OIDCDiscoveryApiResponse): Promise<TemporaryStoreValue>;
53
+ getTemporaryDataParameter(key: keyof TemporaryStore, userID?: string): Promise<TemporaryStoreValue>;
54
+ getSessionDataParameter(key: keyof SessionData, userID?: string): Promise<TemporaryStoreValue>;
55
+ setConfigDataParameter(key: keyof AuthClientConfig<T>, value: TemporaryStoreValue): Promise<void>;
56
+ setOIDCProviderMetaDataParameter(key: keyof OIDCDiscoveryApiResponse, value: TemporaryStoreValue): Promise<void>;
57
+ setTemporaryDataParameter(key: keyof TemporaryStore, value: TemporaryStoreValue, userID?: string): Promise<void>;
58
+ setSessionDataParameter(key: keyof SessionData, value: TemporaryStoreValue, userID?: string): Promise<void>;
59
+ removeConfigDataParameter(key: keyof AuthClientConfig<T>): Promise<void>;
60
+ removeOIDCProviderMetaDataParameter(key: keyof OIDCDiscoveryApiResponse): Promise<void>;
61
+ removeTemporaryDataParameter(key: keyof TemporaryStore, userID?: string): Promise<void>;
62
+ removeSessionDataParameter(key: keyof SessionData, userID?: string): Promise<void>;
63
+ }
64
+ export {};
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2020, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ export * from "./data-layer";
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright (c) 2020, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ export declare class AsgardeoAuthException {
19
+ name: string;
20
+ code: string | undefined;
21
+ message: string;
22
+ constructor(code: string, name: string, message: string);
23
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2020, WSO2 LLC. (https://www.wso2.com). All Rights Reserved.
3
+ *
4
+ * WSO2 LLC. licenses this file to you under the Apache License,
5
+ * Version 2.0 (the "License"); you may not use this file except
6
+ * in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing,
12
+ * software distributed under the License is distributed on an
13
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ * KIND, either express or implied. See the License for the
15
+ * specific language governing permissions and limitations
16
+ * under the License.
17
+ */
18
+ export * from "./exception";