@medusajs/auth-emailpass 0.0.2-snapshot-20240531102054 → 0.0.2-snapshot-20240701122250
Sign up to get free protection for your applications and to get access to all the features.
@@ -30,7 +30,6 @@ class EmailPassAuthService extends utils_1.AbstractAuthModuleProvider {
|
|
30
30
|
try {
|
31
31
|
authIdentity = await authIdentityService.retrieve({
|
32
32
|
entity_id: email,
|
33
|
-
provider: this.provider,
|
34
33
|
});
|
35
34
|
}
|
36
35
|
catch (error) {
|
@@ -39,13 +38,13 @@ class EmailPassAuthService extends utils_1.AbstractAuthModuleProvider {
|
|
39
38
|
const passwordHash = await scrypt_kdf_1.default.kdf(password, config);
|
40
39
|
const createdAuthIdentity = await authIdentityService.create({
|
41
40
|
entity_id: email,
|
42
|
-
provider: this.provider,
|
43
41
|
provider_metadata: {
|
44
42
|
password: passwordHash.toString("base64"),
|
45
43
|
},
|
46
44
|
});
|
47
45
|
const copy = JSON.parse(JSON.stringify(createdAuthIdentity));
|
48
|
-
|
46
|
+
const providerIdentity = copy.provider_identities?.find((pi) => pi.provider === this.provider);
|
47
|
+
delete providerIdentity.provider_metadata?.password;
|
49
48
|
return {
|
50
49
|
success: true,
|
51
50
|
authIdentity: copy,
|
@@ -53,13 +52,15 @@ class EmailPassAuthService extends utils_1.AbstractAuthModuleProvider {
|
|
53
52
|
}
|
54
53
|
return { success: false, error: error.message };
|
55
54
|
}
|
56
|
-
const
|
55
|
+
const providerIdentity = authIdentity.provider_identities?.find((pi) => pi.provider === this.provider);
|
56
|
+
const passwordHash = providerIdentity.provider_metadata?.password;
|
57
57
|
if ((0, utils_1.isString)(passwordHash)) {
|
58
58
|
const buf = Buffer.from(passwordHash, "base64");
|
59
59
|
const success = await scrypt_kdf_1.default.verify(buf, password);
|
60
60
|
if (success) {
|
61
61
|
const copy = JSON.parse(JSON.stringify(authIdentity));
|
62
|
-
|
62
|
+
const providerIdentity = copy.provider_identities?.find((pi) => pi.provider === this.provider);
|
63
|
+
delete providerIdentity.provider_metadata?.password;
|
63
64
|
return {
|
64
65
|
success,
|
65
66
|
authIdentity: copy,
|
@@ -73,4 +74,4 @@ class EmailPassAuthService extends utils_1.AbstractAuthModuleProvider {
|
|
73
74
|
}
|
74
75
|
}
|
75
76
|
exports.EmailPassAuthService = EmailPassAuthService;
|
76
|
-
//# sourceMappingURL=data:application/json;base64,
|
77
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZW1haWxwYXNzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3NlcnZpY2VzL2VtYWlscGFzcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFRQSwyQ0FJd0I7QUFDeEIsNERBQStCO0FBUS9CLE1BQWEsb0JBQXFCLFNBQVEsa0NBQTBCO0lBSWxFLFlBQ0UsRUFBRSxNQUFNLEVBQXdCLEVBQ2hDLE9BQXFDO1FBRXJDLEtBQUssQ0FDSCxFQUFFLEVBQ0YsRUFBRSxRQUFRLEVBQUUsV0FBVyxFQUFFLFdBQVcsRUFBRSwrQkFBK0IsRUFBRSxDQUN4RSxDQUFBO1FBQ0QsSUFBSSxDQUFDLE9BQU8sR0FBRyxPQUFPLENBQUE7UUFDdEIsSUFBSSxDQUFDLE9BQU8sR0FBRyxNQUFNLENBQUE7SUFDdkIsQ0FBQztJQUVELEtBQUssQ0FBQyxZQUFZLENBQ2hCLFFBQTZCLEVBQzdCLG1CQUFnRDtRQUVoRCxNQUFNLEVBQUUsS0FBSyxFQUFFLFFBQVEsRUFBRSxHQUFHLFFBQVEsQ0FBQyxJQUFJLElBQUksRUFBRSxDQUFBO1FBRS9DLElBQUksQ0FBQyxRQUFRLElBQUksQ0FBQyxJQUFBLGdCQUFRLEVBQUMsUUFBUSxDQUFDLEVBQUUsQ0FBQztZQUNyQyxPQUFPO2dCQUNMLE9BQU8sRUFBRSxLQUFLO2dCQUNkLEtBQUssRUFBRSw2QkFBNkI7YUFDckMsQ0FBQTt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UFLLENBQUMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxZQUFZLENBQUMsQ0FBQyxDQUFBO2dCQUNyRCxNQUFNLGdCQUFnQixHQUFHLElBQUksQ0FBQyxtQkFBbUIsRUFBRSxJQUFJLENBQ3JELENBQUMsRUFBRSxFQUFFLEVBQUUsQ0FBQyxFQUFFLENBQUMsUUFBUSxLQUFLLElBQUksQ0FBQyxRQUFRLENBQ3JDLENBQUE7Z0JBQ0YsT0FBTyxnQkFBZ0IsQ0FBQyxpQkFBaUIsRUFBRSxRQUFRLENBQUE7Z0JBRW5ELE9BQU87b0JBQ0wsT0FBTztvQkFDUCxZQUFZLEVBQUUsSUFBSTtpQkFDbkIsQ0FBQTtZQUNILENBQUM7UUFDSCxDQUFDO1FBRUQsT0FBTztZQUNMLE9BQU8sRUFBRSxLQUFLO1lBQ2QsS0FBSyxFQUFFLDJCQUEyQjtTQUNuQyxDQUFBO0lBQ0gsQ0FBQztDQUNGO0FBaEdELG9EQWdHQyJ9
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@medusajs/auth-emailpass",
|
3
|
-
"version": "0.0.2-snapshot-
|
3
|
+
"version": "0.0.2-snapshot-20240701122250",
|
4
4
|
"description": "Email and password credential authentication provider for Medusa",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"repository": {
|
@@ -12,7 +12,7 @@
|
|
12
12
|
"dist"
|
13
13
|
],
|
14
14
|
"engines": {
|
15
|
-
"node": ">=
|
15
|
+
"node": ">=20"
|
16
16
|
},
|
17
17
|
"author": "Medusa",
|
18
18
|
"license": "MIT",
|
@@ -25,12 +25,12 @@
|
|
25
25
|
},
|
26
26
|
"devDependencies": {
|
27
27
|
"cross-env": "^5.2.1",
|
28
|
-
"jest": "^
|
28
|
+
"jest": "^29.7.0",
|
29
29
|
"rimraf": "^5.0.1",
|
30
|
-
"typescript": "^
|
30
|
+
"typescript": "^5.3.3"
|
31
31
|
},
|
32
32
|
"dependencies": {
|
33
|
-
"@medusajs/utils": "1.12.0-snapshot-
|
33
|
+
"@medusajs/utils": "1.12.0-snapshot-20240701122250",
|
34
34
|
"scrypt-kdf": "^2.0.1"
|
35
35
|
},
|
36
36
|
"keywords": [
|