|
| 1 | +import * as t from 'io-ts'; |
| 2 | +import { httpRoute, httpRequest, optional } from '@api-ts/io-ts-http'; |
| 3 | +import { BitgoExpressError } from '../../schemas/error'; |
| 4 | + |
| 5 | +export const LoginRequest = { |
| 6 | + password: t.string, |
| 7 | + email: optional(t.string), |
| 8 | + username: optional(t.string), |
| 9 | + otp: optional(t.string), |
| 10 | + trust: optional(t.number), |
| 11 | + forceSMS: optional(t.boolean), |
| 12 | + extensible: optional(t.boolean), |
| 13 | + forceV1Auth: optional(t.boolean), |
| 14 | + /** |
| 15 | + * Whether or not to ensure that the user's ECDH keychain is created. |
| 16 | + * @type {boolean} |
| 17 | + * @default false |
| 18 | + * @description If set to true, the user's ECDH keychain will be created if it does not already exist. |
| 19 | + * The ecdh keychain is a user level keychain that enables the sharing of secret material, |
| 20 | + * primarily for wallet sharing, as well as the signing of less private material such as various cryptographic challenges. |
| 21 | + * It is highly recommended that this is always set to avoid any issues when using a BitGo wallet |
| 22 | + */ |
| 23 | + ensureEcdhKeychain: optional(t.boolean), |
| 24 | + forReset2FA: optional(t.boolean), |
| 25 | + /** |
| 26 | + * The initial stage fingerprint hash used for device identification and verification. |
| 27 | + * @type {string} |
| 28 | + * @default undefined |
| 29 | + * @description An SHA-256 hash string generated from device-specific attributes |
| 30 | + */ |
| 31 | + initialHash: optional(t.string), |
| 32 | + /** |
| 33 | + * The final stage fingerprint hash used for trusted device verification. |
| 34 | + * @type {string} |
| 35 | + * @default undefined |
| 36 | + * @description An SHA-256 hash string derived from the initialHash and verification code |
| 37 | + */ |
| 38 | + fingerprintHash: optional(t.string), |
| 39 | +}; |
| 40 | + |
| 41 | +/** |
| 42 | + * Login |
| 43 | + * |
| 44 | + * @operationId express.login |
| 45 | + */ |
| 46 | +export const PostLogin = httpRoute({ |
| 47 | + path: '/api/v[12]/user/login', |
| 48 | + method: 'POST', |
| 49 | + request: httpRequest({ |
| 50 | + body: LoginRequest, |
| 51 | + }), |
| 52 | + response: { |
| 53 | + 200: t.type({ |
| 54 | + email: t.string, |
| 55 | + password: t.string, |
| 56 | + forceSMS: t.boolean, |
| 57 | + otp: optional(t.string), |
| 58 | + trust: optional(t.number), |
| 59 | + extensible: optional(t.boolean), |
| 60 | + extensionAddress: optional(t.string), |
| 61 | + forceV1Auth: optional(t.boolean), |
| 62 | + forReset2FA: optional(t.boolean), |
| 63 | + initialHash: optional(t.string), |
| 64 | + fingerprintHash: optional(t.string), |
| 65 | + }), |
| 66 | + 404: BitgoExpressError, |
| 67 | + }, |
| 68 | +}); |
0 commit comments