@nauth-toolkit/core 0.1.97 → 0.1.99
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/interfaces/config.interface.d.ts +0 -47
- package/dist/interfaces/config.interface.d.ts.map +1 -1
- package/dist/openapi/components.schemas.json +4109 -0
- package/dist/openapi/generate-openapi.d.ts +28 -0
- package/dist/openapi/generate-openapi.d.ts.map +1 -0
- package/dist/openapi/generate-openapi.js +247 -0
- package/dist/openapi/generate-openapi.js.map +1 -0
- package/dist/openapi/index.d.ts +77 -0
- package/dist/openapi/index.d.ts.map +1 -0
- package/dist/openapi/index.js +46 -0
- package/dist/openapi/index.js.map +1 -0
- package/dist/platform/interfaces.d.ts +0 -2
- package/dist/platform/interfaces.d.ts.map +1 -1
- package/dist/services/auth-service-internal-helpers.d.ts +13 -7
- package/dist/services/auth-service-internal-helpers.d.ts.map +1 -1
- package/dist/services/auth-service-internal-helpers.js +17 -32
- package/dist/services/auth-service-internal-helpers.js.map +1 -1
- package/package.json +13 -4
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build-time OpenAPI schema generator for nauth-toolkit DTOs.
|
|
3
|
+
*
|
|
4
|
+
* Why this exists:
|
|
5
|
+
* - Consumer apps often import DTO classes from `node_modules`.
|
|
6
|
+
* - Many OpenAPI integrations (including NestJS Swagger plugin transforms)
|
|
7
|
+
* don't introspect external packages well enough to "expand" DTO shapes.
|
|
8
|
+
* - To keep `@nauth-toolkit/core` framework-agnostic, we generate and ship
|
|
9
|
+
* OpenAPI component schemas as plain JSON.
|
|
10
|
+
*
|
|
11
|
+
* Output:
|
|
12
|
+
* - `dist/openapi/components.schemas.json`
|
|
13
|
+
*
|
|
14
|
+
* Implementation approach (Option A):
|
|
15
|
+
* - Parse `src/dto/index.ts` to find exported DTO/type files.
|
|
16
|
+
* - Collect exported symbols (classes/interfaces/enums/types) from those files.
|
|
17
|
+
* - Create a temporary "registry" type that references all symbols.
|
|
18
|
+
* - Generate a single JSON Schema document and convert `definitions` into
|
|
19
|
+
* OpenAPI `components.schemas` (with `$ref` rewrites).
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```bash
|
|
23
|
+
* # Executed by the core build:
|
|
24
|
+
* node dist/openapi/generate-openapi.js
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function generateOpenApiSchemas(): void;
|
|
28
|
+
//# sourceMappingURL=generate-openapi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-openapi.d.ts","sourceRoot":"","sources":["../../src/openapi/generate-openapi.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,sBAAsB,IAAI,IAAI,CAgD7C"}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.generateOpenApiSchemas = generateOpenApiSchemas;
|
|
37
|
+
const node_fs_1 = require("node:fs");
|
|
38
|
+
const node_path_1 = require("node:path");
|
|
39
|
+
const ts_json_schema_generator_1 = require("ts-json-schema-generator");
|
|
40
|
+
const ts = __importStar(require("typescript"));
|
|
41
|
+
/**
|
|
42
|
+
* Build-time OpenAPI schema generator for nauth-toolkit DTOs.
|
|
43
|
+
*
|
|
44
|
+
* Why this exists:
|
|
45
|
+
* - Consumer apps often import DTO classes from `node_modules`.
|
|
46
|
+
* - Many OpenAPI integrations (including NestJS Swagger plugin transforms)
|
|
47
|
+
* don't introspect external packages well enough to "expand" DTO shapes.
|
|
48
|
+
* - To keep `@nauth-toolkit/core` framework-agnostic, we generate and ship
|
|
49
|
+
* OpenAPI component schemas as plain JSON.
|
|
50
|
+
*
|
|
51
|
+
* Output:
|
|
52
|
+
* - `dist/openapi/components.schemas.json`
|
|
53
|
+
*
|
|
54
|
+
* Implementation approach (Option A):
|
|
55
|
+
* - Parse `src/dto/index.ts` to find exported DTO/type files.
|
|
56
|
+
* - Collect exported symbols (classes/interfaces/enums/types) from those files.
|
|
57
|
+
* - Create a temporary "registry" type that references all symbols.
|
|
58
|
+
* - Generate a single JSON Schema document and convert `definitions` into
|
|
59
|
+
* OpenAPI `components.schemas` (with `$ref` rewrites).
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```bash
|
|
63
|
+
* # Executed by the core build:
|
|
64
|
+
* node dist/openapi/generate-openapi.js
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
function generateOpenApiSchemas() {
|
|
68
|
+
const packageRoot = (0, node_path_1.resolve)(__dirname, '..', '..');
|
|
69
|
+
const tsconfigPath = (0, node_path_1.join)(packageRoot, 'tsconfig.json');
|
|
70
|
+
const dtoIndexPath = (0, node_path_1.join)(packageRoot, 'src', 'dto', 'index.ts');
|
|
71
|
+
// `dist/openapi` (same folder as this compiled script)
|
|
72
|
+
const outputDir = __dirname;
|
|
73
|
+
const outputJsonPath = (0, node_path_1.join)(outputDir, 'components.schemas.json');
|
|
74
|
+
// Temporary TS source file used only for schema generation.
|
|
75
|
+
//
|
|
76
|
+
// Important: this must live under `rootDir` (src/) because the generator
|
|
77
|
+
// type-checks using the project's tsconfig.
|
|
78
|
+
const tempRegistryPath = (0, node_path_1.join)(packageRoot, 'src', 'openapi', '_nauth-openapi-dto-registry.ts');
|
|
79
|
+
(0, node_fs_1.mkdirSync)(outputDir, { recursive: true });
|
|
80
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(tempRegistryPath), { recursive: true });
|
|
81
|
+
const dtoExportFiles = parseDtoExportFiles(dtoIndexPath);
|
|
82
|
+
const exportedSymbols = collectExportedSymbols(dtoExportFiles);
|
|
83
|
+
// Avoid generating an empty schema file if parsing fails.
|
|
84
|
+
if (exportedSymbols.length === 0) {
|
|
85
|
+
throw new Error(`OpenAPI generation failed: no exported DTO symbols found from ${dtoIndexPath}.`);
|
|
86
|
+
}
|
|
87
|
+
(0, node_fs_1.writeFileSync)(tempRegistryPath, renderRegistryType(exportedSymbols), 'utf8');
|
|
88
|
+
try {
|
|
89
|
+
const generatorConfig = {
|
|
90
|
+
path: tempRegistryPath,
|
|
91
|
+
tsconfig: tsconfigPath,
|
|
92
|
+
type: 'NAuthOpenApiDtoRegistry',
|
|
93
|
+
expose: 'all',
|
|
94
|
+
// We already run `tsc -b` as part of the build. Skipping type-check here
|
|
95
|
+
// avoids TypeScript project-file-list issues when generating schemas.
|
|
96
|
+
skipTypeCheck: true,
|
|
97
|
+
};
|
|
98
|
+
const generator = (0, ts_json_schema_generator_1.createGenerator)(generatorConfig);
|
|
99
|
+
const jsonSchema = generator.createSchema('NAuthOpenApiDtoRegistry');
|
|
100
|
+
const openApiDoc = buildOpenApiDocumentFromJsonSchema(jsonSchema);
|
|
101
|
+
(0, node_fs_1.writeFileSync)(outputJsonPath, `${JSON.stringify(openApiDoc, null, 2)}\n`, 'utf8');
|
|
102
|
+
}
|
|
103
|
+
finally {
|
|
104
|
+
// Best-effort cleanup. Even if this fails, it doesn't affect consumers.
|
|
105
|
+
(0, node_fs_1.rmSync)(tempRegistryPath, { force: true });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Parse `src/dto/index.ts` to get the list of `export * from './x';` files.
|
|
110
|
+
*/
|
|
111
|
+
function parseDtoExportFiles(dtoIndexPath) {
|
|
112
|
+
const content = (0, node_fs_1.readFileSync)(dtoIndexPath, 'utf8');
|
|
113
|
+
const baseDir = (0, node_path_1.dirname)(dtoIndexPath);
|
|
114
|
+
const files = new Set();
|
|
115
|
+
for (const line of content.split('\n')) {
|
|
116
|
+
const match = line.match(/^\s*export\s+\*\s+from\s+['"](\.\/[^'"]+)['"]\s*;\s*$/);
|
|
117
|
+
if (!match)
|
|
118
|
+
continue;
|
|
119
|
+
const relative = match[1];
|
|
120
|
+
const resolved = (0, node_path_1.join)(baseDir, `${relative}.ts`).replace(/\.ts\.ts$/, '.ts');
|
|
121
|
+
files.add(resolved);
|
|
122
|
+
}
|
|
123
|
+
return Array.from(files).sort();
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Collect exported symbol names from DTO source files.
|
|
127
|
+
*
|
|
128
|
+
* We intentionally keep this limited to common exported declarations:
|
|
129
|
+
* - `export class Foo`
|
|
130
|
+
* - `export interface Foo`
|
|
131
|
+
* - `export enum Foo`
|
|
132
|
+
* - `export type Foo = ...`
|
|
133
|
+
*/
|
|
134
|
+
function collectExportedSymbols(dtoFiles) {
|
|
135
|
+
const symbols = new Set();
|
|
136
|
+
for (const filePath of dtoFiles) {
|
|
137
|
+
const src = (0, node_fs_1.readFileSync)(filePath, 'utf8');
|
|
138
|
+
const sourceFile = ts.createSourceFile(filePath, src, ts.ScriptTarget.ES2022, true);
|
|
139
|
+
for (const statement of sourceFile.statements) {
|
|
140
|
+
if (!hasExportModifier(statement))
|
|
141
|
+
continue;
|
|
142
|
+
if (ts.isClassDeclaration(statement) && statement.name) {
|
|
143
|
+
symbols.add(statement.name.text);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
if (ts.isInterfaceDeclaration(statement) && statement.name) {
|
|
147
|
+
symbols.add(statement.name.text);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (ts.isEnumDeclaration(statement) && statement.name) {
|
|
151
|
+
symbols.add(statement.name.text);
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (ts.isTypeAliasDeclaration(statement) && statement.name) {
|
|
155
|
+
symbols.add(statement.name.text);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return Array.from(symbols).sort();
|
|
161
|
+
}
|
|
162
|
+
function hasExportModifier(node) {
|
|
163
|
+
const modifiers = ts.canHaveModifiers(node) ? ts.getModifiers(node) : undefined;
|
|
164
|
+
return !!modifiers?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Render a temporary DTO registry type referencing all exported DTO symbols.
|
|
168
|
+
*/
|
|
169
|
+
function renderRegistryType(symbols) {
|
|
170
|
+
const lines = [];
|
|
171
|
+
lines.push('/**');
|
|
172
|
+
lines.push(' * AUTO-GENERATED FILE (build-time only)');
|
|
173
|
+
lines.push(' *');
|
|
174
|
+
lines.push(' * This file is created temporarily during the core build to');
|
|
175
|
+
lines.push(' * generate OpenAPI component schemas. It is not published.');
|
|
176
|
+
lines.push(' */');
|
|
177
|
+
// Temp file lives in `src/openapi/`, so `../dto` resolves to `src/dto/`.
|
|
178
|
+
lines.push("import type * as Dtos from '../dto';");
|
|
179
|
+
lines.push('');
|
|
180
|
+
lines.push('export type NAuthOpenApiDtoRegistry = {');
|
|
181
|
+
for (const name of symbols) {
|
|
182
|
+
// Keep it purely in the type space.
|
|
183
|
+
lines.push(` ${name}: Dtos.${name};`);
|
|
184
|
+
}
|
|
185
|
+
lines.push('};');
|
|
186
|
+
lines.push('');
|
|
187
|
+
return lines.join('\n');
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Convert a JSON Schema document into an OpenAPI document containing
|
|
191
|
+
* `components.schemas`.
|
|
192
|
+
*
|
|
193
|
+
* OpenAPI tooling generally expects shared schemas to be addressed via:
|
|
194
|
+
* - `#/components/schemas/<Name>`
|
|
195
|
+
*
|
|
196
|
+
* JSON Schema generators often emit shared types under:
|
|
197
|
+
* - `#/definitions/<Name>`
|
|
198
|
+
*/
|
|
199
|
+
function buildOpenApiDocumentFromJsonSchema(jsonSchema) {
|
|
200
|
+
if (typeof jsonSchema !== 'object' || jsonSchema === null || !('definitions' in jsonSchema)) {
|
|
201
|
+
throw new Error('OpenAPI generation failed: JSON Schema missing `definitions`.');
|
|
202
|
+
}
|
|
203
|
+
const definitions = jsonSchema.definitions ?? {};
|
|
204
|
+
const schemas = {};
|
|
205
|
+
for (const [name, schema] of Object.entries(definitions)) {
|
|
206
|
+
schemas[name] = rewriteRefs(schema);
|
|
207
|
+
}
|
|
208
|
+
// Remove registry type if it got emitted as a definition.
|
|
209
|
+
delete schemas.NAuthOpenApiDtoRegistry;
|
|
210
|
+
// Also rewrite refs in case any schema object references the registry name.
|
|
211
|
+
for (const [name, schema] of Object.entries(schemas)) {
|
|
212
|
+
schemas[name] = rewriteRefs(schema);
|
|
213
|
+
}
|
|
214
|
+
return {
|
|
215
|
+
openapi: '3.0.3',
|
|
216
|
+
components: { schemas },
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Recursively rewrite JSON Schema `$ref` pointers to OpenAPI pointers.
|
|
221
|
+
*/
|
|
222
|
+
function rewriteRefs(value) {
|
|
223
|
+
if (Array.isArray(value)) {
|
|
224
|
+
return value.map((v) => rewriteRefs(v));
|
|
225
|
+
}
|
|
226
|
+
if (typeof value !== 'object' || value === null) {
|
|
227
|
+
return value;
|
|
228
|
+
}
|
|
229
|
+
const obj = value;
|
|
230
|
+
const next = {};
|
|
231
|
+
for (const [key, val] of Object.entries(obj)) {
|
|
232
|
+
if (key === '$ref' && typeof val === 'string') {
|
|
233
|
+
next[key] = val.replace(/^#\/definitions\//, '#/components/schemas/');
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
next[key] = rewriteRefs(val);
|
|
237
|
+
}
|
|
238
|
+
return next;
|
|
239
|
+
}
|
|
240
|
+
// ============================================================================
|
|
241
|
+
// CLI entrypoint (build-time)
|
|
242
|
+
// ============================================================================
|
|
243
|
+
// When executed directly by `node dist/openapi/generate-openapi.js`
|
|
244
|
+
if (require.main === module) {
|
|
245
|
+
generateOpenApiSchemas();
|
|
246
|
+
}
|
|
247
|
+
//# sourceMappingURL=generate-openapi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-openapi.js","sourceRoot":"","sources":["../../src/openapi/generate-openapi.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,wDAgDC;AA/ED,qCAAyE;AACzE,yCAAmD;AACnD,uEAAwE;AACxE,+CAAiC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,sBAAsB;IACpC,MAAM,WAAW,GAAG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CAAC;IAED,MAAM,GAAG,GAAG,KAAgC,CAAC;IAC7C,MAAM,IAAI,GAA4B,EAAE,CAAC;IAEzC,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7C,IAAI,GAAG,KAAK,MAAM,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YAC9C,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC,mBAAmB,EAAE,uBAAuB,CAAC,CAAC;YACtE,SAAS;QACX,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,+EAA+E;AAC/E,8BAA8B;AAC9B,+EAA+E;AAE/E,oEAAoE;AACpE,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,sBAAsB,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAPI component schemas exported by `@nauth-toolkit/core`.
|
|
3
|
+
*
|
|
4
|
+
* This is intentionally framework-agnostic: consumer apps can merge these
|
|
5
|
+
* schemas into their OpenAPI document (NestJS, Express, Fastify, etc.).
|
|
6
|
+
*
|
|
7
|
+
* Notes:
|
|
8
|
+
* - Schemas are generated at build time into `dist/openapi/components.schemas.json`
|
|
9
|
+
* - The schema names match the exported DTO/type names (e.g. `SignupDTO`)
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { loadNAuthOpenApiSchemas } from '@nauth-toolkit/core/openapi';
|
|
14
|
+
*
|
|
15
|
+
* // Merge into your OpenAPI document:
|
|
16
|
+
* const schemas = loadNAuthOpenApiSchemas();
|
|
17
|
+
* openapi.components = openapi.components ?? {};
|
|
18
|
+
* openapi.components.schemas = {
|
|
19
|
+
* ...(openapi.components.schemas ?? {}),
|
|
20
|
+
* ...schemas,
|
|
21
|
+
* };
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export interface NAuthOpenApiDocument {
|
|
25
|
+
/**
|
|
26
|
+
* OpenAPI version string.
|
|
27
|
+
*
|
|
28
|
+
* Example: `"3.0.3"`
|
|
29
|
+
*/
|
|
30
|
+
openapi: string;
|
|
31
|
+
/**
|
|
32
|
+
* OpenAPI components section containing reusable schemas.
|
|
33
|
+
*/
|
|
34
|
+
components: {
|
|
35
|
+
/**
|
|
36
|
+
* Generated schemas keyed by DTO/type name.
|
|
37
|
+
*
|
|
38
|
+
* Values are OpenAPI Schema Objects (kept as `unknown` to avoid introducing
|
|
39
|
+
* a runtime dependency on an OpenAPI typings package).
|
|
40
|
+
*/
|
|
41
|
+
schemas: Record<string, unknown>;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Load the generated OpenAPI document from the packaged JSON file.
|
|
46
|
+
*
|
|
47
|
+
* This is safe to call in production code. The JSON is generated during the
|
|
48
|
+
* library build and shipped in `dist/`.
|
|
49
|
+
*
|
|
50
|
+
* @returns The generated OpenAPI document containing `components.schemas`.
|
|
51
|
+
*
|
|
52
|
+
* @throws {Error} When the generated OpenAPI JSON file is missing or invalid.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* import { loadNAuthOpenApiDocument } from '@nauth-toolkit/core/openapi';
|
|
57
|
+
*
|
|
58
|
+
* const doc = loadNAuthOpenApiDocument();
|
|
59
|
+
* console.log(Object.keys(doc.components.schemas));
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function loadNAuthOpenApiDocument(): NAuthOpenApiDocument;
|
|
63
|
+
/**
|
|
64
|
+
* Load only the OpenAPI component schemas (`components.schemas`).
|
|
65
|
+
*
|
|
66
|
+
* @returns The generated OpenAPI schemas keyed by DTO/type name.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* import { loadNAuthOpenApiSchemas } from '@nauth-toolkit/core/openapi';
|
|
71
|
+
*
|
|
72
|
+
* const schemas = loadNAuthOpenApiSchemas();
|
|
73
|
+
* console.log(Object.keys(schemas));
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function loadNAuthOpenApiSchemas(): Record<string, unknown>;
|
|
77
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/openapi/index.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,UAAU,EAAE;QACV;;;;;WAKG;QACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAClC,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,wBAAwB,IAAI,oBAAoB,CAI/D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEjE"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadNAuthOpenApiDocument = loadNAuthOpenApiDocument;
|
|
4
|
+
exports.loadNAuthOpenApiSchemas = loadNAuthOpenApiSchemas;
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
/**
|
|
8
|
+
* Load the generated OpenAPI document from the packaged JSON file.
|
|
9
|
+
*
|
|
10
|
+
* This is safe to call in production code. The JSON is generated during the
|
|
11
|
+
* library build and shipped in `dist/`.
|
|
12
|
+
*
|
|
13
|
+
* @returns The generated OpenAPI document containing `components.schemas`.
|
|
14
|
+
*
|
|
15
|
+
* @throws {Error} When the generated OpenAPI JSON file is missing or invalid.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { loadNAuthOpenApiDocument } from '@nauth-toolkit/core/openapi';
|
|
20
|
+
*
|
|
21
|
+
* const doc = loadNAuthOpenApiDocument();
|
|
22
|
+
* console.log(Object.keys(doc.components.schemas));
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
function loadNAuthOpenApiDocument() {
|
|
26
|
+
const filePath = (0, node_path_1.join)(__dirname, 'components.schemas.json');
|
|
27
|
+
const json = (0, node_fs_1.readFileSync)(filePath, 'utf8');
|
|
28
|
+
return JSON.parse(json);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Load only the OpenAPI component schemas (`components.schemas`).
|
|
32
|
+
*
|
|
33
|
+
* @returns The generated OpenAPI schemas keyed by DTO/type name.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* import { loadNAuthOpenApiSchemas } from '@nauth-toolkit/core/openapi';
|
|
38
|
+
*
|
|
39
|
+
* const schemas = loadNAuthOpenApiSchemas();
|
|
40
|
+
* console.log(Object.keys(schemas));
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
function loadNAuthOpenApiSchemas() {
|
|
44
|
+
return loadNAuthOpenApiDocument().components.schemas;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/openapi/index.ts"],"names":[],"mappings":";;AAkEA,4DAIC;AAeD,0DAEC;AAvFD,qCAAuC;AACvC,yCAAiC;AA+CjC;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,wBAAwB;IACtC,MAAM,QAAQ,GAAG,IAAA,gBAAI,EAAC,SAAS,EAAE,yBAAyB,CAAC,CAAC;IAC5D,MAAM,IAAI,GAAG,IAAA,sBAAY,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC5C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAyB,CAAC;AAClD,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,uBAAuB;IACrC,OAAO,wBAAwB,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;AACvD,CAAC"}
|
|
@@ -76,8 +76,6 @@ export interface NAuthRequestAttributes {
|
|
|
76
76
|
nauthTokenDelivery?: 'json' | 'cookies';
|
|
77
77
|
/** Token delivery mode override (alias for nauthTokenDelivery for better naming) */
|
|
78
78
|
nauthTokenDeliveryOverride?: 'json' | 'cookies';
|
|
79
|
-
/** Skip reCAPTCHA validation for this route (set by @SkipRecaptcha()) */
|
|
80
|
-
nauthSkipRecaptcha?: boolean;
|
|
81
79
|
/** Require reCAPTCHA validation for this route (set by @RequireRecaptcha()) */
|
|
82
80
|
nauthRequireRecaptcha?: boolean;
|
|
83
81
|
/** Allow arbitrary string keys for extensibility */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../src/platform/interfaces.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,oEAAoE;IACpE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,gEAAgE;IAChE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,8CAA8C;IAC9C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB,2CAA2C;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEvC,2BAA2B;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAExC,oDAAoD;IACpD,QAA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|
|
244
244
|
/**
|
|
245
|
-
* Validate reCAPTCHA token if
|
|
245
|
+
* Validate reCAPTCHA token if required
|
|
246
246
|
*
|
|
247
|
-
*
|
|
247
|
+
* Explicit control via @RequireRecaptcha() decorator on routes.
|
|
248
|
+
* No automatic enforcement - consumer controls which endpoints need protection.
|
|
249
|
+
*
|
|
250
|
+
* Validation logic:
|
|
248
251
|
* 1. Skip if reCAPTCHA not enabled in config
|
|
249
|
-
* 2.
|
|
250
|
-
* 3.
|
|
251
|
-
* 4. Enforce if route has @RequireRecaptcha() decorator
|
|
252
|
-
* 5. Enforce if current delivery mode is in enforceFor array
|
|
253
|
-
* 6. If token provided (even when not enforced), validate it (opportunistic)
|
|
252
|
+
* 2. Enforce if route has @RequireRecaptcha() decorator (throws if token missing/invalid)
|
|
253
|
+
* 3. If token provided (even when not required), validate it opportunistically
|
|
254
254
|
*
|
|
255
255
|
* @param token - reCAPTCHA token from client (optional)
|
|
256
256
|
* @param clientIp - Client IP address for validation (optional)
|
|
@@ -262,6 +262,12 @@ export declare class AuthServiceInternalHelpers {
|
|
|
262
262
|
*
|
|
263
263
|
* @example
|
|
264
264
|
* ```typescript
|
|
265
|
+
* // In controller:
|
|
266
|
+
* @RequireRecaptcha()
|
|
267
|
+
* @Post('login')
|
|
268
|
+
* async login(@Body() dto: LoginDTO) { ... }
|
|
269
|
+
*
|
|
270
|
+
* // In AuthService.login():
|
|
265
271
|
* await this.helpers.validateRecaptchaIfNeeded(dto.recaptchaToken, clientInfo.ipAddress);
|
|
266
272
|
* ```
|
|
267
273
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-service-internal-helpers.d.ts","sourceRoot":"","sources":["../../src/services/auth-service-internal-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EA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I;IA+BpH;;;;;OAKG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAQhC;;;;;OAKG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAUhC
|
|
1
|
+
{"version":3,"file":"auth-service-internal-helpers.d.ts","sourceRoot":"","sources":["../../src/services/auth-service-internal-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,kCAAkC,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,4BAA4B,EAAE,MAAM,4CAA4C,CAAC;AAC1F,OAAO,EAAE,wBAAwB,IAAI,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAEzE,OAAO,EACL,qBAAqB,EAErB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,EAExB,gBAAgB,EACjB,MAAM,+BA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O,CAAC,IAAI,CAAC;IAwB3E;;;;;;;OAOG;IACG,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBjH;;;;;OAKG;IACH,gBAAgB,CAAC,QAAQ,EAAE;QAAE,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;KAAE,EAAE,YAAY,EAAE,OAAO,GAAG,IAAI;IA+BpH;;;;;OAKG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAQhC;;;;;OAKG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAUhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACG,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA8B5F;;;;;;;;;OASG;YACW,oBAAoB;CAqDnC"}
|
|
@@ -1072,15 +1072,15 @@ class AuthServiceInternalHelpers {
|
|
|
1072
1072
|
// reCAPTCHA Validation
|
|
1073
1073
|
// ============================================================================
|
|
1074
1074
|
/**
|
|
1075
|
-
* Validate reCAPTCHA token if
|
|
1075
|
+
* Validate reCAPTCHA token if required
|
|
1076
1076
|
*
|
|
1077
|
-
*
|
|
1077
|
+
* Explicit control via @RequireRecaptcha() decorator on routes.
|
|
1078
|
+
* No automatic enforcement - consumer controls which endpoints need protection.
|
|
1079
|
+
*
|
|
1080
|
+
* Validation logic:
|
|
1078
1081
|
* 1. Skip if reCAPTCHA not enabled in config
|
|
1079
|
-
* 2.
|
|
1080
|
-
* 3.
|
|
1081
|
-
* 4. Enforce if route has @RequireRecaptcha() decorator
|
|
1082
|
-
* 5. Enforce if current delivery mode is in enforceFor array
|
|
1083
|
-
* 6. If token provided (even when not enforced), validate it (opportunistic)
|
|
1082
|
+
* 2. Enforce if route has @RequireRecaptcha() decorator (throws if token missing/invalid)
|
|
1083
|
+
* 3. If token provided (even when not required), validate it opportunistically
|
|
1084
1084
|
*
|
|
1085
1085
|
* @param token - reCAPTCHA token from client (optional)
|
|
1086
1086
|
* @param clientIp - Client IP address for validation (optional)
|
|
@@ -1092,6 +1092,12 @@ class AuthServiceInternalHelpers {
|
|
|
1092
1092
|
*
|
|
1093
1093
|
* @example
|
|
1094
1094
|
* ```typescript
|
|
1095
|
+
* // In controller:
|
|
1096
|
+
* @RequireRecaptcha()
|
|
1097
|
+
* @Post('login')
|
|
1098
|
+
* async login(@Body() dto: LoginDTO) { ... }
|
|
1099
|
+
*
|
|
1100
|
+
* // In AuthService.login():
|
|
1095
1101
|
* await this.helpers.validateRecaptchaIfNeeded(dto.recaptchaToken, clientInfo.ipAddress);
|
|
1096
1102
|
* ```
|
|
1097
1103
|
*/
|
|
@@ -1101,39 +1107,18 @@ class AuthServiceInternalHelpers {
|
|
|
1101
1107
|
if (!recaptchaConfig?.enabled) {
|
|
1102
1108
|
return;
|
|
1103
1109
|
}
|
|
1104
|
-
//
|
|
1105
|
-
if (recaptchaConfig.skipInDevelopment && process.env.NODE_ENV !== 'production') {
|
|
1106
|
-
this.logger?.debug?.('Skipping reCAPTCHA validation in development mode');
|
|
1107
|
-
return;
|
|
1108
|
-
}
|
|
1109
|
-
// Get current request context for attributes set by decorators/helpers
|
|
1110
|
+
// Get current request context for attributes set by decorators
|
|
1110
1111
|
const req = context_storage_1.ContextStorage.get('REQUEST');
|
|
1111
|
-
//
|
|
1112
|
-
if (req?.attributes.nauthSkipRecaptcha === true) {
|
|
1113
|
-
this.logger?.debug?.('Skipping reCAPTCHA validation (explicit skip via decorator)');
|
|
1114
|
-
return;
|
|
1115
|
-
}
|
|
1116
|
-
// Priority 2: Explicit require via @RequireRecaptcha() decorator
|
|
1112
|
+
// Check if reCAPTCHA is explicitly required via @RequireRecaptcha() decorator
|
|
1117
1113
|
if (req?.attributes.nauthRequireRecaptcha === true) {
|
|
1118
|
-
this.logger?.debug?.('reCAPTCHA validation required (explicit
|
|
1114
|
+
this.logger?.debug?.('reCAPTCHA validation required (explicit @RequireRecaptcha() decorator)');
|
|
1119
1115
|
if (!token) {
|
|
1120
1116
|
throw new nauth_exception_1.NAuthException(error_codes_enum_1.AuthErrorCode.RECAPTCHA_REQUIRED, 'reCAPTCHA token is required');
|
|
1121
1117
|
}
|
|
1122
1118
|
await this.verifyRecaptchaToken(token, clientIp);
|
|
1123
1119
|
return;
|
|
1124
1120
|
}
|
|
1125
|
-
//
|
|
1126
|
-
const effectiveDelivery = req?.attributes.nauthTokenDeliveryOverride || this.config.tokenDelivery?.method;
|
|
1127
|
-
const shouldEnforce = recaptchaConfig.enforceFor?.includes(effectiveDelivery);
|
|
1128
|
-
if (shouldEnforce) {
|
|
1129
|
-
this.logger?.debug?.(`reCAPTCHA enforcement enabled for delivery mode: ${effectiveDelivery}`);
|
|
1130
|
-
if (!token) {
|
|
1131
|
-
throw new nauth_exception_1.NAuthException(error_codes_enum_1.AuthErrorCode.RECAPTCHA_REQUIRED, 'reCAPTCHA token is required for web authentication');
|
|
1132
|
-
}
|
|
1133
|
-
await this.verifyRecaptchaToken(token, clientIp);
|
|
1134
|
-
return;
|
|
1135
|
-
}
|
|
1136
|
-
// Priority 4: Opportunistic validation - if token provided, validate it
|
|
1121
|
+
// Opportunistic validation: if token provided, validate it (even when not required)
|
|
1137
1122
|
if (token) {
|
|
1138
1123
|
this.logger?.debug?.('reCAPTCHA token provided, performing opportunistic validation');
|
|
1139
1124
|
await this.verifyRecaptchaToken(token, clientIp);
|