@alloyidentity/web-sdk
Advanced tools
Comparing version 0.2.13 to 0.2.14
@@ -122,2 +122,19 @@ function createCommonjsModule(fn, module) { | ||
var filterObj = function (obj, predicate) { | ||
var ret = {}; | ||
var keys = Object.keys(obj); | ||
var isArr = Array.isArray(predicate); | ||
for (var i = 0; i < keys.length; i++) { | ||
var key = keys[i]; | ||
var val = obj[key]; | ||
if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) { | ||
ret[key] = val; | ||
} | ||
} | ||
return ret; | ||
}; | ||
var queryString = createCommonjsModule(function (module, exports) { | ||
@@ -128,2 +145,3 @@ | ||
const isNullOrUndefined = value => value === null || value === undefined; | ||
@@ -248,4 +266,6 @@ | ||
return (key, value, accumulator) => { | ||
const isArray = typeof value === 'string' && value.split('').indexOf(options.arrayFormatSeparator) > -1; | ||
const newValue = isArray ? value.split(options.arrayFormatSeparator).map(item => decode(item, options)) : value === null ? value : decode(value, options); | ||
const isArray = typeof value === 'string' && value.includes(options.arrayFormatSeparator); | ||
const isEncodedArray = (typeof value === 'string' && !isArray && decode(value, options).includes(options.arrayFormatSeparator)); | ||
value = isEncodedArray ? decode(value, options) : value; | ||
const newValue = isArray || isEncodedArray ? value.split(options.arrayFormatSeparator).map(item => decode(item, options)) : value === null ? value : decode(value, options); | ||
accumulator[key] = newValue; | ||
@@ -341,3 +361,3 @@ }; | ||
function parse(input, options) { | ||
function parse(query, options) { | ||
options = Object.assign({ | ||
@@ -359,13 +379,17 @@ decode: true, | ||
if (typeof input !== 'string') { | ||
if (typeof query !== 'string') { | ||
return ret; | ||
} | ||
input = input.trim().replace(/^[?#&]/, ''); | ||
query = query.trim().replace(/^[?#&]/, ''); | ||
if (!input) { | ||
if (!query) { | ||
return ret; | ||
} | ||
for (const param of input.split('&')) { | ||
for (const param of query.split('&')) { | ||
if (param === '') { | ||
continue; | ||
} | ||
let [key, value] = splitOnFirst(options.decode ? param.replace(/\+/g, ' ') : param, '='); | ||
@@ -466,15 +490,29 @@ | ||
exports.parseUrl = (input, options) => { | ||
return { | ||
url: removeHash(input).split('?')[0] || '', | ||
query: parse(extract(input), options) | ||
}; | ||
exports.parseUrl = (url, options) => { | ||
options = Object.assign({ | ||
decode: true | ||
}, options); | ||
const [url_, hash] = splitOnFirst(url, '#'); | ||
return Object.assign( | ||
{ | ||
url: url_.split('?')[0] || '', | ||
query: parse(extract(url), options) | ||
}, | ||
options && options.parseFragmentIdentifier && hash ? {fragmentIdentifier: decode(hash, options)} : {} | ||
); | ||
}; | ||
exports.stringifyUrl = (input, options) => { | ||
const url = removeHash(input.url).split('?')[0] || ''; | ||
const queryFromUrl = exports.extract(input.url); | ||
const parsedQueryFromUrl = exports.parse(queryFromUrl); | ||
const hash = getHash(input.url); | ||
const query = Object.assign(parsedQueryFromUrl, input.query); | ||
exports.stringifyUrl = (object, options) => { | ||
options = Object.assign({ | ||
encode: true, | ||
strict: true | ||
}, options); | ||
const url = removeHash(object.url).split('?')[0] || ''; | ||
const queryFromUrl = exports.extract(object.url); | ||
const parsedQueryFromUrl = exports.parse(queryFromUrl, {sort: false}); | ||
const query = Object.assign(parsedQueryFromUrl, object.query); | ||
let queryString = exports.stringify(query, options); | ||
@@ -485,13 +523,39 @@ if (queryString) { | ||
let hash = getHash(object.url); | ||
if (object.fragmentIdentifier) { | ||
hash = `#${encode(object.fragmentIdentifier, options)}`; | ||
} | ||
return `${url}${queryString}${hash}`; | ||
}; | ||
exports.pick = (input, filter, options) => { | ||
options = Object.assign({ | ||
parseFragmentIdentifier: true | ||
}, options); | ||
const {url, query, fragmentIdentifier} = exports.parseUrl(input, options); | ||
return exports.stringifyUrl({ | ||
url, | ||
query: filterObj(query, filter), | ||
fragmentIdentifier | ||
}, options); | ||
}; | ||
exports.exclude = (input, filter, options) => { | ||
const exclusionFilter = Array.isArray(filter) ? key => !filter.includes(key) : (key, value) => !filter(key, value); | ||
return exports.pick(input, exclusionFilter, options); | ||
}; | ||
}); | ||
var queryString_1 = queryString.extract; | ||
var queryString_2 = queryString.parse; | ||
var queryString_3 = queryString.stringify; | ||
var queryString_4 = queryString.parseUrl; | ||
var queryString_5 = queryString.stringifyUrl; | ||
queryString.extract; | ||
queryString.parse; | ||
queryString.stringify; | ||
queryString.parseUrl; | ||
queryString.stringifyUrl; | ||
queryString.pick; | ||
queryString.exclude; | ||
var config = { | ||
iframe: 'https://docv-iframe.alloy.co/', | ||
iframe: 'https://docv-iframe.alloy.co/', | ||
codeless: process.env.CODELESS_SDK_APP_URL || 'https://alloysdk.alloy.co/' | ||
@@ -511,3 +575,4 @@ }; | ||
var init = function (_a) { | ||
var key = _a.key, entityToken = _a.entityToken, externalEntityId = _a.externalEntityId, evaluationData = _a.evaluationData, production = _a.production, maxEvaluationAttempts = _a.maxEvaluationAttempts, documents = _a.documents, selfie = _a.selfie, color = _a.color, forceMobile = _a.forceMobile, validationPreChecks = _a.validationPreChecks, journeyApplicationToken = _a.journeyApplicationToken, journeyToken = _a.journeyToken, isLegacy = _a.isLegacy, isNext = _a.isNext; | ||
var key = _a.key, entityToken = _a.entityToken, externalEntityId = _a.externalEntityId, evaluationData = _a.evaluationData, production = _a.production, maxEvaluationAttempts = _a.maxEvaluationAttempts, documents = _a.documents, selfie = _a.selfie, color = _a.color, customStyle = _a.customStyle, forceMobile = _a.forceMobile, validationPreChecks = _a.validationPreChecks, journeyApplicationToken = _a.journeyApplicationToken, journeyToken = _a.journeyToken, isLegacy = _a.isLegacy, isNext = _a.isNext, isSingleEntity = _a.isSingleEntity; | ||
var _b, _c; | ||
alloyInitParams.key = key; | ||
@@ -550,3 +615,15 @@ if (entityToken) { | ||
} | ||
iframeSrc = "" + queryString.stringify(alloyInitParams) + (evaluationData ? "&" + queryString.stringify(evaluationData) : '') + (color ? "&" + queryString.stringify(color) : ''); | ||
if (isSingleEntity) { | ||
alloyInitParams.isSingleEntity = isSingleEntity; | ||
} | ||
//parse the theme and component customization object into a string and pass it along to SDK UI. | ||
var themeString = JSON.stringify((_b = customStyle) === null || _b === void 0 ? void 0 : _b.theme); | ||
var componentOverrideString = JSON.stringify((_c = customStyle) === null || _c === void 0 ? void 0 : _c.componentOverride); | ||
var themeObject = { | ||
theme: themeString, | ||
}; | ||
var componentOverrideObject = { | ||
componentOverride: componentOverrideString | ||
}; | ||
iframeSrc = "" + queryString.stringify(alloyInitParams) + (evaluationData ? "&" + queryString.stringify(evaluationData) : '') + (color ? "&" + queryString.stringify(color) : '') + (themeObject.theme ? "&" + queryString.stringify(themeObject) : '') + (componentOverrideObject.componentOverride ? "&" + queryString.stringify(componentOverrideObject) : ''); | ||
window.addEventListener('message', function (event) { | ||
@@ -606,3 +683,3 @@ var isAlloyUrl = event.origin === 'https://docv-iframe.alloy.co' || event.origin === 'https://alloysdk.alloy.co' || event.origin === 'https://alloysdk-qa.alloy.co'; | ||
export default alloy; | ||
export { alloy as default }; | ||
//# sourceMappingURL=index.es.js.map |
@@ -126,2 +126,19 @@ 'use strict'; | ||
var filterObj = function (obj, predicate) { | ||
var ret = {}; | ||
var keys = Object.keys(obj); | ||
var isArr = Array.isArray(predicate); | ||
for (var i = 0; i < keys.length; i++) { | ||
var key = keys[i]; | ||
var val = obj[key]; | ||
if (isArr ? predicate.indexOf(key) !== -1 : predicate(key, val, obj)) { | ||
ret[key] = val; | ||
} | ||
} | ||
return ret; | ||
}; | ||
var queryString = createCommonjsModule(function (module, exports) { | ||
@@ -132,2 +149,3 @@ | ||
const isNullOrUndefined = value => value === null || value === undefined; | ||
@@ -252,4 +270,6 @@ | ||
return (key, value, accumulator) => { | ||
const isArray = typeof value === 'string' && value.split('').indexOf(options.arrayFormatSeparator) > -1; | ||
const newValue = isArray ? value.split(options.arrayFormatSeparator).map(item => decode(item, options)) : value === null ? value : decode(value, options); | ||
const isArray = typeof value === 'string' && value.includes(options.arrayFormatSeparator); | ||
const isEncodedArray = (typeof value === 'string' && !isArray && decode(value, options).includes(options.arrayFormatSeparator)); | ||
value = isEncodedArray ? decode(value, options) : value; | ||
const newValue = isArray || isEncodedArray ? value.split(options.arrayFormatSeparator).map(item => decode(item, options)) : value === null ? value : decode(value, options); | ||
accumulator[key] = newValue; | ||
@@ -345,3 +365,3 @@ }; | ||
function parse(input, options) { | ||
function parse(query, options) { | ||
options = Object.assign({ | ||
@@ -363,13 +383,17 @@ decode: true, | ||
if (typeof input !== 'string') { | ||
if (typeof query !== 'string') { | ||
return ret; | ||
} | ||
input = input.trim().replace(/^[?#&]/, ''); | ||
query = query.trim().replace(/^[?#&]/, ''); | ||
if (!input) { | ||
if (!query) { | ||
return ret; | ||
} | ||
for (const param of input.split('&')) { | ||
for (const param of query.split('&')) { | ||
if (param === '') { | ||
continue; | ||
} | ||
let [key, value] = splitOnFirst(options.decode ? param.replace(/\+/g, ' ') : param, '='); | ||
@@ -470,15 +494,29 @@ | ||
exports.parseUrl = (input, options) => { | ||
return { | ||
url: removeHash(input).split('?')[0] || '', | ||
query: parse(extract(input), options) | ||
}; | ||
exports.parseUrl = (url, options) => { | ||
options = Object.assign({ | ||
decode: true | ||
}, options); | ||
const [url_, hash] = splitOnFirst(url, '#'); | ||
return Object.assign( | ||
{ | ||
url: url_.split('?')[0] || '', | ||
query: parse(extract(url), options) | ||
}, | ||
options && options.parseFragmentIdentifier && hash ? {fragmentIdentifier: decode(hash, options)} : {} | ||
); | ||
}; | ||
exports.stringifyUrl = (input, options) => { | ||
const url = removeHash(input.url).split('?')[0] || ''; | ||
const queryFromUrl = exports.extract(input.url); | ||
const parsedQueryFromUrl = exports.parse(queryFromUrl); | ||
const hash = getHash(input.url); | ||
const query = Object.assign(parsedQueryFromUrl, input.query); | ||
exports.stringifyUrl = (object, options) => { | ||
options = Object.assign({ | ||
encode: true, | ||
strict: true | ||
}, options); | ||
const url = removeHash(object.url).split('?')[0] || ''; | ||
const queryFromUrl = exports.extract(object.url); | ||
const parsedQueryFromUrl = exports.parse(queryFromUrl, {sort: false}); | ||
const query = Object.assign(parsedQueryFromUrl, object.query); | ||
let queryString = exports.stringify(query, options); | ||
@@ -489,13 +527,39 @@ if (queryString) { | ||
let hash = getHash(object.url); | ||
if (object.fragmentIdentifier) { | ||
hash = `#${encode(object.fragmentIdentifier, options)}`; | ||
} | ||
return `${url}${queryString}${hash}`; | ||
}; | ||
exports.pick = (input, filter, options) => { | ||
options = Object.assign({ | ||
parseFragmentIdentifier: true | ||
}, options); | ||
const {url, query, fragmentIdentifier} = exports.parseUrl(input, options); | ||
return exports.stringifyUrl({ | ||
url, | ||
query: filterObj(query, filter), | ||
fragmentIdentifier | ||
}, options); | ||
}; | ||
exports.exclude = (input, filter, options) => { | ||
const exclusionFilter = Array.isArray(filter) ? key => !filter.includes(key) : (key, value) => !filter(key, value); | ||
return exports.pick(input, exclusionFilter, options); | ||
}; | ||
}); | ||
var queryString_1 = queryString.extract; | ||
var queryString_2 = queryString.parse; | ||
var queryString_3 = queryString.stringify; | ||
var queryString_4 = queryString.parseUrl; | ||
var queryString_5 = queryString.stringifyUrl; | ||
queryString.extract; | ||
queryString.parse; | ||
queryString.stringify; | ||
queryString.parseUrl; | ||
queryString.stringifyUrl; | ||
queryString.pick; | ||
queryString.exclude; | ||
var config = { | ||
iframe: 'https://docv-iframe.alloy.co/', | ||
iframe: 'https://docv-iframe.alloy.co/', | ||
codeless: process.env.CODELESS_SDK_APP_URL || 'https://alloysdk.alloy.co/' | ||
@@ -515,3 +579,4 @@ }; | ||
var init = function (_a) { | ||
var key = _a.key, entityToken = _a.entityToken, externalEntityId = _a.externalEntityId, evaluationData = _a.evaluationData, production = _a.production, maxEvaluationAttempts = _a.maxEvaluationAttempts, documents = _a.documents, selfie = _a.selfie, color = _a.color, forceMobile = _a.forceMobile, validationPreChecks = _a.validationPreChecks, journeyApplicationToken = _a.journeyApplicationToken, journeyToken = _a.journeyToken, isLegacy = _a.isLegacy, isNext = _a.isNext; | ||
var key = _a.key, entityToken = _a.entityToken, externalEntityId = _a.externalEntityId, evaluationData = _a.evaluationData, production = _a.production, maxEvaluationAttempts = _a.maxEvaluationAttempts, documents = _a.documents, selfie = _a.selfie, color = _a.color, customStyle = _a.customStyle, forceMobile = _a.forceMobile, validationPreChecks = _a.validationPreChecks, journeyApplicationToken = _a.journeyApplicationToken, journeyToken = _a.journeyToken, isLegacy = _a.isLegacy, isNext = _a.isNext, isSingleEntity = _a.isSingleEntity; | ||
var _b, _c; | ||
alloyInitParams.key = key; | ||
@@ -554,3 +619,15 @@ if (entityToken) { | ||
} | ||
iframeSrc = "" + queryString.stringify(alloyInitParams) + (evaluationData ? "&" + queryString.stringify(evaluationData) : '') + (color ? "&" + queryString.stringify(color) : ''); | ||
if (isSingleEntity) { | ||
alloyInitParams.isSingleEntity = isSingleEntity; | ||
} | ||
//parse the theme and component customization object into a string and pass it along to SDK UI. | ||
var themeString = JSON.stringify((_b = customStyle) === null || _b === void 0 ? void 0 : _b.theme); | ||
var componentOverrideString = JSON.stringify((_c = customStyle) === null || _c === void 0 ? void 0 : _c.componentOverride); | ||
var themeObject = { | ||
theme: themeString, | ||
}; | ||
var componentOverrideObject = { | ||
componentOverride: componentOverrideString | ||
}; | ||
iframeSrc = "" + queryString.stringify(alloyInitParams) + (evaluationData ? "&" + queryString.stringify(evaluationData) : '') + (color ? "&" + queryString.stringify(color) : '') + (themeObject.theme ? "&" + queryString.stringify(themeObject) : '') + (componentOverrideObject.componentOverride ? "&" + queryString.stringify(componentOverrideObject) : ''); | ||
window.addEventListener('message', function (event) { | ||
@@ -610,3 +687,3 @@ var isAlloyUrl = event.origin === 'https://docv-iframe.alloy.co' || event.origin === 'https://alloysdk.alloy.co' || event.origin === 'https://alloysdk-qa.alloy.co'; | ||
exports.default = alloy; | ||
exports["default"] = alloy; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@alloyidentity/web-sdk", | ||
"version": "0.2.13", | ||
"version": "0.2.14", | ||
"description": "Alloy Web Document SDK", | ||
@@ -8,2 +8,3 @@ "license": "MIT", | ||
"module": "dist/index.es.js", | ||
"types": "dist/index.d.ts", | ||
"jsnext:main": "dist/index.es.js", | ||
@@ -76,3 +77,3 @@ "scripts": { | ||
"rollup-plugin-url": "2.2.2", | ||
"typescript": "3.5.3" | ||
"typescript": "3.7.5" | ||
}, | ||
@@ -79,0 +80,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
143354
12
1302