@driveflux/auth 4.0.88 → 4.0.90

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 (46) hide show
  1. package/dist/AuthProvider.d.ts.map +1 -1
  2. package/dist/AuthProvider.js +60 -79
  3. package/dist/authorization/define.js +28 -57
  4. package/dist/authorization/fields/index.js +7 -4
  5. package/dist/authorization/helpers.js +8 -10
  6. package/dist/authorization/index.js +6 -6
  7. package/dist/authorization/permissions-list.js +7 -5
  8. package/dist/authorization/quick.js +1 -1
  9. package/dist/authorization/roles/admin/business-development-executive.js +7 -20
  10. package/dist/authorization/roles/admin/ceo.js +2 -4
  11. package/dist/authorization/roles/admin/common.d.ts.map +1 -1
  12. package/dist/authorization/roles/admin/common.js +3 -5
  13. package/dist/authorization/roles/admin/concierge.js +10 -35
  14. package/dist/authorization/roles/admin/customer-success-executive.js +10 -40
  15. package/dist/authorization/roles/admin/data-analyst.js +4 -7
  16. package/dist/authorization/roles/admin/designer.js +4 -7
  17. package/dist/authorization/roles/admin/engineer.js +4 -7
  18. package/dist/authorization/roles/admin/finance-executive.js +4 -11
  19. package/dist/authorization/roles/admin/head-of-business-development.js +4 -14
  20. package/dist/authorization/roles/admin/head-of-data-analytics.js +4 -14
  21. package/dist/authorization/roles/admin/head-of-engineering.js +6 -17
  22. package/dist/authorization/roles/admin/head-of-finance.js +3 -8
  23. package/dist/authorization/roles/admin/head-of-human-resources.js +5 -13
  24. package/dist/authorization/roles/admin/head-of-marketing.js +5 -17
  25. package/dist/authorization/roles/admin/head-of-operations.js +3 -8
  26. package/dist/authorization/roles/admin/head-of-product.js +6 -17
  27. package/dist/authorization/roles/admin/head-of-sales.js +5 -17
  28. package/dist/authorization/roles/admin/human-resources-executive.js +5 -12
  29. package/dist/authorization/roles/admin/marketing-executive.js +4 -7
  30. package/dist/authorization/roles/admin/product-manager.js +4 -7
  31. package/dist/authorization/roles/admin/sales-executive.js +8 -24
  32. package/dist/authorization/roles/consumer/business-admin.js +6 -19
  33. package/dist/authorization/roles/consumer/business-user.js +6 -18
  34. package/dist/authorization/roles/consumer/member.js +6 -16
  35. package/dist/authorization/types.js +1 -1
  36. package/dist/authorization/update-user-permissions.js +15 -22
  37. package/dist/authorization/utils.js +11 -26
  38. package/dist/server/authenticate-user.js +7 -11
  39. package/dist/server/cors.js +12 -23
  40. package/dist/server/credentials-provider.js +2 -2
  41. package/dist/server/next-auth.d.ts +12 -1
  42. package/dist/server/next-auth.d.ts.map +1 -1
  43. package/dist/server/next-auth.js +109 -104
  44. package/dist/server/prisma-adapter.js +52 -88
  45. package/dist/server/verfiy-token.js +24 -39
  46. package/package.json +16 -16
@@ -1,36 +1,29 @@
1
1
  import { prisma } from '@driveflux/db';
2
- import { makeProblem, PROBLEM_CORRUPT, PROBLEM_EXPIRED, PROBLEM_INVALID_DATA } from '@driveflux/problem';
2
+ import { makeProblem, PROBLEM_CORRUPT, PROBLEM_EXPIRED, PROBLEM_INVALID_DATA, } from '@driveflux/problem';
3
3
  import { Err, Ok } from '@driveflux/result';
4
- export const verifyToken = async (tokenIdOrValue, verifications, option)=>{
5
- const token = typeof tokenIdOrValue === 'object' ? tokenIdOrValue : await prisma.token.findFirst({
6
- where: {
7
- OR: [
8
- {
9
- id: tokenIdOrValue
10
- },
11
- {
12
- value: tokenIdOrValue
13
- }
14
- ]
15
- },
16
- ...option?.includeUser ? {
17
- include: {
18
- user: true
19
- }
20
- } : {}
21
- });
4
+ export const verifyToken = async (tokenIdOrValue, verifications, option) => {
5
+ const token = typeof tokenIdOrValue === 'object'
6
+ ? tokenIdOrValue
7
+ : (await prisma.token.findFirst({
8
+ where: {
9
+ OR: [{ id: tokenIdOrValue }, { value: tokenIdOrValue }],
10
+ },
11
+ ...(option?.includeUser ? { include: { user: true } } : {}),
12
+ }));
22
13
  if (!token) {
23
14
  return new Err(makeProblem(PROBLEM_INVALID_DATA, 'Invalid token'));
24
15
  }
25
16
  if (token.expiresAt && token.expiresAt.getTime() < Date.now()) {
26
17
  return new Err(makeProblem(PROBLEM_EXPIRED, 'This token has expired'));
27
18
  }
28
- if (typeof verifications?.scope !== 'undefined' && token.scope !== verifications.scope) {
19
+ if (typeof verifications?.scope !== 'undefined' &&
20
+ token.scope !== verifications.scope) {
29
21
  return new Err(makeProblem(PROBLEM_INVALID_DATA, 'Invalid token scope'));
30
22
  }
31
23
  if (typeof verifications?.metadata !== 'undefined') {
32
- for (const key of Object.keys(verifications.metadata)){
33
- if (typeof verifications.metadata[key] !== 'undefined' && verifications.metadata[key] !== token.metadata?.[key]) {
24
+ for (const key of Object.keys(verifications.metadata)) {
25
+ if (typeof verifications.metadata[key] !== 'undefined' &&
26
+ verifications.metadata[key] !== token.metadata?.[key]) {
34
27
  return new Err(makeProblem(PROBLEM_INVALID_DATA, 'Invalid token data'));
35
28
  }
36
29
  }
@@ -40,30 +33,22 @@ export const verifyToken = async (tokenIdOrValue, verifications, option)=>{
40
33
  }
41
34
  return new Ok(token);
42
35
  };
43
- export const clearToken = async (tokenId)=>{
36
+ export const clearToken = async (tokenId) => {
44
37
  try {
45
38
  await prisma.token.delete({
46
39
  where: {
47
- id: tokenId
48
- }
40
+ id: tokenId,
41
+ },
49
42
  });
50
- } catch (_e) {
51
- // Nothing to for now
43
+ }
44
+ catch (_e) {
45
+ // Nothing to for now
52
46
  }
53
47
  };
54
- export const clearExpiredTokens = async ()=>{
48
+ export const clearExpiredTokens = async () => {
55
49
  await prisma.token.deleteMany({
56
50
  where: {
57
- OR: [
58
- {
59
- expiresAt: {
60
- lte: new Date()
61
- }
62
- },
63
- {
64
- invalid: true
65
- }
66
- ]
67
- }
51
+ OR: [{ expiresAt: { lte: new Date() } }, { invalid: true }],
52
+ },
68
53
  });
69
54
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@driveflux/auth",
3
- "version": "4.0.88",
3
+ "version": "4.0.90",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -74,34 +74,34 @@
74
74
  "dependencies": {
75
75
  "@casl/ability": "^6.8.1",
76
76
  "@casl/prisma": "^1.6.2",
77
- "@driveflux/config": "3.0.11",
78
- "@driveflux/db": "4.1.19",
79
- "@driveflux/fetch": "8.0.2",
80
- "@driveflux/problem": "6.0.2",
81
- "@driveflux/reporter": "7.0.3",
82
- "@driveflux/result": "6.0.2",
83
- "@driveflux/singleton": "3.0.1",
84
- "@driveflux/ui": "3.0.4",
85
- "@driveflux/utils": "6.0.1",
86
- "@driveflux/web-analytics": "3.0.4",
77
+ "@driveflux/config": "3.0.12",
78
+ "@driveflux/db": "4.1.20",
79
+ "@driveflux/fetch": "8.0.3",
80
+ "@driveflux/problem": "6.0.3",
81
+ "@driveflux/reporter": "7.0.4",
82
+ "@driveflux/result": "6.0.3",
83
+ "@driveflux/singleton": "3.0.2",
84
+ "@driveflux/ui": "3.0.5",
85
+ "@driveflux/utils": "6.0.2",
86
+ "@driveflux/web-analytics": "3.0.5",
87
87
  "@types/cors": "^2.8.19",
88
88
  "bcryptjs": "^3.0.3",
89
89
  "change-case": "^5.4.4",
90
90
  "cors": "^2.8.6",
91
91
  "jose": "^6.2.3",
92
- "js-cookie": "^3.0.5",
92
+ "js-cookie": "^3.0.7",
93
93
  "nanoid": "^5.1.11",
94
94
  "next-auth": "4.24.14",
95
95
  "universal-cookie": "^8.1.2"
96
96
  },
97
97
  "devDependencies": {
98
- "@driveflux/fab": "4.0.1",
99
- "@driveflux/tsconfig": "3.0.1",
98
+ "@driveflux/fab": "4.0.2",
99
+ "@driveflux/tsconfig": "3.0.2",
100
100
  "@swc/cli": "^0.8.1",
101
101
  "@swc/core": "^1.15.33",
102
102
  "@types/js-cookie": "^3.0.6",
103
- "@types/node": "^25.7.0",
104
- "@types/react": "19.2.14",
103
+ "@types/node": "^25.9.1",
104
+ "@types/react": "19.2.15",
105
105
  "del-cli": "^7.0.0",
106
106
  "next": "16.2.6",
107
107
  "react": "19.2.6",