(params: LoginParams)
| 208 | } |
| 209 | |
| 210 | async login(params: LoginParams): Promise<{ privKey: string } | null> { |
| 211 | if (!params.authConnection && (!params.authConnectionId || !params.groupedAuthConnectionId)) |
| 212 | throw LoginError.invalidLoginParams(`AuthConnection is required`); |
| 213 | |
| 214 | const loginParams: LoginParams = { ...params }; |
| 215 | |
| 216 | const dataObject: AuthRequestPayload = { |
| 217 | actionType: AUTH_ACTIONS.LOGIN, |
| 218 | options: this.options, |
| 219 | params: loginParams, |
| 220 | }; |
| 221 | |
| 222 | const result = await this.authHandler(`${this.baseUrl}/start`, dataObject, getTimeout(params.authConnection as AUTH_CONNECTION_TYPE)); |
| 223 | if (!result) return null; |
| 224 | if (isAuthFlowError(result)) { |
| 225 | this.dappState = result.state; |
| 226 | throw LoginError.loginFailed(result.error); |
| 227 | } |
| 228 | await this.sessionManager.setTokens({ |
| 229 | sessionId: add0x(result.sessionId), |
| 230 | accessToken: result.accessToken, |
| 231 | refreshToken: result.refreshToken, |
| 232 | idToken: result.idToken, |
| 233 | }); |
| 234 | await this.refreshSession(); |
| 235 | return { privKey: this.privKey }; |
| 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."); |
no test coverage detected