Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@persona-js/verify

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@persona-js/verify - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

76

dist/index.js

@@ -5,2 +5,28 @@ 'use strict';

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var IFRAME_SANDBOX_PERMISSIONS = [

@@ -16,15 +42,35 @@ 'allow-same-origin',

var BACKDROP_STYLE = "\n position: absolute;\n top: 0;\n bottom: 0;\n width: 100%;\n height: 100vh;\n background-color: #000000AA;\n overflow-y: scroll;\n";
var camelToKebab = function (camel) {
return camel
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
.replace(/([A-Z])([A-Z])(?=[a-z])/g, '$1-$2')
.toLowerCase();
};
var generateClient = function (normalizedOptions) {
var search = Object.entries(normalizedOptions)
.filter(function (_a) {
var key = _a[0], value = _a[1];
return value !== null && key !== 'host';
})
.reduce(function (query, _a) {
var key = _a[0], value = _a[1];
return query + "&" + key + "=" + encodeURIComponent(value);
}, "?client=something");
var prefills = __assign({}, normalizedOptions.prefill);
var givenOptions = __assign(__assign({}, normalizedOptions), { prefill: null });
var getSearchParam = function () {
var basicParams = Object.entries(givenOptions)
.filter(function (keyAndValue) {
return keyAndValue[1] !== null && keyAndValue[0] !== 'host';
})
.reduce(function (query, _a) {
var key = _a[0], value = _a[1];
return query + "&" + key + "=" + encodeURIComponent(value);
}, "?client=something");
var prefillQueries = Object.entries(prefills)
.filter(function (prefillKeyAndValue) { return prefillKeyAndValue[1] !== undefined; })
.map(function (_a) {
var prefillKey = _a[0], prefillValue = _a[1];
return "prefill[" + camelToKebab(prefillKey) + "]=" + encodeURIComponent(prefillValue);
})
.join('&');
return [basicParams, prefillQueries].join('&');
};
var on = function (eventName, listener) {
return client;
};
var prefill = function (prefillParams) {
prefills = __assign(__assign({}, prefills), prefillParams);
};
var start = function () {

@@ -36,3 +82,3 @@ var backdrop = document.createElement('div');

iframe.allow = 'camera';
iframe.src = "https://" + normalizedOptions.host + "/widget" + search + "&iframe-origin=" + encodeURIComponent(window.location.origin);
iframe.src = "https://" + normalizedOptions.host + "/widget" + getSearchParam() + "&iframe-origin=" + encodeURIComponent(window.location.origin);
iframe.setAttribute('sandbox', IFRAME_SANDBOX_PERMISSIONS.join(' '));

@@ -55,3 +101,3 @@ iframe.setAttribute('style', IFRAME_STYLE.replace(/^\s+/g, '').replace(/\n/g, ''));

var getHostedFlowUrl = function () {
return "https://" + normalizedOptions.host + "/verify" + search;
return "https://" + normalizedOptions.host + "/verify" + getSearchParam();
};

@@ -61,3 +107,3 @@ var client = {

on: on,
prefill: function () { },
prefill: prefill,
start: start,

@@ -68,3 +114,3 @@ };

var newInquiry = function (templateId, options) {
var _a, _b, _c, _d, _e;
var _a, _b, _c, _d, _e, _f;
return generateClient({

@@ -77,6 +123,7 @@ 'template-id': templateId,

'account-id': (_e = options === null || options === void 0 ? void 0 : options.accountId) !== null && _e !== void 0 ? _e : null,
prefill: (_f = options === null || options === void 0 ? void 0 : options.prefill) !== null && _f !== void 0 ? _f : null,
});
};
var resumeInquiry = function (inquiryId, options) {
var _a, _b, _c;
var _a, _b, _c, _d;
return generateClient({

@@ -87,2 +134,3 @@ 'inquiry-id': inquiryId,

'session-token': (_c = options === null || options === void 0 ? void 0 : options.sessionToken) !== null && _c !== void 0 ? _c : null,
prefill: (_d = options === null || options === void 0 ? void 0 : options.prefill) !== null && _d !== void 0 ? _d : null,
});

@@ -89,0 +137,0 @@ };

interface CommonOptions {
host: string;
language: string;
prefill?: {
nameFirst?: string;
nameLast?: string;
birthdate?: string;
addressStreet1?: string;
addressCity?: string;
addressSubdivision?: string;
addressPostalCode?: string;
countryCode?: string;
phoneNumber?: string;
emailAddress?: string;
};
}

@@ -16,3 +28,3 @@ interface CreateInquiryOptions extends CommonOptions {

on: (eventName: 'complete' | 'fail' | 'start', listener: (inquiryId: string) => void) => any;
prefill: () => void;
prefill: (prefillParams: CommonOptions['prefill']) => void;
start: () => void;

@@ -23,5 +35,5 @@ };

on: (eventName: 'complete' | 'fail' | 'start', listener: (inquiryId: string) => void) => any;
prefill: () => void;
prefill: (prefillParams: CommonOptions['prefill']) => void;
start: () => void;
};
export {};

7

package.json
{
"name": "@persona-js/verify",
"version": "0.1.0",
"version": "0.2.0",
"description": "An unofficial Persona client to verify customers",

@@ -14,6 +14,3 @@ "main": "./dist/index.js",

},
"publishConfig": {
"access": "public"
},
"gitHead": "f80a269f28f2c2e9815f23a2f975679fbfbde847"
"gitHead": "0783bb13fcdbfb078f14164411d91092b46bcb97"
}
interface CommonOptions {
host: string
language: string
prefill?: {
nameFirst?: string
nameLast?: string
birthdate?: string
addressStreet1?: string
addressCity?: string
addressSubdivision?: string
addressPostalCode?: string
countryCode?: string
phoneNumber?: string
emailAddress?: string
}
}

@@ -55,6 +67,16 @@

interface NewInquiryNormalizedOptions {
'template-id': string
const camelToKebab = (camel: string) =>
camel
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
.replace(/([A-Z])([A-Z])(?=[a-z])/g, '$1-$2')
.toLowerCase()
interface CommonNormalizedOptions {
host: string
language: string | null
prefill: CommonOptions['prefill'] | null
}
interface NewInquiryNormalizedOptions extends CommonNormalizedOptions {
'template-id': string
environment: string

@@ -65,6 +87,4 @@ 'reference-id': string | null

interface ResumeInquiryNormalizedOptions {
interface ResumeInquiryNormalizedOptions extends CommonNormalizedOptions {
'inquiry-id': string
host: string
language: string | null
'session-token': string | null

@@ -75,11 +95,25 @@ }

const listeners = []
let prefills = { ...normalizedOptions.prefill }
const givenOptions: NewInquiryNormalizedOptions | ResumeInquiryNormalizedOptions = {
...normalizedOptions,
prefill: null,
}
const search = Object.entries(normalizedOptions)
.filter(([key, value]) => {
return value !== null && key !== 'host'
})
.reduce((query, [key, value]) => {
return `${query}&${key}=${encodeURIComponent(value)}`
}, `?client=something`)
const getSearchParam = () => {
const basicParams = Object.entries(givenOptions)
.filter((keyAndValue): keyAndValue is [string, string] => {
return keyAndValue[1] !== null && keyAndValue[0] !== 'host'
})
.reduce((query, [key, value]) => {
return `${query}&${key}=${encodeURIComponent(value)}`
}, `?client=something`)
const prefillQueries = Object.entries(prefills)
.filter((prefillKeyAndValue): prefillKeyAndValue is [string, string] => prefillKeyAndValue[1] !== undefined)
.map(([prefillKey, prefillValue]) => `prefill[${camelToKebab(prefillKey)}]=${encodeURIComponent(prefillValue)}`)
.join('&')
return [basicParams, prefillQueries].join('&')
}
const on = (eventName: 'complete' | 'fail' | 'start', listener: (inquiryId: string) => void) => {

@@ -90,2 +124,6 @@ listeners.push(listener)

const prefill = (prefillParams: CommonOptions['prefill']) => {
prefills = { ...prefills, ...prefillParams }
}
const start = () => {

@@ -98,3 +136,3 @@ const backdrop = document.createElement('div')

iframe.allow = 'camera'
iframe.src = `https://${normalizedOptions.host}/widget${search}&iframe-origin=${encodeURIComponent(
iframe.src = `https://${normalizedOptions.host}/widget${getSearchParam()}&iframe-origin=${encodeURIComponent(
window.location.origin,

@@ -123,3 +161,3 @@ )}`

const getHostedFlowUrl = () => {
return `https://${normalizedOptions.host}/verify${search}`
return `https://${normalizedOptions.host}/verify${getSearchParam()}`
}

@@ -130,3 +168,3 @@

on,
prefill: () => {},
prefill,
start,

@@ -146,2 +184,3 @@ }

'account-id': options?.accountId ?? null,
prefill: options?.prefill ?? null,
})

@@ -156,3 +195,4 @@ }

'session-token': options?.sessionToken ?? null,
prefill: options?.prefill ?? null,
})
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc