@driveflux/auth 4.0.90 → 4.0.92
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.
- package/dist/AuthProvider.d.ts +1 -0
- package/dist/AuthProvider.js +76 -59
- package/dist/ability.d.ts +1 -0
- package/dist/authorization/casl-prisma.d.ts +3 -0
- package/dist/authorization/casl-prisma.d.ts.map +1 -0
- package/dist/authorization/casl-prisma.js +2 -0
- package/dist/authorization/constants.d.ts +2 -1
- package/dist/authorization/define.d.ts +1 -0
- package/dist/authorization/define.js +57 -28
- package/dist/authorization/fields/index.d.ts +1 -0
- package/dist/authorization/fields/index.js +4 -7
- package/dist/authorization/helpers.d.ts +1 -0
- package/dist/authorization/helpers.js +10 -8
- package/dist/authorization/index.d.ts +1 -0
- package/dist/authorization/index.d.ts.map +1 -1
- package/dist/authorization/index.js +6 -6
- package/dist/authorization/permissions-list.d.ts +1 -0
- package/dist/authorization/permissions-list.js +5 -7
- package/dist/authorization/quick.d.ts +3 -1
- package/dist/authorization/quick.d.ts.map +1 -1
- package/dist/authorization/quick.js +1 -1
- package/dist/authorization/roles/admin/business-development-executive.d.ts +1 -0
- package/dist/authorization/roles/admin/business-development-executive.js +20 -7
- package/dist/authorization/roles/admin/ceo.d.ts +1 -0
- package/dist/authorization/roles/admin/ceo.js +4 -2
- package/dist/authorization/roles/admin/common.d.ts +1 -0
- package/dist/authorization/roles/admin/common.js +5 -3
- package/dist/authorization/roles/admin/concierge.d.ts +1 -0
- package/dist/authorization/roles/admin/concierge.js +35 -10
- package/dist/authorization/roles/admin/customer-success-executive.d.ts +1 -0
- package/dist/authorization/roles/admin/customer-success-executive.js +40 -10
- package/dist/authorization/roles/admin/data-analyst.d.ts +1 -0
- package/dist/authorization/roles/admin/data-analyst.js +7 -4
- package/dist/authorization/roles/admin/designer.d.ts +1 -0
- package/dist/authorization/roles/admin/designer.js +7 -4
- package/dist/authorization/roles/admin/engineer.d.ts +1 -0
- package/dist/authorization/roles/admin/engineer.js +7 -4
- package/dist/authorization/roles/admin/finance-executive.d.ts +1 -0
- package/dist/authorization/roles/admin/finance-executive.js +11 -4
- package/dist/authorization/roles/admin/head-of-business-development.d.ts +1 -0
- package/dist/authorization/roles/admin/head-of-business-development.js +14 -4
- package/dist/authorization/roles/admin/head-of-data-analytics.d.ts +1 -0
- package/dist/authorization/roles/admin/head-of-data-analytics.js +14 -4
- package/dist/authorization/roles/admin/head-of-engineering.d.ts +1 -0
- package/dist/authorization/roles/admin/head-of-engineering.js +17 -6
- package/dist/authorization/roles/admin/head-of-finance.d.ts +1 -0
- package/dist/authorization/roles/admin/head-of-finance.js +8 -3
- package/dist/authorization/roles/admin/head-of-human-resources.d.ts +1 -0
- package/dist/authorization/roles/admin/head-of-human-resources.js +13 -5
- package/dist/authorization/roles/admin/head-of-marketing.d.ts +1 -0
- package/dist/authorization/roles/admin/head-of-marketing.js +17 -5
- package/dist/authorization/roles/admin/head-of-operations.d.ts +1 -0
- package/dist/authorization/roles/admin/head-of-operations.js +8 -3
- package/dist/authorization/roles/admin/head-of-product.d.ts +1 -0
- package/dist/authorization/roles/admin/head-of-product.js +17 -6
- package/dist/authorization/roles/admin/head-of-sales.d.ts +1 -0
- package/dist/authorization/roles/admin/head-of-sales.js +17 -5
- package/dist/authorization/roles/admin/human-resources-executive.d.ts +1 -0
- package/dist/authorization/roles/admin/human-resources-executive.js +12 -5
- package/dist/authorization/roles/admin/marketing-executive.d.ts +1 -0
- package/dist/authorization/roles/admin/marketing-executive.js +7 -4
- package/dist/authorization/roles/admin/product-manager.d.ts +1 -0
- package/dist/authorization/roles/admin/product-manager.js +7 -4
- package/dist/authorization/roles/admin/sales-executive.d.ts +1 -0
- package/dist/authorization/roles/admin/sales-executive.js +24 -8
- package/dist/authorization/roles/consumer/business-admin.d.ts +1 -0
- package/dist/authorization/roles/consumer/business-admin.js +19 -6
- package/dist/authorization/roles/consumer/business-user.d.ts +1 -0
- package/dist/authorization/roles/consumer/business-user.js +18 -6
- package/dist/authorization/roles/consumer/member.d.ts +1 -0
- package/dist/authorization/roles/consumer/member.js +16 -6
- package/dist/authorization/types.d.ts +7 -17
- package/dist/authorization/types.d.ts.map +1 -1
- package/dist/authorization/types.js +1 -1
- package/dist/authorization/update-user-permissions.d.ts +1 -0
- package/dist/authorization/update-user-permissions.js +22 -15
- package/dist/authorization/utils.d.ts +1 -0
- package/dist/authorization/utils.d.ts.map +1 -1
- package/dist/authorization/utils.js +26 -11
- package/dist/constants.d.ts +1 -0
- package/dist/context.d.ts +1 -0
- package/dist/default.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/providers.d.ts +1 -0
- package/dist/react.d.ts +1 -0
- package/dist/server/authenticate-user.d.ts +1 -0
- package/dist/server/authenticate-user.js +11 -7
- package/dist/server/cors.d.ts +1 -0
- package/dist/server/cors.js +23 -12
- package/dist/server/credentials-provider.d.ts +1 -0
- package/dist/server/credentials-provider.js +2 -2
- package/dist/server/index.d.ts +1 -0
- package/dist/server/next-auth.d.ts +12 -11
- package/dist/server/next-auth.js +104 -109
- package/dist/server/prisma-adapter.d.ts +1 -0
- package/dist/server/prisma-adapter.js +88 -52
- package/dist/server/types.d.ts +1 -0
- package/dist/server/verfiy-token.d.ts +1 -0
- package/dist/server/verfiy-token.js +39 -24
- package/dist/translations.d.ts +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/use-auth.d.ts +1 -0
- package/dist/use-session.d.ts +1 -0
- package/package.json +17 -13
package/dist/server/types.d.ts
CHANGED
|
@@ -11,3 +11,4 @@ export declare const verifyToken: (tokenIdOrValue: string | TokenWithMaybeUser,
|
|
|
11
11
|
export declare const clearToken: (tokenId: string) => Promise<void>;
|
|
12
12
|
export declare const clearExpiredTokens: () => Promise<void>;
|
|
13
13
|
export {};
|
|
14
|
+
//# sourceMappingURL=verfiy-token.d.ts.map
|
|
@@ -1,29 +1,36 @@
|
|
|
1
1
|
import { prisma } from '@driveflux/db';
|
|
2
|
-
import { makeProblem, PROBLEM_CORRUPT, PROBLEM_EXPIRED, PROBLEM_INVALID_DATA
|
|
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'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
+
});
|
|
13
22
|
if (!token) {
|
|
14
23
|
return new Err(makeProblem(PROBLEM_INVALID_DATA, 'Invalid token'));
|
|
15
24
|
}
|
|
16
25
|
if (token.expiresAt && token.expiresAt.getTime() < Date.now()) {
|
|
17
26
|
return new Err(makeProblem(PROBLEM_EXPIRED, 'This token has expired'));
|
|
18
27
|
}
|
|
19
|
-
if (typeof verifications?.scope !== 'undefined' &&
|
|
20
|
-
token.scope !== verifications.scope) {
|
|
28
|
+
if (typeof verifications?.scope !== 'undefined' && token.scope !== verifications.scope) {
|
|
21
29
|
return new Err(makeProblem(PROBLEM_INVALID_DATA, 'Invalid token scope'));
|
|
22
30
|
}
|
|
23
31
|
if (typeof verifications?.metadata !== 'undefined') {
|
|
24
|
-
for (const key of Object.keys(verifications.metadata))
|
|
25
|
-
if (typeof verifications.metadata[key] !== 'undefined' &&
|
|
26
|
-
verifications.metadata[key] !== token.metadata?.[key]) {
|
|
32
|
+
for (const key of Object.keys(verifications.metadata)){
|
|
33
|
+
if (typeof verifications.metadata[key] !== 'undefined' && verifications.metadata[key] !== token.metadata?.[key]) {
|
|
27
34
|
return new Err(makeProblem(PROBLEM_INVALID_DATA, 'Invalid token data'));
|
|
28
35
|
}
|
|
29
36
|
}
|
|
@@ -33,22 +40,30 @@ export const verifyToken = async (tokenIdOrValue, verifications, option) => {
|
|
|
33
40
|
}
|
|
34
41
|
return new Ok(token);
|
|
35
42
|
};
|
|
36
|
-
export const clearToken = async (tokenId)
|
|
43
|
+
export const clearToken = async (tokenId)=>{
|
|
37
44
|
try {
|
|
38
45
|
await prisma.token.delete({
|
|
39
46
|
where: {
|
|
40
|
-
id: tokenId
|
|
41
|
-
}
|
|
47
|
+
id: tokenId
|
|
48
|
+
}
|
|
42
49
|
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Nothing to for now
|
|
50
|
+
} catch (_e) {
|
|
51
|
+
// Nothing to for now
|
|
46
52
|
}
|
|
47
53
|
};
|
|
48
|
-
export const clearExpiredTokens = async ()
|
|
54
|
+
export const clearExpiredTokens = async ()=>{
|
|
49
55
|
await prisma.token.deleteMany({
|
|
50
56
|
where: {
|
|
51
|
-
OR: [
|
|
52
|
-
|
|
57
|
+
OR: [
|
|
58
|
+
{
|
|
59
|
+
expiresAt: {
|
|
60
|
+
lte: new Date()
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
invalid: true
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
53
68
|
});
|
|
54
69
|
};
|
package/dist/translations.d.ts
CHANGED
|
@@ -9,3 +9,4 @@ export declare const translations: {
|
|
|
9
9
|
export declare const setTranslations: (ts: Partial<Translations>) => void;
|
|
10
10
|
export declare const setTranslation: <K extends keyof Translations>(key: K, value: Translations[K]) => void;
|
|
11
11
|
export {};
|
|
12
|
+
//# sourceMappingURL=translations.d.ts.map
|
package/dist/types.d.ts
CHANGED
package/dist/use-auth.d.ts
CHANGED
package/dist/use-session.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@driveflux/auth",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.92",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -66,24 +66,28 @@
|
|
|
66
66
|
"./ability": {
|
|
67
67
|
"types": "./dist/ability.d.ts",
|
|
68
68
|
"import": "./dist/ability.js"
|
|
69
|
+
},
|
|
70
|
+
"./authorization/casl-prisma": {
|
|
71
|
+
"types": "./dist/authorization/casl-prisma.d.ts",
|
|
72
|
+
"import": "./dist/authorization/casl-prisma.js"
|
|
69
73
|
}
|
|
70
74
|
},
|
|
71
75
|
"files": [
|
|
72
76
|
"dist"
|
|
73
77
|
],
|
|
74
78
|
"dependencies": {
|
|
75
|
-
"@casl/ability": "^
|
|
76
|
-
"@casl/prisma": "^
|
|
77
|
-
"@driveflux/config": "3.0.
|
|
78
|
-
"@driveflux/db": "4.1.
|
|
79
|
-
"@driveflux/fetch": "8.0.
|
|
79
|
+
"@casl/ability": "^7.0.0",
|
|
80
|
+
"@casl/prisma": "^2.0.1",
|
|
81
|
+
"@driveflux/config": "3.0.13",
|
|
82
|
+
"@driveflux/db": "4.1.21",
|
|
83
|
+
"@driveflux/fetch": "8.0.4",
|
|
80
84
|
"@driveflux/problem": "6.0.3",
|
|
81
|
-
"@driveflux/reporter": "7.0.
|
|
82
|
-
"@driveflux/result": "6.0.
|
|
83
|
-
"@driveflux/singleton": "3.0.
|
|
84
|
-
"@driveflux/ui": "3.0.
|
|
85
|
+
"@driveflux/reporter": "7.0.5",
|
|
86
|
+
"@driveflux/result": "6.0.4",
|
|
87
|
+
"@driveflux/singleton": "3.0.3",
|
|
88
|
+
"@driveflux/ui": "3.0.6",
|
|
85
89
|
"@driveflux/utils": "6.0.2",
|
|
86
|
-
"@driveflux/web-analytics": "3.0.
|
|
90
|
+
"@driveflux/web-analytics": "3.0.6",
|
|
87
91
|
"@types/cors": "^2.8.19",
|
|
88
92
|
"bcryptjs": "^3.0.3",
|
|
89
93
|
"change-case": "^5.4.4",
|
|
@@ -95,10 +99,10 @@
|
|
|
95
99
|
"universal-cookie": "^8.1.2"
|
|
96
100
|
},
|
|
97
101
|
"devDependencies": {
|
|
98
|
-
"@driveflux/fab": "4.0.
|
|
102
|
+
"@driveflux/fab": "4.0.3",
|
|
99
103
|
"@driveflux/tsconfig": "3.0.2",
|
|
100
104
|
"@swc/cli": "^0.8.1",
|
|
101
|
-
"@swc/core": "^1.15.
|
|
105
|
+
"@swc/core": "^1.15.40",
|
|
102
106
|
"@types/js-cookie": "^3.0.6",
|
|
103
107
|
"@types/node": "^25.9.1",
|
|
104
108
|
"@types/react": "19.2.15",
|