@truework/credentials
Advanced tools
Comparing version 0.7.0 to 0.8.0
@@ -1,1 +0,1 @@ | ||
{"processes":{"1f1f9c96-8e56-4bc3-8f34-2c9e0017d6e9":{"parent":"f0f52aa2-d4af-4f95-a13c-0c0615d537ee","externalId":"src/__tests__/events.test.ts","children":[]},"511da6fd-67a4-4337-bd33-1fd731f464bb":{"parent":"f0f52aa2-d4af-4f95-a13c-0c0615d537ee","externalId":"src/__tests__/frame.test.ts","children":[]},"cd4b8fe3-ba5b-476a-9993-a15a06323792":{"parent":"f0f52aa2-d4af-4f95-a13c-0c0615d537ee","externalId":"src/__tests__/index.test.ts","children":[]},"f0f52aa2-d4af-4f95-a13c-0c0615d537ee":{"parent":null,"children":["1f1f9c96-8e56-4bc3-8f34-2c9e0017d6e9","511da6fd-67a4-4337-bd33-1fd731f464bb","cd4b8fe3-ba5b-476a-9993-a15a06323792"]}},"files":{"/home/runner/work/truework.js/truework.js/packages/credentials/src/index.ts":["1f1f9c96-8e56-4bc3-8f34-2c9e0017d6e9","cd4b8fe3-ba5b-476a-9993-a15a06323792"],"/home/runner/work/truework.js/truework.js/packages/credentials/src/events.ts":["1f1f9c96-8e56-4bc3-8f34-2c9e0017d6e9","cd4b8fe3-ba5b-476a-9993-a15a06323792"],"/home/runner/work/truework.js/truework.js/packages/credentials/src/frame.ts":["1f1f9c96-8e56-4bc3-8f34-2c9e0017d6e9","511da6fd-67a4-4337-bd33-1fd731f464bb","cd4b8fe3-ba5b-476a-9993-a15a06323792"],"/home/runner/work/truework.js/truework.js/packages/credentials/src/utils.ts":["1f1f9c96-8e56-4bc3-8f34-2c9e0017d6e9","cd4b8fe3-ba5b-476a-9993-a15a06323792"]},"externalIds":{"src/__tests__/events.test.ts":{"root":"1f1f9c96-8e56-4bc3-8f34-2c9e0017d6e9","children":[]},"src/__tests__/frame.test.ts":{"root":"511da6fd-67a4-4337-bd33-1fd731f464bb","children":[]},"src/__tests__/index.test.ts":{"root":"cd4b8fe3-ba5b-476a-9993-a15a06323792","children":[]}}} | ||
{"processes":{"5f5ba21d-78af-4510-8082-604b704578e5":{"parent":"f9adf17a-773c-45a4-afb2-f165ecad9c35","externalId":"src/__tests__/frame.test.ts","children":[]},"8c4f4088-0a5c-4c81-9d4b-a24944452d5b":{"parent":"f9adf17a-773c-45a4-afb2-f165ecad9c35","externalId":"src/__tests__/events.test.ts","children":[]},"bc38e4fc-3884-4324-845e-fce24204dd18":{"parent":"f9adf17a-773c-45a4-afb2-f165ecad9c35","externalId":"src/__tests__/index.test.ts","children":[]},"f9adf17a-773c-45a4-afb2-f165ecad9c35":{"parent":null,"children":["5f5ba21d-78af-4510-8082-604b704578e5","8c4f4088-0a5c-4c81-9d4b-a24944452d5b","bc38e4fc-3884-4324-845e-fce24204dd18"]}},"files":{"/home/runner/work/truework.js/truework.js/packages/credentials/src/frame.ts":["5f5ba21d-78af-4510-8082-604b704578e5","bc38e4fc-3884-4324-845e-fce24204dd18"],"/home/runner/work/truework.js/truework.js/packages/credentials/src/constants.ts":["8c4f4088-0a5c-4c81-9d4b-a24944452d5b","bc38e4fc-3884-4324-845e-fce24204dd18"],"/home/runner/work/truework.js/truework.js/packages/credentials/src/events.ts":["8c4f4088-0a5c-4c81-9d4b-a24944452d5b","bc38e4fc-3884-4324-845e-fce24204dd18"],"/home/runner/work/truework.js/truework.js/packages/credentials/src/index.ts":["bc38e4fc-3884-4324-845e-fce24204dd18"],"/home/runner/work/truework.js/truework.js/packages/credentials/src/utils.ts":["bc38e4fc-3884-4324-845e-fce24204dd18"]},"externalIds":{"src/__tests__/frame.test.ts":{"root":"5f5ba21d-78af-4510-8082-604b704578e5","children":[]},"src/__tests__/events.test.ts":{"root":"8c4f4088-0a5c-4c81-9d4b-a24944452d5b","children":[]},"src/__tests__/index.test.ts":{"root":"bc38e4fc-3884-4324-845e-fce24204dd18","children":[]}}} |
@@ -1,1 +0,1 @@ | ||
!function(e,n){for(var t in n)e[t]=n[t]}(exports,function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=1)}([function(e){e.exports=JSON.parse('{"name":"@truework/credentials","version":"0.7.0","description":"The embeddable Truework Credentials experience.","author":"truework-team","main":"build/index.js","types":"build/src/index.d.ts","scripts":{"build":"webpack --mode production && pnpm typegen","watch":"webpack -w --mode development","typegen":"pnpm exec tsc --emitDeclarationOnly","typecheck":"pnpm exec tsc --noEmit","test":"TJS_FRAME_ORIGIN=http://localhost:4002 tap --ts --no-check-coverage --test-regex .*test\\\\.tsx?"},"devDependencies":{"@babel/core":"^7.15.0","@babel/preset-env":"^7.15.0","@babel/preset-typescript":"^7.15.0","@tsconfig/create-react-app":"^1.0.2","@types/jsdom":"^16.2.13","@types/node":"^17.0.31","@types/proxyquire":"^1.3.28","@types/tap":"^15.0.5","babel-loader":"^8.2.2","core-js":"^3.21.1","jsdom":"^17.0.0","proxyquire":"^2.1.3","regenerator-runtime":"^0.13.9","tap":"^15.0.9","ts-node":"^10.2.1","typescript":"^4.3.5","webpack":"^4.46.0","webpack-cli":"^4.8.0"}}')},function(e,n,t){"use strict";t.r(n),t.d(n,"EventType",(function(){return r})),t.d(n,"createEmitter",(function(){return f})),t.d(n,"createEvents",(function(){return l})),t.d(n,"Env",(function(){return i})),t.d(n,"FrameOrigin",(function(){return c})),t.d(n,"MessageTypes",(function(){return u})),t.d(n,"ErrorCode",(function(){return s})),t.d(n,"version",(function(){return C})),t.d(n,"origins",(function(){return _})),t.d(n,"ConfigurationError",(function(){return T})),t.d(n,"init",(function(){return R}));var r,o,i,c,u,s,a=t(0);function f(){var e={};return{clear:function(){e={}},emit:function(n,t){e[n]&&e[n].forEach((function(e){return e(t)})),e["*"]&&e["*"].forEach((function(e){return e(t)}))},on:function(n,t){return e[n]=e[n]?e[n].concat(t):[t],function(){e[n].splice(e[n].indexOf(t),1)}}}}function l(){var e=f();return{emitOpen:function(){e.emit(r.Open)},emitClose:function(){e.emit(r.Close)},emitSuccess:function(){e.emit(r.Success)},emitError:function(n){e.emit(r.Error,n)},onOpen:function(n){return e.on(r.Open,n)},onClose:function(n){return e.on(r.Close,n)},onSuccess:function(n){return e.on(r.Success,n)},onError:function(n){return e.on(r.Error,n)}}}function p(e){var n=e.src,t=document.createElement("iframe");return t.src=n,t.setAttribute("sandbox","allow-scripts allow-forms allow-same-origin allow-popups"),t.style.position="fixed",t.style.top="0",t.style.bottom="0",t.style.left="0",t.style.right="0",t.style.zIndex="999999999",t.style.border="0",t.style.padding="0",t.style.margin="0",t.width="100%",t.height="100%",t}function d(e){return new Promise((function(n,t){e.onload=n,e.onerror=t,document.body.appendChild(e)}))}function y(e,n,t){var r;null===(r=e.contentWindow)||void 0===r||r.postMessage(t,n)}function b(e){document.body.removeChild(e)}function m(e){return(m="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})(e)}function v(e,n,t,r,o,i,c){try{var u=e[i](c),s=u.value}catch(e){return void t(e)}u.done?n(s):Promise.resolve(s).then(r,o)}function w(e){return function(){var n=this,t=arguments;return new Promise((function(r,o){var i=e.apply(n,t);function c(e){v(i,r,o,c,u,"next",e)}function u(e){v(i,r,o,c,u,"throw",e)}c(void 0)}))}}function h(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function g(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function O(e,n){if(n&&("object"===m(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function x(e){var n="function"==typeof Map?new Map:void 0;return(x=function(e){if(null===e||(t=e,-1===Function.toString.call(t).indexOf("[native code]")))return e;var t;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,r)}function r(){return E(e,arguments,k(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),j(r,e)})(e)}function E(e,n,t){return(E=S()?Reflect.construct:function(e,n,t){var r=[null];r.push.apply(r,n);var o=new(Function.bind.apply(e,r));return t&&j(o,t.prototype),o}).apply(null,arguments)}function S(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function j(e,n){return(j=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function k(e){return(k=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function P(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}!function(e){e.Open="open",e.Close="close",e.Success="success",e.Error="error"}(r||(r={})),function(e){e.Production="production",e.Sandbox="sandbox"}(i||(i={})),function(e){e.Production="https://js.truework.com/frames/credentials/v1/index.html",e.Sandbox="https://js.truework.com/frames/credentials/v1/index.html"}(c||(c={})),function(e){e.Bootstrap="bootstrap",e.Open="open",e.Close="close",e.Success="success",e.Error="error"}(u||(u={})),function(e){e[e.Critical=0]="Critical",e[e.Error=1]="Error"}(s||(s={}));var C="@truework/credentials@0.7.0@",_=(P(o={},i.Production,c.Production),P(o,i.Sandbox,c.Sandbox),o),T=function(e){!function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),n&&j(e,n)}(u,e);var n,t,r,o,i,c=(n=u,t=S(),function(){var e,r=k(n);if(t){var o=k(this).constructor;e=Reflect.construct(r,arguments,o)}else e=r.apply(this,arguments);return O(this,e)});function u(){return g(this,u),c.apply(this,arguments)}return r=u,o&&h(r.prototype,o),i&&h(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r}(x(Error));function R(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.publishableKey,t=e.sessionToken,r=e.env;if(!n)throw new T("".concat(a.name," — missing publishableKey"));if(!t)throw new T("".concat(a.name," — missing sessionToken"));if(r||(r=i.Production),!Object.values(i).includes(r))throw new T("".concat(a.name," — invalid environment ").concat(r));var o=_[r],c=p({src:o}),f=l(),m=function e(n){var t=n.data;switch(t.type){case u.Open:f.emitOpen();break;case u.Close:f.emitClose(),b(c),window.removeEventListener("message",e);break;case u.Success:f.emitSuccess();break;case u.Error:f.emitError(t)}};return f.onError((function(e){e.code===s.Critical&&(b(c),window.removeEventListener("message",m))})),window.addEventListener("message",m),{open:function(){return w(regeneratorRuntime.mark((function e(){var i,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,d(c);case 3:y(c,o,{type:u.Bootstrap,publishableKey:n,sessionToken:t,env:r,packageVersion:C,bundleVersion:null===(i=window)||void 0===i||null===(a=i.Truework)||void 0===a?void 0:a.version}),e.next=9;break;case 6:e.prev=6,e.t0=e.catch(0),f.emitError({code:s.Critical});case 9:case"end":return e.stop()}}),e,null,[[0,6]])})))()},close:function(){y(c,o,{type:u.Close})},onOpen:function(e){return f.onOpen(e)},onClose:function(e){return f.onClose(e)},onSuccess:function(e){return f.onSuccess(e)},onError:function(e){return f.onError(e)}}}}])); | ||
!function(e,n){for(var t in n)e[t]=n[t]}(exports,function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=1)}([function(e){e.exports=JSON.parse('{"name":"@truework/credentials","version":"0.8.0","description":"The embeddable Truework Credentials experience.","author":"truework-team","main":"build/index.js","types":"build/src/index.d.ts","scripts":{"build":"webpack --mode production && pnpm typegen","watch":"webpack -w --mode development","typegen":"pnpm exec tsc --emitDeclarationOnly","typecheck":"pnpm exec tsc --noEmit","test":"TJS_FRAME_ORIGIN=http://localhost:4002 tap --ts --no-check-coverage --test-regex .*test\\\\.tsx?"},"devDependencies":{"@babel/core":"^7.15.0","@babel/preset-env":"^7.15.0","@babel/preset-typescript":"^7.15.0","@tsconfig/create-react-app":"^1.0.2","@types/jsdom":"^16.2.13","@types/node":"^17.0.31","@types/proxyquire":"^1.3.28","@types/tap":"^15.0.5","babel-loader":"^8.2.2","core-js":"^3.21.1","jsdom":"^17.0.0","proxyquire":"^2.1.3","regenerator-runtime":"^0.13.9","tap":"^15.0.9","ts-node":"^10.2.1","typescript":"^4.3.5","webpack":"^4.46.0","webpack-cli":"^4.8.0"}}')},function(e,n,t){"use strict";t.r(n),t.d(n,"version",(function(){return _})),t.d(n,"init",(function(){return R})),t.d(n,"MessageTypes",(function(){return c})),t.d(n,"Env",(function(){return o})),t.d(n,"ErrorCode",(function(){return u}));var r,o,i,c,u,s=t(0);function a(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}!function(e){e.Production="production",e.Sandbox="sandbox"}(o||(o={})),function(e){e.Production="https://js.truework.com/frames/credentials/v1/index.html",e.Sandbox="https://js.truework.com/frames/credentials/v1/index.html"}(i||(i={})),function(e){e.Bootstrap="bootstrap",e.Open="open",e.Close="close",e.Success="success",e.Error="error"}(c||(c={})),function(e){e[e.Critical=0]="Critical",e[e.Error=1]="Error"}(u||(u={}));var l,f=(a(r={},o.Production,i.Production),a(r,o.Sandbox,i.Sandbox),r);function p(){var e,n=(e={},{clear:function(){e={}},emit:function(n,t){e[n]&&e[n].forEach((function(e){return e(t)})),e["*"]&&e["*"].forEach((function(e){return e(t)}))},on:function(n,t){return e[n]=e[n]?e[n].concat(t):[t],function(){e[n].splice(e[n].indexOf(t),1)}}});return{emitOpen:function(){n.emit(l.Open)},emitClose:function(){n.emit(l.Close)},emitSuccess:function(){n.emit(l.Success)},emitError:function(e){n.emit(l.Error,e)},onOpen:function(e){return n.on(l.Open,e)},onClose:function(e){return n.on(l.Close,e)},onSuccess:function(e){return n.on(l.Success,e)},onError:function(e){return n.on(l.Error,e)}}}function d(e){var n=e.src,t=document.createElement("iframe");return t.src=n,t.setAttribute("sandbox","allow-scripts allow-forms allow-same-origin allow-popups"),t.style.position="fixed",t.style.top="0",t.style.bottom="0",t.style.left="0",t.style.right="0",t.style.zIndex="999999999",t.style.border="0",t.style.padding="0",t.style.margin="0",t.width="100%",t.height="100%",t}function y(e){return new Promise((function(n,t){e.onload=n,e.onerror=t,document.body.appendChild(e)}))}function b(e){document.body.removeChild(e)}function m(e,n,t){var r;null===(r=e.contentWindow)||void 0===r||r.postMessage(t,n)}function v(e){return(v="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})(e)}function w(e,n,t,r,o,i,c){try{var u=e[i](c),s=u.value}catch(e){return void t(e)}u.done?n(s):Promise.resolve(s).then(r,o)}function h(e){return function(){var n=this,t=arguments;return new Promise((function(r,o){var i=e.apply(n,t);function c(e){w(i,r,o,c,u,"next",e)}function u(e){w(i,r,o,c,u,"throw",e)}c(void 0)}))}}function O(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function g(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function x(e,n){if(n&&("object"===v(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function E(e){var n="function"==typeof Map?new Map:void 0;return(E=function(e){if(null===e||(t=e,-1===Function.toString.call(t).indexOf("[native code]")))return e;var t;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,r)}function r(){return S(e,arguments,P(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),k(r,e)})(e)}function S(e,n,t){return(S=j()?Reflect.construct:function(e,n,t){var r=[null];r.push.apply(r,n);var o=new(Function.bind.apply(e,r));return t&&k(o,t.prototype),o}).apply(null,arguments)}function j(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function k(e,n){return(k=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function P(e){return(P=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}!function(e){e.Open="open",e.Close="close",e.Success="success",e.Error="error"}(l||(l={}));var C=function(e){!function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),n&&k(e,n)}(u,e);var n,t,r,o,i,c=(n=u,t=j(),function(){var e,r=P(n);if(t){var o=P(this).constructor;e=Reflect.construct(r,arguments,o)}else e=r.apply(this,arguments);return x(this,e)});function u(){return g(this,u),c.apply(this,arguments)}return r=u,o&&O(r.prototype,o),i&&O(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r}(E(Error)),_="@truework/credentials@0.8.0@",T=0;function R(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.publishableKey,t=e.sessionToken,r=e.env;if(!n)throw new C("".concat(s.name," — missing publishableKey"));if(!t)throw new C("".concat(s.name," — missing sessionToken"));if(r||(r=o.Production),!Object.values(o).includes(r))throw new C("".concat(s.name," — invalid environment ").concat(r));var i=f[r],a=d({src:i}),l=p();T+=1;var v=function e(n){var t=n.data;switch(t.type){case c.Open:l.emitOpen();break;case c.Close:l.emitClose(),b(a),T-=1,window.removeEventListener("message",e);break;case c.Success:l.emitSuccess();break;case c.Error:l.emitError(t)}};return l.onError((function(e){e.code===u.Critical&&(b(a),T-=1,window.removeEventListener("message",v))})),window.addEventListener("message",v),{open:function(){return h(regeneratorRuntime.mark((function e(){var o,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,y(a);case 3:m(a,i,{type:c.Bootstrap,publishableKey:n,sessionToken:t,env:r,packageVersion:_,bundleVersion:null===(o=window)||void 0===o||null===(s=o.Truework)||void 0===s?void 0:s.version,invocationCount:T}),e.next=9;break;case 6:e.prev=6,e.t0=e.catch(0),l.emitError({code:u.Critical});case 9:case"end":return e.stop()}}),e,null,[[0,6]])})))()},close:function(){m(a,i,{type:c.Close})},onOpen:function(e){return l.onOpen(e)},onClose:function(e){return l.onClose(e)},onSuccess:function(e){return l.onSuccess(e)},onError:function(e){return l.onError(e)}}}}])); |
@@ -1,2 +0,2 @@ | ||
import { ErrorCode } from './'; | ||
import { ErrorCode } from './constants'; | ||
export declare enum EventType { | ||
@@ -3,0 +3,0 @@ Open = "open", |
@@ -5,1 +5,2 @@ export declare function createFrame({ src }: { | ||
export declare function mountFrame(frame: HTMLIFrameElement): Promise<unknown>; | ||
export declare function removeFrame(frame: HTMLIFrameElement): void; |
@@ -0,51 +1,12 @@ | ||
import { Env, ErrorCode, MessageTypes } from './constants'; | ||
import { EventHandler } from './events'; | ||
export * from './events'; | ||
export declare enum Env { | ||
Production = "production", | ||
Sandbox = "sandbox" | ||
import { Config, Messages } from './types'; | ||
declare global { | ||
interface Window { | ||
Truework: { | ||
version: string; | ||
}; | ||
} | ||
} | ||
export declare enum FrameOrigin { | ||
Production = "https://js.truework.com/frames/credentials/v1/index.html", | ||
Sandbox = "https://js.truework.com/frames/credentials/v1/index.html" | ||
} | ||
export declare enum MessageTypes { | ||
Bootstrap = "bootstrap", | ||
Open = "open", | ||
Close = "close", | ||
Success = "success", | ||
Error = "error" | ||
} | ||
export declare enum ErrorCode { | ||
Critical = 0, | ||
Error = 1 | ||
} | ||
export declare type Messages = { | ||
type: MessageTypes.Bootstrap; | ||
publishableKey: string; | ||
sessionToken: string; | ||
env: Env; | ||
packageVersion: string; | ||
bundleVersion?: string; | ||
} | { | ||
type: MessageTypes.Open; | ||
} | { | ||
type: MessageTypes.Close; | ||
} | { | ||
type: MessageTypes.Success; | ||
} | { | ||
type: MessageTypes.Error; | ||
code: ErrorCode; | ||
}; | ||
export declare type Config = { | ||
publishableKey: string; | ||
sessionToken?: string; | ||
env?: Env; | ||
}; | ||
export declare const version: string; | ||
export declare const origins: { | ||
production: FrameOrigin; | ||
sandbox: FrameOrigin; | ||
}; | ||
export declare class ConfigurationError extends Error { | ||
} | ||
export declare function init({ publishableKey, sessionToken, env }?: Config): { | ||
@@ -61,1 +22,3 @@ open(): Promise<void>; | ||
}; | ||
export { MessageTypes, Env, ErrorCode }; | ||
export type { Messages }; |
@@ -1,3 +0,3 @@ | ||
import { Messages, FrameOrigin } from '.'; | ||
import { FrameOrigin } from './constants'; | ||
import { Messages } from './types'; | ||
export declare function postMessage(frame: HTMLIFrameElement, origin: FrameOrigin, message: Messages): void; | ||
export declare function removeFrame(frame: HTMLIFrameElement): void; |
# @truework/credentials | ||
## 0.8.0 | ||
### Minor Changes | ||
- 8d9c159: # Current Version TJS Polish | ||
- Fixes the multiple `onSuccess` hook firing issue for Argyle and Citadel connectors | ||
- Warns users when multiple sessions are invoked in parallel | ||
- Removes internal code that was being exposed by default to our customers | ||
- Updates event system implementation for the credentials frame | ||
## 0.7.0 | ||
@@ -4,0 +15,0 @@ |
{ | ||
"name": "@truework/credentials", | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"description": "The embeddable Truework Credentials experience.", | ||
@@ -5,0 +5,0 @@ "author": "truework-team", |
import tap from 'tap' | ||
import { ErrorCode } from '../constants' | ||
import { ErrorCode } from '../' | ||
import { createEmitter, createEvents, EventType } from '../events' | ||
@@ -5,0 +5,0 @@ |
@@ -5,5 +5,4 @@ import tap from 'tap' | ||
import './setup' | ||
import { Env, ErrorCode } from '../constants' | ||
import { Env, ErrorCode } from '../' | ||
tap.test('params', async (t) => { | ||
@@ -64,3 +63,3 @@ const publishableKey = 'key' | ||
const { init } = proxy('../', { | ||
'./utils': { | ||
'./frame': { | ||
removeFrame() { | ||
@@ -75,4 +74,3 @@ // frame is removed in catastrophic event | ||
// @ts-ignore proxyquired | ||
credentials.onError((data) => { | ||
credentials.onError((data: { code: string }) => { | ||
t.equal(data.code, ErrorCode.Critical) | ||
@@ -79,0 +77,0 @@ }) |
@@ -1,2 +0,2 @@ | ||
import { ErrorCode } from './' | ||
import { ErrorCode } from './constants' | ||
@@ -3,0 +3,0 @@ export enum EventType { |
@@ -30,1 +30,5 @@ export function createFrame({ src }: { src: string }) { | ||
} | ||
export function removeFrame(frame: HTMLIFrameElement) { | ||
document.body.removeChild(frame) | ||
} |
import pkg from '../package.json' | ||
import { Env, ErrorCode, FrameOrigin, MessageTypes, origins } from './constants' | ||
import { createEvents, EventHandler } from './events' | ||
import { createFrame, mountFrame } from './frame' | ||
import { postMessage, removeFrame } from './utils' | ||
import { createFrame, mountFrame, removeFrame } from './frame' | ||
import { Config, Messages } from './types' | ||
import { postMessage } from './utils' | ||
export * from './events' | ||
export enum Env { | ||
Production = 'production', | ||
Sandbox = 'sandbox', | ||
declare global { | ||
interface Window { | ||
Truework: { | ||
version: string | ||
} | ||
} | ||
} | ||
export enum FrameOrigin { | ||
Production = 'https://js.truework.com/frames/credentials/v1/index.html', | ||
Sandbox = 'https://js.truework.com/frames/credentials/v1/index.html', | ||
} | ||
class ConfigurationError extends Error {} | ||
export enum MessageTypes { | ||
Bootstrap = 'bootstrap', | ||
Open = 'open', | ||
Close = 'close', | ||
Success = 'success', | ||
Error = 'error', | ||
} | ||
export enum ErrorCode { | ||
Critical, | ||
Error, | ||
} | ||
export type Messages = | ||
| { | ||
type: MessageTypes.Bootstrap | ||
publishableKey: string | ||
sessionToken: string | ||
env: Env | ||
packageVersion: string | ||
bundleVersion?: string | ||
} | ||
| { | ||
type: MessageTypes.Open | ||
} | ||
| { | ||
type: MessageTypes.Close | ||
} | ||
| { | ||
type: MessageTypes.Success | ||
} | ||
| { | ||
type: MessageTypes.Error | ||
code: ErrorCode | ||
} | ||
export type Config = { | ||
publishableKey: string | ||
sessionToken?: string | ||
env?: Env | ||
} | ||
export const version: string = process.env.VERSION as string | ||
export const origins = { | ||
[Env.Production]: FrameOrigin.Production, | ||
[Env.Sandbox]: FrameOrigin.Sandbox, | ||
} | ||
let initInvocationCount = 0 | ||
export class ConfigurationError extends Error {} | ||
export function init({ publishableKey, sessionToken, env }: Config = {} as Config) { | ||
// required | ||
// required settings | ||
if (!publishableKey) throw new ConfigurationError(`${pkg.name} — missing publishableKey`) | ||
if (!sessionToken) | ||
// TODO temporary, see tests | ||
throw new ConfigurationError(`${pkg.name} — missing sessionToken`) | ||
if (!sessionToken) throw new ConfigurationError(`${pkg.name} — missing sessionToken`) | ||
@@ -80,7 +31,10 @@ if (!env) env = Env.Production | ||
} | ||
const frameOrigin = (process.env.TJS_FRAME_ORIGIN as FrameOrigin) || origins[env] | ||
const frameOrigin = (process.env.TJS_FRAME_ORIGIN as FrameOrigin) || origins[env] | ||
// setup credentials frame and events | ||
const frame = createFrame({ src: frameOrigin }) | ||
const events = createEvents() | ||
initInvocationCount += 1 | ||
const messageEventHandler = ({ data }: MessageEvent<Messages>) => { | ||
@@ -94,2 +48,3 @@ switch (data.type) { | ||
removeFrame(frame) | ||
initInvocationCount -= 1 | ||
window.removeEventListener('message', messageEventHandler) | ||
@@ -109,2 +64,3 @@ break | ||
removeFrame(frame) | ||
initInvocationCount -= 1 | ||
window.removeEventListener('message', messageEventHandler) | ||
@@ -117,6 +73,5 @@ } | ||
return { | ||
// what other methods could be useful to have here? validation? | ||
async open() { | ||
try { | ||
await mountFrame(frame) // must happen before comms channel is open | ||
await mountFrame(frame) | ||
postMessage(frame, frameOrigin, { | ||
@@ -126,7 +81,6 @@ type: MessageTypes.Bootstrap, | ||
sessionToken, | ||
// @ts-expect-error env is defined above | ||
env: env, | ||
env: env as Env, | ||
packageVersion: version, | ||
// @ts-ignore | ||
bundleVersion: window?.Truework?.version, | ||
invocationCount: initInvocationCount, | ||
}) | ||
@@ -141,3 +95,3 @@ } catch (e) { | ||
// hooks | ||
// hooks for the integrator | ||
onOpen(handler: EventHandler) { | ||
@@ -157,1 +111,4 @@ return events.onOpen(handler) | ||
} | ||
export { MessageTypes, Env, ErrorCode } | ||
export type { Messages } |
@@ -1,2 +0,3 @@ | ||
import { Messages, FrameOrigin } from '.' | ||
import { FrameOrigin } from './constants' | ||
import { Messages } from './types' | ||
@@ -6,5 +7,1 @@ export function postMessage(frame: HTMLIFrameElement, origin: FrameOrigin, message: Messages) { | ||
} | ||
export function removeFrame(frame: HTMLIFrameElement) { | ||
document.body.removeChild(frame) | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37
528
115985