@vertigis/licensing 5.1.3 → 6.0.1

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/main.min.js CHANGED
@@ -1 +1 @@
1
- !function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var t=r();for(var n in t)("object"==typeof exports?exports:e)[n]=t[n]}}(this,(()=>(()=>{"use strict";var e={71:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.licenseEndpoint=r.rootLicenses=r.publicKey=void 0,r.publicKey={kty:"RSA",alg:"RS256",e:"AQAB",n:"nlHt1VzvxiuksjLFPxA4609Dk5OxKsDoIq3dtXsyLvqhj5iWyCNUQR4bAW0SwPEeQVTlgX14gktc6PYlTpTwkqf__PBU32-suYxha_cZBQyG-KZJVPECzZzR21wrFYKkl7mVQBvPPS8XckDGL8EOW1XadTWYBebTpSk8HeaTZgRkJNi4X2a0i3ZrU39FT730BcZ4oWwpeYJYkE_jrb0KgUT0bAdQfoAgaiHDe8RopKNctOL2nfy6clVKDrMQnmVsUatc-Uc1vRIxD-vexp9waUxj_pFYkyH6zSLCcx54N2hWiY60H6H0mP7ym4Z6yaos4BYR_6U1AIVVxal6hfuOgQ"},r.rootLicenses=[{signerToken:"3q4GGyI1VbSeUUTBQS36XyZ2OAYwoGZTZ_fDAX6ivPY",validUntil:"2019-06-01T00:00:00Z"}],r.licenseEndpoint="https://licensing.geocortex.com/licenses"},208:(e,r)=>{var t;Object.defineProperty(r,"__esModule",{value:!0}),r.getExtendedLicenseInfo=r.LicenseState=void 0,function(e){e.NO_LICENSE="noLicense",e.VALID_TRIAL="validTrial",e.EXPIRED_TRIAL="expiredTrial",e.VALID_LICENSE="validLicense",e.VALID_LICENSE_WARN_LEVEL_1="validLicenseWarnLevel1",e.VALID_LICENSE_WARN_LEVEL_2="validLicenseWarnLevel2",e.INVALID_LICENSE_WARN_LEVEL_1="invalidLicenseWarnLevel1",e.INVALID_LICENSE_WARN_LEVEL_2="invalidLicenseWarnLevel2",e.INVALID_LICENSE_WARN_LEVEL_3="invalidLicenseWarnLevel3"}(t||(r.LicenseState=t={})),r.getExtendedLicenseInfo=function(e){let r=t.NO_LICENSE,n=Number(e.daysUntilExpiry);const i=Number(e.daysSinceExpiry);let s,o;return e.expires&&(e.isEval?n>0?(r=t.VALID_TRIAL,n>60&&(n=60)):r=t.EXPIRED_TRIAL:n>0?r=n>60?t.VALID_LICENSE:n>30?t.VALID_LICENSE_WARN_LEVEL_1:t.VALID_LICENSE_WARN_LEVEL_2:i>0&&(i>90?r=t.INVALID_LICENSE_WARN_LEVEL_3:i>60?(r=t.INVALID_LICENSE_WARN_LEVEL_2,o=91-i):(r=t.INVALID_LICENSE_WARN_LEVEL_1,o=91-i,s=61-i))),{isAccessRestricted:r===t.NO_LICENSE||r===t.INVALID_LICENSE_WARN_LEVEL_3||r===t.EXPIRED_TRIAL,state:r,daysUntilExpiry:n,daysUntilAccessBlocked:o,daysUntilUserNotification:s}}},211:(e,r)=>{function t(e,r,t){var n;if(void 0===t&&(t={}),!r.codes){r.codes={};for(var i=0;i<r.chars.length;++i)r.codes[r.chars[i]]=i}if(!t.loose&&e.length*r.bits&7)throw new SyntaxError("Invalid padding");for(var s=e.length;"="===e[s-1];)if(--s,!(t.loose||(e.length-s)*r.bits&7))throw new SyntaxError("Invalid padding");for(var o=new(null!=(n=t.out)?n:Uint8Array)(s*r.bits/8|0),a=0,c=0,l=0,u=0;u<s;++u){var d=r.codes[e[u]];if(void 0===d)throw new SyntaxError("Invalid character "+e[u]);c=c<<r.bits|d,(a+=r.bits)>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=r.bits||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o}function n(e,r,t){void 0===t&&(t={});for(var n=t.pad,i=void 0===n||n,s=(1<<r.bits)-1,o="",a=0,c=0,l=0;l<e.length;++l)for(c=c<<8|255&e[l],a+=8;a>r.bits;)a-=r.bits,o+=r.chars[s&c>>a];if(a&&(o+=r.chars[s&c<<r.bits-a]),i)for(;o.length*r.bits&7;)o+="=";return o}Object.defineProperty(r,"__esModule",{value:!0});var i={chars:"0123456789ABCDEF",bits:4},s={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bits:5},o={chars:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bits:5},a={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bits:6},c={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bits:6},l={parse:function(e,r){return t(e.toUpperCase(),i,r)},stringify:function(e,r){return n(e,i,r)}},u={parse:function(e,r){return void 0===r&&(r={}),t(r.loose?e.toUpperCase().replace(/0/g,"O").replace(/1/g,"L").replace(/8/g,"B"):e,s,r)},stringify:function(e,r){return n(e,s,r)}},d={parse:function(e,r){return t(e,o,r)},stringify:function(e,r){return n(e,o,r)}},f={parse:function(e,r){return t(e,a,r)},stringify:function(e,r){return n(e,a,r)}},v={parse:function(e,r){return t(e,c,r)},stringify:function(e,r){return n(e,c,r)}},E={parse:t,stringify:n};r.base16=l,r.base32=u,r.base32hex=d,r.base64=f,r.base64url=v,r.codec=E},323:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.error=void 0,r.error=console.error},340:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0})},361:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.LicenseToken=void 0;const n=t(211),i=t(71);function s(e){return n.base64url.parse(e,{loose:!0})}r.LicenseToken=class{constructor(){this.licenses=[],this.accountId="",this.agolOrgs=[]}init(e,r){return new Promise(((t,n)=>{(function(e,r){if(!r)return Promise.resolve(!0);if("undefined"!=typeof window&&!window.isSecureContext)return Promise.resolve(!0);const t=e.lastIndexOf("."),n=e.substr(t+1),o=e.substr(0,t),a=s(n),c=(new TextEncoder).encode(o);return r.importKey("jwk",i.publicKey,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]).then((e=>r.verify("RSASSA-PKCS1-v1_5",e,a,c)))})(e,r).then((r=>{r||n("JWT verification failed.");const i=function(e){const r=e.indexOf(".")+1,t=e.lastIndexOf(".")-r,n=(i=s(e.substr(r,t)),new TextDecoder("utf-8").decode(i));var i;return function(e,r){if(null==e)throw new Error(r);if("string"==typeof e&&e.length<1)throw new Error(r);if(!1===e)throw new Error(r);return e}(JSON.parse(n),"JWT payload is invalid.")}(e);this.licenses=i.licenses||[],this.accountId=i.accountId||"",this.agolOrgs=i.agolOrgs||[],t()}),(e=>n(e)))}))}isLicenseFor(e,r){return"string"!=typeof e.signerToken&&(void 0===e.sku||!r.sku||("string"==typeof r.sku?-1!==e.sku.indexOf(r.sku):r.sku instanceof RegExp&&r.sku.test(e.sku)))}findLicensesFor(e){const r=[];if("string"!=typeof e.sku&&!(e.sku instanceof RegExp))return r;if(!Array.isArray(e.roots))return r;for(const t of this.licenses)this.isLicenseFor(t,e)&&r.push(t);return r}}},509:function(e,r,t){var n=this&&this.__createBinding||(Object.create?function(e,r,t,n){void 0===n&&(n=t);var i=Object.getOwnPropertyDescriptor(r,t);i&&!("get"in i?!r.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,n,i)}:function(e,r,t,n){void 0===n&&(n=t),e[n]=r[t]}),i=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||n(r,e,t)};Object.defineProperty(r,"__esModule",{value:!0}),r.getLicenseInfo=r.validateJwt=r.validate=r.clearCache=void 0;const s=t(323),o=t(71),a=t(361);let c;function l(e,r,t={}){return new Promise(((n,i)=>{if(!e)return n({error:{message:"Invalid license JWT"},isEval:!1,isValid:!1});const c=t.cryptoApi||window?.crypto?.subtle;(function(e,r,t){return new Promise((n=>{if("string"!=typeof e)return n(void 0);const i=o.rootLicenses,c={sku:r,roots:i},l=new a.LicenseToken;l.init(e,t).then((()=>n({licenses:l.findLicensesFor(c),accountId:l.accountId,agolOrgs:l.agolOrgs}))).catch((e=>((0,s.error)("Error while processing licenses",e),n(void 0))))}))})(e,r,c).then((e=>{if(!e)return n({error:{message:"Failed to retrieve licenses from JWT"},isEval:!1,isValid:!1});const r=u(e.licenses);r.accountId=e.accountId,r.agolOrgs=e.agolOrgs,n(r)})).catch((e=>i(e)))}))}function u(e){let r,t,n=!1,i=!1;if(!e||0===e.length)return{expires:r,isEval:n,isValid:i,sku:t};const s=new Date;let o,a;for(const c of e){const e=/-EVAL$/.test(c.sku),l=c.validFrom?new Date(c.validFrom):s,u=new Date(c.validUntil);isFinite(l.valueOf())&&l.valueOf()>s.valueOf()?(!o||o>l)&&(o=l,a=u):(u>s&&(i=!0),r?u>r&&(r=u,n=e,t=c.sku):(r=u,n=e,t=c.sku))}let c,l;if(o&&a&&r&&o.valueOf()-r.valueOf()<=1728e5&&(r=a),r){const e=r.valueOf()-s.valueOf();c=Math.ceil(e/864e5),e<0&&(l=Math.abs(c)+1,c=void 0)}return{expires:r,isEval:n,isValid:i,sku:t,daysUntilExpiry:c,daysSinceExpiry:l}}i(t(340),r),i(t(208),r),r.clearCache=function(){c={}},r.validate=function(e){return new Promise(((r,t)=>{if(void 0===e.useCache&&(e.useCache=!0),!e.url&&!e.orgId)return r({error:{message:"Either an orgId, or url need to be provided"},isEval:!1,isValid:!1});var n,i;e.url||(e.url=`${o.licenseEndpoint}/${e.orgId}`),(n=e.url,i=e.useCache,new Promise(((e,r)=>{const t=n.match(/licenses\/?(.*)/i);if(i&&c&&t&&c[t[1]])return e(c[t[1]]());const s=new XMLHttpRequest;s.onload=()=>{if(200===s.status){let r;if(r=String(s.responseText),"{"===r[0])try{const n=JSON.parse(r);r=n.jwt,t&&i&&(c||(c={}),c[t[1]]=function(){return r}),e(r)}catch(r){e(void 0)}else r=r.replace(/\s+/g,""),t&&i&&(c||(c={}),c[t[1]]=function(){return r}),e(r)}else e(void 0)},s.onerror=e=>r("The request to fetch the license failed."),s.ontimeout=e=>r("The request to fetch the license timed out"),s.onabort=e=>r("The license request was aborted"),s.open("GET",n,!0),s.send()}))).then((r=>r?l(r,e.sku,{cryptoApi:e.cryptoApi}):{error:{message:"Failed to retrieve JWT"},isEval:!1,isValid:!1})).then((e=>r(e))).catch((e=>t(e)))}))},r.validateJwt=l,r.getLicenseInfo=u}},r={};return function t(n){var i=r[n];if(void 0!==i)return i.exports;var s=r[n]={exports:{}};return e[n].call(s.exports,s,s.exports,t),s.exports}(509)})()));
1
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(this,(()=>(()=>{"use strict";var e={71:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.licenseEndpoint=t.rootLicenses=t.publicKey=void 0,t.publicKey={kty:"RSA",alg:"RS256",e:"AQAB",n:"nlHt1VzvxiuksjLFPxA4609Dk5OxKsDoIq3dtXsyLvqhj5iWyCNUQR4bAW0SwPEeQVTlgX14gktc6PYlTpTwkqf__PBU32-suYxha_cZBQyG-KZJVPECzZzR21wrFYKkl7mVQBvPPS8XckDGL8EOW1XadTWYBebTpSk8HeaTZgRkJNi4X2a0i3ZrU39FT730BcZ4oWwpeYJYkE_jrb0KgUT0bAdQfoAgaiHDe8RopKNctOL2nfy6clVKDrMQnmVsUatc-Uc1vRIxD-vexp9waUxj_pFYkyH6zSLCcx54N2hWiY60H6H0mP7ym4Z6yaos4BYR_6U1AIVVxal6hfuOgQ"},t.rootLicenses=[{signerToken:"3q4GGyI1VbSeUUTBQS36XyZ2OAYwoGZTZ_fDAX6ivPY",validUntil:"2019-06-01T00:00:00Z"}],t.licenseEndpoint="https://licensing.geocortex.com/licenses"},208:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.getExtendedLicenseInfo=t.LicenseState=void 0,function(e){e.NO_LICENSE="noLicense",e.VALID_TRIAL="validTrial",e.EXPIRED_TRIAL="expiredTrial",e.VALID_LICENSE="validLicense",e.VALID_LICENSE_WARN_LEVEL_1="validLicenseWarnLevel1",e.VALID_LICENSE_WARN_LEVEL_2="validLicenseWarnLevel2",e.INVALID_LICENSE_WARN_LEVEL_1="invalidLicenseWarnLevel1",e.INVALID_LICENSE_WARN_LEVEL_2="invalidLicenseWarnLevel2",e.INVALID_LICENSE_WARN_LEVEL_3="invalidLicenseWarnLevel3"}(r||(t.LicenseState=r={})),t.getExtendedLicenseInfo=function(e){let t=r.NO_LICENSE,n=Number(e.daysUntilExpiry);const i=Number(e.daysSinceExpiry);let s,o;return e.expires&&(e.isEval?n>0?(t=r.VALID_TRIAL,n>60&&(n=60)):t=r.EXPIRED_TRIAL:n>0?t=n>60?r.VALID_LICENSE:n>30?r.VALID_LICENSE_WARN_LEVEL_1:r.VALID_LICENSE_WARN_LEVEL_2:i>0&&(i>90?t=r.INVALID_LICENSE_WARN_LEVEL_3:i>60?(t=r.INVALID_LICENSE_WARN_LEVEL_2,o=91-i):(t=r.INVALID_LICENSE_WARN_LEVEL_1,o=91-i,s=61-i))),{isAccessRestricted:t===r.NO_LICENSE||t===r.INVALID_LICENSE_WARN_LEVEL_3||t===r.EXPIRED_TRIAL,state:t,daysUntilExpiry:n,daysUntilAccessBlocked:o,daysUntilUserNotification:s}}},211:(e,t)=>{function r(e,t,r){var n;if(void 0===r&&(r={}),!t.codes){t.codes={};for(var i=0;i<t.chars.length;++i)t.codes[t.chars[i]]=i}if(!r.loose&&e.length*t.bits&7)throw new SyntaxError("Invalid padding");for(var s=e.length;"="===e[s-1];)if(--s,!(r.loose||(e.length-s)*t.bits&7))throw new SyntaxError("Invalid padding");for(var o=new(null!=(n=r.out)?n:Uint8Array)(s*t.bits/8|0),a=0,c=0,l=0,u=0;u<s;++u){var d=t.codes[e[u]];if(void 0===d)throw new SyntaxError("Invalid character "+e[u]);c=c<<t.bits|d,(a+=t.bits)>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=t.bits||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o}function n(e,t,r){void 0===r&&(r={});for(var n=r.pad,i=void 0===n||n,s=(1<<t.bits)-1,o="",a=0,c=0,l=0;l<e.length;++l)for(c=c<<8|255&e[l],a+=8;a>t.bits;)a-=t.bits,o+=t.chars[s&c>>a];if(a&&(o+=t.chars[s&c<<t.bits-a]),i)for(;o.length*t.bits&7;)o+="=";return o}Object.defineProperty(t,"__esModule",{value:!0});var i={chars:"0123456789ABCDEF",bits:4},s={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bits:5},o={chars:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bits:5},a={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bits:6},c={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bits:6},l={parse:function(e,t){return r(e.toUpperCase(),i,t)},stringify:function(e,t){return n(e,i,t)}},u={parse:function(e,t){return void 0===t&&(t={}),r(t.loose?e.toUpperCase().replace(/0/g,"O").replace(/1/g,"L").replace(/8/g,"B"):e,s,t)},stringify:function(e,t){return n(e,s,t)}},d={parse:function(e,t){return r(e,o,t)},stringify:function(e,t){return n(e,o,t)}},f={parse:function(e,t){return r(e,a,t)},stringify:function(e,t){return n(e,a,t)}},p={parse:function(e,t){return r(e,c,t)},stringify:function(e,t){return n(e,c,t)}},E={parse:r,stringify:n};t.base16=l,t.base32=u,t.base32hex=d,t.base64=f,t.base64url=p,t.codec=E},323:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.error=void 0,t.error=console.error},340:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0})},361:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LicenseToken=void 0;const n=r(211),i=r(71);function s(e){return n.base64url.parse(e,{loose:!0})}t.LicenseToken=class{constructor(){this.licenses=[],this.accountId="",this.agolOrgs=[]}init(e){return new Promise(((t,r)=>{(function(e){if("undefined"!=typeof window&&!window.isSecureContext)return Promise.resolve(!0);const t=e.lastIndexOf("."),r=e.substr(t+1),n=e.substr(0,t),o=s(r),a=(new TextEncoder).encode(n);return window?.crypto?.subtle.importKey("jwk",i.publicKey,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]).then((e=>window?.crypto?.subtle.verify("RSASSA-PKCS1-v1_5",e,o,a)))})(e).then((n=>{n||r("JWT verification failed.");const i=function(e){const t=e.indexOf(".")+1,r=e.lastIndexOf(".")-t,n=(i=s(e.substr(t,r)),new TextDecoder("utf-8").decode(i));var i;return function(e,t){if(null==e)throw new Error(t);if("string"==typeof e&&e.length<1)throw new Error(t);if(!1===e)throw new Error(t);return e}(JSON.parse(n),"JWT payload is invalid.")}(e);this.licenses=i.licenses||[],this.accountId=i.accountId||"",this.agolOrgs=i.agolOrgs||[],t()}),(e=>r(e)))}))}isLicenseFor(e,t){return"string"!=typeof e.signerToken&&(void 0===e.sku||!t.sku||("string"==typeof t.sku?-1!==e.sku.indexOf(t.sku):t.sku instanceof RegExp&&t.sku.test(e.sku)))}findLicensesFor(e){const t=[];if("string"!=typeof e.sku&&!(e.sku instanceof RegExp))return t;if(!Array.isArray(e.roots))return t;for(const r of this.licenses)this.isLicenseFor(r,e)&&t.push(r);return t}}},509:function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),t.getLicenseInfo=t.validateJwt=t.validate=t.clearCache=void 0;const s=r(323),o=r(71),a=r(361),c=r(667);let l;function u(e,t=/^((?!-EVAL).)+$/){return new Promise(((r,n)=>{if(!e)return r({error:{message:"Invalid license JWT"},isEval:!1,isValid:!1});(function(e,t){return new Promise((r=>{if("string"!=typeof e)return r(void 0);const n=o.rootLicenses,i={sku:t,roots:n},c=new a.LicenseToken;c.init(e).then((()=>r({licenses:c.findLicensesFor(i),accountId:c.accountId,agolOrgs:c.agolOrgs}))).catch((e=>((0,s.error)("Error while processing licenses",e),r(void 0))))}))})(e,t).then((e=>{if(!e)return r({error:{message:"Failed to retrieve licenses from JWT"},isEval:!1,isValid:!1});const t=d(e.licenses);t.accountId=e.accountId,t.agolOrgs=e.agolOrgs,r(t)})).catch((e=>n(e)))}))}function d(e){let t,r,n=!1,i=!1;if(!e||0===e.length)return{expires:t,isEval:n,isValid:i,sku:r};const s=new Date;let o,a;for(const c of e){const e=/-EVAL$/.test(c.sku),l=c.validFrom?new Date(c.validFrom):s,u=new Date(c.validUntil);isFinite(l.valueOf())&&l.valueOf()>s.valueOf()?(!o||o>l)&&(o=l,a=u):(u>s&&(i=!0),t?u>t&&(t=u,n=e,r=c.sku):(t=u,n=e,r=c.sku))}let c,l;if(o&&a&&t&&o.valueOf()-t.valueOf()<=1728e5&&(t=a),t){const e=t.valueOf()-s.valueOf();c=Math.ceil(e/864e5),e<0&&(l=Math.abs(c)+1,c=void 0)}return{expires:t,isEval:n,isValid:i,sku:r,daysUntilExpiry:c,daysSinceExpiry:l}}i(r(340),t),i(r(208),t),t.clearCache=function(){l={}},t.validate=async function({sku:e,orgId:t,isDesigner:r,portalUrl:n,userName:i,useCache:s=!0,url:a}){if(!n||!t&&!a)return{error:{message:"A portalUrl and an orgId or url override must be provided to evaluate a license."},isEval:!1,isValid:!1};const d=new URL(a??`${o.licenseEndpoint}/${t}`),f=await(0,c.default)(n),p=await(0,c.default)(i);a||(e instanceof RegExp?d.searchParams.append("sku",e.source):d.searchParams.append("sku",e??"ANY-VALID-NON-EVAL"),p&&d.searchParams.append("user",p),f&&d.searchParams.append("portal",f),r&&d.searchParams.append("designer","true"));const E=await async function(e,t,r){return new Promise(((n,i)=>{if(r&&l&&t&&l[t])return n(l[t]());const s=new XMLHttpRequest;s.onload=()=>{if(200===s.status){let e;if(e=String(s.responseText),"{"===e[0])try{const i=JSON.parse(e);e=i.jwt,t&&r&&(l||(l={}),l[t]=function(){return e}),n(e)}catch(e){n(void 0)}else e=e.replace(/\s+/g,""),t&&r&&(l||(l={}),l[t]=function(){return e}),n(e)}else n(void 0)},s.onerror=e=>i("The request to fetch the license failed."),s.ontimeout=e=>i("The request to fetch the license timed out"),s.onabort=e=>i("The license request was aborted"),s.open("GET",e,!0),s.send()}))}(d.toString(),p??t,s);return E?u(E,e):{error:{message:"Failed to retrieve JWT"},isEval:!1,isValid:!1}},t.validateJwt=u,t.getLicenseInfo=d},667:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});t.default=async function(e){if(e)return function(e){const t=new Uint8Array(e),r=(e,r)=>[...t.slice(e,r)].map((e=>e.toString(16).padStart(2,"0"))).join("");let n=0;return[r(n,n+=4),r(n,n+=2),r(n,n+=2),r(n,n+=2),r(n,n+=6)].join("-")}(await async function(e){return window?.crypto?.subtle.digest("SHA-256",e)}(function(e){const t=(new TextEncoder).encode(e+" "),r=Array.from(t,(e=>String.fromCodePoint(e))).join(""),n=btoa(r);return Uint8Array.from(n,(e=>e.codePointAt(0)))}(e)))}}},t={};return function r(n){var i=t[n];if(void 0!==i)return i.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}(509)})()));
package/lib/index.d.ts CHANGED
@@ -1,17 +1,13 @@
1
- import type { CryptoApi, License, LicenseInfo } from "./types";
1
+ import type { License, LicenseInfo, ValidateLicenseArgs } from "./types";
2
2
  export * from "./types";
3
3
  export * from "./extended";
4
- export declare function clearCache(): void;
5
- export declare function validate(args: {
6
- sku: string | RegExp;
7
- cryptoApi?: CryptoApi;
8
- orgId?: string;
9
- url?: string;
10
- useCache?: boolean;
11
- }): Promise<LicenseInfo>;
12
- export declare function validateJwt(jwt: string, sku: string | RegExp, opts?: {
13
- cryptoApi?: CryptoApi;
14
- }): Promise<LicenseInfo>;
4
+ export declare function validate({ sku, orgId, isDesigner, portalUrl, userName, useCache, url: inputUrl }: ValidateLicenseArgs): Promise<LicenseInfo>;
5
+ /**
6
+ * If no SKU is provided this will validate using any non-EVAL SKU. This is
7
+ * required for add-on products that aren't tied to any particular SKU but
8
+ * require a license, eg: Item Manager
9
+ */
10
+ export declare function validateJwt(jwt: string, sku?: string | RegExp): Promise<LicenseInfo>;
15
11
  /**
16
12
  * Returns a LicenseInfo model from a collection of Licenses.
17
13
  * @param licenses The licenses.
@@ -0,0 +1 @@
1
+ export default function obfuscate(input?: string): Promise<string | undefined>;
package/lib/types.d.ts CHANGED
@@ -1,3 +1,38 @@
1
+ export interface ValidateLicenseArgs {
2
+ /**
3
+ * The SKU to evaluate. Leaving this undefined will evaluate any non EVAL
4
+ * SKU.
5
+ */
6
+ sku: string | RegExp | undefined;
7
+ /**
8
+ * The org that is being evaluated. Required if we are not using a url override.
9
+ */
10
+ orgId?: string;
11
+ /**
12
+ * Flag license requests coming from designer apps. For logging purposes
13
+ * only.
14
+ */
15
+ isDesigner?: boolean;
16
+ /**
17
+ * The portal associated with this request. For logging purposes only.
18
+ */
19
+ portalUrl: string;
20
+ /**
21
+ * The unique user associated with this request. The string provided will be
22
+ * obfuscated and logged.
23
+ */
24
+ userName: string | undefined;
25
+ /**
26
+ * Prevent refetching the license if requested in the same session. The
27
+ * cache will be keyed by user if set, by org otherwise.
28
+ */
29
+ useCache?: boolean;
30
+ /**
31
+ * @deprecated
32
+ * Optionally a URL to use for the license request. This should only be used for on-premises deployments.
33
+ */
34
+ url?: string;
35
+ }
1
36
  export interface LicenseInfo {
2
37
  /** Whether there were any errors trying to retrieve the license. */
3
38
  error?: {
@@ -42,4 +77,3 @@ export interface LicenseError {
42
77
  message: string;
43
78
  exception: Error;
44
79
  }
45
- export type CryptoApi = Pick<SubtleCrypto, "importKey" | "verify">;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vertigis/licensing",
3
- "version": "5.1.3",
3
+ "version": "6.0.1",
4
4
  "main": "./dist/main.min.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "files": [