@weft-framework/server 0.0.0-stage → 0.0.3

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 (175) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -2
  3. package/dist/account.d.ts +124 -0
  4. package/dist/account.js +344 -0
  5. package/dist/action.d.ts +43 -0
  6. package/dist/action.js +135 -0
  7. package/dist/admin.d.ts +99 -0
  8. package/dist/admin.js +431 -0
  9. package/dist/api.d.ts +21 -0
  10. package/dist/api.js +72 -0
  11. package/dist/app.d.ts +202 -0
  12. package/dist/app.js +3692 -0
  13. package/dist/assets.d.ts +4 -0
  14. package/dist/assets.js +91 -0
  15. package/dist/auth.d.ts +150 -0
  16. package/dist/auth.js +215 -0
  17. package/dist/backup.d.ts +46 -0
  18. package/dist/backup.js +345 -0
  19. package/dist/build.d.ts +33 -0
  20. package/dist/build.js +274 -0
  21. package/dist/bun.d.ts +30 -0
  22. package/dist/bun.js +53 -0
  23. package/dist/calendar.d.ts +161 -0
  24. package/dist/calendar.js +690 -0
  25. package/dist/compiler.d.ts +13 -0
  26. package/dist/compiler.js +58 -0
  27. package/dist/compress.d.ts +6 -0
  28. package/dist/compress.js +78 -0
  29. package/dist/config.d.ts +26 -0
  30. package/dist/config.js +317 -0
  31. package/dist/context.d.ts +9 -0
  32. package/dist/context.js +1 -0
  33. package/dist/contract.d.ts +18 -0
  34. package/dist/contract.js +171 -0
  35. package/dist/datamap.d.ts +24 -0
  36. package/dist/datamap.js +365 -0
  37. package/dist/db-backup.d.ts +27 -0
  38. package/dist/db-backup.js +115 -0
  39. package/dist/dev-events.d.ts +14 -0
  40. package/dist/dev-events.js +135 -0
  41. package/dist/dev.d.ts +1 -0
  42. package/dist/dev.js +240 -0
  43. package/dist/devtools-client.d.ts +1 -0
  44. package/dist/devtools-client.js +362 -0
  45. package/dist/devtools.d.ts +87 -0
  46. package/dist/devtools.js +68 -0
  47. package/dist/edge.d.ts +3 -0
  48. package/dist/edge.js +7 -0
  49. package/dist/email-signin.d.ts +92 -0
  50. package/dist/email-signin.js +259 -0
  51. package/dist/env.d.ts +1 -0
  52. package/dist/env.js +15 -0
  53. package/dist/explain.d.ts +12 -0
  54. package/dist/explain.js +217 -0
  55. package/dist/files.d.ts +6 -0
  56. package/dist/files.js +170 -0
  57. package/dist/grants.d.ts +69 -0
  58. package/dist/grants.js +206 -0
  59. package/dist/image/bitmap.d.ts +11 -0
  60. package/dist/image/bitmap.js +172 -0
  61. package/dist/image/jpeg.d.ts +10 -0
  62. package/dist/image/jpeg.js +697 -0
  63. package/dist/image/png.d.ts +8 -0
  64. package/dist/image/png.js +282 -0
  65. package/dist/image/transform.d.ts +20 -0
  66. package/dist/image/transform.js +52 -0
  67. package/dist/image/worker.d.ts +1 -0
  68. package/dist/image/worker.js +11 -0
  69. package/dist/images.d.ts +39 -0
  70. package/dist/images.js +283 -0
  71. package/dist/index.d.ts +64 -0
  72. package/dist/index.js +31 -0
  73. package/dist/inspect-hub.d.ts +42 -0
  74. package/dist/inspect-hub.js +14 -0
  75. package/dist/inspector.d.ts +51 -0
  76. package/dist/inspector.js +193 -0
  77. package/dist/job-admin.d.ts +55 -0
  78. package/dist/job-admin.js +89 -0
  79. package/dist/jobs.d.ts +222 -0
  80. package/dist/jobs.js +789 -0
  81. package/dist/live.d.ts +72 -0
  82. package/dist/live.js +481 -0
  83. package/dist/load-config.d.ts +2 -0
  84. package/dist/load-config.js +41 -0
  85. package/dist/log.d.ts +20 -0
  86. package/dist/log.js +143 -0
  87. package/dist/mail.d.ts +189 -0
  88. package/dist/mail.js +999 -0
  89. package/dist/media.d.ts +129 -0
  90. package/dist/media.js +470 -0
  91. package/dist/meta.d.ts +54 -0
  92. package/dist/meta.js +146 -0
  93. package/dist/middleware.d.ts +20 -0
  94. package/dist/middleware.js +101 -0
  95. package/dist/migrate.d.ts +12 -0
  96. package/dist/migrate.js +88 -0
  97. package/dist/node.d.ts +26 -0
  98. package/dist/node.js +96 -0
  99. package/dist/notice.d.ts +21 -0
  100. package/dist/notice.js +48 -0
  101. package/dist/npm.d.ts +16 -0
  102. package/dist/npm.js +347 -0
  103. package/dist/oauth.d.ts +76 -0
  104. package/dist/oauth.js +408 -0
  105. package/dist/otel.d.ts +57 -0
  106. package/dist/otel.js +293 -0
  107. package/dist/passkey.d.ts +99 -0
  108. package/dist/passkey.js +572 -0
  109. package/dist/password.d.ts +8 -0
  110. package/dist/password.js +65 -0
  111. package/dist/pdf.d.ts +46 -0
  112. package/dist/pdf.js +332 -0
  113. package/dist/personal-data.d.ts +22 -0
  114. package/dist/personal-data.js +148 -0
  115. package/dist/pointers.d.ts +9 -0
  116. package/dist/pointers.js +148 -0
  117. package/dist/postcss.d.ts +3 -0
  118. package/dist/postcss.js +89 -0
  119. package/dist/presence.d.ts +27 -0
  120. package/dist/presence.js +161 -0
  121. package/dist/preview.d.ts +25 -0
  122. package/dist/preview.js +353 -0
  123. package/dist/production.d.ts +16 -0
  124. package/dist/production.js +119 -0
  125. package/dist/project.d.ts +23 -0
  126. package/dist/project.js +536 -0
  127. package/dist/regions.d.ts +47 -0
  128. package/dist/regions.js +511 -0
  129. package/dist/replay.d.ts +44 -0
  130. package/dist/replay.js +259 -0
  131. package/dist/router.d.ts +29 -0
  132. package/dist/router.js +146 -0
  133. package/dist/rules-diff.d.ts +18 -0
  134. package/dist/rules-diff.js +165 -0
  135. package/dist/rules-test.d.ts +17 -0
  136. package/dist/rules-test.js +108 -0
  137. package/dist/saml.d.ts +160 -0
  138. package/dist/saml.js +959 -0
  139. package/dist/seal.d.ts +35 -0
  140. package/dist/seal.js +107 -0
  141. package/dist/secret.d.ts +14 -0
  142. package/dist/secret.js +110 -0
  143. package/dist/security.d.ts +53 -0
  144. package/dist/security.js +250 -0
  145. package/dist/seed.d.ts +16 -0
  146. package/dist/seed.js +94 -0
  147. package/dist/seo.d.ts +42 -0
  148. package/dist/seo.js +175 -0
  149. package/dist/settings.d.ts +79 -0
  150. package/dist/settings.js +212 -0
  151. package/dist/shared.d.ts +15 -0
  152. package/dist/shared.js +283 -0
  153. package/dist/shell.d.ts +12 -0
  154. package/dist/shell.js +118 -0
  155. package/dist/storage.d.ts +13 -0
  156. package/dist/storage.js +55 -0
  157. package/dist/support.d.ts +83 -0
  158. package/dist/support.js +236 -0
  159. package/dist/sync.d.ts +35 -0
  160. package/dist/sync.js +167 -0
  161. package/dist/tailwind.d.ts +14 -0
  162. package/dist/tailwind.js +117 -0
  163. package/dist/two-factor.d.ts +103 -0
  164. package/dist/two-factor.js +435 -0
  165. package/dist/uploads.d.ts +185 -0
  166. package/dist/uploads.js +991 -0
  167. package/dist/webhooks.d.ts +169 -0
  168. package/dist/webhooks.js +758 -0
  169. package/dist/webpush.d.ts +97 -0
  170. package/dist/webpush.js +372 -0
  171. package/dist/wizard.d.ts +141 -0
  172. package/dist/wizard.js +410 -0
  173. package/dist/workflows.d.ts +134 -0
  174. package/dist/workflows.js +511 -0
  175. package/package.json +186 -4
package/dist/npm.js ADDED
@@ -0,0 +1,347 @@
1
+ import { readFileSync, statSync } from "node:fs";
2
+ import { builtinModules, stripTypeScriptTypes } from "node:module";
3
+ import { dirname, extname, join, relative, resolve, sep } from "node:path";
4
+ export const NPM_PREFIX = "/_weft/npm/";
5
+ export const LOCAL_PREFIX = "/_weft/local/";
6
+ export class NpmError extends Error {
7
+ }
8
+ const CONDITIONS = ["browser", "import", "module", "default"];
9
+ const EXTENSIONS = ["", ".js", ".mjs", ".cjs", ".json", "/index.js", "/index.mjs", "/index.cjs", "/index.json"];
10
+ const LOCAL_EXTENSIONS = ["", ".ts", ".js", ".mjs", "/index.ts", "/index.js"];
11
+ const BUILTINS = new Set(builtinModules);
12
+ const SPECIFIER = /(\bfrom\s*|\bimport\s*\(?\s*)(["'])([^"'\n]+)\2/g;
13
+ const REQUIRE = /\brequire\s*\(\s*(["'])([^"'\n]+)\1\s*\)/g;
14
+ const ESM_SYNTAX = /(^|[\n;])\s*(import\b\s*[\w*{"'$]|export\b\s*[\w*{])/;
15
+ const NAMED_EXPORT = /\bexports\.([A-Za-z_$][\w$]*)\s*=|Object\.defineProperty\(\s*(?:module\.)?exports\s*,\s*["']([A-Za-z_$][\w$]*)["']/g;
16
+ const REEXPORT = /\bmodule\.exports\s*=\s*require\s*\(\s*(["'])([^"'\n]+)\1\s*\)/g;
17
+ const RESERVED = new Set("default break case catch class const continue debugger delete do else enum export extends false finally for function if import in instanceof new null return super switch this throw true try typeof var void while with yield let static implements interface package private protected public await __weftCjs".split(" "));
18
+ const isBare = (s) => !/^(\.{0,2}\/|[a-z][a-z0-9+.-]*:)/i.test(s) || s.startsWith("node:");
19
+ function splitSpec(spec) {
20
+ const parts = spec.split("/");
21
+ const n = spec.startsWith("@") ? 2 : 1;
22
+ const name = parts.slice(0, n).join("/");
23
+ const rest = parts.slice(n).join("/");
24
+ return [name, rest === "" ? "." : `./${rest}`];
25
+ }
26
+ function isFile(p) {
27
+ try {
28
+ return statSync(p).isFile();
29
+ }
30
+ catch {
31
+ return false;
32
+ }
33
+ }
34
+ function probe(base, exts) {
35
+ for (const e of exts) {
36
+ if (isFile(base + e))
37
+ return base + e;
38
+ }
39
+ return null;
40
+ }
41
+ const pkgCache = new Map();
42
+ function readPkg(dir) {
43
+ if (pkgCache.has(dir))
44
+ return pkgCache.get(dir);
45
+ let pkg = null;
46
+ const file = join(dir, "package.json");
47
+ if (isFile(file)) {
48
+ try {
49
+ const json = JSON.parse(readFileSync(file, "utf8"));
50
+ pkg = { dir, name: String(json.name ?? ""), version: String(json.version ?? "0.0.0"), json };
51
+ }
52
+ catch {
53
+ pkg = null;
54
+ }
55
+ }
56
+ pkgCache.set(dir, pkg);
57
+ return pkg;
58
+ }
59
+ function findPackage(name, from) {
60
+ let dir = from;
61
+ for (;;) {
62
+ const cand = join(dir, "node_modules", name);
63
+ const pkg = readPkg(cand);
64
+ if (pkg)
65
+ return { ...pkg, name: pkg.name || name };
66
+ const up = dirname(dir);
67
+ if (up === dir)
68
+ return null;
69
+ dir = up;
70
+ }
71
+ }
72
+ function ownerOf(file) {
73
+ let dir = dirname(file);
74
+ for (;;) {
75
+ const pkg = readPkg(dir);
76
+ if (pkg && pkg.name)
77
+ return pkg;
78
+ const up = dirname(dir);
79
+ if (up === dir)
80
+ return null;
81
+ dir = up;
82
+ }
83
+ }
84
+ function exportTarget(target, star) {
85
+ if (typeof target === "string") {
86
+ return star === null ? target : target.split("*").join(star);
87
+ }
88
+ if (Array.isArray(target)) {
89
+ for (const t of target) {
90
+ const r = exportTarget(t, star);
91
+ if (r)
92
+ return r;
93
+ }
94
+ return undefined;
95
+ }
96
+ if (target === null)
97
+ return null;
98
+ if (typeof target === "object") {
99
+ for (const [cond, value] of Object.entries(target)) {
100
+ if (CONDITIONS.includes(cond)) {
101
+ const r = exportTarget(value, star);
102
+ if (r !== undefined)
103
+ return r;
104
+ }
105
+ }
106
+ }
107
+ return undefined;
108
+ }
109
+ function resolveExports(pkg, sub) {
110
+ let exp = pkg.json.exports;
111
+ if (exp === undefined)
112
+ return undefined;
113
+ const subpathMap = typeof exp === "object" && exp !== null && !Array.isArray(exp) && Object.keys(exp).some((k) => k.startsWith("."));
114
+ if (!subpathMap)
115
+ exp = { ".": exp };
116
+ const map = exp;
117
+ if (sub in map)
118
+ return exportTarget(map[sub], null) ?? null;
119
+ let best = null;
120
+ for (const key of Object.keys(map)) {
121
+ const i = key.indexOf("*");
122
+ if (i < 0)
123
+ continue;
124
+ const [pre, post] = [key.slice(0, i), key.slice(i + 1)];
125
+ if (sub.startsWith(pre) && sub.endsWith(post) && sub.length >= key.length - 1) {
126
+ if (!best || pre.length > best[0].length)
127
+ best = [key, sub.slice(pre.length, sub.length - post.length)];
128
+ }
129
+ }
130
+ return best ? (exportTarget(map[best[0]], best[1]) ?? null) : null;
131
+ }
132
+ function browserRemap(pkg, key) {
133
+ const b = pkg.json.browser;
134
+ if (typeof b !== "object" || b === null)
135
+ return undefined;
136
+ const map = b;
137
+ for (const k of [key, key.replace(/^\.\//, ""), `${key}.js`]) {
138
+ const v = map[k];
139
+ if (v === false)
140
+ return false;
141
+ if (typeof v === "string")
142
+ return v;
143
+ }
144
+ return undefined;
145
+ }
146
+ function resolveBare(spec, fromDir, importer) {
147
+ if (BUILTINS.has(spec) || spec.startsWith("node:"))
148
+ return { empty: spec };
149
+ if (importer) {
150
+ const remap = browserRemap(importer, spec);
151
+ if (remap === false)
152
+ return { empty: spec };
153
+ if (typeof remap === "string")
154
+ return resolveFile(join(importer.dir, remap), importer);
155
+ }
156
+ const [name, sub] = splitSpec(spec);
157
+ const pkg = findPackage(name, fromDir);
158
+ if (!pkg)
159
+ return null;
160
+ const viaExports = resolveExports(pkg, sub);
161
+ if (viaExports === null)
162
+ return null;
163
+ if (viaExports !== undefined)
164
+ return resolveFile(join(pkg.dir, viaExports), pkg);
165
+ if (sub !== ".")
166
+ return resolveFile(join(pkg.dir, sub), pkg);
167
+ const browser = typeof pkg.json.browser === "string" ? pkg.json.browser : undefined;
168
+ const entry = [pkg.json.module, browser, pkg.json.main].find((e) => typeof e === "string") ?? "index.js";
169
+ return resolveFile(join(pkg.dir, entry), pkg);
170
+ }
171
+ function resolveFile(path, pkg) {
172
+ const file = probe(path, EXTENSIONS);
173
+ if (!file)
174
+ return null;
175
+ const owner = pkg ?? ownerOf(file);
176
+ if (owner) {
177
+ const rel = "./" + relative(owner.dir, file).split(sep).join("/");
178
+ const remap = browserRemap(owner, rel);
179
+ if (remap === false)
180
+ return { empty: rel };
181
+ if (typeof remap === "string") {
182
+ const again = probe(join(owner.dir, remap), EXTENSIONS);
183
+ if (again)
184
+ return { file: again, pkg: owner };
185
+ }
186
+ }
187
+ return { file, pkg: owner };
188
+ }
189
+ function rewrite(code, map) {
190
+ return code.replace(SPECIFIER, (all, lead, q, spec) => {
191
+ const url = map(spec);
192
+ return url === null ? all : `${lead}${q}${url}${q}`;
193
+ });
194
+ }
195
+ export function browserModules(modules, opts) {
196
+ const mode = opts.mode ?? "development";
197
+ const warn = opts.onWarn ?? (() => { });
198
+ const assets = {};
199
+ const urlOf = new Map();
200
+ const cjsNames = new Map();
201
+ const queue = [];
202
+ const srcRoot = resolve(opts.root);
203
+ const enqueue = (t, local) => {
204
+ if ("empty" in t) {
205
+ const url = `${NPM_PREFIX}_empty/${encodeURIComponent(t.empty)}.js`;
206
+ assets[url] = "export default {};\nexport const __weftCjs = true;\n";
207
+ return url;
208
+ }
209
+ let url = urlOf.get(t.file);
210
+ if (url)
211
+ return url;
212
+ if (local) {
213
+ const rel = relative(srcRoot, t.file).split(sep).join("/");
214
+ if (rel.startsWith(".."))
215
+ throw new NpmError(`client import outside src/: ${t.file}`);
216
+ url = LOCAL_PREFIX + encodeURI(rel.replace(/\.ts$/, ".js"));
217
+ }
218
+ else if (t.pkg) {
219
+ const rel = relative(t.pkg.dir, t.file).split(sep).join("/");
220
+ url = `${NPM_PREFIX}${encodeURI(`${t.pkg.name}@${t.pkg.version}/${rel}`)}`;
221
+ }
222
+ else {
223
+ throw new NpmError(`${t.file} belongs to no package`);
224
+ }
225
+ if (extname(url) === ".json")
226
+ url += ".js";
227
+ if (extname(url) === ".cjs")
228
+ url = url.slice(0, -4) + ".cjs.js";
229
+ urlOf.set(t.file, url);
230
+ queue.push({ file: t.file, pkg: t.pkg, local });
231
+ return url;
232
+ };
233
+ const resolveFrom = (spec, fromDir, importer, local) => {
234
+ if (isBare(spec))
235
+ return resolveBare(spec, fromDir, importer);
236
+ if (spec.startsWith("/") || /^[a-z][a-z0-9+.-]*:/i.test(spec))
237
+ return null;
238
+ const base = resolve(fromDir, spec);
239
+ if (local) {
240
+ const f = probe(base, LOCAL_EXTENSIONS);
241
+ return f ? { file: f, pkg: null } : null;
242
+ }
243
+ return resolveFile(base, importer);
244
+ };
245
+ const out = {};
246
+ for (const [key, { js, dir }] of Object.entries(modules)) {
247
+ out[key] = rewrite(js, (spec) => {
248
+ if (spec.startsWith("/_weft/") || spec === "@weft-framework/runtime")
249
+ return null;
250
+ if (BUILTINS.has(spec) || spec.startsWith("node:")) {
251
+ throw new NpmError(`${key}: \`${spec}\` is a Node built-in and cannot run in the browser`);
252
+ }
253
+ const t = resolveFrom(spec, dir, null, !isBare(spec));
254
+ if (!t) {
255
+ throw new NpmError(isBare(spec)
256
+ ? `${key}: cannot resolve \`${spec}\` for the browser; is it installed (npm install ${splitSpec(spec)[0]})?`
257
+ : `${key}: cannot find \`${spec}\` from ${dir}`);
258
+ }
259
+ return enqueue(t, !isBare(spec));
260
+ });
261
+ }
262
+ while (queue.length > 0) {
263
+ const { file, pkg, local } = queue.shift();
264
+ const url = urlOf.get(file);
265
+ let code = readFileSync(file, "utf8");
266
+ const dir = dirname(file);
267
+ const map = (spec) => {
268
+ if (spec === "@weft-framework/runtime")
269
+ return "/_weft/rt/index.js";
270
+ const t = resolveFrom(spec, dir, pkg, local && !isBare(spec));
271
+ if (!t) {
272
+ warn(`${url}: cannot resolve \`${spec}\` for the browser`);
273
+ return null;
274
+ }
275
+ return enqueue(t, local && !isBare(spec));
276
+ };
277
+ if (file.endsWith(".json")) {
278
+ assets[url] = `export default ${code.trim() || "null"};\nexport const __weftCjs = true;\n`;
279
+ continue;
280
+ }
281
+ if (file.endsWith(".ts")) {
282
+ code = stripTypeScriptTypes(code, { mode: "strip" });
283
+ }
284
+ code = code.replace(/\bprocess\.env\.NODE_ENV\b/g, JSON.stringify(mode));
285
+ if (local || file.endsWith(".mjs") || ESM_SYNTAX.test(code)) {
286
+ assets[url] = rewrite(code, map);
287
+ }
288
+ else {
289
+ assets[url] = wrapCommonJs(code, namedExports(file, cjsNames, 0), map);
290
+ }
291
+ }
292
+ return { modules: out, assets };
293
+ }
294
+ function namedExports(file, cache, depth) {
295
+ const hit = cache.get(file);
296
+ if (hit)
297
+ return hit;
298
+ let code;
299
+ try {
300
+ code = readFileSync(file, "utf8");
301
+ }
302
+ catch {
303
+ return [];
304
+ }
305
+ const names = new Set();
306
+ for (const m of code.matchAll(NAMED_EXPORT))
307
+ names.add(m[1] ?? m[2]);
308
+ if (depth < 4) {
309
+ for (const m of code.matchAll(REEXPORT)) {
310
+ const t = m[2].startsWith(".") ? probe(resolve(dirname(file), m[2]), EXTENSIONS) : null;
311
+ if (t)
312
+ for (const n of namedExports(t, cache, depth + 1))
313
+ names.add(n);
314
+ }
315
+ }
316
+ const out = [...names].filter((n) => !RESERVED.has(n));
317
+ cache.set(file, out);
318
+ return out;
319
+ }
320
+ function wrapCommonJs(code, names, map) {
321
+ const deps = new Map();
322
+ const imports = [];
323
+ for (const m of code.matchAll(REQUIRE)) {
324
+ const spec = m[2];
325
+ if (deps.has(spec))
326
+ continue;
327
+ const url = map(spec);
328
+ if (url === null)
329
+ continue;
330
+ const id = `__weft${deps.size}`;
331
+ deps.set(spec, id);
332
+ imports.push(`import * as ${id} from ${JSON.stringify(url)};\n`);
333
+ }
334
+ const table = [...deps].map(([spec, id]) => `${JSON.stringify(spec)}: ${id}`).join(", ");
335
+ const named = names.length > 0 ? `export const { ${names.join(", ")} } = __m.exports;\n` : "";
336
+ return (imports.join("") +
337
+ `const __deps = { ${table} };\n` +
338
+ `const __m = { exports: {} };\n` +
339
+ `(function (module, exports, require, global) {\n${code}\n}).call(__m.exports, __m, __m.exports, (s) => {\n` +
340
+ ` const d = __deps[s];\n` +
341
+ ` if (!d) throw new Error("weft: cannot require " + s + " in the browser");\n` +
342
+ ` return d.__weftCjs ? d.default : d;\n` +
343
+ `}, globalThis);\n` +
344
+ `export default __m.exports;\n` +
345
+ `export const __weftCjs = true;\n` +
346
+ named);
347
+ }
@@ -0,0 +1,76 @@
1
+ import { type Secret } from "./secret.js";
2
+ export interface Identity {
3
+ readonly provider: string;
4
+ readonly subject: string;
5
+ readonly email: string | null;
6
+ readonly emailVerified: boolean;
7
+ readonly name: string | null;
8
+ readonly picture: string | null;
9
+ readonly claims: Readonly<Record<string, unknown>>;
10
+ }
11
+ export declare class SignInError extends Error {
12
+ readonly code: "denied" | "failed";
13
+ constructor(code: "denied" | "failed", message: string);
14
+ }
15
+ export interface AuthorizeInput {
16
+ redirectUri: string;
17
+ state: string;
18
+ nonce: string;
19
+ challenge: string;
20
+ }
21
+ export interface IdentifyInput {
22
+ code: string;
23
+ redirectUri: string;
24
+ verifier: string;
25
+ nonce: string;
26
+ }
27
+ export interface Provider {
28
+ readonly id: string;
29
+ readonly label: string;
30
+ authorize(input: AuthorizeInput): Promise<string>;
31
+ identify(input: IdentifyInput): Promise<Identity>;
32
+ }
33
+ type Fetch = (input: string, init?: RequestInit) => Promise<Response>;
34
+ export interface ProviderOptions {
35
+ clientId: string;
36
+ clientSecret: Secret | string;
37
+ scopes?: string[];
38
+ params?: Record<string, string>;
39
+ id?: string;
40
+ label?: string;
41
+ timeoutMs?: number;
42
+ fetch?: Fetch;
43
+ }
44
+ export interface OidcOptions extends ProviderOptions {
45
+ id: string;
46
+ issuer: string;
47
+ }
48
+ export declare function checkEndpoint(raw: unknown, what: string): string;
49
+ export declare function pkceChallenge(verifier: string): Promise<string>;
50
+ type Jwk = JsonWebKey & {
51
+ kid?: string;
52
+ use?: string;
53
+ alg?: string;
54
+ };
55
+ export interface VerifyOptions {
56
+ key(kid: string | null, alg: string): Promise<Jwk | null>;
57
+ issuer(iss: unknown, claims: Record<string, unknown>): boolean;
58
+ audience: string;
59
+ nonce: string;
60
+ algs: readonly string[];
61
+ now?: number;
62
+ }
63
+ export declare function verifyIdToken(token: unknown, o: VerifyOptions): Promise<Record<string, unknown>>;
64
+ export declare function oidc(o: OidcOptions): Provider;
65
+ export declare function google(o: ProviderOptions): Provider;
66
+ export interface MicrosoftOptions extends ProviderOptions {
67
+ tenant?: string;
68
+ authority?: string;
69
+ }
70
+ export declare function microsoft(o: MicrosoftOptions): Provider;
71
+ export interface GitHubOptions extends ProviderOptions {
72
+ baseUrl?: string;
73
+ apiUrl?: string;
74
+ }
75
+ export declare function github(o: GitHubOptions): Provider;
76
+ export {};