@asgardeo/javascript 0.0.1 → 0.1.0

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 (56) hide show
  1. package/README.md +3 -3
  2. package/dist/AsgardeoJavaScriptClient.d.ts +2 -1
  3. package/dist/IsomorphicCrypto.d.ts +4 -4
  4. package/dist/{__legacy__/data/data-layer.d.ts → StorageManager.d.ts} +26 -25
  5. package/dist/__legacy__/client.d.ts +82 -98
  6. package/dist/__legacy__/helpers/authentication-helper.d.ts +8 -8
  7. package/dist/__legacy__/models/client-config.d.ts +6 -6
  8. package/dist/__legacy__/models/index.d.ts +0 -5
  9. package/dist/api/{oidc/getUserInfo.d.ts → getUserInfo.d.ts} +1 -1
  10. package/dist/api/handleApplicationNativeAuthentication.d.ts +33 -0
  11. package/dist/api/initializeApplicationNativeAuthentication.d.ts +117 -0
  12. package/dist/cjs/index.js +1581 -1188
  13. package/dist/cjs/index.js.map +4 -4
  14. package/dist/constants/ApplicationNativeAuthenticationConstants.d.ts +39 -0
  15. package/dist/constants/OIDCRequestConstants.d.ts +14 -0
  16. package/dist/constants/PKCEConstants.d.ts +1 -0
  17. package/dist/constants/TokenExchangeConstants.d.ts +1 -1
  18. package/dist/{__legacy__/exception → errors}/exception.d.ts +3 -0
  19. package/dist/{__legacy__/data/index.d.ts → i18n/en-US.d.ts} +4 -2
  20. package/dist/{__legacy__/exception → i18n}/index.d.ts +2 -2
  21. package/dist/index.d.ts +28 -10
  22. package/dist/index.js +1562 -1184
  23. package/dist/index.js.map +4 -4
  24. package/dist/models/application-native-authentication.d.ts +82 -0
  25. package/dist/models/client.d.ts +8 -2
  26. package/dist/models/config.d.ts +26 -1
  27. package/dist/models/crypto.d.ts +2 -2
  28. package/dist/{__legacy__/models/custom-grant.d.ts → models/field.d.ts} +13 -9
  29. package/dist/models/i18n.d.ts +66 -0
  30. package/dist/{__legacy__/models/authorization-url.d.ts → models/oauth-request.d.ts} +3 -3
  31. package/dist/models/oauth-response.d.ts +1 -17
  32. package/dist/models/scim2-schema.d.ts +3 -0
  33. package/dist/{__legacy__/models/data.d.ts → models/session.d.ts} +4 -0
  34. package/dist/models/store.d.ts +1 -1
  35. package/dist/models/token.d.ts +47 -0
  36. package/dist/models/user.d.ts +11 -84
  37. package/dist/theme/types.d.ts +0 -1
  38. package/dist/utils/deepMerge.d.ts +44 -0
  39. package/dist/utils/extractTenantDomainFromIdTokenPayload.d.ts +1 -1
  40. package/dist/utils/extractUserClaimsFromIdToken.d.ts +1 -1
  41. package/dist/utils/flattenUserSchema.d.ts +64 -0
  42. package/dist/utils/generateFlattenedUserProfile.d.ts +46 -0
  43. package/dist/utils/generateUserProfile.d.ts +55 -0
  44. package/dist/utils/get.d.ts +29 -0
  45. package/dist/utils/getAuthorizeRequestUrlParams.d.ts +59 -0
  46. package/dist/utils/getI18nBundles.d.ts +26 -0
  47. package/dist/utils/getLatestStateParam.d.ts +40 -0
  48. package/dist/utils/processOpenIDScopes.d.ts +36 -0
  49. package/dist/{__legacy__/core/index.d.ts → utils/resolveFieldName.d.ts} +3 -2
  50. package/dist/utils/resolveFieldType.d.ts +20 -0
  51. package/dist/utils/set.d.ts +30 -0
  52. package/package.json +4 -4
  53. package/dist/__legacy__/core/authentication-core.d.ts +0 -51
  54. package/dist/__legacy__/models/fetch.d.ts +0 -55
  55. package/dist/__legacy__/models/user.d.ts +0 -85
  56. package/dist/models/id-token.d.ts +0 -55
package/README.md CHANGED
@@ -28,8 +28,8 @@ import { AsgardeoAuth } from "@asgardeo/javascript";
28
28
 
29
29
  // Initialize the auth instance
30
30
  const auth = new AsgardeoAuth({
31
- signInRedirectURL: "https://localhost:3000",
32
- clientID: "<your_client_id>",
31
+ afterSignInUrl: "https://localhost:3000",
32
+ clientId: "<your_client_id>",
33
33
  baseUrl: "https://api.asgardeo.io/t/<org_name>"
34
34
  });
35
35
 
@@ -43,7 +43,7 @@ auth.signIn()
43
43
  });
44
44
 
45
45
  // Get authenticated user
46
- auth.getBasicUserInfo()
46
+ auth.getUser()
47
47
  .then((userInfo) => {
48
48
  console.log(userInfo);
49
49
  });
@@ -16,7 +16,7 @@
16
16
  * under the License.
17
17
  */
18
18
  import { AsgardeoClient, SignInOptions, SignOutOptions } from './models/client';
19
- import { User } from './models/user';
19
+ import { User, UserProfile } from './models/user';
20
20
  import { Config } from './models/config';
21
21
  /**
22
22
  * Base class for implementing Asgardeo clients.
@@ -38,6 +38,7 @@ declare abstract class AsgardeoJavaScriptClient<T = Config> implements AsgardeoC
38
38
  * @returns User object containing user details.
39
39
  */
40
40
  abstract getUser(): Promise<User>;
41
+ abstract getUserProfile(): Promise<UserProfile>;
41
42
  /**
42
43
  * Checks if the client is currently loading.
43
44
  * This can be used to determine if the client is in the process of initializing or fetching user data.
@@ -16,7 +16,7 @@
16
16
  * under the License.
17
17
  */
18
18
  import { Crypto, JWKInterface } from './models/crypto';
19
- import { IdTokenPayload } from './models/id-token';
19
+ import { IdTokenPayload } from './models/token';
20
20
  export declare class IsomorphicCrypto<T = any> {
21
21
  private _cryptoUtils;
22
22
  constructor(cryptoUtils: Crypto<T>);
@@ -50,7 +50,7 @@ export declare class IsomorphicCrypto<T = any> {
50
50
  *
51
51
  * @param idToken - id_token received from the IdP.
52
52
  * @param jwk - public key used for signing.
53
- * @param clientID - app identification.
53
+ * @param clientId - app identification.
54
54
  * @param issuer - id_token issuer.
55
55
  * @param username - Username.
56
56
  * @param clockTolerance - Allowed leeway for id_tokens (in seconds).
@@ -59,7 +59,7 @@ export declare class IsomorphicCrypto<T = any> {
59
59
  *
60
60
  * @throws
61
61
  */
62
- isValidIdToken(idToken: string, jwk: JWKInterface, clientID: string, issuer: string, username: string, clockTolerance: number | undefined, validateJwtIssuer: boolean | undefined): Promise<boolean>;
62
+ isValidIdToken(idToken: string, jwk: JWKInterface, clientId: string, issuer: string, username: string, clockTolerance: number | undefined, validateJwtIssuer: boolean | undefined): Promise<boolean>;
63
63
  /**
64
64
  * This function decodes the payload of an id token and returns it.
65
65
  *
@@ -69,5 +69,5 @@ export declare class IsomorphicCrypto<T = any> {
69
69
  *
70
70
  * @throws
71
71
  */
72
- decodeIDToken(idToken: string): IdTokenPayload;
72
+ decodeIdToken(idToken: string): IdTokenPayload;
73
73
  }
@@ -15,50 +15,51 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
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';
18
+ import { Stores } from './models/store';
19
+ import { Storage } from './models/store';
20
+ import { AuthClientConfig } from './__legacy__/models';
21
+ import { SessionData } from './models/session';
22
+ import { TemporaryStore, TemporaryStoreValue } from './models/store';
23
+ import { OIDCDiscoveryApiResponse } from './models/oidc-discovery';
23
24
  type PartialData<T> = Partial<AuthClientConfig<T> | OIDCDiscoveryApiResponse | SessionData | TemporaryStore>;
24
25
  export declare const ASGARDEO_SESSION_ACTIVE: string;
25
- export declare class DataLayer<T> {
26
+ declare class StorageManager<T> {
26
27
  protected _id: string;
27
- protected _store: Store;
28
- constructor(instanceID: string, store: Store);
28
+ protected _store: Storage;
29
+ constructor(instanceID: string, store: Storage);
29
30
  protected setDataInBulk(key: string, data: PartialData<T>): Promise<void>;
30
31
  protected setValue(key: string, attribute: keyof AuthClientConfig<T> | keyof OIDCDiscoveryApiResponse | keyof SessionData | keyof TemporaryStore, value: TemporaryStoreValue): Promise<void>;
31
32
  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 _resolveKey(store: Stores | string, userId?: string): string;
33
34
  protected isLocalStorageAvailable(): boolean;
34
35
  setConfigData(config: Partial<AuthClientConfig<T>>): Promise<void>;
35
36
  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>;
37
+ setTemporaryData(temporaryData: Partial<TemporaryStore>, userId?: string): Promise<void>;
38
+ setSessionData(sessionData: Partial<SessionData>, userId?: string): Promise<void>;
39
+ setCustomData<K>(key: string, customData: Partial<K>, userId?: string): Promise<void>;
39
40
  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>;
41
+ loadOpenIDProviderConfiguration(): Promise<OIDCDiscoveryApiResponse>;
42
+ getTemporaryData(userId?: string): Promise<TemporaryStore>;
43
+ getSessionData(userId?: string): Promise<SessionData>;
44
+ getCustomData<K>(key: string, userId?: string): Promise<K>;
44
45
  setSessionStatus(status: string): void;
45
46
  getSessionStatus(): string;
46
47
  removeSessionStatus(): void;
47
48
  removeConfigData(): Promise<void>;
48
49
  removeOIDCProviderMetaData(): Promise<void>;
49
- removeTemporaryData(userID?: string): Promise<void>;
50
- removeSessionData(userID?: string): Promise<void>;
50
+ removeTemporaryData(userId?: string): Promise<void>;
51
+ removeSessionData(userId?: string): Promise<void>;
51
52
  getConfigDataParameter(key: keyof AuthClientConfig<T>): Promise<TemporaryStoreValue>;
52
53
  getOIDCProviderMetaDataParameter(key: keyof OIDCDiscoveryApiResponse): Promise<TemporaryStoreValue>;
53
- getTemporaryDataParameter(key: keyof TemporaryStore, userID?: string): Promise<TemporaryStoreValue>;
54
- getSessionDataParameter(key: keyof SessionData, userID?: string): Promise<TemporaryStoreValue>;
54
+ getTemporaryDataParameter(key: keyof TemporaryStore, userId?: string): Promise<TemporaryStoreValue>;
55
+ getSessionDataParameter(key: keyof SessionData, userId?: string): Promise<TemporaryStoreValue>;
55
56
  setConfigDataParameter(key: keyof AuthClientConfig<T>, value: TemporaryStoreValue): Promise<void>;
56
57
  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>;
58
+ setTemporaryDataParameter(key: keyof TemporaryStore, value: TemporaryStoreValue, userId?: string): Promise<void>;
59
+ setSessionDataParameter(key: keyof SessionData, value: TemporaryStoreValue, userId?: string): Promise<void>;
59
60
  removeConfigDataParameter(key: keyof AuthClientConfig<T>): Promise<void>;
60
61
  removeOIDCProviderMetaDataParameter(key: keyof OIDCDiscoveryApiResponse): Promise<void>;
61
- removeTemporaryDataParameter(key: keyof TemporaryStore, userID?: string): Promise<void>;
62
- removeSessionDataParameter(key: keyof SessionData, userID?: string): Promise<void>;
62
+ removeTemporaryDataParameter(key: keyof TemporaryStore, userId?: string): Promise<void>;
63
+ removeSessionDataParameter(key: keyof SessionData, userId?: string): Promise<void>;
63
64
  }
64
- export {};
65
+ export default StorageManager;
@@ -15,22 +15,28 @@
15
15
  * specific language governing permissions and limitations
16
16
  * under the License.
17
17
  */
18
- import { DataLayer } from './data';
19
- import { AuthClientConfig, BasicUserInfo, CustomGrantConfig, FetchResponse, GetAuthURLConfig } from './models';
18
+ import StorageManager from '../StorageManager';
19
+ import { AuthClientConfig } from './models';
20
+ import { ExtendedAuthorizeRequestUrlParams } from '../models/oauth-request';
20
21
  import { Crypto } from '../models/crypto';
21
- import { TokenResponse } from '../models/token';
22
- import { IdTokenPayload } from '../models/id-token';
22
+ import { TokenResponse, IdTokenPayload, TokenExchangeRequestConfig } from '../models/token';
23
23
  import { OIDCEndpoints } from '../models/oidc-endpoints';
24
- import { Store } from '../models/store';
24
+ import { Storage } from '../models/store';
25
25
  import { IsomorphicCrypto } from '../IsomorphicCrypto';
26
+ import { UserSession } from '../models/session';
27
+ import { User } from '../models/user';
26
28
  /**
27
29
  * This class provides the necessary methods needed to implement authentication.
28
30
  */
29
31
  export declare class AsgardeoAuthClient<T> {
30
- private _dataLayer;
31
- private _authenticationCore;
32
+ private _storageManager;
33
+ private _config;
34
+ private _oidcProviderMetaData;
35
+ private _authenticationHelper;
36
+ private _cryptoUtils;
37
+ private _cryptoHelper;
32
38
  private static _instanceID;
33
- static _authenticationCore: any;
39
+ static _authenticationHelper: any;
34
40
  /**
35
41
  * This is the constructor method that returns an instance of the .
36
42
  *
@@ -55,8 +61,8 @@ export declare class AsgardeoAuthClient<T> {
55
61
  *
56
62
  * @example
57
63
  * const config = \{
58
- * signInRedirectURL: "http://localhost:3000/sign-in",
59
- * clientID: "client ID",
64
+ * afterSignInUrl: "http://localhost:3000/sign-in",
65
+ * clientId: "client ID",
60
66
  * baseUrl: "https://localhost:9443"
61
67
  * \}
62
68
  *
@@ -66,22 +72,22 @@ export declare class AsgardeoAuthClient<T> {
66
72
  *
67
73
  * @preserve
68
74
  */
69
- initialize(config: AuthClientConfig<T>, store: Store, cryptoUtils: Crypto, instanceID?: number): Promise<void>;
75
+ initialize(config: AuthClientConfig<T>, store: Storage, cryptoUtils: Crypto, instanceID?: number): Promise<void>;
70
76
  /**
71
- * This method returns the `DataLayer` object that allows you to access authentication data.
77
+ * This method returns the `StorageManager` object that allows you to access authentication data.
72
78
  *
73
- * @returns - The `DataLayer` object.
79
+ * @returns - The `StorageManager` object.
74
80
  *
75
81
  * @example
76
82
  * ```
77
- * const data = auth.getDataLayer();
83
+ * const data = auth.getStorageManager();
78
84
  * ```
79
85
  *
80
- * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getDataLayer}
86
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getStorageManager}
81
87
  *
82
88
  * @preserve
83
89
  */
84
- getDataLayer(): DataLayer<T>;
90
+ getStorageManager(): StorageManager<T>;
85
91
  /**
86
92
  * This method returns the `instanceID` variable of the given instance.
87
93
  *
@@ -89,67 +95,43 @@ export declare class AsgardeoAuthClient<T> {
89
95
  *
90
96
  * @example
91
97
  * ```
92
- * const instanceId = auth.getInstanceID();
98
+ * const instanceId = auth.getInstanceId();
93
99
  * ```
94
100
  *
95
101
  * @preserve
96
102
  */
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>>;
103
+ getInstanceId(): number;
122
104
  /**
123
105
  * This is an async method that returns a Promise that resolves with the authorization URL.
124
106
  *
125
107
  * @param config - (Optional) A config object to force initialization and pass
126
108
  * 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
109
+ * @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
128
110
  * scenarios where each user should be uniquely identified.
129
111
  *
130
112
  * @returns - A promise that resolves with the authorization URL.
131
113
  *
132
114
  * @example
133
115
  * ```
134
- * auth.getAuthorizationURL().then((url)=>{
116
+ * auth.getSignInUrl().then((url)=>{
135
117
  * // console.log(url);
136
118
  * }).catch((error)=>{
137
119
  * // console.error(error);
138
120
  * });
139
121
  * ```
140
122
  *
141
- * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getAuthorizationURL}
123
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getSignInUrl}
142
124
  *
143
125
  * @preserve
144
126
  */
145
- getAuthorizationURL(config?: GetAuthURLConfig, userID?: string): Promise<string>;
127
+ getSignInUrl(requestConfig?: ExtendedAuthorizeRequestUrlParams, userId?: string): Promise<string>;
146
128
  /**
147
129
  * This is an async method that sends a request to obtain the access token and returns a Promise
148
130
  * that resolves with the token and other relevant data.
149
131
  *
150
132
  * @param authorizationCode - The authorization code.
151
133
  * @param sessionState - The session state.
152
- * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
134
+ * @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
153
135
  * scenarios where each user should be uniquely identified.
154
136
  *
155
137
  * @returns - A Promise that resolves with the token response.
@@ -168,13 +150,14 @@ export declare class AsgardeoAuthClient<T> {
168
150
  *
169
151
  * @preserve
170
152
  */
171
- requestAccessToken(authorizationCode: string, sessionState: string, state: string, userID?: string, tokenRequestConfig?: {
153
+ requestAccessToken(authorizationCode: string, sessionState: string, state: string, userId?: string, tokenRequestConfig?: {
172
154
  params: Record<string, unknown>;
173
155
  }): Promise<TokenResponse>;
156
+ loadOpenIDProviderConfiguration(forceInit: boolean): Promise<void>;
174
157
  /**
175
158
  * This method returns the sign-out URL.
176
159
  *
177
- * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
160
+ * @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
178
161
  * scenarios where each user should be uniquely identified.
179
162
  *
180
163
  * **This doesn't clear the authentication data.**
@@ -183,14 +166,14 @@ export declare class AsgardeoAuthClient<T> {
183
166
  *
184
167
  * @example
185
168
  * ```
186
- * const signOutUrl = await auth.getSignOutURL();
169
+ * const signOutUrl = await auth.getSignOutUrl();
187
170
  * ```
188
171
  *
189
- * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getSignOutURL}
172
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getSignOutUrl}
190
173
  *
191
174
  * @preserve
192
175
  */
193
- getSignOutURL(userID?: string): Promise<string>;
176
+ getSignOutUrl(userId?: string): Promise<string>;
194
177
  /**
195
178
  * This method returns OIDC service endpoints that are fetched from the `.well-known` endpoint.
196
179
  *
@@ -198,68 +181,69 @@ export declare class AsgardeoAuthClient<T> {
198
181
  *
199
182
  * @example
200
183
  * ```
201
- * const endpoints = await auth.getOIDCServiceEndpoints();
184
+ * const endpoints = await auth.getOpenIDProviderEndpoints();
202
185
  * ```
203
186
  *
204
- * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getOIDCServiceEndpoints}
187
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getOpenIDProviderEndpoints}
205
188
  *
206
189
  * @preserve
207
190
  */
208
- getOIDCServiceEndpoints(): Promise<Partial<OIDCEndpoints>>;
191
+ getOpenIDProviderEndpoints(): Promise<Partial<OIDCEndpoints>>;
209
192
  /**
210
193
  * This method decodes the payload of the ID token and returns it.
211
194
  *
212
- * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
195
+ * @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
213
196
  * scenarios where each user should be uniquely identified.
214
197
  *
215
198
  * @returns - A Promise that resolves with the decoded ID token payload.
216
199
  *
217
200
  * @example
218
201
  * ```
219
- * const decodedIdToken = await auth.getDecodedIDToken();
202
+ * const decodedIdToken = await auth.getDecodedIdToken();
220
203
  * ```
221
204
  *
222
- * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getDecodedIDToken}
205
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getDecodedIdToken}
223
206
  *
224
207
  * @preserve
225
208
  */
226
- getDecodedIDToken(userID?: string): Promise<IdTokenPayload>;
209
+ getDecodedIdToken(userId?: string): Promise<IdTokenPayload>;
227
210
  /**
228
211
  * This method returns the ID token.
229
212
  *
230
- * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
213
+ * @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
231
214
  * scenarios where each user should be uniquely identified.
232
215
  *
233
216
  * @returns - A Promise that resolves with the ID token.
234
217
  *
235
218
  * @example
236
219
  * ```
237
- * const idToken = await auth.getIDToken();
220
+ * const idToken = await auth.getIdToken();
238
221
  * ```
239
222
  *
240
- * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getIDToken}
223
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getIdToken}
241
224
  *
242
225
  * @preserve
243
226
  */
244
- getIDToken(userID?: string): Promise<string>;
227
+ getIdToken(userId?: string): Promise<string>;
245
228
  /**
246
229
  * This method returns the basic user information obtained from the ID token.
247
230
  *
248
- * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
231
+ * @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
249
232
  * scenarios where each user should be uniquely identified.
250
233
  *
251
234
  * @returns - A Promise that resolves with an object containing the basic user information.
252
235
  *
253
236
  * @example
254
237
  * ```
255
- * const userInfo = await auth.getBasicUserInfo();
238
+ * const userInfo = await auth.getUser();
256
239
  * ```
257
240
  *
258
- * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getBasicUserInfo}
241
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getUser}
259
242
  *
260
243
  * @preserve
261
244
  */
262
- getBasicUserInfo(userID?: string): Promise<BasicUserInfo>;
245
+ getUser(userId?: string): Promise<User>;
246
+ getUserSession(userId?: string): Promise<UserSession>;
263
247
  /**
264
248
  * This method returns the crypto helper object.
265
249
  *
@@ -270,15 +254,15 @@ export declare class AsgardeoAuthClient<T> {
270
254
  * const cryptoHelper = await auth.IsomorphicCrypto();
271
255
  * ```
272
256
  *
273
- * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getCryptoHelper}
257
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getCrypto}
274
258
  *
275
259
  * @preserve
276
260
  */
277
- getCryptoHelper(): Promise<IsomorphicCrypto>;
261
+ getCrypto(): Promise<IsomorphicCrypto>;
278
262
  /**
279
263
  * This method revokes the access token.
280
264
  *
281
- * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
265
+ * @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
282
266
  * scenarios where each user should be uniquely identified.
283
267
  *
284
268
  * **This method also clears the authentication data.**
@@ -298,12 +282,12 @@ export declare class AsgardeoAuthClient<T> {
298
282
  *
299
283
  * @preserve
300
284
  */
301
- revokeAccessToken(userID?: string): Promise<FetchResponse>;
285
+ revokeAccessToken(userId?: string): Promise<Response>;
302
286
  /**
303
287
  * This method refreshes the access token and returns a Promise that resolves with the new access
304
288
  * token and other relevant data.
305
289
  *
306
- * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
290
+ * @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
307
291
  * scenarios where each user should be uniquely identified.
308
292
  *
309
293
  * @returns - A Promise that resolves with the token response.
@@ -321,11 +305,11 @@ export declare class AsgardeoAuthClient<T> {
321
305
  *
322
306
  * @preserve
323
307
  */
324
- refreshAccessToken(userID?: string): Promise<TokenResponse>;
308
+ refreshAccessToken(userId?: string): Promise<TokenResponse>;
325
309
  /**
326
310
  * This method returns the access token.
327
311
  *
328
- * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
312
+ * @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
329
313
  * scenarios where each user should be uniquely identified.
330
314
  *
331
315
  * @returns - A Promise that resolves with the access token.
@@ -339,13 +323,13 @@ export declare class AsgardeoAuthClient<T> {
339
323
  *
340
324
  * @preserve
341
325
  */
342
- getAccessToken(userID?: string): Promise<string>;
326
+ getAccessToken(userId?: string): Promise<string>;
343
327
  /**
344
328
  * This method sends a custom-grant request and returns a Promise that resolves with the response
345
329
  * depending on the config passed.
346
330
  *
347
331
  * @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
332
+ * @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
349
333
  * scenarios where each user should be uniquely identified.
350
334
  *
351
335
  * @returns - A Promise that resolves with the response depending
@@ -356,7 +340,7 @@ export declare class AsgardeoAuthClient<T> {
356
340
  * const config = {
357
341
  * attachToken: false,
358
342
  * data: {
359
- * client_id: "{{clientID}}",
343
+ * client_id: "{{clientId}}",
360
344
  * grant_type: "account_switch",
361
345
  * scope: "{{scope}}",
362
346
  * token: "{{token}}",
@@ -367,40 +351,40 @@ export declare class AsgardeoAuthClient<T> {
367
351
  * signInRequired: true
368
352
  * }
369
353
  *
370
- * auth.requestCustomGrant(config).then((response)=>{
354
+ * auth.exchangeToken(config).then((response)=>{
371
355
  * // console.log(response);
372
356
  * }).catch((error)=>{
373
357
  * // console.error(error);
374
358
  * });
375
359
  * ```
376
360
  *
377
- * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#requestCustomGrant}
361
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#exchangeToken}
378
362
  *
379
363
  * @preserve
380
364
  */
381
- requestCustomGrant(config: CustomGrantConfig, userID?: string): Promise<TokenResponse | FetchResponse>;
365
+ exchangeToken(config: TokenExchangeRequestConfig, userId?: string): Promise<TokenResponse | Response>;
382
366
  /**
383
367
  * This method returns if the user is authenticated or not.
384
368
  *
385
- * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
369
+ * @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
386
370
  * scenarios where each user should be uniquely identified.
387
371
  *
388
372
  * @returns - A Promise that resolves with `true` if the user is authenticated, `false` otherwise.
389
373
  *
390
374
  * @example
391
375
  * ```
392
- * await auth.isAuthenticated();
376
+ * await auth.isSignedIn();
393
377
  * ```
394
378
  *
395
- * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#isAuthenticated}
379
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#isSignedIn}
396
380
  *
397
381
  * @preserve
398
382
  */
399
- isAuthenticated(userID?: string): Promise<boolean>;
383
+ isSignedIn(userId?: string): Promise<boolean>;
400
384
  /**
401
385
  * This method returns the PKCE code generated during the generation of the authentication URL.
402
386
  *
403
- * @param userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
387
+ * @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
404
388
  * scenarios where each user should be uniquely identified.
405
389
  * @param state - The state parameter that was passed in the authentication URL.
406
390
  *
@@ -415,13 +399,13 @@ export declare class AsgardeoAuthClient<T> {
415
399
  *
416
400
  * @preserve
417
401
  */
418
- getPKCECode(state: string, userID?: string): Promise<string>;
402
+ getPKCECode(state: string, userId?: string): Promise<string>;
419
403
  /**
420
404
  * This method sets the PKCE code to the data store.
421
405
  *
422
406
  * @param pkce - The PKCE code.
423
407
  * @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
408
+ * @param userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
425
409
  * scenarios where each user should be uniquely identified.
426
410
  *
427
411
  * @example
@@ -433,13 +417,13 @@ export declare class AsgardeoAuthClient<T> {
433
417
  *
434
418
  * @preserve
435
419
  */
436
- setPKCECode(pkce: string, state: string, userID?: string): Promise<void>;
420
+ setPKCECode(pkce: string, state: string, userId?: string): Promise<void>;
437
421
  /**
438
422
  * This method returns if the sign-out is successful or not.
439
423
  *
440
424
  * @param signOutRedirectUrl - The URL to which the user has been redirected to after signing-out.
441
425
  *
442
- * **The server appends path parameters to the `signOutRedirectURL` and these path parameters
426
+ * **The server appends path parameters to the `afterSignOutUrl` and these path parameters
443
427
  * are required for this method to function.**
444
428
  *
445
429
  * @returns - `true` if successful, `false` otherwise.
@@ -448,13 +432,13 @@ export declare class AsgardeoAuthClient<T> {
448
432
  *
449
433
  * @preserve
450
434
  */
451
- static isSignOutSuccessful(signOutRedirectURL: string): boolean;
435
+ static isSignOutSuccessful(afterSignOutUrl: string): boolean;
452
436
  /**
453
437
  * This method returns if the sign-out has failed or not.
454
438
  *
455
439
  * @param signOutRedirectUrl - The URL to which the user has been redirected to after signing-out.
456
440
  *
457
- * **The server appends path parameters to the `signOutRedirectURL` and these path parameters
441
+ * **The server appends path parameters to the `afterSignOutUrl` and these path parameters
458
442
  * are required for this method to function.**
459
443
  *
460
444
  * @returns - `true` if successful, `false` otherwise.
@@ -463,7 +447,7 @@ export declare class AsgardeoAuthClient<T> {
463
447
  *
464
448
  * @preserve
465
449
  */
466
- static didSignOutFail(signOutRedirectURL: string): boolean;
450
+ static didSignOutFail(afterSignOutUrl: string): boolean;
467
451
  /**
468
452
  * This method updates the configuration that was passed into the constructor when instantiating this class.
469
453
  *
@@ -472,17 +456,17 @@ export declare class AsgardeoAuthClient<T> {
472
456
  * @example
473
457
  * ```
474
458
  * const config = {
475
- * signInRedirectURL: "http://localhost:3000/sign-in",
476
- * clientID: "client ID",
459
+ * afterSignInUrl: "http://localhost:3000/sign-in",
460
+ * clientId: "client ID",
477
461
  * baseUrl: "https://localhost:9443"
478
462
  * }
479
463
  *
480
- * await auth.updateConfig(config);
464
+ * await auth.reInitialize(config);
481
465
  * ```
482
- * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#updateConfig}
466
+ * {@link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#reInitialize}
483
467
  *
484
468
  * @preserve
485
469
  */
486
- updateConfig(config: Partial<AuthClientConfig<T>>): Promise<void>;
487
- static clearUserSessionData(userID?: string): Promise<void>;
470
+ reInitialize(config: Partial<AuthClientConfig<T>>): Promise<void>;
471
+ static clearSession(userId?: string): Promise<void>;
488
472
  }
@@ -16,22 +16,22 @@
16
16
  * under the License.
17
17
  */
18
18
  import { IsomorphicCrypto } from '../../IsomorphicCrypto';
19
- import { DataLayer } from '../data';
20
- import { AuthenticatedUserInfo } from '../models';
19
+ import StorageManager from '../../StorageManager';
20
+ import { User } from '../../models/user';
21
21
  import { TokenResponse } from '../../models/token';
22
22
  import { OIDCDiscoveryEndpointsApiResponse, OIDCDiscoveryApiResponse } from '../../models/oidc-discovery';
23
23
  export declare class AuthenticationHelper<T> {
24
- private _dataLayer;
24
+ private _storageManager;
25
25
  private _config;
26
26
  private _oidcProviderMetaData;
27
27
  private _cryptoHelper;
28
- constructor(dataLayer: DataLayer<T>, cryptoHelper: IsomorphicCrypto);
28
+ constructor(storageManager: StorageManager<T>, cryptoHelper: IsomorphicCrypto);
29
29
  resolveEndpoints(response: OIDCDiscoveryApiResponse): Promise<OIDCDiscoveryApiResponse>;
30
30
  resolveEndpointsExplicitly(): Promise<OIDCDiscoveryEndpointsApiResponse>;
31
31
  resolveEndpointsByBaseURL(): Promise<OIDCDiscoveryEndpointsApiResponse>;
32
32
  validateIdToken(idToken: string): Promise<boolean>;
33
- getAuthenticatedUserInfo(idToken: string): AuthenticatedUserInfo;
34
- replaceCustomGrantTemplateTags(text: string, userID?: string): Promise<string>;
35
- clearUserSessionData(userID?: string): Promise<void>;
36
- handleTokenResponse(response: Response, userID?: string): Promise<TokenResponse>;
33
+ getAuthenticatedUserInfo(idToken: string): User;
34
+ replaceCustomGrantTemplateTags(text: string, userId?: string): Promise<string>;
35
+ clearSession(userId?: string): Promise<void>;
36
+ handleTokenResponse(response: Response, userId?: string): Promise<TokenResponse>;
37
37
  }