strapi-identity 0.4.2 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/admin/{AdminReset-DOmsyqwQ.mjs → AdminReset-DjVX7phX.mjs} +1 -1
  2. package/dist/admin/{AdminReset-BiWQDTRv.js → AdminReset-DsKz040S.js} +1 -1
  3. package/dist/admin/{ProfileToggle-BUqs_hxZ.js → ProfileToggle-4u6WWddz.js} +1 -1
  4. package/dist/admin/{ProfileToggle-k0d-caPC.mjs → ProfileToggle-B1UK1opI.mjs} +1 -1
  5. package/dist/admin/{SettingsPage-Dm_llkYv.mjs → SettingsPage-CcHTu8-f.mjs} +1 -1
  6. package/dist/admin/{SettingsPage-DVVkN1xw.js → SettingsPage-DZDW9kNI.js} +1 -1
  7. package/dist/admin/{index-DpIJdETG.mjs → index-Bm3H4z3W.mjs} +41 -20
  8. package/dist/admin/{index-B9P8S4CX.js → index-Ce4QOU6Y.js} +41 -20
  9. package/dist/admin/index.js +1 -1
  10. package/dist/admin/index.mjs +1 -1
  11. package/dist/admin/src/components/ConfirmModal/ConfirmModal.d.ts +9 -0
  12. package/dist/admin/src/components/ConfirmModal/index.d.ts +1 -0
  13. package/dist/admin/src/components/EmailOTPModal/EmailOTPModal.d.ts +8 -0
  14. package/dist/admin/src/components/Initializer.d.ts +5 -0
  15. package/dist/admin/src/components/InputOTP.d.ts +11 -0
  16. package/dist/admin/src/components/RemoveModal/RemoveModal.d.ts +6 -0
  17. package/dist/admin/src/components/RemoveModal/index.d.ts +1 -0
  18. package/dist/admin/src/components/WarningAlert/WarningAlert.d.ts +10 -0
  19. package/dist/admin/src/components/WarningAlert/index.d.ts +1 -0
  20. package/dist/admin/src/injection/AdminReset.d.ts +4 -0
  21. package/dist/admin/src/injection/ProfileToggle.d.ts +2 -0
  22. package/dist/admin/src/pages/EnforcedPage.d.ts +13 -0
  23. package/dist/admin/src/pluginId.d.ts +1 -0
  24. package/dist/admin/src/public/VerifyPage.d.ts +12 -0
  25. package/dist/admin/src/settings/SettingsPage.d.ts +1 -0
  26. package/dist/admin/src/utils/getTranslation.d.ts +2 -0
  27. package/dist/admin/src/utils/tokenHelpers.d.ts +12 -0
  28. package/dist/server/index.js +72 -46
  29. package/dist/server/index.mjs +72 -46
  30. package/dist/server/src/bootstrap.d.ts +3 -0
  31. package/dist/server/src/config/index.d.ts +3 -0
  32. package/dist/server/src/content-types/config/index.d.ts +72 -0
  33. package/dist/server/src/content-types/config/schema.json.d.ts +72 -0
  34. package/dist/server/src/content-types/email-otp/index.d.ts +48 -0
  35. package/dist/server/src/content-types/email-otp/schema.json.d.ts +48 -0
  36. package/dist/server/src/content-types/index.d.ts +3 -0
  37. package/dist/server/src/content-types/mfa/index.d.ts +55 -0
  38. package/dist/server/src/content-types/mfa/schema.json.d.ts +55 -0
  39. package/dist/server/src/content-types/temp-mfa/index.d.ts +35 -0
  40. package/dist/server/src/content-types/temp-mfa/schema.json.d.ts +35 -0
  41. package/dist/server/src/controllers/admin.d.ts +4 -0
  42. package/dist/server/src/controllers/config.d.ts +4 -0
  43. package/dist/server/src/controllers/controller.d.ts +8 -0
  44. package/dist/server/src/controllers/index.d.ts +3 -0
  45. package/dist/server/src/destroy.d.ts +3 -0
  46. package/dist/server/src/middlewares/index.d.ts +3 -0
  47. package/dist/server/src/policies/has-mfa.d.ts +3 -0
  48. package/dist/server/src/policies/index.d.ts +3 -0
  49. package/dist/server/src/register.d.ts +3 -0
  50. package/dist/server/src/routes/admin/admin.json.d.ts +35 -0
  51. package/dist/server/src/routes/admin/config.json.d.ts +50 -0
  52. package/dist/server/src/routes/admin/index.d.ts +3 -0
  53. package/dist/server/src/routes/admin/mfa.json.d.ts +94 -0
  54. package/dist/server/src/routes/index.d.ts +3 -0
  55. package/dist/server/src/services/admin.d.ts +11 -0
  56. package/dist/server/src/services/config.d.ts +57 -0
  57. package/dist/server/src/services/email.d.ts +8 -0
  58. package/dist/server/src/services/index.d.ts +3 -0
  59. package/dist/server/src/services/mfa.d.ts +82 -0
  60. package/package.json +6 -5
@@ -0,0 +1,3 @@
1
+ import { Plugin } from '@strapi/types';
2
+ declare const services: Plugin.LoadedPlugin['services'];
3
+ export default services;
@@ -0,0 +1,82 @@
1
+ import { Secret } from 'otpauth';
2
+ /**
3
+ * Validates a TOTP token against the temporary secret for a given user
4
+ * @param userId id of the user to validate against
5
+ * @param token TOTP token to validate
6
+ * @returns {Promise<boolean>} is the token valid
7
+ */
8
+ export declare const validateTempToken: (userId: string, token: string) => Promise<boolean>;
9
+ /**
10
+ * Validates a code against both the user's active TOTP secret and their recovery codes
11
+ * @param userId id of the user to validate against
12
+ * @param code code to validate (either TOTP token or recovery code)
13
+ * @returns {Promise<boolean>} is the code valid
14
+ */
15
+ export declare const validateTokenOrRecoveryCode: (userId: string, code: string) => Promise<boolean>;
16
+ /**
17
+ * Sets up a temporary secret for a user during MFA setup
18
+ * @param userId id of the user to set up MFA for
19
+ * @return {Promise<Secret>} the generated temporary secret
20
+ */
21
+ export declare const setupTemporarySecret: (userId: string) => Promise<Secret>;
22
+ /**
23
+ * Finalizes MFA setup by moving the temporary secret to the main token document and generating recovery codes
24
+ * @param userId id of the user to finalize MFA setup for
25
+ * @returns {Promise<string[]>} the generated recovery codes
26
+ */
27
+ export declare const setupFullSecret: (userId: string) => Promise<string[]>;
28
+ /**
29
+ * Generates a 6-digit email OTP for a user, stores it hashed with expiry, and returns the plaintext code
30
+ * @param userId id of the user to generate an OTP for
31
+ * @param purpose the purpose of the OTP: 'login', 'setup', or 'disable'
32
+ * @returns {Promise<string>} the plaintext OTP
33
+ */
34
+ export declare const generateEmailOTP: (userId: string, purpose?: "login" | "setup" | "disable") => Promise<string>;
35
+ /**
36
+ * Validates an email OTP for a given user and purpose.
37
+ * Increments attempt count, rejects on expiry or too many attempts, removes the record on success.
38
+ * @param userId id of the user to validate against
39
+ * @param code plaintext OTP to validate
40
+ * @param purpose the purpose of the OTP
41
+ * @returns {Promise<boolean>} whether the code is valid
42
+ */
43
+ export declare const validateEmailOTP: (userId: string, code: string, purpose?: "login" | "setup" | "disable") => Promise<boolean>;
44
+ /**
45
+ * Enables email OTP MFA for a user, creating or updating their mfa-token record
46
+ * @param userId id of the user to enable email MFA for
47
+ */
48
+ export declare const enableEmailMFA: (userId: string) => Promise<void>;
49
+ /**
50
+ * Returns the MFA status and method type for a given user
51
+ * @param userId id of the user to check
52
+ * @returns the status and type of MFA, or null if not enabled
53
+ */
54
+ export declare const getMFAInfo: (userId: string) => Promise<{
55
+ status: "full";
56
+ type: "totp" | "email";
57
+ } | null>;
58
+ /**
59
+ * Disables MFA for a user after validating the provided code.
60
+ * For TOTP, validates against TOTP token or recovery code.
61
+ * For email OTP, validates against a previously generated disable OTP.
62
+ * @param userId id of the user to disable MFA for
63
+ * @param code a valid TOTP token, recovery code, or email OTP
64
+ */
65
+ export declare const disableSecret: (userId: string, code: string) => Promise<void>;
66
+ /**
67
+ * Disables the temporary secret for a user, effectively canceling the MFA setup process
68
+ * @param userId id of the user to disable the temporary secret for
69
+ */
70
+ export declare const disableTempSecret: (userId: string) => Promise<void>;
71
+ /**
72
+ * Checks if MFA is currently enabled for a given user
73
+ * @param userId id of the user to check
74
+ * @returns {Promise<'full' | null>} is MFA enabled for the user
75
+ */
76
+ export declare const isMFAEnabled: (userId: string) => Promise<"full" | null>;
77
+ /**
78
+ * Generates a secure random recovery code of the specified length
79
+ * @param length length of the recovery code to generate (default: 8)
80
+ * @returns {string} the generated recovery code
81
+ */
82
+ export declare const generateRecoveryCode: (length?: number) => string;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.4.2",
2
+ "version": "0.5.1",
3
3
  "keywords": [
4
4
  "strapi",
5
5
  "plugin",
@@ -43,16 +43,17 @@
43
43
  "strapi-admin-portal": "^0.3.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@strapi/sdk-plugin": "^6.0.1",
47
- "@strapi/typescript-utils": "^5.40.0",
46
+ "@strapi/sdk-plugin": "^6.1.0",
47
+ "@strapi/typescript-utils": "^5.43.0",
48
48
  "@types/bcryptjs": "^2.4.6",
49
- "@types/react": "^18.3.27",
49
+ "@types/react": "^18.3.28",
50
50
  "@types/react-dom": "^18.3.7",
51
- "prettier": "^3.8.1",
51
+ "prettier": "^3.8.3",
52
52
  "typescript": "^5.9.3"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "@strapi/design-system": "^2.1.2",
56
+ "koa2-ratelimit": "^1.1.3",
56
57
  "@strapi/email": "^5.39.0",
57
58
  "@strapi/icons": "^2.1.2",
58
59
  "@strapi/sdk-plugin": "^5.4.0",