@jskit-ai/auth-provider-local-core 0.1.52 → 0.1.53
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/auth-provider-local-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.53",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test"
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"./server/lib/index": "./src/server/lib/index.js"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@jskit-ai/auth-core": "0.1.
|
|
15
|
-
"@jskit-ai/kernel": "0.1.
|
|
14
|
+
"@jskit-ai/auth-core": "0.1.150",
|
|
15
|
+
"@jskit-ai/kernel": "0.1.152",
|
|
16
16
|
"nodemailer": "^9.0.3"
|
|
17
17
|
},
|
|
18
18
|
"description": "Local auth provider with a file backend default and no database requirement.",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"mutations": {
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"runtime": {
|
|
77
|
-
"@jskit-ai/auth-core": "0.1.
|
|
78
|
-
"@jskit-ai/kernel": "0.1.
|
|
77
|
+
"@jskit-ai/auth-core": "0.1.150",
|
|
78
|
+
"@jskit-ai/kernel": "0.1.152",
|
|
79
79
|
"nodemailer": "^9.0.3",
|
|
80
80
|
"dotenv": "^16.4.5"
|
|
81
81
|
},
|
|
@@ -118,7 +118,6 @@ function buildActor(user, profile = null) {
|
|
|
118
118
|
|
|
119
119
|
function buildAuthResult({ user, session, appProfile = null }) {
|
|
120
120
|
return normalizeAuthResult({
|
|
121
|
-
profile: appProfile || buildProfile(user),
|
|
122
121
|
actor: buildActor(user, appProfile),
|
|
123
122
|
session
|
|
124
123
|
});
|
|
@@ -165,7 +165,7 @@ test("local auth provider registers, logs in, reads session, and logs out with f
|
|
|
165
165
|
password: "correct horse battery staple",
|
|
166
166
|
displayName: "Ada"
|
|
167
167
|
});
|
|
168
|
-
assert.equal(registered.
|
|
168
|
+
assert.equal(registered.actor.email, "ada@example.com");
|
|
169
169
|
assert.equal(registered.actor.provider, "local");
|
|
170
170
|
assert.equal(registered.requiresEmailConfirmation, false);
|
|
171
171
|
|
|
@@ -217,7 +217,7 @@ test("local file auth login-as issues native cookies for an existing user", asyn
|
|
|
217
217
|
const impersonated = await authService.devLoginAs(createDevAuthExchangeRequest(), {
|
|
218
218
|
email: "ADA@EXAMPLE.COM"
|
|
219
219
|
});
|
|
220
|
-
assert.equal(impersonated.
|
|
220
|
+
assert.equal(impersonated.actor.email, "ada@example.com");
|
|
221
221
|
assert.equal(impersonated.session.purpose, "dev-auth");
|
|
222
222
|
assert.equal(authService.getCapabilities().features.devLoginAs, true);
|
|
223
223
|
|
|
@@ -279,8 +279,8 @@ test("local login-as never invokes the mutating profile projector", async () =>
|
|
|
279
279
|
cookies: reply.cookies
|
|
280
280
|
}));
|
|
281
281
|
|
|
282
|
-
assert.equal(impersonated.
|
|
283
|
-
assert.equal(authenticated.
|
|
282
|
+
assert.equal(impersonated.actor.id, "app-user-ada");
|
|
283
|
+
assert.equal(authenticated.actor.id, "app-user-ada");
|
|
284
284
|
assert.equal(findCalls, 2);
|
|
285
285
|
assert.equal(syncCalls, 0);
|
|
286
286
|
});
|
|
@@ -411,9 +411,9 @@ test("local auth provider applies auth service decorators for blocking and non-b
|
|
|
411
411
|
hook: {
|
|
412
412
|
hookId: "permissions",
|
|
413
413
|
blocking: true,
|
|
414
|
-
async handle({ actor
|
|
414
|
+
async handle({ actor }) {
|
|
415
415
|
calls.push({ hook: "permissions", email: actor.email });
|
|
416
|
-
if (
|
|
416
|
+
if (actor.displayName === "Block Permissions") {
|
|
417
417
|
throw new Error("permission provisioning failed");
|
|
418
418
|
}
|
|
419
419
|
}
|
|
@@ -507,14 +507,14 @@ test("local auth provider resolves a custom password strategy from the container
|
|
|
507
507
|
test("local auth password strategy supports partial overrides and rejects invalid methods", async () => {
|
|
508
508
|
const strategy = normalizePasswordStrategy({
|
|
509
509
|
verifyPassword(password, record) {
|
|
510
|
-
return record === `
|
|
510
|
+
return record === `custom:${this.realm}:${password}`;
|
|
511
511
|
},
|
|
512
512
|
realm: "users"
|
|
513
513
|
});
|
|
514
514
|
|
|
515
515
|
const defaultHashed = await strategy.hashPassword("new password value");
|
|
516
516
|
assert.equal(await verifyPassword("new password value", defaultHashed), true);
|
|
517
|
-
assert.equal(await strategy.verifyPassword("
|
|
517
|
+
assert.equal(await strategy.verifyPassword("stored password value", "custom:users:stored password value"), true);
|
|
518
518
|
|
|
519
519
|
const hashOnlyStrategy = normalizePasswordStrategy({
|
|
520
520
|
async hashPassword(password) {
|
|
@@ -608,7 +608,7 @@ test("local auth login verifies password and creates session in one backend tran
|
|
|
608
608
|
assert.equal(sessionCreated, true);
|
|
609
609
|
});
|
|
610
610
|
|
|
611
|
-
test("local auth service accepts a custom
|
|
611
|
+
test("local auth service accepts a custom stored-password format", async () => {
|
|
612
612
|
const passwordRecords = [];
|
|
613
613
|
const sessions = [];
|
|
614
614
|
const authService = createLocalAuthService({
|
|
@@ -617,26 +617,26 @@ test("local auth service accepts a custom strategy for legacy stored password re
|
|
|
617
617
|
return callback({
|
|
618
618
|
users: {
|
|
619
619
|
async findByEmail(email) {
|
|
620
|
-
if (email !== "
|
|
620
|
+
if (email !== "existing@example.com") {
|
|
621
621
|
return null;
|
|
622
622
|
}
|
|
623
623
|
return {
|
|
624
|
-
id: "
|
|
624
|
+
id: "usr_existing",
|
|
625
625
|
email,
|
|
626
|
-
displayName: "
|
|
627
|
-
password: "
|
|
626
|
+
displayName: "Existing User",
|
|
627
|
+
password: "custom:existing@example.com:stored-password",
|
|
628
628
|
disabled: false
|
|
629
629
|
};
|
|
630
630
|
},
|
|
631
631
|
async findById(userId) {
|
|
632
|
-
if (userId !== "
|
|
632
|
+
if (userId !== "usr_existing") {
|
|
633
633
|
return null;
|
|
634
634
|
}
|
|
635
635
|
return {
|
|
636
|
-
id: "
|
|
637
|
-
email: "
|
|
638
|
-
displayName: "
|
|
639
|
-
password: passwordRecords.at(-1) || "
|
|
636
|
+
id: "usr_existing",
|
|
637
|
+
email: "existing@example.com",
|
|
638
|
+
displayName: "Existing User",
|
|
639
|
+
password: passwordRecords.at(-1) || "custom:existing@example.com:stored-password",
|
|
640
640
|
disabled: false
|
|
641
641
|
};
|
|
642
642
|
},
|
|
@@ -647,9 +647,9 @@ test("local auth service accepts a custom strategy for legacy stored password re
|
|
|
647
647
|
async updatePassword(_userId, password) {
|
|
648
648
|
passwordRecords.push(password);
|
|
649
649
|
return {
|
|
650
|
-
id: "
|
|
651
|
-
email: "
|
|
652
|
-
displayName: "
|
|
650
|
+
id: "usr_existing",
|
|
651
|
+
email: "existing@example.com",
|
|
652
|
+
displayName: "Existing User",
|
|
653
653
|
password,
|
|
654
654
|
disabled: false
|
|
655
655
|
};
|
|
@@ -704,16 +704,16 @@ test("local auth service accepts a custom strategy for legacy stored password re
|
|
|
704
704
|
},
|
|
705
705
|
passwordStrategy: {
|
|
706
706
|
async verifyPassword(password, record) {
|
|
707
|
-
return record === `
|
|
707
|
+
return record === `custom:existing@example.com:${password}`;
|
|
708
708
|
}
|
|
709
709
|
}
|
|
710
710
|
});
|
|
711
711
|
|
|
712
|
-
const
|
|
713
|
-
email: "
|
|
714
|
-
password: "
|
|
712
|
+
const existingLogin = await authService.login({
|
|
713
|
+
email: "existing@example.com",
|
|
714
|
+
password: "stored-password"
|
|
715
715
|
});
|
|
716
|
-
assert.equal(
|
|
716
|
+
assert.equal(existingLogin.actor.providerUserId, "usr_existing");
|
|
717
717
|
assert.equal(sessions.length, 1);
|
|
718
718
|
|
|
719
719
|
await authService.register({
|
|
@@ -1032,7 +1032,7 @@ test("local auth provider projects app profile when auth.profile.projector is in
|
|
|
1032
1032
|
displayName: "Projected"
|
|
1033
1033
|
});
|
|
1034
1034
|
|
|
1035
|
-
assert.equal(registered.
|
|
1035
|
+
assert.equal(registered.actor.id, "app-user-1");
|
|
1036
1036
|
assert.equal(registered.actor.providerUserId, projectedProfiles[0].authProviderUserSid);
|
|
1037
1037
|
assert.equal(registered.actor.appUserId, "app-user-1");
|
|
1038
1038
|
assert.equal(registered.actor.profileSource, "users");
|