openid 1.0.0 → 1.0.4

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
@@ -18,7 +18,7 @@
18
18
  "email": "havard.stranden@gmail.com",
19
19
  "web": "http://ox.no"
20
20
  },
21
- "version": "1.0.0",
21
+ "version": "1.0.4",
22
22
  "repository": {
23
23
  "type": "git",
24
24
  "url": "http://github.com/havard/node-openid.git"
package/sample.js CHANGED
@@ -53,9 +53,9 @@ var extensions = [new openid.UserInterface(),
53
53
  })];
54
54
 
55
55
  var relyingParty = new openid.RelyingParty(
56
- 'http://example.com/verify', // Verification URL (yours)
56
+ 'http://localhost:8080/verify', // Verification URL (yours)
57
57
  null, // Realm (optional, specifies realm for OpenID authentication)
58
- false, // Use stateless verification
58
+ true, // Use stateless verification
59
59
  false, // Strict mode
60
60
  extensions); // List of extensions to enable and include
61
61
 
@@ -126,4 +126,4 @@ var server = require('http').createServer(
126
126
  + '</form></body></html>');
127
127
  }
128
128
  });
129
- server.listen(80);
129
+ server.listen(8080);
package/test.js ADDED
@@ -0,0 +1,21 @@
1
+ var _buffer = null;
2
+ if (typeof(Buffer.from) === 'function') {
3
+ // Some older Node versions throw an exception when
4
+ // buffers with binary encoding are created using the
5
+ // from function, so if that happens we have to resort
6
+ // to constructor based creation.
7
+ try {
8
+ Buffer.from('openid', 'binary');
9
+ _buffer = Buffer.from;
10
+ }
11
+ catch(_) {
12
+ }
13
+ }
14
+ if (_buffer === null) {
15
+ // Either the Node version is too old to have a Buffer.from,
16
+ // or the Buffer.from call failed with binary encoding.
17
+ // Either way, use the (deprecated from node v6) constructor.
18
+ _buffer = function(str, enc) { return new Buffer(str, enc); };
19
+ }
20
+
21
+ _buffer('hello', 'binary');
package/lib/base64.js DELETED
@@ -1,161 +0,0 @@
1
- /* Base64 conversion functions
2
- *
3
- * Adaptions for node.js are Copyright (c) 2010 Håvard Stranden
4
- *
5
- * Copyright (c) 2010 Nick Galbreath
6
- * http://code.google.com/p/stringencoders/source/browse/#svn/trunk/javascript
7
- *
8
- * Permission is hereby granted, free of charge, to any person
9
- * obtaining a copy of this software and associated documentation
10
- * files (the "Software"), to deal in the Software without
11
- * restriction, including without limitation the rights to use,
12
- * copy, modify, merge, publish, distribute, sublicense, and/or sell
13
- * copies of the Software, and to permit persons to whom the
14
- * Software is furnished to do so, subject to the following
15
- * conditions:
16
- *
17
- * The above copyright notice and this permission notice shall be
18
- * included in all copies or substantial portions of the Software.
19
- *
20
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
22
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
25
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27
- * OTHER DEALINGS IN THE SOFTWARE.
28
- *
29
- * base64 encode/decode compatible with window.btoa/atob
30
- *
31
- * window.atob/btoa is a Firefox extension to convert binary data (the "b")
32
- * to base64 (ascii, the "a").
33
- *
34
- * It is also found in Safari and Chrome. It is not available in IE.
35
- *
36
- * if (!window.btoa) window.btoa = base64.encode
37
- * if (!window.atob) window.atob = base64.decode
38
- *
39
- * The original spec's for atob/btoa are a bit lacking
40
- * https://developer.mozilla.org/en/DOM/window.atob
41
- * https://developer.mozilla.org/en/DOM/window.btoa
42
- *
43
- * window.btoa and base64.encode takes a string where charCodeAt is [0,255]
44
- * If any character is not [0,255], then an exception is thrown.
45
- *
46
- * window.atob and base64.decode take a base64-encoded string
47
- * If the input length is not a multiple of 4, or contains invalid characters
48
- * then an exception is thrown.
49
- *
50
- * -*- Mode: JS; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
51
- * vim: set sw=2 ts=2 et tw=80 :
52
- */
53
- var base64 = {};
54
- base64.PADCHAR = '=';
55
- base64.ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
56
- base64.getbyte64 = function(s,i) {
57
- // This is oddly fast, except on Chrome/V8.
58
- // Minimal or no improvement in performance by using a
59
- // object with properties mapping chars to value (eg. 'A': 0)
60
- var idx = base64.ALPHA.indexOf(s.charAt(i));
61
- if (idx == -1) {
62
- throw "Cannot decode base64";
63
- }
64
- return idx;
65
- }
66
-
67
- base64.decode = function(s) {
68
- // convert to string
69
- s = "" + s;
70
- var getbyte64 = base64.getbyte64;
71
- var pads, i, b10;
72
- var imax = s.length
73
- if (imax == 0) {
74
- return s;
75
- }
76
-
77
- if (imax % 4 != 0) {
78
- throw "Cannot decode base64";
79
- }
80
-
81
- pads = 0
82
- if (s.charAt(imax -1) == base64.PADCHAR) {
83
- pads = 1;
84
- if (s.charAt(imax -2) == base64.PADCHAR) {
85
- pads = 2;
86
- }
87
- // either way, we want to ignore this last block
88
- imax -= 4;
89
- }
90
-
91
- var x = [];
92
- for (i = 0; i < imax; i += 4) {
93
- b10 = (getbyte64(s,i) << 18) | (getbyte64(s,i+1) << 12) |
94
- (getbyte64(s,i+2) << 6) | getbyte64(s,i+3);
95
- x.push(String.fromCharCode(b10 >> 16, (b10 >> 8) & 0xff, b10 & 0xff));
96
- }
97
-
98
- switch (pads) {
99
- case 1:
100
- b10 = (getbyte64(s,i) << 18) | (getbyte64(s,i+1) << 12) | (getbyte64(s,i+2) << 6)
101
- x.push(String.fromCharCode(b10 >> 16, (b10 >> 8) & 0xff));
102
- break;
103
- case 2:
104
- b10 = (getbyte64(s,i) << 18) | (getbyte64(s,i+1) << 12);
105
- x.push(String.fromCharCode(b10 >> 16));
106
- break;
107
- }
108
- return x.join('');
109
- }
110
-
111
- base64.getbyte = function(s,i) {
112
- var x = s.charCodeAt(i);
113
- if (x > 255) {
114
- throw "INVALID_CHARACTER_ERR: DOM Exception 5";
115
- }
116
- return x;
117
- }
118
-
119
-
120
- base64.encode = function(s) {
121
- if (arguments.length != 1) {
122
- throw "SyntaxError: Not enough arguments";
123
- }
124
- var padchar = base64.PADCHAR;
125
- var alpha = base64.ALPHA;
126
- var getbyte = base64.getbyte;
127
-
128
- var i, b10;
129
- var x = [];
130
-
131
- // convert to string
132
- s = "" + s;
133
-
134
- var imax = s.length - s.length % 3;
135
-
136
- if (s.length == 0) {
137
- return s;
138
- }
139
- for (i = 0; i < imax; i += 3) {
140
- b10 = (getbyte(s,i) << 16) | (getbyte(s,i+1) << 8) | getbyte(s,i+2);
141
- x.push(alpha.charAt(b10 >> 18));
142
- x.push(alpha.charAt((b10 >> 12) & 0x3F));
143
- x.push(alpha.charAt((b10 >> 6) & 0x3f));
144
- x.push(alpha.charAt(b10 & 0x3f));
145
- }
146
- switch (s.length - imax) {
147
- case 1:
148
- b10 = getbyte(s,i) << 16;
149
- x.push(alpha.charAt(b10 >> 18) + alpha.charAt((b10 >> 12) & 0x3F) +
150
- padchar + padchar);
151
- break;
152
- case 2:
153
- b10 = (getbyte(s,i) << 16) | (getbyte(s,i+1) << 8);
154
- x.push(alpha.charAt(b10 >> 18) + alpha.charAt((b10 >> 12) & 0x3F) +
155
- alpha.charAt((b10 >> 6) & 0x3f) + padchar);
156
- break;
157
- }
158
- return x.join('');
159
- }
160
-
161
- exports.base64 = base64;
package/lib/convert.js DELETED
@@ -1,52 +0,0 @@
1
- /* Conversion functions used in 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
- * -*- Mode: JS; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
26
- * vim: set sw=2 ts=2 et tw=80 :
27
- */
28
-
29
- var base64 = require('./base64').base64;
30
-
31
- function btwoc(i)
32
- {
33
- if(i.charCodeAt(0) > 127)
34
- {
35
- return String.fromCharCode(0) + i;
36
- }
37
- return i;
38
- }
39
-
40
- function unbtwoc(i)
41
- {
42
- if(i[0] === String.fromCharCode(0))
43
- {
44
- return i.substr(1);
45
- }
46
-
47
- return i;
48
- }
49
-
50
- exports.btwoc = btwoc;
51
- exports.unbtwoc = unbtwoc;
52
- exports.base64 = base64;