@nestjs-kit/better-auth 2.1.0 → 2.1.2
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 +3 -3
- package/dist/admin.cjs +3 -4
- package/dist/admin.d.cts +1 -3
- package/dist/admin.d.cts.map +1 -1
- package/dist/admin.d.mts +1 -3
- package/dist/admin.d.mts.map +1 -1
- package/dist/admin.mjs +3 -4
- package/dist/api-key.cjs +4 -5
- package/dist/api-key.d.cts +1 -3
- package/dist/api-key.d.cts.map +1 -1
- package/dist/api-key.d.mts +1 -3
- package/dist/api-key.d.mts.map +1 -1
- package/dist/api-key.mjs +4 -5
- package/dist/{auth-contracts-Brh_Qko9.d.cts → auth-contracts-CADGyI0O.d.mts} +3 -53
- package/dist/auth-contracts-CADGyI0O.d.mts.map +1 -0
- package/dist/{auth-contracts-Cz7C4_Ch.d.mts → auth-contracts-zvt8ysoZ.d.cts} +3 -53
- package/dist/auth-contracts-zvt8ysoZ.d.cts.map +1 -0
- package/dist/{auth-decorators-Cu_nxWnF.cjs → auth-decorators-CJKE9wlT.cjs} +8 -10
- package/dist/{auth-decorators-Cu_nxWnF.cjs.map → auth-decorators-CJKE9wlT.cjs.map} +1 -1
- package/dist/{auth-decorators-B1mFnGJ6.mjs → auth-decorators-CkNkLNpU.mjs} +8 -10
- package/dist/{auth-decorators-B1mFnGJ6.mjs.map → auth-decorators-CkNkLNpU.mjs.map} +1 -1
- package/dist/{auth-errors-C3rbTV9p.mjs → auth-errors-JjxGDVSt.mjs} +3 -5
- package/dist/{auth-errors-C3rbTV9p.mjs.map → auth-errors-JjxGDVSt.mjs.map} +1 -1
- package/dist/{auth-errors-DmiKl0L_.cjs → auth-errors-RW7hOVI-.cjs} +3 -5
- package/dist/{auth-errors-DmiKl0L_.cjs.map → auth-errors-RW7hOVI-.cjs.map} +1 -1
- package/dist/{auth-guard-h9QB_l11.mjs → auth-guard-Da92QEK5.mjs} +4 -5
- package/dist/{auth-guard-h9QB_l11.mjs.map → auth-guard-Da92QEK5.mjs.map} +1 -1
- package/dist/{auth-guard-CLyhAEEj.cjs → auth-guard-wapEh_M_.cjs} +4 -5
- package/dist/{auth-guard-CLyhAEEj.cjs.map → auth-guard-wapEh_M_.cjs.map} +1 -1
- package/dist/{auth-module-BgcY2HpA.cjs → auth-module-ab60-WJZ.cjs} +28 -47
- package/dist/auth-module-ab60-WJZ.cjs.map +1 -0
- package/dist/{auth-module-CtHx3gRU.mjs → auth-module-uy3BBWwR.mjs} +28 -47
- package/dist/auth-module-uy3BBWwR.mjs.map +1 -0
- package/dist/{auth-scope-interceptor-BjxAL1-S.cjs → auth-scope-interceptor-Bui20-Ps.cjs} +5 -7
- package/dist/{auth-scope-interceptor-BjxAL1-S.cjs.map → auth-scope-interceptor-Bui20-Ps.cjs.map} +1 -1
- package/dist/{auth-scope-interceptor-DYPn3b8M.mjs → auth-scope-interceptor-CvCQ52dV.mjs} +5 -7
- package/dist/{auth-scope-interceptor-DYPn3b8M.mjs.map → auth-scope-interceptor-CvCQ52dV.mjs.map} +1 -1
- package/dist/{bridge-protocol-c66aEkr5.mjs → bridge-protocol-CmRsff2P.mjs} +2 -3
- package/dist/{bridge-protocol-BDw8opAG.cjs.map → bridge-protocol-CmRsff2P.mjs.map} +1 -1
- package/dist/{bridge-protocol-BDw8opAG.cjs → bridge-protocol-DNFhIKdo.cjs} +2 -3
- package/dist/{bridge-protocol-c66aEkr5.mjs.map → bridge-protocol-DNFhIKdo.cjs.map} +1 -1
- package/dist/{decorate-Dt0e9K6R.mjs → decorate-bO-rBn-G.mjs} +5 -9
- package/dist/{decorate-Dt0e9K6R.mjs.map → decorate-bO-rBn-G.mjs.map} +1 -1
- package/dist/{decorate-Cr4Q7bNE.cjs → decorate-fMNf0caZ.cjs} +5 -9
- package/dist/{decorate-Cr4Q7bNE.cjs.map → decorate-fMNf0caZ.cjs.map} +1 -1
- package/dist/express.cjs +3 -4
- package/dist/express.d.cts +1 -3
- package/dist/express.d.cts.map +1 -1
- package/dist/express.d.mts +1 -3
- package/dist/express.d.mts.map +1 -1
- package/dist/express.mjs +3 -4
- package/dist/fastify.cjs +2 -3
- package/dist/fastify.d.cts +1 -3
- package/dist/fastify.d.cts.map +1 -1
- package/dist/fastify.d.mts +1 -3
- package/dist/fastify.d.mts.map +1 -1
- package/dist/fastify.mjs +2 -3
- package/dist/graphql.cjs +7 -9
- package/dist/graphql.cjs.map +1 -1
- package/dist/graphql.d.cts +1 -3
- package/dist/graphql.d.cts.map +1 -1
- package/dist/graphql.d.mts +1 -3
- package/dist/graphql.d.mts.map +1 -1
- package/dist/graphql.mjs +7 -9
- package/dist/graphql.mjs.map +1 -1
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +7 -7
- package/dist/microservices.cjs +4 -6
- package/dist/microservices.cjs.map +1 -1
- package/dist/microservices.d.cts +1 -5
- package/dist/microservices.d.cts.map +1 -1
- package/dist/microservices.d.mts +1 -5
- package/dist/microservices.d.mts.map +1 -1
- package/dist/microservices.mjs +3 -5
- package/dist/microservices.mjs.map +1 -1
- package/dist/organization.cjs +3 -4
- package/dist/organization.d.cts +1 -3
- package/dist/organization.d.cts.map +1 -1
- package/dist/organization.d.mts +1 -3
- package/dist/organization.d.mts.map +1 -1
- package/dist/organization.mjs +3 -4
- package/dist/{platform-CZl7TY8j.mjs → platform-BKYVzAv1.mjs} +3 -5
- package/dist/{platform-CZl7TY8j.mjs.map → platform-BKYVzAv1.mjs.map} +1 -1
- package/dist/{platform-YICqqYv6.cjs → platform-C67dxSls.cjs} +3 -5
- package/dist/{platform-YICqqYv6.cjs.map → platform-C67dxSls.cjs.map} +1 -1
- package/dist/platform.cjs +1 -1
- package/dist/platform.d.cts +0 -2
- package/dist/platform.d.cts.map +1 -1
- package/dist/platform.d.mts +0 -2
- package/dist/platform.d.mts.map +1 -1
- package/dist/platform.mjs +1 -1
- package/dist/plugin.cjs +4 -8
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +0 -4
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +0 -4
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +4 -8
- package/dist/plugin.mjs.map +1 -1
- package/dist/{principal-readings-Ied2staw.mjs → principal-readings-BuXTU0-2.mjs} +3 -4
- package/dist/{principal-readings-Ied2staw.mjs.map → principal-readings-BuXTU0-2.mjs.map} +1 -1
- package/dist/{principal-readings-Chmt6rQV.cjs → principal-readings-JLNT58k0.cjs} +3 -4
- package/dist/{principal-readings-Chmt6rQV.cjs.map → principal-readings-JLNT58k0.cjs.map} +1 -1
- package/dist/{rolldown-runtime-VH7oDXx4.cjs → rolldown-runtime-CmQyd0Gu.cjs} +1 -2
- package/dist/testing/conformance.cjs +24 -31
- package/dist/testing/conformance.cjs.map +1 -1
- package/dist/testing/conformance.d.cts +4 -14
- package/dist/testing/conformance.d.cts.map +1 -1
- package/dist/testing/conformance.d.mts +4 -14
- package/dist/testing/conformance.d.mts.map +1 -1
- package/dist/testing/conformance.mjs +23 -30
- package/dist/testing/conformance.mjs.map +1 -1
- package/dist/testing.cjs +6 -7
- package/dist/testing.d.cts +1 -3
- package/dist/testing.d.cts.map +1 -1
- package/dist/testing.d.mts +1 -3
- package/dist/testing.d.mts.map +1 -1
- package/dist/testing.mjs +6 -7
- package/dist/websockets.cjs +7 -10
- package/dist/websockets.cjs.map +1 -1
- package/dist/websockets.d.cts +1 -7
- package/dist/websockets.d.cts.map +1 -1
- package/dist/websockets.d.mts +1 -7
- package/dist/websockets.d.mts.map +1 -1
- package/dist/websockets.mjs +7 -10
- package/dist/websockets.mjs.map +1 -1
- package/package.json +24 -24
- package/dist/auth-contracts-Brh_Qko9.d.cts.map +0 -1
- package/dist/auth-contracts-Cz7C4_Ch.d.mts.map +0 -1
- package/dist/auth-module-BgcY2HpA.cjs.map +0 -1
- package/dist/auth-module-CtHx3gRU.mjs.map +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_rolldown_runtime = require("../rolldown-runtime-
|
|
3
|
-
const require_auth_errors = require("../auth-errors-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const require_auth_module = require("../auth-module-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const require_admin = require("../admin.cjs");
|
|
11
|
-
const require_organization = require("../organization.cjs");
|
|
2
|
+
const require_rolldown_runtime = require("../rolldown-runtime-CmQyd0Gu.cjs");
|
|
3
|
+
const require_auth_errors = require("../auth-errors-RW7hOVI-.cjs");
|
|
4
|
+
const require_bridge_protocol = require("../bridge-protocol-DNFhIKdo.cjs");
|
|
5
|
+
const require_auth_decorators = require("../auth-decorators-CJKE9wlT.cjs");
|
|
6
|
+
const require_auth_module = require("../auth-module-ab60-WJZ.cjs");
|
|
7
|
+
const require_decorate = require("../decorate-fMNf0caZ.cjs");
|
|
8
|
+
const require_auth_guard = require("../auth-guard-wapEh_M_.cjs");
|
|
9
|
+
const require_auth_scope_interceptor = require("../auth-scope-interceptor-Bui20-Ps.cjs");
|
|
12
10
|
const require_testing = require("../testing.cjs");
|
|
11
|
+
const require_organization = require("../organization.cjs");
|
|
12
|
+
const require_admin = require("../admin.cjs");
|
|
13
13
|
let better_auth_api = require("better-auth/api");
|
|
14
14
|
let _nestjs_common = require("@nestjs/common");
|
|
15
15
|
let _nestjs_core = require("@nestjs/core");
|
|
@@ -25,7 +25,7 @@ node_assert_strict = require_rolldown_runtime.__toESM(node_assert_strict, 1);
|
|
|
25
25
|
let node_http2 = require("node:http2");
|
|
26
26
|
let node_net = require("node:net");
|
|
27
27
|
let _nestjs_testing = require("@nestjs/testing");
|
|
28
|
-
|
|
28
|
+
// src/database-hook-dispatcher.ts
|
|
29
29
|
/**
|
|
30
30
|
* Construct all dispatchers once; bindings supply only the late-bound methods.
|
|
31
31
|
*
|
|
@@ -97,8 +97,7 @@ function createDatabaseDispatchers(getBinding, countUnbound) {
|
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
//#region src/hook-dispatcher.ts
|
|
100
|
+
// src/hook-dispatcher.ts
|
|
102
101
|
const API_ERROR_HEADERS = Symbol.for("better-call:api-error-headers");
|
|
103
102
|
const mergeContext = (0, defu.createDefu)((object, key, value) => {
|
|
104
103
|
if (Array.isArray(object[key]) && Array.isArray(value)) {
|
|
@@ -192,8 +191,7 @@ async function runAfter(binding, ctx, scope, relayMatcherError) {
|
|
|
192
191
|
}
|
|
193
192
|
return ctx.context.returned;
|
|
194
193
|
}
|
|
195
|
-
|
|
196
|
-
//#region src/plugin.ts
|
|
194
|
+
// src/plugin.ts
|
|
197
195
|
const NESTJS_PLUGIN_ID = "@nestjs-kit/better-auth";
|
|
198
196
|
const isRouter = (ctx) => "_flag" in ctx && ctx._flag === "router";
|
|
199
197
|
const separator = "\0";
|
|
@@ -336,8 +334,7 @@ function nestjs(options = {}) {
|
|
|
336
334
|
}
|
|
337
335
|
};
|
|
338
336
|
}
|
|
339
|
-
|
|
340
|
-
//#region src/conformance-fixtures.ts
|
|
337
|
+
// src/conformance-fixtures.ts
|
|
341
338
|
const PROBE_PLUGIN_ID = "nestjs-kit-better-auth-conformance-probe";
|
|
342
339
|
/** The trusted origin the probe plugin contributes through init(), so origin cases see the post-init set. */
|
|
343
340
|
const PROBE_TRUSTED_ORIGIN = "https://probe-plugin.example";
|
|
@@ -803,8 +800,7 @@ function bootIssueCodes(error) {
|
|
|
803
800
|
visit(error);
|
|
804
801
|
return codes;
|
|
805
802
|
}
|
|
806
|
-
|
|
807
|
-
//#region src/conformance-http.ts
|
|
803
|
+
// src/conformance-http.ts
|
|
808
804
|
const AUTH = "/api/auth";
|
|
809
805
|
const DYNAMIC_AUTH = "/tenant/auth";
|
|
810
806
|
/** The client IP of the kit's requests: baseUrl() always connects over IPv4 loopback. */
|
|
@@ -2146,8 +2142,7 @@ async function bridgeOf(auth) {
|
|
|
2146
2142
|
const plugin = (await auth.$context).getPlugin("@nestjs-kit/better-auth");
|
|
2147
2143
|
return Reflect.get(plugin, require_bridge_protocol.BRIDGE_HANDLE);
|
|
2148
2144
|
}
|
|
2149
|
-
|
|
2150
|
-
//#region src/conformance-policy-harness.ts
|
|
2145
|
+
// src/conformance-policy-harness.ts
|
|
2151
2146
|
/** An instance with the given overrides, built by options.variant() or createConformanceAuth(). */
|
|
2152
2147
|
async function variantOf$1(options, overrides) {
|
|
2153
2148
|
return options.variant ? await options.variant(overrides) : createConformanceAuth(overrides);
|
|
@@ -2546,8 +2541,7 @@ async function sessionPrincipalOf(auth, headers) {
|
|
|
2546
2541
|
session
|
|
2547
2542
|
};
|
|
2548
2543
|
}
|
|
2549
|
-
|
|
2550
|
-
//#region src/conformance-policy-units.ts
|
|
2544
|
+
// src/conformance-policy-units.ts
|
|
2551
2545
|
const ADMIN_POLICY = "better-auth:admin/permission";
|
|
2552
2546
|
const ORG_POLICIES = /* @__PURE__ */ new Set(["better-auth:organization/permission", "better-auth:organization/member"]);
|
|
2553
2547
|
const API_KEY_POLICY = "better-auth:api-key/permission";
|
|
@@ -3209,8 +3203,7 @@ function unitPolicyCases(options, known) {
|
|
|
3209
3203
|
...(options.deliveries ?? []).flatMap(deliveryCases)
|
|
3210
3204
|
];
|
|
3211
3205
|
}
|
|
3212
|
-
|
|
3213
|
-
//#region src/conformance-policy.ts
|
|
3206
|
+
// src/conformance-policy.ts
|
|
3214
3207
|
const noGrant = {
|
|
3215
3208
|
description: "conformance: no grant",
|
|
3216
3209
|
allows: () => false
|
|
@@ -3410,7 +3403,7 @@ function policyConformance(options) {
|
|
|
3410
3403
|
}
|
|
3411
3404
|
})));
|
|
3412
3405
|
probe.storageFault = void 0;
|
|
3413
|
-
for (const outcome of outcomes) if (customSession) node_assert_strict.default.ok(outcome.ok
|
|
3406
|
+
for (const outcome of outcomes) if (customSession) node_assert_strict.default.ok(outcome.ok ? isSessionLoss(outcome.value) : require_auth_errors.isInfrastructureError(outcome.error), `with customSession a storage failure must be infrastructure or the documented 401: ${outcome.ok ? JSON.stringify(outcome.value) : String(outcome.error)}`);
|
|
3414
3407
|
else node_assert_strict.default.ok(!outcome.ok && require_auth_errors.isInfrastructureError(outcome.error), `a storage failure at the policy's call must be infrastructure: ${JSON.stringify(outcome.ok && outcome.value)}`);
|
|
3415
3408
|
node_assert_strict.default.equal(sessionReads$1(probe, reads), 1, `two invocations of one request re-read the session ${sessionReads$1(probe, reads)} times during the outage`);
|
|
3416
3409
|
}),
|
|
@@ -3498,8 +3491,7 @@ function policyConformance(options) {
|
|
|
3498
3491
|
...unitPolicyCases(options, known)
|
|
3499
3492
|
];
|
|
3500
3493
|
}
|
|
3501
|
-
|
|
3502
|
-
//#region src/conformance-principal.ts
|
|
3494
|
+
// src/conformance-principal.ts
|
|
3503
3495
|
var RecordingSink = class {
|
|
3504
3496
|
values = [];
|
|
3505
3497
|
append(setCookies) {
|
|
@@ -4444,8 +4436,7 @@ function jwtCases(options) {
|
|
|
4444
4436
|
node_assert_strict.default.ok(!require_auth_errors.isAuthFailure(!result.ok && result.error), `a key-set outage was thrown as a denial: ${String(!result.ok && result.error)}`);
|
|
4445
4437
|
})];
|
|
4446
4438
|
}
|
|
4447
|
-
|
|
4448
|
-
//#region src/conformance-transport.ts
|
|
4439
|
+
// src/conformance-transport.ts
|
|
4449
4440
|
const KEY_SOURCE_ID = "@nestjs-kit/better-auth:conformance-api-key";
|
|
4450
4441
|
/** An origin only a function-valued trustedOrigins returns (T-ws-origin-*). */
|
|
4451
4442
|
const FUNCTION_TRUSTED_ORIGIN = "https://function-trusted.example";
|
|
@@ -5911,6 +5902,7 @@ function transportConformance(options) {
|
|
|
5911
5902
|
...cookie(env),
|
|
5912
5903
|
cookie: later.cookie
|
|
5913
5904
|
};
|
|
5905
|
+
const rebuilt = [];
|
|
5914
5906
|
await withApp(options, env, async ({ app, logger }) => {
|
|
5915
5907
|
const first = await invokeAlone(app, "required", cookie(env));
|
|
5916
5908
|
succeeded(first, "the first caller of a cached context");
|
|
@@ -5923,6 +5915,7 @@ function transportConformance(options) {
|
|
|
5923
5915
|
if (result.ok) {
|
|
5924
5916
|
const principal = principalOf(result);
|
|
5925
5917
|
node_assert_strict.default.ok(principal === null || principal?.userId === later.userId, `${label} read neither its own principal nor none: ${JSON.stringify(result.body)}`);
|
|
5918
|
+
if (principal !== null) rebuilt.push(handler);
|
|
5926
5919
|
} else denied(result, 401, void 0, label);
|
|
5927
5920
|
continue;
|
|
5928
5921
|
}
|
|
@@ -5941,6 +5934,7 @@ function transportConformance(options) {
|
|
|
5941
5934
|
node_assert_strict.default.doesNotMatch(logger.text(), /AUTH_MISCONFIGURED|GRAPHQL_CONTEXT_STALE_REQUEST/);
|
|
5942
5935
|
}
|
|
5943
5936
|
}, { graphqlContext: "cached" });
|
|
5937
|
+
if (rebuilt.length > 0) return conformanceSkip(`the later caller of ${rebuilt.join(" and ")} read its own principal, so the driver built a new context for its connection instead of serving the cached one, and no closed connection's context reached the transport`);
|
|
5944
5938
|
});
|
|
5945
5939
|
/** The claimed site of each graph fixture handler of a booted app, by fixture name. */
|
|
5946
5940
|
const graphSites = async (app) => {
|
|
@@ -6201,7 +6195,6 @@ function transportConformance(options) {
|
|
|
6201
6195
|
}, staticMember(options.transport, "defaultAccessFor") === false && !options.invokeEntities ? "the transport nests no handlers, so it serves no federation reference resolvers" : void 0);
|
|
6202
6196
|
return cases;
|
|
6203
6197
|
}
|
|
6204
|
-
//#endregion
|
|
6205
6198
|
exports.PROBE_TRUSTED_ORIGIN = PROBE_TRUSTED_ORIGIN;
|
|
6206
6199
|
exports.conformanceProbePlugin = conformanceProbePlugin;
|
|
6207
6200
|
exports.createConformanceAuth = createConformanceAuth;
|