@codecanva/nest-auth 0.1.0 → 0.2.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/INSTALLATION.md +682 -0
- package/README.md +200 -164
- package/dist/auth.module.d.ts.map +1 -1
- package/dist/auth.module.js +6 -0
- package/dist/auth.module.js.map +1 -1
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +270 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/templates.d.ts +21 -0
- package/dist/cli/templates.d.ts.map +1 -0
- package/dist/cli/templates.js +556 -0
- package/dist/cli/templates.js.map +1 -0
- package/dist/cli/utils.d.ts +55 -0
- package/dist/cli/utils.d.ts.map +1 -0
- package/dist/cli/utils.js +235 -0
- package/dist/cli/utils.js.map +1 -0
- package/dist/filters/auth-exception.filter.d.ts +20 -0
- package/dist/filters/auth-exception.filter.d.ts.map +1 -0
- package/dist/filters/auth-exception.filter.js +40 -0
- package/dist/filters/auth-exception.filter.js.map +1 -0
- package/dist/filters/index.d.ts +2 -0
- package/dist/filters/index.d.ts.map +1 -0
- package/dist/filters/index.js +18 -0
- package/dist/filters/index.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +112 -107
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ---------------------------------------------------------------------------
|
|
3
|
+
// Zero-dependency helpers for the `nest-auth` CLI: logging, safe file writes,
|
|
4
|
+
// .env merging, package-manager detection/install, and best-effort wiring of
|
|
5
|
+
// the host project's AppModule + main.ts.
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.log = exports.c = void 0;
|
|
9
|
+
exports.readText = readText;
|
|
10
|
+
exports.writeFileSafe = writeFileSafe;
|
|
11
|
+
exports.backup = backup;
|
|
12
|
+
exports.mergeEnvFile = mergeEnvFile;
|
|
13
|
+
exports.loadProject = loadProject;
|
|
14
|
+
exports.isNestProject = isNestProject;
|
|
15
|
+
exports.detectPackageManager = detectPackageManager;
|
|
16
|
+
exports.installCommand = installCommand;
|
|
17
|
+
exports.runInstall = runInstall;
|
|
18
|
+
exports.patchAppModule = patchAppModule;
|
|
19
|
+
exports.patchMain = patchMain;
|
|
20
|
+
exports.resolveDir = resolveDir;
|
|
21
|
+
const child_process_1 = require("child_process");
|
|
22
|
+
const fs_1 = require("fs");
|
|
23
|
+
const path_1 = require("path");
|
|
24
|
+
// --- Logging ---------------------------------------------------------------
|
|
25
|
+
const useColor = !!process.stdout.isTTY && !process.env.NO_COLOR;
|
|
26
|
+
const paint = (code, s) => useColor ? `\x1b[${code}m${s}\x1b[0m` : s;
|
|
27
|
+
exports.c = {
|
|
28
|
+
bold: (s) => paint('1', s),
|
|
29
|
+
dim: (s) => paint('2', s),
|
|
30
|
+
green: (s) => paint('32', s),
|
|
31
|
+
yellow: (s) => paint('33', s),
|
|
32
|
+
red: (s) => paint('31', s),
|
|
33
|
+
cyan: (s) => paint('36', s),
|
|
34
|
+
};
|
|
35
|
+
exports.log = {
|
|
36
|
+
info: (m) => console.log(m),
|
|
37
|
+
step: (m) => console.log(`${exports.c.cyan('›')} ${m}`),
|
|
38
|
+
ok: (m) => console.log(` ${exports.c.green('✓')} ${m}`),
|
|
39
|
+
skip: (m) => console.log(` ${exports.c.dim('•')} ${exports.c.dim(m)}`),
|
|
40
|
+
warn: (m) => console.log(` ${exports.c.yellow('!')} ${m}`),
|
|
41
|
+
err: (m) => console.error(`${exports.c.red('✗')} ${m}`),
|
|
42
|
+
};
|
|
43
|
+
// --- Filesystem ------------------------------------------------------------
|
|
44
|
+
function readText(path) {
|
|
45
|
+
return (0, fs_1.readFileSync)(path, 'utf8');
|
|
46
|
+
}
|
|
47
|
+
/** Write a file, creating parent dirs. Won't clobber an existing file unless `force`. */
|
|
48
|
+
function writeFileSafe(path, content, opts) {
|
|
49
|
+
const present = (0, fs_1.existsSync)(path);
|
|
50
|
+
if (present && !opts.force)
|
|
51
|
+
return 'skipped';
|
|
52
|
+
if (opts.dryRun)
|
|
53
|
+
return 'would-write';
|
|
54
|
+
(0, fs_1.mkdirSync)((0, path_1.dirname)(path), { recursive: true });
|
|
55
|
+
(0, fs_1.writeFileSync)(path, content, 'utf8');
|
|
56
|
+
return 'written';
|
|
57
|
+
}
|
|
58
|
+
/** Copy `path` to `path.bak` (or `.bak.1`, `.bak.2`, …) before mutating it. */
|
|
59
|
+
function backup(path, dryRun) {
|
|
60
|
+
if (dryRun)
|
|
61
|
+
return `${path}.bak`;
|
|
62
|
+
let dest = `${path}.bak`;
|
|
63
|
+
let n = 1;
|
|
64
|
+
while ((0, fs_1.existsSync)(dest))
|
|
65
|
+
dest = `${path}.bak.${n++}`;
|
|
66
|
+
(0, fs_1.copyFileSync)(path, dest);
|
|
67
|
+
return dest;
|
|
68
|
+
}
|
|
69
|
+
// --- .env merging ----------------------------------------------------------
|
|
70
|
+
/** Append any missing keys to an env file. Returns the keys actually added. */
|
|
71
|
+
function mergeEnvFile(path, entries, dryRun) {
|
|
72
|
+
const existing = (0, fs_1.existsSync)(path) ? readText(path) : '';
|
|
73
|
+
const present = new Set(existing
|
|
74
|
+
.split('\n')
|
|
75
|
+
.map((l) => l.trim())
|
|
76
|
+
.filter((l) => l && !l.startsWith('#'))
|
|
77
|
+
.map((l) => l.split('=')[0].trim()));
|
|
78
|
+
const missing = entries.filter((e) => !present.has(e.key));
|
|
79
|
+
if (missing.length === 0)
|
|
80
|
+
return [];
|
|
81
|
+
if (dryRun)
|
|
82
|
+
return missing.map((e) => e.key);
|
|
83
|
+
const block = missing
|
|
84
|
+
.map((e) => `${e.comment ? `# ${e.comment}\n` : ''}${e.key}=${e.value}`)
|
|
85
|
+
.join('\n');
|
|
86
|
+
const needsNl = existing.length > 0 && !existing.endsWith('\n');
|
|
87
|
+
const prefix = existing.length === 0 ? '' : `${needsNl ? '\n' : ''}\n`;
|
|
88
|
+
(0, fs_1.writeFileSync)(path, `${existing}${prefix}${block}\n`, 'utf8');
|
|
89
|
+
return missing.map((e) => e.key);
|
|
90
|
+
}
|
|
91
|
+
function loadProject(root) {
|
|
92
|
+
const pkgPath = (0, path_1.join)(root, 'package.json');
|
|
93
|
+
if (!(0, fs_1.existsSync)(pkgPath))
|
|
94
|
+
return null;
|
|
95
|
+
let pkgJson;
|
|
96
|
+
try {
|
|
97
|
+
pkgJson = JSON.parse(readText(pkgPath));
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
const srcDir = (0, fs_1.existsSync)((0, path_1.join)(root, 'src')) ? (0, path_1.join)(root, 'src') : root;
|
|
103
|
+
const appModulePath = firstExisting([
|
|
104
|
+
(0, path_1.join)(srcDir, 'app.module.ts'),
|
|
105
|
+
(0, path_1.join)(root, 'app.module.ts'),
|
|
106
|
+
]);
|
|
107
|
+
const mainPath = firstExisting([(0, path_1.join)(srcDir, 'main.ts'), (0, path_1.join)(root, 'main.ts')]);
|
|
108
|
+
return { root, srcDir, appModulePath, mainPath, pkgJson };
|
|
109
|
+
}
|
|
110
|
+
function isNestProject(p) {
|
|
111
|
+
const deps = { ...p.pkgJson.dependencies, ...p.pkgJson.devDependencies };
|
|
112
|
+
return Boolean(deps['@nestjs/core'] || deps['@nestjs/common']);
|
|
113
|
+
}
|
|
114
|
+
function firstExisting(paths) {
|
|
115
|
+
for (const p of paths)
|
|
116
|
+
if ((0, fs_1.existsSync)(p))
|
|
117
|
+
return p;
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
function detectPackageManager(root) {
|
|
121
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(root, 'pnpm-lock.yaml')))
|
|
122
|
+
return 'pnpm';
|
|
123
|
+
if ((0, fs_1.existsSync)((0, path_1.join)(root, 'yarn.lock')))
|
|
124
|
+
return 'yarn';
|
|
125
|
+
return 'npm';
|
|
126
|
+
}
|
|
127
|
+
function installCommand(pm, deps, dev) {
|
|
128
|
+
const add = pm === 'npm' ? 'install' : 'add';
|
|
129
|
+
const devFlag = dev ? ['-D'] : [];
|
|
130
|
+
return { cmd: pm, args: [add, ...devFlag, ...deps] };
|
|
131
|
+
}
|
|
132
|
+
function runInstall(root, pm, deps, devDeps) {
|
|
133
|
+
const groups = [
|
|
134
|
+
{ list: deps, dev: false },
|
|
135
|
+
{ list: devDeps, dev: true },
|
|
136
|
+
];
|
|
137
|
+
for (const g of groups) {
|
|
138
|
+
if (g.list.length === 0)
|
|
139
|
+
continue;
|
|
140
|
+
const { cmd, args } = installCommand(pm, g.list, g.dev);
|
|
141
|
+
exports.log.step(`${cmd} ${args.join(' ')}`);
|
|
142
|
+
const res = (0, child_process_1.spawnSync)(cmd, args, {
|
|
143
|
+
cwd: root,
|
|
144
|
+
stdio: 'inherit',
|
|
145
|
+
shell: true, // resolve npm/yarn/pnpm(.cmd) on Windows
|
|
146
|
+
});
|
|
147
|
+
if (res.status !== 0) {
|
|
148
|
+
exports.log.err(`Dependency install failed (${cmd} exited ${res.status ?? 'null'}).`);
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
// --- Source patching -------------------------------------------------------
|
|
155
|
+
/** Insert an import statement after the last existing import in a source file. */
|
|
156
|
+
function insertImport(src, importLine) {
|
|
157
|
+
if (src.includes(importLine))
|
|
158
|
+
return src;
|
|
159
|
+
const lines = src.split('\n');
|
|
160
|
+
let lastImport = -1;
|
|
161
|
+
for (let i = 0; i < lines.length; i++) {
|
|
162
|
+
if (/^\s*import\b/.test(lines[i]) || /\bfrom\s+['"][^'"]+['"];?\s*$/.test(lines[i])) {
|
|
163
|
+
lastImport = i;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (lastImport === -1)
|
|
167
|
+
return `${importLine}\n${src}`;
|
|
168
|
+
lines.splice(lastImport + 1, 0, importLine);
|
|
169
|
+
return lines.join('\n');
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Add the integration module to AppModule: an import statement plus an entry at
|
|
173
|
+
* the head of the `@Module({ imports: [ ... ] })` array. Backs up first.
|
|
174
|
+
*/
|
|
175
|
+
function patchAppModule(path, moduleName, importPath, dryRun) {
|
|
176
|
+
let src = readText(path);
|
|
177
|
+
if (new RegExp(`\\b${moduleName}\\b`).test(src))
|
|
178
|
+
return 'already';
|
|
179
|
+
const withImport = insertImport(src, `import { ${moduleName} } from '${importPath}';`);
|
|
180
|
+
const emptyImportsRe = /(@Module\(\s*\{[\s\S]*?imports\s*:\s*\[)\s*\]/;
|
|
181
|
+
const importsArrayRe = /(@Module\(\s*\{[\s\S]*?imports\s*:\s*\[)/;
|
|
182
|
+
let patched;
|
|
183
|
+
if (emptyImportsRe.test(withImport)) {
|
|
184
|
+
// `imports: []` → `imports: [AuthIntegrationModule]`
|
|
185
|
+
patched = withImport.replace(emptyImportsRe, `$1${moduleName}]`);
|
|
186
|
+
}
|
|
187
|
+
else if (importsArrayRe.test(withImport)) {
|
|
188
|
+
patched = withImport.replace(importsArrayRe, `$1\n ${moduleName},`);
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
// No imports array — add one right after `@Module({`.
|
|
192
|
+
const moduleOpenRe = /(@Module\(\s*\{)/;
|
|
193
|
+
if (!moduleOpenRe.test(withImport))
|
|
194
|
+
return 'manual';
|
|
195
|
+
patched = withImport.replace(moduleOpenRe, `$1\n imports: [${moduleName}],`);
|
|
196
|
+
}
|
|
197
|
+
if (dryRun)
|
|
198
|
+
return 'patched';
|
|
199
|
+
backup(path);
|
|
200
|
+
(0, fs_1.writeFileSync)(path, patched, 'utf8');
|
|
201
|
+
return 'patched';
|
|
202
|
+
}
|
|
203
|
+
/** Ensure main.ts installs a global ValidationPipe. Backs up first. */
|
|
204
|
+
function patchMain(path, dryRun) {
|
|
205
|
+
let src = readText(path);
|
|
206
|
+
if (/useGlobalPipes/.test(src))
|
|
207
|
+
return 'already';
|
|
208
|
+
if (!/\bValidationPipe\b/.test(src)) {
|
|
209
|
+
const commonRe = /import\s*\{([^}]*)\}\s*from\s*(['"])@nestjs\/common\2;?/;
|
|
210
|
+
if (commonRe.test(src)) {
|
|
211
|
+
src = src.replace(commonRe, (_m, names, q) => {
|
|
212
|
+
const trimmed = names.replace(/\s+$/, '');
|
|
213
|
+
const sep = trimmed.trim().endsWith(',') ? '' : ',';
|
|
214
|
+
return `import {${trimmed}${sep} ValidationPipe } from ${q}@nestjs/common${q};`;
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
src = insertImport(src, `import { ValidationPipe } from '@nestjs/common';`);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
const createRe = /(const\s+app\s*=\s*await\s+NestFactory\.create\([^;]*\);)/;
|
|
222
|
+
if (!createRe.test(src))
|
|
223
|
+
return 'manual';
|
|
224
|
+
src = src.replace(createRe, `$1\n app.useGlobalPipes(new ValidationPipe({ whitelist: true, transform: true }));`);
|
|
225
|
+
if (dryRun)
|
|
226
|
+
return 'patched';
|
|
227
|
+
backup(path);
|
|
228
|
+
(0, fs_1.writeFileSync)(path, src, 'utf8');
|
|
229
|
+
return 'patched';
|
|
230
|
+
}
|
|
231
|
+
// --- Misc ------------------------------------------------------------------
|
|
232
|
+
function resolveDir(input) {
|
|
233
|
+
return (0, path_1.resolve)(process.cwd(), input ?? '.');
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/lib/cli/utils.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,8EAA8E;AAC9E,6EAA6E;AAC7E,0CAA0C;AAC1C,8EAA8E;;;AAuC9E,4BAEC;AAUD,sCAWC;AAGD,wBAOC;AAKD,oCAy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,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,KAAa,EAAE,CAAS,EAAE,EAAE;gBAC3D,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;gBAC1C,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;gBACpD,OAAO,WAAW,OAAO,GAAG,GAAG,0BAA0B,CAAC,iBAAiB,CAAC,GAAG,CAAC;YAClF,CAAC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,GAAG,GAAG,YAAY,CAAC,GAAG,EAAE,kDAAkD,CAAC,CAAC;QAC9E,CAAC;IACH,CAAC;IAED,MAAM,QAAQ,GAAG,2DAA2D,CAAC;IAC7E,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;QAAE,OAAO,QAAQ,CAAC;IACzC,GAAG,GAAG,GAAG,CAAC,OAAO,CACf,QAAQ,EACR,qFAAqF,CACtF,CAAC;IAEF,IAAI,MAAM;QAAE,OAAO,SAAS,CAAC;IAC7B,MAAM,CAAC,IAAI,CAAC,CAAC;IACb,IAAA,kBAAa,EAAC,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IACjC,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,8EAA8E;AAE9E,SAAgB,UAAU,CAAC,KAAyB;IAClD,OAAO,IAAA,cAAO,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,IAAI,GAAG,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ArgumentsHost } from '@nestjs/common';
|
|
2
|
+
import { BaseExceptionFilter } from '@nestjs/core';
|
|
3
|
+
import { AuthError } from '../errors/auth.errors';
|
|
4
|
+
/**
|
|
5
|
+
* Translates the library's framework-agnostic {@link AuthError} domain errors
|
|
6
|
+
* into proper NestJS HTTP responses.
|
|
7
|
+
*
|
|
8
|
+
* Without this, a thrown `AuthError` (a plain `Error`, not an `HttpException`)
|
|
9
|
+
* is treated by Nest's default exception layer as an unexpected failure and
|
|
10
|
+
* rendered as `500 Internal Server Error` — so a failed login would never
|
|
11
|
+
* surface as `401 Invalid credentials`.
|
|
12
|
+
*
|
|
13
|
+
* `AuthModule.forRootAsync` registers this globally via `APP_FILTER`, so
|
|
14
|
+
* consumers get correct status codes without writing per-route try/catch.
|
|
15
|
+
*/
|
|
16
|
+
export declare class AuthExceptionFilter extends BaseExceptionFilter {
|
|
17
|
+
catch(err: AuthError, host: ArgumentsHost): void;
|
|
18
|
+
private toHttpException;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=auth-exception.filter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-exception.filter.d.ts","sourceRoot":"","sources":["../../src/lib/filters/auth-exception.filter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAId,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD;;;;;;;;;;;GAWG;AACH,qBACa,mBAAoB,SAAQ,mBAAmB;IAC1D,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI;IAIhD,OAAO,CAAC,eAAe;CAMxB"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.AuthExceptionFilter = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const core_1 = require("@nestjs/core");
|
|
12
|
+
const auth_errors_1 = require("../errors/auth.errors");
|
|
13
|
+
/**
|
|
14
|
+
* Translates the library's framework-agnostic {@link AuthError} domain errors
|
|
15
|
+
* into proper NestJS HTTP responses.
|
|
16
|
+
*
|
|
17
|
+
* Without this, a thrown `AuthError` (a plain `Error`, not an `HttpException`)
|
|
18
|
+
* is treated by Nest's default exception layer as an unexpected failure and
|
|
19
|
+
* rendered as `500 Internal Server Error` — so a failed login would never
|
|
20
|
+
* surface as `401 Invalid credentials`.
|
|
21
|
+
*
|
|
22
|
+
* `AuthModule.forRootAsync` registers this globally via `APP_FILTER`, so
|
|
23
|
+
* consumers get correct status codes without writing per-route try/catch.
|
|
24
|
+
*/
|
|
25
|
+
let AuthExceptionFilter = class AuthExceptionFilter extends core_1.BaseExceptionFilter {
|
|
26
|
+
catch(err, host) {
|
|
27
|
+
super.catch(this.toHttpException(err), host);
|
|
28
|
+
}
|
|
29
|
+
toHttpException(err) {
|
|
30
|
+
// Every current auth failure is an authentication problem → 401.
|
|
31
|
+
// Branch here (e.g. NotFoundException for UserNotFoundError) if that
|
|
32
|
+
// changes in future.
|
|
33
|
+
return new common_1.UnauthorizedException(err.message);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
exports.AuthExceptionFilter = AuthExceptionFilter;
|
|
37
|
+
exports.AuthExceptionFilter = AuthExceptionFilter = __decorate([
|
|
38
|
+
(0, common_1.Catch)(auth_errors_1.AuthError)
|
|
39
|
+
], AuthExceptionFilter);
|
|
40
|
+
//# sourceMappingURL=auth-exception.filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-exception.filter.js","sourceRoot":"","sources":["../../src/lib/filters/auth-exception.filter.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAKwB;AACxB,uCAAmD;AACnD,uDAAkD;AAElD;;;;;;;;;;;GAWG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,0BAAmB;IAC1D,KAAK,CAAC,GAAc,EAAE,IAAmB;QACvC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;IAEO,eAAe,CAAC,GAAc;QACpC,iEAAiE;QACjE,qEAAqE;QACrE,qBAAqB;QACrB,OAAO,IAAI,8BAAqB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC;CACF,CAAA;AAXY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,cAAK,EAAC,uBAAS,CAAC;GACJ,mBAAmB,CAW/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/filters/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./auth-exception.filter"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/filters/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type { AuthTokens, LoginResult } from './auth.service';
|
|
|
4
4
|
export { JWT_STRATEGY_NAME, REFRESH_STRATEGY_NAME, REFRESH_TOKEN_STORE, USER_VALIDATOR, AUTH_MODULE_OPTIONS, IS_PUBLIC_KEY, } from './auth.constants';
|
|
5
5
|
export * from './decorators';
|
|
6
6
|
export * from './guards';
|
|
7
|
+
export * from './filters';
|
|
7
8
|
export * from './dto';
|
|
8
9
|
export * from './interfaces';
|
|
9
10
|
export * from './errors/auth.errors';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,aAAa,GACd,MAAM,kBAAkB,CAAC;AAE1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,YAAY,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,mBAAmB,EACnB,aAAa,GACd,MAAM,kBAAkB,CAAC;AAE1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC;AACrC,YAAY,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -28,6 +28,7 @@ Object.defineProperty(exports, "AUTH_MODULE_OPTIONS", { enumerable: true, get: f
|
|
|
28
28
|
Object.defineProperty(exports, "IS_PUBLIC_KEY", { enumerable: true, get: function () { return auth_constants_1.IS_PUBLIC_KEY; } });
|
|
29
29
|
__exportStar(require("./decorators"), exports);
|
|
30
30
|
__exportStar(require("./guards"), exports);
|
|
31
|
+
__exportStar(require("./filters"), exports);
|
|
31
32
|
__exportStar(require("./dto"), exports);
|
|
32
33
|
__exportStar(require("./interfaces"), exports);
|
|
33
34
|
__exportStar(require("./errors/auth.errors"), exports);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AAGpB,mDAO0B;AANxB,mHAAA,iBAAiB,OAAA;AACjB,uHAAA,qBAAqB,OAAA;AACrB,qHAAA,mBAAmB,OAAA;AACnB,gHAAA,cAAc,OAAA;AACd,qHAAA,mBAAmB,OAAA;AACnB,+GAAA,aAAa,OAAA;AAGf,+CAA6B;AAC7B,2CAAyB;AACzB,wCAAsB;AACtB,+CAA6B;AAC7B,uDAAqC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AACnB,+CAA6C;AAApC,2GAAA,WAAW,OAAA;AAGpB,mDAO0B;AANxB,mHAAA,iBAAiB,OAAA;AACjB,uHAAA,qBAAqB,OAAA;AACrB,qHAAA,mBAAmB,OAAA;AACnB,gHAAA,cAAc,OAAA;AACd,qHAAA,mBAAmB,OAAA;AACnB,+GAAA,aAAa,OAAA;AAGf,+CAA6B;AAC7B,2CAAyB;AACzB,4CAA0B;AAC1B,wCAAsB;AACtB,+CAA6B;AAC7B,uDAAqC"}
|
package/package.json
CHANGED
|
@@ -1,107 +1,112 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@codecanva/nest-auth",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Reusable NestJS authentication module with JWT access + refresh-token rotation, multi-device sessions, and pluggable persistence.",
|
|
5
|
-
"author": "
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"keywords": [
|
|
8
|
-
"nestjs",
|
|
9
|
-
"auth",
|
|
10
|
-
"jwt",
|
|
11
|
-
"refresh-token",
|
|
12
|
-
"passport",
|
|
13
|
-
"authentication"
|
|
14
|
-
],
|
|
15
|
-
"main": "dist/index.js",
|
|
16
|
-
"types": "dist/index.d.ts",
|
|
17
|
-
"
|
|
18
|
-
"dist"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"@
|
|
60
|
-
"@
|
|
61
|
-
"@nestjs/
|
|
62
|
-
"@nestjs/
|
|
63
|
-
"@nestjs/
|
|
64
|
-
"@
|
|
65
|
-
"@
|
|
66
|
-
"@
|
|
67
|
-
"@
|
|
68
|
-
"@
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"prettier": "^
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
"
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
"
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
"
|
|
100
|
-
|
|
101
|
-
"
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@codecanva/nest-auth",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Reusable NestJS authentication module with JWT access + refresh-token rotation, multi-device sessions, and pluggable persistence.",
|
|
5
|
+
"author": "amitsingh",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"nestjs",
|
|
9
|
+
"auth",
|
|
10
|
+
"jwt",
|
|
11
|
+
"refresh-token",
|
|
12
|
+
"passport",
|
|
13
|
+
"authentication"
|
|
14
|
+
],
|
|
15
|
+
"main": "dist/index.js",
|
|
16
|
+
"types": "dist/index.d.ts",
|
|
17
|
+
"bin": {
|
|
18
|
+
"nest-auth": "dist/cli/index.js"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md",
|
|
23
|
+
"INSTALLATION.md"
|
|
24
|
+
],
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build:lib": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.lib.json",
|
|
30
|
+
"build:demo": "nest build",
|
|
31
|
+
"cli": "node dist/cli/index.js",
|
|
32
|
+
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
33
|
+
"start": "nest start",
|
|
34
|
+
"start:dev": "nest start --watch",
|
|
35
|
+
"start:debug": "nest start --debug --watch",
|
|
36
|
+
"start:prod": "node dist-demo/main",
|
|
37
|
+
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
|
38
|
+
"test": "jest",
|
|
39
|
+
"test:watch": "jest --watch",
|
|
40
|
+
"test:cov": "jest --coverage",
|
|
41
|
+
"test:e2e": "jest --config ./test/jest-e2e.json",
|
|
42
|
+
"prepublishOnly": "npm run build:lib",
|
|
43
|
+
"publish:lib": "npm publish"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@nestjs/common": "^10.0.0 || ^11.0.0",
|
|
47
|
+
"@nestjs/core": "^10.0.0 || ^11.0.0",
|
|
48
|
+
"@nestjs/jwt": "^10.0.0 || ^11.0.0",
|
|
49
|
+
"@nestjs/passport": "^10.0.0 || ^11.0.0",
|
|
50
|
+
"class-transformer": "^0.5.0",
|
|
51
|
+
"class-validator": "^0.14.0",
|
|
52
|
+
"passport": "^0.7.0",
|
|
53
|
+
"passport-jwt": "^4.0.0",
|
|
54
|
+
"reflect-metadata": "^0.2.0",
|
|
55
|
+
"rxjs": "^7.8.0"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@eslint/eslintrc": "^3.2.0",
|
|
60
|
+
"@eslint/js": "^9.18.0",
|
|
61
|
+
"@nestjs/cli": "^11.0.0",
|
|
62
|
+
"@nestjs/common": "^11.0.1",
|
|
63
|
+
"@nestjs/core": "^11.0.1",
|
|
64
|
+
"@nestjs/jwt": "^11.0.0",
|
|
65
|
+
"@nestjs/passport": "^11.0.5",
|
|
66
|
+
"@nestjs/platform-express": "^11.0.1",
|
|
67
|
+
"@nestjs/schematics": "^11.0.0",
|
|
68
|
+
"@nestjs/testing": "^11.0.1",
|
|
69
|
+
"@types/express": "^5.0.0",
|
|
70
|
+
"@types/jest": "^30.0.0",
|
|
71
|
+
"@types/node": "^24.0.0",
|
|
72
|
+
"@types/passport-jwt": "^4.0.1",
|
|
73
|
+
"@types/supertest": "^7.0.0",
|
|
74
|
+
"class-transformer": "^0.5.1",
|
|
75
|
+
"class-validator": "^0.14.1",
|
|
76
|
+
"eslint": "^9.18.0",
|
|
77
|
+
"eslint-config-prettier": "^10.0.1",
|
|
78
|
+
"eslint-plugin-prettier": "^5.2.2",
|
|
79
|
+
"globals": "^17.0.0",
|
|
80
|
+
"jest": "^30.0.0",
|
|
81
|
+
"passport": "^0.7.0",
|
|
82
|
+
"passport-jwt": "^4.0.1",
|
|
83
|
+
"prettier": "^3.4.2",
|
|
84
|
+
"reflect-metadata": "^0.2.2",
|
|
85
|
+
"rxjs": "^7.8.1",
|
|
86
|
+
"source-map-support": "^0.5.21",
|
|
87
|
+
"supertest": "^7.0.0",
|
|
88
|
+
"ts-jest": "^29.2.5",
|
|
89
|
+
"ts-loader": "^9.5.2",
|
|
90
|
+
"ts-node": "^10.9.2",
|
|
91
|
+
"tsconfig-paths": "^4.2.0",
|
|
92
|
+
"typescript": "^5.7.3",
|
|
93
|
+
"typescript-eslint": "^8.20.0"
|
|
94
|
+
},
|
|
95
|
+
"jest": {
|
|
96
|
+
"moduleFileExtensions": [
|
|
97
|
+
"js",
|
|
98
|
+
"json",
|
|
99
|
+
"ts"
|
|
100
|
+
],
|
|
101
|
+
"rootDir": "src",
|
|
102
|
+
"testRegex": ".*\\.spec\\.ts$",
|
|
103
|
+
"transform": {
|
|
104
|
+
"^.+\\.(t|j)s$": "ts-jest"
|
|
105
|
+
},
|
|
106
|
+
"collectCoverageFrom": [
|
|
107
|
+
"**/*.(t|j)s"
|
|
108
|
+
],
|
|
109
|
+
"coverageDirectory": "../coverage",
|
|
110
|
+
"testEnvironment": "node"
|
|
111
|
+
}
|
|
112
|
+
}
|