@privateid/ultra-web-sdk-alpha
Version:
CryptoNets WebAssembly SDK
922 lines • 28.6 kB
JavaScript
// import { Base64, DLType, HCType, LOGTYPE, VerifyType } from './types';
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import { convertPngBase64ToJpegBase64 } from './utils';
// const rand = () => Math.random().toString(36).substr(2);
// export const postImages = (image: Base64) =>
// fetch(`${apiUrl}/upload-img`, {
// method: 'POST',
// headers: {
// Accept: 'application/json',
// 'Content-Type': 'application/json',
// },
// body: JSON.stringify({ image }),
// });
// /**
// * @category Api
// * @param pramUuid UUID to delete
// * @param callback Callback called once the delete is completed
// */
// export async function deleteUuid(guid: string, callback: () => void) {
// const myHeaders = new Headers();
// myHeaders.append('Accept', 'application/json, text/plain, */*');
// myHeaders.append('Accept-Encoding', 'gzip, deflate, br');
// myHeaders.append('x-api-key', apiKey);
// const formdata = new FormData();
// formdata.append('guid', guid);
// formdata.append('api_key', apiKey);
// const requestOptions: RequestInit = {
// method: 'POST',
// headers: myHeaders,
// body: formdata,
// mode: 'no-cors',
// };
// try {
// await fetch(`${apiUrl}/deleteUser`, requestOptions);
// callback();
// } catch (e) {
// printLogs('', e, getDebugType(), LOGTYPE.ERROR);
// }
// }
// export async function getPhrases(): Promise<Array<string>> {
// const requestOptions: RequestInit = {
// method: 'POST',
// };
// const res = await fetch(`${apiUrl}/getLivenessPhrases`, requestOptions);
// return res.json();
// }
// export async function sendOTP(phone_number: string): Promise<string> {
// if (!phone_number) return '';
// const token = rand() + rand();
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify({
// phone_number,
// token,
// api_key: apiKey,
// hostURL: window.location.href,
// customerName: 'betmgm',
// }),
// };
// const res = await fetch(`${apiUrl}/sendOTP`, requestOptions);
// return res.json();
// }
// export async function verifyOTP(otp: string, token: string): Promise<string> {
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify({
// token,
// otp,
// }),
// };
// const res = await fetch(`${apiUrl}/verifyOTP`, requestOptions);
// return res.json();
// }
// type createUserProps = {
// id?: string;
// guid?: string;
// phone?: string;
// phoneVerified?: boolean;
// email?: string;
// emailVerified?: boolean;
// ssn4?: string;
// ssn9?: string;
// userConsent: boolean;
// userConsentDate: string;
// userFaceEnrollConsent?: boolean;
// consentVersion?: string;
// consentContent?: string;
// portrait?: string;
// };
// export async function createUser(payload: createUserProps): Promise<string> {
// const userInfo = {
// token: payload.id,
// phone: payload.phone,
// phoneVerified: payload.phoneVerified,
// email: payload.email,
// emailVerified: payload.emailVerified,
// ssn: payload.ssn4,
// ssn4: payload.ssn4,
// ssn9: payload.ssn9,
// userConsent: payload.userConsent,
// userConsentDate: payload.userConsentDate,
// userFaceEnrollConsent: payload.userFaceEnrollConsent,
// consentVersion: payload.consentVersion,
// consentContent: payload.consentContent,
// };
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify(userInfo),
// headers: {
// 'x-api-key': apiKey,
// 'Content-Type': 'application/json',
// },
// };
// const res = await fetch(`${apiUrl}/user/create`, requestOptions);
// return res.json();
// }
// export async function sendEmail(email: string, uuid: string, skin: string, customerName: string): Promise<string> {
// const token = rand() + rand();
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify({
// skin,
// customerName,
// alias: uuid,
// hostUrl: window.location.href,
// version: '1.0',
// api_key: apiKey,
// email_address: email,
// token,
// action: 'exact_url',
// }),
// headers: {
// 'Content-Type': 'application/json',
// 'x-api-key': apiKey,
// },
// };
// const res = await fetch(`${apiUrl}/requestAuthLink`, requestOptions);
// return res.json();
// }
// export async function expandUri(shortUrl: string): Promise<string> {
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify({
// shortUrl,
// api_key: apiKey,
// }),
// headers: {
// 'Content-Type': 'application/json',
// 'x-api-key': apiKey,
// },
// };
// const res = await fetch(`${apiUrl}/expandUri`, requestOptions);
// return res.json();
// }
// type VerifyTokenProps = {
// code: string;
// type: VerifyType;
// };
// export async function verifyToken({ code, type }: VerifyTokenProps): Promise<string> {
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify({ code, type }),
// headers: {
// 'Content-Type': 'application/json',
// 'x-api-key': apiKey,
// },
// };
// const res = await fetch(`${apiUrl}/user/verif_code`, requestOptions);
// return res.json();
// }
// export async function sendSmsCode({ id, phone }: { id: string; phone: string }): Promise<string> {
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify({ token: id, phone }),
// headers: {
// 'Content-Type': 'application/json',
// 'x-api-key': apiKey,
// },
// };
// const res = await fetch(`${apiUrl}/user/send_code`, requestOptions);
// return res.json();
// }
// export async function sendEnrollSms({ id }: { id: string }): Promise<string> {
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify({ token: id }),
// headers: {
// 'Content-Type': 'application/json',
// 'x-api-key': apiKey,
// },
// };
// const res = await fetch(`${apiUrl}/user/send_redirectSms`, requestOptions);
// return res.json();
// }
// export async function sendMessage({
// id,
// type,
// endpoint,
// message,
// email,
// subject,
// phone,
// }: {
// id: string;
// type: 'email' | 'phone';
// endpoint: string;
// message: string;
// email?: string;
// subject?: string;
// phone?: string;
// }): Promise<string> {
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify({ token: id, type, email, subject, phone, endpoint, message }),
// headers: {
// 'Content-Type': 'application/json',
// 'x-api-key': apiKey,
// },
// };
// const res = await fetch(`${apiUrl}/user/sendMessage`, requestOptions);
// return res.json();
// }
// export async function uploadPortrait({ id, portrait }: { id: string; portrait: string }): Promise<string> {
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify({ token: id, portrait }),
// headers: {
// 'Content-Type': 'application/json',
// 'x-api-key': apiKey,
// },
// };
// const res = await fetch(`${apiUrl}/user/upload/portrait`, requestOptions);
// return res.json();
// }
// type UploadDlProps = {
// id: string;
// type: DLType;
// image?: string;
// barcode?: string;
// process_ocr?: boolean;
// };
// export async function uploadDL({ id, type, image, barcode, process_ocr }: UploadDlProps): Promise<string> {
// let payload;
// if (type === DLType.BARCODEJSON) {
// payload = {
// token: id,
// type,
// barcode,
// };
// } else {
// payload = {
// token: id,
// type,
// image,
// process_ocr,
// };
// }
// if (type === DLType.BARCODEJSON && !barcode) throw new Error("Barcode data is required for 'barcodeJson' type.");
// else if (type !== DLType.BARCODEJSON && !image) throw new Error('Image is required.');
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify(payload),
// headers: {
// 'Content-Type': 'application/json',
// 'x-api-key': apiKey,
// },
// };
// const res = await fetch(`${apiUrl}/user/upload/dl`, requestOptions);
// return res.json();
// }
// type UploadHcProps = {
// id: string;
// type: HCType;
// image?: string;
// processOcr?: boolean;
// };
// export async function uploadHC({ id, type, image, processOcr }: UploadHcProps): Promise<string> {
// const payload = {
// token: id,
// type,
// image,
// process_ocr: processOcr,
// };
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify(payload),
// headers: {
// 'Content-Type': 'application/json',
// 'x-api-key': apiKey,
// },
// };
// const res = await fetch(`${apiUrl}/user/upload/hc`, requestOptions);
// return res.json();
// }
// export async function getUserStatus({ id }: { id: string }): Promise<{
// complianceReview: boolean;
// expiredDate: string;
// expiredID: boolean;
// manualPIIEntry: boolean;
// orchestrationStatus: string;
// requestResAddress: boolean;
// requestSSN4: boolean;
// requestSSN9: boolean;
// requestScanID: boolean;
// toBeEncrypted: boolean;
// underAge: boolean;
// userApproved: boolean;
// userBiometric: string;
// userRegistered: boolean;
// userScanId: boolean;
// }> {
// const payload = { token: id };
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify(payload),
// headers: {
// 'Content-Type': 'application/json',
// 'x-api-key': apiKey,
// },
// };
// const res = await fetch(`${apiUrl}/user/status`, requestOptions);
// return res.json();
// }
// type Attributes = {
// uuid?: string;
// guid?: string;
// ssn?: string;
// ssn4?: string;
// govId?: {
// firstName?: string;
// lastName?: string;
// portraitConfScore?: number;
// address?: {
// addressLine1?: string;
// addressLine2?: string;
// city?: string;
// state?: string;
// zipCode?: string;
// country?: string;
// };
// idDocumentNumber?: string;
// };
// preferred?: {
// firstName?: string;
// lastName?: string;
// dob?: string;
// address?: {
// addressLine1?: string;
// addressLine2?: string;
// city?: string;
// state?: string;
// zipCode?: string;
// country?: string;
// };
// idDocumentNumber?: string;
// };
// };
// export async function updateUser({ id, attributes }: { id: string; attributes: Attributes }): Promise<string> {
// const payload = { token: id, attributes };
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify(payload),
// headers: {
// 'Content-Type': 'application/json',
// 'x-api-key': apiKey,
// },
// };
// const res = await fetch(`${apiUrl}/user/update`, requestOptions);
// return res.json();
// }
// export async function verifyUser({
// id,
// apiValue,
// organizationApiKey,
// }: {
// id: string;
// apiValue: string;
// organizationApiKey: string;
// }): Promise<any> {
// const payload = { token: id };
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify(payload),
// headers: {
// 'Content-Type': 'application/json',
// x_api_key: organizationApiKey,
// },
// };
// const res = await fetch(`${orchestrationAPIUrl}/verify/${apiValue}`, requestOptions);
// return res.json();
// }
// export async function getProductGroups(): Promise<any> {
// const requestOptions: RequestInit = {
// method: 'GET',
// headers: {
// 'Content-Type': 'application/json',
// 'x-api-key': apiKey,
// },
// };
// const res = await fetch(`${orchestrationAPIUrl}/product-group/list/prod`, requestOptions);
// return res.json();
// }
// export async function transmit({
// id,
// url,
// sessionToken,
// final,
// apiToken,
// }: {
// id: string;
// url: string;
// sessionToken: string;
// apiToken?: string;
// final: boolean;
// }) {
// const payload = { token: id, url, sessionToken, apiToken, final };
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify(payload),
// headers: {
// 'Content-Type': 'application/json',
// 'x-api-key': apiKey,
// },
// };
// return fetch(`${orchestrationAPIUrl}/transmit`, requestOptions);
// }
// export async function validateSecurityToken({ token, uuid }: { token: string; uuid: string }) {
// const payload = { api_key: apiKey, uuid, securityToken: token, IAL: '1' };
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify(payload),
// headers: {
// 'Content-Type': 'application/json',
// 'x-api-key': apiKey,
// },
// };
// const result = await (await fetch(`${apiUrl}/isSecurityTokenValid`, requestOptions)).json();
// return result;
// }
// export enum VerificationType {
// IDENTITY = 'IDENTITY',
// AGE = 'AGE',
// }
// export async function createVerificationSession({
// successUrl,
// failureUrl,
// type,
// productGroupId,
// }: {
// successUrl: string;
// failureUrl: string;
// type: VerificationType;
// productGroupId: string;
// }): Promise<any> {
// const payload = { successUrl, failureUrl, type, productGroupId };
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify(payload),
// headers: {
// 'Content-Type': 'application/json',
// 'x-api-key': apiKey,
// },
// };
// const result = await (await fetch(`${orchestrationAPIUrl}/verification-session’`, requestOptions)).json();
// return result;
// }
// // api v2
// enum SessionType {
// Identity = 'IDENTITY',
// Age = 'AGE',
// }
// export interface VerificationSessionPayload {
// successUrl: string;
// failureUrl: string;
// type: SessionType; // identity or age
// productGroupId: string;
// customerIn?: boolean; // customer information v1 only
// }
// export const createVerificationSessionV2 = async ({
// successUrl,
// failureUrl,
// type,
// productGroupId,
// customerIn,
// }: VerificationSessionPayload) => {
// try {
// const payload = {
// successUrl,
// failureUrl,
// type,
// productGroupId,
// customerIn,
// };
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify(payload),
// headers: {
// 'Content-Type': 'application/json',
// x_api_key: apiKey,
// },
// };
// const result = await (await fetch(`${orchestrationAPIUrl}/v2/verification-session`, requestOptions)).json();
// return result;
// } catch (err) {
// return err;
// }
// };
// export type createUserWithSessionProp = {
// sessionToken: string;
// ssn?: string;
// phone?: string;
// email?: string;
// };
// export const createUserWithSession = async ({ sessionToken, ssn, email, phone }: createUserWithSessionProp) => {
// const payload = { ssn, email, phone };
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify(payload),
// headers: {
// 'Content-Type': 'application/json',
// x_api_key: apiKey,
// },
// };
// const result = await (
// await fetch(`${orchestrationAPIUrl}/v2/verification-session/${sessionToken}/user`, requestOptions)
// ).json();
// return result;
// };
// export type updateUserManualInputWithSessionProps = {
// sessionToken: string;
// firstName?: string;
// lastName?: string;
// dob?: string;
// address?: {
// addressLine1?: string;
// addressLine2?: string;
// city?: string;
// state?: string;
// zipCode?: string;
// country?: string;
// };
// ssn?: string;
// };
// export const updateUserManualInputWithSession = async ({
// sessionToken,
// firstName,
// lastName,
// dob,
// address,
// }: updateUserManualInputWithSessionProps) => {
// const payload = { firstName, lastName, dob, ...address };
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify(payload),
// headers: {
// 'Content-Type': 'application/json',
// x_api_key: apiKey,
// },
// };
// const result = await (
// await fetch(`${orchestrationAPIUrl}/v2/verification-session/${sessionToken}/user/manual-input`, requestOptions)
// ).json();
// return result;
// };
// export enum createDocumentUploadIdTypeEnum {
// health_card = 'health_card',
// passport = 'passport',
// drivers_license = 'drivers_license',
// }
// export type createDocumentUploadIdType = {
// sessionToken: string;
// documentType: createDocumentUploadIdTypeEnum;
// content?: any;
// };
// export const createDocumentUploadIdWithSession = async ({
// sessionToken,
// documentType,
// content,
// }: createDocumentUploadIdType) => {
// const payload = { content };
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify(payload),
// headers: {
// 'Content-Type': 'application/json',
// x_api_key: apiKey,
// },
// };
// const result = await (
// await fetch(
// `${orchestrationAPIUrl}/v2/verification-session/${sessionToken}/document/${documentType}
// `,
// requestOptions,
// )
// ).json();
// return result;
// };
// export enum documentImageTypeEnum {
// FRONT = 'front',
// BACK = 'back',
// FRONT_CROPPED_DOCUMENT = 'front_cropped_document',
// BACK_CROPPED_DOCUMENT = 'back_cropped_document',
// FRONT_MUGSHOT = 'front_mugshot',
// BACK_BARCODE = 'back_barcode',
// }
// export type uploadDocumentImageWithSessionProps = {
// sessionToken: string;
// documentId: string;
// documentImageType: documentImageTypeEnum;
// imageString: string;
// };
// export const uploadDocumentImageWithSession = async ({
// sessionToken,
// documentId,
// documentImageType,
// imageString,
// }: uploadDocumentImageWithSessionProps) => {
// const payload = { type: documentImageType, data: imageString };
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify(payload),
// headers: {
// 'Content-Type': 'application/json',
// x_api_key: apiKey,
// },
// };
// const result = await (
// await fetch(
// `${orchestrationAPIUrl}/v2/verification-session/${sessionToken}/${documentId}/img
// `,
// requestOptions,
// )
// ).json();
// return result;
// };
// interface updateDocumentContentInterface {
// sessionToken: string;
// documentId: string;
// content: any;
// }
// export const updateDocumentContent = async ({ sessionToken, documentId, content }: updateDocumentContentInterface) => {
// const payload = { content };
// const requestOptions: RequestInit = {
// method: 'PUT',
// body: JSON.stringify(payload),
// headers: {
// 'Content-Type': 'application/json',
// x_api_key: apiKey,
// },
// };
// const result = await (
// await fetch(`${orchestrationAPIUrl}/v2/verification-session/${sessionToken}/document/${documentId}`, requestOptions)
// ).json();
// return result;
// };
// export type uploadEnrollImageWithSessionProps = {
// sessionToken: string;
// imageString: string;
// };
// export const uploadEnrollImageWithSession = async ({
// sessionToken,
// imageString,
// }: uploadEnrollImageWithSessionProps) => {
// const payload = { data: imageString };
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify(payload),
// headers: {
// 'Content-Type': 'application/json',
// x_api_key: apiKey,
// },
// };
// const result = await (
// await fetch(`${orchestrationAPIUrl}/v2/verification-session/${sessionToken}/img`, requestOptions)
// ).json();
// return result;
// };
// export enum updateTypeEnum {
// enroll = 'enroll',
// compare = 'compare',
// personalDetails = 'personalDetails',
// }
// export type updateUserWithSessionProps = {
// sessionToken: string;
// guid?: string;
// uuid?: string;
// ssn?: string;
// email?: string;
// phone?: string;
// portrait_conf_score?: string;
// updateType: updateTypeEnum;
// };
// export const updateUserWithSession = async ({
// sessionToken,
// guid,
// uuid,
// email,
// phone,
// ssn,
// portrait_conf_score,
// updateType,
// }: updateUserWithSessionProps) => {
// let payload;
// if (updateType === updateTypeEnum.enroll) {
// payload = {
// guid,
// uuid,
// };
// } else if (updateType === updateTypeEnum.compare) {
// payload = {
// portrait_conf_score,
// };
// } else if (updateType === updateTypeEnum.personalDetails) {
// payload = {
// email,
// phone,
// ssn,
// };
// } else {
// return;
// }
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify(payload),
// headers: {
// 'Content-Type': 'application/json',
// x_api_key: apiKey,
// },
// };
// const result = await (
// await fetch(`${orchestrationAPIUrl}/v2/verification-session/${sessionToken}/user/update`, requestOptions)
// ).json();
// return result;
// };
// export const verifyIdWithSession = async ({ sessionToken }: { sessionToken: string }) => {
// const requestOptions: RequestInit = {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json',
// x_api_key: apiKey,
// },
// };
// const result = await (await fetch(`${orchestrationAPIUrl}/v3/verify-id/${sessionToken}`, requestOptions)).json();
// return result;
// };
// export const verifySessionTokenV2 = async ({ sessionToken }: { sessionToken: string }) => {
// const requestOptions: RequestInit = {
// method: 'GET',
// headers: {
// 'Content-Type': 'application/json',
// x_api_key: apiKey,
// },
// };
// const result = await (
// await fetch(`${orchestrationAPIUrl}/v2/verification-session/${sessionToken}`, requestOptions)
// ).json();
// return result;
// };
// export const createFederationHash = async ({ sesstionToken }: { sesstionToken: string }) => {
// const requestOptions: RequestInit = {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json',
// x_api_key: apiKey,
// },
// };
// const result = await (
// await fetch(`${orchestrationAPIUrl}/v2/verification-session/${sesstionToken}/federation-hash`, requestOptions)
// ).json();
// return result;
// };
// export const deletePasskey = async (uuid: any) => {
// try {
// const response = await fetch(`${orchestrationAPIUrl}/v2/passkey/delete-authentication`, {
// method: 'DELETE',
// headers: {
// 'Content-Type': 'application/json',
// x_api_key: apiKey,
// },
// // credentials: 'include',
// body: JSON.stringify({ uuid }),
// });
// const result = await response.json();
// return result;
// } catch (error) {
// return error;
// }
// };
// // Auth with session API
// interface createAuthSessionInterface {
// requiredAAL: number;
// productGroupId: string;
// actionFlow: string;
// requiredIAL: number;
// requiredFAL: number;
// interactionUID?: string;
// }
// export const createAuthSession = async ({
// requiredAAL,
// productGroupId,
// requiredFAL,
// requiredIAL,
// actionFlow,
// interactionUID,
// }: createAuthSessionInterface) => {
// const payload = { requiredAAL, productGroupId, requiredFAL, requiredIAL, interactionUID, actionFlow };
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify(payload),
// headers: {
// 'Content-Type': 'application/json',
// x_api_key: apiKey,
// },
// };
// const result = await (await fetch(`${orchestrationAPIUrl}/v2/auth-session`, requestOptions)).json();
// return result;
// };
// export const generateAuthPasskeyOptions = async ({ uuid, sessionToken }: { uuid: string; sessionToken: string }) => {
// const payload = { uuid };
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify(payload),
// headers: {
// 'Content-Type': 'application/json',
// x_api_key: apiKey,
// },
// };
// const result = await (
// await fetch(
// `${orchestrationAPIUrl}/v2/auth/${sessionToken}/passkey/generate-authentication-options`,
// requestOptions,
// )
// ).json();
// return result;
// };
// export const verifyAuthPasskey = async ({
// uuid,
// sessionToken,
// data, // Generate passkey options
// }: {
// uuid: string;
// sessionToken: string;
// data: any;
// }) => {
// const payload = { uuid, data };
// const requestOptions: RequestInit = {
// method: 'POST',
// body: JSON.stringify(payload),
// headers: {
// 'Content-Type': 'application/json',
// x_api_key: apiKey,
// },
// };
// const result = await (
// await fetch(`${orchestrationAPIUrl}/v2/auth-session/${sessionToken}/passkey/verify-authentication`, requestOptions)
// ).json();
// return result;
// };
export const createDocumentDL = ({ baseUrl, token }) => __awaiter(void 0, void 0, void 0, function* () {
const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
};
const result = yield (yield fetch(`${baseUrl}/${token}/document/drivers_license`, requestOptions)).json();
return result;
});
export const updateDocumentDetails = ({ baseUrl, token, documentId, params, }) => __awaiter(void 0, void 0, void 0, function* () {
const requestOptions = {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params),
};
const result = yield (yield fetch(`${baseUrl}/v2/verification-session/${token}/document/${documentId}`, requestOptions)).json();
return result;
});
export var documentImageTypeEnum;
(function (documentImageTypeEnum) {
documentImageTypeEnum["FRONTDLORIGINAL"] = "front";
documentImageTypeEnum["FRONTDLHEADSHOT"] = "front_mugshot";
documentImageTypeEnum["FRONTDLCROPPED"] = "front_cropped_document";
documentImageTypeEnum["BACKDLORIGINAL"] = "back";
documentImageTypeEnum["BACKDLCROPPED"] = "back_cropped_document";
documentImageTypeEnum["BACKDLBARCODE"] = "back_barcode";
})(documentImageTypeEnum || (documentImageTypeEnum = {}));
export const uploadDocumentImage = ({ baseUrl, token, documentId, params, }) => __awaiter(void 0, void 0, void 0, function* () {
const pngBase64 = params.data;
const jpegBase64 = yield convertPngBase64ToJpegBase64(pngBase64);
const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(Object.assign(Object.assign({}, params), { data: jpegBase64 })),
};
const result = yield (yield fetch(`${baseUrl}/v2/verification-session/${token}/${documentId}/img`, requestOptions)).json();
return result;
});
// Update User Details
export const updateUserDetails = ({ baseUrl, token, params, }) => __awaiter(void 0, void 0, void 0, function* () {
const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(params),
};
const result = yield (yield fetch(`${baseUrl}/v2/verification-session/${token}/user/update`, requestOptions)).json();
return result;
});
//# sourceMappingURL=apiUtils.js.map