1616 * under the License.
1717 */
1818
19- import { OIDC_SCOPE , OP_CONFIG_INITIATED , ResponseMode , SIGN_OUT_SUCCESS_PARAM } from "./constants" ;
19+ import { OIDC_SCOPE , OP_CONFIG_INITIATED , ResponseMode , SIGN_OUT_SUCCESS_PARAM , STATE } from "./constants" ;
2020import { AuthenticationCore } from "./core" ;
2121import { DataLayer } from "./data" ;
2222import {
@@ -205,7 +205,7 @@ export class AsgardeoAuthClient<T> {
205205 }
206206
207207 return this . _authenticationCore . getOIDCProviderMetaData ( false ) . then ( ( ) => {
208- return this . _authenticationCore . requestAccessToken ( authorizationCode , sessionState , state , userID ) ;
208+ return this . _authenticationCore . requestAccessToken ( authorizationCode , sessionState , state , userID ) ;
209209 } ) ;
210210 }
211211
@@ -498,6 +498,7 @@ export class AsgardeoAuthClient<T> {
498498 *
499499 * @param {string } userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
500500 * scenarios where each user should be uniquely identified.
501+ * @param {string } state - The state parameter that was passed in the authentication URL.
501502 *
502503 * @return {Promise<string> } - A Promise that resolves with the PKCE code.
503504 *
@@ -512,15 +513,15 @@ export class AsgardeoAuthClient<T> {
512513 *
513514 * @preserve
514515 */
515- public async getPKCECode ( userID ?: string ) : Promise < string > {
516- return this . _authenticationCore . getPKCECode ( userID ) ;
516+ public async getPKCECode ( state : string , userID ?: string ) : Promise < string > {
517+ return this . _authenticationCore . getPKCECode ( state , userID ) ;
517518 }
518519
519520 /**
520521 * This method sets the PKCE code to the data store.
521522 *
522523 * @param {string } pkce - The PKCE code.
523- *
524+ * @param { string } state - The state parameter that was passed in the authentication URL.
524525 * @param {string } userID - (Optional) A unique ID of the user to be authenticated. This is useful in multi-user
525526 * scenarios where each user should be uniquely identified.
526527 *
@@ -535,8 +536,8 @@ export class AsgardeoAuthClient<T> {
535536 *
536537 * @preserve
537538 */
538- public async setPKCECode ( pkce : string , userID ?: string ) : Promise < void > {
539- await this . _authenticationCore . setPKCECode ( pkce , userID ) ;
539+ public async setPKCECode ( pkce : string , state : string , userID ?: string ) : Promise < void > {
540+ await this . _authenticationCore . setPKCECode ( pkce , state , userID ) ;
540541 }
541542
542543 /**
@@ -557,12 +558,36 @@ export class AsgardeoAuthClient<T> {
557558 */
558559 public static isSignOutSuccessful ( signOutRedirectURL : string ) : boolean {
559560 const url = new URL ( signOutRedirectURL ) ;
560- const stateParam = url . searchParams . get ( "state" ) ;
561+ const stateParam = url . searchParams . get ( STATE ) ;
561562 const error = Boolean ( url . searchParams . get ( "error" ) ) ;
562563
563564 return stateParam ? stateParam === SIGN_OUT_SUCCESS_PARAM && ! error : false ;
564565 }
565566
567+ /**
568+ * This method returns if the sign-out has failed or not.
569+ *
570+ * @param {string } signOutRedirectUrl - The URL to which the user has been redirected to after signing-out.
571+ *
572+ * **The server appends path parameters to the `signOutRedirectURL` and these path parameters
573+ * are required for this method to function.**
574+ *
575+ * @return {boolean } - `true` if successful, `false` otherwise.
576+ *
577+ * @link https://github.com/asgardeo/asgardeo-auth-js-sdk/tree/master#didSignOutFail
578+ *
579+ * @memberof AsgardeoAuthClient
580+ *
581+ * @preserve
582+ */
583+ public static didSignOutFail ( signOutRedirectURL : string ) : boolean {
584+ const url = new URL ( signOutRedirectURL ) ;
585+ const stateParam = url . searchParams . get ( STATE ) ;
586+ const error = Boolean ( url . searchParams . get ( "error" ) ) ;
587+
588+ return stateParam ? stateParam === SIGN_OUT_SUCCESS_PARAM && error : false ;
589+ }
590+
566591 /**
567592 * This method updates the configuration that was passed into the constructor when instantiating this class.
568593 *
0 commit comments