diff --git a/dist/FlamSaasSDK.js b/dist/FlamSaasSDK.js index 3b2fccd..6427cc5 100644 --- a/dist/FlamSaasSDK.js +++ b/dist/FlamSaasSDK.js @@ -12,6 +12,7 @@ }(this, (function (exports) { 'use strict'; const SDK_BASE_URL = 'https://saas-sdk-flam.vercel.app'; + // const SDK_BASE_URL = 'http://localhost:3000'; const PAGES = { main: SDK_BASE_URL, @@ -429,4 +430,3 @@ Object.defineProperty(exports, '__esModule', { value: true }); }))); -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRmxhbVNhYXNTREsuanMiLCJzb3VyY2VzIjpbIi4uL3NyYy9jb25zdGFudHMuanMiLCIuLi9zcmMvcmVuZGVyV2l0aFJldHJ5LmpzIiwiLi4vc3JjL2Nsb3NlSUZyYW1lLmpzIiwiLi4vc3JjL2hlbHBlci9hc3NlcnQuanMiLCIuLi9zcmMvcGxhY2VPcmRlci5qcyIsIi4uL3NyYy9yZWNlaXZlTWVzc2FnZS5qcyIsIi4uL3NyYy9zZW5kTWVzc2FnZS5qcyIsIi4uL3NyYy9zZGsuanMiLCIuLi9zcmMvdmVyc2lvbi5qcyIsIi4uL3NyYy9pbmRleC5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJjb25zdCBTREtfQkFTRV9VUkwgPSAnaHR0cHM6Ly9zYWFzLXNkay1mbGFtLnZlcmNlbC5hcHAnO1xuXG5leHBvcnQgY29uc3QgUEFHRVMgPSB7XG4gIG1haW46IFNES19CQVNFX1VSTCxcbiAgZXJyb3I6IGAke1NES19CQVNFX1VSTH0vZXJyb3JgXG59O1xuIiwiaW1wb3J0IHsgUEFHRVMgfSBmcm9tICcuL2NvbnN0YW50cyc7XG5cbmV4cG9ydCBsZXQgdHJhY2tPcmRlciA9IG51bGw7XG5leHBvcnQgZGVmYXVsdCBhc3luYyBmdW5jdGlvbiByZW5kZXJXaXRoUmV0cnkoeyB1cmwgfSkge1xuICBjb25zdCBib2R5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0aGlzLnNlbmRNZXNzYWdlKFxuICAgICAgICAgIHtcbiAgICAgICAgICAgIHR5cGU6ICdJTklUSUFMX0RBVEEnLFxuICAgICAgICAgICAgcGF5bG9hZDoge1xuICAgICAgICAgICAgICBjbGllbnRfZGF0YTogdGhpcy5jbGllbnREYXRhLFxuICAgICAgICAgICAgICBvcmRlcl9kZXRhaWxzOiB0aGlzLm9yZGVyX2RldGFpbHNcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9LFxuICAgICAgICAgICcqJ1xuICAgICAgICApO1xuICAgICAgICBicmVhaztcbiAgICAgIGNhc2UgJ1JFQURZX1RPX1JFQ0VJVkVfRVJSJzpcbiAgICAgICAgdGhpcy5zZW5kTWVzc2FnZShcbiAgICAgICAgICB7XG4gICAgICAgICAgICB0eXBlOiAnSU5JVElBTF9EQVRBX0VSUicsXG4gICAgICAgICAgICBwYXlsb2FkOiB7XG4gICAgICAgICAgICAgIGVtYWlsOlxuICAgICAgICAgICAgICAgIHRoaXMub3JkZXJfZGV0YWlscyAmJlxuICAgICAgICAgICAgICAgIHRoaXMub3JkZXJfZGV0YWlscy5wcmVmaWxsICYmXG4gICAgICAgICAgICAgICAgdGhpcy5vcmRlcl9kZXRhaWxzLnByZWZpbGwuZW1haWxcbiAgICAgICAgICAgICAgICAgID8gdGhpcy5vcmRlcl9kZXRhaWxzLnByZWZpbGwuZW1haWxcbiAgICAgICAgICAgICAgICAgIDogJycsXG4gICAgICAgICAgICAgIHBob25lOlxuICAgICAgICAgICAgICAgIHRoaXMub3JkZXJfZGV0YWlscyAmJlxuICAgICAgICAgICAgICAgIHRoaXMub3JkZXJfZGV0YWlscy5wcmVmaWxsICYmXG4gICAgICAgICAgICAgICAgdGhpcy5vcmRlcl9kZXRhaWxzLnByZWZpbGwucGhvbmVcbiAgICAgICAgICAgICAgICAgID8gdGhpcy5vcmRlcl9kZXRhaWxzLnByZWZpbGwucGhvbmVcbiAgICAgICAgICAgICAgICAgIDogJydcbiAgICAgICAgICA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QUNwQixRQUFRLFNBQVMsQ0FBQztBQUNsQjtFQUNBLEVBQUUsSUFBSSxDQUFDLFVBQVUsR0FBRyxPQUFPLENBQUM7RUFDNUI7RUFDQSxDQUFDO0FBQ0Q7RUFDQTtFQUNBLElBQUksQ0FBQyxTQUFTLENBQUMsZUFBZSxHQUFHLGVBQWUsQ0FBQztFQUNqRCxJQUFJLENBQUMsU0FBUyxDQUFDLFVBQVUsR0FBRyxVQUFVLENBQUM7RUFDdkMsSUFBSSxDQUFDLFNBQVMsQ0FBQyxjQUFjLEdBQUcsY0FBYyxDQUFDO0VBQy9DLElBQUksQ0FBQyxTQUFTLENBQUMsV0FBVyxHQUFHLFdBQVcsQ0FBQztFQUN6QyxJQUFJLENBQUMsU0FBUyxDQUFDLEtBQUssR0FBR0EsS0FBVyxDQUFDOztFQzVEbkMsV0FBYyxHQUFHLEVBQUUsR0FBRyxFQUFFLE9BQU8sRUFBRTs7QUNLakMsY0FBZSxFQUFFLE9BQU8sRUFBRSxPQUFPLEVBQUUsSUFBSSxFQUFFLElBQUksRUFBRSxDQUFDOzs7Ozs7OzsifQ== diff --git a/dist/FlamSaasSDK.min.esm.js b/dist/FlamSaasSDK.min.esm.js new file mode 100644 index 0000000..b70d295 --- /dev/null +++ b/dist/FlamSaasSDK.min.esm.js @@ -0,0 +1,9 @@ +/** + * flamsdk v1.0.0 + * Author: bucharitesh + * Date: 2022-09-02 + * License: MIT + */ + +const PAGES_main="https://saas-sdk-flam.vercel.app",PAGES_error="https://saas-sdk-flam.vercel.app/error";let trackOrder=null;var toString=Object.prototype.toString;function attribute(o,attr,type,text){if(type="array"===type?"object":type,o&&typeof o[attr]!==type)throw new Error(text)}function variable(o,type,text){if(typeof o!==type)throw new Error(text)}function value(o,values,text){if(-1===values.indexOf(o))throw new Error(text)}var assert={check:function(o,config,attributes){if(config.optional&&!o||variable(o,config.type,config.message),"object"===config.type&&attributes)for(var keys=Object.keys(attributes),index=0;index\n
\n
\n
\n \n \n `,await body.appendChild(UI);const iFrame=document.getElementById("flam-sdk-iframe");iFrame.addEventListener("load",async e=>{e.preventDefault();try{"PRODUCTION"==this.clientData.environment&&await fetch(PAGES_main),document.getElementById("flam-sdk-bg").style.display="none",iFrame.style.opacity="1",trackOrder=e=>{this.receiveMessage(e)},window.addEventListener("message",trackOrder),this.iWindow=document.getElementById("flam-sdk-iframe").contentWindow}catch(err){"Failed to fetch"===err.message&&(this.close(),this.callback({code:500,message:"SDK down!"}))}})},init.prototype.placeOrder=function(order_details,callback){this.order_details=order_details;try{if(assert.check(this.clientData,{type:"object",message:"init data is invalid"},{key:{type:"string",message:"key is required in init data"},environment:{optional:!0,type:"string",message:"environment must be a string in init data"}}),assert.check(order_details,{type:"object",message:"options parameter is invalid"},{productId:{type:"string",message:"productId is required!"}},{refId:{type:"string",message:"refId is required!"}}),!callback)throw new Error("callback function is required!");{let url=""+PAGES_main;this.callback=callback,this.renderWithRetry({url:url,error:!1})}}catch(err){if(!callback)throw new Error("callback function is required!");{let url=PAGES_error+"/Something went wrong!";this.renderWithRetry({url:url,error:!0}),callback({code:400,message:err.message},null)}}},init.prototype.receiveMessage=function(event){if(event.origin==PAGES_main)switch(event.data.type){case"CLOSE":this.close();break;case"READY_TO_RECEIVE":this.sendMessage({type:"INITIAL_DATA",payload:{client_data:this.clientData,order_details:this.order_details}},"*");break;case"READY_TO_RECEIVE_ERR":this.sendMessage({type:"INITIAL_DATA_ERR",payload:{email:this.order_details&&this.order_details.prefill&&this.order_details.prefill.email?this.order_details.prefill.email:"",phone:this.order_details&&this.order_details.prefill&&this.order_details.prefill.phone?this.order_details.prefill.phone:""}},"*");break;case"CREATED":this.callback(null,{code:201,data:event.data.payload,message:"Order placed successfully"}),this.close();break;case"ERROR":this.callback({code:event.data.payload.code,message:event.data.payload.message},null)}},init.prototype.sendMessage=function(message){this.iWindow.postMessage(message,"*")},init.prototype.close=function(){window.removeEventListener("message",trackOrder);const element=document.getElementById("flam-sdk-wrapper");element&&element.remove();const styleSheet=document.getElementById("saas-sdk-style");styleSheet&&styleSheet.remove()};var version={raw:"1.0.0"},index={version:version,init:init};export default index;export{init,version}; +//# sourceMappingURL=FlamSaasSDK.min.esm.js.map diff --git a/dist/FlamSaasSDK.min.esm.js.map b/dist/FlamSaasSDK.min.esm.js.map new file mode 100644 index 0000000..f85f6ab --- /dev/null +++ b/dist/FlamSaasSDK.min.esm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"FlamSaasSDK.min.esm.js","sources":["../src/constants.js","../src/renderWithRetry.js","../src/helper/assert.js","../src/sdk.js","../src/placeOrder.js","../src/receiveMessage.js","../src/sendMessage.js","../src/closeIFrame.js","../src/version.js","../src/index.js"],"sourcesContent":["const SDK_BASE_URL = 'https://saas-sdk-flam.vercel.app';\n// const SDK_BASE_URL = 'http://localhost:3000';\n\nexport const PAGES = {\n main: SDK_BASE_URL,\n error: `${SDK_BASE_URL}/error`\n};\n","import { PAGES } from './constants';\n\nexport let trackOrder = null;\nexport default async function renderWithRetry({ url }) {\n const body = document.querySelector('body');\n\n const styleSheet = document.createElement('style');\n styleSheet.type = 'text/css';\n styleSheet.id = 'saas-sdk-style';\n styleSheet.innerText = `\n .flam-sdk-bg {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n\n min-height: 100vh;\n min-width: 100vw;\n border: none;\n background: rgba(0,0,0, 0.4);\n\n display: flex;\n justify-content: center;\n align-items: center;\n }\n\n #flam-sdk-iframe {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n\n min-height: 100vh;\n min-width: 100vw;\n border: none;\n }\n\n .flam-sdk-loading {\n display: inline-block;\n position: relative;\n width: 80px;\n height: 80px;\n }\n .flam-sdk-loading div {\n box-sizing: border-box;\n display: block;\n position: absolute;\n width: 64px;\n height: 64px;\n margin: 8px;\n border: 3px solid #000;\n border-radius: 50%;\n animation: flam-sdk-loading 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;\n border-color: #000 transparent transparent transparent;\n }\n .flam-sdk-loading div:nth-child(1) {\n animation-delay: -0.45s;\n }\n .flam-sdk-loading div:nth-child(2) {\n animation-delay: -0.3s;\n }\n .flam-sdk-loading div:nth-child(3) {\n animation-delay: -0.15s;\n }\n @keyframes flam-sdk-loading {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n `;\n\n await document.head.appendChild(styleSheet);\n\n const UI = await document.createElement('div');\n UI.id = 'flam-sdk-wrapper';\n\n var RegExp = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i;\n\n const newUrl = () => {\n if (\n this.order_details &&\n this.order_details.theme &&\n this.order_details.theme.color &&\n RegExp.test(this.order_details.theme.color)\n ) {\n const x = '/?theme=';\n return url + x + encodeURIComponent(this.order_details.theme.color);\n }\n return url;\n };\n\n UI.innerHTML = `\n
\n
\n
\n
\n \n
\n `;\n\n await body.appendChild(UI);\n\n const iFrame = document.getElementById('flam-sdk-iframe');\n\n iFrame.addEventListener('load', async e => {\n e.preventDefault();\n\n try {\n if (this.clientData.environment == 'PRODUCTION') {\n await fetch(PAGES.main);\n }\n\n // hide loading\n document.getElementById('flam-sdk-bg').style.display = 'none';\n\n // Bring the iframe back\n iFrame.style.opacity = '1';\n\n trackOrder = e => {\n this.receiveMessage(e);\n };\n\n // for receiving messages from iframe\n window.addEventListener('message', trackOrder);\n\n // for sending messages to iframe\n this.iWindow = document.getElementById('flam-sdk-iframe').contentWindow;\n } catch (err) {\n if (err.message === 'Failed to fetch') {\n this.close();\n this.callback({\n code: 500,\n message: 'SDK down!'\n });\n }\n }\n });\n}\n","var toString = Object.prototype.toString;\n\nfunction attribute(o, attr, type, text) {\n type = type === 'array' ? 'object' : type;\n if (o && typeof o[attr] !== type) {\n throw new Error(text);\n }\n}\n\nfunction variable(o, type, text) {\n if (typeof o !== type) {\n throw new Error(text);\n }\n}\n\nfunction value(o, values, text) {\n if (values.indexOf(o) === -1) {\n throw new Error(text);\n }\n}\n\nfunction check(o, config, attributes) {\n if (!config.optional || o) {\n variable(o, config.type, config.message);\n }\n if (config.type === 'object' && attributes) {\n var keys = Object.keys(attributes);\n\n for (var index = 0; index < keys.length; index++) {\n var a = keys[index];\n if (!attributes[a].optional || o[a]) {\n if (!attributes[a].condition || attributes[a].condition(o)) {\n attribute(o, a, attributes[a].type, attributes[a].message);\n if (attributes[a].values) {\n value(o[a], attributes[a].values, attributes[a].value_message);\n }\n }\n }\n }\n }\n}\n\n/**\n * Wrap `Array.isArray` Polyfill for IE9\n * source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray\n *\n * @param {Array} array\n * @private\n */\nfunction isArray(array) {\n if (this.supportsIsArray()) {\n return Array.isArray(array);\n }\n\n return toString.call(array) === '[object Array]';\n}\n\nfunction supportsIsArray() {\n return Array.isArray != null;\n}\n\nexport default {\n check: check,\n attribute: attribute,\n variable: variable,\n value: value,\n isArray: isArray,\n supportsIsArray: supportsIsArray\n};","import closeIframe from './closeIFrame';\nimport assert from './helper/assert';\nimport placeOrder from './placeOrder';\nimport receiveMessage from './receiveMessage';\nimport renderWithRetry from './renderWithRetry';\nimport sendMessage from './sendMessage';\n\n/**\n * Handles all the browser's AuthN/AuthZ flows\n * @constructor\n * @param {Object} options\n * @param {String} options.key the API Key found on your Application settings page\n * @param {String} [options.environment] enviornment sandbox | production\n * @param {String} [options.name] name of client\n * @param {String} [options.logoUrl] client's brand logo url\n * @param {String} [options.email] client's support email for error page\n * @param {String} [options.phone] client's support phone for error page\n */\nfunction init(options) {\n /* eslint-disable */\n try {\n assert.check(\n options,\n { type: 'object', message: 'clientData parameter is not valid' },\n {\n key: { type: 'string', message: 'key is required' },\n environment: {\n optional: true,\n type: 'string',\n message: 'environment is required'\n }\n }\n );\n\n if (options.overrides) {\n assert.check(options.overrides, {\n type: 'object',\n message: 'overrides option is not valid'\n });\n }\n } catch (err) {\n throw new Error(err.message);\n }\n\n options.environment =\n options &&\n typeof options.environment === 'string' &&\n options.environment.toUpperCase() === 'PRODUCTION'\n ? 'PRODUCTION'\n : 'SANDBOX';\n\n this.clientData = options;\n /* eslint-enable */\n}\n\n// core methods\ninit.prototype.renderWithRetry = renderWithRetry;\ninit.prototype.placeOrder = placeOrder;\ninit.prototype.receiveMessage = receiveMessage;\ninit.prototype.sendMessage = sendMessage;\ninit.prototype.close = closeIframe;\n\nexport default init;\n","import { PAGES } from './constants';\nimport assert from './helper/assert';\n\nexport default function placeOrder(order_details, callback) {\n this.order_details = order_details;\n try {\n assert.check(\n this.clientData,\n { type: 'object', message: 'init data is invalid' },\n {\n key: { type: 'string', message: 'key is required in init data' },\n environment: {\n optional: true,\n type: 'string',\n message: 'environment must be a string in init data'\n }\n }\n );\n\n assert.check(\n order_details,\n {\n type: 'object',\n message: 'options parameter is invalid'\n },\n {\n productId: { type: 'string', message: 'productId is required!' }\n },\n {\n refId: { type: 'string', message: 'refId is required!' }\n }\n );\n\n if (callback) {\n let url = `${PAGES.main}`;\n this.callback = callback;\n this.renderWithRetry({ url, error: false });\n } else {\n throw new Error('callback function is required!');\n }\n } catch (err) {\n if (callback) {\n let url = `${PAGES.error}/Something went wrong!`;\n this.renderWithRetry({\n url,\n error: true\n });\n callback({ code: 400, message: err.message }, null);\n } else {\n throw new Error('callback function is required!');\n }\n }\n}\n","import { PAGES } from './constants';\n\nexport default function receiveMessage(event) {\n if (event.origin == PAGES.main) {\n switch (event.data.type) {\n case 'CLOSE':\n this.close();\n break;\n case 'READY_TO_RECEIVE':\n this.sendMessage(\n {\n type: 'INITIAL_DATA',\n payload: {\n client_data: this.clientData,\n order_details: this.order_details\n }\n },\n '*'\n );\n break;\n case 'READY_TO_RECEIVE_ERR':\n this.sendMessage(\n {\n type: 'INITIAL_DATA_ERR',\n payload: {\n email:\n this.order_details &&\n this.order_details.prefill &&\n this.order_details.prefill.email\n ? this.order_details.prefill.email\n : '',\n phone:\n this.order_details &&\n this.order_details.prefill &&\n this.order_details.prefill.phone\n ? this.order_details.prefill.phone\n : ''\n }\n },\n '*'\n );\n break;\n case 'CREATED':\n this.callback(null, {\n code: 201,\n data: event.data.payload,\n message: 'Order placed successfully'\n });\n this.close();\n break;\n case 'ERROR':\n this.callback(\n {\n code: event.data.payload.code,\n message: event.data.payload.message\n },\n null\n );\n break;\n }\n }\n}\n","export default function sendMessage(message) {\n this.iWindow.postMessage(message, '*');\n}\n","import { trackOrder } from './renderWithRetry';\n\nexport default function close() {\n window.removeEventListener('message', trackOrder);\n\n // remove the UI\n const element = document.getElementById('flam-sdk-wrapper');\n if (element) {\n element.remove();\n }\n\n // remove the styles\n const styleSheet = document.getElementById('saas-sdk-style');\n\n if (styleSheet) {\n styleSheet.remove();\n }\n}\n","module.exports = { raw: '1.0.0' };","import init from './sdk';\nimport version from './version';\n\nexport { version, init };\n\nexport default { version: version, init: init };\n"],"names":["PAGES","trackOrder","toString","Object","prototype","attribute","o","attr","type","text","Error","variable","value","values","indexOf","check","config","attributes","optional","message","keys","index","length","a","condition","value_message","isArray","array","this","supportsIsArray","Array","call","init","options","assert","key","environment","overrides","err","toUpperCase","clientData","renderWithRetry","async","url","body","document","querySelector","styleSheet","createElement","id","innerText","head","appendChild","UI","RegExp","innerHTML","order_details","theme","color","test","encodeURIComponent","newUrl","iFrame","getElementById","addEventListener","e","preventDefault","fetch","style","display","opacity","receiveMessage","window","iWindow","contentWindow","close","callback","code","placeOrder","productId","refId","error","event","origin","data","sendMessage","payload","client_data","email","prefill","phone","postMessage","removeEventListener","element","remove","raw","version"],"mappings":";;;;;;;AAAA,MAGaA,WAHQ,mCAGRA,YAEJ,yCCHF,IAAIC,WAAa,KCFxB,IAAIC,SAAWC,OAAOC,UAAUF,SAEhC,SAASG,UAAUC,EAAGC,KAAMC,KAAMC,MAE9B,GADAD,KAAgB,UAATA,KAAmB,SAAWA,KACjCF,UAAYA,EAAEC,QAAUC,KACxB,MAAM,IAAIE,MAAMD,MAIxB,SAASE,SAASL,EAAGE,KAAMC,MACvB,UAAWH,IAAME,KACb,MAAM,IAAI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KAAKE,QAAQT,KACzB1D,QAAS+D,MAAME,KAAKE,QAAQnE,SAE9B,QFGVa,KAAK5B,UAAUiF,YG3DA,SAAqBlE,SAClCS,KAAK6C,QAAQkB,YAAYxE,QAAS,MH2DpCa,KAAK5B,UAAUuE,MI1DA,WACbH,OAAOoB,oBAAoB,UAAW3F,YAGtC,MAAM4F,QAAUhD,SAASkB,eAAe,oBACpC8B,SACFA,QAAQC,SAIV,MAAM/C,WAAaF,SAASkB,eAAe,kBAEvChB,YACFA,WAAW+C,UCff,YAAiB,CAAEC,IAAK,eCKT,CAAEC,QAASA,QAAShE,KAAMA"} \ No newline at end of file diff --git a/dist/FlamSaasSDK.min.js b/dist/FlamSaasSDK.min.js new file mode 100644 index 0000000..9a0b6fa --- /dev/null +++ b/dist/FlamSaasSDK.min.js @@ -0,0 +1,9 @@ +/** + * flamsdk v1.0.0 + * Author: bucharitesh + * Date: 2022-09-02 + * License: MIT + */ + +!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports):"function"==typeof define&&define.amd?define(["exports"],factory):factory((global=global||self).FlamSaasSDK={})}(this,(function(exports){"use strict";const PAGES_main="https://saas-sdk-flam.vercel.app",PAGES_error="https://saas-sdk-flam.vercel.app/error";let trackOrder=null;var toString=Object.prototype.toString;function attribute(o,attr,type,text){if(type="array"===type?"object":type,o&&typeof o[attr]!==type)throw new Error(text)}function variable(o,type,text){if(typeof o!==type)throw new Error(text)}function value(o,values,text){if(-1===values.indexOf(o))throw new Error(text)}var assert={check:function(o,config,attributes){if(config.optional&&!o||variable(o,config.type,config.message),"object"===config.type&&attributes)for(var keys=Object.keys(attributes),index=0;index\n
\n
\n
\n \n \n `,await body.appendChild(UI);const iFrame=document.getElementById("flam-sdk-iframe");iFrame.addEventListener("load",async e=>{e.preventDefault();try{"PRODUCTION"==this.clientData.environment&&await fetch(PAGES_main),document.getElementById("flam-sdk-bg").style.display="none",iFrame.style.opacity="1",trackOrder=e=>{this.receiveMessage(e)},window.addEventListener("message",trackOrder),this.iWindow=document.getElementById("flam-sdk-iframe").contentWindow}catch(err){"Failed to fetch"===err.message&&(this.close(),this.callback({code:500,message:"SDK down!"}))}})},init.prototype.placeOrder=function(order_details,callback){this.order_details=order_details;try{if(assert.check(this.clientData,{type:"object",message:"init data is invalid"},{key:{type:"string",message:"key is required in init data"},environment:{optional:!0,type:"string",message:"environment must be a string in init data"}}),assert.check(order_details,{type:"object",message:"options parameter is invalid"},{productId:{type:"string",message:"productId is required!"}},{refId:{type:"string",message:"refId is required!"}}),!callback)throw new Error("callback function is required!");{let url=""+PAGES_main;this.callback=callback,this.renderWithRetry({url:url,error:!1})}}catch(err){if(!callback)throw new Error("callback function is required!");{let url=PAGES_error+"/Something went wrong!";this.renderWithRetry({url:url,error:!0}),callback({code:400,message:err.message},null)}}},init.prototype.receiveMessage=function(event){if(event.origin==PAGES_main)switch(event.data.type){case"CLOSE":this.close();break;case"READY_TO_RECEIVE":this.sendMessage({type:"INITIAL_DATA",payload:{client_data:this.clientData,order_details:this.order_details}},"*");break;case"READY_TO_RECEIVE_ERR":this.sendMessage({type:"INITIAL_DATA_ERR",payload:{email:this.order_details&&this.order_details.prefill&&this.order_details.prefill.email?this.order_details.prefill.email:"",phone:this.order_details&&this.order_details.prefill&&this.order_details.prefill.phone?this.order_details.prefill.phone:""}},"*");break;case"CREATED":this.callback(null,{code:201,data:event.data.payload,message:"Order placed successfully"}),this.close();break;case"ERROR":this.callback({code:event.data.payload.code,message:event.data.payload.message},null)}},init.prototype.sendMessage=function(message){this.iWindow.postMessage(message,"*")},init.prototype.close=function(){window.removeEventListener("message",trackOrder);const element=document.getElementById("flam-sdk-wrapper");element&&element.remove();const styleSheet=document.getElementById("saas-sdk-style");styleSheet&&styleSheet.remove()};var version={raw:"1.0.0"},index={version:version,init:init};exports.default=index,exports.init=init,exports.version=version,Object.defineProperty(exports,"__esModule",{value:!0})})); +//# sourceMappingURL=FlamSaasSDK.min.js.map diff --git a/dist/FlamSaasSDK.min.js.map b/dist/FlamSaasSDK.min.js.map new file mode 100644 index 0000000..390239e --- /dev/null +++ b/dist/FlamSaasSDK.min.js.map @@ -0,0 +1 @@ +{"version":3,"file":"FlamSaasSDK.min.js","sources":["../src/constants.js","../src/renderWithRetry.js","../src/helper/assert.js","../src/sdk.js","../src/placeOrder.js","../src/receiveMessage.js","../src/sendMessage.js","../src/closeIFrame.js","../src/version.js","../src/index.js"],"sourcesContent":["const SDK_BASE_URL = 'https://saas-sdk-flam.vercel.app';\n// const SDK_BASE_URL = 'http://localhost:3000';\n\nexport const PAGES = {\n main: SDK_BASE_URL,\n error: `${SDK_BASE_URL}/error`\n};\n","import { PAGES } from './constants';\n\nexport let trackOrder = null;\nexport default async function renderWithRetry({ url }) {\n const body = document.querySelector('body');\n\n const styleSheet = document.createElement('style');\n styleSheet.type = 'text/css';\n styleSheet.id = 'saas-sdk-style';\n styleSheet.innerText = `\n .flam-sdk-bg {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n\n min-height: 100vh;\n min-width: 100vw;\n border: none;\n background: rgba(0,0,0, 0.4);\n\n display: flex;\n justify-content: center;\n align-items: center;\n }\n\n #flam-sdk-iframe {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n\n min-height: 100vh;\n min-width: 100vw;\n border: none;\n }\n\n .flam-sdk-loading {\n display: inline-block;\n position: relative;\n width: 80px;\n height: 80px;\n }\n .flam-sdk-loading div {\n box-sizing: border-box;\n display: block;\n position: absolute;\n width: 64px;\n height: 64px;\n margin: 8px;\n border: 3px solid #000;\n border-radius: 50%;\n animation: flam-sdk-loading 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;\n border-color: #000 transparent transparent transparent;\n }\n .flam-sdk-loading div:nth-child(1) {\n animation-delay: -0.45s;\n }\n .flam-sdk-loading div:nth-child(2) {\n animation-delay: -0.3s;\n }\n .flam-sdk-loading div:nth-child(3) {\n animation-delay: -0.15s;\n }\n @keyframes flam-sdk-loading {\n 0% {\n transform: rotate(0deg);\n }\n 100% {\n transform: rotate(360deg);\n }\n }\n `;\n\n await document.head.appendChild(styleSheet);\n\n const UI = await document.createElement('div');\n UI.id = 'flam-sdk-wrapper';\n\n var RegExp = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i;\n\n const newUrl = () => {\n if (\n this.order_details &&\n this.order_details.theme &&\n this.order_details.theme.color &&\n RegExp.test(this.order_details.theme.color)\n ) {\n const x = '/?theme=';\n return url + x + encodeURIComponent(this.order_details.theme.color);\n }\n return url;\n };\n\n UI.innerHTML = `\n
\n
\n
\n
\n \n
\n `;\n\n await body.appendChild(UI);\n\n const iFrame = document.getElementById('flam-sdk-iframe');\n\n iFrame.addEventListener('load', async e => {\n e.preventDefault();\n\n try {\n if (this.clientData.environment == 'PRODUCTION') {\n await fetch(PAGES.main);\n }\n\n // hide loading\n document.getElementById('flam-sdk-bg').style.display = 'none';\n\n // Bring the iframe back\n iFrame.style.opacity = '1';\n\n trackOrder = e => {\n this.receiveMessage(e);\n };\n\n // for receiving messages from iframe\n window.addEventListener('message', trackOrder);\n\n // for sending messages to iframe\n this.iWindow = document.getElementById('flam-sdk-iframe').contentWindow;\n } catch (err) {\n if (err.message === 'Failed to fetch') {\n this.close();\n this.callback({\n code: 500,\n message: 'SDK down!'\n });\n }\n }\n });\n}\n","var toString = Object.prototype.toString;\n\nfunction attribute(o, attr, type, text) {\n type = type === 'array' ? 'object' : type;\n if (o && typeof o[attr] !== type) {\n throw new Error(text);\n }\n}\n\nfunction variable(o, type, text) {\n if (typeof o !== type) {\n throw new Error(text);\n }\n}\n\nfunction value(o, values, text) {\n if (values.indexOf(o) === -1) {\n throw new Error(text);\n }\n}\n\nfunction check(o, config, attributes) {\n if (!config.optional || o) {\n variable(o, config.type, config.message);\n }\n if (config.type === 'object' && attributes) {\n var keys = Object.keys(attributes);\n\n for (var index = 0; index < keys.length; index++) {\n var a = keys[index];\n if (!attributes[a].optional || o[a]) {\n if (!attributes[a].condition || attributes[a].condition(o)) {\n attribute(o, a, attributes[a].type, attributes[a].message);\n if (attributes[a].values) {\n value(o[a], attributes[a].values, attributes[a].value_message);\n }\n }\n }\n }\n }\n}\n\n/**\n * Wrap `Array.isArray` Polyfill for IE9\n * source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray\n *\n * @param {Array} array\n * @private\n */\nfunction isArray(array) {\n if (this.supportsIsArray()) {\n return Array.isArray(array);\n }\n\n return toString.call(array) === '[object Array]';\n}\n\nfunction supportsIsArray() {\n return Array.isArray != null;\n}\n\nexport default {\n check: check,\n attribute: attribute,\n variable: variable,\n value: value,\n isArray: isArray,\n supportsIsArray: supportsIsArray\n};","import closeIframe from './closeIFrame';\nimport assert from './helper/assert';\nimport placeOrder from './placeOrder';\nimport receiveMessage from './receiveMessage';\nimport renderWithRetry from './renderWithRetry';\nimport sendMessage from './sendMessage';\n\n/**\n * Handles all the browser's AuthN/AuthZ flows\n * @constructor\n * @param {Object} options\n * @param {String} options.key the API Key found on your Application settings page\n * @param {String} [options.environment] enviornment sandbox | production\n * @param {String} [options.name] name of client\n * @param {String} [options.logoUrl] client's brand logo url\n * @param {String} [options.email] client's support email for error page\n * @param {String} [options.phone] client's support phone for error page\n */\nfunction init(options) {\n /* eslint-disable */\n try {\n assert.check(\n options,\n { type: 'object', message: 'clientData parameter is not valid' },\n {\n key: { type: 'string', message: 'key is required' },\n environment: {\n optional: true,\n type: 'string',\n message: 'environment is required'\n }\n }\n );\n\n if (options.overrides) {\n assert.check(options.overrides, {\n type: 'object',\n message: 'overrides option is not valid'\n });\n }\n } catch (err) {\n throw new Error(err.message);\n }\n\n options.environment =\n options &&\n typeof options.environment === 'string' &&\n options.environment.toUpperCase() === 'PRODUCTION'\n ? 'PRODUCTION'\n : 'SANDBOX';\n\n this.clientData = options;\n /* eslint-enable */\n}\n\n// core methods\ninit.prototype.renderWithRetry = renderWithRetry;\ninit.prototype.placeOrder = placeOrder;\ninit.prototype.receiveMessage = receiveMessage;\ninit.prototype.sendMessage = sendMessage;\ninit.prototype.close = closeIframe;\n\nexport default init;\n","import { PAGES } from './constants';\nimport assert from './helper/assert';\n\nexport default function placeOrder(order_details, callback) {\n this.order_details = order_details;\n try {\n assert.check(\n this.clientData,\n { type: 'object', message: 'init data is invalid' },\n {\n key: { type: 'string', message: 'key is required in init data' },\n environment: {\n optional: true,\n type: 'string',\n message: 'environment must be a string in init data'\n }\n }\n );\n\n assert.check(\n order_details,\n {\n type: 'object',\n message: 'options parameter is invalid'\n },\n {\n productId: { type: 'string', message: 'productId is required!' }\n },\n {\n refId: { type: 'string', message: 'refId is required!' }\n }\n );\n\n if (callback) {\n let url = `${PAGES.main}`;\n this.callback = callback;\n this.renderWithRetry({ url, error: false });\n } else {\n throw new Error('callback function is required!');\n }\n } catch (err) {\n if (callback) {\n let url = `${PAGES.error}/Something went wrong!`;\n this.renderWithRetry({\n url,\n error: true\n });\n callback({ code: 400, message: err.message }, null);\n } else {\n throw new Error('callback function is required!');\n }\n }\n}\n","import { PAGES } from './constants';\n\nexport default function receiveMessage(event) {\n if (event.origin == PAGES.main) {\n switch (event.data.type) {\n case 'CLOSE':\n this.close();\n break;\n case 'READY_TO_RECEIVE':\n this.sendMessage(\n {\n type: 'INITIAL_DATA',\n payload: {\n client_data: this.clientData,\n order_details: this.order_details\n }\n },\n '*'\n );\n break;\n case 'READY_TO_RECEIVE_ERR':\n this.sendMessage(\n {\n type: 'INITIAL_DATA_ERR',\n payload: {\n email:\n this.order_details &&\n this.order_details.prefill &&\n this.order_details.prefill.email\n ? this.order_details.prefill.email\n : '',\n phone:\n this.order_details &&\n this.order_details.prefill &&\n this.order_details.prefill.phone\n ? this.order_details.prefill.phone\n : ''\n }\n },\n '*'\n );\n break;\n case 'CREATED':\n this.callback(null, {\n code: 201,\n data: event.data.payload,\n message: 'Order placed successfully'\n });\n this.close();\n break;\n case 'ERROR':\n this.callback(\n {\n code: event.data.payload.code,\n message: event.data.payload.message\n },\n null\n );\n break;\n }\n }\n}\n","export default function sendMessage(message) {\n this.iWindow.postMessage(message, '*');\n}\n","import { trackOrder } from './renderWithRetry';\n\nexport default function close() {\n window.removeEventListener('message', trackOrder);\n\n // remove the UI\n const element = document.getElementById('flam-sdk-wrapper');\n if (element) {\n element.remove();\n }\n\n // remove the styles\n const styleSheet = document.getElementById('saas-sdk-style');\n\n if (styleSheet) {\n styleSheet.remove();\n }\n}\n","module.exports = { raw: '1.0.0' };","import init from './sdk';\nimport version from './version';\n\nexport { version, init };\n\nexport default { version: version, init: init };\n"],"names":["PAGES","trackOrder","toString","Object","prototype","attribute","o","attr","type","text","Error","variable","value","values","indexOf","check","config","attributes","optional","message","keys","index","length","a","condition","value_message","isArray","array","this","supportsIsArray","Array","call","init","options","assert","key","environment","overrides","err","toUpperCase","clientData","renderWithRetry","async","url","body","document","querySelector","styleSheet","createElement","id","innerText","head","appendChild","UI","RegExp","innerHTML","order_details","theme","color","test","encodeURIComponent","newUrl","iFrame","getElementById","addEventListener","e","preventDefault","fetch","style","display","opacity","receiveMessage","window","iWindow","contentWindow","close","callback","code","placeOrder","productId","refId","error","event","origin","data","sendMessage","payload","client_data","email","prefill","phone","postMessage","removeEventListener","element","remove","raw","version"],"mappings":";;;;;;;sPAAA,MAGaA,WAHQ,mCAGRA,YAEJ,yCCHF,IAAIC,WAAa,KCFxB,IAAIC,SAAWC,OAAOC,UAAUF,SAEhC,SAASG,UAAUC,EAAGC,KAAMC,KAAMC,MAE9B,GADAD,KAAgB,UAATA,KAAmB,SAAWA,KACjCF,UAAYA,EAAEC,QAAUC,KACxB,MAAM,IAAIE,MAAMD,MAIxB,SAASE,SAASL,EAAGE,KAAMC,MACvB,UAAWH,IAAME,KACb,MAAM,IAAIE,MAAMD,MAIxB,SAASG,MAAMN,EAAGO,OAAQJ,MACtB,IAA2B,IAAvBI,OAAOC,QAAQR,GACf,MAAM,IAAII,MAAMD,iBA4CT,CACXM,MAzCJ,SAAeT,EAAGU,OAAQC,YAItB,GAHKD,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DA,WACbH,OAAOoB,oBAAoB,UAAW3F,YAGtC,MAAM4F,QAAUhD,SAASkB,eAAe,oBACpC8B,SACFA,QAAQC,SAIV,MAAM/C,WAAaF,SAASkB,eAAe,kBAEvChB,YACFA,WAAW+C,UCff,YAAiB,CAAEC,IAAK,eCKT,CAAEC,QAASA,QAAShE,KAAMA"} \ No newline at end of file diff --git a/examples/vanilla-js/index.html b/examples/vanilla-js/index.html index cbd8ace..4422230 100644 --- a/examples/vanilla-js/index.html +++ b/examples/vanilla-js/index.html @@ -14,6 +14,8 @@ /> + + diff --git a/src/constants.js b/src/constants.js index 95db58c..11ae80a 100644 --- a/src/constants.js +++ b/src/constants.js @@ -1,4 +1,5 @@ const SDK_BASE_URL = 'https://saas-sdk-flam.vercel.app'; +// const SDK_BASE_URL = 'http://localhost:3000'; export const PAGES = { main: SDK_BASE_URL,