@jskit-ai/auth-provider-local-core 0.2.8 → 0.2.10
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.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test --test-concurrency=1"
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"@jskit-ai/auth-core": "0.2.
|
|
70
|
-
"@jskit-ai/kernel": "0.2.
|
|
69
|
+
"@jskit-ai/auth-core": "0.2.8",
|
|
70
|
+
"@jskit-ai/kernel": "0.2.8"
|
|
71
71
|
}
|
|
72
72
|
}
|
package/test/codedTexts.test.js
CHANGED
|
@@ -27,16 +27,17 @@ function assertCoded(error, code) {
|
|
|
27
27
|
return true;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
async function createService(env = {}) {
|
|
30
|
+
async function createService(t, env = {}) {
|
|
31
31
|
const storeDir = await fs.mkdtemp(path.join(os.tmpdir(), "jskit-auth-local-coded-"));
|
|
32
|
+
t.after(() => fs.rm(storeDir, { recursive: true, force: true }));
|
|
32
33
|
return createLocalAuthService({
|
|
33
34
|
...localServiceOptions({ env }),
|
|
34
35
|
backend: createLocalFileBackend({ storeDir })
|
|
35
36
|
});
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
test("local auth errors carry codes whose English is the thrown message", async () => {
|
|
39
|
-
const service = await createService();
|
|
39
|
+
test("local auth errors carry codes whose English is the thrown message", async (t) => {
|
|
40
|
+
const service = await createService(t);
|
|
40
41
|
await assert.rejects(() => service.register({ email: "nope", password: "long enough" }),
|
|
41
42
|
(error) => assertCoded(error, "auth.local.email.invalid"));
|
|
42
43
|
await assert.rejects(() => service.register({ email: "ada@example.com", password: "short" }),
|
|
@@ -53,13 +54,13 @@ test("local auth errors carry codes whose English is the thrown message", async
|
|
|
53
54
|
await assert.rejects(() => service.updateDisplayName({ cookies: {} }, { displayName: "Ada" }),
|
|
54
55
|
(error) => assertCoded(error, "auth.session.required"));
|
|
55
56
|
|
|
56
|
-
const disabled = await createService({ NODE_ENV: "production", AUTH_LOCAL_RECOVERY_DEV_OUTPUT: "log" });
|
|
57
|
+
const disabled = await createService(t, { NODE_ENV: "production", AUTH_LOCAL_RECOVERY_DEV_OUTPUT: "log" });
|
|
57
58
|
await assert.rejects(() => disabled.requestPasswordReset({ email: "ada@example.com" }),
|
|
58
59
|
(error) => assertCoded(error, "auth.local.recovery.notConfigured"));
|
|
59
60
|
});
|
|
60
61
|
|
|
61
|
-
test("local auth success texts carry a message code next to the English", async () => {
|
|
62
|
-
const service = await createService();
|
|
62
|
+
test("local auth success texts carry a message code next to the English", async (t) => {
|
|
63
|
+
const service = await createService(t);
|
|
63
64
|
await service.register({ email: "ada@example.com", password: "correct horse" });
|
|
64
65
|
const requested = await service.requestPasswordReset({ email: "ada@example.com" });
|
|
65
66
|
assert.equal(requested.messageCode, "auth.local.recovery.requested");
|
package/test/oauthSignIn.test.js
CHANGED
|
@@ -25,8 +25,9 @@ const MICROSOFT_CONSUMER_TENANT_ID = "9188040d-6c67-4c5b-b112-36a304b66dad";
|
|
|
25
25
|
const UNVERIFIED = { statusCode: 401, code: "auth.local.oauth.unverified" };
|
|
26
26
|
const EXPIRED = { statusCode: 400, code: "auth.local.oauth.expired" };
|
|
27
27
|
|
|
28
|
-
async function fileBackend() {
|
|
28
|
+
async function fileBackend(t) {
|
|
29
29
|
const storeDir = await fs.mkdtemp(path.join(os.tmpdir(), "jskit-auth-local-oauth-"));
|
|
30
|
+
t.after(() => fs.rm(storeDir, { recursive: true, force: true }));
|
|
30
31
|
return createLocalFileBackend({ storeDir });
|
|
31
32
|
}
|
|
32
33
|
|
|
@@ -72,7 +73,7 @@ function createUsersProfileSync() {
|
|
|
72
73
|
async function googleSetup(t, { account, profileProjector = noAppProfiles } = {}) {
|
|
73
74
|
const issuer = await startOidcProvider({ account });
|
|
74
75
|
t.after(() => issuer.close());
|
|
75
|
-
const backend = await fileBackend();
|
|
76
|
+
const backend = await fileBackend(t);
|
|
76
77
|
const service = createService({ backend, profileProjector, oauthProviders: [oidcProviderEntry(issuer)] });
|
|
77
78
|
return { issuer, backend, service };
|
|
78
79
|
}
|
|
@@ -236,7 +237,7 @@ test("Microsoft accepts personal accounts and work accounts on a verified domain
|
|
|
236
237
|
const issuer = await startOidcProvider();
|
|
237
238
|
st.after(() => issuer.close());
|
|
238
239
|
const service = createService({
|
|
239
|
-
backend: await fileBackend(),
|
|
240
|
+
backend: await fileBackend(st),
|
|
240
241
|
oauthProviders: [oidcProviderEntry(issuer, { id: "microsoft", label: "Microsoft" })],
|
|
241
242
|
profileProjector: noAppProfiles
|
|
242
243
|
});
|
|
@@ -255,7 +256,7 @@ test("Microsoft accepts personal accounts and work accounts on a verified domain
|
|
|
255
256
|
test("GitHub signs in with the primary verified address and refuses an unverified one", async (t) => {
|
|
256
257
|
const github = await startFakeGitHub();
|
|
257
258
|
t.after(() => github.close());
|
|
258
|
-
const backend = await fileBackend();
|
|
259
|
+
const backend = await fileBackend(t);
|
|
259
260
|
const service = createService({ backend, oauthProviders: [github.provider], profileProjector: noAppProfiles });
|
|
260
261
|
|
|
261
262
|
const { started, input, request } = await approveAtProvider(service, { provider: "github" });
|
|
@@ -286,7 +287,7 @@ test("account settings link and unlink providers, never removing the last sign-i
|
|
|
286
287
|
await github.close();
|
|
287
288
|
});
|
|
288
289
|
const service = createService({
|
|
289
|
-
backend: await fileBackend(),
|
|
290
|
+
backend: await fileBackend(t),
|
|
290
291
|
oauthProviders: [oidcProviderEntry(issuer), github.provider],
|
|
291
292
|
profileProjector: noAppProfiles
|
|
292
293
|
});
|
|
@@ -22,6 +22,15 @@ import {
|
|
|
22
22
|
} from "../src/server/lib/index.js";
|
|
23
23
|
|
|
24
24
|
const DEV_AUTH_SECRET = "local-preview-exchange-secret";
|
|
25
|
+
const temporaryStoreDirs = [];
|
|
26
|
+
|
|
27
|
+
async function temporaryStoreDir(prefix) {
|
|
28
|
+
const storeDir = await fs.mkdtemp(path.join(os.tmpdir(), prefix));
|
|
29
|
+
temporaryStoreDirs.push(storeDir);
|
|
30
|
+
return storeDir;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
test.after(() => Promise.all(temporaryStoreDirs.map((storeDir) => fs.rm(storeDir, { recursive: true, force: true }))));
|
|
25
34
|
|
|
26
35
|
function createReplyFixture() {
|
|
27
36
|
const cookies = {};
|
|
@@ -85,7 +94,7 @@ async function createStartedApp({
|
|
|
85
94
|
logger = null,
|
|
86
95
|
configureExtensions = null
|
|
87
96
|
} = {}) {
|
|
88
|
-
const storeDir = await
|
|
97
|
+
const storeDir = await temporaryStoreDir("jskit-auth-local-");
|
|
89
98
|
const backend = createLocalFileBackend({ storeDir });
|
|
90
99
|
const extensions = createAuthExtensions();
|
|
91
100
|
const runtimeLogger = logger || {
|
|
@@ -609,7 +618,7 @@ test("local auth login verifies password and creates session in one backend tran
|
|
|
609
618
|
let transactions = 0;
|
|
610
619
|
let sessionCreated = false;
|
|
611
620
|
const backend = createLocalFileBackend({
|
|
612
|
-
storeDir: await
|
|
621
|
+
storeDir: await temporaryStoreDir("jskit-auth-login-tx-")
|
|
613
622
|
});
|
|
614
623
|
await backend.withTransaction((tx) =>
|
|
615
624
|
tx.users.create({
|
|
@@ -1125,7 +1134,7 @@ test("local auth provider requires an explicit public URL for email recovery", a
|
|
|
1125
1134
|
});
|
|
1126
1135
|
|
|
1127
1136
|
test("local file backend recovers stale transaction locks", async () => {
|
|
1128
|
-
const storeDir = await
|
|
1137
|
+
const storeDir = await temporaryStoreDir("jskit-auth-local-");
|
|
1129
1138
|
await fs.mkdir(storeDir, { recursive: true });
|
|
1130
1139
|
const lockPath = path.join(storeDir, "store.lock");
|
|
1131
1140
|
await fs.writeFile(lockPath, "0:stale\n", "utf8");
|
|
@@ -1152,7 +1161,7 @@ test("local file backend recovers stale transaction locks", async () => {
|
|
|
1152
1161
|
});
|
|
1153
1162
|
|
|
1154
1163
|
test("local file backend replays a pending multi-file transaction journal before reads", async () => {
|
|
1155
|
-
const sourceDir = await
|
|
1164
|
+
const sourceDir = await temporaryStoreDir("jskit-auth-local-source-");
|
|
1156
1165
|
const sourceBackend = createLocalFileBackend({ storeDir: sourceDir });
|
|
1157
1166
|
await sourceBackend.withTransaction(async (tx) => {
|
|
1158
1167
|
await tx.users.create({
|
|
@@ -1180,7 +1189,7 @@ test("local file backend replays a pending multi-file transaction journal before
|
|
|
1180
1189
|
});
|
|
1181
1190
|
});
|
|
1182
1191
|
|
|
1183
|
-
const storeDir = await
|
|
1192
|
+
const storeDir = await temporaryStoreDir("jskit-auth-local-journal-");
|
|
1184
1193
|
const files = await Promise.all(
|
|
1185
1194
|
["users.passwd", "sessions.passwd", "recovery.passwd"].map(async (name) => ({
|
|
1186
1195
|
name,
|