(domainId: string, uname: string, login: boolean)
| 164 | @param('uname', Types.Username, true) |
| 165 | @param('login', Types.Boolean) |
| 166 | async get(domainId: string, uname: string, login: boolean) { |
| 167 | let allowCredentials = []; |
| 168 | let uid = 0; |
| 169 | if (!login) { |
| 170 | const udoc = this.user._id ? this.user : ((await user.getByEmail(domainId, uname)) || await user.getByUname(domainId, uname)); |
| 171 | if (!udoc._id) throw new UserNotFoundError(uname || 'user'); |
| 172 | if (!udoc.authn) throw new AuthOperationError('authn', 'disabled'); |
| 173 | allowCredentials = udoc._authenticators.map((authenticator) => ({ |
| 174 | id: isoBase64URL.fromBuffer(new Uint8Array(authenticator.credentialID.buffer)), |
| 175 | })); |
| 176 | uid = udoc._id; |
| 177 | } |
| 178 | const options = await generateAuthenticationOptions({ |
| 179 | allowCredentials, |
| 180 | rpID: this.getAuthnHost(), |
| 181 | userVerification: 'preferred', |
| 182 | }); |
| 183 | await token.add(token.TYPE_WEBAUTHN, 60, { uid: login ? 'login' : uid }, options.challenge); |
| 184 | this.session.challenge = options.challenge; |
| 185 | this.response.body.authOptions = options; |
| 186 | } |
| 187 | |
| 188 | async post({ domainId, result, redirect }) { |
| 189 | const challenge = this.session.challenge; |
nothing calls this directly
no test coverage detected