Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HVC-33 Add ability to set UI language of Veriff via JS SDK #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "@veriff/js-sdk",
"version": "1.2.3",
"version": "1.2.4",
"description": "JavaScript SDK for Veriff identity verification",
"main": "lib/veriff.js",
"types": "lib/index.d.ts",
"scripts": {
"build": "webpack --config webpack/webpack.config.js --mode production",
"dev": "webpack --progress --colors --watch --config webpack/webpack.config.js",
"dev": "webpack --progress --color --watch --config webpack/webpack.config.js",
"test": "jest",
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
"lint": "eslint --ext=js,ts src"
Expand Down
26 changes: 5 additions & 21 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,15 @@
import './styles/style.css';
import { createTemplate, PersonData, FormLabel } from './template';
import { createTemplate } from './template';
import { createSession } from './xhr';
import { Options, VeriffSDKInstance, MountOptions, Params } from './interfaces';

interface Options {
host?: string;
apiKey: string;
parentId: string;
onSession: (err, response) => void;
}

interface MountOptions {
formLabel?: FormLabel;
submitBtnText?: string;
loadingText?: string;
}

interface Params {
person?: PersonData;
vendorData?: string;
}

const Veriff = (options: Options) => {
const { host = 'https://api.veriff.me', apiKey, parentId, onSession } = options;
const Veriff = (options: Options): VeriffSDKInstance => {
const { host = 'https://api.veriff.me', apiKey, parentId, onSession, lang } = options;
const onSessionCallback = onSession;
let mountedOptions: MountOptions = { loadingText: 'Loading...', submitBtnText: 'Start Verification' };
let params: Params = {
person: {},
lang,
};
let veriffForm: HTMLFormElement;

Expand Down
27 changes: 27 additions & 0 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { FormLabel, PersonData } from './template';

export interface Options {
host?: string;
apiKey: string;
parentId: string;
onSession: (err, response) => void;
lang?: string;
}

export interface MountOptions {
formLabel?: FormLabel;
submitBtnText?: string;
loadingText?: string;
}

export interface Params {
person?: PersonData;
vendorData?: string;
lang?: string,
}

export interface VeriffSDKInstance {
params: Params;
setParams: (params: Params) => void;
mount: (options: MountOptions) => void;
}
5 changes: 3 additions & 2 deletions src/xhr.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { PersonData } from './template';
import type { Params } from './interfaces';

const CREATED_RESPONSE_STATUS = 201;

export function createSession(
host: string,
apiKey: string,
data: { person?: PersonData; vendorData?: string },
data: Params,
cb: (statusObject, resp) => void
): void {
const url = `${host}/v1/sessions`;
Expand Down Expand Up @@ -40,6 +40,7 @@ export function createSession(
},
vendorData: data.vendorData,
timestamp: new Date().toISOString(),
lang: data.lang,
},
};

Expand Down