1 /**
2 * @oas [post] /auth/mfa/recovery-codes
3 * operationId: PostMfaRecoveryCodes
4 * summary: Generate Multi-Factor Authentication (MFA) Recovery Codes
5 * x-sidebar-summary: Generate MFA Recovery Codes
6 * description: |
7 * Generate a new set of single-use recovery codes for the authenticated user. Recovery codes can
8 * be used to verify MFA challenges when the user does not have access to their primary MFA
9 * factor. Generating new codes replaces any previously issued codes, so they should be stored in
10 * a safe place. At least one enabled MFA factor is required to generate recovery codes.
11 * x-authenticated: true
12 * externalDocs:
13 * description: Learn more about MFA in Medusa
14 * url: https://docs.medusajs.com/resources/commerce-modules/auth/mfa
15 * parameters: []
16 * requestBody:
17 * content:
18 * application/json:
19 * schema:
20 * type: object
21 * description: The options to use when generating recovery codes.
22 * properties:
23 * count:
24 * type: number
25 * title: count
26 * description: The number of recovery codes to generate. Must be between 1 and 50. Defaults to the provider's configured value when omitted.
27 * x-codeSamples:
28 * - lang: JavaScript
29 * label: JS SDK
30 * source: |-
31 * import Medusa from "@medusajs/js-sdk"
32 *
33 * export const sdk = new Medusa({
34 * baseUrl: import.meta.env.VITE_BACKEND_URL || "/",
35 * debug: import.meta.env.DEV,
36 * auth: {
37 * type: "session",
38 * },
39 * })
40 *
41 * const { recovery_codes } = await sdk.auth.mfa.generateRecoveryCodes()
42 * - lang: Shell
43 * label: cURL
44 * source: curl -X POST '{backend_url}/auth/mfa/recovery-codes'
45 * tags:
46 * - Multi-Factor Authentication
47 * responses:
48 * "200":
49 * description: OK
50 * "400":
51 * $ref: "#/components/responses/400_error"
52 * "401":
53 * $ref: "#/components/responses/unauthorized"
54 * "404":
55 * $ref: "#/components/responses/not_found_error"
56 * "409":
57 * $ref: "#/components/responses/invalid_state_error"
58 * "422":
59 * $ref: "#/components/responses/invalid_request_error"
60 * "500":
61 * $ref: "#/components/responses/500_error"
62 * x-since: 2.15.3
63 */
64