mates-fullstack 1.0.0-beta.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.
Files changed (202) hide show
  1. package/README.md +311 -0
  2. package/dist/arctic-auth.d.ts +101 -0
  3. package/dist/arctic-auth.d.ts.map +1 -0
  4. package/dist/arctic-auth.js +538 -0
  5. package/dist/arctic-auth.js.map +1 -0
  6. package/dist/asset-manifest.d.ts +14 -0
  7. package/dist/asset-manifest.d.ts.map +1 -0
  8. package/dist/asset-manifest.js +102 -0
  9. package/dist/asset-manifest.js.map +1 -0
  10. package/dist/browser.d.ts +18 -0
  11. package/dist/browser.d.ts.map +1 -0
  12. package/dist/browser.js +25 -0
  13. package/dist/browser.js.map +1 -0
  14. package/dist/build-esbuild.d.ts +29 -0
  15. package/dist/build-esbuild.d.ts.map +1 -0
  16. package/dist/build-esbuild.js +699 -0
  17. package/dist/build-esbuild.js.map +1 -0
  18. package/dist/build-prod.d.ts +126 -0
  19. package/dist/build-prod.d.ts.map +1 -0
  20. package/dist/build-prod.js +1014 -0
  21. package/dist/build-prod.js.map +1 -0
  22. package/dist/cli-new.d.ts +14 -0
  23. package/dist/cli-new.d.ts.map +1 -0
  24. package/dist/cli-new.js +637 -0
  25. package/dist/cli-new.js.map +1 -0
  26. package/dist/client.d.ts +43 -0
  27. package/dist/client.d.ts.map +1 -0
  28. package/dist/client.js +130 -0
  29. package/dist/client.js.map +1 -0
  30. package/dist/cors.d.ts +16 -0
  31. package/dist/cors.d.ts.map +1 -0
  32. package/dist/cors.js +60 -0
  33. package/dist/cors.js.map +1 -0
  34. package/dist/ctx.d.ts +78 -0
  35. package/dist/ctx.d.ts.map +1 -0
  36. package/dist/ctx.js +280 -0
  37. package/dist/ctx.js.map +1 -0
  38. package/dist/dev-watcher.d.ts +23 -0
  39. package/dist/dev-watcher.d.ts.map +1 -0
  40. package/dist/dev-watcher.js +136 -0
  41. package/dist/dev-watcher.js.map +1 -0
  42. package/dist/docs-generator.d.ts +69 -0
  43. package/dist/docs-generator.d.ts.map +1 -0
  44. package/dist/docs-generator.js +557 -0
  45. package/dist/docs-generator.js.map +1 -0
  46. package/dist/docs-page.d.ts +20 -0
  47. package/dist/docs-page.d.ts.map +1 -0
  48. package/dist/docs-page.js +1152 -0
  49. package/dist/docs-page.js.map +1 -0
  50. package/dist/download.d.ts +78 -0
  51. package/dist/download.d.ts.map +1 -0
  52. package/dist/download.js +202 -0
  53. package/dist/download.js.map +1 -0
  54. package/dist/env-loader.d.ts +76 -0
  55. package/dist/env-loader.d.ts.map +1 -0
  56. package/dist/env-loader.js +213 -0
  57. package/dist/env-loader.js.map +1 -0
  58. package/dist/errors.d.ts +146 -0
  59. package/dist/errors.d.ts.map +1 -0
  60. package/dist/errors.js +386 -0
  61. package/dist/errors.js.map +1 -0
  62. package/dist/head.d.ts +31 -0
  63. package/dist/head.d.ts.map +1 -0
  64. package/dist/head.js +245 -0
  65. package/dist/head.js.map +1 -0
  66. package/dist/index.d.ts +30 -0
  67. package/dist/index.d.ts.map +1 -0
  68. package/dist/index.js +30 -0
  69. package/dist/index.js.map +1 -0
  70. package/dist/internal-prefixes.d.ts +16 -0
  71. package/dist/internal-prefixes.d.ts.map +1 -0
  72. package/dist/internal-prefixes.js +16 -0
  73. package/dist/internal-prefixes.js.map +1 -0
  74. package/dist/internal.d.ts +25 -0
  75. package/dist/internal.d.ts.map +1 -0
  76. package/dist/internal.js +25 -0
  77. package/dist/internal.js.map +1 -0
  78. package/dist/jwt.d.ts +166 -0
  79. package/dist/jwt.d.ts.map +1 -0
  80. package/dist/jwt.js +261 -0
  81. package/dist/jwt.js.map +1 -0
  82. package/dist/log.d.ts +44 -0
  83. package/dist/log.d.ts.map +1 -0
  84. package/dist/log.js +66 -0
  85. package/dist/log.js.map +1 -0
  86. package/dist/logger.d.ts +76 -0
  87. package/dist/logger.d.ts.map +1 -0
  88. package/dist/logger.js +138 -0
  89. package/dist/logger.js.map +1 -0
  90. package/dist/main-runner.d.ts +59 -0
  91. package/dist/main-runner.d.ts.map +1 -0
  92. package/dist/main-runner.js +157 -0
  93. package/dist/main-runner.js.map +1 -0
  94. package/dist/mates-auth.d.ts +82 -0
  95. package/dist/mates-auth.d.ts.map +1 -0
  96. package/dist/mates-auth.js +323 -0
  97. package/dist/mates-auth.js.map +1 -0
  98. package/dist/middleware.d.ts +30 -0
  99. package/dist/middleware.d.ts.map +1 -0
  100. package/dist/middleware.js +67 -0
  101. package/dist/middleware.js.map +1 -0
  102. package/dist/project-resolver.d.ts +102 -0
  103. package/dist/project-resolver.d.ts.map +1 -0
  104. package/dist/project-resolver.js +271 -0
  105. package/dist/project-resolver.js.map +1 -0
  106. package/dist/rate-limit.d.ts +37 -0
  107. package/dist/rate-limit.d.ts.map +1 -0
  108. package/dist/rate-limit.js +109 -0
  109. package/dist/rate-limit.js.map +1 -0
  110. package/dist/redirect.d.ts +84 -0
  111. package/dist/redirect.d.ts.map +1 -0
  112. package/dist/redirect.js +105 -0
  113. package/dist/redirect.js.map +1 -0
  114. package/dist/renderer.d.ts +91 -0
  115. package/dist/renderer.d.ts.map +1 -0
  116. package/dist/renderer.js +630 -0
  117. package/dist/renderer.js.map +1 -0
  118. package/dist/request-logger.d.ts +12 -0
  119. package/dist/request-logger.d.ts.map +1 -0
  120. package/dist/request-logger.js +55 -0
  121. package/dist/request-logger.js.map +1 -0
  122. package/dist/rest.d.ts +25 -0
  123. package/dist/rest.d.ts.map +1 -0
  124. package/dist/rest.js +93 -0
  125. package/dist/rest.js.map +1 -0
  126. package/dist/router.d.ts +71 -0
  127. package/dist/router.d.ts.map +1 -0
  128. package/dist/router.js +222 -0
  129. package/dist/router.js.map +1 -0
  130. package/dist/rpc-registry.d.ts +84 -0
  131. package/dist/rpc-registry.d.ts.map +1 -0
  132. package/dist/rpc-registry.js +271 -0
  133. package/dist/rpc-registry.js.map +1 -0
  134. package/dist/rpc-runner.d.ts +82 -0
  135. package/dist/rpc-runner.d.ts.map +1 -0
  136. package/dist/rpc-runner.js +564 -0
  137. package/dist/rpc-runner.js.map +1 -0
  138. package/dist/sanitize.d.ts +61 -0
  139. package/dist/sanitize.d.ts.map +1 -0
  140. package/dist/sanitize.js +193 -0
  141. package/dist/sanitize.js.map +1 -0
  142. package/dist/security-headers.d.ts +114 -0
  143. package/dist/security-headers.d.ts.map +1 -0
  144. package/dist/security-headers.js +121 -0
  145. package/dist/security-headers.js.map +1 -0
  146. package/dist/server-fn.d.ts +323 -0
  147. package/dist/server-fn.d.ts.map +1 -0
  148. package/dist/server-fn.js +373 -0
  149. package/dist/server-fn.js.map +1 -0
  150. package/dist/server-public.d.ts +13 -0
  151. package/dist/server-public.d.ts.map +1 -0
  152. package/dist/server-public.js +12 -0
  153. package/dist/server-public.js.map +1 -0
  154. package/dist/server-timeout.d.ts +38 -0
  155. package/dist/server-timeout.d.ts.map +1 -0
  156. package/dist/server-timeout.js +46 -0
  157. package/dist/server-timeout.js.map +1 -0
  158. package/dist/server.d.ts +100 -0
  159. package/dist/server.d.ts.map +1 -0
  160. package/dist/server.js +1218 -0
  161. package/dist/server.js.map +1 -0
  162. package/dist/socket-router.d.ts +153 -0
  163. package/dist/socket-router.d.ts.map +1 -0
  164. package/dist/socket-router.js +612 -0
  165. package/dist/socket-router.js.map +1 -0
  166. package/dist/sso.d.ts +90 -0
  167. package/dist/sso.d.ts.map +1 -0
  168. package/dist/sso.js +261 -0
  169. package/dist/sso.js.map +1 -0
  170. package/dist/ssr-context.d.ts +49 -0
  171. package/dist/ssr-context.d.ts.map +1 -0
  172. package/dist/ssr-context.js +85 -0
  173. package/dist/ssr-context.js.map +1 -0
  174. package/dist/ssr-globals.d.ts +32 -0
  175. package/dist/ssr-globals.d.ts.map +1 -0
  176. package/dist/ssr-globals.js +1010 -0
  177. package/dist/ssr-globals.js.map +1 -0
  178. package/dist/ssr-template.d.ts +73 -0
  179. package/dist/ssr-template.d.ts.map +1 -0
  180. package/dist/ssr-template.js +507 -0
  181. package/dist/ssr-template.js.map +1 -0
  182. package/dist/stack-mapper.d.ts +25 -0
  183. package/dist/stack-mapper.d.ts.map +1 -0
  184. package/dist/stack-mapper.js +139 -0
  185. package/dist/stack-mapper.js.map +1 -0
  186. package/dist/stream.d.ts +89 -0
  187. package/dist/stream.d.ts.map +1 -0
  188. package/dist/stream.js +299 -0
  189. package/dist/stream.js.map +1 -0
  190. package/dist/upload.d.ts +69 -0
  191. package/dist/upload.d.ts.map +1 -0
  192. package/dist/upload.js +110 -0
  193. package/dist/upload.js.map +1 -0
  194. package/dist/validate.d.ts +58 -0
  195. package/dist/validate.d.ts.map +1 -0
  196. package/dist/validate.js +89 -0
  197. package/dist/validate.js.map +1 -0
  198. package/dist/verify-package.d.ts +3 -0
  199. package/dist/verify-package.d.ts.map +1 -0
  200. package/dist/verify-package.js +128 -0
  201. package/dist/verify-package.js.map +1 -0
  202. package/package.json +79 -0
package/dist/head.js ADDED
@@ -0,0 +1,245 @@
1
+ /**
2
+ * mates-fullstack — head.ts
3
+ *
4
+ * Builds the final HTML page by reading client/index.html as a template and
5
+ * replacing three markers:
6
+ * - <!-- mates:css --> → CSS bundle link
7
+ * - <!-- mates:ssr --> → SSR-rendered app HTML
8
+ * - <!-- mates:scripts --> → dev helpers + client bundle script
9
+ */
10
+ import fs from "node:fs";
11
+ import path from "node:path";
12
+ import { CRASH_OVERLAY_MODULE, RELOAD_ENDPOINT } from "./internal-prefixes.js";
13
+ export const MARKER_CSS = "<!-- mates:css -->";
14
+ export const MARKER_SSR = "<!-- mates:ssr -->";
15
+ export const MARKER_SCRIPTS = "<!-- mates:scripts -->";
16
+ /**
17
+ * Dev-only HMR runtime, injected inline into the page <body>.
18
+ *
19
+ * Connects to the SSE reload endpoint and reacts to structured update
20
+ * messages:
21
+ * - { kind: "css", css } → swap the single linked stylesheet.
22
+ * - anything else → full page reload.
23
+ *
24
+ * The first message after (re)connecting only establishes a baseline
25
+ * generation, so a fresh page load never triggers a spurious reload.
26
+ */
27
+ const HMR_CLIENT = `(function () {
28
+ var ENDPOINT = ${JSON.stringify(RELOAD_ENDPOINT)};
29
+ var lastGen = null;
30
+ var accepted = Object.create(null);
31
+ var components = Object.create(null);
32
+
33
+ window.__mates_hmr = {
34
+ components: components,
35
+ createHotContext: function (id) {
36
+ return {
37
+ accept: function (cb) {
38
+ accepted[id] = cb || function (mod) { window.__mates_hmr.updateModule(id, mod); };
39
+ },
40
+ invalidate: function () {
41
+ location.reload();
42
+ }
43
+ };
44
+ },
45
+ registerComponent: function (id, impl, meta) {
46
+ components[id] = impl;
47
+ if (meta) {
48
+ try { Object.defineProperty(impl, '__mates_hmr_file', { value: normalizeModuleId(meta.file), configurable: true }); } catch (e) {}
49
+ try { Object.defineProperty(impl, '__mates_hmr_export', { value: meta.exportName, configurable: true }); } catch (e) {}
50
+ }
51
+ },
52
+ updateModule: function (path, mod) {
53
+ var file = normalizeModuleId(path);
54
+ var records = [];
55
+ Object.keys(mod || {}).forEach(function (name) {
56
+ var value = mod[name];
57
+ if (typeof value !== 'function') return;
58
+ var id = file + '::' + name;
59
+ try { Object.defineProperty(value, '__mates_hmr_id', { value: id, configurable: true }); } catch (e) {}
60
+ try { Object.defineProperty(value, '__mates_hmr_file', { value: file, configurable: true }); } catch (e) {}
61
+ try { Object.defineProperty(value, '__mates_hmr_export', { value: name, configurable: true }); } catch (e) {}
62
+ components[id] = value;
63
+ records.push({ id: id, file: file, exportName: name });
64
+ });
65
+ if (records.length) refreshComponents(records);
66
+ }
67
+ };
68
+
69
+ function refreshComponents(records) {
70
+ var byId = Object.create(null);
71
+ var byFileExport = Object.create(null);
72
+ records.forEach(function (record) {
73
+ byId[record.id] = record;
74
+ byFileExport[record.file + '::' + record.exportName] = record;
75
+ });
76
+ var refreshed = 0;
77
+ document.querySelectorAll('x-view').forEach(function (node) {
78
+ var view = node.view;
79
+ if (typeof view !== 'function') return;
80
+ var record = byId[view.__mates_hmr_id];
81
+ if (!record && view.__mates_hmr_file && view.__mates_hmr_export) {
82
+ record = byFileExport[normalizeModuleId(view.__mates_hmr_file) + '::' + view.__mates_hmr_export];
83
+ }
84
+ if (!record) return;
85
+ var next = components[record.id];
86
+ if (!next) return;
87
+ if (typeof node._hotRefresh === 'function') {
88
+ node._hotRefresh();
89
+ } else {
90
+ // Fallback for apps still running an older built mates package:
91
+ // swap the x-view's view function directly. The setter schedules a
92
+ // render and performs existing view-change cleanup.
93
+ try { node.oldView = undefined; } catch (e) {}
94
+ node.view = next;
95
+ }
96
+ refreshed++;
97
+ });
98
+ console.info('[mates] js hot-update', records.map(function (r) { return r.id; }), 'refreshed:', refreshed);
99
+ if (refreshed === 0) location.reload();
100
+ }
101
+
102
+ function normalizeModuleId(url) {
103
+ try {
104
+ var u = new URL(url, location.href);
105
+ return u.pathname;
106
+ } catch (e) {
107
+ return url.split('?')[0];
108
+ }
109
+ }
110
+
111
+ function swapCss(href, token) {
112
+ var url = href + (href.indexOf("?") >= 0 ? "&" : "?") + "t=" + token;
113
+ var links = document.querySelectorAll(
114
+ 'link[data-mates-css], link[rel="stylesheet"]'
115
+ );
116
+ var swapped = false;
117
+ for (var i = 0; i < links.length; i++) {
118
+ var old = links[i];
119
+ var current = old.getAttribute("href") || "";
120
+ if (current.split("?")[0] !== href.split("?")[0]) continue;
121
+ var next = old.cloneNode(false);
122
+ next.setAttribute("href", url);
123
+ next.onload = next.onerror = function () {
124
+ if (old.parentNode) old.parentNode.removeChild(old);
125
+ };
126
+ old.parentNode.insertBefore(next, old.nextSibling);
127
+ swapped = true;
128
+ }
129
+ if (!swapped) location.reload();
130
+ }
131
+
132
+ function handle(data) {
133
+ var msg;
134
+ try {
135
+ msg = JSON.parse(data);
136
+ } catch (e) {
137
+ msg = { t: data, kind: "reload" };
138
+ }
139
+ if (lastGen === null) {
140
+ lastGen = msg.t;
141
+ return;
142
+ }
143
+ if (msg.t === lastGen) return;
144
+ lastGen = msg.t;
145
+ if (msg.kind === "css" && msg.css) {
146
+ console.info("[mates] css link hot-update");
147
+ swapCss(msg.css, msg.t);
148
+ return;
149
+ }
150
+ if (msg.kind === "js" && msg.path) {
151
+ var id = normalizeModuleId(msg.path);
152
+ var cb = accepted[id];
153
+ if (!cb) {
154
+ location.reload();
155
+ return;
156
+ }
157
+ import(msg.path + (msg.path.indexOf('?') >= 0 ? '&' : '?') + 't=' + msg.t)
158
+ .then(function (mod) { cb(mod); })
159
+ .catch(function () { location.reload(); });
160
+ return;
161
+ }
162
+ location.reload();
163
+ }
164
+
165
+ function connect() {
166
+ var es = new EventSource(ENDPOINT);
167
+ es.onmessage = function (e) {
168
+ handle(e.data);
169
+ };
170
+ es.onerror = function () {
171
+ es.close();
172
+ setTimeout(connect, 500);
173
+ };
174
+ }
175
+ connect();
176
+ })();`;
177
+ const DEFAULT_INDEX_HTML = `<!doctype html>
178
+ <html lang="en">
179
+ <head>
180
+ <meta charset="UTF-8" />
181
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
182
+ <!-- mates:css -->
183
+ </head>
184
+ <body>
185
+ <div id="app"><!-- mates:ssr --></div>
186
+ <!-- mates:scripts -->
187
+ </body>
188
+ </html>
189
+ `;
190
+ export function buildShell({ projectRoot, bodyHtml, dev = false, clientEntry, cssUrl, ssrStyles, importMap = null, }) {
191
+ const template = readIndexHtml(projectRoot);
192
+ const cssHtml = cssUrl
193
+ ? `<link rel="stylesheet"${dev ? " data-mates-css" : ""} href="${_escapeAttr(cssUrl)}">`
194
+ : "";
195
+ // CSS-in-JS styles collected during SSR — inject into <head>
196
+ const ssrStylesHtml = ssrStyles
197
+ ? `<style id="mates-ssr-styles">${_escapeAttr(ssrStyles)}</style>`
198
+ : "";
199
+ const scripts = [];
200
+ if (dev && importMap && Object.keys(importMap).length > 0) {
201
+ scripts.push(`<script type="importmap">${JSON.stringify({ imports: importMap })}</script>`);
202
+ }
203
+ if (dev) {
204
+ scripts.push(`<script>${HMR_CLIENT}</script>`);
205
+ scripts.push(`<script type="module" src="${CRASH_OVERLAY_MODULE}"></script>`);
206
+ }
207
+ scripts.push(`<script type="module" src="${_escapeAttr(clientEntry)}"></script>`);
208
+ let html = template;
209
+ html = _injectOrFallback(html, MARKER_CSS, cssHtml + "\n " + ssrStylesHtml, /<\/head>/i);
210
+ html = _injectSsr(html, bodyHtml);
211
+ html = _injectOrFallback(html, MARKER_SCRIPTS, scripts.join("\n "), /<\/body>/i);
212
+ return html;
213
+ }
214
+ export function readIndexHtml(projectRoot) {
215
+ const indexPath = path.join(projectRoot, "client", "index.html");
216
+ return fs.existsSync(indexPath)
217
+ ? fs.readFileSync(indexPath, "utf-8")
218
+ : DEFAULT_INDEX_HTML;
219
+ }
220
+ function _injectOrFallback(html, marker, content, fallbackBefore) {
221
+ if (html.includes(marker))
222
+ return html.replace(marker, content);
223
+ if (!content)
224
+ return html;
225
+ return html.replace(fallbackBefore, `${content}\n$&`);
226
+ }
227
+ function _injectSsr(html, bodyHtml) {
228
+ if (html.includes(MARKER_SSR))
229
+ return html.replace(MARKER_SSR, bodyHtml);
230
+ // Marker-free fallback: support a normal <div id="app"></div> shell.
231
+ // This keeps index.html ergonomic while still allowing explicit markers.
232
+ const appDivRe = /<div\s+([^>]*\bid=["']app["'][^>]*)>[\s\S]*?<\/div>/i;
233
+ if (appDivRe.test(html)) {
234
+ return html.replace(appDivRe, `<div $1>${bodyHtml}</div>`);
235
+ }
236
+ // Last resort: inject at top of body.
237
+ return html.replace(/<body([^>]*)>/i, `<body$1>\n<div id="app">${bodyHtml}</div>`);
238
+ }
239
+ function _escapeAttr(str) {
240
+ return str
241
+ .replace(/&/g, "&amp;")
242
+ .replace(/"/g, "&quot;")
243
+ .replace(/'/g, "&#39;");
244
+ }
245
+ //# sourceMappingURL=head.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"head.js","sourceRoot":"","sources":["../src/head.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,eAAe,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c,EAAE,GAAG,OAAO,MAAM,CAAC,CAAC;AACxD,CAAC;AAED,SAAS,UAAU,CAAC,IAAY,EAAE,QAAgB;IAChD,IAAI,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC;QAAE,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAEzE,qEAAqE;IACrE,yEAAyE;IACzE,MAAM,QAAQ,GAAG,sDAAsD,CAAC;IACxE,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,WAAW,QAAQ,QAAQ,CAAC,CAAC;IAC7D,CAAC;IAED,sCAAsC;IACtC,OAAO,IAAI,CAAC,OAAO,CACjB,gBAAgB,EAChB,2BAA2B,QAAQ,QAAQ,CAC5C,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,GAAW;IAC9B,OAAO,GAAG;SACP,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;SACvB,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * mates-fullstack — public API barrel.
3
+ *
4
+ * Keep this entry intentionally small. App code should import framework-facing
5
+ * primitives from here; build/scanner/server internals live in
6
+ * `mates-fullstack/internal`.
7
+ */
8
+ export { isDev } from "./log.js";
9
+ export { type Context, type CookieOptions, type CookieHelper, parseCookieHeader, buildSetCookieHeader, } from "./ctx.js";
10
+ export { ServerError, AppError, NotFoundError, AuthError, ForbiddenError, ValidationError, RateLimitError, registerErrorClass, serializeError, reconstructError, isMatesError, getErrorStatus, type SerializedError, } from "./errors.js";
11
+ export { Redirect, redirect, isRedirect, serializeRedirect, isMatesRedirect, isExternalUrl, type SerializedRedirect, } from "./redirect.js";
12
+ export { StreamResponse, stream, readSseStream, isStreamResponse, } from "./stream.js";
13
+ export { Download, triggerBrowserDownload, isDownload, buildContentDisposition, } from "./download.js";
14
+ export { onRequest, onResponse, onBeforeRPC, onAfterRPC, type RequestHook, type ResponseHook, type BeforeRPCHook, type AfterRPCHook, type AfterRPCInfo, } from "./middleware.js";
15
+ export { jwt, type JwtPayload, type JwtSignOptions, type JwtVerifyOptions, type JwtInstance, } from "./jwt.js";
16
+ export { matesAuth, auth, hashPassword, verifyPassword, type AuthDuration, type MatesAuthClaims, type MatesAuthContext, type MatesAuthOptions, type AuthLoginOptions, } from "./mates-auth.js";
17
+ export { useArctic, arcticProvider, listArcticProviders, type ArcticBuiltInProvider, type ArcticTokenSet, type ArcticProfile, type ArcticProviderConfig, type ArcticProvidersConfig, type ArcticSuccessHandler, type ArcticUseOptions, type ArcticProviderHandler, type ArcticCustomProvider, type ArcticProfileLoader, } from "./arctic-auth.js";
18
+ export { rateLimit, type RateLimitOptions } from "./rate-limit.js";
19
+ export { useSecurityHeaders, type SecurityHeadersOptions, } from "./security-headers.js";
20
+ export { useCors, type CorsOptions } from "./cors.js";
21
+ export { requestLogger, type RequestLoggerOptions } from "./request-logger.js";
22
+ export { type SocketCtx, onSocketConnect, clearSocketConnectHooks, } from "./socket-router.js";
23
+ export { setServerTimeout } from "./server-timeout.js";
24
+ export { rest, type RestHandler, type RestMethod } from "./rest.js";
25
+ export { useSsoProvider, useSsoClient, type SsoProviderOptions, type SsoClientOptions, } from "./sso.js";
26
+ export { logger, configureLogger, generateRequestId, type Logger, type LogLevel, type LogFormat, type LoggerConfig, } from "./logger.js";
27
+ export { sanitizeBody, sanitizeString, SanitizeError, type SanitizeMode, type SanitizeConfig, } from "./sanitize.js";
28
+ export { validate, validateAll, type ValidatorFn } from "./validate.js";
29
+ export { parseUpload, UploadError, type UploadOptions, type ParsedUpload, } from "./upload.js";
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA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
@@ -0,0 +1,30 @@
1
+ /**
2
+ * mates-fullstack — public API barrel.
3
+ *
4
+ * Keep this entry intentionally small. App code should import framework-facing
5
+ * primitives from here; build/scanner/server internals live in
6
+ * `mates-fullstack/internal`.
7
+ */
8
+ export { isDev } from "./log.js";
9
+ export { parseCookieHeader, buildSetCookieHeader, } from "./ctx.js";
10
+ export { ServerError, AppError, NotFoundError, AuthError, ForbiddenError, ValidationError, RateLimitError, registerErrorClass, serializeError, reconstructError, isMatesError, getErrorStatus, } from "./errors.js";
11
+ export { Redirect, redirect, isRedirect, serializeRedirect, isMatesRedirect, isExternalUrl, } from "./redirect.js";
12
+ export { StreamResponse, stream, readSseStream, isStreamResponse, } from "./stream.js";
13
+ export { Download, triggerBrowserDownload, isDownload, buildContentDisposition, } from "./download.js";
14
+ export { onRequest, onResponse, onBeforeRPC, onAfterRPC, } from "./middleware.js";
15
+ export { jwt, } from "./jwt.js";
16
+ export { matesAuth, auth, hashPassword, verifyPassword, } from "./mates-auth.js";
17
+ export { useArctic, arcticProvider, listArcticProviders, } from "./arctic-auth.js";
18
+ export { rateLimit } from "./rate-limit.js";
19
+ export { useSecurityHeaders, } from "./security-headers.js";
20
+ export { useCors } from "./cors.js";
21
+ export { requestLogger } from "./request-logger.js";
22
+ export { onSocketConnect, clearSocketConnectHooks, } from "./socket-router.js";
23
+ export { setServerTimeout } from "./server-timeout.js";
24
+ export { rest } from "./rest.js";
25
+ export { useSsoProvider, useSsoClient, } from "./sso.js";
26
+ export { logger, configureLogger, generateRequestId, } from "./logger.js";
27
+ export { sanitizeBody, sanitizeString, SanitizeError, } from "./sanitize.js";
28
+ export { validate, validateAll } from "./validate.js";
29
+ export { parseUpload, UploadError, } from "./upload.js";
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CA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Gb,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,MAAM,EACN,eAAe,EACf,iBAAiB,GAKlB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,YAAY,EACZ,cAAc,EACd,aAAa,GAGd,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAoB,MAAM,eAAe,CAAC;AAExE,OAAO,EACL,WAAW,EACX,WAAW,GAGZ,MAAM,aAAa,CAAC"}
@@ -0,0 +1,16 @@
1
+ export declare const INTERNAL_SRC_PREFIX = "/_src";
2
+ export declare const INTERNAL_PKG_PREFIX = "/_pkg";
3
+ export declare const INTERNAL_ASSET_PREFIX = "/_asset";
4
+ export declare const INTERNAL_MATES_PREFIX = "/_mates";
5
+ export declare const RELOAD_ENDPOINT = "/__mates_reload";
6
+ export declare const RUNTIME_RELOAD_ENDPOINT = "/__mates_runtime_reload";
7
+ export declare const BROWSER_LOG_ENDPOINT = "/__mates_log";
8
+ export declare const RPC_CLIENT_MODULE = "/_mates/rpc-client.js";
9
+ export declare const ERRORS_MODULE = "/_mates/errors.js";
10
+ export declare const STREAM_MODULE = "/_mates/stream.js";
11
+ export declare const DOWNLOAD_MODULE = "/_mates/download.js";
12
+ export declare const NAV_MODULE = "/_mates/nav.js";
13
+ export declare const STACK_MAP_MODULE = "/_mates/stack-map.js";
14
+ export declare const CRASH_OVERLAY_MODULE = "/_mates/crash-overlay.js";
15
+ export declare const EMPTY_STYLE_MODULE = "/_mates/empty-style.js";
16
+ //# sourceMappingURL=internal-prefixes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal-prefixes.d.ts","sourceRoot":"","sources":["../src/internal-prefixes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAC3C,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAC3C,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAC/C,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAE/C,eAAO,MAAM,eAAe,oBAAoB,CAAC;AACjD,eAAO,MAAM,uBAAuB,4BAA4B,CAAC;AACjE,eAAO,MAAM,oBAAoB,iBAAiB,CAAC;AAEnD,eAAO,MAAM,iBAAiB,0BAA2C,CAAC;AAC1E,eAAO,MAAM,aAAa,sBAAuC,CAAC;AAClE,eAAO,MAAM,aAAa,sBAAuC,CAAC;AAClE,eAAO,MAAM,eAAe,wBAAyC,CAAC;AACtE,eAAO,MAAM,UAAU,mBAAoC,CAAC;AAC5D,eAAO,MAAM,gBAAgB,yBAA0C,CAAC;AACxE,eAAO,MAAM,oBAAoB,6BAA8C,CAAC;AAChF,eAAO,MAAM,kBAAkB,2BAA4C,CAAC"}
@@ -0,0 +1,16 @@
1
+ export const INTERNAL_SRC_PREFIX = "/_src";
2
+ export const INTERNAL_PKG_PREFIX = "/_pkg";
3
+ export const INTERNAL_ASSET_PREFIX = "/_asset";
4
+ export const INTERNAL_MATES_PREFIX = "/_mates";
5
+ export const RELOAD_ENDPOINT = "/__mates_reload";
6
+ export const RUNTIME_RELOAD_ENDPOINT = "/__mates_runtime_reload";
7
+ export const BROWSER_LOG_ENDPOINT = "/__mates_log";
8
+ export const RPC_CLIENT_MODULE = `${INTERNAL_MATES_PREFIX}/rpc-client.js`;
9
+ export const ERRORS_MODULE = `${INTERNAL_MATES_PREFIX}/errors.js`;
10
+ export const STREAM_MODULE = `${INTERNAL_MATES_PREFIX}/stream.js`;
11
+ export const DOWNLOAD_MODULE = `${INTERNAL_MATES_PREFIX}/download.js`;
12
+ export const NAV_MODULE = `${INTERNAL_MATES_PREFIX}/nav.js`;
13
+ export const STACK_MAP_MODULE = `${INTERNAL_MATES_PREFIX}/stack-map.js`;
14
+ export const CRASH_OVERLAY_MODULE = `${INTERNAL_MATES_PREFIX}/crash-overlay.js`;
15
+ export const EMPTY_STYLE_MODULE = `${INTERNAL_MATES_PREFIX}/empty-style.js`;
16
+ //# sourceMappingURL=internal-prefixes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal-prefixes.js","sourceRoot":"","sources":["../src/internal-prefixes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG,OAAO,CAAC;AAC3C,MAAM,CAAC,MAAM,mBAAmB,GAAG,OAAO,CAAC;AAC3C,MAAM,CAAC,MAAM,qBAAqB,GAAG,SAAS,CAAC;AAC/C,MAAM,CAAC,MAAM,qBAAqB,GAAG,SAAS,CAAC;AAE/C,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AACjD,MAAM,CAAC,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;AACjE,MAAM,CAAC,MAAM,oBAAoB,GAAG,cAAc,CAAC;AAEnD,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,qBAAqB,gBAAgB,CAAC;AAC1E,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,qBAAqB,YAAY,CAAC;AAClE,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,qBAAqB,YAAY,CAAC;AAClE,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,qBAAqB,cAAc,CAAC;AACtE,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,qBAAqB,SAAS,CAAC;AAC5D,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,qBAAqB,eAAe,CAAC;AACxE,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,qBAAqB,mBAAmB,CAAC;AAChF,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,qBAAqB,iBAAiB,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * mates-fullstack/internal — unstable framework internals.
3
+ *
4
+ * These exports are for the CLI, tests, and advanced tooling. They are not part
5
+ * of the stable application author API and may change between releases.
6
+ */
7
+ export * from "./server-public.js";
8
+ export { resolveProjectPaths, resolveProductionRuntimePaths, findProjectRoot, findMatesPath, warnMissingPaths, formatPaths, isPathInside, type ResolvedPaths, } from "./project-resolver.js";
9
+ export { loadEnv, getPublicEnv, getBundlerDefines, parseEnvFile, } from "./env-loader.js";
10
+ export { scanRpcFunctions, lookupRpcFn, listRpcFunctions, rpcRegistrySize, clearRpcRegistry, watchRpcFunctions, deriveRpcUrl, type RpcEntry, } from "./rpc-registry.js";
11
+ export { runRpcRequest, parseRpcBody, DEFAULT_TIMEOUT_MS, configureRpcRunner, type RpcRunnerConfig, } from "./rpc-runner.js";
12
+ export { importMainFile, reloadMainFile, watchMainFile, } from "./main-runner.js";
13
+ export { startServer, notifyReload, getActiveRequests, getClientIp, buildDevImportMap, type ServerOptions, type HmrUpdate, } from "./server.js";
14
+ export { scanSocketHandlers, matchSocketRoute, listSocketRoutes, clearSocketRoutes, watchSocketRoutes, attachSocketServer, deriveSocketPattern, type SocketServerOptions, } from "./socket-router.js";
15
+ export { getSSRContext } from "./ssr-context.js";
16
+ export { bootRenderer, renderApp, renderToString, shutdownRenderer, getSSRStyles, DEFAULT_SSR_TIMEOUT_MS, type ComponentFn, type RenderOptions, type RenderResult, } from "./renderer.js";
17
+ export { scanRoutes, matchRoute, watchRoutes, type RouteEntry, type MatchResult, } from "./router.js";
18
+ export { buildShell, type BuildShellOptions } from "./head.js";
19
+ export { buildProduction, buildServerRuntime, buildStyles, copyPublicDir, contentHash, generateRpcStub, extractExportNames, type BuildOptions, type BuildResult, type ServerRuntimeBuildResult, } from "./build-prod.js";
20
+ export { transformFile, isVirtualFile, serveVirtualFile, extractRpcStub, buildDefines, clearTransformCache, } from "./build-esbuild.js";
21
+ export { generateDocs, clearDocsCache, isTsMorphAvailable, type RouteDoc, type TypeShape, type FieldDoc, } from "./docs-generator.js";
22
+ export { buildDocsHtml, serveDocsPage } from "./docs-page.js";
23
+ export { createDevWatcher, getDevWatchPaths, shouldIgnoreWatchPath, classifyDevChange, type DevWatchAction, type DevWatchEvent, type DevWatcherOptions, } from "./dev-watcher.js";
24
+ export { logRequest, logResponse } from "./logger.js";
25
+ //# sourceMappingURL=internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EACL,mBAAmB,EACnB,6BAA6B,EAC7B,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,YAAY,EACZ,KAAK,aAAa,GACnB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,OAAO,EACP,YAAY,EACZ,iBAAiB,EACjB,YAAY,GACb,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,KAAK,QAAQ,GACd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,aAAa,EACb,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,eAAe,GACrB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,cAAc,EACd,cAAc,EACd,aAAa,GACd,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,KAAK,aAAa,EAClB,KAAK,SAAS,GACf,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,mBAAmB,GACzB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EACL,YAAY,EACZ,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,sBAAsB,EACtB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,YAAY,GAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,UAAU,EACV,UAAU,EACV,WAAW,EACX,KAAK,UAAU,EACf,KAAK,WAAW,GACjB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAE/D,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,wBAAwB,GAC9B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,QAAQ,GACd,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,iBAAiB,GACvB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * mates-fullstack/internal — unstable framework internals.
3
+ *
4
+ * These exports are for the CLI, tests, and advanced tooling. They are not part
5
+ * of the stable application author API and may change between releases.
6
+ */
7
+ export * from "./server-public.js";
8
+ export { resolveProjectPaths, resolveProductionRuntimePaths, findProjectRoot, findMatesPath, warnMissingPaths, formatPaths, isPathInside, } from "./project-resolver.js";
9
+ export { loadEnv, getPublicEnv, getBundlerDefines, parseEnvFile, } from "./env-loader.js";
10
+ export { scanRpcFunctions, lookupRpcFn, listRpcFunctions, rpcRegistrySize, clearRpcRegistry, watchRpcFunctions, deriveRpcUrl, } from "./rpc-registry.js";
11
+ export { runRpcRequest, parseRpcBody, DEFAULT_TIMEOUT_MS, configureRpcRunner, } from "./rpc-runner.js";
12
+ export { importMainFile, reloadMainFile, watchMainFile, } from "./main-runner.js";
13
+ export { startServer, notifyReload, getActiveRequests, getClientIp, buildDevImportMap, } from "./server.js";
14
+ export { scanSocketHandlers, matchSocketRoute, listSocketRoutes, clearSocketRoutes, watchSocketRoutes, attachSocketServer, deriveSocketPattern, } from "./socket-router.js";
15
+ export { getSSRContext } from "./ssr-context.js";
16
+ export { bootRenderer, renderApp, renderToString, shutdownRenderer, getSSRStyles, DEFAULT_SSR_TIMEOUT_MS, } from "./renderer.js";
17
+ export { scanRoutes, matchRoute, watchRoutes, } from "./router.js";
18
+ export { buildShell } from "./head.js";
19
+ export { buildProduction, buildServerRuntime, buildStyles, copyPublicDir, contentHash, generateRpcStub, extractExportNames, } from "./build-prod.js";
20
+ export { transformFile, isVirtualFile, serveVirtualFile, extractRpcStub, buildDefines, clearTransformCache, } from "./build-esbuild.js";
21
+ export { generateDocs, clearDocsCache, isTsMorphAvailable, } from "./docs-generator.js";
22
+ export { buildDocsHtml, serveDocsPage } from "./docs-page.js";
23
+ export { createDevWatcher, getDevWatchPaths, shouldIgnoreWatchPath, classifyDevChange, } from "./dev-watcher.js";
24
+ export { logRequest, logResponse } from "./logger.js";
25
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EACL,mBAAmB,EACnB,6BAA6B,EAC7B,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,YAAY,GAEb,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,OAAO,EACP,YAAY,EACZ,iBAAiB,EACjB,YAAY,GACb,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,gBAAgB,EAChB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E1B,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
package/dist/jwt.d.ts ADDED
@@ -0,0 +1,166 @@
1
+ /**
2
+ * mates-fullstack — jwt.ts
3
+ *
4
+ * Zero-dependency JWT implementation using Node.js built-in crypto.
5
+ * Supports HS256 (HMAC-SHA256) — the right choice for tokens you
6
+ * both sign and verify yourself.
7
+ *
8
+ * For asymmetric algorithms (RS256, ES256) or third-party JWKS verification
9
+ * (Google, Auth0, GitHub), use the `jose` package instead.
10
+ *
11
+ * Usage in server/main.ts or server/helpers/auth.ts:
12
+ *
13
+ * import { jwt } from "mates-fullstack";
14
+ *
15
+ * const tokens = jwt(process.env.JWT_SECRET!);
16
+ *
17
+ * // Sign
18
+ * const token = await tokens.sign({ sub: "user_123", role: "admin" });
19
+ *
20
+ * // Verify
21
+ * const payload = await tokens.verify(token);
22
+ * if (!payload) throw new AuthError("Invalid token");
23
+ *
24
+ * // Decode without verifying (e.g. to read sub before re-validating)
25
+ * const claims = jwt.decode(token);
26
+ *
27
+ * API:
28
+ * jwt(secret, options?) → bound instance for sign/verify/refresh
29
+ * jwt.decode(token) → decode payload without verifying
30
+ * jwt.isExpired(token) → check expiry without verifying signature
31
+ *
32
+ * Bound instance:
33
+ * .sign(payload, options?) → Promise<string>
34
+ * .verify(token) → Promise<JwtPayload | null>
35
+ * .refresh(token, options?) → Promise<string | null> (rotate with same claims)
36
+ * .decode(token) → JwtPayload | null (no signature check)
37
+ */
38
+ export interface JwtPayload {
39
+ /** Subject — typically the user ID */
40
+ sub?: string;
41
+ /** Issued at (Unix seconds) */
42
+ iat?: number;
43
+ /** Expiry (Unix seconds) */
44
+ exp?: number;
45
+ /** Not before (Unix seconds) */
46
+ nbf?: number;
47
+ /** JWT ID — unique token identifier */
48
+ jti?: string;
49
+ /** Issuer */
50
+ iss?: string;
51
+ /** Audience */
52
+ aud?: string | string[];
53
+ /** Any custom claims */
54
+ [key: string]: unknown;
55
+ }
56
+ export interface JwtSignOptions {
57
+ /**
58
+ * Token lifetime. Accepts seconds (number) or a duration string.
59
+ * Supported units: s, m, h, d, w
60
+ * Examples: 3600, "1h", "7d", "15m"
61
+ * Pass `false` to issue a token with no expiry (`exp` claim is omitted).
62
+ * @default "1h"
63
+ */
64
+ expiresIn?: number | string | false;
65
+ /**
66
+ * Not-before offset. Token is invalid before now + nbf.
67
+ * Same format as expiresIn.
68
+ * @default undefined (no nbf claim)
69
+ */
70
+ notBefore?: number | string;
71
+ /**
72
+ * Issuer claim (iss).
73
+ */
74
+ issuer?: string;
75
+ /**
76
+ * Audience claim (aud).
77
+ */
78
+ audience?: string | string[];
79
+ /**
80
+ * Include a unique jti (JWT ID) claim.
81
+ * Useful for token revocation tracking.
82
+ * @default false
83
+ */
84
+ includeJti?: boolean;
85
+ }
86
+ export interface JwtVerifyOptions {
87
+ /**
88
+ * Expected issuer. If set, tokens with a different iss are rejected.
89
+ */
90
+ issuer?: string;
91
+ /**
92
+ * Expected audience. If set, tokens without this aud are rejected.
93
+ */
94
+ audience?: string;
95
+ /**
96
+ * Clock skew tolerance in seconds.
97
+ * Allows tokens that are slightly expired or slightly not-yet-valid.
98
+ * @default 0
99
+ */
100
+ clockSkew?: number;
101
+ }
102
+ export interface JwtInstance {
103
+ /**
104
+ * Sign a payload and return a JWT string.
105
+ *
106
+ * @example
107
+ * const token = await tokens.sign({ sub: "user_123", role: "admin" });
108
+ * const token = await tokens.sign({ sub: "user_123" }, { expiresIn: "7d" });
109
+ */
110
+ sign(payload: JwtPayload, options?: JwtSignOptions): Promise<string>;
111
+ /**
112
+ * Verify a JWT and return its payload.
113
+ * Returns null if the token is invalid, expired, or tampered.
114
+ * Never throws.
115
+ *
116
+ * @example
117
+ * const payload = await tokens.verify(token);
118
+ * if (!payload) throw new AuthError("Invalid token");
119
+ * console.log(payload.sub);
120
+ */
121
+ verify(token: string, options?: JwtVerifyOptions): Promise<JwtPayload | null>;
122
+ /**
123
+ * Rotate a token — verify it, then issue a new one with the same claims
124
+ * but a fresh iat and exp. Returns null if the original token is invalid.
125
+ *
126
+ * @example
127
+ * const newToken = await tokens.refresh(oldToken, { expiresIn: "7d" });
128
+ * if (!newToken) throw new AuthError("Cannot refresh invalid token");
129
+ */
130
+ refresh(token: string, options?: JwtSignOptions & JwtVerifyOptions): Promise<string | null>;
131
+ /**
132
+ * Decode a JWT without verifying the signature.
133
+ * Useful for reading claims before full verification,
134
+ * or for logging/debugging purposes.
135
+ * Returns null if the token is malformed.
136
+ */
137
+ decode(token: string): JwtPayload | null;
138
+ }
139
+ /**
140
+ * Decode a JWT without verifying the signature.
141
+ * Safe to call on untrusted tokens — never throws.
142
+ */
143
+ declare function decodeToken(token: string): JwtPayload | null;
144
+ /**
145
+ * Check if a token is expired without verifying the signature.
146
+ * Returns true if expired or malformed.
147
+ */
148
+ declare function isTokenExpired(token: string, clockSkewSeconds?: number): boolean;
149
+ /**
150
+ * Create a bound JWT instance for signing and verifying tokens.
151
+ *
152
+ * @param secret - The secret key string. Use a long random string in production.
153
+ * Minimum 32 characters recommended.
154
+ * @param defaults - Default options applied to all sign() calls.
155
+ *
156
+ * @example
157
+ * const tokens = jwt(process.env.JWT_SECRET!);
158
+ * const tokens = jwt(process.env.JWT_SECRET!, { expiresIn: "7d" });
159
+ */
160
+ export declare function jwt(secret: string, defaults?: JwtSignOptions): JwtInstance;
161
+ export declare namespace jwt {
162
+ var decode: typeof decodeToken;
163
+ var isExpired: typeof isTokenExpired;
164
+ }
165
+ export {};
166
+ //# sourceMappingURL=jwt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt.d.ts","sourceRoot":"","sources":["../src/jwt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAMH,MAAM,WAAW,UAAU;IACzB,sCAAsC;IACtC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,+BAA+B;IAC/B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4BAA4B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