@fonderie/auth 1.0.0

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 (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +51 -0
  3. package/dist/dtos/user.cjs +66 -0
  4. package/dist/dtos/user.cjs.map +1 -0
  5. package/dist/dtos/user.d.cts +24 -0
  6. package/dist/dtos/user.d.ts +24 -0
  7. package/dist/dtos/user.js +41 -0
  8. package/dist/dtos/user.js.map +1 -0
  9. package/dist/index.cjs +1952 -0
  10. package/dist/index.cjs.map +1 -0
  11. package/dist/index.d.cts +22 -0
  12. package/dist/index.d.ts +22 -0
  13. package/dist/index.js +1915 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/middlewares/index.cjs +303 -0
  16. package/dist/middlewares/index.cjs.map +1 -0
  17. package/dist/middlewares/index.d.cts +10 -0
  18. package/dist/middlewares/index.d.ts +10 -0
  19. package/dist/middlewares/index.js +270 -0
  20. package/dist/middlewares/index.js.map +1 -0
  21. package/dist/migrations/index.js +7 -0
  22. package/dist/migrations/index.js.map +1 -0
  23. package/dist/migrations/sql/001_auth.sql +73 -0
  24. package/dist/migrations/sql/002_phone_auth.sql +20 -0
  25. package/dist/migrations/sql/003_phone_registration_name.sql +4 -0
  26. package/dist/migrations/sql/004_drop_phone_verif_name_cols.sql +5 -0
  27. package/dist/migrations/sql/005_phone_verification_user_id.sql +6 -0
  28. package/dist/migrations/sql/006_drop_phone_verified_at.sql +1 -0
  29. package/dist/migrations/sql/007_email_verif_user_id_pk.sql +14 -0
  30. package/dist/migrations/sql/008_password_reset_pin.sql +4 -0
  31. package/dist/migrations/sql/009_password_reset_created_at.sql +1 -0
  32. package/dist/migrations/sql/010_mfa_pending_secret.sql +3 -0
  33. package/dist/migrations/sql/011_mfa_backup_codes.sql +10 -0
  34. package/dist/migrations/sql/012_drop_skills.sql +1 -0
  35. package/dist/session-CLD1WPJs.d.cts +41 -0
  36. package/dist/session-CLD1WPJs.d.ts +41 -0
  37. package/dist/types.cjs +19 -0
  38. package/dist/types.cjs.map +1 -0
  39. package/dist/types.d.cts +52 -0
  40. package/dist/types.d.ts +52 -0
  41. package/dist/types.js +1 -0
  42. package/dist/types.js.map +1 -0
  43. package/package.json +100 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["export interface IUserPreferences {\n\tlocale: string;\n\ttimezone: string;\n\tnotifications: {\n\t\temail: boolean;\n\t\tinApp: boolean;\n\t\tsms: boolean;\n\t\tpush: boolean;\n\t};\n\temailDigest: string;\n\tdateFormat?: string;\n\ttimeFormat?: string;\n}\n\n// Concrete types — fulfill the stubs in @fonderie/core\nexport interface IUser {\n\tid: string;\n\temail: string | null;\n\tfirstName: string | null;\n\tlastName: string | null;\n\tphone: string | null;\n\tprofileImageUrl: string | null;\n\tlocale: string;\n\ttimezone: string;\n\tisActive: boolean;\n\tlastLogin: Date | null;\n\tpreferences: IUserPreferences;\n\tsuspended: boolean;\n\twhitelist: boolean;\n\tipWhitelist: string[];\n\tdeletedAt: Date | null;\n\tcreatedAt: Date;\n\tupdatedAt: Date;\n\tmfaEnabled: boolean;\n\tpasswordHash: string | null;\n\temailVerifiedAt: Date | null;\n}\n\nexport interface ISession {\n\tid: string;\n\ttoken: string;\n\tuserId: string;\n\tuserAgent: string | null;\n\tipAddress: string | null;\n\texpiresAt: Date;\n\tcreatedAt: Date;\n}\n\nexport interface IMfaChallenge {\n\ttoken: string;\n\tuserId: string;\n\texpiresAt: Date;\n\tusedAt: Date | null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,52 @@
1
+ interface IUserPreferences {
2
+ locale: string;
3
+ timezone: string;
4
+ notifications: {
5
+ email: boolean;
6
+ inApp: boolean;
7
+ sms: boolean;
8
+ push: boolean;
9
+ };
10
+ emailDigest: string;
11
+ dateFormat?: string;
12
+ timeFormat?: string;
13
+ }
14
+ interface IUser {
15
+ id: string;
16
+ email: string | null;
17
+ firstName: string | null;
18
+ lastName: string | null;
19
+ phone: string | null;
20
+ profileImageUrl: string | null;
21
+ locale: string;
22
+ timezone: string;
23
+ isActive: boolean;
24
+ lastLogin: Date | null;
25
+ preferences: IUserPreferences;
26
+ suspended: boolean;
27
+ whitelist: boolean;
28
+ ipWhitelist: string[];
29
+ deletedAt: Date | null;
30
+ createdAt: Date;
31
+ updatedAt: Date;
32
+ mfaEnabled: boolean;
33
+ passwordHash: string | null;
34
+ emailVerifiedAt: Date | null;
35
+ }
36
+ interface ISession {
37
+ id: string;
38
+ token: string;
39
+ userId: string;
40
+ userAgent: string | null;
41
+ ipAddress: string | null;
42
+ expiresAt: Date;
43
+ createdAt: Date;
44
+ }
45
+ interface IMfaChallenge {
46
+ token: string;
47
+ userId: string;
48
+ expiresAt: Date;
49
+ usedAt: Date | null;
50
+ }
51
+
52
+ export type { IMfaChallenge, ISession, IUser, IUserPreferences };
@@ -0,0 +1,52 @@
1
+ interface IUserPreferences {
2
+ locale: string;
3
+ timezone: string;
4
+ notifications: {
5
+ email: boolean;
6
+ inApp: boolean;
7
+ sms: boolean;
8
+ push: boolean;
9
+ };
10
+ emailDigest: string;
11
+ dateFormat?: string;
12
+ timeFormat?: string;
13
+ }
14
+ interface IUser {
15
+ id: string;
16
+ email: string | null;
17
+ firstName: string | null;
18
+ lastName: string | null;
19
+ phone: string | null;
20
+ profileImageUrl: string | null;
21
+ locale: string;
22
+ timezone: string;
23
+ isActive: boolean;
24
+ lastLogin: Date | null;
25
+ preferences: IUserPreferences;
26
+ suspended: boolean;
27
+ whitelist: boolean;
28
+ ipWhitelist: string[];
29
+ deletedAt: Date | null;
30
+ createdAt: Date;
31
+ updatedAt: Date;
32
+ mfaEnabled: boolean;
33
+ passwordHash: string | null;
34
+ emailVerifiedAt: Date | null;
35
+ }
36
+ interface ISession {
37
+ id: string;
38
+ token: string;
39
+ userId: string;
40
+ userAgent: string | null;
41
+ ipAddress: string | null;
42
+ expiresAt: Date;
43
+ createdAt: Date;
44
+ }
45
+ interface IMfaChallenge {
46
+ token: string;
47
+ userId: string;
48
+ expiresAt: Date;
49
+ usedAt: Date | null;
50
+ }
51
+
52
+ export type { IMfaChallenge, ISession, IUser, IUserPreferences };
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json ADDED
@@ -0,0 +1,100 @@
1
+ {
2
+ "name": "@fonderie/auth",
3
+ "version": "1.0.0",
4
+ "description": "Drop-in auth for SaaS — email/password, phone OTP, Google OAuth, stateless JWT sessions, TOTP-based MFA with backup codes, and self-service password recovery.",
5
+ "keywords": [
6
+ "fonderie-js",
7
+ "auth",
8
+ "authentication",
9
+ "jwt",
10
+ "oauth",
11
+ "mfa",
12
+ "totp",
13
+ "otp",
14
+ "sessions",
15
+ "saas",
16
+ "typescript"
17
+ ],
18
+ "license": "MIT",
19
+ "type": "module",
20
+ "engines": {
21
+ "node": ">=20"
22
+ },
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "import": "./dist/index.js",
27
+ "require": "./dist/index.cjs"
28
+ },
29
+ "./types": {
30
+ "types": "./dist/types.d.ts",
31
+ "import": "./dist/types.js",
32
+ "require": "./dist/types.cjs"
33
+ },
34
+ "./middleware": {
35
+ "types": "./dist/middlewares/index.d.ts",
36
+ "import": "./dist/middlewares/index.js",
37
+ "require": "./dist/middlewares/index.cjs"
38
+ },
39
+ "./migrations": {
40
+ "types": "./dist/migrations/index.d.ts",
41
+ "import": "./dist/migrations/index.js"
42
+ }
43
+ },
44
+ "main": "./dist/index.cjs",
45
+ "module": "./dist/index.js",
46
+ "types": "./dist/index.d.ts",
47
+ "scripts": {
48
+ "build": "tsup && node -e \"require('node:fs').cpSync('src/migrations/sql', 'dist/migrations/sql', {recursive:true})\"",
49
+ "dev": "tsup --watch",
50
+ "typecheck": "tsc --noEmit",
51
+ "test": "tsx --test src/__tests__/*.test.ts",
52
+ "lint": "biome lint src",
53
+ "format": "biome format --write src",
54
+ "check": "biome check --write src"
55
+ },
56
+ "dependencies": {
57
+ "bcryptjs": "^3.0.3",
58
+ "jsonwebtoken": "^9.0.3",
59
+ "qrcode": "^1.5.4"
60
+ },
61
+ "peerDependencies": {
62
+ "@fonderie/core": "^0.1.0",
63
+ "@fonderie/store": "^0.1.0",
64
+ "@fonderie/events": "^1.0.0"
65
+ },
66
+ "peerDependenciesMeta": {
67
+ "@fonderie/events": {
68
+ "optional": true
69
+ }
70
+ },
71
+ "devDependencies": {
72
+ "@fonderie/core": "../core",
73
+ "@fonderie/store": "../store",
74
+ "@fonderie/events": "../events",
75
+ "@types/bcryptjs": "^2.4.6",
76
+ "@types/jsonwebtoken": "^9.0.10",
77
+ "@types/node": "^25.6.0",
78
+ "@types/qrcode": "^1.5.6",
79
+ "tsup": "^8.5.1",
80
+ "tsx": "^4.21.0",
81
+ "typescript": "^6.0.3"
82
+ },
83
+ "publishConfig": {
84
+ "access": "public"
85
+ },
86
+ "files": [
87
+ "dist",
88
+ "LICENSE",
89
+ "README.md"
90
+ ],
91
+ "repository": {
92
+ "type": "git",
93
+ "url": "git+https://github.com/fonderie-js/sdk.git",
94
+ "directory": "packages/auth"
95
+ },
96
+ "homepage": "https://github.com/fonderie-js/sdk/tree/main/packages/auth#readme",
97
+ "bugs": {
98
+ "url": "https://github.com/fonderie-js/sdk/issues"
99
+ }
100
+ }