@remit/auth-service 0.0.16 → 0.1.1

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.
@@ -2,6 +2,7 @@ import assert from "node:assert/strict";
2
2
  import { describe, it } from "node:test";
3
3
  import { createAuth } from "./auth.js";
4
4
  import { resolveSelfSignUpEnabled } from "./config.js";
5
+ import { openIdentityStore } from "./identity-store.js";
5
6
 
6
7
  describe("resolveSelfSignUpEnabled", () => {
7
8
  it("defaults to enabled when unset or blank", () => {
@@ -36,7 +37,10 @@ const baseConfig = {
36
37
 
37
38
  describe("createAuth self-signup gate", () => {
38
39
  it("rejects a signup request server-side when disabled, before any DB access", async () => {
39
- const auth = await createAuth({ ...baseConfig, selfSignUpEnabled: false });
40
+ const auth = await createAuth(
41
+ { ...baseConfig, selfSignUpEnabled: false, signInEnabled: true },
42
+ await openIdentityStore(baseConfig.connectionString),
43
+ );
40
44
  const request = new Request(
41
45
  "http://localhost:3000/api/auth/sign-up/email",
42
46
  {
@@ -56,4 +60,28 @@ describe("createAuth self-signup gate", () => {
56
60
  const body = (await response.json()) as { code?: string };
57
61
  assert.equal(body.code, "EMAIL_PASSWORD_SIGN_UP_DISABLED");
58
62
  });
63
+
64
+ it("refuses an 11-character password", async () => {
65
+ const auth = await createAuth(
66
+ { ...baseConfig, selfSignUpEnabled: true, signInEnabled: true },
67
+ await openIdentityStore(baseConfig.connectionString),
68
+ );
69
+ const request = new Request(
70
+ "http://localhost:3000/api/auth/sign-up/email",
71
+ {
72
+ method: "POST",
73
+ headers: { "content-type": "application/json" },
74
+ body: JSON.stringify({
75
+ email: "short@example.com",
76
+ password: "elevenchars",
77
+ name: "Short",
78
+ }),
79
+ },
80
+ );
81
+
82
+ const response = await auth.handler(request);
83
+
84
+ const body = (await response.json()) as { code?: string };
85
+ assert.equal(body.code, "PASSWORD_TOO_SHORT");
86
+ });
59
87
  });
package/src/verifier.ts CHANGED
@@ -10,6 +10,8 @@ export {
10
10
  AUTH_BASE_PATH,
11
11
  AUTH_JWKS_PATH,
12
12
  AUTH_TOKEN_PATH,
13
+ resolveSelfSignUpEnabled,
14
+ resolveSignInEnabled,
13
15
  resolveVerifierConfig,
14
16
  type VerifierConfig,
15
17
  } from "./config.js";