@quatronic/sdk 0.7.0-rc.9 → 0.7.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/dist/cli/skills-postinstall.js +118 -1
- package/dist/cli/skills.js +118 -1
- package/dist/next/auth/index.d.ts +12 -0
- package/dist/next/auth/index.js +11 -3
- package/dist/next/auth/index.js.map +1 -1
- package/dist/next/users/index.js +7 -4
- package/dist/next/users/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/qore-enable-auth-method/SKILL.md +4 -3
- package/skills/qore-use-mail-domain/SKILL.next.md +4 -4
|
@@ -172,6 +172,103 @@ off the SDK's lint rules that check the same things.
|
|
|
172
172
|
The \`qore-\` prefix is reserved for managed skills. Sync never touches a skill
|
|
173
173
|
it does not ship, so your own skills are safe under any other name.
|
|
174
174
|
`;
|
|
175
|
+
var APP_README_PATH = "README.md";
|
|
176
|
+
function isLegacyAppReadme(text) {
|
|
177
|
+
const flat = text.replace(/\s+/g, " ");
|
|
178
|
+
return flat.includes("frozen at generation time") && flat.includes("The `quatronic-` prefix is reserved");
|
|
179
|
+
}
|
|
180
|
+
var APP_README_HEAD = `# Claude Code setup for this app
|
|
181
|
+
|
|
182
|
+
This app ships with a Qore Claude Code setup, committed into this repo. The
|
|
183
|
+
\`qore-*\` skills are managed by the SDK; everything else here is yours.
|
|
184
|
+
`;
|
|
185
|
+
var APP_README_CONVENTIONS = `## Conventions
|
|
186
|
+
|
|
187
|
+
- The \`qore-*\` skills are managed by \`@quatronic/sdk\` and stay current with it:
|
|
188
|
+
every SDK upgrade PR re-syncs them. How to turn one off, extend it with your
|
|
189
|
+
own conventions, replace it or keep your own copy is in
|
|
190
|
+
\`qore/README.md\`; editing a managed skill in place does not stick.
|
|
191
|
+
- The \`qore-\` prefix is reserved for managed skills. Name your own skills
|
|
192
|
+
without it (e.g. \`.claude/skills/export-report/SKILL.md\`); sync never touches
|
|
193
|
+
them.
|
|
194
|
+
- \`settings.json\` is yours: it was generated once and nothing re-syncs it.
|
|
195
|
+
`;
|
|
196
|
+
function appReadme(runtime) {
|
|
197
|
+
if (runtime === "next") {
|
|
198
|
+
return `${APP_README_HEAD}
|
|
199
|
+
> New here? Run \`/qore-recommended-tools\` for optional, public skills and
|
|
200
|
+
> plugins (like \`superpowers\` and \`frontend-design\`) that pair well with this app.
|
|
201
|
+
|
|
202
|
+
## What's here
|
|
203
|
+
|
|
204
|
+
- \`settings.json\` \u2014 a safe permission floor: secrets (\`.env\`, \`.env.local\`) can't be read or
|
|
205
|
+
written (\`.env.example\` stays readable), destructive git is blocked, and \`git push\` plus edits to the auth/SDK
|
|
206
|
+
boundary files ask for confirmation.
|
|
207
|
+
- \`skills/qore-*\` \u2014 the managed skills, listed with when to reach for each in
|
|
208
|
+
\`qore/skills.md\` (imported into \`CLAUDE.md\`). Highlights:
|
|
209
|
+
\`/qore-ship-checklist\` (the quality gate to run before every PR),
|
|
210
|
+
\`/qore-author-skill\` to write your own, and \`/qore-recommended-tools\` for
|
|
211
|
+
optional public skills/plugins.
|
|
212
|
+
- \`qore/\` \u2014 \`README.md\` (what you can and can't do with managed skills),
|
|
213
|
+
\`skills.md\` (the index) and \`manifest.json\` (what sync manages).
|
|
214
|
+
- \`../.github/workflows/ci.yml\` \u2014 the PR gate. It calls Quatronic's shared
|
|
215
|
+
pipeline, which runs lint, format-check, typecheck, unit tests,
|
|
216
|
+
integration tests and build on every pull request and on every push to
|
|
217
|
+
\`main\`. Each of those is one of *your* \`package.json\` scripts, so change
|
|
218
|
+
what a check does by changing the script. Add your own jobs to the
|
|
219
|
+
\`verify\` job's \`needs:\` list; leave the shared call alone, as edits to it
|
|
220
|
+
are replaced when the pipeline is upgraded.
|
|
221
|
+
|
|
222
|
+
${APP_README_CONVENTIONS}`;
|
|
223
|
+
}
|
|
224
|
+
return `${APP_README_HEAD}
|
|
225
|
+
## What's here
|
|
226
|
+
|
|
227
|
+
- \`settings.json\` \u2014 a safe permission floor: secrets (\`.env\`, \`.env.local\`) can't be read or
|
|
228
|
+
written, destructive git is blocked, and \`git push\` asks for confirmation.
|
|
229
|
+
- \`skills/qore-*\` \u2014 the managed skills, listed with when to reach for each in
|
|
230
|
+
\`qore/skills.md\` (imported into \`CLAUDE.md\`).
|
|
231
|
+
- \`qore/\` \u2014 \`README.md\` (what you can and can't do with managed skills),
|
|
232
|
+
\`skills.md\` (the index) and \`manifest.json\` (what sync manages).
|
|
233
|
+
- \`../.github/workflows/ci.yml\` \u2014 the PR gate. It calls Quatronic's shared
|
|
234
|
+
pipeline, which runs typecheck, unit tests and build on every pull request
|
|
235
|
+
and on every push to \`main\`. Each of those is one of *your*
|
|
236
|
+
\`package.json\` scripts, so change what a check does by changing the
|
|
237
|
+
script; adding a \`lint\` script is not enough on its own, since the call
|
|
238
|
+
also has to ask for that check. Add your own jobs to the \`verify\` job's
|
|
239
|
+
\`needs:\` list; leave the shared call alone, as edits to it are replaced
|
|
240
|
+
when the pipeline is upgraded.
|
|
241
|
+
|
|
242
|
+
${APP_README_CONVENTIONS}`;
|
|
243
|
+
}
|
|
244
|
+
var TABLE_ROW = /^\s*\|(.*)\|\s*$/;
|
|
245
|
+
var TABLE_RULE = /^\s*\|[\s:|-]+\|\s*$/;
|
|
246
|
+
var firstCell = (line) => TABLE_ROW.exec(line)?.[1].split("|")[0].trim();
|
|
247
|
+
function replaceSkillsTable(md, names) {
|
|
248
|
+
const eol = md.includes("\r\n") ? "\r\n" : "\n";
|
|
249
|
+
const lines = md.split(/\r?\n/);
|
|
250
|
+
for (let i = 0; i + 2 < lines.length; i++) {
|
|
251
|
+
if (!/^skill$/i.test(firstCell(lines[i]) ?? "") || !TABLE_RULE.test(lines[i + 1])) continue;
|
|
252
|
+
let end = i + 2;
|
|
253
|
+
while (end < lines.length && firstCell(lines[end]) !== void 0) end++;
|
|
254
|
+
const rows = lines.slice(i + 2, end);
|
|
255
|
+
const managed = rows.length > 0 && rows.every((r) => {
|
|
256
|
+
const name = /^`\/?([a-z0-9-]+)`$/.exec(firstCell(r))?.[1];
|
|
257
|
+
return name !== void 0 && names.has(name);
|
|
258
|
+
});
|
|
259
|
+
if (!managed) continue;
|
|
260
|
+
const out = [];
|
|
261
|
+
lines.forEach((line, j) => {
|
|
262
|
+
if (j === i) out.push(CLAUDE_MD_IMPORT);
|
|
263
|
+
else if (j > i && j < end) return;
|
|
264
|
+
else if (line.trim() === CLAUDE_MD_IMPORT) {
|
|
265
|
+
if (out.at(-1)?.trim() === "") out.pop();
|
|
266
|
+
} else out.push(line);
|
|
267
|
+
});
|
|
268
|
+
return out.join(eol);
|
|
269
|
+
}
|
|
270
|
+
return void 0;
|
|
271
|
+
}
|
|
175
272
|
function buildTree(catalog, sources, f) {
|
|
176
273
|
const skills = renderSkills(catalog, sources, f);
|
|
177
274
|
for (const entry of catalog.skills) {
|
|
@@ -246,6 +343,7 @@ function planSync(s) {
|
|
|
246
343
|
let claudeMd = s.claudeMd;
|
|
247
344
|
const claudeMdRenamed = [];
|
|
248
345
|
let claudeMdImportAdded = false;
|
|
346
|
+
let claudeMdTableReplaced = false;
|
|
249
347
|
if (claudeMd !== void 0) {
|
|
250
348
|
for (const entry of s.catalog.skills) {
|
|
251
349
|
for (const legacy of entry.legacyNames ?? []) {
|
|
@@ -255,6 +353,11 @@ function planSync(s) {
|
|
|
255
353
|
claudeMdRenamed.push([legacy, entry.name]);
|
|
256
354
|
}
|
|
257
355
|
}
|
|
356
|
+
const withoutTable = replaceSkillsTable(claudeMd, new Set(s.catalog.skills.map((e) => e.name)));
|
|
357
|
+
if (withoutTable !== void 0) {
|
|
358
|
+
claudeMd = withoutTable;
|
|
359
|
+
claudeMdTableReplaced = true;
|
|
360
|
+
}
|
|
258
361
|
if (!claudeMd.split(/\r?\n/).some((l) => l.trim() === CLAUDE_MD_IMPORT)) {
|
|
259
362
|
claudeMd = `${claudeMd.replace(/\s*$/, "")}
|
|
260
363
|
|
|
@@ -263,6 +366,9 @@ ${CLAUDE_MD_IMPORT}
|
|
|
263
366
|
claudeMdImportAdded = true;
|
|
264
367
|
}
|
|
265
368
|
}
|
|
369
|
+
const currentReadme = s.read(APP_README_PATH);
|
|
370
|
+
const appReadmeReplaced = currentReadme !== void 0 && isLegacyAppReadme(currentReadme);
|
|
371
|
+
if (appReadmeReplaced) writes.set(APP_README_PATH, appReadme(s.features.runtime));
|
|
266
372
|
const manifest = {
|
|
267
373
|
schemaVersion: 1,
|
|
268
374
|
sdkVersion: s.sdkVersion,
|
|
@@ -284,7 +390,9 @@ ${CLAUDE_MD_IMPORT}
|
|
|
284
390
|
manifest,
|
|
285
391
|
claudeMd: claudeMd === s.claudeMd ? void 0 : claudeMd,
|
|
286
392
|
claudeMdRenamed: claudeMdRenamed.sort(([a], [b]) => a.localeCompare(b)),
|
|
287
|
-
claudeMdImportAdded
|
|
393
|
+
claudeMdImportAdded,
|
|
394
|
+
claudeMdTableReplaced,
|
|
395
|
+
appReadmeReplaced
|
|
288
396
|
};
|
|
289
397
|
}
|
|
290
398
|
function planChanges(p) {
|
|
@@ -316,9 +424,18 @@ function renderReport(p, opts) {
|
|
|
316
424
|
p.legacyRemoved,
|
|
317
425
|
"(replaced by their `qore-*` names; a local edit to one is in this change's diff):"
|
|
318
426
|
);
|
|
427
|
+
if (p.appReadmeReplaced) {
|
|
428
|
+
lines.push(
|
|
429
|
+
"",
|
|
430
|
+
"**`.claude/README.md`** replaced: the generator's text said this setup is frozen and yours to edit, which the managed skills no longer are. A change of your own to it is in this change's diff."
|
|
431
|
+
);
|
|
432
|
+
}
|
|
319
433
|
if (p.claudeMd !== void 0) {
|
|
320
434
|
lines.push("", "**`CLAUDE.md`:**", "");
|
|
321
435
|
for (const [from, to] of p.claudeMdRenamed) lines.push(`- Renamed \`${from}\` to \`${to}\`.`);
|
|
436
|
+
if (p.claudeMdTableReplaced) {
|
|
437
|
+
lines.push(`- Replaced the generated skills table with \`${CLAUDE_MD_IMPORT}\`, the index of managed skills.`);
|
|
438
|
+
}
|
|
322
439
|
if (p.claudeMdImportAdded) lines.push(`- Imports \`${CLAUDE_MD_IMPORT}\`, the index of managed skills.`);
|
|
323
440
|
}
|
|
324
441
|
return `${lines.join("\n")}
|
package/dist/cli/skills.js
CHANGED
|
@@ -171,6 +171,103 @@ off the SDK's lint rules that check the same things.
|
|
|
171
171
|
The \`qore-\` prefix is reserved for managed skills. Sync never touches a skill
|
|
172
172
|
it does not ship, so your own skills are safe under any other name.
|
|
173
173
|
`;
|
|
174
|
+
var APP_README_PATH = "README.md";
|
|
175
|
+
function isLegacyAppReadme(text) {
|
|
176
|
+
const flat = text.replace(/\s+/g, " ");
|
|
177
|
+
return flat.includes("frozen at generation time") && flat.includes("The `quatronic-` prefix is reserved");
|
|
178
|
+
}
|
|
179
|
+
var APP_README_HEAD = `# Claude Code setup for this app
|
|
180
|
+
|
|
181
|
+
This app ships with a Qore Claude Code setup, committed into this repo. The
|
|
182
|
+
\`qore-*\` skills are managed by the SDK; everything else here is yours.
|
|
183
|
+
`;
|
|
184
|
+
var APP_README_CONVENTIONS = `## Conventions
|
|
185
|
+
|
|
186
|
+
- The \`qore-*\` skills are managed by \`@quatronic/sdk\` and stay current with it:
|
|
187
|
+
every SDK upgrade PR re-syncs them. How to turn one off, extend it with your
|
|
188
|
+
own conventions, replace it or keep your own copy is in
|
|
189
|
+
\`qore/README.md\`; editing a managed skill in place does not stick.
|
|
190
|
+
- The \`qore-\` prefix is reserved for managed skills. Name your own skills
|
|
191
|
+
without it (e.g. \`.claude/skills/export-report/SKILL.md\`); sync never touches
|
|
192
|
+
them.
|
|
193
|
+
- \`settings.json\` is yours: it was generated once and nothing re-syncs it.
|
|
194
|
+
`;
|
|
195
|
+
function appReadme(runtime) {
|
|
196
|
+
if (runtime === "next") {
|
|
197
|
+
return `${APP_README_HEAD}
|
|
198
|
+
> New here? Run \`/qore-recommended-tools\` for optional, public skills and
|
|
199
|
+
> plugins (like \`superpowers\` and \`frontend-design\`) that pair well with this app.
|
|
200
|
+
|
|
201
|
+
## What's here
|
|
202
|
+
|
|
203
|
+
- \`settings.json\` \u2014 a safe permission floor: secrets (\`.env\`, \`.env.local\`) can't be read or
|
|
204
|
+
written (\`.env.example\` stays readable), destructive git is blocked, and \`git push\` plus edits to the auth/SDK
|
|
205
|
+
boundary files ask for confirmation.
|
|
206
|
+
- \`skills/qore-*\` \u2014 the managed skills, listed with when to reach for each in
|
|
207
|
+
\`qore/skills.md\` (imported into \`CLAUDE.md\`). Highlights:
|
|
208
|
+
\`/qore-ship-checklist\` (the quality gate to run before every PR),
|
|
209
|
+
\`/qore-author-skill\` to write your own, and \`/qore-recommended-tools\` for
|
|
210
|
+
optional public skills/plugins.
|
|
211
|
+
- \`qore/\` \u2014 \`README.md\` (what you can and can't do with managed skills),
|
|
212
|
+
\`skills.md\` (the index) and \`manifest.json\` (what sync manages).
|
|
213
|
+
- \`../.github/workflows/ci.yml\` \u2014 the PR gate. It calls Quatronic's shared
|
|
214
|
+
pipeline, which runs lint, format-check, typecheck, unit tests,
|
|
215
|
+
integration tests and build on every pull request and on every push to
|
|
216
|
+
\`main\`. Each of those is one of *your* \`package.json\` scripts, so change
|
|
217
|
+
what a check does by changing the script. Add your own jobs to the
|
|
218
|
+
\`verify\` job's \`needs:\` list; leave the shared call alone, as edits to it
|
|
219
|
+
are replaced when the pipeline is upgraded.
|
|
220
|
+
|
|
221
|
+
${APP_README_CONVENTIONS}`;
|
|
222
|
+
}
|
|
223
|
+
return `${APP_README_HEAD}
|
|
224
|
+
## What's here
|
|
225
|
+
|
|
226
|
+
- \`settings.json\` \u2014 a safe permission floor: secrets (\`.env\`, \`.env.local\`) can't be read or
|
|
227
|
+
written, destructive git is blocked, and \`git push\` asks for confirmation.
|
|
228
|
+
- \`skills/qore-*\` \u2014 the managed skills, listed with when to reach for each in
|
|
229
|
+
\`qore/skills.md\` (imported into \`CLAUDE.md\`).
|
|
230
|
+
- \`qore/\` \u2014 \`README.md\` (what you can and can't do with managed skills),
|
|
231
|
+
\`skills.md\` (the index) and \`manifest.json\` (what sync manages).
|
|
232
|
+
- \`../.github/workflows/ci.yml\` \u2014 the PR gate. It calls Quatronic's shared
|
|
233
|
+
pipeline, which runs typecheck, unit tests and build on every pull request
|
|
234
|
+
and on every push to \`main\`. Each of those is one of *your*
|
|
235
|
+
\`package.json\` scripts, so change what a check does by changing the
|
|
236
|
+
script; adding a \`lint\` script is not enough on its own, since the call
|
|
237
|
+
also has to ask for that check. Add your own jobs to the \`verify\` job's
|
|
238
|
+
\`needs:\` list; leave the shared call alone, as edits to it are replaced
|
|
239
|
+
when the pipeline is upgraded.
|
|
240
|
+
|
|
241
|
+
${APP_README_CONVENTIONS}`;
|
|
242
|
+
}
|
|
243
|
+
var TABLE_ROW = /^\s*\|(.*)\|\s*$/;
|
|
244
|
+
var TABLE_RULE = /^\s*\|[\s:|-]+\|\s*$/;
|
|
245
|
+
var firstCell = (line) => TABLE_ROW.exec(line)?.[1].split("|")[0].trim();
|
|
246
|
+
function replaceSkillsTable(md, names) {
|
|
247
|
+
const eol = md.includes("\r\n") ? "\r\n" : "\n";
|
|
248
|
+
const lines = md.split(/\r?\n/);
|
|
249
|
+
for (let i = 0; i + 2 < lines.length; i++) {
|
|
250
|
+
if (!/^skill$/i.test(firstCell(lines[i]) ?? "") || !TABLE_RULE.test(lines[i + 1])) continue;
|
|
251
|
+
let end = i + 2;
|
|
252
|
+
while (end < lines.length && firstCell(lines[end]) !== void 0) end++;
|
|
253
|
+
const rows = lines.slice(i + 2, end);
|
|
254
|
+
const managed = rows.length > 0 && rows.every((r) => {
|
|
255
|
+
const name = /^`\/?([a-z0-9-]+)`$/.exec(firstCell(r))?.[1];
|
|
256
|
+
return name !== void 0 && names.has(name);
|
|
257
|
+
});
|
|
258
|
+
if (!managed) continue;
|
|
259
|
+
const out = [];
|
|
260
|
+
lines.forEach((line, j) => {
|
|
261
|
+
if (j === i) out.push(CLAUDE_MD_IMPORT);
|
|
262
|
+
else if (j > i && j < end) return;
|
|
263
|
+
else if (line.trim() === CLAUDE_MD_IMPORT) {
|
|
264
|
+
if (out.at(-1)?.trim() === "") out.pop();
|
|
265
|
+
} else out.push(line);
|
|
266
|
+
});
|
|
267
|
+
return out.join(eol);
|
|
268
|
+
}
|
|
269
|
+
return void 0;
|
|
270
|
+
}
|
|
174
271
|
function buildTree(catalog, sources, f) {
|
|
175
272
|
const skills = renderSkills(catalog, sources, f);
|
|
176
273
|
for (const entry of catalog.skills) {
|
|
@@ -245,6 +342,7 @@ function planSync(s) {
|
|
|
245
342
|
let claudeMd = s.claudeMd;
|
|
246
343
|
const claudeMdRenamed = [];
|
|
247
344
|
let claudeMdImportAdded = false;
|
|
345
|
+
let claudeMdTableReplaced = false;
|
|
248
346
|
if (claudeMd !== void 0) {
|
|
249
347
|
for (const entry of s.catalog.skills) {
|
|
250
348
|
for (const legacy of entry.legacyNames ?? []) {
|
|
@@ -254,6 +352,11 @@ function planSync(s) {
|
|
|
254
352
|
claudeMdRenamed.push([legacy, entry.name]);
|
|
255
353
|
}
|
|
256
354
|
}
|
|
355
|
+
const withoutTable = replaceSkillsTable(claudeMd, new Set(s.catalog.skills.map((e) => e.name)));
|
|
356
|
+
if (withoutTable !== void 0) {
|
|
357
|
+
claudeMd = withoutTable;
|
|
358
|
+
claudeMdTableReplaced = true;
|
|
359
|
+
}
|
|
257
360
|
if (!claudeMd.split(/\r?\n/).some((l) => l.trim() === CLAUDE_MD_IMPORT)) {
|
|
258
361
|
claudeMd = `${claudeMd.replace(/\s*$/, "")}
|
|
259
362
|
|
|
@@ -262,6 +365,9 @@ ${CLAUDE_MD_IMPORT}
|
|
|
262
365
|
claudeMdImportAdded = true;
|
|
263
366
|
}
|
|
264
367
|
}
|
|
368
|
+
const currentReadme = s.read(APP_README_PATH);
|
|
369
|
+
const appReadmeReplaced = currentReadme !== void 0 && isLegacyAppReadme(currentReadme);
|
|
370
|
+
if (appReadmeReplaced) writes.set(APP_README_PATH, appReadme(s.features.runtime));
|
|
265
371
|
const manifest = {
|
|
266
372
|
schemaVersion: 1,
|
|
267
373
|
sdkVersion: s.sdkVersion,
|
|
@@ -283,7 +389,9 @@ ${CLAUDE_MD_IMPORT}
|
|
|
283
389
|
manifest,
|
|
284
390
|
claudeMd: claudeMd === s.claudeMd ? void 0 : claudeMd,
|
|
285
391
|
claudeMdRenamed: claudeMdRenamed.sort(([a], [b]) => a.localeCompare(b)),
|
|
286
|
-
claudeMdImportAdded
|
|
392
|
+
claudeMdImportAdded,
|
|
393
|
+
claudeMdTableReplaced,
|
|
394
|
+
appReadmeReplaced
|
|
287
395
|
};
|
|
288
396
|
}
|
|
289
397
|
function planChanges(p) {
|
|
@@ -315,9 +423,18 @@ function renderReport(p, opts) {
|
|
|
315
423
|
p.legacyRemoved,
|
|
316
424
|
"(replaced by their `qore-*` names; a local edit to one is in this change's diff):"
|
|
317
425
|
);
|
|
426
|
+
if (p.appReadmeReplaced) {
|
|
427
|
+
lines.push(
|
|
428
|
+
"",
|
|
429
|
+
"**`.claude/README.md`** replaced: the generator's text said this setup is frozen and yours to edit, which the managed skills no longer are. A change of your own to it is in this change's diff."
|
|
430
|
+
);
|
|
431
|
+
}
|
|
318
432
|
if (p.claudeMd !== void 0) {
|
|
319
433
|
lines.push("", "**`CLAUDE.md`:**", "");
|
|
320
434
|
for (const [from, to] of p.claudeMdRenamed) lines.push(`- Renamed \`${from}\` to \`${to}\`.`);
|
|
435
|
+
if (p.claudeMdTableReplaced) {
|
|
436
|
+
lines.push(`- Replaced the generated skills table with \`${CLAUDE_MD_IMPORT}\`, the index of managed skills.`);
|
|
437
|
+
}
|
|
321
438
|
if (p.claudeMdImportAdded) lines.push(`- Imports \`${CLAUDE_MD_IMPORT}\`, the index of managed skills.`);
|
|
322
439
|
}
|
|
323
440
|
return `${lines.join("\n")}
|
|
@@ -8,6 +8,12 @@ declare function permissionsForRoles(map: PermissionMap, roles: string[]): strin
|
|
|
8
8
|
|
|
9
9
|
type NextAuthOptions = {
|
|
10
10
|
keycloakUrl: string;
|
|
11
|
+
/** Optional in-cluster address of Keycloak, used ONLY for this server's own
|
|
12
|
+
* HTTP calls (token exchange, refresh, back-channel logout, JWKS fetch).
|
|
13
|
+
* The issuer, every `iss` check, the authorize URL, the end-session URL and
|
|
14
|
+
* redirect URIs stay on the public `keycloakUrl`. Keycloak must advertise the
|
|
15
|
+
* public issuer when reached this way. Unset: everything uses `keycloakUrl`. */
|
|
16
|
+
keycloakInternalUrl?: string;
|
|
11
17
|
realm: string;
|
|
12
18
|
clientId: string;
|
|
13
19
|
clientSecret: string;
|
|
@@ -47,6 +53,12 @@ declare function createAuthRouteHandlers(opts: NextAuthOptions): Promise<AuthRou
|
|
|
47
53
|
|
|
48
54
|
type KcConfig = {
|
|
49
55
|
keycloakUrl: string;
|
|
56
|
+
/** Optional in-cluster address of Keycloak, used ONLY for this server's own
|
|
57
|
+
* HTTP calls (token exchange, refresh, back-channel logout, JWKS fetch).
|
|
58
|
+
* The issuer, every `iss` check, the authorize URL, the end-session URL and
|
|
59
|
+
* redirect URIs stay on the public `keycloakUrl`. Keycloak must advertise the
|
|
60
|
+
* public issuer when reached this way. Unset: everything uses `keycloakUrl`. */
|
|
61
|
+
keycloakInternalUrl?: string;
|
|
50
62
|
realm: string;
|
|
51
63
|
clientId: string;
|
|
52
64
|
clientSecret: string;
|
package/dist/next/auth/index.js
CHANGED
|
@@ -136,7 +136,9 @@ var KcTokenError = class extends Error {
|
|
|
136
136
|
};
|
|
137
137
|
function createKcClient(cfg) {
|
|
138
138
|
const issuer = `${cfg.keycloakUrl}/realms/${cfg.realm}`;
|
|
139
|
-
const
|
|
139
|
+
const serverIssuer = cfg.keycloakInternalUrl ? `${cfg.keycloakInternalUrl.replace(/\/+$/, "")}/realms/${cfg.realm}` : issuer;
|
|
140
|
+
const tokenUrl = `${serverIssuer}/protocol/openid-connect/token`;
|
|
141
|
+
const backchannelLogoutUrl = `${serverIssuer}/protocol/openid-connect/logout`;
|
|
140
142
|
const logoutUrl = `${issuer}/protocol/openid-connect/logout`;
|
|
141
143
|
const authorizeUrl = `${issuer}/protocol/openid-connect/auth`;
|
|
142
144
|
const redirectUri = `${cfg.publicOrigin}/api/auth/callback`;
|
|
@@ -221,7 +223,7 @@ function createKcClient(cfg) {
|
|
|
221
223
|
client_secret: cfg.clientSecret,
|
|
222
224
|
refresh_token: refreshToken
|
|
223
225
|
});
|
|
224
|
-
const res = await fetch(
|
|
226
|
+
const res = await fetch(backchannelLogoutUrl, {
|
|
225
227
|
method: "POST",
|
|
226
228
|
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
227
229
|
body,
|
|
@@ -237,7 +239,8 @@ function createKcClient(cfg) {
|
|
|
237
239
|
// src/auth-core/jwks.ts
|
|
238
240
|
import { createRemoteJWKSet, jwtVerify } from "jose";
|
|
239
241
|
function createJwks(opts) {
|
|
240
|
-
const
|
|
242
|
+
const fetchBase = opts.keycloakInternalUrl ? opts.keycloakInternalUrl.replace(/\/+$/, "") : opts.keycloakUrl;
|
|
243
|
+
const url = new URL(`${fetchBase}/realms/${opts.realm}/protocol/openid-connect/certs`);
|
|
241
244
|
const jwkset = createRemoteJWKSet(url, {
|
|
242
245
|
cooldownDuration: opts.cooldownMs ?? 3e4
|
|
243
246
|
});
|
|
@@ -851,6 +854,7 @@ async function createAuthRouteHandlers(opts) {
|
|
|
851
854
|
const handoff = await createIdentityHandoff({ secret: opts.sessionCookieSecret });
|
|
852
855
|
const kcClient = createKcClient({
|
|
853
856
|
keycloakUrl: opts.keycloakUrl,
|
|
857
|
+
keycloakInternalUrl: opts.keycloakInternalUrl,
|
|
854
858
|
realm: opts.realm,
|
|
855
859
|
clientId: opts.clientId,
|
|
856
860
|
clientSecret: opts.clientSecret,
|
|
@@ -860,6 +864,7 @@ async function createAuthRouteHandlers(opts) {
|
|
|
860
864
|
});
|
|
861
865
|
const jwks = createJwks({
|
|
862
866
|
keycloakUrl: opts.keycloakUrl,
|
|
867
|
+
keycloakInternalUrl: opts.keycloakInternalUrl,
|
|
863
868
|
realm: opts.realm,
|
|
864
869
|
audience: opts.clientId
|
|
865
870
|
});
|
|
@@ -1503,6 +1508,7 @@ async function requireAuthFor(opts) {
|
|
|
1503
1508
|
const refreshStore = createRefreshStore({ db: opts.db, cipher });
|
|
1504
1509
|
const kcClient = createKcClient({
|
|
1505
1510
|
keycloakUrl: opts.keycloakUrl,
|
|
1511
|
+
keycloakInternalUrl: opts.keycloakInternalUrl,
|
|
1506
1512
|
realm: opts.realm,
|
|
1507
1513
|
clientId: opts.clientId,
|
|
1508
1514
|
clientSecret: opts.clientSecret,
|
|
@@ -1560,6 +1566,7 @@ var depsCache = /* @__PURE__ */ new WeakMap();
|
|
|
1560
1566
|
function depsCacheKey(opts) {
|
|
1561
1567
|
return JSON.stringify({
|
|
1562
1568
|
keycloakUrl: opts.keycloakUrl,
|
|
1569
|
+
keycloakInternalUrl: opts.keycloakInternalUrl,
|
|
1563
1570
|
realm: opts.realm,
|
|
1564
1571
|
clientId: opts.clientId,
|
|
1565
1572
|
clientSecret: opts.clientSecret,
|
|
@@ -1579,6 +1586,7 @@ async function buildDepsUncached(opts) {
|
|
|
1579
1586
|
const refreshStore = createRefreshStore({ db: opts.db, cipher });
|
|
1580
1587
|
const kcClient = createKcClient({
|
|
1581
1588
|
keycloakUrl: opts.keycloakUrl,
|
|
1589
|
+
keycloakInternalUrl: opts.keycloakInternalUrl,
|
|
1582
1590
|
realm: opts.realm,
|
|
1583
1591
|
clientId: opts.clientId,
|
|
1584
1592
|
clientSecret: opts.clientSecret,
|