@solid/solid-auth-oidc 0.5.4 → 0.5.6-79cb832b
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/index.js +45 -113
- package/lib/provider-select-popup.js +1 -1
- package/package.json +18 -18
package/lib/index.js
CHANGED
|
@@ -26,10 +26,12 @@
|
|
|
26
26
|
*/
|
|
27
27
|
'use strict';
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
function
|
|
32
|
-
|
|
29
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
30
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
31
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
32
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
33
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
34
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
33
35
|
var RelyingParty = require('@solid/oidc-rp');
|
|
34
36
|
var PoPToken = require('@solid/oidc-rp/src/PoPToken');
|
|
35
37
|
var providerSelectPopupSource = require('./provider-select-popup');
|
|
@@ -40,8 +42,7 @@ var QUERY = 'query';
|
|
|
40
42
|
|
|
41
43
|
// AuthenticationRequest sending methods
|
|
42
44
|
var REDIRECT = 'redirect';
|
|
43
|
-
|
|
44
|
-
var ClientAuthOIDC = function () {
|
|
45
|
+
var ClientAuthOIDC = /*#__PURE__*/function () {
|
|
45
46
|
/**
|
|
46
47
|
* @constructor
|
|
47
48
|
* @param [options={}]
|
|
@@ -50,12 +51,9 @@ var ClientAuthOIDC = function () {
|
|
|
50
51
|
*/
|
|
51
52
|
function ClientAuthOIDC() {
|
|
52
53
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
53
|
-
|
|
54
54
|
_classCallCheck(this, ClientAuthOIDC);
|
|
55
|
-
|
|
56
55
|
this.window = options.window || global.window;
|
|
57
56
|
this.store = options.store || global.localStorage;
|
|
58
|
-
|
|
59
57
|
this.currentClient = null;
|
|
60
58
|
this.providerUri = null;
|
|
61
59
|
this.webId = null;
|
|
@@ -63,9 +61,8 @@ var ClientAuthOIDC = function () {
|
|
|
63
61
|
this.accessToken = null;
|
|
64
62
|
this.method = REDIRECT; // only redirect is currently supported
|
|
65
63
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
key: 'initEventListeners',
|
|
64
|
+
return _createClass(ClientAuthOIDC, [{
|
|
65
|
+
key: "initEventListeners",
|
|
69
66
|
value: function initEventListeners(window) {
|
|
70
67
|
window.addEventListener('message', this.onMessage.bind(this));
|
|
71
68
|
}
|
|
@@ -75,25 +72,21 @@ var ClientAuthOIDC = function () {
|
|
|
75
72
|
*
|
|
76
73
|
* @return {string|null}
|
|
77
74
|
*/
|
|
78
|
-
|
|
79
75
|
}, {
|
|
80
|
-
key:
|
|
76
|
+
key: "currentLocation",
|
|
81
77
|
value: function currentLocation() {
|
|
82
78
|
var window = this.window;
|
|
83
|
-
|
|
84
79
|
if (!window || !window.location) {
|
|
85
80
|
return null;
|
|
86
81
|
}
|
|
87
|
-
|
|
88
82
|
return window.location.href;
|
|
89
83
|
}
|
|
90
84
|
|
|
91
85
|
/**
|
|
92
86
|
* @return {Promise<string>} Resolves to current user's WebID URI
|
|
93
87
|
*/
|
|
94
|
-
|
|
95
88
|
}, {
|
|
96
|
-
key:
|
|
89
|
+
key: "currentUser",
|
|
97
90
|
value: function currentUser() {
|
|
98
91
|
if (this.webId) {
|
|
99
92
|
return Promise.resolve(this.webId);
|
|
@@ -101,7 +94,6 @@ var ClientAuthOIDC = function () {
|
|
|
101
94
|
|
|
102
95
|
// Attempt to find a provider based on the 'state' param of the current URI
|
|
103
96
|
var providerUri = this.providerFromCurrentUri();
|
|
104
|
-
|
|
105
97
|
if (providerUri) {
|
|
106
98
|
return this.login(providerUri);
|
|
107
99
|
} else {
|
|
@@ -115,22 +107,17 @@ var ClientAuthOIDC = function () {
|
|
|
115
107
|
*
|
|
116
108
|
* @return {string|null}
|
|
117
109
|
*/
|
|
118
|
-
|
|
119
110
|
}, {
|
|
120
|
-
key:
|
|
111
|
+
key: "providerEndSessionEndpoint",
|
|
121
112
|
value: function providerEndSessionEndpoint() {
|
|
122
113
|
var rp = this.currentClient;
|
|
123
|
-
|
|
124
114
|
if (!rp || !rp.provider || !rp.provider.configuration) {
|
|
125
115
|
return null;
|
|
126
116
|
}
|
|
127
|
-
|
|
128
117
|
var config = rp.provider.configuration;
|
|
129
|
-
|
|
130
118
|
if (!config.end_session_endpoint) {
|
|
131
119
|
return null;
|
|
132
120
|
}
|
|
133
|
-
|
|
134
121
|
return config.end_session_endpoint;
|
|
135
122
|
}
|
|
136
123
|
|
|
@@ -142,42 +129,37 @@ var ClientAuthOIDC = function () {
|
|
|
142
129
|
*
|
|
143
130
|
* @return {string|null} Value of the `state` query or hash fragment param
|
|
144
131
|
*/
|
|
145
|
-
|
|
146
132
|
}, {
|
|
147
|
-
key:
|
|
133
|
+
key: "extractState",
|
|
148
134
|
value: function extractState(uri) {
|
|
149
135
|
var uriType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : HASH;
|
|
150
|
-
|
|
151
136
|
if (!uri) {
|
|
152
137
|
return null;
|
|
153
138
|
}
|
|
154
139
|
var uriObj = new URL(uri);
|
|
155
|
-
var state
|
|
156
|
-
|
|
140
|
+
var state;
|
|
157
141
|
if (uriType === HASH) {
|
|
158
142
|
var hash = uriObj.hash || '#';
|
|
159
143
|
var params = new URLSearchParams(hash.substr(1));
|
|
160
144
|
state = params.get('state');
|
|
161
145
|
}
|
|
162
|
-
|
|
163
146
|
if (uriType === QUERY) {
|
|
164
147
|
state = uriObj.searchParams.get('state');
|
|
165
148
|
}
|
|
166
|
-
|
|
167
149
|
return state;
|
|
168
150
|
}
|
|
169
151
|
}, {
|
|
170
|
-
key:
|
|
152
|
+
key: "keyByProvider",
|
|
171
153
|
value: function keyByProvider(providerUri) {
|
|
172
|
-
return
|
|
154
|
+
return "oidc.rp.by-provider.".concat(providerUri);
|
|
173
155
|
}
|
|
174
156
|
}, {
|
|
175
|
-
key:
|
|
157
|
+
key: "keyByState",
|
|
176
158
|
value: function keyByState(state) {
|
|
177
159
|
if (!state) {
|
|
178
160
|
throw new TypeError('No state provided to keyByState()');
|
|
179
161
|
}
|
|
180
|
-
return
|
|
162
|
+
return "oidc.rp.by-state.".concat(state);
|
|
181
163
|
}
|
|
182
164
|
|
|
183
165
|
/**
|
|
@@ -185,14 +167,11 @@ var ClientAuthOIDC = function () {
|
|
|
185
167
|
*
|
|
186
168
|
* @return {Promise<RelyingParty>}
|
|
187
169
|
*/
|
|
188
|
-
|
|
189
170
|
}, {
|
|
190
|
-
key:
|
|
171
|
+
key: "loadOrRegisterClient",
|
|
191
172
|
value: function loadOrRegisterClient(providerUri) {
|
|
192
173
|
var _this = this;
|
|
193
|
-
|
|
194
174
|
this.currentClient = null;
|
|
195
|
-
|
|
196
175
|
return this.loadClient(providerUri).then(function (loadedClient) {
|
|
197
176
|
if (loadedClient) {
|
|
198
177
|
_this.currentClient = loadedClient;
|
|
@@ -208,9 +187,8 @@ var ClientAuthOIDC = function () {
|
|
|
208
187
|
* @param providerUri {string}
|
|
209
188
|
* @return {Promise<RelyingParty>}
|
|
210
189
|
*/
|
|
211
|
-
|
|
212
190
|
}, {
|
|
213
|
-
key:
|
|
191
|
+
key: "loadClient",
|
|
214
192
|
value: function loadClient(providerUri) {
|
|
215
193
|
if (!providerUri) {
|
|
216
194
|
var error = new Error('Cannot load or register client, providerURI missing');
|
|
@@ -224,7 +202,6 @@ var ClientAuthOIDC = function () {
|
|
|
224
202
|
// Check for client config stored locally
|
|
225
203
|
var key = this.keyByProvider(providerUri);
|
|
226
204
|
var clientConfig = this.store.getItem(key);
|
|
227
|
-
|
|
228
205
|
if (clientConfig) {
|
|
229
206
|
clientConfig = JSON.parse(clientConfig);
|
|
230
207
|
return RelyingParty.from(clientConfig);
|
|
@@ -238,9 +215,8 @@ var ClientAuthOIDC = function () {
|
|
|
238
215
|
* @param state {string}
|
|
239
216
|
* @return {string}
|
|
240
217
|
*/
|
|
241
|
-
|
|
242
218
|
}, {
|
|
243
|
-
key:
|
|
219
|
+
key: "loadProvider",
|
|
244
220
|
value: function loadProvider(state) {
|
|
245
221
|
var key = this.keyByState(state);
|
|
246
222
|
var providerUri = this.store.getItem(key);
|
|
@@ -258,14 +234,11 @@ var ClientAuthOIDC = function () {
|
|
|
258
234
|
*
|
|
259
235
|
* @return {Promise<string>} Resolves to the logged in user's WebID URI
|
|
260
236
|
*/
|
|
261
|
-
|
|
262
237
|
}, {
|
|
263
|
-
key:
|
|
238
|
+
key: "login",
|
|
264
239
|
value: function login(providerUri) {
|
|
265
240
|
var _this2 = this;
|
|
266
|
-
|
|
267
241
|
this.clearCurrentUser();
|
|
268
|
-
|
|
269
242
|
return Promise.resolve(providerUri).then(function (providerUri) {
|
|
270
243
|
return _this2.selectProvider(providerUri);
|
|
271
244
|
}).then(function (selectedProviderUri) {
|
|
@@ -279,7 +252,7 @@ var ClientAuthOIDC = function () {
|
|
|
279
252
|
});
|
|
280
253
|
}
|
|
281
254
|
}, {
|
|
282
|
-
key:
|
|
255
|
+
key: "clearCurrentUser",
|
|
283
256
|
value: function clearCurrentUser() {
|
|
284
257
|
this.webId = null;
|
|
285
258
|
this.accessToken = null;
|
|
@@ -292,22 +265,16 @@ var ClientAuthOIDC = function () {
|
|
|
292
265
|
* A redirect is done (instead of an ajax 'get') to enable the provider to
|
|
293
266
|
* clear any http-only session cookies.
|
|
294
267
|
*/
|
|
295
|
-
|
|
296
268
|
}, {
|
|
297
|
-
key:
|
|
269
|
+
key: "logout",
|
|
298
270
|
value: function logout() {
|
|
299
271
|
this.clearCurrentUser();
|
|
300
|
-
|
|
301
272
|
var logoutEndpoint = this.providerEndSessionEndpoint();
|
|
302
|
-
|
|
303
273
|
if (!logoutEndpoint) {
|
|
304
274
|
return;
|
|
305
275
|
}
|
|
306
|
-
|
|
307
276
|
var logoutUrl = new URL(logoutEndpoint);
|
|
308
|
-
|
|
309
277
|
logoutUrl.searchParams.set('returnToUrl', this.currentLocation());
|
|
310
|
-
|
|
311
278
|
this.redirectTo(logoutUrl.toString());
|
|
312
279
|
}
|
|
313
280
|
|
|
@@ -327,9 +294,8 @@ var ClientAuthOIDC = function () {
|
|
|
327
294
|
* app developer, just pass it through, no need to take further action.
|
|
328
295
|
* @return {Promise<string>}
|
|
329
296
|
*/
|
|
330
|
-
|
|
331
297
|
}, {
|
|
332
|
-
key:
|
|
298
|
+
key: "selectProvider",
|
|
333
299
|
value: function selectProvider(providerUri) {
|
|
334
300
|
if (providerUri) {
|
|
335
301
|
return Promise.resolve(providerUri);
|
|
@@ -352,13 +318,11 @@ var ClientAuthOIDC = function () {
|
|
|
352
318
|
*
|
|
353
319
|
* @return {string|null} Provider URI, if present
|
|
354
320
|
*/
|
|
355
|
-
|
|
356
321
|
}, {
|
|
357
|
-
key:
|
|
322
|
+
key: "providerFromCurrentUri",
|
|
358
323
|
value: function providerFromCurrentUri() {
|
|
359
324
|
var currentUri = this.currentLocation();
|
|
360
325
|
var stateParam = this.extractState(currentUri, HASH);
|
|
361
|
-
|
|
362
326
|
if (stateParam) {
|
|
363
327
|
return this.loadProvider(stateParam);
|
|
364
328
|
} else {
|
|
@@ -366,18 +330,16 @@ var ClientAuthOIDC = function () {
|
|
|
366
330
|
}
|
|
367
331
|
}
|
|
368
332
|
}, {
|
|
369
|
-
key:
|
|
333
|
+
key: "providerFromUI",
|
|
370
334
|
value: function providerFromUI() {
|
|
371
335
|
console.log('Getting provider from default popup UI');
|
|
372
336
|
this.initEventListeners(this.window);
|
|
373
|
-
|
|
374
337
|
if (this.selectProviderWindow) {
|
|
375
338
|
// Popup has already been opened
|
|
376
339
|
this.selectProviderWindow.focus();
|
|
377
340
|
} else {
|
|
378
341
|
// Open a new Provider Select popup window
|
|
379
342
|
this.selectProviderWindow = this.window.open('', 'selectProviderWindow', 'menubar=no,resizable=yes,width=300,height=300');
|
|
380
|
-
|
|
381
343
|
this.selectProviderWindow.document.write(providerSelectPopupSource);
|
|
382
344
|
this.selectProviderWindow.document.close();
|
|
383
345
|
}
|
|
@@ -388,13 +350,11 @@ var ClientAuthOIDC = function () {
|
|
|
388
350
|
* return redirect.
|
|
389
351
|
* @return {boolean}
|
|
390
352
|
*/
|
|
391
|
-
|
|
392
353
|
}, {
|
|
393
|
-
key:
|
|
354
|
+
key: "currentUriHasAuthResponse",
|
|
394
355
|
value: function currentUriHasAuthResponse() {
|
|
395
356
|
var currentUri = this.currentLocation();
|
|
396
357
|
var stateParam = this.extractState(currentUri, HASH);
|
|
397
|
-
|
|
398
358
|
return !!stateParam;
|
|
399
359
|
}
|
|
400
360
|
|
|
@@ -402,12 +362,10 @@ var ClientAuthOIDC = function () {
|
|
|
402
362
|
* Redirects the current window to the given uri.
|
|
403
363
|
* @param uri {string}
|
|
404
364
|
*/
|
|
405
|
-
|
|
406
365
|
}, {
|
|
407
|
-
key:
|
|
366
|
+
key: "redirectTo",
|
|
408
367
|
value: function redirectTo(uri) {
|
|
409
368
|
this.window.location.href = uri;
|
|
410
|
-
|
|
411
369
|
return false;
|
|
412
370
|
}
|
|
413
371
|
|
|
@@ -417,15 +375,12 @@ var ClientAuthOIDC = function () {
|
|
|
417
375
|
* @throws {Error}
|
|
418
376
|
* @return {Promise<null>}
|
|
419
377
|
*/
|
|
420
|
-
|
|
421
378
|
}, {
|
|
422
|
-
key:
|
|
379
|
+
key: "sendAuthRequest",
|
|
423
380
|
value: function sendAuthRequest(client) {
|
|
424
381
|
var _this3 = this;
|
|
425
|
-
|
|
426
382
|
var options = {};
|
|
427
383
|
var providerUri = client.provider.url;
|
|
428
|
-
|
|
429
384
|
return client.createRequest(options, this.store).then(function (authUri) {
|
|
430
385
|
var state = _this3.extractState(authUri, QUERY);
|
|
431
386
|
if (!state) {
|
|
@@ -445,23 +400,20 @@ var ClientAuthOIDC = function () {
|
|
|
445
400
|
* being sent (`null`), or to the webId of the current user (extracted
|
|
446
401
|
* from the authentication response).
|
|
447
402
|
*/
|
|
448
|
-
|
|
449
403
|
}, {
|
|
450
|
-
key:
|
|
404
|
+
key: "validateOrSendAuthRequest",
|
|
451
405
|
value: function validateOrSendAuthRequest(client) {
|
|
452
406
|
if (!client) {
|
|
453
407
|
var error = new Error('Could not load or register a RelyingParty client');
|
|
454
408
|
return Promise.reject(error);
|
|
455
409
|
}
|
|
456
|
-
|
|
457
410
|
if (this.currentUriHasAuthResponse()) {
|
|
458
411
|
return this.initUserFromResponse(client);
|
|
459
412
|
}
|
|
460
|
-
|
|
461
413
|
return this.sendAuthRequest(client);
|
|
462
414
|
}
|
|
463
415
|
}, {
|
|
464
|
-
key:
|
|
416
|
+
key: "issuePoPTokenFor",
|
|
465
417
|
value: function issuePoPTokenFor(uri, session) {
|
|
466
418
|
return PoPToken.issueFor(uri, session);
|
|
467
419
|
}
|
|
@@ -476,21 +428,17 @@ var ClientAuthOIDC = function () {
|
|
|
476
428
|
*
|
|
477
429
|
* @returns {Promise<string>} Current user's web id
|
|
478
430
|
*/
|
|
479
|
-
|
|
480
431
|
}, {
|
|
481
|
-
key:
|
|
432
|
+
key: "initUserFromResponse",
|
|
482
433
|
value: function initUserFromResponse(client) {
|
|
483
434
|
var _this4 = this;
|
|
484
|
-
|
|
485
435
|
return client.validateResponse(this.currentLocation(), this.store).then(function (response) {
|
|
486
436
|
_this4.idToken = response.authorization.id_token;
|
|
487
437
|
_this4.accessToken = response.authorization.access_token;
|
|
488
438
|
_this4.session = response;
|
|
489
|
-
|
|
490
439
|
_this4.clearAuthResponseFromUrl();
|
|
491
|
-
|
|
492
440
|
return _this4.extractAndValidateWebId(response.idClaims.sub);
|
|
493
|
-
})
|
|
441
|
+
})["catch"](function (error) {
|
|
494
442
|
_this4.clearAuthResponseFromUrl();
|
|
495
443
|
if (error.message === 'Cannot resolve signing key for ID Token.') {
|
|
496
444
|
console.log('ID Token found, but could not validate. Provider likely has changed their public keys. Please retry login.');
|
|
@@ -508,9 +456,8 @@ var ClientAuthOIDC = function () {
|
|
|
508
456
|
*
|
|
509
457
|
* @return {string}
|
|
510
458
|
*/
|
|
511
|
-
|
|
512
459
|
}, {
|
|
513
|
-
key:
|
|
460
|
+
key: "extractAndValidateWebId",
|
|
514
461
|
value: function extractAndValidateWebId(idToken) {
|
|
515
462
|
var webId = idToken;
|
|
516
463
|
this.webId = webId;
|
|
@@ -521,37 +468,31 @@ var ClientAuthOIDC = function () {
|
|
|
521
468
|
* Removes authentication response data (access token, id token etc) from
|
|
522
469
|
* the current url's hash fragment.
|
|
523
470
|
*/
|
|
524
|
-
|
|
525
471
|
}, {
|
|
526
|
-
key:
|
|
472
|
+
key: "clearAuthResponseFromUrl",
|
|
527
473
|
value: function clearAuthResponseFromUrl() {
|
|
528
474
|
var clearedUrl = this.currentLocationNoHash();
|
|
529
|
-
|
|
530
475
|
this.replaceCurrentUrl(clearedUrl);
|
|
531
476
|
}
|
|
532
477
|
}, {
|
|
533
|
-
key:
|
|
478
|
+
key: "currentLocationNoHash",
|
|
534
479
|
value: function currentLocationNoHash() {
|
|
535
480
|
var currentLocation = this.currentLocation();
|
|
536
481
|
if (!currentLocation) {
|
|
537
482
|
return null;
|
|
538
483
|
}
|
|
539
|
-
|
|
540
484
|
var currentUrl = new URL(this.currentLocation());
|
|
541
485
|
currentUrl.hash = ''; // remove the hash fragment
|
|
542
486
|
var clearedUrl = currentUrl.toString();
|
|
543
|
-
|
|
544
487
|
return clearedUrl;
|
|
545
488
|
}
|
|
546
489
|
}, {
|
|
547
|
-
key:
|
|
490
|
+
key: "replaceCurrentUrl",
|
|
548
491
|
value: function replaceCurrentUrl(newUrl) {
|
|
549
492
|
var history = this.window.history;
|
|
550
|
-
|
|
551
493
|
if (!history) {
|
|
552
494
|
return;
|
|
553
495
|
}
|
|
554
|
-
|
|
555
496
|
history.replaceState(history.state, history.title, newUrl);
|
|
556
497
|
}
|
|
557
498
|
|
|
@@ -563,14 +504,11 @@ var ClientAuthOIDC = function () {
|
|
|
563
504
|
* @throws {TypeError} If providerUri is missing
|
|
564
505
|
* @return {Promise<RelyingParty>} Registered RelyingParty client instance
|
|
565
506
|
*/
|
|
566
|
-
|
|
567
507
|
}, {
|
|
568
|
-
key:
|
|
508
|
+
key: "registerClient",
|
|
569
509
|
value: function registerClient(providerUri) {
|
|
570
510
|
var _this5 = this;
|
|
571
|
-
|
|
572
511
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
573
|
-
|
|
574
512
|
return this.registerPublicClient(providerUri, options).then(function (registeredClient) {
|
|
575
513
|
_this5.storeClient(registeredClient, providerUri);
|
|
576
514
|
return registeredClient;
|
|
@@ -586,12 +524,10 @@ var ClientAuthOIDC = function () {
|
|
|
586
524
|
* @throws {TypeError} If providerUri is missing
|
|
587
525
|
* @return {Promise<RelyingParty>} Registered RelyingParty client instance
|
|
588
526
|
*/
|
|
589
|
-
|
|
590
527
|
}, {
|
|
591
|
-
key:
|
|
528
|
+
key: "registerPublicClient",
|
|
592
529
|
value: function registerPublicClient(providerUri) {
|
|
593
530
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
594
|
-
|
|
595
531
|
console.log('Registering public client...');
|
|
596
532
|
if (!providerUri) {
|
|
597
533
|
throw new TypeError('Cannot registerClient auth client, missing providerUri');
|
|
@@ -609,7 +545,8 @@ var ClientAuthOIDC = function () {
|
|
|
609
545
|
defaults: {
|
|
610
546
|
authenticate: {
|
|
611
547
|
redirect_uri: redirectUri,
|
|
612
|
-
response_type: 'id_token token'
|
|
548
|
+
response_type: 'id_token token',
|
|
549
|
+
scope: options.scope || 'openid profile'
|
|
613
550
|
}
|
|
614
551
|
},
|
|
615
552
|
store: this.store
|
|
@@ -617,7 +554,7 @@ var ClientAuthOIDC = function () {
|
|
|
617
554
|
return RelyingParty.register(providerUri, registration, rpOptions);
|
|
618
555
|
}
|
|
619
556
|
}, {
|
|
620
|
-
key:
|
|
557
|
+
key: "onMessage",
|
|
621
558
|
value: function onMessage(event) {
|
|
622
559
|
console.log('Auth client received event: ', event);
|
|
623
560
|
if (!event || !event.data) {
|
|
@@ -642,9 +579,8 @@ var ClientAuthOIDC = function () {
|
|
|
642
579
|
* @param providerUri {string}
|
|
643
580
|
* @throws {Error}
|
|
644
581
|
*/
|
|
645
|
-
|
|
646
582
|
}, {
|
|
647
|
-
key:
|
|
583
|
+
key: "saveProviderByState",
|
|
648
584
|
value: function saveProviderByState(state, providerUri) {
|
|
649
585
|
if (!state) {
|
|
650
586
|
throw new Error('Cannot save providerUri - state not provided');
|
|
@@ -658,16 +594,12 @@ var ClientAuthOIDC = function () {
|
|
|
658
594
|
* @param client {RelyingParty}
|
|
659
595
|
* @param providerUri {string}
|
|
660
596
|
*/
|
|
661
|
-
|
|
662
597
|
}, {
|
|
663
|
-
key:
|
|
598
|
+
key: "storeClient",
|
|
664
599
|
value: function storeClient(client, providerUri) {
|
|
665
600
|
this.currentClient = client;
|
|
666
601
|
this.store.setItem(this.keyByProvider(providerUri), client.serialize());
|
|
667
602
|
}
|
|
668
603
|
}]);
|
|
669
|
-
|
|
670
|
-
return ClientAuthOIDC;
|
|
671
604
|
}();
|
|
672
|
-
|
|
673
605
|
module.exports = ClientAuthOIDC;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
module.exports =
|
|
3
|
+
module.exports = "<!doctype html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n <meta http-equiv=\"Content-type\" content=\"text/html;charset=utf-8\">\n <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css\" />\n\n</head>\n<body>\n<div class=\"container\">\n <div class=\"row\">\n <div class=\"col-xs-12 text-center\" style=\"margin-top: 3em;\">\n Login with:\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-xs-12 text-center\" style=\"padding-top: 2em;\">\n <button type=\"button\" class=\"btn btn-md btn-primary\" id=\"testProvider\">\n solidtest.space\n </button>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-xs-12 text-center\" style=\"padding-top: 2em;\">\n or custom:<br />\n <input type=\"text\" id=\"customProviderUri\" value=\"https://\" />\n <button type=\"button\" class=\"btn btn-md\" id=\"customProvider\">Go</button>\n </div>\n </div>\n</div>\n<script type=\"text/javascript\">\n window.addEventListener('load', function () { init() });\n\n function init () {\n initEvents()\n }\n\n function initButton(id, action) {\n document.getElementById(id).addEventListener('click', action)\n }\n\n function initEvents () {\n initButton('testProvider',\n function () { selectProvider('https://solidtest.space') })\n initButton('customProvider',\n function () {\n var defaultValue = 'https://'\n var customUri = document.getElementById('customProviderUri')\n if (customUri && customUri.value !== defaultValue) {\n selectProvider(customUri.value)\n }\n })\n }\n\n function selectProvider (providerUri) {\n console.log('Provider selected: ', providerUri)\n var message = {\n event_type: 'providerSelected',\n value: providerUri\n }\n console.log('opener.window.location: ', opener.window.location.href)\n\n opener.postMessage(message, opener.window.location.origin)\n }\n</script>\n</body>\n</html>\n";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solid/solid-auth-oidc",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6-79cb832b",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">= 6.0"
|
|
6
6
|
},
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
],
|
|
13
13
|
"scripts": {
|
|
14
14
|
"build": "npm run build-lib",
|
|
15
|
-
"build-dist": "webpack --progress
|
|
15
|
+
"build-dist": "webpack --progress",
|
|
16
16
|
"build-lib": "babel src -d lib",
|
|
17
17
|
"dist": "npm run build && npm run build-dist",
|
|
18
18
|
"mocha": "nyc mocha test/*.js",
|
|
19
19
|
"postversion": "git push --follow-tags",
|
|
20
|
-
"
|
|
20
|
+
"ignore:prepublishOnly": "npm run build && npm run test",
|
|
21
21
|
"preversion": "npm test",
|
|
22
22
|
"standard": "standard src/*",
|
|
23
23
|
"test": "npm run standard && npm run mocha"
|
|
@@ -52,28 +52,28 @@
|
|
|
52
52
|
"author": "Dmitri Zagidulin <dzagidulin@gmail.com>",
|
|
53
53
|
"license": "MIT",
|
|
54
54
|
"bugs": {
|
|
55
|
-
"url": "https://github.com/solid/solid-auth-oidc/issues"
|
|
55
|
+
"url": "https://github.com/node-solid-server/solid-auth-oidc/issues"
|
|
56
56
|
},
|
|
57
|
-
"homepage": "https://github.com/solid/solid-auth-oidc",
|
|
57
|
+
"homepage": "https://github.com/node-solid-server/solid-auth-oidc",
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@solid/oidc-rp": "^0.11.
|
|
59
|
+
"@solid/oidc-rp": "^0.11.10"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"babel
|
|
63
|
-
"babel
|
|
64
|
-
"babel-
|
|
65
|
-
"babel-
|
|
66
|
-
"chai": "^4.
|
|
67
|
-
"chai-as-promised": "^7.1.
|
|
62
|
+
"@babel/cli": "^7.28.3",
|
|
63
|
+
"@babel/core": "^7.28.5",
|
|
64
|
+
"@babel/preset-env": "^7.28.5",
|
|
65
|
+
"babel-loader": "^8.4.1",
|
|
66
|
+
"chai": "^4.5.0",
|
|
67
|
+
"chai-as-promised": "^7.1.2",
|
|
68
68
|
"dirty-chai": "^2.0.1",
|
|
69
69
|
"localstorage-memory": "^1.0.3",
|
|
70
|
-
"mocha": "^
|
|
71
|
-
"nyc": "^
|
|
70
|
+
"mocha": "^11.7.5",
|
|
71
|
+
"nyc": "^17.1.0",
|
|
72
72
|
"sinon": "^9.2.4",
|
|
73
|
-
"sinon-chai": "^3.
|
|
74
|
-
"standard": "^
|
|
75
|
-
"webpack": "^5.
|
|
76
|
-
"whatwg-url": "^
|
|
73
|
+
"sinon-chai": "^3.7.0",
|
|
74
|
+
"standard": "^17.1.2",
|
|
75
|
+
"webpack": "^5.104.0",
|
|
76
|
+
"whatwg-url": "^15.1.0"
|
|
77
77
|
},
|
|
78
78
|
"standard": {
|
|
79
79
|
"globals": [
|