or3-provider-basic-auth 0.0.18 → 0.0.19

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/README.md CHANGED
@@ -198,6 +198,12 @@ Optional:
198
198
  - `OR3_BASIC_AUTH_ALLOW_INSECURE_DEV` (`true` in non-production to start with missing secrets instead of failing)
199
199
  - `OR3_PLUGIN_DEV_COOKIE_SCOPE` (set by the isolated plugin development launcher to keep browser sessions separate across local hosts)
200
200
 
201
+ When both bootstrap values are set, the first account is created before the
202
+ server accepts requests. An existing account is preserved on restart; changing
203
+ the bootstrap password does not reset it. Bootstrap errors stop startup rather
204
+ than leaving the server available with an unusable initial login. Request-time
205
+ password hashing remains asynchronous.
206
+
201
207
  Registration mode is a core-auth policy, not a provider setting:
202
208
 
203
209
  - `OR3_AUTH_REGISTRATION_MODE=open|invite_only|disabled`
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "or3-provider-basic-auth",
3
3
  "configKey": "or3-provider-basic-auth",
4
- "version": "0.0.18",
4
+ "version": "0.0.19",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.3",
7
7
  "unbuild": "3.6.1"
@@ -1,2 +1,3 @@
1
+ export declare function hashPasswordSync(password: string): string;
1
2
  export declare function hashPassword(password: string): Promise<string>;
2
3
  export declare function verifyPassword(password: string, hash: string): Promise<boolean>;
@@ -1,10 +1,17 @@
1
1
  import bcrypt from "bcryptjs";
2
2
  import { newPasswordFitsBcrypt } from "../../password-policy.js";
3
3
  const PASSWORD_COST = 12;
4
- export async function hashPassword(password) {
4
+ function assertPasswordLength(password) {
5
5
  if (!newPasswordFitsBcrypt(password)) {
6
6
  throw new RangeError("New passwords must be 72 UTF-8 bytes or fewer.");
7
7
  }
8
+ }
9
+ export function hashPasswordSync(password) {
10
+ assertPasswordLength(password);
11
+ return bcrypt.hashSync(password, PASSWORD_COST);
12
+ }
13
+ export async function hashPassword(password) {
14
+ assertPasswordLength(password);
8
15
  return await bcrypt.hash(password, PASSWORD_COST);
9
16
  }
10
17
  export async function verifyPassword(password, hash) {
@@ -12,10 +12,10 @@ import {
12
12
  isBasicAuthInsecureDevEscapeHatchEnabled,
13
13
  validateBasicAuthConfig
14
14
  } from "../lib/config.js";
15
- import { hashPassword } from "../lib/password.js";
15
+ import { hashPasswordSync } from "../lib/password.js";
16
16
  import { ensureBootstrapAccount, findAccountByEmail } from "../lib/session-store.js";
17
17
  import { basicAuthAdminAdapter } from "../admin/adapters/auth-basic-auth.js";
18
- async function ensureBootstrapUserIfConfigured() {
18
+ function ensureBootstrapUserIfConfigured() {
19
19
  const config = getBasicAuthConfig();
20
20
  const email = config.bootstrapEmail?.trim();
21
21
  const password = config.bootstrapPassword;
@@ -25,14 +25,14 @@ async function ensureBootstrapUserIfConfigured() {
25
25
  if (findAccountByEmail(email)) {
26
26
  return;
27
27
  }
28
- const passwordHash = await hashPassword(password);
28
+ const passwordHash = hashPasswordSync(password);
29
29
  ensureBootstrapAccount({
30
30
  email,
31
31
  passwordHash,
32
32
  displayName: email
33
33
  });
34
34
  }
35
- export default defineNitroPlugin(async () => {
35
+ export default defineNitroPlugin(() => {
36
36
  const runtimeConfig = useRuntimeConfig();
37
37
  const diagnostics = validateBasicAuthConfig(runtimeConfig);
38
38
  for (const warning of diagnostics.warnings) {
@@ -54,6 +54,7 @@ export default defineNitroPlugin(async () => {
54
54
  }
55
55
  throw new Error(message);
56
56
  }
57
+ ensureBootstrapUserIfConfigured();
57
58
  registerAuthProvider({
58
59
  id: BASIC_AUTH_PROVIDER_ID,
59
60
  order: 100,
@@ -61,5 +62,4 @@ export default defineNitroPlugin(async () => {
61
62
  });
62
63
  registerProviderTokenBroker(BASIC_AUTH_PROVIDER_ID, createBasicAuthTokenBroker);
63
64
  registerProviderAdminAdapter(basicAuthAdminAdapter);
64
- await ensureBootstrapUserIfConfigured();
65
65
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "or3-provider-basic-auth",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/Saluana/or3-provider-basic-auth.git"