From 707afe5477218eef32ea22cd249fe98da4b55b2c Mon Sep 17 00:00:00 2001 From: Jake Feasel Date: Wed, 4 Jan 2023 13:23:31 -0800 Subject: [PATCH 1/3] Introduces attemptSilentAuthGrant option --- README.md | 2 ++ appAuthHelper.js | 6 +++++- appAuthHelperBundle.js | 2 +- appAuthHelperFetchTokens.js | 12 +++++++++++- appAuthHelperFetchTokensBundle.js | 2 +- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 916ea57..dd088a1 100644 --- a/README.md +++ b/README.md @@ -112,6 +112,7 @@ Once the library is loaded, you have to provide the environmental details along oidc: true, identityProxyPreference: "XHR", // can be either "XHR" or "serviceWorker" renewStrategy: "authCode", // can be either "authCode" or "refreshToken" + attemptSilentAuthGrant: true, // if false, appAuthHelper won't use iframes to attempt to make silent auth code grants redirectUri: "appAuthHelperRedirect.html", // can be a relative or absolute url serviceWorkerUri: "appAuthServiceWorker.js" // can be a relative or absolute url }); @@ -132,6 +133,7 @@ Once the library is loaded, you have to provide the environmental details along - oidc [default: true] - indicate whether or not you want to get back an id_token - identityProxyPreference [default: serviceWorker] - Preferred identity proxy implementation (serviceWorker or XHR) - renewStrategy [default: authCode] - Preferred method for obtaining fresh (and down-scoped) access tokens (authCode or refreshToken); see "How it works" for details. + - attemptSilentAuthGrant [default: true] - By default appAuthHelper will try to silently acquire access tokens using a silent auth code grant in a hidden iframe. This may not always be possible, and may cause some issues with various OP vendors or in the context of third-party cookie restrictions. If set to false, the default renewStrategy will become "refreshToken". - redirectUri [default: appAuthHelperRedirect.html] - The redirect uri registered in the OP - serviceWorkerUri [default: appAuthServiceWorker.js] - Path to the service worker script. Make sure it is located low enough in your URL path so that its scope encapsulates all application code making network requests. See [Why is my service worker failing to register?](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API/Using_Service_Workers#Why_is_my_service_worker_failing_to_register) if you have questions. diff --git a/appAuthHelper.js b/appAuthHelper.js index ebf6fc8..f4e52c5 100644 --- a/appAuthHelper.js +++ b/appAuthHelper.js @@ -12,6 +12,7 @@ * @param {Object} config - configuration needed for working with the OP * @param {string} config.clientId - The id of this RP client within the OP * @param {boolean} [config.oidc=true] - indicate whether or not you want OIDC included + * @param {boolean} config.attemptSilentAuthGrant - indicate whether or not you want to try a silent auth code grant in a hidden iframe * @param {string} config.authorizationEndpoint - Full URL to the OP authorization endpoint * @param {string} config.tokenEndpoint - Full URL to the OP token endpoint * @param {string} config.revocationEndpoint - Full URL to the OP revocation endpoint @@ -43,7 +44,10 @@ this.tokensAvailableHandler = config.tokensAvailableHandler; this.interactionRequiredHandler = config.interactionRequiredHandler; this.appAuthConfig.oidc = typeof config.oidc !== "undefined" ? !!config.oidc : true; - this.appAuthConfig.renewStrategy = config.renewStrategy || "authCode"; + + this.appAuthConfig.attemptSilentAuthGrant = typeof config.attemptSilentAuthGrant !== "undefined" ? !!config.attemptSilentAuthGrant : true; + this.appAuthConfig.renewStrategy = config.renewStrategy || (this.appAuthConfig.attemptSilentAuthGrant ? "authCode" : "refreshToken"); + this.pendingResourceServerRenewals = []; this.identityProxyPreference = config.identityProxyPreference || "serviceWorker"; diff --git a/appAuthHelperBundle.js b/appAuthHelperBundle.js index f1c14e3..6424608 100644 --- a/appAuthHelperBundle.js +++ b/appAuthHelperBundle.js @@ -43,4 +43,4 @@ License for AppAuthHelper (Apache 2.0) : Copyright (c) 2019 ForgeRock, Inc. */ -"use strict";function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}(function(a){if("object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"==typeof window?"undefined"==typeof global?"undefined"==typeof self?this:self:global:window,b.AppAuthHelper=a()}})(function(){return function(){function b(d,e,g){function a(j,i){if(!e[j]){if(!d[j]){var f="function"==typeof require&&require;if(!i&&f)return f(j,!0);if(h)return h(j,!0);var c=new Error("Cannot find module '"+j+"'");throw c.code="MODULE_NOT_FOUND",c}var k=e[j]={exports:{}};d[j][0].call(k.exports,function(b){var c=d[j][1][b];return a(c||b)},k,k.exports,b,d,e,g)}return e[j].exports}for(var h="function"==typeof require&&require,c=0;carguments.length)&&h.call(arguments,1);return i[b]=!0,f(function(){i[b]&&(d?a.apply(null,d):a.call(null),c.clearImmediate(b))}),b},c.clearImmediate="function"==typeof d?d:function(a){delete i[a]}}).call(this,a("timers").setImmediate,a("timers").clearImmediate)},{"process/browser.js":5,timers:7}],8:[function(){(function(a){(function(a){var b=function checkIfIteratorIsSupported(){try{return!!Symbol.iterator}catch(a){return!1}}(),c=function(a){var c={next:function next(){var b=a.shift();return{done:void 0===b,value:b}}};return b&&(c[Symbol.iterator]=function(){return c}),c},d=function(a){return encodeURIComponent(a).replace(/%20/g,"+")},e=function(a){return decodeURIComponent((a+"").replace(/\+/g," "))};(function checkIfURLSearchParamsSupported(){try{var b=a.URLSearchParams;return"a=1"===new b("?a=1").toString()&&"function"==typeof b.prototype.set&&"function"==typeof b.prototype.entries}catch(a){return!1}})()||function polyfillURLSearchParams(){var e=function(a){Object.defineProperty(this,"_entries",{writable:!0,value:{}});var b=_typeof(a);if("undefined"===b);else if("string"===b)""!==a&&this._fromString(a);else if(a instanceof e){var c=this;a.forEach(function(a,b){c.append(b,a)})}else if(!(null!==a&&"object"===b))throw new TypeError("Unsupported input's type for URLSearchParams");else if("[object Array]"===Object.prototype.toString.call(a)){for(var d,f=0;fa[0]?1:0}),a._entries&&(a._entries={});for(var c=0;carguments.length)&&h.call(arguments,1);return i[b]=!0,f(function(){i[b]&&(d?a.apply(null,d):a.call(null),c.clearImmediate(b))}),b},c.clearImmediate="function"==typeof d?d:function(a){delete i[a]}}).call(this,a("timers").setImmediate,a("timers").clearImmediate)},{"process/browser.js":5,timers:7}],8:[function(){(function(a){(function(a){var b=function checkIfIteratorIsSupported(){try{return!!Symbol.iterator}catch(a){return!1}}(),c=function(a){var c={next:function next(){var b=a.shift();return{done:void 0===b,value:b}}};return b&&(c[Symbol.iterator]=function(){return c}),c},d=function(a){return encodeURIComponent(a).replace(/%20/g,"+")},e=function(a){return decodeURIComponent((a+"").replace(/\+/g," "))};(function checkIfURLSearchParamsSupported(){try{var b=a.URLSearchParams;return"a=1"===new b("?a=1").toString()&&"function"==typeof b.prototype.set&&"function"==typeof b.prototype.entries}catch(a){return!1}})()||function polyfillURLSearchParams(){var e=function(a){Object.defineProperty(this,"_entries",{writable:!0,value:{}});var b=_typeof(a);if("undefined"===b);else if("string"===b)""!==a&&this._fromString(a);else if(a instanceof e){var c=this;a.forEach(function(a,b){c.append(b,a)})}else if(!(null!==a&&"object"===b))throw new TypeError("Unsupported input's type for URLSearchParams");else if("[object Array]"===Object.prototype.toString.call(a)){for(var d,f=0;fa[0]?1:0}),a._entries&&(a._entries={});for(var c=0;c { - tokenManager.silentAuthzRequest(); + if (e.data.config.attemptSilentAuthGrant) { + tokenManager.silentAuthzRequest(); + } else { + tokenManager.getAuthzURL().then((url) => + parent.postMessage({ + message: "appAuth-interactionRequired", + error: "Stored tokens unavailable and silent auth code grant not attempted", + authorizationUrl: url + }, TRUSTED_ORIGIN) + ); + } }); break; case "makeRSRequest": diff --git a/appAuthHelperFetchTokensBundle.js b/appAuthHelperFetchTokensBundle.js index 2011b06..1bf772e 100644 --- a/appAuthHelperFetchTokensBundle.js +++ b/appAuthHelperFetchTokensBundle.js @@ -43,4 +43,4 @@ License for AppAuthHelper (Apache 2.0) : Copyright (c) 2019 ForgeRock, Inc. */ -"use strict";function _typeof(e){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}(function(){function s(l,e,r){function t(d,n){if(!e[d]){if(!l[d]){var i="function"==typeof require&&require;if(!n&&i)return i(d,!0);if(o)return o(d,!0);var u=new Error("Cannot find module '"+d+"'");throw u.code="MODULE_NOT_FOUND",u}var a=e[d]={exports:{}};l[d][0].call(a.exports,function(e){var r=l[d][1][e];return t(r||e)},a,a.exports,s,l,e,r)}return e[d].exports}for(var o="function"==typeof require&&require,n=0;nr.BUILT_IN_PARAMETERS.indexOf(n)&&(o[n]=t.extras[n]);var a=this.utils.stringify(o),i=e.authorizationEndpoint;return i+"?"+a},e.prototype.completeAuthorizationRequestIfPossible=function(){var e=this;return o.log("Checking to see if there is an authorization response to be delivered."),this.notifier||o.log("Notifier is not present on AuthorizationRequest handler.\n No delivery of result will be possible"),this.completeAuthorizationRequest().then(function(t){t||o.log("No result is available yet."),t&&e.notifier&&e.notifier.onAuthorizationComplete(t.request,t.response,t.error)})},e.prototype.setAuthorizationNotifier=function(e){return this.notifier=e,this},e}();r.AuthorizationRequestHandler=a},{"./logger":12}],6:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=function(){function e(e){this.code=e.code,this.state=e.state}return e.prototype.toJson=function(){return{code:this.code,state:this.state}},e}();r.AuthorizationResponse=o;var n=function(){function e(e){this.error=e.error,this.errorDescription=e.error_description,this.errorUri=e.error_uri,this.state=e.state}return e.prototype.toJson=function(){return{error:this.error,error_description:this.errorDescription,error_uri:this.errorUri,state:this.state}},e}();r.AuthorizationError=n},{}],7:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=e("./xhr"),n=function(){function e(e){this.authorizationEndpoint=e.authorization_endpoint,this.tokenEndpoint=e.token_endpoint,this.revocationEndpoint=e.revocation_endpoint,this.userInfoEndpoint=e.userinfo_endpoint,this.endSessionEndpoint=e.end_session_endpoint}return e.prototype.toJson=function(){return{authorization_endpoint:this.authorizationEndpoint,token_endpoint:this.tokenEndpoint,revocation_endpoint:this.revocationEndpoint,end_session_endpoint:this.endSessionEndpoint,userinfo_endpoint:this.userInfoEndpoint}},e.fetchFromIssuer=function(t,r){var n=r||new o.JQueryRequestor;return n.xhr({url:t+"/"+".well-known"+"/"+"openid-configuration",dataType:"json",method:"GET"}).then(function(t){return new e(t)})},e}();r.AuthorizationServiceConfiguration=n},{"./xhr":20}],8:[function(e,t,r){"use strict";function o(e){for(var t,r=[],o=0;oe.length||128e.status){var t=e.headers.get("content-type");return i||t&&-1!==t.indexOf("application/json")?e.json():e.text()}return Promise.reject(new n.AppAuthError(e.status.toString(),e.statusText))})},t}(a);r.FetchRequestor=s;var p=function(e){function t(t){var r=e.call(this)||this;return r.promise=t,r}return o(t,e),t.prototype.xhr=function(){return this.promise},t}(a);r.TestRequestor=p},{"./errors":9}],21:[function(e,t,r){'use strict';function o(e){var t=e.length;if(0>16,l[d++]=255&t>>8,l[d++]=255&t;return 2===p&&(t=u[e.charCodeAt(r)]<<2|u[e.charCodeAt(r+1)]>>4,l[d++]=255&t),1===p&&(t=u[e.charCodeAt(r)]<<10|u[e.charCodeAt(r+1)]<<4|u[e.charCodeAt(r+2)]>>2,l[d++]=255&t>>8,l[d++]=255&t),l}function s(e){return d[63&e>>18]+d[63&e>>12]+d[63&e>>6]+d[63&e]}function p(e,t,r){for(var o,n=[],a=t;al?l:s+a));return 1===o?(t=e[r-1],n.push(d[t>>2]+d[63&t<<4]+"==")):2===o&&(t=(e[r-2]<<8)+e[r-1],n.push(d[t>>10]+d[63&t>>4]+d[63&t<<2]+"=")),n.join("")}r.byteLength=function(e){var t=o(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=a,r.fromByteArray=l;for(var d=[],u=[],c="undefined"==typeof Uint8Array?Array:Uint8Array,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",y=0,f=h.length;yarguments.length)&&s.call(arguments,1);return p[t]=!0,a(function(){p[t]&&(o?e.apply(null,o):e.call(null),r.clearImmediate(t))}),t},r.clearImmediate="function"==typeof o?o:function(e){delete p[e]}}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":22,timers:24}],25:[function(){(function(e){(function(e){var t=function checkIfIteratorIsSupported(){try{return!!Symbol.iterator}catch(e){return!1}}(),r=function(e){var r={next:function next(){var t=e.shift();return{done:void 0===t,value:t}}};return t&&(r[Symbol.iterator]=function(){return r}),r},o=function(e){return encodeURIComponent(e).replace(/%20/g,"+")},n=function(e){return decodeURIComponent((e+"").replace(/\+/g," "))};(function checkIfURLSearchParamsSupported(){try{var t=e.URLSearchParams;return"a=1"===new t("?a=1").toString()&&"function"==typeof t.prototype.set&&"function"==typeof t.prototype.entries}catch(t){return!1}})()||function polyfillURLSearchParams(){var n=function(e){Object.defineProperty(this,"_entries",{writable:!0,value:{}});var t=_typeof(e);if("undefined"===t);else if("string"===t)""!==e&&this._fromString(e);else if(e instanceof n){var r=this;e.forEach(function(e,t){r.append(t,e)})}else if(!(null!==e&&"object"===t))throw new TypeError("Unsupported input's type for URLSearchParams");else if("[object Array]"===Object.prototype.toString.call(e)){for(var o,a=0;at[0]?1:0}),e._entries&&(e._entries={});for(var r=0;rt.end-t.pos||t.end>e.length)throw new RangeError("Malformed DER");var r=e[t.pos++],o=e[t.pos++];if(128<=o){if(o&=127,t.end-t.pos>24,255&l>>16,255&l>>8,255&l);1>24);)l<<=8,o--;4>o&&t.splice(a,4-o),o|=128}return t.splice(a-2,2,r,o),t}function y(e,t,r,o){Object.defineProperties(this,{_key:{value:e},type:{value:e.type,enumerable:!0},extractable:{value:void 0===r?e.extractable:r,enumerable:!0},algorithm:{value:void 0===t?e.algorithm:t,enumerable:!0},usages:{value:void 0===o?e.usages:o,enumerable:!0}})}function f(e){return"verify"===e||"encrypt"===e||"wrapKey"===e}function g(e){return"sign"===e||"decrypt"===e||"unwrapKey"===e}if("function"!=typeof Promise)throw"Promise support required";var _=e.crypto||e.msCrypto;if(_){var A=_.subtle||_.webkitSubtle;if(A){var v=e.Crypto||_.constructor||Object,T=e.SubtleCrypto||A.constructor||Object,S=e.CryptoKey||e.Key||Object,E=-1>3)),c,m,v);if(x&&"generateKey"===e&&"RSASSA-PKCS1-v1_5"===c.name&&(!c.modulusLength||2048<=c.modulusLength))return r=i(r),r.name="RSAES-PKCS1-v1_5",delete r.hash,A.generateKey(r,!0,["encrypt","decrypt"]).then(function(e){return Promise.all([A.exportKey("jwk",e.publicKey),A.exportKey("jwk",e.privateKey)])}).then(function(e){return e[0].alg=e[1].alg=s(c),e[0].key_ops=v.filter(f),e[1].key_ops=v.filter(g),Promise.all([A.importKey("jwk",e[0],c,!0,e[0].key_ops),A.importKey("jwk",e[1],c,m,e[1].key_ops)])}).then(function(e){return{publicKey:e[0],privateKey:e[1]}});if((x||R&&"SHA-1"===(c.hash||{}).name)&&"importKey"===e&&"jwk"===r&&"HMAC"===c.name&&"oct"===u.kty)return A.importKey("raw",n(o(u.k)),h,T[3],T[4]);if(x&&"importKey"===e&&("spki"===r||"pkcs8"===r))return A.importKey("jwk",d(u),h,T[3],T[4]);if(R&&"unwrapKey"===e)return A.decrypt(T[3],h,u).then(function(e){return A.importKey(r,e,T[4],T[5],T[6])});var S;try{S=t.apply(A,T)}catch(t){return Promise.reject(t)}return R&&(S=new Promise(function(e,t){S.onabort=S.onerror=function(r){t(r)},S.oncomplete=function(t){e(t.target.result)}})),S=S.then(function(e){return"HMAC"!==c.name||c.length||(c.length=8*e.algorithm.length),0==c.name.search("RSA")&&(!c.modulusLength&&(c.modulusLength=(e.publicKey||e).algorithm.modulusLength),!c.publicExponent&&(c.publicExponent=(e.publicKey||e).algorithm.publicExponent)),e=e.publicKey&&e.privateKey?{publicKey:new y(e.publicKey,c,m,v.filter(f)),privateKey:new y(e.privateKey,c,m,v.filter(g))}:new y(e,c,m,v),e}),S}}),["exportKey","wrapKey"].forEach(function(e){var r=A[e];A[e]=function(o,i,l){var d=[].slice.call(arguments);if("exportKey"===e?d[1]=i._key:"wrapKey"===e?(d[1]=i._key,d[2]=l._key):void 0,(x||R&&"SHA-1"===(i.algorithm.hash||{}).name)&&"exportKey"===e&&"jwk"===o&&"HMAC"===i.algorithm.name&&(d[0]="raw"),x&&"exportKey"===e&&("spki"===o||"pkcs8"===o)&&(d[0]="jwk"),R&&"wrapKey"===e)return A.exportKey(o,i).then(function(e){return"jwk"===o&&(e=n(unescape(encodeURIComponent(JSON.stringify(p(e)))))),A.encrypt(d[3],l,e)});var c;try{c=r.apply(A,d)}catch(t){return Promise.reject(t)}return R&&(c=new Promise(function(e,t){c.onabort=c.onerror=function(r){t(r)},c.oncomplete=function(t){e(t.target.result)}})),"exportKey"===e&&"jwk"===o&&(c=c.then(function(e){return(x||R&&"SHA-1"===(i.algorithm.hash||{}).name)&&"HMAC"===i.algorithm.name?{kty:"oct",alg:s(i.algorithm),key_ops:i.usages.slice(),ext:!0,k:t(a(e))}:(e=p(e),e.alg||(e.alg=s(i.algorithm)),e.key_ops||(e.key_ops="public"===i.type?i.usages.filter(f):"private"===i.type?i.usages.filter(g):i.usages.slice()),e)})),x&&"exportKey"===e&&("spki"===o||"pkcs8"===o)&&(c=c.then(function(e){return e=u(p(e)),e})),c}}),["encrypt","decrypt","sign","verify"].forEach(function(e){var t=A[e];A[e]=function(r,o,n,a){if(R&&(!n.byteLength||a&&!a.byteLength))throw new Error("Empy input is not allowed");var s=[].slice.call(arguments),p=i(r);if(R&&("sign"===e||"verify"===e)&&("RSASSA-PKCS1-v1_5"===r||"HMAC"===r)&&(s[0]={name:r}),R&&o.algorithm.hash&&(s[0].hash=s[0].hash||o.algorithm.hash),R&&"decrypt"===e&&"AES-GCM"===p.name){var l=r.tagLength>>3;s[2]=(n.buffer||n).slice(0,n.byteLength-l),r.tag=(n.buffer||n).slice(n.byteLength-l)}s[1]=o._key;var d;try{d=t.apply(A,s)}catch(t){return Promise.reject(t)}return R&&(d=new Promise(function(o,n){d.onabort=d.onerror=function(t){n(t)},d.oncomplete=function(n){var n=n.target.result;if("encrypt"===e&&n instanceof AesGcmEncryptResult){var a=n.ciphertext,i=n.tag;n=new Uint8Array(a.byteLength+i.byteLength),n.set(new Uint8Array(a),0),n.set(new Uint8Array(i),a.byteLength),n=n.buffer}o(n)}})),d}}),R){var P=A.digest;A.digest=function(e,t){if(!t.byteLength)throw new Error("Empy input is not allowed");var r;try{r=P.call(A,e,t)}catch(t){return Promise.reject(t)}return r=new Promise(function(e,t){r.onabort=r.onerror=function(r){t(r)},r.oncomplete=function(t){e(t.target.result)}}),r},e.crypto=Object.create(_,{getRandomValues:{value:function value(e){return _.getRandomValues(e)}},subtle:{value:A}}),e.CryptoKey=y}x&&(_.subtle=A,e.Crypto=v,e.SubtleCrypto=T,e.CryptoKey=y)}}}})},{}],27:[function(e,t,r){(function(e,o){"object"===_typeof(r)&&"undefined"!=typeof t?o(r):"function"==typeof define&&define.amd?define(["exports"],o):o(e.WHATWGFetch={})})(this,function(e){function t(e){return e&&DataView.prototype.isPrototypeOf(e)}function r(e){if("string"!=typeof e&&(e+=""),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function o(e){return"string"!=typeof e&&(e+=""),e}function n(e){var t={next:function next(){var t=e.shift();return{done:void 0===t,value:t}}};return b.iterable&&(t[Symbol.iterator]=function(){return t}),t}function a(e){this.map={},e instanceof a?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function i(e){return e.bodyUsed?Promise.reject(new TypeError("Already read")):void(e.bodyUsed=!0)}function s(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function p(e){var t=new FileReader,r=s(t);return t.readAsArrayBuffer(e),r}function l(e){var t=new FileReader,r=s(t);return t.readAsText(e),r}function d(e){for(var t=new Uint8Array(e),r=Array(t.length),o=0;othis.status,this.statusText="statusText"in t?t.statusText:"",this.headers=new a(t.headers),this.url=t.url||"",this._initBody(e)}function m(t,r){return new Promise(function(o,n){function a(){s.abort()}var i=new y(t,r);if(i.signal&&i.signal.aborted)return n(new e.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;s.onload=function(){var e={status:s.status,statusText:s.statusText,headers:g(s.getAllResponseHeaders()||"")};e.url="responseURL"in s?s.responseURL:e.headers.get("X-Request-URL");var t="response"in s?s.response:s.responseText;setTimeout(function(){o(new _(t,e))},0)},s.onerror=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},s.ontimeout=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},s.onabort=function(){setTimeout(function(){n(new e.DOMException("Aborted","AbortError"))},0)},s.open(i.method,function(t){try{return""===t&&k.location.href?k.location.href:t}catch(r){return t}}(i.url),!0),"include"===i.credentials?s.withCredentials=!0:"omit"===i.credentials&&(s.withCredentials=!1),"responseType"in s&&(b.blob?s.responseType="blob":b.arrayBuffer&&i.headers.get("Content-Type")&&-1!==i.headers.get("Content-Type").indexOf("application/octet-stream")&&(s.responseType="arraybuffer")),i.headers.forEach(function(e,t){s.setRequestHeader(t,e)}),i.signal&&(i.signal.addEventListener("abort",a),s.onreadystatechange=function(){4===s.readyState&&i.signal.removeEventListener("abort",a)}),s.send("undefined"==typeof i._bodyInit?null:i._bodyInit)})}var k=function(e){return e}("undefined"==typeof self?this:self),b={searchParams:"URLSearchParams"in k,iterable:"Symbol"in k&&"iterator"in Symbol,blob:"FileReader"in k&&"Blob"in k&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in k,arrayBuffer:"ArrayBuffer"in k};if(b.arrayBuffer)var A=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],v=ArrayBuffer.isView||function(e){return e&&-1r.BUILT_IN_PARAMETERS.indexOf(n)&&(o[n]=t.extras[n]);var a=this.utils.stringify(o),i=e.authorizationEndpoint;return i+"?"+a},e.prototype.completeAuthorizationRequestIfPossible=function(){var e=this;return o.log("Checking to see if there is an authorization response to be delivered."),this.notifier||o.log("Notifier is not present on AuthorizationRequest handler.\n No delivery of result will be possible"),this.completeAuthorizationRequest().then(function(t){t||o.log("No result is available yet."),t&&e.notifier&&e.notifier.onAuthorizationComplete(t.request,t.response,t.error)})},e.prototype.setAuthorizationNotifier=function(e){return this.notifier=e,this},e}();r.AuthorizationRequestHandler=a},{"./logger":12}],6:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=function(){function e(e){this.code=e.code,this.state=e.state}return e.prototype.toJson=function(){return{code:this.code,state:this.state}},e}();r.AuthorizationResponse=o;var n=function(){function e(e){this.error=e.error,this.errorDescription=e.error_description,this.errorUri=e.error_uri,this.state=e.state}return e.prototype.toJson=function(){return{error:this.error,error_description:this.errorDescription,error_uri:this.errorUri,state:this.state}},e}();r.AuthorizationError=n},{}],7:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var o=e("./xhr"),n=function(){function e(e){this.authorizationEndpoint=e.authorization_endpoint,this.tokenEndpoint=e.token_endpoint,this.revocationEndpoint=e.revocation_endpoint,this.userInfoEndpoint=e.userinfo_endpoint,this.endSessionEndpoint=e.end_session_endpoint}return e.prototype.toJson=function(){return{authorization_endpoint:this.authorizationEndpoint,token_endpoint:this.tokenEndpoint,revocation_endpoint:this.revocationEndpoint,end_session_endpoint:this.endSessionEndpoint,userinfo_endpoint:this.userInfoEndpoint}},e.fetchFromIssuer=function(t,r){var n=r||new o.JQueryRequestor;return n.xhr({url:t+"/"+".well-known"+"/"+"openid-configuration",dataType:"json",method:"GET"}).then(function(t){return new e(t)})},e}();r.AuthorizationServiceConfiguration=n},{"./xhr":20}],8:[function(e,t,r){"use strict";function o(e){for(var t,r=[],o=0;oe.length||128e.status){var t=e.headers.get("content-type");return i||t&&-1!==t.indexOf("application/json")?e.json():e.text()}return Promise.reject(new n.AppAuthError(e.status.toString(),e.statusText))})},t}(a);r.FetchRequestor=s;var p=function(e){function t(t){var r=e.call(this)||this;return r.promise=t,r}return o(t,e),t.prototype.xhr=function(){return this.promise},t}(a);r.TestRequestor=p},{"./errors":9}],21:[function(e,t,r){'use strict';function o(e){var t=e.length;if(0>16,l[d++]=255&t>>8,l[d++]=255&t;return 2===p&&(t=u[e.charCodeAt(r)]<<2|u[e.charCodeAt(r+1)]>>4,l[d++]=255&t),1===p&&(t=u[e.charCodeAt(r)]<<10|u[e.charCodeAt(r+1)]<<4|u[e.charCodeAt(r+2)]>>2,l[d++]=255&t>>8,l[d++]=255&t),l}function s(e){return d[63&e>>18]+d[63&e>>12]+d[63&e>>6]+d[63&e]}function p(e,t,r){for(var o,n=[],a=t;al?l:s+a));return 1===o?(t=e[r-1],n.push(d[t>>2]+d[63&t<<4]+"==")):2===o&&(t=(e[r-2]<<8)+e[r-1],n.push(d[t>>10]+d[63&t>>4]+d[63&t<<2]+"=")),n.join("")}r.byteLength=function(e){var t=o(e),r=t[0],n=t[1];return 3*(r+n)/4-n},r.toByteArray=a,r.fromByteArray=l;for(var d=[],u=[],c="undefined"==typeof Uint8Array?Array:Uint8Array,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",y=0,f=h.length;yarguments.length)&&s.call(arguments,1);return p[t]=!0,a(function(){p[t]&&(o?e.apply(null,o):e.call(null),r.clearImmediate(t))}),t},r.clearImmediate="function"==typeof o?o:function(e){delete p[e]}}).call(this,e("timers").setImmediate,e("timers").clearImmediate)},{"process/browser.js":22,timers:24}],25:[function(){(function(e){(function(e){var t=function checkIfIteratorIsSupported(){try{return!!Symbol.iterator}catch(e){return!1}}(),r=function(e){var r={next:function next(){var t=e.shift();return{done:void 0===t,value:t}}};return t&&(r[Symbol.iterator]=function(){return r}),r},o=function(e){return encodeURIComponent(e).replace(/%20/g,"+")},n=function(e){return decodeURIComponent((e+"").replace(/\+/g," "))};(function checkIfURLSearchParamsSupported(){try{var t=e.URLSearchParams;return"a=1"===new t("?a=1").toString()&&"function"==typeof t.prototype.set&&"function"==typeof t.prototype.entries}catch(t){return!1}})()||function polyfillURLSearchParams(){var n=function(e){Object.defineProperty(this,"_entries",{writable:!0,value:{}});var t=_typeof(e);if("undefined"===t);else if("string"===t)""!==e&&this._fromString(e);else if(e instanceof n){var r=this;e.forEach(function(e,t){r.append(t,e)})}else if(!(null!==e&&"object"===t))throw new TypeError("Unsupported input's type for URLSearchParams");else if("[object Array]"===Object.prototype.toString.call(e)){for(var o,a=0;at[0]?1:0}),e._entries&&(e._entries={});for(var r=0;rt.end-t.pos||t.end>e.length)throw new RangeError("Malformed DER");var r=e[t.pos++],o=e[t.pos++];if(128<=o){if(o&=127,t.end-t.pos>24,255&l>>16,255&l>>8,255&l);1>24);)l<<=8,o--;4>o&&t.splice(a,4-o),o|=128}return t.splice(a-2,2,r,o),t}function y(e,t,r,o){Object.defineProperties(this,{_key:{value:e},type:{value:e.type,enumerable:!0},extractable:{value:void 0===r?e.extractable:r,enumerable:!0},algorithm:{value:void 0===t?e.algorithm:t,enumerable:!0},usages:{value:void 0===o?e.usages:o,enumerable:!0}})}function f(e){return"verify"===e||"encrypt"===e||"wrapKey"===e}function g(e){return"sign"===e||"decrypt"===e||"unwrapKey"===e}if("function"!=typeof Promise)throw"Promise support required";var _=e.crypto||e.msCrypto;if(_){var A=_.subtle||_.webkitSubtle;if(A){var v=e.Crypto||_.constructor||Object,S=e.SubtleCrypto||A.constructor||Object,T=e.CryptoKey||e.Key||Object,E=-1>3)),c,m,v);if(x&&"generateKey"===e&&"RSASSA-PKCS1-v1_5"===c.name&&(!c.modulusLength||2048<=c.modulusLength))return r=i(r),r.name="RSAES-PKCS1-v1_5",delete r.hash,A.generateKey(r,!0,["encrypt","decrypt"]).then(function(e){return Promise.all([A.exportKey("jwk",e.publicKey),A.exportKey("jwk",e.privateKey)])}).then(function(e){return e[0].alg=e[1].alg=s(c),e[0].key_ops=v.filter(f),e[1].key_ops=v.filter(g),Promise.all([A.importKey("jwk",e[0],c,!0,e[0].key_ops),A.importKey("jwk",e[1],c,m,e[1].key_ops)])}).then(function(e){return{publicKey:e[0],privateKey:e[1]}});if((x||R&&"SHA-1"===(c.hash||{}).name)&&"importKey"===e&&"jwk"===r&&"HMAC"===c.name&&"oct"===u.kty)return A.importKey("raw",n(o(u.k)),h,S[3],S[4]);if(x&&"importKey"===e&&("spki"===r||"pkcs8"===r))return A.importKey("jwk",d(u),h,S[3],S[4]);if(R&&"unwrapKey"===e)return A.decrypt(S[3],h,u).then(function(e){return A.importKey(r,e,S[4],S[5],S[6])});var T;try{T=t.apply(A,S)}catch(t){return Promise.reject(t)}return R&&(T=new Promise(function(e,t){T.onabort=T.onerror=function(r){t(r)},T.oncomplete=function(t){e(t.target.result)}})),T=T.then(function(e){return"HMAC"!==c.name||c.length||(c.length=8*e.algorithm.length),0==c.name.search("RSA")&&(!c.modulusLength&&(c.modulusLength=(e.publicKey||e).algorithm.modulusLength),!c.publicExponent&&(c.publicExponent=(e.publicKey||e).algorithm.publicExponent)),e=e.publicKey&&e.privateKey?{publicKey:new y(e.publicKey,c,m,v.filter(f)),privateKey:new y(e.privateKey,c,m,v.filter(g))}:new y(e,c,m,v),e}),T}}),["exportKey","wrapKey"].forEach(function(e){var r=A[e];A[e]=function(o,i,l){var d=[].slice.call(arguments);if("exportKey"===e?d[1]=i._key:"wrapKey"===e?(d[1]=i._key,d[2]=l._key):void 0,(x||R&&"SHA-1"===(i.algorithm.hash||{}).name)&&"exportKey"===e&&"jwk"===o&&"HMAC"===i.algorithm.name&&(d[0]="raw"),x&&"exportKey"===e&&("spki"===o||"pkcs8"===o)&&(d[0]="jwk"),R&&"wrapKey"===e)return A.exportKey(o,i).then(function(e){return"jwk"===o&&(e=n(unescape(encodeURIComponent(JSON.stringify(p(e)))))),A.encrypt(d[3],l,e)});var c;try{c=r.apply(A,d)}catch(t){return Promise.reject(t)}return R&&(c=new Promise(function(e,t){c.onabort=c.onerror=function(r){t(r)},c.oncomplete=function(t){e(t.target.result)}})),"exportKey"===e&&"jwk"===o&&(c=c.then(function(e){return(x||R&&"SHA-1"===(i.algorithm.hash||{}).name)&&"HMAC"===i.algorithm.name?{kty:"oct",alg:s(i.algorithm),key_ops:i.usages.slice(),ext:!0,k:t(a(e))}:(e=p(e),e.alg||(e.alg=s(i.algorithm)),e.key_ops||(e.key_ops="public"===i.type?i.usages.filter(f):"private"===i.type?i.usages.filter(g):i.usages.slice()),e)})),x&&"exportKey"===e&&("spki"===o||"pkcs8"===o)&&(c=c.then(function(e){return e=u(p(e)),e})),c}}),["encrypt","decrypt","sign","verify"].forEach(function(e){var t=A[e];A[e]=function(r,o,n,a){if(R&&(!n.byteLength||a&&!a.byteLength))throw new Error("Empy input is not allowed");var s=[].slice.call(arguments),p=i(r);if(R&&("sign"===e||"verify"===e)&&("RSASSA-PKCS1-v1_5"===r||"HMAC"===r)&&(s[0]={name:r}),R&&o.algorithm.hash&&(s[0].hash=s[0].hash||o.algorithm.hash),R&&"decrypt"===e&&"AES-GCM"===p.name){var l=r.tagLength>>3;s[2]=(n.buffer||n).slice(0,n.byteLength-l),r.tag=(n.buffer||n).slice(n.byteLength-l)}s[1]=o._key;var d;try{d=t.apply(A,s)}catch(t){return Promise.reject(t)}return R&&(d=new Promise(function(o,n){d.onabort=d.onerror=function(t){n(t)},d.oncomplete=function(n){var n=n.target.result;if("encrypt"===e&&n instanceof AesGcmEncryptResult){var a=n.ciphertext,i=n.tag;n=new Uint8Array(a.byteLength+i.byteLength),n.set(new Uint8Array(a),0),n.set(new Uint8Array(i),a.byteLength),n=n.buffer}o(n)}})),d}}),R){var P=A.digest;A.digest=function(e,t){if(!t.byteLength)throw new Error("Empy input is not allowed");var r;try{r=P.call(A,e,t)}catch(t){return Promise.reject(t)}return r=new Promise(function(e,t){r.onabort=r.onerror=function(r){t(r)},r.oncomplete=function(t){e(t.target.result)}}),r},e.crypto=Object.create(_,{getRandomValues:{value:function value(e){return _.getRandomValues(e)}},subtle:{value:A}}),e.CryptoKey=y}x&&(_.subtle=A,e.Crypto=v,e.SubtleCrypto=S,e.CryptoKey=y)}}}})},{}],27:[function(e,t,r){(function(e,o){"object"===_typeof(r)&&"undefined"!=typeof t?o(r):"function"==typeof define&&define.amd?define(["exports"],o):o(e.WHATWGFetch={})})(this,function(e){function t(e){return e&&DataView.prototype.isPrototypeOf(e)}function r(e){if("string"!=typeof e&&(e+=""),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function o(e){return"string"!=typeof e&&(e+=""),e}function n(e){var t={next:function next(){var t=e.shift();return{done:void 0===t,value:t}}};return b.iterable&&(t[Symbol.iterator]=function(){return t}),t}function a(e){this.map={},e instanceof a?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function i(e){return e.bodyUsed?Promise.reject(new TypeError("Already read")):void(e.bodyUsed=!0)}function s(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function p(e){var t=new FileReader,r=s(t);return t.readAsArrayBuffer(e),r}function l(e){var t=new FileReader,r=s(t);return t.readAsText(e),r}function d(e){for(var t=new Uint8Array(e),r=Array(t.length),o=0;othis.status,this.statusText="statusText"in t?t.statusText:"",this.headers=new a(t.headers),this.url=t.url||"",this._initBody(e)}function m(t,r){return new Promise(function(o,n){function a(){s.abort()}var i=new y(t,r);if(i.signal&&i.signal.aborted)return n(new e.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;s.onload=function(){var e={status:s.status,statusText:s.statusText,headers:g(s.getAllResponseHeaders()||"")};e.url="responseURL"in s?s.responseURL:e.headers.get("X-Request-URL");var t="response"in s?s.response:s.responseText;setTimeout(function(){o(new _(t,e))},0)},s.onerror=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},s.ontimeout=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},s.onabort=function(){setTimeout(function(){n(new e.DOMException("Aborted","AbortError"))},0)},s.open(i.method,function(t){try{return""===t&&k.location.href?k.location.href:t}catch(r){return t}}(i.url),!0),"include"===i.credentials?s.withCredentials=!0:"omit"===i.credentials&&(s.withCredentials=!1),"responseType"in s&&(b.blob?s.responseType="blob":b.arrayBuffer&&i.headers.get("Content-Type")&&-1!==i.headers.get("Content-Type").indexOf("application/octet-stream")&&(s.responseType="arraybuffer")),i.headers.forEach(function(e,t){s.setRequestHeader(t,e)}),i.signal&&(i.signal.addEventListener("abort",a),s.onreadystatechange=function(){4===s.readyState&&i.signal.removeEventListener("abort",a)}),s.send("undefined"==typeof i._bodyInit?null:i._bodyInit)})}var k=function(e){return e}("undefined"==typeof self?this:self),b={searchParams:"URLSearchParams"in k,iterable:"Symbol"in k&&"iterator"in Symbol,blob:"FileReader"in k&&"Blob"in k&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in k,arrayBuffer:"ArrayBuffer"in k};if(b.arrayBuffer)var A=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],v=ArrayBuffer.isView||function(e){return e&&-1 Date: Wed, 4 Jan 2023 13:25:32 -0800 Subject: [PATCH 2/3] 0.5.1 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index ff5adfb..bd0abd6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "appauthhelper", - "version": "0.5.0", + "version": "0.5.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 7543e25..332d9f9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "appauthhelper", - "version": "0.5.0", + "version": "0.5.1", "description": "Wrapper for AppAuthJS to assist with silent token acquisition and renewal", "main": "appAuthHelper.js", "scripts": { From 09846b3ea3fe86cee5a37ac96ff3daa3586b1b01 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Jul 2023 22:25:30 +0000 Subject: [PATCH 3/3] Bump word-wrap from 1.2.3 to 1.2.4 Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/jonschlinkert/word-wrap/releases) - [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4) --- updated-dependencies: - dependency-name: word-wrap dependency-type: indirect ... Signed-off-by: dependabot[bot] --- package-lock.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index bd0abd6..daa0732 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1378,7 +1378,7 @@ }, "util": { "version": "0.10.3", - "resolved": "http://registry.npmjs.org/util/-/util-0.10.3.tgz", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", "dev": true, "requires": { @@ -1839,7 +1839,7 @@ "dependencies": { "resolve": { "version": "1.1.7", - "resolved": "http://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", "dev": true } @@ -2792,7 +2792,7 @@ "dependencies": { "doctrine": { "version": "1.5.0", - "resolved": "http://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=", "dev": true, "requires": { @@ -4649,7 +4649,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { @@ -4664,7 +4664,7 @@ "dependencies": { "string_decoder": { "version": "1.1.1", - "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { @@ -5764,9 +5764,9 @@ } }, "word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.4.tgz", + "integrity": "sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==", "dev": true }, "wrappy": {