Socket
Socket
Sign inDemoInstall

@fiatconnect/fiatconnect-types

Package Overview
Dependencies
1
Maintainers
6
Versions
59
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 11.0.2 to 11.1.0

1

dist/common.d.ts

@@ -72,1 +72,2 @@ import { z } from 'zod';

export declare const cryptoTypeSchema: z.ZodNativeEnum<typeof CryptoType>;
export declare const EMAIL_REGEX: RegExp;

5

dist/common.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.cryptoTypeSchema = exports.CryptoType = exports.fiatTypeSchema = exports.FiatType = exports.networkSchema = exports.Network = exports.fiatConnectErrorSchema = exports.FiatConnectError = void 0;
exports.EMAIL_REGEX = exports.cryptoTypeSchema = exports.CryptoType = exports.fiatTypeSchema = exports.FiatType = exports.networkSchema = exports.Network = exports.fiatConnectErrorSchema = exports.FiatConnectError = void 0;
const zod_1 = require("zod");

@@ -96,2 +96,5 @@ // Errors returned by FiatConnect endpoints

});
exports.EMAIL_REGEX =
/* eslint-disable-next-line no-useless-escape */ // For some reason, eslint thinks the escaped \[ and /] are useless. they are indeed useful.
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; // credit to http://emailregex.com/
//# sourceMappingURL=common.js.map

@@ -24,3 +24,2 @@ import { z } from 'zod';

export declare const pixKeyTypeEnumSchema: z.ZodNativeEnum<typeof PIXKeyTypeEnum>;
export declare const PIX_EMAIL_KEY_REGEX: RegExp;
export declare const PIX_CPF_KEY_REGEX: RegExp;

@@ -27,0 +26,0 @@ export declare const PIX_PHONE_KEY_REGEX: RegExp;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.postFiatAccountResponseSchema = exports.getFiatAccountsResponseSchema = exports.deleteFiatAccountRequestParamsSchema = exports.postFiatAccountRequestBodySchema = exports.obfuscatedFiatAccountDataSchema = exports.fiatAccountIdSchema = exports.fiatAccountSchemasSchema = exports.iFSCAccountSchema = exports.iBANNumberSchema = exports.mobileMoneySchema = exports.duniaWalletSchema = exports.accountNumberSchema = exports.pixAccountSchema = exports.PIX_RANDOM_KEY_REGEX = exports.PIX_PHONE_KEY_REGEX = exports.PIX_CPF_KEY_REGEX = exports.PIX_EMAIL_KEY_REGEX = exports.pixKeyTypeEnumSchema = exports.PIXKeyTypeEnum = exports.fiatAccountTypeSchema = exports.FiatAccountType = exports.fiatAccountSchemaSchema = exports.FiatAccountSchema = void 0;
exports.postFiatAccountResponseSchema = exports.getFiatAccountsResponseSchema = exports.deleteFiatAccountRequestParamsSchema = exports.postFiatAccountRequestBodySchema = exports.obfuscatedFiatAccountDataSchema = exports.fiatAccountIdSchema = exports.fiatAccountSchemasSchema = exports.iFSCAccountSchema = exports.iBANNumberSchema = exports.mobileMoneySchema = exports.duniaWalletSchema = exports.accountNumberSchema = exports.pixAccountSchema = exports.PIX_RANDOM_KEY_REGEX = exports.PIX_PHONE_KEY_REGEX = exports.PIX_CPF_KEY_REGEX = exports.pixKeyTypeEnumSchema = exports.PIXKeyTypeEnum = exports.fiatAccountTypeSchema = exports.FiatAccountType = exports.fiatAccountSchemaSchema = exports.FiatAccountSchema = void 0;
const zod_1 = require("zod");
const common_1 = require("./common");
/*

@@ -50,5 +51,2 @@ * FiatConnect dynamic type definitions.

});
exports.PIX_EMAIL_KEY_REGEX =
/* eslint-disable-next-line no-useless-escape */ // For some reason, eslint thinks the escaped \[ and /] are useless. they are indeed useful.
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; // credit to http://emailregex.com/
exports.PIX_CPF_KEY_REGEX = /^([0-9]{3}\.){2}[0-9]{3}[-]([0-9]{2})$/; // example: 000.000.000-00, see https://en.wikipedia.org/wiki/CPF_number

@@ -64,3 +62,3 @@ exports.PIX_PHONE_KEY_REGEX = /^[0-9]{11}$/;

keyType: zod_1.z.literal(PIXKeyTypeEnum.EMAIL),
key: zod_1.z.string().regex(exports.PIX_EMAIL_KEY_REGEX),
key: zod_1.z.string().regex(common_1.EMAIL_REGEX),
})

@@ -67,0 +65,0 @@ .or(zod_1.z.object({

@@ -11,5 +11,12 @@ import { z } from 'zod';

export declare enum KycSchema {
PersonalDataAndDocuments = "PersonalDataAndDocuments"
PersonalDataAndDocuments = "PersonalDataAndDocuments",
PersonalDataAndDocumentsDetailed = "PersonalDataAndDocumentsDetailed"
}
export declare const kycSchemaSchema: z.ZodNativeEnum<typeof KycSchema>;
export declare enum IdentificationDocumentType {
IDC = "IDC",
PAS = "PAS",
DL = "DL"
}
export declare const identificationDocumentTypeSchema: z.ZodUnion<[z.ZodEnum<[IdentificationDocumentType, ...IdentificationDocumentType[]]>, z.ZodEnum<[IdentificationDocumentType, ...IdentificationDocumentType[]]>]>;
export declare const personalDataAndDocumentsKycSchema: z.ZodObject<{

@@ -99,2 +106,108 @@ firstName: z.ZodString;

export type PersonalDataAndDocumentsKyc = z.infer<typeof personalDataAndDocumentsKycSchema>;
export declare const personalDataAndDocumentsDetailedKycSchema: z.ZodIntersection<z.ZodIntersection<z.ZodObject<Omit<{
firstName: z.ZodString;
middleName: z.ZodOptional<z.ZodString>;
lastName: z.ZodString;
dateOfBirth: z.ZodObject<{
day: z.ZodString;
month: z.ZodString;
year: z.ZodString;
}, "strip", z.ZodTypeAny, {
day: string;
month: string;
year: string;
}, {
day: string;
month: string;
year: string;
}>;
address: z.ZodObject<{
address1: z.ZodString;
address2: z.ZodOptional<z.ZodString>;
isoCountryCode: z.ZodString;
isoRegionCode: z.ZodString;
city: z.ZodString;
postalCode: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
address2?: string | undefined;
postalCode?: string | undefined;
address1: string;
isoCountryCode: string;
isoRegionCode: string;
city: string;
}, {
address2?: string | undefined;
postalCode?: string | undefined;
address1: string;
isoCountryCode: string;
isoRegionCode: string;
city: string;
}>;
phoneNumber: z.ZodString;
selfieDocument: z.ZodString;
identificationDocument: z.ZodString;
}, "identificationDocument">, "strip", z.ZodTypeAny, {
middleName?: string | undefined;
firstName: string;
lastName: string;
dateOfBirth: {
day: string;
month: string;
year: string;
};
address: {
address2?: string | undefined;
postalCode?: string | undefined;
address1: string;
isoCountryCode: string;
isoRegionCode: string;
city: string;
};
phoneNumber: string;
selfieDocument: string;
}, {
middleName?: string | undefined;
firstName: string;
lastName: string;
dateOfBirth: {
day: string;
month: string;
year: string;
};
address: {
address2?: string | undefined;
postalCode?: string | undefined;
address1: string;
isoCountryCode: string;
isoRegionCode: string;
city: string;
};
phoneNumber: string;
selfieDocument: string;
}>, z.ZodObject<{
email: z.ZodString;
identificationDocumentFront: z.ZodString;
}, "strip", z.ZodTypeAny, {
email: string;
identificationDocumentFront: string;
}, {
email: string;
identificationDocumentFront: string;
}>>, z.ZodUnion<[z.ZodObject<{
identificationDocumentType: z.ZodEnum<[IdentificationDocumentType, ...IdentificationDocumentType[]]>;
identificationDocumentBack: z.ZodString;
}, "strip", z.ZodTypeAny, {
identificationDocumentType: IdentificationDocumentType;
identificationDocumentBack: string;
}, {
identificationDocumentType: IdentificationDocumentType;
identificationDocumentBack: string;
}>, z.ZodObject<{
identificationDocumentType: z.ZodEnum<[IdentificationDocumentType, ...IdentificationDocumentType[]]>;
}, "strip", z.ZodTypeAny, {
identificationDocumentType: IdentificationDocumentType;
}, {
identificationDocumentType: IdentificationDocumentType;
}>]>>;
export type PersonalDataAndDocumentsDetailedKyc = z.infer<typeof personalDataAndDocumentsDetailedKycSchema>;
export declare const kycSchemasSchema: z.ZodObject<{

@@ -184,2 +297,107 @@ PersonalDataAndDocuments: z.ZodObject<{

}>;
PersonalDataAndDocumentsDetailed: z.ZodIntersection<z.ZodIntersection<z.ZodObject<Omit<{
firstName: z.ZodString;
middleName: z.ZodOptional<z.ZodString>;
lastName: z.ZodString;
dateOfBirth: z.ZodObject<{
day: z.ZodString;
month: z.ZodString;
year: z.ZodString;
}, "strip", z.ZodTypeAny, {
day: string;
month: string;
year: string;
}, {
day: string;
month: string;
year: string;
}>;
address: z.ZodObject<{
address1: z.ZodString;
address2: z.ZodOptional<z.ZodString>;
isoCountryCode: z.ZodString;
isoRegionCode: z.ZodString;
city: z.ZodString;
postalCode: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
address2?: string | undefined;
postalCode?: string | undefined;
address1: string;
isoCountryCode: string;
isoRegionCode: string;
city: string;
}, {
address2?: string | undefined;
postalCode?: string | undefined;
address1: string;
isoCountryCode: string;
isoRegionCode: string;
city: string;
}>;
phoneNumber: z.ZodString;
selfieDocument: z.ZodString;
identificationDocument: z.ZodString;
}, "identificationDocument">, "strip", z.ZodTypeAny, {
middleName?: string | undefined;
firstName: string;
lastName: string;
dateOfBirth: {
day: string;
month: string;
year: string;
};
address: {
address2?: string | undefined;
postalCode?: string | undefined;
address1: string;
isoCountryCode: string;
isoRegionCode: string;
city: string;
};
phoneNumber: string;
selfieDocument: string;
}, {
middleName?: string | undefined;
firstName: string;
lastName: string;
dateOfBirth: {
day: string;
month: string;
year: string;
};
address: {
address2?: string | undefined;
postalCode?: string | undefined;
address1: string;
isoCountryCode: string;
isoRegionCode: string;
city: string;
};
phoneNumber: string;
selfieDocument: string;
}>, z.ZodObject<{
email: z.ZodString;
identificationDocumentFront: z.ZodString;
}, "strip", z.ZodTypeAny, {
email: string;
identificationDocumentFront: string;
}, {
email: string;
identificationDocumentFront: string;
}>>, z.ZodUnion<[z.ZodObject<{
identificationDocumentType: z.ZodEnum<[IdentificationDocumentType, ...IdentificationDocumentType[]]>;
identificationDocumentBack: z.ZodString;
}, "strip", z.ZodTypeAny, {
identificationDocumentType: IdentificationDocumentType;
identificationDocumentBack: string;
}, {
identificationDocumentType: IdentificationDocumentType;
identificationDocumentBack: string;
}>, z.ZodObject<{
identificationDocumentType: z.ZodEnum<[IdentificationDocumentType, ...IdentificationDocumentType[]]>;
}, "strip", z.ZodTypeAny, {
identificationDocumentType: IdentificationDocumentType;
}, {
identificationDocumentType: IdentificationDocumentType;
}>]>>;
}, "strip", z.ZodTypeAny, {

@@ -207,2 +425,30 @@ PersonalDataAndDocuments: {

};
PersonalDataAndDocumentsDetailed: {
middleName?: string | undefined;
firstName: string;
lastName: string;
dateOfBirth: {
day: string;
month: string;
year: string;
};
address: {
address2?: string | undefined;
postalCode?: string | undefined;
address1: string;
isoCountryCode: string;
isoRegionCode: string;
city: string;
};
phoneNumber: string;
selfieDocument: string;
} & {
email: string;
identificationDocumentFront: string;
} & ({
identificationDocumentType: IdentificationDocumentType;
identificationDocumentBack: string;
} | {
identificationDocumentType: IdentificationDocumentType;
});
}, {

@@ -230,2 +476,30 @@ PersonalDataAndDocuments: {

};
PersonalDataAndDocumentsDetailed: {
middleName?: string | undefined;
firstName: string;
lastName: string;
dateOfBirth: {
day: string;
month: string;
year: string;
};
address: {
address2?: string | undefined;
postalCode?: string | undefined;
address1: string;
isoCountryCode: string;
isoRegionCode: string;
city: string;
};
phoneNumber: string;
selfieDocument: string;
} & {
email: string;
identificationDocumentFront: string;
} & ({
identificationDocumentType: IdentificationDocumentType;
identificationDocumentBack: string;
} | {
identificationDocumentType: IdentificationDocumentType;
});
}>;

@@ -236,5 +510,5 @@ export type KycSchemas = z.infer<typeof kycSchemasSchema>;

}, "strip", z.ZodTypeAny, {
kycSchema: KycSchema.PersonalDataAndDocuments;
kycSchema: KycSchema;
}, {
kycSchema: KycSchema.PersonalDataAndDocuments;
kycSchema: KycSchema;
}>;

@@ -241,0 +515,0 @@ export type KycRequestParams = z.infer<typeof kycRequestParamsSchema>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.kycStatusResponseSchema = exports.kycRequestParamsSchema = exports.kycSchemasSchema = exports.personalDataAndDocumentsKycSchema = exports.kycSchemaSchema = exports.KycSchema = exports.kycStatusSchema = exports.KycStatus = void 0;
exports.kycStatusResponseSchema = exports.kycRequestParamsSchema = exports.kycSchemasSchema = exports.personalDataAndDocumentsDetailedKycSchema = exports.personalDataAndDocumentsKycSchema = exports.identificationDocumentTypeSchema = exports.IdentificationDocumentType = exports.kycSchemaSchema = exports.KycSchema = exports.kycStatusSchema = exports.KycStatus = void 0;
const zod_1 = require("zod");
const common_1 = require("./common");
var KycStatus;

@@ -28,2 +29,3 @@ (function (KycStatus) {

KycSchema["PersonalDataAndDocuments"] = "PersonalDataAndDocuments";
KycSchema["PersonalDataAndDocumentsDetailed"] = "PersonalDataAndDocumentsDetailed";
})(KycSchema = exports.KycSchema || (exports.KycSchema = {}));

@@ -33,2 +35,14 @@ exports.kycSchemaSchema = zod_1.z.nativeEnum(KycSchema, {

});
var IdentificationDocumentType;
(function (IdentificationDocumentType) {
IdentificationDocumentType["IDC"] = "IDC";
IdentificationDocumentType["PAS"] = "PAS";
IdentificationDocumentType["DL"] = "DL";
})(IdentificationDocumentType = exports.IdentificationDocumentType || (exports.IdentificationDocumentType = {}));
// need nonempty array types to get zod enums to compile
const documentsWithBack = [IdentificationDocumentType.IDC, IdentificationDocumentType.DL];
const documentsWithoutBack = Object.keys(IdentificationDocumentType).filter((idType) => !documentsWithBack.includes(idType));
const identificationDocumentTypeWithBackSchema = zod_1.z.enum(documentsWithBack);
const identificationDocumentTypeWithoutBackSchema = zod_1.z.enum(documentsWithoutBack);
exports.identificationDocumentTypeSchema = identificationDocumentTypeWithBackSchema.or(identificationDocumentTypeWithoutBackSchema);
exports.personalDataAndDocumentsKycSchema = zod_1.z.object({

@@ -55,4 +69,19 @@ firstName: zod_1.z.string(),

}, { description: 'personalDataAndDocumentsKycSchema' });
exports.personalDataAndDocumentsDetailedKycSchema = exports.personalDataAndDocumentsKycSchema
.omit({ identificationDocument: true })
.and(zod_1.z.object({
email: zod_1.z.string().regex(common_1.EMAIL_REGEX),
identificationDocumentFront: zod_1.z.string(),
}))
.and(zod_1.z
.object({
identificationDocumentType: identificationDocumentTypeWithBackSchema,
identificationDocumentBack: zod_1.z.string(),
})
.or(zod_1.z.object({
identificationDocumentType: identificationDocumentTypeWithoutBackSchema,
})));
exports.kycSchemasSchema = zod_1.z.object({
[exports.kycSchemaSchema.enum.PersonalDataAndDocuments]: exports.personalDataAndDocumentsKycSchema,
[exports.kycSchemaSchema.enum.PersonalDataAndDocumentsDetailed]: exports.personalDataAndDocumentsDetailedKycSchema,
}, { description: 'kycSchemasSchema' });

@@ -59,0 +88,0 @@ /*

@@ -65,6 +65,6 @@ import { z } from 'zod';

}, "strip", z.ZodTypeAny, {
kycSchema: import("./kyc").KycSchema.PersonalDataAndDocuments;
kycSchema: import("./kyc").KycSchema;
allowedValues: Record<string, [string, ...string[]]>;
}, {
kycSchema: import("./kyc").KycSchema.PersonalDataAndDocuments;
kycSchema: import("./kyc").KycSchema;
allowedValues: Record<string, [string, ...string[]]>;

@@ -157,6 +157,6 @@ }>;

}, "strip", z.ZodTypeAny, {
kycSchema: import("./kyc").KycSchema.PersonalDataAndDocuments;
kycSchema: import("./kyc").KycSchema;
allowedValues: Record<string, [string, ...string[]]>;
}, {
kycSchema: import("./kyc").KycSchema.PersonalDataAndDocuments;
kycSchema: import("./kyc").KycSchema;
allowedValues: Record<string, [string, ...string[]]>;

@@ -167,3 +167,3 @@ }>, "many">;

kycSchemas: {
kycSchema: import("./kyc").KycSchema.PersonalDataAndDocuments;
kycSchema: import("./kyc").KycSchema;
allowedValues: Record<string, [string, ...string[]]>;

@@ -174,3 +174,3 @@ }[];

kycSchemas: {
kycSchema: import("./kyc").KycSchema.PersonalDataAndDocuments;
kycSchema: import("./kyc").KycSchema;
allowedValues: Record<string, [string, ...string[]]>;

@@ -224,3 +224,3 @@ }[];

kycSchemas: {
kycSchema: import("./kyc").KycSchema.PersonalDataAndDocuments;
kycSchema: import("./kyc").KycSchema;
allowedValues: Record<string, [string, ...string[]]>;

@@ -254,3 +254,3 @@ }[];

kycSchemas: {
kycSchema: import("./kyc").KycSchema.PersonalDataAndDocuments;
kycSchema: import("./kyc").KycSchema;
allowedValues: Record<string, [string, ...string[]]>;

@@ -307,6 +307,6 @@ }[];

}, "strip", z.ZodTypeAny, {
kycSchema: import("./kyc").KycSchema.PersonalDataAndDocuments;
kycSchema: import("./kyc").KycSchema;
allowedValues: Record<string, [string, ...string[]]>;
}, {
kycSchema: import("./kyc").KycSchema.PersonalDataAndDocuments;
kycSchema: import("./kyc").KycSchema;
allowedValues: Record<string, [string, ...string[]]>;

@@ -317,3 +317,3 @@ }>, "many">;

kycSchemas: {
kycSchema: import("./kyc").KycSchema.PersonalDataAndDocuments;
kycSchema: import("./kyc").KycSchema;
allowedValues: Record<string, [string, ...string[]]>;

@@ -324,3 +324,3 @@ }[];

kycSchemas: {
kycSchema: import("./kyc").KycSchema.PersonalDataAndDocuments;
kycSchema: import("./kyc").KycSchema;
allowedValues: Record<string, [string, ...string[]]>;

@@ -372,3 +372,3 @@ }[];

kycSchemas: {
kycSchema: import("./kyc").KycSchema.PersonalDataAndDocuments;
kycSchema: import("./kyc").KycSchema;
allowedValues: Record<string, [string, ...string[]]>;

@@ -400,3 +400,3 @@ }[];

kycSchemas: {
kycSchema: import("./kyc").KycSchema.PersonalDataAndDocuments;
kycSchema: import("./kyc").KycSchema;
allowedValues: Record<string, [string, ...string[]]>;

@@ -403,0 +403,0 @@ }[];

@@ -191,6 +191,6 @@ import { z } from 'zod';

}, "strip", z.ZodTypeAny, {
kycSchema: import("./kyc").KycSchema.PersonalDataAndDocuments;
kycSchema: import("./kyc").KycSchema;
kycStatus: import("./kyc").KycStatus;
}, {
kycSchema: import("./kyc").KycSchema.PersonalDataAndDocuments;
kycSchema: import("./kyc").KycSchema;
kycStatus: import("./kyc").KycStatus;

@@ -201,3 +201,3 @@ }>;

payload: {
kycSchema: import("./kyc").KycSchema.PersonalDataAndDocuments;
kycSchema: import("./kyc").KycSchema;
kycStatus: import("./kyc").KycStatus;

@@ -208,3 +208,3 @@ };

payload: {
kycSchema: import("./kyc").KycSchema.PersonalDataAndDocuments;
kycSchema: import("./kyc").KycSchema;
kycStatus: import("./kyc").KycStatus;

@@ -393,6 +393,6 @@ };

}, "strip", z.ZodTypeAny, {
kycSchema: import("./kyc").KycSchema.PersonalDataAndDocuments;
kycSchema: import("./kyc").KycSchema;
kycStatus: import("./kyc").KycStatus;
}, {
kycSchema: import("./kyc").KycSchema.PersonalDataAndDocuments;
kycSchema: import("./kyc").KycSchema;
kycStatus: import("./kyc").KycStatus;

@@ -403,3 +403,3 @@ }>;

payload: {
kycSchema: import("./kyc").KycSchema.PersonalDataAndDocuments;
kycSchema: import("./kyc").KycSchema;
kycStatus: import("./kyc").KycStatus;

@@ -410,3 +410,3 @@ };

payload: {
kycSchema: import("./kyc").KycSchema.PersonalDataAndDocuments;
kycSchema: import("./kyc").KycSchema;
kycStatus: import("./kyc").KycStatus;

@@ -413,0 +413,0 @@ };

{
"name": "@fiatconnect/fiatconnect-types",
"version": "11.0.2",
"version": "11.1.0",
"description": "Types used in the FiatConnect specification. Offered as standalone module for payment providers and wallets to both use for FiatConnect APIs and integrations.",

@@ -30,14 +30,14 @@ "scripts": {

"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.48.1",
"@typescript-eslint/eslint-plugin": "^5.49.0",
"@valora/eslint-config-typescript": "^1.0.1",
"@valora/prettier-config": "^0.0.1",
"conventional-changelog-conventionalcommits": "^5.0.0",
"eslint": "^8.31.0",
"eslint-plugin-import": "^2.27.4",
"eslint": "^8.32.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-react": "^7.32.0",
"eslint-plugin-react": "^7.32.1",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-native": "^4.0.0",
"jest": "^29.3.1",
"prettier": "^2.8.2",
"jest": "^29.4.1",
"prettier": "^2.8.3",
"semantic-release": "^19.0.5",

@@ -44,0 +44,0 @@ "typescript": "^4.9.4"

@@ -94,1 +94,4 @@ import { z } from 'zod'

})
export const EMAIL_REGEX =
/* eslint-disable-next-line no-useless-escape */ // For some reason, eslint thinks the escaped \[ and /] are useless. they are indeed useful.
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ // credit to http://emailregex.com/
import { z } from 'zod'
import { EMAIL_REGEX } from './common'

@@ -50,5 +51,2 @@ /*

export const PIX_EMAIL_KEY_REGEX =
/* eslint-disable-next-line no-useless-escape */ // For some reason, eslint thinks the escaped \[ and /] are useless. they are indeed useful.
/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ // credit to http://emailregex.com/
export const PIX_CPF_KEY_REGEX = /^([0-9]{3}\.){2}[0-9]{3}[-]([0-9]{2})$/ // example: 000.000.000-00, see https://en.wikipedia.org/wiki/CPF_number

@@ -71,3 +69,3 @@ export const PIX_PHONE_KEY_REGEX = /^[0-9]{11}$/

keyType: z.literal(PIXKeyTypeEnum.EMAIL),
key: z.string().regex(PIX_EMAIL_KEY_REGEX),
key: z.string().regex(EMAIL_REGEX),
})

@@ -74,0 +72,0 @@ .or(

import { z } from 'zod'
import { EMAIL_REGEX } from './common'

@@ -10,2 +11,3 @@ export enum KycStatus {

}
export const kycStatusSchema = z.nativeEnum(KycStatus, {

@@ -27,3 +29,5 @@ description: 'kycStatusSchema',

PersonalDataAndDocuments = 'PersonalDataAndDocuments',
PersonalDataAndDocumentsDetailed = 'PersonalDataAndDocumentsDetailed',
}
export const kycSchemaSchema = z.nativeEnum(KycSchema, {

@@ -33,2 +37,33 @@ description: 'kycSchemaSchema',

export enum IdentificationDocumentType {
IDC = 'IDC',
PAS = 'PAS',
DL = 'DL',
}
// need nonempty array types to get zod enums to compile
const documentsWithBack: [
IdentificationDocumentType,
...IdentificationDocumentType[],
] = [IdentificationDocumentType.IDC, IdentificationDocumentType.DL]
const documentsWithoutBack: [
IdentificationDocumentType,
...IdentificationDocumentType[],
] = (
Object.keys(IdentificationDocumentType) as [
IdentificationDocumentType,
...IdentificationDocumentType[],
]
).filter((idType) => !documentsWithBack.includes(idType)) as [
IdentificationDocumentType,
...IdentificationDocumentType[],
]
const identificationDocumentTypeWithBackSchema = z.enum(documentsWithBack)
const identificationDocumentTypeWithoutBackSchema = z.enum(documentsWithoutBack)
export const identificationDocumentTypeSchema =
identificationDocumentTypeWithBackSchema.or(
identificationDocumentTypeWithoutBackSchema,
)
export const personalDataAndDocumentsKycSchema = z.object(

@@ -62,2 +97,29 @@ {

export const personalDataAndDocumentsDetailedKycSchema =
personalDataAndDocumentsKycSchema
.omit({ identificationDocument: true })
.and(
z.object({
email: z.string().regex(EMAIL_REGEX),
identificationDocumentFront: z.string(),
}),
)
.and(
z
.object({
identificationDocumentType: identificationDocumentTypeWithBackSchema,
identificationDocumentBack: z.string(),
})
.or(
z.object({
identificationDocumentType:
identificationDocumentTypeWithoutBackSchema,
}),
),
)
export type PersonalDataAndDocumentsDetailedKyc = z.infer<
typeof personalDataAndDocumentsDetailedKycSchema
>
export const kycSchemasSchema = z.object(

@@ -67,2 +129,4 @@ {

personalDataAndDocumentsKycSchema,
[kycSchemaSchema.enum.PersonalDataAndDocumentsDetailed]:
personalDataAndDocumentsDetailedKycSchema,
},

@@ -69,0 +133,0 @@ { description: 'kycSchemasSchema' },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc