@inrupt/solid-client-authn-browser 1.11.9-alpha.1 → 1.11.9-alpha.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/dist/index.es.js +4 -352
- package/dist/index.es.js.map +1 -0
- package/dist/index.js +12 -360
- package/dist/index.js.map +1 -1
- package/dist/solid-client-authn.bundle.js +14 -363
- package/dist/solid-client-authn.bundle.js.map +1 -0
- package/package.json +8 -5
- package/.eslintrc.js +0 -16
- package/NOTICE +0 -5
- package/coverage/clover.xml +0 -547
- package/coverage/coverage-final.json +0 -28
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -266
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/src/ClientAuthentication.ts.html +0 -631
- package/coverage/lcov-report/src/Session.ts.html +0 -1435
- package/coverage/lcov-report/src/constant.ts.html +0 -163
- package/coverage/lcov-report/src/defaultSession.ts.html +0 -460
- package/coverage/lcov-report/src/dependencies.ts.html +0 -400
- package/coverage/lcov-report/src/iframe.ts.html +0 -394
- package/coverage/lcov-report/src/index.browser.ts.html +0 -157
- package/coverage/lcov-report/src/index.html +0 -206
- package/coverage/lcov-report/src/login/AggregateLoginHandler.ts.html +0 -226
- package/coverage/lcov-report/src/login/index.html +0 -116
- package/coverage/lcov-report/src/login/oidc/AggregateOidcHandler.ts.html +0 -226
- package/coverage/lcov-report/src/login/oidc/ClientRegistrar.ts.html +0 -415
- package/coverage/lcov-report/src/login/oidc/IssuerConfigFetcher.ts.html +0 -646
- package/coverage/lcov-report/src/login/oidc/OidcLoginHandler.ts.html +0 -436
- package/coverage/lcov-report/src/login/oidc/Redirector.ts.html +0 -229
- package/coverage/lcov-report/src/login/oidc/index.html +0 -176
- package/coverage/lcov-report/src/login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler.ts.html +0 -478
- package/coverage/lcov-report/src/login/oidc/oidcHandlers/OidcHandlerCanHandleTest.ts.html +0 -319
- package/coverage/lcov-report/src/login/oidc/oidcHandlers/index.html +0 -131
- package/coverage/lcov-report/src/login/oidc/redirectHandler/AggregateRedirectHandler.ts.html +0 -226
- package/coverage/lcov-report/src/login/oidc/redirectHandler/AuthCodeRedirectHandler.ts.html +0 -667
- package/coverage/lcov-report/src/login/oidc/redirectHandler/ErrorOidcHandler.ts.html +0 -283
- package/coverage/lcov-report/src/login/oidc/redirectHandler/FallbackRedirectHandler.ts.html +0 -265
- package/coverage/lcov-report/src/login/oidc/redirectHandler/index.html +0 -161
- package/coverage/lcov-report/src/login/oidc/refresh/TokenRefresher.ts.html +0 -385
- package/coverage/lcov-report/src/login/oidc/refresh/index.html +0 -116
- package/coverage/lcov-report/src/login/webid/WebIdLoginHandler.ts.html +0 -250
- package/coverage/lcov-report/src/login/webid/index.html +0 -116
- package/coverage/lcov-report/src/logout/GeneralLogoutHandler.ts.html +0 -220
- package/coverage/lcov-report/src/logout/index.html +0 -116
- package/coverage/lcov-report/src/sessionInfo/SessionInfoManager.ts.html +0 -775
- package/coverage/lcov-report/src/sessionInfo/index.html +0 -116
- package/coverage/lcov-report/src/storage/BrowserStorage.ts.html +0 -229
- package/coverage/lcov-report/src/storage/StorageUtility.ts.html +0 -214
- package/coverage/lcov-report/src/storage/index.html +0 -131
- package/coverage/lcov-report/src/util/UuidGenerator.ts.html +0 -226
- package/coverage/lcov-report/src/util/index.html +0 -131
- package/coverage/lcov-report/src/util/urlPath.ts.html +0 -208
- package/coverage/lcov.info +0 -1001
- package/dist/ClientAuthentication.js +0 -64
- package/dist/ClientAuthentication.js.map +0 -1
- package/dist/Session.js +0 -165
- package/dist/Session.js.map +0 -1
- package/dist/constant.js +0 -7
- package/dist/constant.js.map +0 -1
- package/dist/defaultSession.js +0 -48
- package/dist/defaultSession.js.map +0 -1
- package/dist/dependencies.js +0 -41
- package/dist/dependencies.js.map +0 -1
- package/dist/iframe.js +0 -43
- package/dist/iframe.js.map +0 -1
- package/dist/index.browser.d.ts +0 -1
- package/dist/index.browser.js +0 -28
- package/dist/index.browser.js.map +0 -1
- package/dist/login/AggregateLoginHandler.js +0 -10
- package/dist/login/AggregateLoginHandler.js.map +0 -1
- package/dist/login/oidc/AggregateOidcHandler.js +0 -10
- package/dist/login/oidc/AggregateOidcHandler.js.map +0 -1
- package/dist/login/oidc/ClientRegistrar.js +0 -51
- package/dist/login/oidc/ClientRegistrar.js.map +0 -1
- package/dist/login/oidc/IssuerConfigFetcher.js +0 -124
- package/dist/login/oidc/IssuerConfigFetcher.js.map +0 -1
- package/dist/login/oidc/OidcLoginHandler.js +0 -40
- package/dist/login/oidc/OidcLoginHandler.js.map +0 -1
- package/dist/login/oidc/Redirector.js +0 -21
- package/dist/login/oidc/Redirector.js.map +0 -1
- package/dist/login/oidc/__mocks__/IOidcOptions.d.ts +0 -2
- package/dist/login/oidc/__mocks__/IOidcOptions.js +0 -25
- package/dist/login/oidc/__mocks__/IOidcOptions.js.map +0 -1
- package/dist/login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler.js +0 -56
- package/dist/login/oidc/oidcHandlers/AuthorizationCodeWithPkceOidcHandler.js.map +0 -1
- package/dist/login/oidc/oidcHandlers/OidcHandlerCanHandleTest.js +0 -47
- package/dist/login/oidc/oidcHandlers/OidcHandlerCanHandleTest.js.map +0 -1
- package/dist/login/oidc/redirectHandler/AggregateRedirectHandler.js +0 -10
- package/dist/login/oidc/redirectHandler/AggregateRedirectHandler.js.map +0 -1
- package/dist/login/oidc/redirectHandler/AuthCodeRedirectHandler.js +0 -92
- package/dist/login/oidc/redirectHandler/AuthCodeRedirectHandler.js.map +0 -1
- package/dist/login/oidc/redirectHandler/ErrorOidcHandler.js +0 -26
- package/dist/login/oidc/redirectHandler/ErrorOidcHandler.js.map +0 -1
- package/dist/login/oidc/redirectHandler/FallbackRedirectHandler.js +0 -20
- package/dist/login/oidc/redirectHandler/FallbackRedirectHandler.js.map +0 -1
- package/dist/login/oidc/refresh/TokenRefresher.js +0 -31
- package/dist/login/oidc/refresh/TokenRefresher.js.map +0 -1
- package/dist/login/webid/WebIdLoginHandler.js +0 -12
- package/dist/login/webid/WebIdLoginHandler.js.map +0 -1
- package/dist/logout/GeneralLogoutHandler.js +0 -15
- package/dist/logout/GeneralLogoutHandler.js.map +0 -1
- package/dist/sessionInfo/SessionInfoManager.js +0 -95
- package/dist/sessionInfo/SessionInfoManager.js.map +0 -1
- package/dist/solid-client-authn.bundle.js.LICENSE.txt +0 -17
- package/dist/storage/BrowserStorage.js +0 -18
- package/dist/storage/BrowserStorage.js.map +0 -1
- package/dist/storage/StorageUtility.js +0 -10
- package/dist/storage/StorageUtility.js.map +0 -1
- package/dist/util/UuidGenerator.js +0 -10
- package/dist/util/UuidGenerator.js.map +0 -1
- package/dist/util/urlPath.js +0 -11
- package/dist/util/urlPath.js.map +0 -1
- package/docs/api/Makefile +0 -76
- package/docs/api/README.md +0 -46
- package/docs/api/build/docs-assets/README.md +0 -183
- package/docs/api/build/docs-assets/_static/css/inrupt.css +0 -349
- package/docs/api/build/docs-assets/_templates/breadcrumb-navigation.html +0 -10
- package/docs/api/build/docs-assets/_templates/copyright.html +0 -3
- package/docs/api/build/docs-assets/_templates/docs-sidebar.html +0 -32
- package/docs/api/build/docs-assets/_templates/docs-version-selector.html +0 -21
- package/docs/api/build/docs-assets/_templates/jira-feedback.html +0 -21
- package/docs/api/build/docs-assets/_templates/layout.html +0 -34
- package/docs/api/build/docs-assets/_templates/matomo.html +0 -18
- package/docs/api/build/docs-assets/_templates/navbar-logo.html +0 -5
- package/docs/api/build/docs-assets/_templates/navbar-nav.html +0 -44
- package/docs/api/build/docs-assets/_templates/prev-next.html +0 -19
- package/docs/api/build/docs-assets/_templates/versioned-canonical.html +0 -8
- package/docs/api/build/docs-assets/themes/inrupt/theme.conf +0 -18
- package/docs/api/build/doctrees/classes/ConfigurationError.doctree +0 -0
- package/docs/api/build/doctrees/classes/InMemoryStorage.doctree +0 -0
- package/docs/api/build/doctrees/classes/NotImplementedError.doctree +0 -0
- package/docs/api/build/doctrees/classes/Session.doctree +0 -0
- package/docs/api/build/doctrees/environment.pickle +0 -0
- package/docs/api/build/doctrees/functions.doctree +0 -0
- package/docs/api/build/doctrees/index.doctree +0 -0
- package/docs/api/build/doctrees/interfaces/ILoginInputOptions.doctree +0 -0
- package/docs/api/build/doctrees/interfaces/ISessionInfo.doctree +0 -0
- package/docs/api/build/doctrees/interfaces/ISessionOptions.doctree +0 -0
- package/docs/api/build/doctrees/interfaces/IStorage.doctree +0 -0
- package/docs/api/build/html/.buildinfo +0 -4
- package/docs/api/build/html/_static/basic.css +0 -905
- package/docs/api/build/html/_static/css/blank.css +0 -2
- package/docs/api/build/html/_static/css/index.ff1ffe594081f20da1ef19478df9384b.css +0 -6
- package/docs/api/build/html/_static/css/inrupt.css +0 -349
- package/docs/api/build/html/_static/css/theme.css +0 -120
- package/docs/api/build/html/_static/doctools.js +0 -323
- package/docs/api/build/html/_static/documentation_options.js +0 -12
- package/docs/api/build/html/_static/file.png +0 -0
- package/docs/api/build/html/_static/jquery-3.5.1.js +0 -10872
- package/docs/api/build/html/_static/jquery.js +0 -2
- package/docs/api/build/html/_static/js/index.be7d3bbb2ef33a8344ce.js +0 -32
- package/docs/api/build/html/_static/language_data.js +0 -297
- package/docs/api/build/html/_static/minus.png +0 -0
- package/docs/api/build/html/_static/plus.png +0 -0
- package/docs/api/build/html/_static/pygments.css +0 -74
- package/docs/api/build/html/_static/searchtools.js +0 -529
- package/docs/api/build/html/_static/underscore-1.13.1.js +0 -2042
- package/docs/api/build/html/_static/underscore.js +0 -6
- package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/LICENSE.txt +0 -34
- package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/css/all.min.css +0 -5
- package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-brands-400.eot +0 -0
- package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-brands-400.svg +0 -3570
- package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-brands-400.ttf +0 -0
- package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-brands-400.woff +0 -0
- package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-brands-400.woff2 +0 -0
- package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-regular-400.eot +0 -0
- package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-regular-400.svg +0 -803
- package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-regular-400.ttf +0 -0
- package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-regular-400.woff +0 -0
- package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-regular-400.woff2 +0 -0
- package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-solid-900.eot +0 -0
- package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-solid-900.svg +0 -4938
- package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-solid-900.ttf +0 -0
- package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-solid-900.woff +0 -0
- package/docs/api/build/html/_static/vendor/fontawesome/5.13.0/webfonts/fa-solid-900.woff2 +0 -0
- package/docs/api/build/html/_static/webpack-macros.html +0 -25
- package/docs/api/build/html/classes/ConfigurationError.html +0 -726
- package/docs/api/build/html/classes/InMemoryStorage.html +0 -636
- package/docs/api/build/html/classes/NotImplementedError.html +0 -726
- package/docs/api/build/html/classes/Session.html +0 -2428
- package/docs/api/build/html/functions.html +0 -834
- package/docs/api/build/html/genindex.html +0 -311
- package/docs/api/build/html/index.html +0 -342
- package/docs/api/build/html/interfaces/ILoginInputOptions.html +0 -595
- package/docs/api/build/html/interfaces/ISessionInfo.html +0 -481
- package/docs/api/build/html/interfaces/ISessionOptions.html +0 -463
- package/docs/api/build/html/interfaces/IStorage.html +0 -531
- package/docs/api/build/html/objects.inv +0 -0
- package/docs/api/build/html/search.html +0 -340
- package/docs/api/build/html/searchindex.js +0 -1
- package/docs/api/build/source/classes/ConfigurationError.md +0 -159
- package/docs/api/build/source/classes/InMemoryStorage.md +0 -112
- package/docs/api/build/source/classes/NotImplementedError.md +0 -159
- package/docs/api/build/source/classes/Session.md +0 -907
- package/docs/api/build/source/functions.md +0 -235
- package/docs/api/build/source/index.rst +0 -13
- package/docs/api/build/source/interfaces/ILoginInputOptions.md +0 -109
- package/docs/api/build/source/interfaces/ISessionInfo.md +0 -63
- package/docs/api/build/source/interfaces/ISessionOptions.md +0 -60
- package/docs/api/build/source/interfaces/IStorage.md +0 -76
- package/docs/api/conf.py +0 -135
- package/docs/api/redirects.txt +0 -41
- package/docs/api/requirements.txt +0 -5
- package/docs/api/source/api/.nojekyll +0 -1
- package/docs/api/source/api/classes/ConfigurationError.md +0 -163
- package/docs/api/source/api/classes/InMemoryStorage.md +0 -112
- package/docs/api/source/api/classes/NotImplementedError.md +0 -163
- package/docs/api/source/api/classes/Session.md +0 -1426
- package/docs/api/source/api/index.md +0 -251
- package/docs/api/source/api/interfaces/ILoginInputOptions.md +0 -109
- package/docs/api/source/api/interfaces/ISessionInfo.md +0 -63
- package/docs/api/source/api/interfaces/ISessionOptions.md +0 -60
- package/docs/api/source/api/interfaces/IStorage.md +0 -76
- package/docs/api/source/functions.md +0 -3
- package/docs/api/source/index.rst +0 -13
- package/examples/demoAuthentiationMonitor/index.js +0 -34
- package/examples/demoAuthentiationMonitor/package-lock.json +0 -916
- package/examples/demoAuthentiationMonitor/package.json +0 -15
- package/examples/demoClientApp/.babelrc +0 -3
- package/examples/demoClientApp/package-lock.json +0 -11710
- package/examples/demoClientApp/package.json +0 -37
- package/examples/demoClientApp/src/DemoClientApp.js +0 -686
- package/examples/demoClientApp/src/index.html +0 -142
- package/examples/demoClientApp/src/index.js +0 -26
- package/examples/demoClientApp/webpack.config.js +0 -39
- package/examples/single/bundle/.babelrc +0 -3
- package/examples/single/bundle/README.md +0 -11
- package/examples/single/bundle/client-app-profile.ttl +0 -10
- package/examples/single/bundle/package-lock.json +0 -11196
- package/examples/single/bundle/package.json +0 -31
- package/examples/single/bundle/src/App.js +0 -123
- package/examples/single/bundle/src/index.html +0 -10
- package/examples/single/bundle/src/index.js +0 -26
- package/examples/single/bundle/webpack.config.js +0 -33
- package/examples/single/script/README.md +0 -11
- package/examples/single/script/index.html +0 -36
- package/examples/single/script/package-lock.json +0 -1293
- package/examples/single/script/package.json +0 -20
- package/examples/single/script/server.ts +0 -18
- package/jest.config.js +0 -10
- package/licenses.csv +0 -147
- package/rollup.config.js +0 -54
- package/sampleFlows/SolidAuthClientArchitecture.png +0 -0
- package/sampleFlows/authorization-code-with-pkce.png +0 -0
- package/sampleFlows/authorization-code-with-pkce.seqdiag +0 -46
- package/sampleFlows/authorization-code.png +0 -0
- package/sampleFlows/authorization-code.seqdiag +0 -50
- package/sampleFlows/client-credentials.png +0 -0
- package/sampleFlows/client-credentials.seqdiag +0 -38
- package/sampleFlows/legacy-implicit-flow.png +0 -0
- package/sampleFlows/legacy-implicit-flow.seqdiag +0 -43
- package/sampleFlows/self-signed.png +0 -0
- package/sampleFlows/self-signed.seqdiag +0 -49
- package/sampleFlows/signatory-access-control.seqdiag +0 -36
- package/sampleFlows/signatory-access-control.svg +0 -1
- package/tsconfig.eslint.json +0 -6
- package/tsconfig.json +0 -17
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { StorageUtility,
|
|
1
|
+
import { StorageUtility, EVENTS, ConfigurationError, handleRegistration, isSupportedTokenType, loadOidcContextFromStorage, buildAuthenticatedFetch, AggregateHandler, InMemoryStorage, SOLID_CLIENT_AUTHN_KEY_PREFIX } from '@inrupt/solid-client-authn-core';
|
|
2
2
|
export { ConfigurationError, InMemoryStorage, NotImplementedError } from '@inrupt/solid-client-authn-core';
|
|
3
|
-
import {
|
|
3
|
+
import { v4 } from 'uuid';
|
|
4
|
+
import { removeOidcQueryParam, OidcClient, clearOidcPersistentStorage, getDpopToken, getBearerToken, registerClient, refresh } from '@inrupt/oidc-client-ext';
|
|
4
5
|
|
|
5
6
|
var domain;
|
|
6
7
|
|
|
@@ -474,362 +475,12 @@ function unwrapListeners(arr) {
|
|
|
474
475
|
return ret;
|
|
475
476
|
}
|
|
476
477
|
|
|
477
|
-
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
478
|
-
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
479
|
-
// generators (like Math.random()).
|
|
480
|
-
var getRandomValues;
|
|
481
|
-
var rnds8 = new Uint8Array(16);
|
|
482
|
-
function rng() {
|
|
483
|
-
// lazy load so that environments that need to polyfill have a chance to do so
|
|
484
|
-
if (!getRandomValues) {
|
|
485
|
-
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
|
|
486
|
-
// find the complete implementation of crypto (msCrypto) on IE11.
|
|
487
|
-
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
|
|
488
|
-
|
|
489
|
-
if (!getRandomValues) {
|
|
490
|
-
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
return getRandomValues(rnds8);
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
|
498
|
-
|
|
499
|
-
function validate(uuid) {
|
|
500
|
-
return typeof uuid === 'string' && REGEX.test(uuid);
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* Convert array of 16 byte values to UUID string format of the form:
|
|
505
|
-
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
506
|
-
*/
|
|
507
|
-
|
|
508
|
-
var byteToHex = [];
|
|
509
|
-
|
|
510
|
-
for (var i = 0; i < 256; ++i) {
|
|
511
|
-
byteToHex.push((i + 0x100).toString(16).substr(1));
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
function stringify(arr) {
|
|
515
|
-
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
516
|
-
// Note: Be careful editing this code! It's been tuned for performance
|
|
517
|
-
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
518
|
-
var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
|
|
519
|
-
// of the following:
|
|
520
|
-
// - One or more input array values don't map to a hex octet (leading to
|
|
521
|
-
// "undefined" in the uuid)
|
|
522
|
-
// - Invalid input values for the RFC `version` or `variant` fields
|
|
523
|
-
|
|
524
|
-
if (!validate(uuid)) {
|
|
525
|
-
throw TypeError('Stringified UUID is invalid');
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
return uuid;
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
function v4(options, buf, offset) {
|
|
532
|
-
options = options || {};
|
|
533
|
-
var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
534
|
-
|
|
535
|
-
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
536
|
-
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
537
|
-
|
|
538
|
-
if (buf) {
|
|
539
|
-
offset = offset || 0;
|
|
540
|
-
|
|
541
|
-
for (var i = 0; i < 16; ++i) {
|
|
542
|
-
buf[offset + i] = rnds[i];
|
|
543
|
-
}
|
|
544
|
-
|
|
545
|
-
return buf;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
return stringify(rnds);
|
|
549
|
-
}
|
|
550
|
-
|
|
551
478
|
class StorageUtilityBrowser extends StorageUtility {
|
|
552
479
|
constructor(secureStorage, insecureStorage) {
|
|
553
480
|
super(secureStorage, insecureStorage);
|
|
554
481
|
}
|
|
555
482
|
}
|
|
556
483
|
|
|
557
|
-
function processErrorResponse(responseBody, options) {
|
|
558
|
-
var _a, _b, _c, _d;
|
|
559
|
-
if (responseBody.error === "invalid_redirect_uri") {
|
|
560
|
-
throw new Error(`Dynamic client registration failed: the provided redirect uri [${(_a = options.redirectUrl) === null || _a === void 0 ? void 0 : _a.toString()}] is invalid - ${(_b = responseBody.error_description) !== null && _b !== void 0 ? _b : ""}`);
|
|
561
|
-
}
|
|
562
|
-
if (responseBody.error === "invalid_client_metadata") {
|
|
563
|
-
throw new Error(`Dynamic client registration failed: the provided client metadata ${JSON.stringify(options)} is invalid - ${(_c = responseBody.error_description) !== null && _c !== void 0 ? _c : ""}`);
|
|
564
|
-
}
|
|
565
|
-
throw new Error(`Dynamic client registration failed: ${responseBody.error} - ${(_d = responseBody.error_description) !== null && _d !== void 0 ? _d : ""}`);
|
|
566
|
-
}
|
|
567
|
-
function validateRegistrationResponse(responseBody, options) {
|
|
568
|
-
if (responseBody.client_id === undefined) {
|
|
569
|
-
throw new Error(`Dynamic client registration failed: no client_id has been found on ${JSON.stringify(responseBody)}`);
|
|
570
|
-
}
|
|
571
|
-
if (options.redirectUrl &&
|
|
572
|
-
(responseBody.redirect_uris === undefined ||
|
|
573
|
-
responseBody.redirect_uris[0] !== options.redirectUrl.toString())) {
|
|
574
|
-
throw new Error(`Dynamic client registration failed: the returned redirect URIs ${JSON.stringify(responseBody.redirect_uris)} don't match the provided ${JSON.stringify([
|
|
575
|
-
options.redirectUrl.toString(),
|
|
576
|
-
])}`);
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
async function registerClient(options, issuerConfig) {
|
|
580
|
-
var _a;
|
|
581
|
-
if (!issuerConfig.registrationEndpoint) {
|
|
582
|
-
throw new Error("Dynamic Registration could not be completed because the issuer has no registration endpoint.");
|
|
583
|
-
}
|
|
584
|
-
if (!Array.isArray(issuerConfig.idTokenSigningAlgValuesSupported)) {
|
|
585
|
-
throw new Error("The OIDC issuer discovery profile is missing the 'id_token_signing_alg_values_supported' value, which is mandatory.");
|
|
586
|
-
}
|
|
587
|
-
const signingAlg = determineSigningAlg(issuerConfig.idTokenSigningAlgValuesSupported, PREFERRED_SIGNING_ALG);
|
|
588
|
-
const config = {
|
|
589
|
-
client_name: options.clientName,
|
|
590
|
-
application_type: "web",
|
|
591
|
-
redirect_uris: [(_a = options.redirectUrl) === null || _a === void 0 ? void 0 : _a.toString()],
|
|
592
|
-
subject_type: "public",
|
|
593
|
-
token_endpoint_auth_method: "client_secret_basic",
|
|
594
|
-
id_token_signed_response_alg: signingAlg,
|
|
595
|
-
grant_types: ["authorization_code", "refresh_token"],
|
|
596
|
-
};
|
|
597
|
-
const headers = {
|
|
598
|
-
"Content-Type": "application/json",
|
|
599
|
-
};
|
|
600
|
-
if (options.registrationAccessToken) {
|
|
601
|
-
headers.Authorization = `Bearer ${options.registrationAccessToken}`;
|
|
602
|
-
}
|
|
603
|
-
const registerResponse = await fetch(issuerConfig.registrationEndpoint.toString(), {
|
|
604
|
-
method: "POST",
|
|
605
|
-
headers,
|
|
606
|
-
body: JSON.stringify(config),
|
|
607
|
-
});
|
|
608
|
-
if (registerResponse.ok) {
|
|
609
|
-
const responseBody = await registerResponse.json();
|
|
610
|
-
validateRegistrationResponse(responseBody, options);
|
|
611
|
-
return {
|
|
612
|
-
clientId: responseBody.client_id,
|
|
613
|
-
clientSecret: responseBody.client_secret,
|
|
614
|
-
idTokenSignedResponseAlg: responseBody.id_token_signed_response_alg,
|
|
615
|
-
clientType: "dynamic",
|
|
616
|
-
};
|
|
617
|
-
}
|
|
618
|
-
if (registerResponse.status === 400) {
|
|
619
|
-
processErrorResponse(await registerResponse.json(), options);
|
|
620
|
-
}
|
|
621
|
-
throw new Error(`Dynamic client registration failed: the server returned ${registerResponse.status} ${registerResponse.statusText} - ${await registerResponse.text()}`);
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
function hasError(value) {
|
|
625
|
-
return value.error !== undefined && typeof value.error === "string";
|
|
626
|
-
}
|
|
627
|
-
function hasErrorDescription(value) {
|
|
628
|
-
return (value.error_description !== undefined &&
|
|
629
|
-
typeof value.error_description === "string");
|
|
630
|
-
}
|
|
631
|
-
function hasErrorUri(value) {
|
|
632
|
-
return value.error_uri !== undefined && typeof value.error_uri === "string";
|
|
633
|
-
}
|
|
634
|
-
function hasAccessToken(value) {
|
|
635
|
-
return (value.access_token !== undefined && typeof value.access_token === "string");
|
|
636
|
-
}
|
|
637
|
-
function hasIdToken(value) {
|
|
638
|
-
return value.id_token !== undefined && typeof value.id_token === "string";
|
|
639
|
-
}
|
|
640
|
-
function hasRefreshToken(value) {
|
|
641
|
-
return (value.refresh_token !== undefined && typeof value.refresh_token === "string");
|
|
642
|
-
}
|
|
643
|
-
function hasTokenType(value) {
|
|
644
|
-
return value.token_type !== undefined && typeof value.token_type === "string";
|
|
645
|
-
}
|
|
646
|
-
function hasExpiresIn(value) {
|
|
647
|
-
return value.expires_in === undefined || typeof value.expires_in === "number";
|
|
648
|
-
}
|
|
649
|
-
function validatePreconditions(issuer, data) {
|
|
650
|
-
if (data.grantType &&
|
|
651
|
-
(!issuer.grantTypesSupported ||
|
|
652
|
-
!issuer.grantTypesSupported.includes(data.grantType))) {
|
|
653
|
-
throw new Error(`The issuer [${issuer.issuer}] does not support the [${data.grantType}] grant`);
|
|
654
|
-
}
|
|
655
|
-
if (!issuer.tokenEndpoint) {
|
|
656
|
-
throw new Error(`This issuer [${issuer.issuer}] does not have a token endpoint`);
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
function validateTokenEndpointResponse(tokenResponse, dpop) {
|
|
660
|
-
if (hasError(tokenResponse)) {
|
|
661
|
-
throw new OidcProviderError(`Token endpoint returned error [${tokenResponse.error}]${hasErrorDescription(tokenResponse)
|
|
662
|
-
? `: ${tokenResponse.error_description}`
|
|
663
|
-
: ""}${hasErrorUri(tokenResponse) ? ` (see ${tokenResponse.error_uri})` : ""}`, tokenResponse.error, hasErrorDescription(tokenResponse)
|
|
664
|
-
? tokenResponse.error_description
|
|
665
|
-
: undefined);
|
|
666
|
-
}
|
|
667
|
-
if (!hasAccessToken(tokenResponse)) {
|
|
668
|
-
throw new InvalidResponseError(["access_token"]);
|
|
669
|
-
}
|
|
670
|
-
if (!hasIdToken(tokenResponse)) {
|
|
671
|
-
throw new InvalidResponseError(["id_token"]);
|
|
672
|
-
}
|
|
673
|
-
if (!hasTokenType(tokenResponse)) {
|
|
674
|
-
throw new InvalidResponseError(["token_type"]);
|
|
675
|
-
}
|
|
676
|
-
if (!hasExpiresIn(tokenResponse)) {
|
|
677
|
-
throw new InvalidResponseError(["expires_in"]);
|
|
678
|
-
}
|
|
679
|
-
if (!dpop && tokenResponse.token_type.toLowerCase() !== "bearer") {
|
|
680
|
-
throw new Error(`Invalid token endpoint response: requested a [Bearer] token, but got a 'token_type' value of [${tokenResponse.token_type}].`);
|
|
681
|
-
}
|
|
682
|
-
return tokenResponse;
|
|
683
|
-
}
|
|
684
|
-
async function getTokens(issuer, client, data, dpop) {
|
|
685
|
-
validatePreconditions(issuer, data);
|
|
686
|
-
const headers = {
|
|
687
|
-
"content-type": "application/x-www-form-urlencoded",
|
|
688
|
-
};
|
|
689
|
-
let dpopKey;
|
|
690
|
-
if (dpop) {
|
|
691
|
-
dpopKey = await generateDpopKeyPair();
|
|
692
|
-
headers.DPoP = await createDpopHeader(issuer.tokenEndpoint, "POST", dpopKey);
|
|
693
|
-
}
|
|
694
|
-
if (client.clientSecret) {
|
|
695
|
-
headers.Authorization = `Basic ${btoa(`${client.clientId}:${client.clientSecret}`)}`;
|
|
696
|
-
}
|
|
697
|
-
const requestBody = {
|
|
698
|
-
grant_type: data.grantType,
|
|
699
|
-
redirect_uri: data.redirectUrl,
|
|
700
|
-
code: data.code,
|
|
701
|
-
code_verifier: data.codeVerifier,
|
|
702
|
-
client_id: client.clientId,
|
|
703
|
-
};
|
|
704
|
-
const tokenRequestInit = {
|
|
705
|
-
method: "POST",
|
|
706
|
-
headers,
|
|
707
|
-
body: new URLSearchParams(requestBody).toString(),
|
|
708
|
-
};
|
|
709
|
-
const rawTokenResponse = await await fetch(issuer.tokenEndpoint, tokenRequestInit);
|
|
710
|
-
const jsonTokenResponse = (await rawTokenResponse.json());
|
|
711
|
-
const tokenResponse = validateTokenEndpointResponse(jsonTokenResponse, dpop);
|
|
712
|
-
const webId = await getWebidFromTokenPayload(tokenResponse.id_token, issuer.jwksUri, issuer.issuer, client.clientId);
|
|
713
|
-
return {
|
|
714
|
-
accessToken: tokenResponse.access_token,
|
|
715
|
-
idToken: tokenResponse.id_token,
|
|
716
|
-
refreshToken: hasRefreshToken(tokenResponse)
|
|
717
|
-
? tokenResponse.refresh_token
|
|
718
|
-
: undefined,
|
|
719
|
-
webId,
|
|
720
|
-
dpopKey,
|
|
721
|
-
expiresIn: tokenResponse.expires_in,
|
|
722
|
-
};
|
|
723
|
-
}
|
|
724
|
-
async function getBearerToken(redirectUrl) {
|
|
725
|
-
let signinResponse;
|
|
726
|
-
try {
|
|
727
|
-
const client = new OidcClient({
|
|
728
|
-
response_mode: "query",
|
|
729
|
-
loadUserInfo: false,
|
|
730
|
-
});
|
|
731
|
-
signinResponse = await client.processSigninResponse(redirectUrl);
|
|
732
|
-
if (client.settings.metadata === undefined) {
|
|
733
|
-
throw new Error("Cannot retrieve issuer metadata from client information in storage.");
|
|
734
|
-
}
|
|
735
|
-
if (client.settings.metadata.jwks_uri === undefined) {
|
|
736
|
-
throw new Error("Missing some issuer metadata from client information in storage: 'jwks_uri' is undefined");
|
|
737
|
-
}
|
|
738
|
-
if (client.settings.metadata.issuer === undefined) {
|
|
739
|
-
throw new Error("Missing some issuer metadata from client information in storage: 'issuer' is undefined");
|
|
740
|
-
}
|
|
741
|
-
if (client.settings.client_id === undefined) {
|
|
742
|
-
throw new Error("Missing some client information in storage: 'client_id' is undefined");
|
|
743
|
-
}
|
|
744
|
-
const webId = await getWebidFromTokenPayload(signinResponse.id_token, client.settings.metadata.jwks_uri, client.settings.metadata.issuer, client.settings.client_id);
|
|
745
|
-
return {
|
|
746
|
-
accessToken: signinResponse.access_token,
|
|
747
|
-
idToken: signinResponse.id_token,
|
|
748
|
-
webId,
|
|
749
|
-
refreshToken: signinResponse.refresh_token,
|
|
750
|
-
};
|
|
751
|
-
}
|
|
752
|
-
catch (err) {
|
|
753
|
-
throw new Error(`Problem handling Auth Code Grant (Flow) redirect - URL [${redirectUrl}]: ${err}`);
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
async function getDpopToken(issuer, client, data) {
|
|
757
|
-
return getTokens(issuer, client, data, true);
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
async function refresh(refreshToken, issuer, client, dpopKey) {
|
|
761
|
-
const requestBody = {
|
|
762
|
-
grant_type: "refresh_token",
|
|
763
|
-
refresh_token: refreshToken,
|
|
764
|
-
scope: "openid offline_access",
|
|
765
|
-
};
|
|
766
|
-
let dpopHeader = {};
|
|
767
|
-
if (dpopKey !== undefined) {
|
|
768
|
-
dpopHeader = {
|
|
769
|
-
DPoP: await createDpopHeader(issuer.tokenEndpoint, "POST", dpopKey),
|
|
770
|
-
};
|
|
771
|
-
}
|
|
772
|
-
let authHeader = {};
|
|
773
|
-
if (client.clientSecret !== undefined) {
|
|
774
|
-
authHeader = {
|
|
775
|
-
Authorization: `Basic ${btoa(`${client.clientId}:${client.clientSecret}`)}`,
|
|
776
|
-
};
|
|
777
|
-
}
|
|
778
|
-
const rawResponse = await fetch(issuer.tokenEndpoint, {
|
|
779
|
-
method: "POST",
|
|
780
|
-
body: new URLSearchParams(requestBody).toString(),
|
|
781
|
-
headers: {
|
|
782
|
-
...dpopHeader,
|
|
783
|
-
...authHeader,
|
|
784
|
-
"Content-Type": "application/x-www-form-urlencoded",
|
|
785
|
-
},
|
|
786
|
-
});
|
|
787
|
-
let response;
|
|
788
|
-
try {
|
|
789
|
-
response = await rawResponse.json();
|
|
790
|
-
}
|
|
791
|
-
catch (e) {
|
|
792
|
-
throw new Error(`The token endpoint of issuer ${issuer.issuer} returned a malformed response.`);
|
|
793
|
-
}
|
|
794
|
-
const validatedResponse = validateTokenEndpointResponse(response, dpopKey !== undefined);
|
|
795
|
-
const webId = await getWebidFromTokenPayload(validatedResponse.id_token, issuer.jwksUri, issuer.issuer, client.clientId);
|
|
796
|
-
return {
|
|
797
|
-
accessToken: validatedResponse.access_token,
|
|
798
|
-
idToken: validatedResponse.id_token,
|
|
799
|
-
refreshToken: typeof validatedResponse.refresh_token === "string"
|
|
800
|
-
? validatedResponse.refresh_token
|
|
801
|
-
: undefined,
|
|
802
|
-
webId,
|
|
803
|
-
dpopKey,
|
|
804
|
-
expiresIn: validatedResponse.expires_in,
|
|
805
|
-
};
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
function removeOidcQueryParam(redirectUrl) {
|
|
809
|
-
const cleanedUrl = new URL(redirectUrl);
|
|
810
|
-
cleanedUrl.searchParams.delete("code");
|
|
811
|
-
cleanedUrl.searchParams.delete("state");
|
|
812
|
-
cleanedUrl.hash = "";
|
|
813
|
-
return cleanedUrl.toString();
|
|
814
|
-
}
|
|
815
|
-
async function clearOidcPersistentStorage() {
|
|
816
|
-
const client = new OidcClient({
|
|
817
|
-
response_mode: "query",
|
|
818
|
-
});
|
|
819
|
-
await client.clearStaleState(new WebStorageStateStore({}));
|
|
820
|
-
const myStorage = window.localStorage;
|
|
821
|
-
const itemsToRemove = [];
|
|
822
|
-
for (let i = 0; i <= myStorage.length; i += 1) {
|
|
823
|
-
const key = myStorage.key(i);
|
|
824
|
-
if (key &&
|
|
825
|
-
(key.match(/^oidc\..+$/) ||
|
|
826
|
-
key.match(/^solidClientAuthenticationUser:.+$/))) {
|
|
827
|
-
itemsToRemove.push(key);
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
itemsToRemove.forEach((key) => myStorage.removeItem(key));
|
|
831
|
-
}
|
|
832
|
-
|
|
833
484
|
const globalFetch = (request, init) => window.fetch(request, init);
|
|
834
485
|
class ClientAuthentication {
|
|
835
486
|
constructor(loginHandler, redirectHandler, logoutHandler, sessionInfoManager, issuerConfigFetcher) {
|
|
@@ -1691,3 +1342,4 @@ const onSessionRestore = (...args) => {
|
|
|
1691
1342
|
};
|
|
1692
1343
|
|
|
1693
1344
|
export { Session, fetch$1 as fetch, getClientAuthenticationWithDependencies, getDefaultSession, handleIncomingRedirect, login, logout, onLogin, onLogout, onSessionRestore };
|
|
1345
|
+
//# sourceMappingURL=index.es.js.map
|