openid 2.0.12 → 2.0.13

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/package.json CHANGED
@@ -1,45 +1,47 @@
1
- {
2
- "name": "openid",
3
- "description": "OpenID 1.1/2.0 library for Node.js",
4
- "keywords": [
5
- "openid",
6
- "auth",
7
- "authentication",
8
- "identity",
9
- "identifier",
10
- "relying",
11
- "party",
12
- "relying party",
13
- "1.1",
14
- "2.0",
15
- "library"
16
- ],
17
- "author": {
18
- "name": "Håvard Stranden",
19
- "email": "havard.stranden@gmail.com"
20
- },
21
- "version": "2.0.12",
22
- "repository": {
23
- "type": "git",
24
- "url": "http://github.com/havard/node-openid.git"
25
- },
26
- "bugs": "http://github.com/havard/node-openid/issues",
27
- "license": "MIT",
28
- "directories": {
29
- "lib": "./lib"
30
- },
31
- "main": "./openid.js",
32
- "scripts": {
33
- "test": "jest"
34
- },
35
- "engines": {
36
- "node": ">= 0.6.0"
37
- },
38
- "devDependencies": {
39
- "jest": "^29.7.0"
40
- },
41
- "dependencies": {
42
- "axios": "^1.6.0",
43
- "qs": "^6.5.2"
44
- }
45
- }
1
+ {
2
+ "name": "openid",
3
+ "description": "OpenID 1.1/2.0 library for Node.js",
4
+ "keywords": [
5
+ "openid",
6
+ "auth",
7
+ "authentication",
8
+ "identity",
9
+ "identifier",
10
+ "relying",
11
+ "party",
12
+ "relying party",
13
+ "1.1",
14
+ "2.0",
15
+ "library"
16
+ ],
17
+ "author": {
18
+ "name": "Håvard Stranden",
19
+ "email": "havard.stranden@gmail.com"
20
+ },
21
+ "version": "2.0.13",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "http://github.com/havard/node-openid.git"
25
+ },
26
+ "bugs": "http://github.com/havard/node-openid/issues",
27
+ "license": "MIT",
28
+ "directories": {
29
+ "lib": "./lib"
30
+ },
31
+ "main": "./openid.js",
32
+ "scripts": {
33
+ "test": "jest"
34
+ },
35
+ "engines": {
36
+ "node": ">= 0.6.0"
37
+ },
38
+ "devDependencies": {
39
+ "axios-cookiejar-support": "^5.0.5",
40
+ "jest": "^29.7.0",
41
+ "tough-cookie": "^5.1.2"
42
+ },
43
+ "dependencies": {
44
+ "axios": "^1.6.0",
45
+ "qs": "^6.5.2"
46
+ }
47
+ }
package/sample.js CHANGED
@@ -1,129 +1,118 @@
1
- /* A simple sample demonstrating OpenID for node.js
2
- *
3
- * http://ox.no/software/node-openid
4
- * http://github.com/havard/node-openid
5
- *
6
- * Copyright (C) 2010 by Håvard Stranden
7
- *
8
- * Permission is hereby granted, free of charge, to any person obtaining a copy
9
- * of this software and associated documentation files (the "Software"), to deal
10
- * in the Software without restriction, including without limitation the rights
11
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
- * copies of the Software, and to permit persons to whom the Software is
13
- * furnished to do so, subject to the following conditions:
14
- *
15
- * The above copyright notice and this permission notice shall be included in
16
- * all copies or substantial portions of the Software.
17
- *
18
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
- */
25
-
26
- var openid = require('./openid');
27
- var url = require('url');
28
- var querystring = require('querystring');
29
-
30
- var extensions = [new openid.UserInterface(),
31
- new openid.SimpleRegistration(
32
- {
33
- "nickname" : true,
34
- "email" : true,
35
- "fullname" : true,
36
- "dob" : true,
37
- "gender" : true,
38
- "postcode" : true,
39
- "country" : true,
40
- "language" : true,
41
- "timezone" : true
42
- }),
43
- new openid.AttributeExchange(
44
- {
45
- "http://axschema.org/contact/email": "required",
46
- "http://axschema.org/namePerson/friendly": "required",
47
- "http://axschema.org/namePerson": "required"
48
- }),
49
- new openid.PAPE(
50
- {
51
- "max_auth_age": 24 * 60 * 60, // one day
52
- "preferred_auth_policies" : "none" //no auth method preferred.
53
- })];
54
-
55
- var relyingParty = new openid.RelyingParty(
56
- 'http://example.com/verify', // Verification URL (yours)
57
- null, // Realm (optional, specifies realm for OpenID authentication)
58
- false, // Use stateless verification
59
- false, // Strict mode
60
- extensions); // List of extensions to enable and include
61
-
62
-
63
- var server = require('http').createServer(
64
- function(req, res)
65
- {
66
- var parsedUrl = url.parse(req.url);
67
- if(parsedUrl.pathname == '/authenticate')
68
- {
69
- // User supplied identifier
70
- var query = querystring.parse(parsedUrl.query);
71
- var identifier = query.openid_identifier;
72
-
73
- // Resolve identifier, associate, and build authentication URL
74
- relyingParty.authenticate(identifier, false, function(error, authUrl)
75
- {
76
- if(error)
77
- {
78
- res.writeHead(200, { 'Content-Type' : 'text/plain; charset=utf-8' });
79
- res.end('Authentication failed: ' + error.message);
80
- }
81
- else if (!authUrl)
82
- {
83
- res.writeHead(200, { 'Content-Type' : 'text/plain; charset=utf-8' });
84
- res.end('Authentication failed');
85
- }
86
- else
87
- {
88
- res.writeHead(302, { Location: authUrl });
89
- res.end();
90
- }
91
- });
92
- }
93
- else if(parsedUrl.pathname == '/verify')
94
- {
95
- // Verify identity assertion
96
- // NOTE: Passing just the URL is also possible
97
- relyingParty.verifyAssertion(req, function(error, result)
98
- {
99
- res.writeHead(200, { 'Content-Type' : 'text/plain; charset=utf-8' });
100
-
101
- if(error)
102
- {
103
- res.end('Authentication failed: ' + error.message);
104
- }
105
- else
106
- {
107
- // Result contains properties:
108
- // - authenticated (true/false)
109
- // - answers from any extensions (e.g.
110
- // "http://axschema.org/contact/email" if requested
111
- // and present at provider)
112
- res.end((result.authenticated ? 'Success :)' : 'Failure :(') +
113
- '\n\n' + JSON.stringify(result));
114
- }
115
- });
116
- }
117
- else
118
- {
119
- // Deliver an OpenID form on all other URLs
120
- res.writeHead(200, { 'Content-Type' : 'text/html; charset=utf-8' });
121
- res.end('<!DOCTYPE html><html><body>'
122
- + '<form method="get" action="/authenticate">'
123
- + '<p>Login using OpenID</p>'
124
- + '<input name="openid_identifier" />'
125
- + '<input type="submit" value="Login" />'
126
- + '</form></body></html>');
127
- }
128
- });
129
- server.listen(80);
1
+ /* A simple sample demonstrating OpenID for node.js
2
+ *
3
+ * http://ox.no/software/node-openid
4
+ * http://github.com/havard/node-openid
5
+ *
6
+ * Copyright (C) 2010 by Håvard Stranden
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the "Software"), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in
16
+ * all copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ */
25
+
26
+ var openid = require('./openid');
27
+ var url = require('url');
28
+ var querystring = require('querystring');
29
+
30
+ var extensions = [new openid.UserInterface(),
31
+ new openid.SimpleRegistration(
32
+ {
33
+ "nickname": true,
34
+ "email": true,
35
+ "fullname": true,
36
+ "dob": true,
37
+ "gender": true,
38
+ "postcode": true,
39
+ "country": true,
40
+ "language": true,
41
+ "timezone": true
42
+ }),
43
+ new openid.AttributeExchange(
44
+ {
45
+ "http://axschema.org/contact/email": "required",
46
+ "http://axschema.org/namePerson/friendly": "required",
47
+ "http://axschema.org/namePerson": "required"
48
+ }),
49
+ new openid.PAPE(
50
+ {
51
+ "max_auth_age": 24 * 60 * 60, // one day
52
+ "preferred_auth_policies": "none" //no auth method preferred.
53
+ })];
54
+
55
+ var relyingParty = new openid.RelyingParty(
56
+ 'http://example.com/verify', // Verification URL (yours)
57
+ null, // Realm (optional, specifies realm for OpenID authentication)
58
+ false, // Use stateless verification
59
+ false, // Strict mode
60
+ extensions); // List of extensions to enable and include
61
+
62
+
63
+ var server = require('http').createServer(
64
+ function (req, res) {
65
+ var parsedUrl = url.parse(req.url);
66
+ if (parsedUrl.pathname == '/authenticate') {
67
+ // User supplied identifier
68
+ var query = querystring.parse(parsedUrl.query);
69
+ var identifier = query.openid_identifier;
70
+
71
+ // Resolve identifier, associate, and build authentication URL
72
+ relyingParty.authenticate(identifier, false, function (error, authUrl) {
73
+ if (error) {
74
+ res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
75
+ res.end('Authentication failed: ' + error.message);
76
+ }
77
+ else if (!authUrl) {
78
+ res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
79
+ res.end('Authentication failed');
80
+ }
81
+ else {
82
+ res.writeHead(302, { Location: authUrl });
83
+ res.end();
84
+ }
85
+ });
86
+ }
87
+ else if (parsedUrl.pathname == '/verify') {
88
+ // Verify identity assertion
89
+ // NOTE: Passing just the URL is also possible
90
+ relyingParty.verifyAssertion(req, function (error, result) {
91
+ res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' });
92
+
93
+ if (error) {
94
+ res.end('Authentication failed: ' + error.message);
95
+ }
96
+ else {
97
+ // Result contains properties:
98
+ // - authenticated (true/false)
99
+ // - answers from any extensions (e.g.
100
+ // "http://axschema.org/contact/email" if requested
101
+ // and present at provider)
102
+ res.end((result.authenticated ? 'Success :)' : 'Failure :(') +
103
+ '\n\n' + JSON.stringify(result));
104
+ }
105
+ });
106
+ }
107
+ else {
108
+ // Deliver an OpenID form on all other URLs
109
+ res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8' });
110
+ res.end('<!DOCTYPE html><html><body>'
111
+ + '<form method="get" action="/authenticate">'
112
+ + '<p>Login using OpenID</p>'
113
+ + '<input name="openid_identifier" />'
114
+ + '<input type="submit" value="Login" />'
115
+ + '</form></body></html>');
116
+ }
117
+ });
118
+ server.listen(80);
@@ -1,38 +1,37 @@
1
- /* OpenID for node.js
2
- *
3
- * http://ox.no/software/node-openid
4
- * http://github.com/havard/node-openid
5
- *
6
- * Copyright (C) 2010 by Håvard Stranden
7
- *
8
- * Permission is hereby granted, free of charge, to any person obtaining a copy
9
- * of this software and associated documentation files (the "Software"), to deal
10
- * in the Software without restriction, including without limitation the rights
11
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
- * copies of the Software, and to permit persons to whom the Software is
13
- * furnished to do so, subject to the following conditions:
14
- *
15
- * The above copyright notice and this permission notice shall be included in
16
- * all copies or substantial portions of the Software.
17
- *
18
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
- */
25
-
26
- const openid = require('../openid');
27
-
28
- test('Cancelled verification does not authenticate', () => {
29
- openid.verifyAssertion(
30
- 'http://host/?openid.mode=cancel' +
31
- '&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0',
32
- 'http://example.com/verify',
33
- (error, result) => {
34
- expect(error).toBeTruthy();
35
- expect(result).toBeFalsy();
36
- });
37
- });
38
-
1
+ /* OpenID for node.js
2
+ *
3
+ * http://ox.no/software/node-openid
4
+ * http://github.com/havard/node-openid
5
+ *
6
+ * Copyright (C) 2010 by Håvard Stranden
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the "Software"), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in
16
+ * all copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ */
25
+
26
+ const openid = require('../openid');
27
+
28
+ test('Cancelled verification does not authenticate', () => {
29
+ openid.verifyAssertion(
30
+ 'http://host/?openid.mode=cancel' +
31
+ '&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0',
32
+ 'http://example.com/verify',
33
+ (error, result) => {
34
+ expect(error).toBeTruthy();
35
+ expect(result).toBeFalsy();
36
+ });
37
+ });
@@ -1,66 +1,65 @@
1
- /* OpenID for node.js
2
- *
3
- * http://ox.no/software/node-openid
4
- * http://github.com/havard/node-openid
5
- *
6
- * Copyright (C) 2010 by Håvard Stranden
7
- *
8
- * Permission is hereby granted, free of charge, to any person obtaining a copy
9
- * of this software and associated documentation files (the "Software"), to deal
10
- * in the Software without restriction, including without limitation the rights
11
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
- * copies of the Software, and to permit persons to whom the Software is
13
- * furnished to do so, subject to the following conditions:
14
- *
15
- * The above copyright notice and this permission notice shall be included in
16
- * all copies or substantial portions of the Software.
17
- *
18
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
- */
25
-
26
- const openid = require('../openid');
27
-
28
- test('Attribute Exchange (AX) values are parsed', () => {
29
- const ax = new openid.AttributeExchange(),
30
- results = {},
31
- exampleParams = {
32
- 'openid.ax.type.email' : 'http://axschema.org/contact/email',
33
- 'openid.ax.value.email' : 'fred.example@gmail.com',
34
- 'openid.ax.type.language' : 'http://axschema.org/pref/language',
35
- 'openid.ax.value.language' : 'english',
36
- 'openid.ax.type.phones' : 'http://axschema.org/contact/phone/cell',
37
- 'openid.ax.count.phones' : '2',
38
- 'openid.ax.value.phones.1' : '+1 (555) 555-5555',
39
- 'openid.ax.value.phones.2' : '+33 6 55 55 55 55',
40
- 'openid.ax.value.phones.3' : '+46 5 5555 5555',
41
- }
42
- ax.fillResult(exampleParams, results);
43
-
44
- expect(results['email']).toBe('fred.example@gmail.com');
45
- expect(results['http://axschema.org/contact/email']).toBe('fred.example@gmail.com');
46
- expect(results['language']).toBe('english');
47
- expect(results['http://axschema.org/pref/language']).toBe('english');
48
- expect(results['phones'].length).toBe(2);
49
- expect(results['phones'][0]).toBe('+1 (555) 555-5555');
50
- expect(results['phones'][1]).toBe('+33 6 55 55 55 55');
51
- });
52
-
53
- test('PAPE values are parsed', () => {
54
- const authDate = new Date().toISOString();
55
- const exampleParams = {
56
- "openid.pape.auth_time" : authDate,
57
- "openid.pape.auth_policies" : 'http://schemas.openid.net/pape/policies/2007/06/multi-factor http://schemas.openid.net/pape/policies/2007/06/phishing-resistant'
58
- };
59
- const pape = new openid.PAPE(),
60
- results = {};
61
-
62
- pape.fillResult(exampleParams, results);
63
- expect(results['auth_time']).toBe(authDate);
64
- expect(results['auth_policies']).toBe('multi-factor phishing-resistant');
65
- });
66
-
1
+ /* OpenID for node.js
2
+ *
3
+ * http://ox.no/software/node-openid
4
+ * http://github.com/havard/node-openid
5
+ *
6
+ * Copyright (C) 2010 by Håvard Stranden
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the "Software"), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in
16
+ * all copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ */
25
+
26
+ const openid = require('../openid');
27
+
28
+ test('Attribute Exchange (AX) values are parsed', () => {
29
+ const ax = new openid.AttributeExchange(),
30
+ results = {},
31
+ exampleParams = {
32
+ 'openid.ax.type.email': 'http://axschema.org/contact/email',
33
+ 'openid.ax.value.email': 'fred.example@gmail.com',
34
+ 'openid.ax.type.language': 'http://axschema.org/pref/language',
35
+ 'openid.ax.value.language': 'english',
36
+ 'openid.ax.type.phones': 'http://axschema.org/contact/phone/cell',
37
+ 'openid.ax.count.phones': '2',
38
+ 'openid.ax.value.phones.1': '+1 (555) 555-5555',
39
+ 'openid.ax.value.phones.2': '+33 6 55 55 55 55',
40
+ 'openid.ax.value.phones.3': '+46 5 5555 5555',
41
+ }
42
+ ax.fillResult(exampleParams, results);
43
+
44
+ expect(results['email']).toBe('fred.example@gmail.com');
45
+ expect(results['http://axschema.org/contact/email']).toBe('fred.example@gmail.com');
46
+ expect(results['language']).toBe('english');
47
+ expect(results['http://axschema.org/pref/language']).toBe('english');
48
+ expect(results['phones'].length).toBe(2);
49
+ expect(results['phones'][0]).toBe('+1 (555) 555-5555');
50
+ expect(results['phones'][1]).toBe('+33 6 55 55 55 55');
51
+ });
52
+
53
+ test('PAPE values are parsed', () => {
54
+ const authDate = new Date().toISOString();
55
+ const exampleParams = {
56
+ "openid.pape.auth_time": authDate,
57
+ "openid.pape.auth_policies": 'http://schemas.openid.net/pape/policies/2007/06/multi-factor http://schemas.openid.net/pape/policies/2007/06/phishing-resistant'
58
+ };
59
+ const pape = new openid.PAPE(),
60
+ results = {};
61
+
62
+ pape.fillResult(exampleParams, results);
63
+ expect(results['auth_time']).toBe(authDate);
64
+ expect(results['auth_policies']).toBe('multi-factor phishing-resistant');
65
+ });