@tsed/cli-plugin-oidc-provider 6.6.3 → 7.0.0-alpha.2
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/lib/esm/CliPluginOidcProviderModule.js +17 -22
- package/lib/esm/hooks/OidcProviderInitHook.js +92 -49
- package/{templates/init/src/config/oidc/index.ts.hbs → lib/esm/templates/index.template.js} +13 -3
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/types/CliPluginOidcProviderModule.d.ts +3 -2
- package/lib/types/hooks/OidcProviderInitHook.d.ts +9 -9
- package/lib/types/templates/index.template.d.ts +9 -0
- package/package.json +8 -5
- package/templates/{init/src → src}/interactions/__mock__/oidcContext.fixture.ts +2 -2
- /package/templates/{init/src → src}/controllers/oidc/InteractionsController.spec.ts +0 -0
- /package/templates/{init/src → src}/controllers/oidc/InteractionsController.ts +0 -0
- /package/templates/{init/src → src}/interactions/AbortInteraction.ts +0 -0
- /package/templates/{init/src → src}/interactions/ConsentInteraction.spec.ts +0 -0
- /package/templates/{init/src → src}/interactions/ConsentInteraction.ts +0 -0
- /package/templates/{init/src → src}/interactions/CustomInteraction.ts +0 -0
- /package/templates/{init/src → src}/interactions/LoginInteraction.spec.ts +0 -0
- /package/templates/{init/src → src}/interactions/LoginInteraction.ts +0 -0
- /package/templates/{init/src → src}/models/Account.ts +0 -0
- /package/templates/{init/src → src}/services/Accounts.ts +0 -0
- /package/templates/{init/views → views}/consent.ejs +0 -0
- /package/templates/{init/views → views}/forms/consent-form.ejs +0 -0
- /package/templates/{init/views → views}/forms/login-form.ejs +0 -0
- /package/templates/{init/views → views}/forms/select-account-form.ejs +0 -0
- /package/templates/{init/views → views}/login.ejs +0 -0
- /package/templates/{init/views → views}/partials/footer.ejs +0 -0
- /package/templates/{init/views → views}/partials/header.ejs +0 -0
- /package/templates/{init/views → views}/partials/login-help.ejs +0 -0
- /package/templates/{init/views → views}/repost.ejs +0 -0
- /package/templates/{init/views → views}/select_account.ejs +0 -0
|
@@ -1,29 +1,24 @@
|
|
|
1
|
-
import { __decorate
|
|
2
|
-
import
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import "./templates/index.template.js";
|
|
3
|
+
import { Module, ProjectPackageJson } from "@tsed/cli-core";
|
|
3
4
|
import { OidcProviderInitHook } from "./hooks/OidcProviderInitHook.js";
|
|
4
5
|
let CliPluginOidcProviderModule = class CliPluginOidcProviderModule {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
6
|
+
$alterPackageJson(packageJson, data) {
|
|
7
|
+
if (data.oidc) {
|
|
8
|
+
packageJson.addDependencies({
|
|
9
|
+
"oidc-provider": "latest",
|
|
10
|
+
"@tsed/oidc-provider": "latest",
|
|
11
|
+
"@tsed/jwks": "latest",
|
|
12
|
+
"@tsed/adapters": "latest",
|
|
13
|
+
bcrypt: "latest"
|
|
14
|
+
});
|
|
15
|
+
packageJson.addDevDependencies({
|
|
16
|
+
"@types/oidc-provider": "latest"
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return packageJson;
|
|
19
20
|
}
|
|
20
21
|
};
|
|
21
|
-
__decorate([
|
|
22
|
-
OnAdd("@tsed/cli-plugin-oidc-provider"),
|
|
23
|
-
__metadata("design:type", Function),
|
|
24
|
-
__metadata("design:paramtypes", []),
|
|
25
|
-
__metadata("design:returntype", void 0)
|
|
26
|
-
], CliPluginOidcProviderModule.prototype, "install", null);
|
|
27
22
|
CliPluginOidcProviderModule = __decorate([
|
|
28
23
|
Module({
|
|
29
24
|
imports: [OidcProviderInitHook]
|
|
@@ -1,53 +1,96 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Injectable } from "@tsed/di";
|
|
1
|
+
import { ProjectClient, render } from "@tsed/cli";
|
|
2
|
+
import { injectable } from "@tsed/di";
|
|
3
|
+
import { SyntaxKind } from "ts-morph";
|
|
5
4
|
import { TEMPLATE_DIR } from "../utils/templateDir.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
onExec(ctx) {
|
|
5
|
+
export class OidcProviderInitHook {
|
|
6
|
+
$alterRenderFiles(files, data) {
|
|
7
|
+
if (!data.oidc) {
|
|
8
|
+
return files;
|
|
9
|
+
}
|
|
12
10
|
return [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
11
|
+
...files,
|
|
12
|
+
...[
|
|
13
|
+
"/src/controllers/oidc/InteractionsController.ts",
|
|
14
|
+
data.testing && "/src/controllers/oidc/InteractionsController.spec.ts",
|
|
15
|
+
"/src/interactions/ConsentInteraction.ts",
|
|
16
|
+
data.testing && "/src/interactions/ConsentInteraction.spec.ts",
|
|
17
|
+
"/src/interactions/CustomInteraction.ts",
|
|
18
|
+
"/src/interactions/LoginInteraction.ts",
|
|
19
|
+
data.testing && "/src/interactions/LoginInteraction.spec.ts",
|
|
20
|
+
data.testing && "/src/interactions/__mock__/oidcContext.fixture.ts",
|
|
21
|
+
"/src/models/Account.ts",
|
|
22
|
+
"/src/services/Accounts.ts",
|
|
23
|
+
"/views/forms/consent-form.ejs",
|
|
24
|
+
"/views/forms/login-form.ejs",
|
|
25
|
+
"/views/forms/select-account-form.ejs",
|
|
26
|
+
"/views/partials/footer.ejs",
|
|
27
|
+
"/views/partials/header.ejs",
|
|
28
|
+
"/views/partials/login-help.ejs",
|
|
29
|
+
"/views/consent.ejs",
|
|
30
|
+
"/views/login.ejs",
|
|
31
|
+
"/views/repost.ejs",
|
|
32
|
+
"/views/select_account.ejs"
|
|
33
|
+
]
|
|
34
|
+
.filter(Boolean)
|
|
35
|
+
.map((path) => {
|
|
36
|
+
return {
|
|
37
|
+
id: path,
|
|
38
|
+
from: TEMPLATE_DIR
|
|
39
|
+
};
|
|
40
|
+
})
|
|
41
41
|
];
|
|
42
42
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
async $alterProjectFiles(project, data) {
|
|
44
|
+
if (!data.oidc) {
|
|
45
|
+
return project;
|
|
46
|
+
}
|
|
47
|
+
await render("oidc-provider.index", {
|
|
48
|
+
...data,
|
|
49
|
+
name: "index"
|
|
50
|
+
});
|
|
51
|
+
this.updateServerFile(project);
|
|
52
|
+
this.updateConfigFile(project);
|
|
53
|
+
return project;
|
|
54
|
+
}
|
|
55
|
+
updateServerFile(project) {
|
|
56
|
+
const sourceFile = project.serverSourceFile;
|
|
57
|
+
sourceFile.addImportDeclaration({
|
|
58
|
+
moduleSpecifier: "@tsed/oidc-provider"
|
|
59
|
+
});
|
|
60
|
+
const importDeclaration = sourceFile.addImportDeclaration({
|
|
61
|
+
moduleSpecifier: "./controllers/oidc/InteractionsController.js",
|
|
62
|
+
namedImports: [{ name: "InteractionsController" }]
|
|
63
|
+
});
|
|
64
|
+
importDeclaration.getNamedImports().find((value) => value.getName() === "InteractionsController");
|
|
65
|
+
project.addMountPath("/", "InteractionsController");
|
|
66
|
+
}
|
|
67
|
+
updateConfigFile(project) {
|
|
68
|
+
const sourceFile = project.configSourceFile;
|
|
69
|
+
const options = project.findConfiguration("config");
|
|
70
|
+
if (!options) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
sourceFile.addImportDeclaration({
|
|
74
|
+
moduleSpecifier: "./oidc/index.js",
|
|
75
|
+
defaultImport: "oidcConfig"
|
|
76
|
+
});
|
|
77
|
+
sourceFile.addImportDeclaration({
|
|
78
|
+
moduleSpecifier: "@tsed/adapters",
|
|
79
|
+
namedImports: [{ name: "FileSyncAdapter" }]
|
|
80
|
+
});
|
|
81
|
+
project.getPropertyAssignment(options, {
|
|
82
|
+
name: "oidc",
|
|
83
|
+
kind: SyntaxKind.Identifier,
|
|
84
|
+
initializer: "oidcConfig"
|
|
85
|
+
});
|
|
86
|
+
project
|
|
87
|
+
.getPropertyAssignment(options, {
|
|
88
|
+
name: "adapters",
|
|
89
|
+
kind: SyntaxKind.ArrayLiteralExpression,
|
|
90
|
+
initializer: "[]"
|
|
91
|
+
})
|
|
92
|
+
.addElement("FileSyncAdapter");
|
|
93
|
+
return project;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
injectable(OidcProviderInitHook);
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineTemplate } from "@tsed/cli";
|
|
2
|
+
export default defineTemplate({
|
|
3
|
+
id: "oidc-provider.index",
|
|
4
|
+
label: "OIDC Provider Index",
|
|
5
|
+
fileName: "index",
|
|
6
|
+
outputDir: "{{srcDir}}/config/oidc",
|
|
7
|
+
hidden: true,
|
|
8
|
+
render(_, data) {
|
|
9
|
+
return `import {OidcSettings} from "@tsed/oidc-provider";
|
|
2
10
|
import {Accounts} from "../../services/Accounts.js";
|
|
3
11
|
|
|
4
12
|
const settings: OidcSettings = {
|
|
5
|
-
path: "{
|
|
13
|
+
path: "${data.oidcBasePath}",
|
|
6
14
|
Accounts: Accounts,
|
|
7
15
|
jwksPath: "./jwks.jon",
|
|
8
16
|
clients: [
|
|
@@ -30,4 +38,6 @@ const settings: OidcSettings = {
|
|
|
30
38
|
}
|
|
31
39
|
}
|
|
32
40
|
|
|
33
|
-
export default settings
|
|
41
|
+
export default settings`;
|
|
42
|
+
}
|
|
43
|
+
});
|