@lunora/auth 1.0.0-alpha.15 → 1.0.0-alpha.17
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/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +3 -3
- package/dist/middleware.d.mts +2 -1
- package/dist/middleware.d.ts +2 -1
- package/dist/middleware.mjs +6 -3
- package/dist/packem_shared/{LunoraAuthAdminError-BxrfEeA_.mjs → LunoraAuthAdminError-BpVImgEy.mjs} +4 -5
- package/dist/packem_shared/{compileMigrationsSql-BJ9a-BY8.mjs → compileMigrationsSql-B9bj-mJv.mjs} +1 -1
- package/dist/packem_shared/{createAuth-DAVqY5Gx.mjs → createAuth-BVMMllTm.mjs} +4 -2
- package/package.json +4 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { lunoraAuthAdapter, lunoraD1Adapter } from "./adapter.mjs";
|
|
2
|
+
import { LunoraError } from '@lunora/errors';
|
|
2
3
|
import { L as LunoraAuth, a as LunoraAuthOptions } from "./packem_shared/create-auth.d-Mwhb4gSc.mjs";
|
|
3
4
|
export { c as createAuth, r as resolveAuthOptions } from "./packem_shared/create-auth.d-Mwhb4gSc.mjs";
|
|
4
5
|
export { type LunoraAuthApiContext, LunoraAuthHeadersError, type WithAuthPluginsMiddleware, type WithAuthPluginsOptions, withAuthPlugins } from "./middleware.mjs";
|
|
@@ -271,8 +272,7 @@ interface CreateAuthAdminOptions {
|
|
|
271
272
|
* surface that `code` so the runtime can map it onto an HTTP status and the
|
|
272
273
|
* studio can show a meaningful message instead of a generic 500.
|
|
273
274
|
*/
|
|
274
|
-
declare class LunoraAuthAdminError extends
|
|
275
|
-
readonly code: string;
|
|
275
|
+
declare class LunoraAuthAdminError extends LunoraError {
|
|
276
276
|
constructor(message: string, code: string);
|
|
277
277
|
}
|
|
278
278
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { lunoraAuthAdapter, lunoraD1Adapter } from "./adapter.js";
|
|
2
|
+
import { LunoraError } from '@lunora/errors';
|
|
2
3
|
import { L as LunoraAuth, a as LunoraAuthOptions } from "./packem_shared/create-auth.d-Mwhb4gSc.js";
|
|
3
4
|
export { c as createAuth, r as resolveAuthOptions } from "./packem_shared/create-auth.d-Mwhb4gSc.js";
|
|
4
5
|
export { type LunoraAuthApiContext, LunoraAuthHeadersError, type WithAuthPluginsMiddleware, type WithAuthPluginsOptions, withAuthPlugins } from "./middleware.js";
|
|
@@ -271,8 +272,7 @@ interface CreateAuthAdminOptions {
|
|
|
271
272
|
* surface that `code` so the runtime can map it onto an HTTP status and the
|
|
272
273
|
* studio can show a meaningful message instead of a generic 500.
|
|
273
274
|
*/
|
|
274
|
-
declare class LunoraAuthAdminError extends
|
|
275
|
-
readonly code: string;
|
|
275
|
+
declare class LunoraAuthAdminError extends LunoraError {
|
|
276
276
|
constructor(message: string, code: string);
|
|
277
277
|
}
|
|
278
278
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { lunoraAuthAdapter, lunoraD1Adapter } from './adapter.mjs';
|
|
2
|
-
export { LunoraAuthAdminError, createAuthAdmin } from './packem_shared/LunoraAuthAdminError-
|
|
3
|
-
export { createAuth, resolveAuthOptions } from './packem_shared/createAuth-
|
|
2
|
+
export { LunoraAuthAdminError, createAuthAdmin } from './packem_shared/LunoraAuthAdminError-BpVImgEy.mjs';
|
|
3
|
+
export { createAuth, resolveAuthOptions } from './packem_shared/createAuth-BVMMllTm.mjs';
|
|
4
4
|
export { DEFAULT_AUTH_BASE_PATH, handleAuthRequest } from './packem_shared/DEFAULT_AUTH_BASE_PATH-DjcUWEQl.mjs';
|
|
5
5
|
export { LunoraAuthHeadersError, withAuthPlugins } from './middleware.mjs';
|
|
6
|
-
export { compileMigrationsSql, ensureMigrated } from './packem_shared/compileMigrationsSql-
|
|
6
|
+
export { compileMigrationsSql, ensureMigrated } from './packem_shared/compileMigrationsSql-B9bj-mJv.mjs';
|
|
7
7
|
export { default as authTables } from './schema.mjs';
|
|
8
8
|
export { sessionPresets, validateSessionPolicy } from './packem_shared/sessionPresets-Dwwd74_J.mjs';
|
|
9
9
|
export { createSqlAuthStore, d1Executor } from './sql-store.mjs';
|
package/dist/middleware.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LunoraError } from '@lunora/errors';
|
|
1
2
|
import { L as LunoraAuth } from "./packem_shared/create-auth.d-Mwhb4gSc.mjs";
|
|
2
3
|
import 'better-auth';
|
|
3
4
|
/**
|
|
@@ -22,7 +23,7 @@ interface MiddlewareNext<ContextIn> {
|
|
|
22
23
|
* advisor lint — both treat a header-less `ctx.authApi.*` call as an
|
|
23
24
|
* authorization bypass, so a call that trips the lint also trips this guard.
|
|
24
25
|
*/
|
|
25
|
-
declare class LunoraAuthHeadersError extends
|
|
26
|
+
declare class LunoraAuthHeadersError extends LunoraError {
|
|
26
27
|
/** The `ctx.authApi.<method>` that was called without `headers`. */
|
|
27
28
|
readonly method: string;
|
|
28
29
|
constructor(method: string);
|
package/dist/middleware.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LunoraError } from '@lunora/errors';
|
|
1
2
|
import { L as LunoraAuth } from "./packem_shared/create-auth.d-Mwhb4gSc.js";
|
|
2
3
|
import 'better-auth';
|
|
3
4
|
/**
|
|
@@ -22,7 +23,7 @@ interface MiddlewareNext<ContextIn> {
|
|
|
22
23
|
* advisor lint — both treat a header-less `ctx.authApi.*` call as an
|
|
23
24
|
* authorization bypass, so a call that trips the lint also trips this guard.
|
|
24
25
|
*/
|
|
25
|
-
declare class LunoraAuthHeadersError extends
|
|
26
|
+
declare class LunoraAuthHeadersError extends LunoraError {
|
|
26
27
|
/** The `ctx.authApi.<method>` that was called without `headers`. */
|
|
27
28
|
readonly method: string;
|
|
28
29
|
constructor(method: string);
|
package/dist/middleware.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { LunoraError } from '@lunora/errors';
|
|
2
|
+
|
|
1
3
|
const callHasHeaders = (argument) => {
|
|
2
4
|
if (argument === void 0) {
|
|
3
5
|
return false;
|
|
@@ -30,14 +32,15 @@ const guardAuthApi = (api) => {
|
|
|
30
32
|
}
|
|
31
33
|
});
|
|
32
34
|
};
|
|
33
|
-
class LunoraAuthHeadersError extends
|
|
35
|
+
class LunoraAuthHeadersError extends LunoraError {
|
|
34
36
|
/** The `ctx.authApi.<method>` that was called without `headers`. */
|
|
35
37
|
method;
|
|
36
38
|
constructor(method) {
|
|
37
39
|
super(
|
|
38
|
-
|
|
40
|
+
"AUTH_HEADERS_MISSING",
|
|
41
|
+
`@lunora/auth: ctx.authApi.${method}(…) was called without \`headers\`. better-auth treats a header-less call as a trusted server-to-server invocation and skips session authorization entirely — an authorization bypass. Pass the inbound request headers: ctx.authApi.${method}({ body, headers: request.headers }). If you genuinely intend an unauthenticated server-to-server call, opt out explicitly via ctx.authApi.withoutHeaders().<method>(…), or disable the guard for the whole middleware with withAuthPlugins(auth, { enforceHeaders: false }).`,
|
|
42
|
+
{ name: "LunoraAuthHeadersError" }
|
|
39
43
|
);
|
|
40
|
-
this.name = "LunoraAuthHeadersError";
|
|
41
44
|
this.method = method;
|
|
42
45
|
}
|
|
43
46
|
}
|
package/dist/packem_shared/{LunoraAuthAdminError-BxrfEeA_.mjs → LunoraAuthAdminError-BpVImgEy.mjs}
RENAMED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { LunoraError } from '@lunora/errors';
|
|
2
|
+
|
|
3
|
+
class LunoraAuthAdminError extends LunoraError {
|
|
3
4
|
constructor(message, code) {
|
|
4
|
-
super(message);
|
|
5
|
-
this.name = "LunoraAuthAdminError";
|
|
6
|
-
this.code = code;
|
|
5
|
+
super(code, message, { name: "LunoraAuthAdminError" });
|
|
7
6
|
}
|
|
8
7
|
}
|
|
9
8
|
const DEFAULT_LIMIT = 50;
|
package/dist/packem_shared/{compileMigrationsSql-BJ9a-BY8.mjs → compileMigrationsSql-B9bj-mJv.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getMigrations } from 'better-auth/db/migration';
|
|
2
|
-
import { resolveAuthOptions } from './createAuth-
|
|
2
|
+
import { resolveAuthOptions } from './createAuth-BVMMllTm.mjs';
|
|
3
3
|
|
|
4
4
|
const migrating = /* @__PURE__ */ new WeakMap();
|
|
5
5
|
const ensureMigrated = async (auth) => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { LunoraError } from '@lunora/errors';
|
|
1
2
|
import { betterAuth } from 'better-auth';
|
|
2
3
|
import { validateSessionPolicy } from './sessionPresets-Dwwd74_J.mjs';
|
|
3
4
|
|
|
@@ -40,7 +41,7 @@ const hardenAuthOptions = (options) => {
|
|
|
40
41
|
if (isWeakSecret(options.secret)) {
|
|
41
42
|
const message = `@lunora/auth: AUTH_SECRET is only ${String(options.secret?.trim().length)} characters. Use at least ${String(MIN_SECRET_LENGTH)} for a brute-force-resistant secret — generate one with \`openssl rand -hex 32\`.`;
|
|
42
43
|
if (isHttpsBaseUrl(options.baseURL)) {
|
|
43
|
-
throw new
|
|
44
|
+
throw new LunoraError("INTERNAL", message);
|
|
44
45
|
}
|
|
45
46
|
console.warn(message);
|
|
46
47
|
}
|
|
@@ -72,7 +73,8 @@ const resolveAuthOptions = (options) => {
|
|
|
72
73
|
};
|
|
73
74
|
const createAuth = (options) => {
|
|
74
75
|
if (!options.secret || options.secret.trim() === "") {
|
|
75
|
-
throw new
|
|
76
|
+
throw new LunoraError(
|
|
77
|
+
"INTERNAL",
|
|
76
78
|
'@lunora/auth: `secret` is required. Set AUTH_SECRET locally in .dev.vars (`lunora env set AUTH_SECRET "$(openssl rand -hex 32)"`), and in production with `wrangler secret put AUTH_SECRET`.'
|
|
77
79
|
);
|
|
78
80
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/auth",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.17",
|
|
4
4
|
"description": "Auth for Lunora — a thin better-auth wrapper: email/password, OAuth, plugins, D1-backed",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"auth",
|
|
@@ -83,8 +83,9 @@
|
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
85
|
"@better-auth/passkey": "^1.6.22",
|
|
86
|
-
"@lunora/
|
|
87
|
-
"@lunora/
|
|
86
|
+
"@lunora/errors": "1.0.0-alpha.1",
|
|
87
|
+
"@lunora/server": "1.0.0-alpha.15",
|
|
88
|
+
"@lunora/values": "1.0.0-alpha.4",
|
|
88
89
|
"better-auth": "^1.6.22"
|
|
89
90
|
},
|
|
90
91
|
"engines": {
|