@guren/server 2.25.0 → 2.26.0
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 +42 -0
- package/dist/{Gate-YOt54xGF.js → Gate-BL_zW82W.js} +1 -1
- package/dist/{Job-COMzBNOL.js → Job-DsFMcXVk.js} +35 -3
- package/dist/{Resource-BdYd4J9a.js → Resource-gki0_2B6.js} +172 -37
- package/dist/agent/scopes.d.ts +1 -3
- package/dist/auth/email-verification.d.ts +6 -0
- package/dist/auth/index.js +1 -1
- package/dist/auth/password-reset.d.ts +8 -2
- package/dist/{auth-vFeem6uM.js → auth-DiyWALZT.js} +38 -9
- package/dist/authorization/index.js +2 -2
- package/dist/{authorization-BLhwA2Yh.js → authorization-E6X6Y-B6.js} +1 -1
- package/dist/broadcasting/index.js +1 -1
- package/dist/{broadcasting-BUBCPCnu.js → broadcasting-D0vMkKcq.js} +1 -1
- package/dist/cache/index.js +1 -1
- package/dist/cache/stores/FileStore.d.ts +2 -0
- package/dist/cache/stores/MemoryStore.d.ts +1 -0
- package/dist/cache/stores/RedisStore.d.ts +1 -0
- package/dist/cache/types.d.ts +2 -0
- package/dist/{cache-93n2PCnB.js → cache-DcnRufMe.js} +94 -25
- package/dist/contained-path-BkNSBljW.js +78 -0
- package/dist/container/Container.d.ts +6 -2
- package/dist/container/defineModule.d.ts +10 -0
- package/dist/{default-application-D5ezhhiV.js → default-application-DWwscxfW.js} +14 -18
- package/dist/encryption/index.js +1 -1
- package/dist/{encryption-D1dxfMqD.js → encryption-CWK5l22W.js} +1 -1
- package/dist/events/EventManager.d.ts +2 -0
- package/dist/events/index.js +1 -1
- package/dist/{events-c94CdUFc.js → events-DQavGm8W.js} +20 -7
- package/dist/health/HealthManager.d.ts +0 -1
- package/dist/health/index.js +1 -1
- package/dist/{health-CB0oS_UE.js → health-Bg0Xj3aD.js} +8 -8
- package/dist/http/Application.d.ts +12 -1
- package/dist/http/middleware/rate-limit.d.ts +1 -4
- package/dist/i18n/index.js +1 -1
- package/dist/{i18n-DqcRD4qL.js → i18n-DmMKcbqj.js} +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +61 -50
- package/dist/internal/app-conventions.d.ts +6 -0
- package/dist/internal/app-conventions.js +9 -0
- package/dist/internal/testing.d.ts +1 -1
- package/dist/internal/testing.js +2 -2
- package/dist/lambda/index.js +66 -28
- package/dist/logging/index.js +1 -1
- package/dist/{logging-YbKmbAd7.js → logging-Ci0mBk5k.js} +1 -1
- package/dist/mail/index.js +1 -1
- package/dist/{mail-uRBrUl9q.js → mail-CI2Kfe8P.js} +2 -2
- package/dist/mvc/Controller.d.ts +3 -2
- package/dist/mvc/inertia/InertiaEngine.d.ts +31 -0
- package/dist/mvc/inertia/props.d.ts +71 -0
- package/dist/notifications/index.js +1 -1
- package/dist/notifications/registry.d.ts +2 -2
- package/dist/{notifications-LHuujttf.js → notifications-Bp2uamzD.js} +7 -5
- package/dist/providers/ConfigServiceProvider.d.ts +5 -5
- package/dist/queue/Job.d.ts +5 -0
- package/dist/queue/Worker.d.ts +6 -1
- package/dist/queue/drivers/RedisDriver.d.ts +4 -2
- package/dist/queue/drivers/SqsDriver.d.ts +31 -2
- package/dist/queue/drivers/redis-queue-scripts.d.ts +83 -0
- package/dist/queue/index.js +2 -2
- package/dist/queue/serialize.d.ts +7 -0
- package/dist/queue/types.d.ts +13 -2
- package/dist/{queue-BiBn5Sff.js → queue-Bo4Q857L.js} +294 -125
- package/dist/redis/RedisEmailVerificationStore.d.ts +2 -0
- package/dist/redis/RedisPasswordResetStore.d.ts +2 -0
- package/dist/redis/auth-token-scripts.d.ts +4 -0
- package/dist/redis/index.js +50 -0
- package/dist/runtime/index.js +3 -36
- package/dist/scheduling/ScheduledTask.d.ts +2 -1
- package/dist/scheduling/index.js +1 -1
- package/dist/{scheduling-DhYfbJFj.js → scheduling-DNV5tj44.js} +32 -38
- package/dist/serialize-CKXek0Tr.js +17 -0
- package/dist/storage/drivers/LocalDriver.d.ts +15 -0
- package/dist/storage/index.js +1 -1
- package/dist/storage/url-path.d.ts +2 -0
- package/dist/{storage-6HLaUf9j.js → storage-wFsUJHZW.js} +78 -28
- package/dist/support/contained-path.d.ts +8 -0
- package/dist/support/registry-collision.d.ts +12 -0
- package/dist/{vite-manifest-C5kqRoBV.js → vite-manifest-DlU94f3Z.js} +2 -2
- package/package.json +20 -2
- package/dist/trim-slashes-BLY9hKAa.js +0 -22
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# @guren/server
|
|
2
|
+
|
|
3
|
+
The HTTP layer of [Guren](https://guren.dev/), a Bun-first fullstack TypeScript framework with Laravel-style conventions. Routing, controllers, middleware, auth, sessions, queues, mail, events, and the AWS Lambda adapter, built on [Hono](https://hono.dev/).
|
|
4
|
+
|
|
5
|
+
## Application code should not import this package
|
|
6
|
+
|
|
7
|
+
Install and import [`@guren/core`](https://www.npmjs.com/package/@guren/core) instead. It re-exports this package's whole public API, so there is one import specifier to learn and one to keep working across releases:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bun add @guren/core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Controller, Router, createApp } from '@guren/core'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Starting a new app? Scaffold one, and this is wired up for you:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
bunx create-guren-app my-app --auth
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
It is published separately because the framework is released as independently versioned packages, not because application code is meant to reach for it. Depend on it directly only when you are writing a Guren plugin against the HTTP layer.
|
|
24
|
+
|
|
25
|
+
## What is in here
|
|
26
|
+
|
|
27
|
+
| Area | Contents |
|
|
28
|
+
|------|----------|
|
|
29
|
+
| HTTP | `Application`, `Router`, `Controller`, middleware, exception handling, CSRF, CORS, rate limiting |
|
|
30
|
+
| Auth | Sessions, guards, password hashing, API tokens, OAuth, authorization policies |
|
|
31
|
+
| Subsystems | Queues, mail, events, notifications, cache, broadcasting, storage, scheduling, i18n, logging, health checks |
|
|
32
|
+
| Runtimes | `@guren/server/lambda` for AWS Lambda, `@guren/server/redis` for Redis-backed stores |
|
|
33
|
+
|
|
34
|
+
Develop on Bun; deploy to Bun, AWS Lambda on the Node.js runtime, Vercel, or Cloudflare Workers. The default password hasher writes `node:crypto` scrypt on every runtime, so a hash written on Bun verifies on Node.js.
|
|
35
|
+
|
|
36
|
+
## Documentation
|
|
37
|
+
|
|
38
|
+
[guren.dev/docs](https://guren.dev/docs)
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
MIT
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as HttpException } from "./HttpException-BlQ2yEmT.js";
|
|
2
|
-
import { h as warnDeprecatedSetter, i as bindAmbient, m as warnDeprecatedGetter, n as ambientBinding } from "./default-application-
|
|
2
|
+
import { h as warnDeprecatedSetter, i as bindAmbient, m as warnDeprecatedGetter, n as ambientBinding } from "./default-application-DWwscxfW.js";
|
|
3
3
|
import { r as getAuthContext } from "./context-af2n5abO.js";
|
|
4
4
|
//#region src/http/request-container.ts
|
|
5
5
|
/**
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
import { t as resolveOptional } from "./resolve-optional-ax6gPWTp.js";
|
|
2
|
-
import {
|
|
2
|
+
import { t as warnOnce } from "./warn-once-p-IlMjra.js";
|
|
3
|
+
import { h as warnDeprecatedSetter, m as warnDeprecatedGetter, n as ambientBinding, o as defaultContainer, r as ambientContainer } from "./default-application-DWwscxfW.js";
|
|
3
4
|
import { randomBytes } from "node:crypto";
|
|
5
|
+
//#region src/support/registry-collision.ts
|
|
6
|
+
const ADVICE = {
|
|
7
|
+
job: "A queued message runs whichever registered last. Give one a different class name or its own static jobName.",
|
|
8
|
+
event: "Listeners are keyed by the name, so each class's listeners also run for the other's emits, and a queued emit is rebuilt as whichever registered last. Give one a different class name or its own static eventName.",
|
|
9
|
+
notification: "A queued notification is rebuilt as whichever registered last. Give one a different class name or override its type getter."
|
|
10
|
+
};
|
|
11
|
+
function label(cls) {
|
|
12
|
+
return cls.name === "" ? "(anonymous class)" : cls.name;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Warns when a different class takes a name another class holds; the same class
|
|
16
|
+
* again is silent. The caller still overwrites, last wins, so only the log
|
|
17
|
+
* changes. A future major will throw here instead.
|
|
18
|
+
*/
|
|
19
|
+
function reportRegistryCollision(kind, name, taken, incoming) {
|
|
20
|
+
if (taken === void 0 || taken === incoming) return;
|
|
21
|
+
const classes = taken.name === incoming.name ? `both named ${label(taken)}` : `${label(taken)} and ${label(incoming)}`;
|
|
22
|
+
warnOnce(`registry-collision:${kind}:${name}`, `[guren] Two different ${kind} classes are registered as "${name}" (${classes}). ${ADVICE[kind]} A future major will throw here instead.`);
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
4
25
|
//#region src/queue/Job.ts
|
|
5
26
|
/**
|
|
6
27
|
* The pin `setQueueDriver()` writes, and nothing else does. A manager that
|
|
@@ -105,6 +126,15 @@ var Job = class {
|
|
|
105
126
|
*/
|
|
106
127
|
static backoff = "exponential";
|
|
107
128
|
container;
|
|
129
|
+
executionSignal;
|
|
130
|
+
/** Aborted when the worker times out or loses its reservation. Pass it to cancellable I/O. */
|
|
131
|
+
get signal() {
|
|
132
|
+
return this.executionSignal ??= new AbortController().signal;
|
|
133
|
+
}
|
|
134
|
+
/** @internal Installed by the worker before handle(). */
|
|
135
|
+
setExecutionSignal(signal) {
|
|
136
|
+
this.executionSignal = signal;
|
|
137
|
+
}
|
|
108
138
|
/** @internal Called by the Worker with the container of the app it drains, before `handle()`. */
|
|
109
139
|
setContainer(container) {
|
|
110
140
|
this.container = container;
|
|
@@ -142,7 +172,9 @@ function resolveJobName(jobClass) {
|
|
|
142
172
|
}
|
|
143
173
|
const jobRegistry = /* @__PURE__ */ new Map();
|
|
144
174
|
function registerJob(jobClass) {
|
|
145
|
-
|
|
175
|
+
const name = resolveJobName(jobClass);
|
|
176
|
+
reportRegistryCollision("job", name, jobRegistry.get(name), jobClass);
|
|
177
|
+
jobRegistry.set(name, jobClass);
|
|
146
178
|
}
|
|
147
179
|
function getJob(name) {
|
|
148
180
|
return jobRegistry.get(name);
|
|
@@ -155,4 +187,4 @@ function clearJobRegistry() {
|
|
|
155
187
|
jobRegistry.clear();
|
|
156
188
|
}
|
|
157
189
|
//#endregion
|
|
158
|
-
export { getJob as a, pinnedQueueDriver as c, resolveQueueDriver as d, setQueueDriver as f, enqueueJob as i, registerJob as l, clearJobRegistry as n, getQueueDriver as o, clearQueueDriver as r, getRegisteredJobs as s, Job as t, resolveJobName as u };
|
|
190
|
+
export { getJob as a, pinnedQueueDriver as c, resolveQueueDriver as d, setQueueDriver as f, enqueueJob as i, registerJob as l, clearJobRegistry as n, getQueueDriver as o, reportRegistryCollision as p, clearQueueDriver as r, getRegisteredJobs as s, Job as t, resolveJobName as u };
|
|
@@ -3,12 +3,12 @@ import { n as getValidatedInput, r as readValidatedInput } from "./validated-inp
|
|
|
3
3
|
import { n as ValidationException } from "./errors-JpkcCjjn.js";
|
|
4
4
|
import { n as parseImportMap, t as DEFAULT_DEV_STYLES_ENTRY } from "./inertia-defaults-BjrcT7za.js";
|
|
5
5
|
import { t as resolveOptional } from "./resolve-optional-ax6gPWTp.js";
|
|
6
|
-
import { h as warnDeprecatedSetter, m as warnDeprecatedGetter } from "./default-application-
|
|
6
|
+
import { h as warnDeprecatedSetter, m as warnDeprecatedGetter } from "./default-application-DWwscxfW.js";
|
|
7
7
|
import { n as ServiceProvider } from "./ServiceProvider-DDW3MqQJ.js";
|
|
8
8
|
import { r as getAuthContext } from "./context-af2n5abO.js";
|
|
9
9
|
import { o as getApiTokenOrFail } from "./api-token-BbgDEd6j.js";
|
|
10
|
-
import { a as resolveI18n } from "./i18n-
|
|
11
|
-
import { d as resolveGate, g as tryGetRequestContainer } from "./Gate-
|
|
10
|
+
import { a as resolveI18n } from "./i18n-DmMKcbqj.js";
|
|
11
|
+
import { d as resolveGate, g as tryGetRequestContainer } from "./Gate-BL_zW82W.js";
|
|
12
12
|
import { t as jsx_runtime_exports } from "./jsx-runtime.js";
|
|
13
13
|
import { getCookie } from "hono/cookie";
|
|
14
14
|
import { isAbsolute, resolve } from "node:path";
|
|
@@ -67,6 +67,117 @@ function copyStackFromError(target, source) {
|
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
//#endregion
|
|
70
|
+
//#region src/mvc/inertia/props.ts
|
|
71
|
+
/**
|
|
72
|
+
* Prop evaluation for the Inertia protocol's partial reloads and deferred
|
|
73
|
+
* props (https://inertiajs.com/the-protocol, "Prop Evaluation Model").
|
|
74
|
+
* `@guren/testing`'s controller mock resolves through the same function, so a
|
|
75
|
+
* test cannot pass on a prop set production would not send.
|
|
76
|
+
*/
|
|
77
|
+
const DEFERRED_BRAND = Symbol.for("guren.inertia.deferred");
|
|
78
|
+
const ALWAYS_BRAND = Symbol.for("guren.inertia.always");
|
|
79
|
+
/**
|
|
80
|
+
* A prop sent on every response, partial reloads included, whatever the
|
|
81
|
+
* `only`/`except` lists say (Laravel's `Inertia::always()`). The protocol's
|
|
82
|
+
* `errors` is one; a flash-backed shared prop is the usual other, since a
|
|
83
|
+
* flash the partial filter drops is gone with the request.
|
|
84
|
+
*/
|
|
85
|
+
function always(value) {
|
|
86
|
+
return Object.freeze({
|
|
87
|
+
[ALWAYS_BRAND]: true,
|
|
88
|
+
value,
|
|
89
|
+
toJSON: () => value
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function isAlwaysProp(value) {
|
|
93
|
+
return typeof value === "object" && value !== null && value[ALWAYS_BRAND] === true;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* A prop resolved in a follow-up request rather than the initial visit
|
|
97
|
+
* (Laravel's `Inertia::defer()`). The initial response announces the key under
|
|
98
|
+
* `deferredProps[group]` and the client fetches each group with one partial
|
|
99
|
+
* reload; `resolve` runs only on the request that asks for the key.
|
|
100
|
+
*/
|
|
101
|
+
function defer(resolve, group = "default") {
|
|
102
|
+
return Object.freeze({
|
|
103
|
+
[DEFERRED_BRAND]: true,
|
|
104
|
+
resolve,
|
|
105
|
+
group
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function isDeferredProp(value) {
|
|
109
|
+
return typeof value === "object" && value !== null && value[DEFERRED_BRAND] === true;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* A header list as its top-level prop names: `author.name` selects `author`.
|
|
113
|
+
* The prototype client (`@guren/inertia-client/prototype`) answers a fixture
|
|
114
|
+
* with the same rule; the two cannot import each other, so keep them in step.
|
|
115
|
+
*/
|
|
116
|
+
function propNames(value) {
|
|
117
|
+
const names = (value ?? "").split(",").map((item) => item.trim().split(".")[0]);
|
|
118
|
+
return new Set(names.filter((name) => Boolean(name)));
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The partial reload a request asks for, or undefined for a full visit. A
|
|
122
|
+
* partial reload is an Inertia request whose `X-Inertia-Partial-Component`
|
|
123
|
+
* names the component being rendered; a different component (the visit was
|
|
124
|
+
* redirected elsewhere) is a full visit again.
|
|
125
|
+
*/
|
|
126
|
+
function readPartialReload(request, component) {
|
|
127
|
+
if (!request?.headers.get("X-Inertia")) return void 0;
|
|
128
|
+
if (request.headers.get("X-Inertia-Partial-Component") !== component) return void 0;
|
|
129
|
+
return {
|
|
130
|
+
only: propNames(request.headers.get("X-Inertia-Partial-Data")),
|
|
131
|
+
except: propNames(request.headers.get("X-Inertia-Partial-Except"))
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function isSelected(key, partial) {
|
|
135
|
+
if (partial.only.size > 0 && !partial.only.has(key)) return false;
|
|
136
|
+
return !partial.except.has(key);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Starts one prop's value. Through a promise so a resolver that throws
|
|
140
|
+
* synchronously rejects like one that throws later: `Promise.all` then settles
|
|
141
|
+
* every sibling rather than leaving the ones already started unhandled.
|
|
142
|
+
*/
|
|
143
|
+
function startProp(value) {
|
|
144
|
+
return Promise.resolve().then(() => isDeferredProp(value) ? value.resolve() : value());
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* The props a response carries under the protocol's evaluation rules: a full
|
|
148
|
+
* visit resolves every prop but the deferred ones, which it announces; a
|
|
149
|
+
* partial reload resolves only the selected props, deferred ones included, and
|
|
150
|
+
* announces nothing; an always prop is sent either way; a lazy prop (a function
|
|
151
|
+
* value) runs only when sent. Resolvers run concurrently, unlike Laravel's.
|
|
152
|
+
*/
|
|
153
|
+
async function resolveInertiaProps(input, partial) {
|
|
154
|
+
const props = {};
|
|
155
|
+
const deferredProps = {};
|
|
156
|
+
const pending = [];
|
|
157
|
+
for (const [key, raw] of Object.entries(input)) {
|
|
158
|
+
const alwaysProp = isAlwaysProp(raw);
|
|
159
|
+
const value = alwaysProp ? raw.value : raw;
|
|
160
|
+
const deferred = isDeferredProp(value);
|
|
161
|
+
if (partial) {
|
|
162
|
+
if (!alwaysProp && !isSelected(key, partial)) continue;
|
|
163
|
+
} else if (deferred) {
|
|
164
|
+
(deferredProps[value.group] ??= []).push(key);
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (deferred || typeof value === "function") {
|
|
168
|
+
props[key] = void 0;
|
|
169
|
+
pending.push(startProp(value).then((resolved) => {
|
|
170
|
+
props[key] = resolved;
|
|
171
|
+
}));
|
|
172
|
+
} else props[key] = value;
|
|
173
|
+
}
|
|
174
|
+
if (pending.length > 0) await Promise.all(pending);
|
|
175
|
+
return Object.keys(deferredProps).length > 0 ? {
|
|
176
|
+
props,
|
|
177
|
+
deferredProps
|
|
178
|
+
} : { props };
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
70
181
|
//#region src/mvc/inertia/InertiaEngine.ts
|
|
71
182
|
ensureErrorStackTracePolyfill();
|
|
72
183
|
let documentOptions;
|
|
@@ -109,47 +220,71 @@ const DEV_FALLBACK_IMPORT_MAP = {
|
|
|
109
220
|
"@inertiajs/react": "https://esm.sh/@inertiajs/react@2.2.15?dev&external=react,react-dom/client"
|
|
110
221
|
};
|
|
111
222
|
async function inertia(component, props, options = {}) {
|
|
223
|
+
const { response } = await renderInertia(component, props, options);
|
|
224
|
+
return response;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* The page body varies on the partial-reload headers as well as on
|
|
228
|
+
* `X-Inertia`: a shared cache keyed on the URL alone would hand a narrowed
|
|
229
|
+
* partial response to the next full visit.
|
|
230
|
+
*/
|
|
231
|
+
const INERTIA_VARY = "Accept, X-Inertia, X-Inertia-Partial-Component, X-Inertia-Partial-Data, X-Inertia-Partial-Except";
|
|
232
|
+
/**
|
|
233
|
+
* {@link inertia} plus the page it sent, for a caller that records the props
|
|
234
|
+
* actually resolved (`Controller.inertia()`'s response marker). The version
|
|
235
|
+
* check runs before any prop resolves: a 409 must not run a lazy prop's query.
|
|
236
|
+
*/
|
|
237
|
+
async function renderInertia(component, props, options = {}) {
|
|
112
238
|
const resolvedVersion = options.version ?? process.env.GUREN_INERTIA_VERSION ?? void 0;
|
|
113
|
-
const page = {
|
|
114
|
-
component,
|
|
115
|
-
props,
|
|
116
|
-
url: options.url ?? inertiaPageUrl(options.request) ?? "",
|
|
117
|
-
version: resolvedVersion
|
|
118
|
-
};
|
|
119
239
|
const request = options.request;
|
|
120
240
|
const isInertiaVisit = Boolean(request?.headers.get("X-Inertia"));
|
|
121
241
|
const prefersJson = request ? acceptsJson(request) : false;
|
|
122
242
|
const versionHeader = resolvedVersion ? { "X-Inertia-Version": resolvedVersion } : {};
|
|
123
243
|
if (request && resolvedVersion && isInertiaVisit && request.method === "GET") {
|
|
124
|
-
if (request.headers.get("X-Inertia-Version") !== resolvedVersion) return new Response(null, {
|
|
244
|
+
if (request.headers.get("X-Inertia-Version") !== resolvedVersion) return { response: new Response(null, {
|
|
125
245
|
status: 409,
|
|
126
246
|
headers: {
|
|
127
247
|
"X-Inertia-Location": options.url ?? request.url,
|
|
128
248
|
Vary: "Accept"
|
|
129
249
|
}
|
|
130
|
-
});
|
|
250
|
+
}) };
|
|
131
251
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
"X-Inertia": "true",
|
|
137
|
-
Vary: "Accept",
|
|
138
|
-
...versionHeader,
|
|
139
|
-
...options.headers
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
const html = await renderDocument$1(page, options);
|
|
143
|
-
return new Response(html, {
|
|
144
|
-
status: options.status ?? 200,
|
|
145
|
-
headers: {
|
|
146
|
-
"Content-Type": "text/html; charset=utf-8",
|
|
147
|
-
"X-Inertia": "true",
|
|
148
|
-
Vary: "Accept",
|
|
149
|
-
...versionHeader,
|
|
150
|
-
...options.headers
|
|
151
|
-
}
|
|
252
|
+
const page = await buildInertiaPage(component, props, {
|
|
253
|
+
url: options.url,
|
|
254
|
+
version: resolvedVersion,
|
|
255
|
+
request
|
|
152
256
|
});
|
|
257
|
+
const wantsJson = isInertiaVisit || prefersJson;
|
|
258
|
+
const body = wantsJson ? serializePage(page) : await renderDocument$1(page, options);
|
|
259
|
+
return {
|
|
260
|
+
page,
|
|
261
|
+
response: new Response(body, {
|
|
262
|
+
status: options.status ?? 200,
|
|
263
|
+
headers: {
|
|
264
|
+
"Content-Type": wantsJson ? "application/json; charset=utf-8" : "text/html; charset=utf-8",
|
|
265
|
+
"X-Inertia": "true",
|
|
266
|
+
Vary: INERTIA_VARY,
|
|
267
|
+
...versionHeader,
|
|
268
|
+
...options.headers
|
|
269
|
+
}
|
|
270
|
+
})
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* The page object for one request: props resolved under the request's
|
|
275
|
+
* partial-reload headers, the deferred announcement, and the page url derived
|
|
276
|
+
* from the request when `url` is absent. `@guren/testing`'s mock builds its
|
|
277
|
+
* page here too, so the two cannot disagree on the payload's shape.
|
|
278
|
+
*/
|
|
279
|
+
async function buildInertiaPage(component, props, options) {
|
|
280
|
+
const resolved = await resolveInertiaProps(props, readPartialReload(options.request, component));
|
|
281
|
+
return {
|
|
282
|
+
component,
|
|
283
|
+
props: resolved.props,
|
|
284
|
+
url: options.url ?? inertiaPageUrl(options.request) ?? "",
|
|
285
|
+
version: options.version,
|
|
286
|
+
...resolved.deferredProps ? { deferredProps: resolved.deferredProps } : {}
|
|
287
|
+
};
|
|
153
288
|
}
|
|
154
289
|
/**
|
|
155
290
|
* The Inertia protocol's page `url` is the request path plus query string, kept
|
|
@@ -486,7 +621,8 @@ function defineModule(definition) {
|
|
|
486
621
|
prefix: definition.prefix,
|
|
487
622
|
routes: definition.routes,
|
|
488
623
|
providers: definition.providers ?? [],
|
|
489
|
-
commands: definition.commands ?? []
|
|
624
|
+
commands: definition.commands ?? [],
|
|
625
|
+
config: definition.config ?? []
|
|
490
626
|
};
|
|
491
627
|
}
|
|
492
628
|
/**
|
|
@@ -755,11 +891,10 @@ var Controller = class {
|
|
|
755
891
|
async inertia(componentOrPage, props, options = {}) {
|
|
756
892
|
const ctx = this.ctx;
|
|
757
893
|
const component = typeof componentOrPage === "string" ? componentOrPage : componentOrPage.component ?? componentOrPage.id;
|
|
758
|
-
const
|
|
894
|
+
const { response, page } = await renderInertia(component, {
|
|
759
895
|
...await resolveSharedInertiaProps(ctx, this._container),
|
|
760
896
|
...props
|
|
761
|
-
}
|
|
762
|
-
const response = await inertia(component, propsWithShared, {
|
|
897
|
+
}, {
|
|
763
898
|
...options,
|
|
764
899
|
lang: options.lang ?? this.#resolveLocale(),
|
|
765
900
|
request: ctx.req.raw,
|
|
@@ -767,7 +902,7 @@ var Controller = class {
|
|
|
767
902
|
});
|
|
768
903
|
response.__gurenInertia = {
|
|
769
904
|
component,
|
|
770
|
-
props:
|
|
905
|
+
props: page?.props ?? {}
|
|
771
906
|
};
|
|
772
907
|
return response;
|
|
773
908
|
}
|
|
@@ -1032,4 +1167,4 @@ var JsonResource = class extends Resource {
|
|
|
1032
1167
|
}
|
|
1033
1168
|
};
|
|
1034
1169
|
//#endregion
|
|
1035
|
-
export { ensureErrorStackTracePolyfill as S,
|
|
1170
|
+
export { setInertiaSsrRenderer as C, isDeferredProp as D, isAlwaysProp as E, ensureErrorStackTracePolyfill as O, setInertiaDocument as S, defer as T, INERTIA_VARY as _, renderDocument as a, inertia as b, getRequestLocale as c, mountModuleRoutes as d, definePlugin as f, shareInertiaProps as g, setInertiaSharedProps as h, Controller as i, getRequestTranslator as l, resolveSharedInertiaProps as m, Resource as n, LOCALE_CONTEXT_KEY as o, getInertiaSharedPropsResolver as p, collect as r, detectLocaleMiddleware as s, JsonResource as t, defineModule as u, acceptsJson as v, always as w, serializePage as x, buildInertiaPage as y };
|
package/dist/agent/scopes.d.ts
CHANGED
|
@@ -10,9 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
/**
|
|
12
12
|
* The MCP tool-name grammar (SEP-986), which a `tool:` scope names and a
|
|
13
|
-
* `tools:<prefix>.*` scope must stay inside.
|
|
14
|
-
* holds the same pattern; collapsing the two needs a built server, so it waits
|
|
15
|
-
* for the PR doing that build-order work. `*` is not in the charset, so
|
|
13
|
+
* `tools:<prefix>.*` scope must stay inside. `*` is not in the charset, so
|
|
16
14
|
* `tool:posts.*` is rejected with no special case.
|
|
17
15
|
*/
|
|
18
16
|
export declare const AGENT_TOOL_NAME_PATTERN: RegExp;
|
|
@@ -17,6 +17,10 @@ export interface EmailVerificationToken {
|
|
|
17
17
|
export interface EmailVerificationTokenStore {
|
|
18
18
|
/** Store a new verification token. */
|
|
19
19
|
store(token: EmailVerificationToken): Promise<void>;
|
|
20
|
+
/** Atomically replace every token for this email. Required by token issuance. */
|
|
21
|
+
replace?(token: EmailVerificationToken): Promise<void>;
|
|
22
|
+
/** Atomically delete this token only if its stored email matches. Required by completion. */
|
|
23
|
+
consume?(tokenId: string, email: string): Promise<boolean>;
|
|
20
24
|
/** Find a token by its opaque token ID. */
|
|
21
25
|
findByTokenId(tokenId: string): Promise<EmailVerificationToken | null>;
|
|
22
26
|
/** Delete a token by its opaque token ID. */
|
|
@@ -28,6 +32,8 @@ export interface EmailVerificationTokenStore {
|
|
|
28
32
|
export declare class MemoryEmailVerificationStore implements EmailVerificationTokenStore {
|
|
29
33
|
private tokens;
|
|
30
34
|
store(token: EmailVerificationToken): Promise<void>;
|
|
35
|
+
replace(token: EmailVerificationToken): Promise<void>;
|
|
36
|
+
consume(tokenId: string, email: string): Promise<boolean>;
|
|
31
37
|
findByTokenId(tokenId: string): Promise<EmailVerificationToken | null>;
|
|
32
38
|
delete(tokenId: string): Promise<void>;
|
|
33
39
|
deleteForEmail(email: string): Promise<void>;
|
package/dist/auth/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as verifyOAuthState, B as NodeHasher, C as createGoogleOAuthProviderConfig, D as fetchOAuthUserProfile, E as exchangeOAuthCode, H as BaseUserProvider, I as TokenGuard, L as SessionGuard, O as parseOAuthRedirectUrl, P as AuthManager, R as ModelUserProvider, S as createGitHubOAuthProviderConfig, T as createOAuthState, V as ScryptHasher, _ as OAUTH_SESSION_BINDING_KEY, a as isEmailVerified, b as buildOAuthRedirectUrl, c as verifyEmailToken, d as completePasswordReset, f as createPasswordResetToken, g as MemoryOAuthStateStore, h as AuthenticatableModel, i as createEmailVerificationToken, k as sanitizeOAuthRedirect, l as MemoryPasswordResetStore, m as verifyPasswordResetToken, n as buildVerificationUrl, o as parseVerificationUrl, p as parsePasswordResetUrl, r as completeEmailVerification, s as requireVerifiedEmail, t as MemoryEmailVerificationStore, u as buildPasswordResetUrl, v as OAuthManager, w as createOAuthManager, x as createDiscordOAuthProviderConfig, y as buildOAuthAuthorizeUrl } from "../auth-
|
|
1
|
+
import { A as verifyOAuthState, B as NodeHasher, C as createGoogleOAuthProviderConfig, D as fetchOAuthUserProfile, E as exchangeOAuthCode, H as BaseUserProvider, I as TokenGuard, L as SessionGuard, O as parseOAuthRedirectUrl, P as AuthManager, R as ModelUserProvider, S as createGitHubOAuthProviderConfig, T as createOAuthState, V as ScryptHasher, _ as OAUTH_SESSION_BINDING_KEY, a as isEmailVerified, b as buildOAuthRedirectUrl, c as verifyEmailToken, d as completePasswordReset, f as createPasswordResetToken, g as MemoryOAuthStateStore, h as AuthenticatableModel, i as createEmailVerificationToken, k as sanitizeOAuthRedirect, l as MemoryPasswordResetStore, m as verifyPasswordResetToken, n as buildVerificationUrl, o as parseVerificationUrl, p as parsePasswordResetUrl, r as completeEmailVerification, s as requireVerifiedEmail, t as MemoryEmailVerificationStore, u as buildPasswordResetUrl, v as OAuthManager, w as createOAuthManager, x as createDiscordOAuthProviderConfig, y as buildOAuthAuthorizeUrl } from "../auth-DiyWALZT.js";
|
|
2
2
|
import { C as secureCompare, S as parseTokenUrl, _ as verifyApiToken, a as getApiToken, b as generateToken, d as revokeAllApiTokens, f as revokeApiToken, g as tokenCanAny, h as tokenCanAll, i as createBearerTokenMiddleware, l as parseApiToken, m as tokenCan, n as MemoryApiTokenStore, o as getApiTokenOrFail, r as createApiToken, s as getUserApiTokens, t as API_TOKEN_KEY, u as readBearerToken, v as buildTokenUrl, w as secureStringCompare, x as hashToken, y as generateId } from "../api-token-BbgDEd6j.js";
|
|
3
3
|
export { API_TOKEN_KEY, ScryptHasher as Argon2Hasher, ScryptHasher, AuthManager, AuthenticatableModel, BaseUserProvider, MemoryApiTokenStore, MemoryEmailVerificationStore, MemoryOAuthStateStore, MemoryPasswordResetStore, ModelUserProvider, NodeHasher, OAUTH_SESSION_BINDING_KEY, OAuthManager, SessionGuard, TokenGuard, buildOAuthAuthorizeUrl, buildOAuthRedirectUrl, buildPasswordResetUrl, buildTokenUrl, buildVerificationUrl, completeEmailVerification, completePasswordReset, createApiToken, createBearerTokenMiddleware, createDiscordOAuthProviderConfig, createEmailVerificationToken, createGitHubOAuthProviderConfig, createGoogleOAuthProviderConfig, createOAuthManager, createOAuthState, createPasswordResetToken, exchangeOAuthCode, fetchOAuthUserProfile, generateId, generateToken, getApiToken, getApiTokenOrFail, getUserApiTokens, hashToken, isEmailVerified, parseApiToken, parseOAuthRedirectUrl, parsePasswordResetUrl, parseTokenUrl, parseVerificationUrl, readBearerToken, requireVerifiedEmail, revokeAllApiTokens, revokeApiToken, sanitizeOAuthRedirect, secureCompare, secureStringCompare, tokenCan, tokenCanAll, tokenCanAny, verifyApiToken, verifyEmailToken, verifyOAuthState, verifyPasswordResetToken };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { UserProvider } from './types.js';
|
|
2
2
|
import { buildTokenUrl, parseTokenUrl } from './utils.js';
|
|
3
3
|
/**
|
|
4
4
|
* Configuration for password reset tokens. Applies at issuance only: the expiry
|
|
@@ -18,6 +18,10 @@ export interface PasswordResetConfig {
|
|
|
18
18
|
export interface PasswordResetTokenStore {
|
|
19
19
|
/** Store a token ID with associated email and expiration */
|
|
20
20
|
store(tokenId: string, email: string, expiresAt: Date): Promise<void>;
|
|
21
|
+
/** Atomically replace every token for this email. Required by token issuance. */
|
|
22
|
+
replace?(tokenId: string, email: string, expiresAt: Date): Promise<void>;
|
|
23
|
+
/** Atomically delete this token only if its stored email matches. Required by completion. */
|
|
24
|
+
consume?(tokenId: string, email: string): Promise<boolean>;
|
|
21
25
|
/** Find email by token ID, returns null if not found or already dropped */
|
|
22
26
|
find(tokenId: string): Promise<{
|
|
23
27
|
email: string;
|
|
@@ -32,6 +36,8 @@ export interface PasswordResetTokenStore {
|
|
|
32
36
|
export declare class MemoryPasswordResetStore implements PasswordResetTokenStore {
|
|
33
37
|
private tokens;
|
|
34
38
|
store(tokenId: string, email: string, expiresAt: Date): Promise<void>;
|
|
39
|
+
replace(tokenId: string, email: string, expiresAt: Date): Promise<void>;
|
|
40
|
+
consume(tokenId: string, email: string): Promise<boolean>;
|
|
35
41
|
find(tokenId: string): Promise<{
|
|
36
42
|
email: string;
|
|
37
43
|
expiresAt: Date;
|
|
@@ -58,7 +64,7 @@ export declare function verifyPasswordResetToken(token: string, store: PasswordR
|
|
|
58
64
|
* Complete a password reset: update the user's password and invalidate the
|
|
59
65
|
* token. Returns the user, or `null` when the token is invalid.
|
|
60
66
|
*/
|
|
61
|
-
export declare function completePasswordReset<T
|
|
67
|
+
export declare function completePasswordReset<T>(token: string, newPassword: string, store: PasswordResetTokenStore, provider: Pick<UserProvider<T>, 'retrieveByCredentials'>, updatePassword: (user: T, password: string) => Promise<void>): Promise<T | null>;
|
|
62
68
|
/** Build a password reset URL from a base URL and token. */
|
|
63
69
|
export declare const buildPasswordResetUrl: typeof buildTokenUrl;
|
|
64
70
|
/** Parse a password reset URL to extract the token and optional email. */
|
|
@@ -1806,6 +1806,20 @@ var MemoryPasswordResetStore = class {
|
|
|
1806
1806
|
expiresAt
|
|
1807
1807
|
});
|
|
1808
1808
|
}
|
|
1809
|
+
async replace(tokenId, email, expiresAt) {
|
|
1810
|
+
const normalizedEmail = email.toLowerCase();
|
|
1811
|
+
for (const [id, record] of this.tokens) if (record.email.toLowerCase() === normalizedEmail) this.tokens.delete(id);
|
|
1812
|
+
this.tokens.set(tokenId, {
|
|
1813
|
+
email: normalizedEmail,
|
|
1814
|
+
expiresAt
|
|
1815
|
+
});
|
|
1816
|
+
}
|
|
1817
|
+
async consume(tokenId, email) {
|
|
1818
|
+
const record = this.tokens.get(tokenId);
|
|
1819
|
+
if (!record || record.email !== email) return false;
|
|
1820
|
+
this.tokens.delete(tokenId);
|
|
1821
|
+
return true;
|
|
1822
|
+
}
|
|
1809
1823
|
async find(tokenId) {
|
|
1810
1824
|
const record = this.tokens.get(tokenId);
|
|
1811
1825
|
if (!record) return null;
|
|
@@ -1819,7 +1833,7 @@ var MemoryPasswordResetStore = class {
|
|
|
1819
1833
|
this.tokens.delete(tokenId);
|
|
1820
1834
|
}
|
|
1821
1835
|
async deleteForEmail(email) {
|
|
1822
|
-
for (const [hash, record] of this.tokens) if (record.email === email) this.tokens.delete(hash);
|
|
1836
|
+
for (const [hash, record] of this.tokens) if (record.email.toLowerCase() === email.toLowerCase()) this.tokens.delete(hash);
|
|
1823
1837
|
}
|
|
1824
1838
|
/** Clear all tokens (useful for testing) */
|
|
1825
1839
|
clear() {
|
|
@@ -1836,7 +1850,7 @@ function createPasswordResetSigner() {
|
|
|
1836
1850
|
async function createPasswordResetToken(email, store, config = {}) {
|
|
1837
1851
|
const expiresIn = config.expiresIn ?? DEFAULT_EXPIRES_IN;
|
|
1838
1852
|
const tokenLength = config.tokenLength ?? DEFAULT_TOKEN_LENGTH;
|
|
1839
|
-
|
|
1853
|
+
if (!store.replace) throw new Error("Password reset token issuance requires an atomic store.replace() implementation.");
|
|
1840
1854
|
const tokenId = generateId();
|
|
1841
1855
|
const expiresAt = new Date(Date.now() + expiresIn);
|
|
1842
1856
|
const token = createPasswordResetSigner().sign({
|
|
@@ -1847,7 +1861,7 @@ async function createPasswordResetToken(email, store, config = {}) {
|
|
|
1847
1861
|
purpose: PASSWORD_RESET_PURPOSE,
|
|
1848
1862
|
expiresIn
|
|
1849
1863
|
});
|
|
1850
|
-
await store.
|
|
1864
|
+
await store.replace(tokenId, email.toLowerCase(), expiresAt);
|
|
1851
1865
|
return {
|
|
1852
1866
|
token,
|
|
1853
1867
|
tokenId,
|
|
@@ -1877,8 +1891,9 @@ async function completePasswordReset(token, newPassword, store, provider, update
|
|
|
1877
1891
|
await store.delete(claims.id);
|
|
1878
1892
|
return null;
|
|
1879
1893
|
}
|
|
1894
|
+
if (!store.consume) throw new Error("Password reset completion requires an atomic store.consume() implementation.");
|
|
1895
|
+
if (!await store.consume(claims.id, record.email)) return null;
|
|
1880
1896
|
await updatePassword(user, newPassword);
|
|
1881
|
-
await store.delete(claims.id);
|
|
1882
1897
|
return user;
|
|
1883
1898
|
}
|
|
1884
1899
|
/** Build a password reset URL from a base URL and token. */
|
|
@@ -1893,6 +1908,20 @@ var MemoryEmailVerificationStore = class {
|
|
|
1893
1908
|
async store(token) {
|
|
1894
1909
|
this.tokens.set(token.tokenId, token);
|
|
1895
1910
|
}
|
|
1911
|
+
async replace(token) {
|
|
1912
|
+
const email = token.email.toLowerCase();
|
|
1913
|
+
for (const [id, record] of this.tokens) if (record.email.toLowerCase() === email) this.tokens.delete(id);
|
|
1914
|
+
this.tokens.set(token.tokenId, {
|
|
1915
|
+
...token,
|
|
1916
|
+
email
|
|
1917
|
+
});
|
|
1918
|
+
}
|
|
1919
|
+
async consume(tokenId, email) {
|
|
1920
|
+
const record = this.tokens.get(tokenId);
|
|
1921
|
+
if (!record || record.email !== email) return false;
|
|
1922
|
+
this.tokens.delete(tokenId);
|
|
1923
|
+
return true;
|
|
1924
|
+
}
|
|
1896
1925
|
async findByTokenId(tokenId) {
|
|
1897
1926
|
return this.tokens.get(tokenId) ?? null;
|
|
1898
1927
|
}
|
|
@@ -1929,7 +1958,7 @@ async function createEmailVerificationToken(email, store, config = {}) {
|
|
|
1929
1958
|
...DEFAULT_CONFIG,
|
|
1930
1959
|
...config
|
|
1931
1960
|
};
|
|
1932
|
-
|
|
1961
|
+
if (!store.replace) throw new Error("Email verification token issuance requires an atomic store.replace() implementation.");
|
|
1933
1962
|
const tokenId = generateId();
|
|
1934
1963
|
const now = /* @__PURE__ */ new Date();
|
|
1935
1964
|
const expiresAt = new Date(now.getTime() + expiresIn);
|
|
@@ -1941,7 +1970,7 @@ async function createEmailVerificationToken(email, store, config = {}) {
|
|
|
1941
1970
|
purpose: EMAIL_VERIFICATION_PURPOSE,
|
|
1942
1971
|
expiresIn
|
|
1943
1972
|
});
|
|
1944
|
-
await store.
|
|
1973
|
+
await store.replace({
|
|
1945
1974
|
email: email.toLowerCase(),
|
|
1946
1975
|
tokenId,
|
|
1947
1976
|
expiresAt,
|
|
@@ -1973,9 +2002,9 @@ async function completeEmailVerification(token, store, markVerified) {
|
|
|
1973
2002
|
const storedToken = await store.findByTokenId(claims.id);
|
|
1974
2003
|
if (!storedToken) return null;
|
|
1975
2004
|
if (storedToken.email.toLowerCase() !== claims.email.toLowerCase()) return null;
|
|
1976
|
-
|
|
1977
|
-
await store.
|
|
1978
|
-
return
|
|
2005
|
+
if (!store.consume) throw new Error("Email verification completion requires an atomic store.consume() implementation.");
|
|
2006
|
+
if (!await store.consume(claims.id, storedToken.email)) return null;
|
|
2007
|
+
return markVerified(storedToken.email);
|
|
1979
2008
|
}
|
|
1980
2009
|
/** Build a verification URL. */
|
|
1981
2010
|
const buildVerificationUrl = buildTokenUrl;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as withAuthorization, n as authorizeMiddleware, o as Policy, r as authorizeResourceMiddleware, s as definePolicy, t as authorizeAllMiddleware } from "../authorization-
|
|
2
|
-
import { a as cannot, f as setGate, i as can, l as getGate, n as Response, o as createGate, r as authorize, s as defineGate, t as Gate, u as isAuthorizationResponse } from "../Gate-
|
|
1
|
+
import { a as withAuthorization, n as authorizeMiddleware, o as Policy, r as authorizeResourceMiddleware, s as definePolicy, t as authorizeAllMiddleware } from "../authorization-E6X6Y-B6.js";
|
|
2
|
+
import { a as cannot, f as setGate, i as can, l as getGate, n as Response, o as createGate, r as authorize, s as defineGate, t as Gate, u as isAuthorizationResponse } from "../Gate-BL_zW82W.js";
|
|
3
3
|
export { Gate, Policy, Response, authorize, authorizeAllMiddleware, authorizeMiddleware, authorizeResourceMiddleware, can, cannot, createGate, defineGate, definePolicy, getGate, isAuthorizationResponse, setGate, withAuthorization };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as denialToException, d as resolveGate, g as tryGetRequestContainer, n as Response, p as AuthorizationException } from "./Gate-
|
|
1
|
+
import { c as denialToException, d as resolveGate, g as tryGetRequestContainer, n as Response, p as AuthorizationException } from "./Gate-BL_zW82W.js";
|
|
2
2
|
//#region src/http/middleware/capabilities.ts
|
|
3
3
|
/**
|
|
4
4
|
* Internal security-capability marker (RFC 0007): built-in middleware
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as setBroadcastManager, c as PresenceChannel, i as getBroadcastManager, l as PrivateChannel, n as BroadcastManager, o as RedisDriver, r as createBroadcastManager, s as MemoryDriver, t as createTypedBroadcaster, u as Channel } from "../broadcasting-
|
|
1
|
+
import { a as setBroadcastManager, c as PresenceChannel, i as getBroadcastManager, l as PrivateChannel, n as BroadcastManager, o as RedisDriver, r as createBroadcastManager, s as MemoryDriver, t as createTypedBroadcaster, u as Channel } from "../broadcasting-D0vMkKcq.js";
|
|
2
2
|
export { BroadcastManager, Channel, MemoryDriver, PresenceChannel, PrivateChannel, RedisDriver, createBroadcastManager, createTypedBroadcaster, getBroadcastManager, setBroadcastManager };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as parseRequestPayload } from "./request-CLOYytGP.js";
|
|
2
|
-
import { h as warnDeprecatedSetter, i as bindAmbient, m as warnDeprecatedGetter, n as ambientBinding } from "./default-application-
|
|
2
|
+
import { h as warnDeprecatedSetter, i as bindAmbient, m as warnDeprecatedGetter, n as ambientBinding } from "./default-application-DWwscxfW.js";
|
|
3
3
|
import { n as isHotReloadRuntime, t as claimHotDisposable } from "./hot-disposables-W2fH-GID.js";
|
|
4
4
|
import { c as randomHex } from "./Random-S0OvCuR8.js";
|
|
5
5
|
//#region src/broadcasting/channels/Channel.ts
|
package/dist/cache/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as RedisStore, i as FileStore, n as createCacheManager, o as MemoryStore, r as TaggedCache, t as CacheManager } from "../cache-
|
|
1
|
+
import { a as RedisStore, i as FileStore, n as createCacheManager, o as MemoryStore, r as TaggedCache, t as CacheManager } from "../cache-DcnRufMe.js";
|
|
2
2
|
export { CacheManager, FileStore, MemoryStore, RedisStore, TaggedCache, createCacheManager };
|
|
@@ -9,10 +9,12 @@ export declare class FileStore implements CacheStore {
|
|
|
9
9
|
private ensureDirectory;
|
|
10
10
|
private readCacheFile;
|
|
11
11
|
private writeCacheFile;
|
|
12
|
+
private withFileLock;
|
|
12
13
|
private deleteCacheFile;
|
|
13
14
|
private isExpired;
|
|
14
15
|
get<T>(key: string): Promise<T | null>;
|
|
15
16
|
set<T>(key: string, value: T, ttl?: number): Promise<void>;
|
|
17
|
+
add<T>(key: string, value: T): Promise<boolean>;
|
|
16
18
|
has(key: string): Promise<boolean>;
|
|
17
19
|
delete(key: string): Promise<boolean>;
|
|
18
20
|
clear(): Promise<void>;
|
|
@@ -11,6 +11,7 @@ export declare class MemoryStore implements CacheStore {
|
|
|
11
11
|
private evictIfNeeded;
|
|
12
12
|
get<T>(key: string): Promise<T | null>;
|
|
13
13
|
set<T>(key: string, value: T, ttl?: number): Promise<void>;
|
|
14
|
+
add<T>(key: string, value: T): Promise<boolean>;
|
|
14
15
|
has(key: string): Promise<boolean>;
|
|
15
16
|
delete(key: string): Promise<boolean>;
|
|
16
17
|
clear(): Promise<void>;
|
|
@@ -9,6 +9,7 @@ export declare class RedisStore implements CacheStore {
|
|
|
9
9
|
private deserialize;
|
|
10
10
|
get<T>(key: string): Promise<T | null>;
|
|
11
11
|
set<T>(key: string, value: T, ttl?: number): Promise<void>;
|
|
12
|
+
add<T>(key: string, value: T): Promise<boolean>;
|
|
12
13
|
has(key: string): Promise<boolean>;
|
|
13
14
|
delete(key: string): Promise<boolean>;
|
|
14
15
|
clear(): Promise<void>;
|
package/dist/cache/types.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export interface CacheStore {
|
|
2
|
+
/** Atomic insertion when absent, required for tag namespace initialization. */
|
|
3
|
+
add?<T>(key: string, value: T): Promise<boolean>;
|
|
2
4
|
get<T>(key: string): Promise<T | null>;
|
|
3
5
|
/** @param ttl Time-to-live in seconds. */
|
|
4
6
|
set<T>(key: string, value: T, ttl?: number): Promise<void>;
|