generator-aspnet-oauth 9.0.1 → 10.0.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/generators/app/index.js +70 -46
- package/package.json +25 -8
package/generators/app/index.js
CHANGED
|
@@ -1,47 +1,48 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
module.exports = class extends Generator {
|
|
2
|
+
import fetch from 'cross-fetch';
|
|
3
|
+
import Generator from 'yeoman-generator';
|
|
4
|
+
import queryString from 'query-string';
|
|
5
|
+
import yosay from 'yosay';
|
|
8
6
|
|
|
7
|
+
export default class extends Generator {
|
|
9
8
|
initializing() {
|
|
10
9
|
this.templateData = {};
|
|
11
10
|
this.log(yosay('Welcome to the classy ASP.NET OAuth Provider generator!'));
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
async prompting() {
|
|
15
|
-
const prompts = [
|
|
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
14
|
+
const prompts = [
|
|
15
|
+
{
|
|
16
|
+
type: 'input',
|
|
17
|
+
name: 'name',
|
|
18
|
+
message: 'What is the name of the provider you want to create?',
|
|
19
|
+
store: true,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
type: 'input',
|
|
23
|
+
name: 'authorname',
|
|
24
|
+
message: 'What is your name?',
|
|
25
|
+
store: true,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
type: 'input',
|
|
29
|
+
name: 'authorizationendpoint',
|
|
30
|
+
message: 'What is the Authorization Endpoint for this service?',
|
|
31
|
+
store: true,
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
type: 'input',
|
|
35
|
+
name: 'tokenendpoint',
|
|
36
|
+
message: 'What is the Token Endpoint for this service?',
|
|
37
|
+
store: true,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
type: 'input',
|
|
41
|
+
name: 'userinformationendpoint',
|
|
42
|
+
message: 'What is the User Information Endpoint for this service?',
|
|
43
|
+
store: true,
|
|
44
|
+
},
|
|
45
|
+
];
|
|
45
46
|
|
|
46
47
|
const answers = await this.prompt(prompts);
|
|
47
48
|
|
|
@@ -58,15 +59,34 @@ module.exports = class extends Generator {
|
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
writing() {
|
|
61
|
-
this.fs.copyTpl(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
this.fs.copyTpl(
|
|
63
|
+
this.templatePath('Project.csproj'),
|
|
64
|
+
this.applicationName + '/' + this.applicationName + '.csproj',
|
|
65
|
+
this.templateData
|
|
66
|
+
);
|
|
67
|
+
this.fs.copyTpl(
|
|
68
|
+
this.templatePath('AuthenticationDefaults.cs'),
|
|
69
|
+
this.applicationName + '/' + this.name + 'AuthenticationDefaults.cs',
|
|
70
|
+
this.templateData
|
|
71
|
+
);
|
|
72
|
+
this.fs.copyTpl(
|
|
73
|
+
this.templatePath('AuthenticationExtensions.cs'),
|
|
74
|
+
this.applicationName + '/' + this.name + 'AuthenticationExtensions.cs',
|
|
75
|
+
this.templateData
|
|
76
|
+
);
|
|
77
|
+
this.fs.copyTpl(
|
|
78
|
+
this.templatePath('AuthenticationHandler.cs'),
|
|
79
|
+
this.applicationName + '/' + this.name + 'AuthenticationHandler.cs',
|
|
80
|
+
this.templateData
|
|
81
|
+
);
|
|
82
|
+
this.fs.copyTpl(
|
|
83
|
+
this.templatePath('AuthenticationOptions.cs'),
|
|
84
|
+
this.applicationName + '/' + this.name + 'AuthenticationOptions.cs',
|
|
85
|
+
this.templateData
|
|
86
|
+
);
|
|
66
87
|
}
|
|
67
88
|
|
|
68
89
|
async getCurrentVersion() {
|
|
69
|
-
|
|
70
90
|
let response = await fetch('https://api.nuget.org/v3/index.json');
|
|
71
91
|
|
|
72
92
|
if (!response.ok) {
|
|
@@ -74,7 +94,9 @@ module.exports = class extends Generator {
|
|
|
74
94
|
}
|
|
75
95
|
|
|
76
96
|
const serviceIndex = await response.json();
|
|
77
|
-
const baseAddress = serviceIndex.resources.find(
|
|
97
|
+
const baseAddress = serviceIndex.resources.find(
|
|
98
|
+
(resource) => resource['@type'] === 'SearchQueryService/3.5.0'
|
|
99
|
+
)['@id'];
|
|
78
100
|
|
|
79
101
|
if (!baseAddress) {
|
|
80
102
|
throw new Error('Failed to determine the base address for the NuGet search query service.');
|
|
@@ -84,14 +106,16 @@ module.exports = class extends Generator {
|
|
|
84
106
|
prerelease: false,
|
|
85
107
|
q: 'PackageId:AspNet.Security.OAuth.GitHub',
|
|
86
108
|
semVerLevel: '2.0.0',
|
|
87
|
-
take: 1
|
|
109
|
+
take: 1,
|
|
88
110
|
});
|
|
89
111
|
|
|
90
112
|
const searchUrl = `${baseAddress}?${query}`;
|
|
91
113
|
response = await fetch(searchUrl);
|
|
92
114
|
|
|
93
115
|
if (!response.ok) {
|
|
94
|
-
throw new Error(
|
|
116
|
+
throw new Error(
|
|
117
|
+
`Failed to search for NuGet package from '${searchUrl}'. HTTP status code: ${response.status}.`
|
|
118
|
+
);
|
|
95
119
|
}
|
|
96
120
|
|
|
97
121
|
const searchResult = await response.json();
|
|
@@ -115,4 +139,4 @@ module.exports = class extends Generator {
|
|
|
115
139
|
|
|
116
140
|
return versionParts.join(dot);
|
|
117
141
|
}
|
|
118
|
-
}
|
|
142
|
+
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "generator-aspnet-oauth",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
4
4
|
"description": "Yeoman generator for OAuth Providers for ASP.NET Core",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"main": "app/index.js",
|
|
7
8
|
"repository": {
|
|
8
9
|
"type": "git",
|
|
@@ -17,7 +18,10 @@
|
|
|
17
18
|
"url": "https://github.com/jerriep"
|
|
18
19
|
},
|
|
19
20
|
"scripts": {
|
|
20
|
-
"
|
|
21
|
+
"format": "prettier --write **/*.js",
|
|
22
|
+
"format-check": "prettier --check **/*.js",
|
|
23
|
+
"test": "mocha",
|
|
24
|
+
"all": "npm run format && npm test"
|
|
21
25
|
},
|
|
22
26
|
"files": [
|
|
23
27
|
"generators"
|
|
@@ -30,14 +34,27 @@
|
|
|
30
34
|
],
|
|
31
35
|
"dependencies": {
|
|
32
36
|
"cross-fetch": "^4.1.0",
|
|
33
|
-
"query-string": "^
|
|
34
|
-
"
|
|
35
|
-
"
|
|
37
|
+
"query-string": "^9.2.2",
|
|
38
|
+
"yeoman-generator": "^7.5.1",
|
|
39
|
+
"yosay": "^3.0.0"
|
|
36
40
|
},
|
|
37
41
|
"devDependencies": {
|
|
38
|
-
"glob": "^11.0.
|
|
39
|
-
"mocha": "^11.1
|
|
42
|
+
"glob": "^11.0.3",
|
|
43
|
+
"mocha": "^11.7.1",
|
|
44
|
+
"prettier": "3.6.2",
|
|
40
45
|
"yeoman-assert": "^3.1.1",
|
|
41
|
-
"yeoman-
|
|
46
|
+
"yeoman-environment": "^5.0.0",
|
|
47
|
+
"yeoman-test": "^11.0.0"
|
|
48
|
+
},
|
|
49
|
+
"prettier": {
|
|
50
|
+
"arrowParens": "always",
|
|
51
|
+
"bracketSpacing": true,
|
|
52
|
+
"printWidth": 100,
|
|
53
|
+
"quoteProps": "consistent",
|
|
54
|
+
"semi": true,
|
|
55
|
+
"singleQuote": true,
|
|
56
|
+
"tabWidth": 2,
|
|
57
|
+
"trailingComma": "es5",
|
|
58
|
+
"useTabs": false
|
|
42
59
|
}
|
|
43
60
|
}
|