(params: LoginParams, nonce?: string)
| 236 | } |
| 237 | |
| 238 | async postLoginInitiatedMessage(params: LoginParams, nonce?: string): Promise<void> { |
| 239 | if (this.options.sdkMode !== SDK_MODE.IFRAME) throw LoginError.invalidLoginParams("Cannot perform this action in default mode."); |
| 240 | // This is to ensure that the auth provider is initialized before calling postLoginInitiatedMessage |
| 241 | // This is setup in the init method, if there is no active session. |
| 242 | if (this.authProviderPromise) await this.authProviderPromise; |
| 243 | |
| 244 | // if there is an active session, we dont load the auth provider in the init method. |
| 245 | // so we need to initialize it here, if user logged out and then login in again. |
| 246 | if (!this.authProvider?.initialized) { |
| 247 | await this.authProvider.init({ network: this.options.network, clientId: this.options.clientId }); |
| 248 | } |
| 249 | |
| 250 | const result = await this.authProvider.postLoginInitiatedMessage({ actionType: AUTH_ACTIONS.LOGIN, params, options: this.options }, nonce); |
| 251 | await this.sessionManager.setTokens({ |
| 252 | sessionId: add0x(result.sessionId), |
| 253 | accessToken: result.accessToken, |
| 254 | refreshToken: result.refreshToken, |
| 255 | idToken: result.idToken, |
| 256 | }); |
| 257 | this.options.sessionNamespace = result.sessionNamespace; |
| 258 | await this.refreshSession(); |
| 259 | } |
| 260 | |
| 261 | async postLoginCancelledMessage(nonce: string): Promise<void> { |
| 262 | if (this.options.sdkMode !== SDK_MODE.IFRAME) throw LoginError.invalidLoginParams("Cannot perform this action in default mode."); |
no test coverage detected