@redocly/reference-docs 1.5.15 → 1.6.0

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.
@@ -9,4 +9,5 @@ export declare type LicenseInfo = {
9
9
  local?: boolean;
10
10
  cryptoMissing?: boolean;
11
11
  };
12
+ export declare function isHostAllowed(hostname: string, hosts: string[] | boolean | undefined): boolean;
12
13
  export default function parse(key?: string): Promise<LicenseInfo>;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tslib_1=require("tslib"),cryptoLib="undefined"!=typeof window&&(window.crypto||window.msCrypto)||void 0;function promisifyIECryptoRes(e){return e.then?e:new Promise((function(t){e.oncomplete=function(e){t(e.target.result)}}))}function str2ab(e){for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),n=0,o=e.length;n<o;n++)r[n]=e.charCodeAt(n);return t}var getKey=function(){var e=str2ab(atob("undefined"!=typeof REDOCLY_PUBLIC_KEY?REDOCLY_PUBLIC_KEY:"MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMHjNir5fXx/ZXoaEeXQ5XyxbNJ4YJYczoCRdSkL6NLzw1FHnng5Vfcgk5+bvox9QRYRbuk84mA4f2NhywDbXKECAwEAAQ=="));return promisifyIECryptoRes(cryptoLib.subtle.importKey("spki",e,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!0,["verify"]))};function textEncode(e){if(window.TextEncoder)return(new TextEncoder).encode(e);for(var t=unescape(encodeURIComponent(e)),r=new Uint8Array(t.length),n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function verify(e,t){return tslib_1.__awaiter(this,void 0,void 0,(function(){var r,n,o,i;return tslib_1.__generator(this,(function(a){switch(a.label){case 0:return r=promisifyIECryptoRes,o=(n=cryptoLib.subtle).verify,i=[{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"}],[4,getKey()];case 1:return[2,r.apply(void 0,[o.apply(n,i.concat([a.sent(),str2ab(atob(t)),textEncode(e)]))])]}}))}))}function parse(e){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,r,n,o,i;return tslib_1.__generator(this,(function(a){switch(a.label){case 0:if("development"===process.env.NODE_ENV)return[2,{valid:!0,allowed:!0}];if(t=window.location.hostname,!e)return"localhost"===t||"127.0.0.1"===t||t.endsWith(".localhost")?[2,{local:!0}]:[2,{}];r=e.split("."),n=r[0],o=r[1],a.label=1;case 1:return a.trys.push([1,3,,4]),[4,verify(atob(n),o)];case 2:return a.sent()?(i=JSON.parse(atob(n)),[3,4]):[2,{valid:!1}];case 3:return a.sent(),[2,{valid:!1,cryptoMissing:!0}];case 4:return i.valid=!0,(!i.e||Date.now()/1e3>i.e)&&(i.expired=!0),!0===i.h&&(i.allowed=!0),Array.isArray(i.h)&&"undefined"!=typeof window&&("localhost"===t||"127.0.0.1"===t||t.endsWith(".localhost")||i.h.find((function(e){return e===t||t.endsWith("."+e)})))&&(i.allowed=!0),[2,i]}}))}))}exports.default=parse;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tslib_1=require("tslib"),cryptoLib="undefined"!=typeof window&&(window.crypto||window.msCrypto)||void 0;function promisifyIECryptoRes(e){return e.then?e:new Promise((function(t){e.oncomplete=function(e){t(e.target.result)}}))}function str2ab(e){for(var t=new ArrayBuffer(e.length),n=new Uint8Array(t),r=0,o=e.length;r<o;r++)n[r]=e.charCodeAt(r);return t}var getKey=function(){var e=str2ab(atob("undefined"!=typeof REDOCLY_PUBLIC_KEY?REDOCLY_PUBLIC_KEY:"MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMHjNir5fXx/ZXoaEeXQ5XyxbNJ4YJYczoCRdSkL6NLzw1FHnng5Vfcgk5+bvox9QRYRbuk84mA4f2NhywDbXKECAwEAAQ=="));return promisifyIECryptoRes(cryptoLib.subtle.importKey("spki",e,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!0,["verify"]))};function textEncode(e){if(window.TextEncoder)return(new TextEncoder).encode(e);for(var t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length),r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function verify(e,t){return tslib_1.__awaiter(this,void 0,void 0,(function(){var n,r,o,i;return tslib_1.__generator(this,(function(s){switch(s.label){case 0:return n=promisifyIECryptoRes,o=(r=cryptoLib.subtle).verify,i=[{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"}],[4,getKey()];case 1:return[2,n.apply(void 0,[o.apply(r,i.concat([s.sent(),str2ab(atob(t)),textEncode(e)]))])]}}))}))}function isHostAllowed(e,t){return!0===t||!(!Array.isArray(t)||"undefined"==typeof window)&&(!("localhost"!==e&&"127.0.0.1"!==e&&!e.endsWith(".localhost")&&!t.find((function(t){return t===e||e.endsWith("."+t)})))||!!t.find((function(t){if(t.indexOf("*")===t.lastIndexOf("*")){var n=t.split("*"),r=n[0],o=n[1];return o&&e.startsWith(r)&&e.endsWith(o)&&o.split(".").length>2}})))}function parse(e){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,n,r,o,i;return tslib_1.__generator(this,(function(s){switch(s.label){case 0:if("development"===process.env.NODE_ENV)return[2,{valid:!0,allowed:!0}];if(t=window.location.hostname,!e)return"localhost"===t||"127.0.0.1"===t||t.endsWith(".localhost")?[2,{local:!0}]:[2,{}];n=e.split("."),r=n[0],o=n[1],s.label=1;case 1:return s.trys.push([1,3,,4]),[4,verify(atob(r),o)];case 2:return s.sent()?(i=JSON.parse(atob(r)),[3,4]):[2,{valid:!1}];case 3:return s.sent(),[2,{valid:!1,cryptoMissing:!0}];case 4:return i.valid=!0,(!i.e||Date.now()/1e3>i.e)&&(i.expired=!0),i.allowed=isHostAllowed(t,i.h),[2,i]}}))}))}exports.isHostAllowed=isHostAllowed,exports.default=parse;
2
2
  //# sourceMappingURL=check.js.map
@@ -9,4 +9,5 @@ export declare type LicenseInfo = {
9
9
  local?: boolean;
10
10
  cryptoMissing?: boolean;
11
11
  };
12
+ export declare function isHostAllowed(hostname: string, hosts: string[] | boolean | undefined): boolean;
12
13
  export default function parse(key?: string): Promise<LicenseInfo>;
@@ -1,2 +1,2 @@
1
- import{__awaiter,__generator}from"tslib";var cryptoLib="undefined"!=typeof window&&(window.crypto||window.msCrypto)||void 0;function promisifyIECryptoRes(e){return e.then?e:new Promise((function(t){e.oncomplete=function(e){t(e.target.result)}}))}function str2ab(e){for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),n=0,o=e.length;n<o;n++)r[n]=e.charCodeAt(n);return t}var getKey=function(){var e=str2ab(atob("undefined"!=typeof REDOCLY_PUBLIC_KEY?REDOCLY_PUBLIC_KEY:"MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMHjNir5fXx/ZXoaEeXQ5XyxbNJ4YJYczoCRdSkL6NLzw1FHnng5Vfcgk5+bvox9QRYRbuk84mA4f2NhywDbXKECAwEAAQ=="));return promisifyIECryptoRes(cryptoLib.subtle.importKey("spki",e,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!0,["verify"]))};function textEncode(e){if(window.TextEncoder)return(new TextEncoder).encode(e);for(var t=unescape(encodeURIComponent(e)),r=new Uint8Array(t.length),n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function verify(e,t){return __awaiter(this,void 0,void 0,(function(){var r,n,o,i;return __generator(this,(function(a){switch(a.label){case 0:return r=promisifyIECryptoRes,o=(n=cryptoLib.subtle).verify,i=[{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"}],[4,getKey()];case 1:return[2,r.apply(void 0,[o.apply(n,i.concat([a.sent(),str2ab(atob(t)),textEncode(e)]))])]}}))}))}export default function parse(e){return __awaiter(this,void 0,void 0,(function(){var t,r,n,o,i;return __generator(this,(function(a){switch(a.label){case 0:if("development"===process.env.NODE_ENV)return[2,{valid:!0,allowed:!0}];if(t=window.location.hostname,!e)return"localhost"===t||"127.0.0.1"===t||t.endsWith(".localhost")?[2,{local:!0}]:[2,{}];r=e.split("."),n=r[0],o=r[1],a.label=1;case 1:return a.trys.push([1,3,,4]),[4,verify(atob(n),o)];case 2:return a.sent()?(i=JSON.parse(atob(n)),[3,4]):[2,{valid:!1}];case 3:return a.sent(),[2,{valid:!1,cryptoMissing:!0}];case 4:return i.valid=!0,(!i.e||Date.now()/1e3>i.e)&&(i.expired=!0),!0===i.h&&(i.allowed=!0),Array.isArray(i.h)&&"undefined"!=typeof window&&("localhost"===t||"127.0.0.1"===t||t.endsWith(".localhost")||i.h.find((function(e){return e===t||t.endsWith("."+e)})))&&(i.allowed=!0),[2,i]}}))}))}
1
+ import{__awaiter,__generator}from"tslib";var cryptoLib="undefined"!=typeof window&&(window.crypto||window.msCrypto)||void 0;function promisifyIECryptoRes(e){return e.then?e:new Promise((function(t){e.oncomplete=function(e){t(e.target.result)}}))}function str2ab(e){for(var t=new ArrayBuffer(e.length),n=new Uint8Array(t),r=0,o=e.length;r<o;r++)n[r]=e.charCodeAt(r);return t}var getKey=function(){var e=str2ab(atob("undefined"!=typeof REDOCLY_PUBLIC_KEY?REDOCLY_PUBLIC_KEY:"MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMHjNir5fXx/ZXoaEeXQ5XyxbNJ4YJYczoCRdSkL6NLzw1FHnng5Vfcgk5+bvox9QRYRbuk84mA4f2NhywDbXKECAwEAAQ=="));return promisifyIECryptoRes(cryptoLib.subtle.importKey("spki",e,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!0,["verify"]))};function textEncode(e){if(window.TextEncoder)return(new TextEncoder).encode(e);for(var t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length),r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function verify(e,t){return __awaiter(this,void 0,void 0,(function(){var n,r,o,i;return __generator(this,(function(a){switch(a.label){case 0:return n=promisifyIECryptoRes,o=(r=cryptoLib.subtle).verify,i=[{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"}],[4,getKey()];case 1:return[2,n.apply(void 0,[o.apply(r,i.concat([a.sent(),str2ab(atob(t)),textEncode(e)]))])]}}))}))}export function isHostAllowed(e,t){return!0===t||!(!Array.isArray(t)||"undefined"==typeof window)&&(!("localhost"!==e&&"127.0.0.1"!==e&&!e.endsWith(".localhost")&&!t.find((function(t){return t===e||e.endsWith("."+t)})))||!!t.find((function(t){if(t.indexOf("*")===t.lastIndexOf("*")){var n=t.split("*"),r=n[0],o=n[1];return o&&e.startsWith(r)&&e.endsWith(o)&&o.split(".").length>2}})))}export default function parse(e){return __awaiter(this,void 0,void 0,(function(){var t,n,r,o,i;return __generator(this,(function(a){switch(a.label){case 0:if("development"===process.env.NODE_ENV)return[2,{valid:!0,allowed:!0}];if(t=window.location.hostname,!e)return"localhost"===t||"127.0.0.1"===t||t.endsWith(".localhost")?[2,{local:!0}]:[2,{}];n=e.split("."),r=n[0],o=n[1],a.label=1;case 1:return a.trys.push([1,3,,4]),[4,verify(atob(r),o)];case 2:return a.sent()?(i=JSON.parse(atob(r)),[3,4]):[2,{valid:!1}];case 3:return a.sent(),[2,{valid:!1,cryptoMissing:!0}];case 4:return i.valid=!0,(!i.e||Date.now()/1e3>i.e)&&(i.expired=!0),i.allowed=isHostAllowed(t,i.h),[2,i]}}))}))}
2
2
  //# sourceMappingURL=check.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redocly/reference-docs",
3
- "version": "1.5.15",
3
+ "version": "1.6.0",
4
4
  "description": "Redocly Reference Docs",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-esm/index.js",