@asgardeo/node 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -197,11 +197,11 @@ var NodeCryptoUtils = class {
197
197
  generateRandomBytes(length) {
198
198
  return (0, import_secure_random_bytes.default)(length);
199
199
  }
200
- async verifyJwt(idToken, jwk, algorithms, clientID, issuer, subject, clockTolerance) {
200
+ async verifyJwt(idToken, jwk, algorithms, clientId, issuer, subject, clockTolerance) {
201
201
  const key = await jose.importJWK(jwk);
202
202
  return jose.jwtVerify(idToken, key, {
203
203
  algorithms,
204
- audience: clientID,
204
+ audience: clientId,
205
205
  clockTolerance,
206
206
  issuer,
207
207
  subject
@@ -217,7 +217,7 @@ var AsgardeoNodeCore = class _AsgardeoNodeCore {
217
217
  __publicField(this, "_auth");
218
218
  __publicField(this, "_cryptoUtils");
219
219
  __publicField(this, "_store");
220
- __publicField(this, "_dataLayer");
220
+ __publicField(this, "_storageManager");
221
221
  if (!store) {
222
222
  this._store = new MemoryCacheStore();
223
223
  } else {
@@ -226,11 +226,11 @@ var AsgardeoNodeCore = class _AsgardeoNodeCore {
226
226
  this._cryptoUtils = new NodeCryptoUtils();
227
227
  this._auth = new import_javascript.AsgardeoAuthClient();
228
228
  this._auth.initialize(config, this._store, this._cryptoUtils);
229
- this._dataLayer = this._auth.getDataLayer();
229
+ this._storageManager = this._auth.getStorageManager();
230
230
  Logger.debug("Initialized AsgardeoAuthClient successfully");
231
231
  }
232
- async signIn(authURLCallback, userID, authorizationCode, sessionState, state, signInConfig) {
233
- if (!userID) {
232
+ async signIn(authURLCallback, userId, authorizationCode, sessionState, state, signInConfig) {
233
+ if (!userId) {
234
234
  return Promise.reject(
235
235
  new import_javascript.AsgardeoAuthException(
236
236
  "NODE-AUTH_CORE-SI-NF01",
@@ -239,8 +239,8 @@ var AsgardeoNodeCore = class _AsgardeoNodeCore {
239
239
  )
240
240
  );
241
241
  }
242
- if (await this.isAuthenticated(userID)) {
243
- const sessionData = await this._dataLayer.getSessionData(userID);
242
+ if (await this.isSignedIn(userId)) {
243
+ const sessionData = await this._storageManager.getSessionData(userId);
244
244
  return Promise.resolve({
245
245
  accessToken: sessionData.access_token,
246
246
  createdAt: sessionData.created_at,
@@ -261,7 +261,7 @@ var AsgardeoNodeCore = class _AsgardeoNodeCore {
261
261
  )
262
262
  );
263
263
  }
264
- const authURL = await this.getAuthURL(userID, signInConfig);
264
+ const authURL = await this.getAuthURL(userId, signInConfig);
265
265
  authURLCallback(authURL);
266
266
  return Promise.resolve({
267
267
  accessToken: "",
@@ -274,10 +274,10 @@ var AsgardeoNodeCore = class _AsgardeoNodeCore {
274
274
  tokenType: ""
275
275
  });
276
276
  }
277
- return this.requestAccessToken(authorizationCode, sessionState ?? "", userID, state);
277
+ return this.requestAccessToken(authorizationCode, sessionState ?? "", userId, state);
278
278
  }
279
279
  async getAuthURL(userId, signInConfig) {
280
- const authURL = await this._auth.getAuthorizationURL(signInConfig, userId);
280
+ const authURL = await this._auth.getSignInUrl(signInConfig, userId);
281
281
  if (authURL) {
282
282
  return Promise.resolve(authURL.toString());
283
283
  } else {
@@ -293,8 +293,8 @@ var AsgardeoNodeCore = class _AsgardeoNodeCore {
293
293
  async requestAccessToken(authorizationCode, sessionState, userId, state) {
294
294
  return this._auth.requestAccessToken(authorizationCode, sessionState, state, userId);
295
295
  }
296
- async getIDToken(userId) {
297
- const is_logged_in = await this.isAuthenticated(userId);
296
+ async getIdToken(userId) {
297
+ const is_logged_in = await this.isSignedIn(userId);
298
298
  if (!is_logged_in) {
299
299
  return Promise.reject(
300
300
  new import_javascript.AsgardeoAuthException(
@@ -304,7 +304,7 @@ var AsgardeoNodeCore = class _AsgardeoNodeCore {
304
304
  )
305
305
  );
306
306
  }
307
- const idToken = await this._auth.getIDToken(userId);
307
+ const idToken = await this._auth.getIdToken(userId);
308
308
  if (idToken) {
309
309
  return Promise.resolve(idToken);
310
310
  } else {
@@ -320,27 +320,27 @@ var AsgardeoNodeCore = class _AsgardeoNodeCore {
320
320
  async refreshAccessToken(userId) {
321
321
  return this._auth.refreshAccessToken(userId);
322
322
  }
323
- async isAuthenticated(userId) {
323
+ async isSignedIn(userId) {
324
324
  try {
325
- if (!await this._auth.isAuthenticated(userId)) {
325
+ if (!await this._auth.isSignedIn(userId)) {
326
326
  return Promise.resolve(false);
327
327
  }
328
- if (await SessionUtils.validateSession(await this._dataLayer.getSessionData(userId))) {
328
+ if (await SessionUtils.validateSession(await this._storageManager.getSessionData(userId))) {
329
329
  return Promise.resolve(true);
330
330
  }
331
331
  const refreshed_token = await this.refreshAccessToken(userId);
332
332
  if (refreshed_token) {
333
333
  return Promise.resolve(true);
334
334
  }
335
- this._dataLayer.removeSessionData(userId);
336
- this._dataLayer.getTemporaryData(userId);
335
+ this._storageManager.removeSessionData(userId);
336
+ this._storageManager.getTemporaryData(userId);
337
337
  return Promise.resolve(false);
338
338
  } catch (error) {
339
339
  return Promise.reject(error);
340
340
  }
341
341
  }
342
342
  async signOut(userId) {
343
- const signOutURL = await this._auth.getSignOutURL(userId);
343
+ const signOutURL = await this._auth.getSignOutUrl(userId);
344
344
  if (!signOutURL) {
345
345
  return Promise.reject(
346
346
  new import_javascript.AsgardeoAuthException(
@@ -352,35 +352,35 @@ var AsgardeoNodeCore = class _AsgardeoNodeCore {
352
352
  }
353
353
  return Promise.resolve(signOutURL);
354
354
  }
355
- async getBasicUserInfo(userId) {
356
- return this._auth.getBasicUserInfo(userId);
355
+ async getUser(userId) {
356
+ return this._auth.getUser(userId);
357
357
  }
358
- async getOIDCServiceEndpoints() {
359
- return this._auth.getOIDCServiceEndpoints();
358
+ async getOpenIDProviderEndpoints() {
359
+ return this._auth.getOpenIDProviderEndpoints();
360
360
  }
361
- async getDecodedIDToken(userId) {
362
- return this._auth.getDecodedIDToken(userId);
361
+ async getDecodedIdToken(userId) {
362
+ return this._auth.getDecodedIdToken(userId);
363
363
  }
364
364
  async getAccessToken(userId) {
365
365
  return this._auth.getAccessToken(userId);
366
366
  }
367
- async requestCustomGrant(config, userId) {
368
- return this._auth.requestCustomGrant(config, userId);
367
+ async exchangeToken(config, userId) {
368
+ return this._auth.exchangeToken(config, userId);
369
369
  }
370
- async updateConfig(config) {
371
- return this._auth.updateConfig(config);
370
+ async reInitialize(config) {
371
+ return this._auth.reInitialize(config);
372
372
  }
373
373
  async revokeAccessToken(userId) {
374
374
  return this._auth.revokeAccessToken(userId);
375
375
  }
376
- static didSignOutFail(signOutRedirectURL) {
377
- return _AsgardeoNodeCore.didSignOutFail(signOutRedirectURL);
376
+ static didSignOutFail(afterSignOutUrl) {
377
+ return _AsgardeoNodeCore.didSignOutFail(afterSignOutUrl);
378
378
  }
379
- static isSignOutSuccessful(signOutRedirectURL) {
380
- return _AsgardeoNodeCore.isSignOutSuccessful(signOutRedirectURL);
379
+ static isSignOutSuccessful(afterSignOutUrl) {
380
+ return _AsgardeoNodeCore.isSignOutSuccessful(afterSignOutUrl);
381
381
  }
382
- getDataLayer() {
383
- return this._dataLayer;
382
+ getStorageManager() {
383
+ return this._storageManager;
384
384
  }
385
385
  };
386
386
 
@@ -390,15 +390,15 @@ var AsgardeoNodeClient = class _AsgardeoNodeClient {
390
390
  * This is the constructor method that returns an instance of the `AsgardeoNodeClient` class.
391
391
  *
392
392
  * @param {AuthClientConfig<T>} config - The configuration object.
393
- * @param {Store} store - The store object.
393
+ * @param {Storage} store - The store object.
394
394
  *
395
395
  * @example
396
396
  * ```
397
- * const _store: Store = new DataStore();
397
+ * const _store: Storage = new DataStore();
398
398
  * const _config = {
399
- signInRedirectURL: "http://localhost:3000/sign-in",
400
- signOutRedirectURL: "http://localhost:3000/dashboard",
401
- clientID: "client ID",
399
+ afterSignInUrl: "http://localhost:3000/sign-in",
400
+ afterSignOutUrl: "http://localhost:3000/dashboard",
401
+ clientId: "client ID",
402
402
  serverOrigin: "https://api.asgardeo.io/t/<org_name>"
403
403
  };
404
404
  * const auth = new AsgardeoNodeClient(_config,_store);
@@ -419,7 +419,7 @@ var AsgardeoNodeClient = class _AsgardeoNodeClient {
419
419
  * authorization URL to authorize the user.
420
420
  * @param {string} authorizationCode - The authorization code obtained from Asgardeo after a user signs in.
421
421
  * @param {String} sessionState - The session state obtained from Asgardeo after a user signs in.
422
- * @param {string} userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
422
+ * @param {string} userId - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
423
423
  * scenarios where each user should be uniquely identified.
424
424
  * @param {string} state - The state parameter in the redirect URL.
425
425
  *
@@ -478,16 +478,16 @@ var AsgardeoNodeClient = class _AsgardeoNodeClient {
478
478
  *
479
479
  * @example
480
480
  * ```
481
- * const isAuth = await authClient.isAuthenticated("a2a2972c-51cd-5e9d-a9ae-058fae9f7927");
481
+ * const isAuth = await authClient.isSignedIn("a2a2972c-51cd-5e9d-a9ae-058fae9f7927");
482
482
  * ```
483
483
  *
484
- * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#isAuthenticated
484
+ * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#isSignedIn
485
485
  *
486
486
  * @memberof AsgardeoNodeClient
487
487
  *
488
488
  */
489
- async isAuthenticated(userId) {
490
- return this._authCore.isAuthenticated(userId);
489
+ async isSignedIn(userId) {
490
+ return this._authCore.isSignedIn(userId);
491
491
  }
492
492
  /**
493
493
  * This method returns the id token.
@@ -498,16 +498,16 @@ var AsgardeoNodeClient = class _AsgardeoNodeClient {
498
498
  *
499
499
  * @example
500
500
  * ```
501
- * const isAuth = await authClient.getIDToken("a2a2972c-51cd-5e9d-a9ae-058fae9f7927");
501
+ * const isAuth = await authClient.getIdToken("a2a2972c-51cd-5e9d-a9ae-058fae9f7927");
502
502
  * ```
503
503
  *
504
- * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getIDToken
504
+ * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getIdToken
505
505
  *
506
506
  * @memberof AsgardeoNodeClient
507
507
  *
508
508
  */
509
- async getIDToken(userId) {
510
- return this._authCore.getIDToken(userId);
509
+ async getIdToken(userId) {
510
+ return this._authCore.getIdToken(userId);
511
511
  }
512
512
  /**
513
513
  * This method returns an object containing basic user information obtained from the id token.
@@ -519,16 +519,16 @@ var AsgardeoNodeClient = class _AsgardeoNodeClient {
519
519
  *
520
520
  * @example
521
521
  * ```
522
- * const basicInfo = await authClient.getBasicUserInfo("a2a2972c-51cd-5e9d-a9ae-058fae9f7927");
522
+ * const basicInfo = await authClient.getUser("a2a2972c-51cd-5e9d-a9ae-058fae9f7927");
523
523
  * ```
524
524
  *
525
- * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getBasicUserInfo
525
+ * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getUser
526
526
  *
527
527
  * @memberof AsgardeoNodeClient
528
528
  *
529
529
  */
530
- async getBasicUserInfo(userId) {
531
- return this._authCore.getBasicUserInfo(userId);
530
+ async getUser(userId) {
531
+ return this._authCore.getUser(userId);
532
532
  }
533
533
  /**
534
534
  * This method returns an object containing the OIDC service endpoints returned by the `.well-known` endpoint.
@@ -537,16 +537,16 @@ var AsgardeoNodeClient = class _AsgardeoNodeClient {
537
537
  *
538
538
  * @example
539
539
  * ```
540
- * const oidcEndpoints = await auth.getOIDCServiceEndpoints();
540
+ * const oidcEndpoints = await auth.getOpenIDProviderEndpoints();
541
541
  * ```
542
542
  *
543
- * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getOIDCServiceEndpoints
543
+ * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getOpenIDProviderEndpoints
544
544
  *
545
545
  * @memberof AsgardeoNodeClient
546
546
  *
547
547
  */
548
- async getOIDCServiceEndpoints() {
549
- return this._authCore.getOIDCServiceEndpoints();
548
+ async getOpenIDProviderEndpoints() {
549
+ return this._authCore.getOpenIDProviderEndpoints();
550
550
  }
551
551
  /**
552
552
  * This method returns the decoded ID token payload.
@@ -558,16 +558,16 @@ var AsgardeoNodeClient = class _AsgardeoNodeClient {
558
558
  *
559
559
  * @example
560
560
  * ```
561
- * const decodedIDTokenPayload = await auth.getDecodedIDToken("a2a2972c-51cd-5e9d-a9ae-058fae9f7927");
561
+ * const decodedIDTokenPayload = await auth.getDecodedIdToken("a2a2972c-51cd-5e9d-a9ae-058fae9f7927");
562
562
  * ```
563
563
  *
564
- * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getDecodedIDToken
564
+ * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#getDecodedIdToken
565
565
  *
566
566
  * @memberof AsgardeoNodeClient
567
567
  *
568
568
  */
569
- async getDecodedIDToken(userId) {
570
- return this._authCore.getDecodedIDToken(userId);
569
+ async getDecodedIdToken(userId) {
570
+ return this._authCore.getDecodedIdToken(userId);
571
571
  }
572
572
  /**
573
573
  * This method returns the access token.
@@ -591,15 +591,15 @@ var AsgardeoNodeClient = class _AsgardeoNodeClient {
591
591
  return this._authCore.getAccessToken(userId);
592
592
  }
593
593
  /**
594
- * This method returns Promise that resolves with the token information
594
+ * This method returns Promise that resolves with the token information
595
595
  * or the response returned by the server depending on the configuration passed.
596
- * @param {CustomGrantConfig} config - The config object contains attributes that would be used
596
+ * @param {TokenExchangeRequestConfig} config - The config object contains attributes that would be used
597
597
  * to configure the custom grant request.
598
598
  *
599
599
  * @param {string} userId - The userId of the user.
600
600
  * (If you are using ExpressJS, you may get this from the request cookies)
601
- *
602
- * @return {Promise<TokenResponse | FetchResponse>} -A Promise that resolves with the token information
601
+ *
602
+ * @return {Promise<TokenResponse | Response>} -A Promise that resolves with the token information
603
603
  * or the response returned by the server depending on the configuration passed.
604
604
  *
605
605
  * @example
@@ -607,7 +607,7 @@ var AsgardeoNodeClient = class _AsgardeoNodeClient {
607
607
  * const config = {
608
608
  * attachToken: false,
609
609
  * data: {
610
- * client_id: "{{clientID}}",
610
+ * client_id: "{{clientId}}",
611
611
  * grant_type: "account_switch",
612
612
  * scope: "{{scope}}",
613
613
  * token: "{{token}}",
@@ -618,20 +618,20 @@ var AsgardeoNodeClient = class _AsgardeoNodeClient {
618
618
  * signInRequired: true
619
619
  * }
620
620
 
621
- * auth.requestCustomGrant(config).then((response)=>{
621
+ * auth.exchangeToken(config).then((response)=>{
622
622
  * console.log(response);
623
623
  * }).catch((error)=>{
624
624
  * console.error(error);
625
625
  * });
626
626
  * ```
627
627
  *
628
- * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#requestCustomGrant
628
+ * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#exchangeToken
629
629
  *
630
630
  * @memberof AsgardeoNodeClient
631
631
  *
632
632
  */
633
- async requestCustomGrant(config, userId) {
634
- return this._authCore.requestCustomGrant(config, userId);
633
+ async exchangeToken(config, userId) {
634
+ return this._authCore.exchangeToken(config, userId);
635
635
  }
636
636
  /**
637
637
  * This method can be used to update the configurations passed into the constructor of the AsgardeoAuthClient.
@@ -642,25 +642,25 @@ var AsgardeoNodeClient = class _AsgardeoNodeClient {
642
642
  *
643
643
  * @example
644
644
  * ```
645
- * const updateConfig = await auth.updateConfig({
646
- * signOutRedirectURL: "http://localhost:3000/sign-out"
645
+ * const reInitialize = await auth.reInitialize({
646
+ * afterSignOutUrl: "http://localhost:3000/sign-out"
647
647
  * });
648
648
  * ```
649
649
  *
650
- * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#updateConfig
650
+ * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#reInitialize
651
651
  *
652
652
  * @memberof AsgardeoNodeClient
653
653
  *
654
654
  */
655
- async updateConfig(config) {
656
- return this._authCore.updateConfig(config);
655
+ async reInitialize(config) {
656
+ return this._authCore.reInitialize(config);
657
657
  }
658
658
  /**
659
659
  * This method returns a Promise that resolves with the response returned by the server.
660
660
  * @param {string} userId - The userId of the user.
661
661
  * (If you are using ExpressJS, you may get this from the request cookies)
662
662
  *
663
- * @return {Promise<FetchResponse>} -A Promise that resolves with the response returned by the server.
663
+ * @return {Promise<Response>} -A Promise that resolves with the response returned by the server.
664
664
  *
665
665
  * @example
666
666
  * ```
@@ -698,7 +698,7 @@ var AsgardeoNodeClient = class _AsgardeoNodeClient {
698
698
  }
699
699
  /**
700
700
  * This method returns if the user has been successfully signed out or not.
701
- * @param {string} signOutRedirectURL - The URL to which the user is redirected to
701
+ * @param {string} afterSignOutUrl - The URL to which the user is redirected to
702
702
  * after signing out from the server.
703
703
  *
704
704
  * @return {boolean} - A boolean value indicating if the user has been signed out or not.
@@ -713,12 +713,12 @@ var AsgardeoNodeClient = class _AsgardeoNodeClient {
713
713
  * @memberof AsgardeoNodeClient
714
714
  *
715
715
  */
716
- static isSignOutSuccessful(signOutRedirectURL) {
717
- return _AsgardeoNodeClient.isSignOutSuccessful(signOutRedirectURL);
716
+ static isSignOutSuccessful(afterSignOutUrl) {
717
+ return _AsgardeoNodeClient.isSignOutSuccessful(afterSignOutUrl);
718
718
  }
719
719
  /**
720
720
  * This method returns if sign-out failed or not
721
- * @param {string} signOutRedirectURL - The URL to which the user is redirected to
721
+ * @param {string} afterSignOutUrl - The URL to which the user is redirected to
722
722
  * after signing out from the server.
723
723
  *
724
724
  * @return {boolean} - A boolean value indicating if sign-out failed or not.
@@ -733,11 +733,11 @@ var AsgardeoNodeClient = class _AsgardeoNodeClient {
733
733
  * @memberof AsgardeoNodeClient
734
734
  *
735
735
  */
736
- static didSignOutFail(signOutRedirectURL) {
737
- return _AsgardeoNodeClient.didSignOutFail(signOutRedirectURL);
736
+ static didSignOutFail(afterSignOutUrl) {
737
+ return _AsgardeoNodeClient.didSignOutFail(afterSignOutUrl);
738
738
  }
739
- async getDataLayer() {
740
- return this._authCore.getDataLayer();
739
+ async getStorageManager() {
740
+ return this._authCore.getStorageManager();
741
741
  }
742
742
  };
743
743