UNPKG

@bit-ui-libs/common

Version:
1,911 lines (1,841 loc) 149 kB
import { AxiosError, AxiosInstance, AxiosRequestConfig, AxiosRequestHeaders, AxiosProgressEvent } from 'axios'; interface ApiResponse<TData = object> { status: boolean; data: TData; message?: string; } interface BaseError { message: string; error?: string; statusCode: number; } type ApiServiceError = AxiosError<BaseError, unknown>; interface PaginatedResponse<TData = object> { data: TData; meta: { currentPage: number; itemsPerPage: number; totalItems: number; totalPages: number; }; } type BaseServiceOptions = { axiosInstance?: AxiosInstance; apiUrl: string; }; declare class BaseService { private axiosInstance; protected apiUrl: string; protected coreApiServicePrefix: string; protected coreApiUrl: string; constructor(opts: BaseServiceOptions); protected beforeQuery(params?: object): Promise<void>; protected beforeMutation(data: object): Promise<void>; get<TRes, TParams extends object = NonNullable<unknown>>(url: string, params?: TParams, options?: AxiosRequestConfig<TParams>): Promise<TRes>; post<TRes, TVars extends object>(url: string, data: TVars, config?: AxiosRequestConfig<TVars>): Promise<TRes>; put<TRes, TVars extends object>(url: string, data: TVars, config?: AxiosRequestConfig<TVars>): Promise<TRes>; patch<TRes, TVars extends object>(url: string, data: TVars): Promise<TRes>; delete<TRes, TParams extends object = NonNullable<unknown>>(url: string, params?: TParams, config?: AxiosRequestConfig): Promise<TRes>; } interface AppIds { [key: string]: string; } declare const APP_ID: AppIds; declare const DEFAULT_APP_ID: string; declare const DEFAULT_ORG_ID = "00000000-0000-0000-0000-000000000000"; declare const DEVICE_LEVELS: { level: number; label: string; color: string; bgColor: string; }[]; declare const ENCRYPTED_STORAGE_KEYS: { accessToken: string; bitToken: string; refreshToken: string; chainItNftWalletAddress: string; codeVerifier: string; state: string; sessionToken: string; expiresIn: string; idToken: string; hasProfile: string; introPassed: string; deviceId: string; mintPlatform: string; isLoggingDisabled: string; incodeUserId: string; organizationId: string; themeMode: string; shippingDetails: string; authStep: string; authEmails: string; incodeInterviewId: string; incodeToken: string; selfCustodyWalletAddress: string; selfCustodyWalletMnemonic: string; selfCustodyWalletPrivateKey: string; }; declare const BEING_ID_LEVELS: { level: number; label: string; description: string; }[]; declare const HARDWARE_LEVELS: { level: number; label: string; color: string; bgColor: string; }[]; interface ApplicationData { id: string; } interface OldAttachmentData { id: string; mimeType: string; docType: AttachmentDocType; classification: AttachmentClassification; name: string; description: string; } interface AttachmentData { docId: string; mimeType: string; docType: AttachmentDocType; classification: AttachmentClassification; name: string; description: string; url: string; thumbUrl: string; isMain?: boolean; } type AttachmentDocType = 'PHOTO' | 'PDF'; declare enum AttachmentType { TokenDocument = "TOKEN_DOCUMENT", TokenPhoto = "TOKEN_PHOTO", VerificationPhoto = "VERIFICATION_PHOTO", WitnessPhoto = "WITNESS_PHOTO" } declare enum AttachmentClassification { Face = "FACE", GovtId = "GOVTID", FaceAndGovtId = "FACEANDGOVTID", QrCode = "QRCODE", AssetPhoto = "ASSET_PHOTO", AssetVerificationPhoto = "ASSET_VERIFICATION_PHOTO", AssetWitnessPhoto = "ASSET_WITNESS_PHOTO", ServicePhoto = "SERVICE_PHOTO", ServiceVerificationPhoto = "SERVICE_VERIFICATION_PHOTO", ServiceWitnessPhoto = "SERVICE_WITNESS_PHOTO", Other = "OTHER", AssetDocument = "ASSET_DOCUMENT", ServiceDocument = "SERVICE_DOCUMENT" } interface CreateAttachmentInputData { mimeType: string; docType: AttachmentDocType; classification: AttachmentClassification; name: string; description: string; data?: string; isMain?: boolean; } interface CreateQrAttachmentInputData { docType: AttachmentDocType; classification: AttachmentClassification; data: string; name?: string; description?: string; } interface UpdateAttachmentInputData { mimeType?: string; docType?: AttachmentDocType; classification: AttachmentClassification; name?: string; description?: string; docId: string; data?: string; isMain?: boolean; } interface UploadedAttachmentData { mimeType: string; docType: AttachmentDocType; classification: AttachmentClassification; docId: string; name: string; description: string; url?: string; isMain: boolean; } declare enum EAttachmentUploadStatus { New = "NEW", Uploaded = "UPLOADED", Error = "ERROR" } declare enum UserTypeEnum { EndUser = "end-user", Admin = "admin" } declare enum ProfileTypeEnum { Buyer = "buyer", Seller = "seller", Creator = "creator" } declare enum UserRoleEnum { SuperUser = "super_user", AdminUser = "admin_user", SystemUser = "system_user", BusinessUser = "business_user", MarketingUser = "marketing_user", CustomerSupportUser = "cust_support_user", TechSupportUser = "tech_support_user", ProductUser = "product_user", Client = "client", Official = "official", FirstOrgUser = "first_org_user", Member = "member" } declare enum UserRoleIdEnum { Client = 1, Official = 2, FirstOrgUser = 3, Member = 4, Inspector = 5, Buyer = 6, Seller = 6 } declare enum VerifyCredentialTypeEnum { Pin = "PIN", Otp = "OTP", Face = "FACE", Fyc = "FYC" } declare enum SocialMediaSiteTypeEnum { Facebook = "Facebook", Twitter = "Twitter", Instagram = "Instagram", LinkedIn = "LinkedIn", Youtube = "Youtube", Github = "Github", Reddit = "Reddit", Pinterest = "Pinterest", Tumbler = "Tumbler" } declare enum PaymentTypeEnum { BankAccount = "BankAccount", NetBanking = "NetBanking", Card = "Card", Paypal = "Paypal" } declare enum AddressTypeEnum { Home = "Home", Office = "Office", Warehouse = "Warehouse", Company = "Company", Factory = "Factory", Others = "Others" } declare enum DocumentStatusEnum { Pending = "Pending", Verified = "Verified", Rejected = "Rejected" } declare enum SellerTypeEnum { Individual = "Individual", Company = "Company" } declare enum ConsentActionTypesEnum { Privacy = "privacy", Age = "age" } interface BaseAddress { name: string; type: AddressTypeEnum; address: string; city: string; state: string; zip: string; country: string; } interface UserAddress extends BaseAddress { id: string; userId: string; isMain: boolean; isDefault: boolean; phoneNumber?: string; } interface ShippingAddress extends UserAddress { profileId: string; phoneNumber: string; shipInternationally?: boolean; } declare enum BeingLevelEnum { GovWitness = 1, GovRealId = 2, SecGovId = 3, WitnessConfirm = 4, MultiEvents = 5, Human = 6 } interface BeingIdHistory$1 { level: number; timestamp: string; } interface BeingId { userId: string; updatedAt: string; level: number; history: BeingIdHistory$1[]; } interface BitDocument { id: string; profileId: string; typeId: number; userId: string; number: string; status: DocumentStatusEnum; createdAt: string; updatedAt: string; attachments: AttachmentData[]; } declare enum EGovIdType { Unknown = "Unknown", Passport = "Passport", Visa = "Visa", DriverLicense = "Drivers License", IdCard = "Identification Card", Permit = "Permit", Currency = "Currency", ResidenceDoc = "Residence Document", TravelDoc = "Travel Document", BirthCert = "Birth Certificate", VehicleReg = "Vehicle Registration", Other = "Other", WeaponLicense = "Weapon License", TribalId = "Tribal Identification", VoterId = "Voter Identification", Military = "Military", TaxId = "Tax Identification", FederalId = "Federal ID", MedicalCard = "Medical Card" } declare enum EFycCheckStatus { Ok = "OK", Fail = "FAIL", Unknown = "UNKNOWN" } interface FycDocument { userId: string; govIdType: EGovIdType; sessionId: string; govIdName: string; govIdDescription: string; totalScoreStatus: EFycCheckStatus; livenessScoreStatus: EFycCheckStatus; faceRecognitionScoreStatus: EFycCheckStatus; incodeIdValidationScoreStatus: EFycCheckStatus; idOcrValidationScoreStatus: EFycCheckStatus; governmentScoreStatus: EFycCheckStatus; expireAt: string; } interface DocumentTypePhotoRequirement { id: number; name: string; } interface ChainItDocumentType { id: number; name: string; photoRequirements: DocumentTypePhotoRequirement[]; } interface UserOrganization { userId: string; orgId: string; startedAt: string; jobTitle: string; endedAt: string; } interface PaymentTypeInfoData { bankName?: string; accountNumber?: string; routingNumber?: string; nameOnCard?: string; cardNumber?: string; cvv?: string; expiryDate?: string; username?: string; email?: string; } interface PaymentInfo { id: string; userId: string; type: PaymentTypeEnum; data: PaymentTypeInfoData; createdAt: Date; updatedAt: Date; profileId: string; isDefault: boolean; } interface WithAddress { address: AddressService; } type SearchAddressesRequest = PagedRequest<{ userId?: string; name?: string; address?: string; }>; type ListAddressesRequest = FilteredRequest<{ userId?: string; name?: string; address?: string; }>; interface AddAddressRequest { userId: string; type: AddressTypeEnum; name: string; address: string; city: string; state: string; zip: string; country: string; isMain: boolean; } interface EditAddressRequest { userId: string; type: AddressTypeEnum; name: string; address: string; city: string; state: string; zip: string; country: string; isMain: boolean; id: string; } type AddressServiceOptions = BaseServiceOptions & { userType: UserTypeEnum; }; declare class AddressService extends BaseService { protected addressApiUrl: string; constructor(opts: AddressServiceOptions); searchAddresses(req: SearchAddressesRequest): Promise<PagedResponse<UserAddress>>; listAddresses(req: ListAddressesRequest): Promise<UserAddress[]>; addAddress(req: AddAddressRequest): Promise<UserAddress>; getMainAddress(): Promise<UserAddress>; getAddressById(id: string): Promise<UserAddress>; editAddress(id: string, req: EditAddressRequest): Promise<UserAddress>; removeAddress(id: string): Promise<void>; } interface WithPaymentDetails { paymentDetails: PaymentDetailsService; } type ListPaymentDetailsRequest = FilteredRequest<{ userId?: string; paymentDetailId?: string; }>; interface AddPaymentDetailRequest { paymentDetailId?: string; profileId: string; userId?: string; type?: PaymentTypeEnum; data?: PaymentTypeInfoData; isDefault: boolean; } interface EditPaymentDetailRequest { paymentDetailId: string; profileId: string; type: PaymentTypeEnum; data: PaymentTypeInfoData; isDefault: boolean; } type PaymentDetailsServiceOptions = BaseServiceOptions & { profileApiUrl: string; }; declare class PaymentDetailsService extends BaseService { private profileApiUrl; constructor(opts: PaymentDetailsServiceOptions); listPaymentDetails(profileId: string, req: ListPaymentDetailsRequest): Promise<PaymentInfo[]>; addPaymentDetails(profileId: string, req: AddPaymentDetailRequest): Promise<PaymentInfo>; getDefaultPaymentDetails(profileId: string): Promise<PaymentInfo>; getPaymentDetailsById(profileId: string, paymentDetailId: string): Promise<PaymentInfo>; editPaymentDetails(profileId: string, paymentDetailId: string, req: EditPaymentDetailRequest): Promise<PaymentInfo>; removePaymentDetails(profileId: string, paymentDetailId: string): Promise<void>; } type ListProfilesRequest = FilteredRequest<{ userId?: string; appName?: string; }>; interface EditProfileRequest { id: string; isDefault: boolean; } interface AddProfileRequest { userId: string; appName: string; isDefault: boolean; } type AddShippingAddressRequest = AddAddressRequest & { addressId?: string; profileId?: string; phoneNumber: string; shipInternationally: boolean; id?: string; isDefault: boolean; isMain?: boolean; }; type ProfileServiceOptions = BaseServiceOptions & { profileType: ProfileTypeEnum; }; declare class ProfileService<TProfile extends Profile> extends BaseService { protected profileApiUrl: string; constructor(opts: ProfileServiceOptions); listProfiles(req: ListProfilesRequest): Promise<TProfile[]>; getDefaultProfile(): Promise<TProfile>; getProfileById(id: string): Promise<TProfile>; editProfile(id: string, req: EditProfileRequest): Promise<TProfile>; removeProfile(id: string): Promise<void>; addProfile(req: AddProfileRequest): Promise<TProfile>; } interface WithShippingAddress { shippingAddress: ShippingAddressService; } type ListShippingAddressesRequest = FilteredRequest<{ userId?: string; addressId?: string; }>; interface ProfileAddShippingAddressRequest { addressId?: string; profileId?: string; isDefault: boolean; phoneNumber: string; userId?: string; type?: AddressTypeEnum; name?: string; address?: string; city?: string; state?: string; zip?: string; country?: string; isMain?: boolean; shipInternationally: boolean; } interface EditShippingAddressRequest { id?: string; addressId: string; profileId: string; isDefault: boolean; phoneNumber?: string; type: AddressTypeEnum; name: string; address: string; city: string; state: string; zip: string; country: string; isMain: boolean; shipInternationally?: boolean; } type ShippingAddressServiceOptions = BaseServiceOptions & { profileApiUrl: string; }; declare class ShippingAddressService extends BaseService { private profileApiUrl; constructor(opts: ShippingAddressServiceOptions); listShippingAddresses(profileId: string, req: ListShippingAddressesRequest): Promise<ShippingAddress[]>; addShippingAddress(profileId: string, req: ProfileAddShippingAddressRequest): Promise<ShippingAddress>; getDefaultShippingAddress(profileId: string): Promise<ShippingAddress>; getShippingAddressById(profileId: string, addressId: string): Promise<ShippingAddress>; editShippingAddress(profileId: string, addressId: string, req: EditShippingAddressRequest): Promise<ShippingAddress>; removeShippingAddress(profileId: string, addressId: string): Promise<void>; } type EditBuyerProfileRequest = EditProfileRequest; type AddBuyerProfileRequest = AddProfileRequest; declare class BuyerProfileService extends ProfileService<BuyerProfile> implements WithPaymentDetails, WithShippingAddress { paymentDetails: PaymentDetailsService; shippingAddress: ShippingAddressService; constructor(opts: BaseServiceOptions); editProfile(id: string, req: EditBuyerProfileRequest): Promise<BuyerProfile>; addProfile(req: AddBuyerProfileRequest): Promise<BuyerProfile>; getBuyerProfile(): Promise<GetBuyerProfileRes>; getBuyerProfilebyId(buyerId: string): Promise<GetBuyerProfileRes>; getBuyerAddresses(profileId: string): Promise<CreateShippingAddressesRes[]>; getBuyerPaymentDetails(profileId: string): Promise<CreatePaymentRes[]>; createBuyerProfile(payload: CreateBuyerProfilePayload): Promise<GetBuyerProfileRes>; updateBuyerProfile(payload: CreateBuyerProfilePayload): Promise<GetBuyerProfileRes>; addBuyerAddress(payload: AddShippingAddressRequest): Promise<CreateShippingAddressesRes>; addBuyerPaymentDetails(payload: CreatePaymentPayload): Promise<CreatePaymentRes>; updateBuyerAddress(payload: AddShippingAddressRequest): Promise<CreateShippingAddressesRes>; deleteBuyerAddress(payload: { profileId: string; addressId: string; }): Promise<unknown>; updateBuyerPaymentDetails(payload: any): Promise<CreatePaymentRes>; deleteBuyerPaymentDetails(payload: any): Promise<unknown>; } type EditCreatorProfileRequest = EditProfileRequest & Partial<CreatorProfile>; type AddCreatorProfileRequest = AddProfileRequest & Partial<CreatorProfile>; declare class CreatorProfileService extends ProfileService<CreatorProfile> { constructor(opts: BaseServiceOptions); editProfile(id: string, req: EditCreatorProfileRequest): Promise<CreatorProfile>; addProfile(req: AddCreatorProfileRequest): Promise<CreatorProfile>; } type SearchDocumentTypesRequest = PagedRequest<{ name?: string; }>; type ListDocumentTypesRequest = FilteredRequest<{ name?: string; }>; declare class DocumentTypesService extends BaseService { protected dtApiUrl: string; constructor(opts: BaseServiceOptions); searchDocumentTypes(req: SearchDocumentTypesRequest): Promise<PagedResponse<ChainItDocumentType>>; listDocumentTypes(req: ListDocumentTypesRequest): Promise<ChainItDocumentType[]>; } interface WithDocumentsService { documents: DocumentsService; } type ListDocumentsRequest = FilteredRequest<{ docId?: string; userId?: string; typeId?: string; status?: DocumentStatusEnum; }>; interface BitDocumentAttachmentData { name: string; data?: string; url?: string; } interface AddDocumentRequest { docId?: string; profileId: string; userId?: string; typeId?: number; number: string; attachments?: BitDocumentAttachmentData[]; } interface EditDocumentRequest { docId: string; profileId: string; typeId: number; number: string; attachments: BitDocumentAttachmentData[]; } type DocumentsServiceOptions = BaseServiceOptions & { profileApiUrl: string; }; declare class DocumentsService extends BaseService { private profileApiUrl; constructor(opts: DocumentsServiceOptions); listDocuments(profileId: string, req: ListDocumentsRequest): Promise<BitDocument[]>; addDocument(profileId: string, req: AddDocumentRequest): Promise<BitDocument>; getDocumentById(profileId: string, docId: string): Promise<BitDocument>; editDocument(profileId: string, docId: string, req: EditDocumentRequest): Promise<BitDocument>; removeDocument(profileId: string, docId: string): Promise<void>; } declare enum FeedbackEnum { EXCELLENT = "EXCELLENT", GOOD = "GOOD", POOR = "POOR", VERY_POOR = "VERY POOR" } interface AddFeedbackRequest { type: FeedbackEnum; comment: string; } interface Feedback { id: string; userId: string; type: FeedbackEnum; comment: string; createdAt: string; updatedBy: string; updatedAt: string; } declare class FeedbackService extends BaseService { private feedbackApiUrl; constructor(opts: BaseServiceOptions); addFeedback(req: AddFeedbackRequest): Promise<Feedback>; } interface Invite { id: string; type?: { description?: string; }; email: string; appName: string; orgId: string; jobTitle?: string; roleIds: string[]; firstName?: string; lastName?: string; phone?: string; userId?: string; createdAt: string; } interface InvitationTicketClaims { id: string; email: string; iat: number; exp: number; } type SearchRolesRequest = PagedRequest<{ name?: string; }>; interface Role { id: string; name: any; friendlyName: string; description: string; } type RoleServiceOptions = BaseServiceOptions & { userType: UserTypeEnum; }; declare class RoleService extends BaseService { protected rolesApiUrl: string; constructor(opts: RoleServiceOptions); searchRoles(req?: SearchRolesRequest): Promise<PagedResponse<Role>>; } type EditSellerProfileRequest = EditProfileRequest & Partial<SellerProfile>; type AddSellerProfileRequest = AddProfileRequest & Partial<SellerProfile>; declare class SellerProfileService extends ProfileService<SellerProfile> implements WithPaymentDetails, WithShippingAddress, WithDocumentsService { paymentDetails: PaymentDetailsService; shippingAddress: ShippingAddressService; documents: DocumentsService; constructor(opts: BaseServiceOptions); getSellerProfileByUserId(userId: string): Promise<GetSellerProfileRes[]>; getSellerDocuments(profileId: string): Promise<CreateSellerDocumentRes[]>; addSellerDocument(req: CreateSellerDocumentPayload): Promise<CreateSellerDocumentRes>; updateSellerDocument(req: CreateSellerDocumentPayload): Promise<CreateSellerDocumentRes>; getSellerAddress(profileId: string): Promise<ShippingAddress[]>; getSellerDefaultPaymentDetails(profileId: string): Promise<CreatePaymentRes>; editProfile(id: string, req: EditSellerProfileRequest): Promise<SellerProfile>; addProfile(req: AddSellerProfileRequest): Promise<SellerProfile>; deleteSellerAddress(profileId: string, addressId: string): Promise<unknown>; addSellerAddress(req: ProfileAddShippingAddressRequest): Promise<CreateShippingAddressesRes>; editSellerAddress(req: EditShippingAddressRequest): Promise<unknown>; } type SearchUsersRequest = PagedRequest<{ name?: string; username?: string; email?: string; phone?: string; emailVerified?: boolean; phoneVerified?: boolean; appNames?: string[]; organizationIds?: string[]; roleIds?: string[]; includeRoles?: boolean; showSoftDeleted?: boolean; $resolveImages?: boolean; isActive?: boolean; showAllOrgUserType?: boolean; }>; type ListUsersRequest = FilteredRequest<{ name?: string; username?: string; email?: string; phone?: string; emailVerified?: boolean; phoneVerified?: boolean; appNames?: string[]; organizationIds?: string[]; roleIds?: string[]; includeRoles?: boolean; showSoftDeleted?: boolean; $resolveImages?: boolean; }>; interface EditUserRequest { id: string; username?: string; firstName?: string; lastName?: string; middleName?: string; avatarUrl?: string | null; avatar?: string | null; dateOfBirth?: string; phone?: string; } interface GetUserRolesResponse { global: Array<UserRoleEnum>; apps: { [key: string]: any; }; orgs: { [key: string]: any; }; } interface ChangeEmailRequest { email: string; } interface VerifyEmailRequest { ticket: string; } interface VerifyPhoneRequest { code: string; } interface UserRoleDataRequest { userId: string; roleId: number; appName: string; orgId: string; } interface ManageUserRolesRequest { roles: UserRoleDataRequest[]; } interface ChangePhoneRequest { phone: string; } interface VerifyCredentialsRequest { type: VerifyCredentialTypeEnum; faceCredentials: { email: string; photo: string; }; otpCredentials: object; pinCredentials: object; fycCredentials: { userId: string; transactionId: string; token: string; }; } interface VerifyCredentialsResponse { status: boolean; data: { token?: string; }; } interface VerifyCredentialsWitnessRequest { transactionId: string; token: string; } interface VerifyCredentialsWitnessResponse extends VerifyCredentialsResponse { userId: string; } interface SetBeingIdRequest { userId: string; level: number; timestamp: string; } interface RecalculateBeingIdRequest { userId: string; sessionId?: number; forceLevel?: boolean; } interface CompleteFycOnboardingRequest { sessionId: string; userId: string; } type SearchOrgsRequest = PagedRequest<Partial<UserOrganization>>; type SearchOrgsResponse = PagedResponse<UserOrganization>; type ConsentActionRequest = { type: ConsentActionTypesEnum; isAccepted: boolean; biometricsId: string; incodeSession: string; }; interface ConsentActionResponse extends ConsentActionRequest { id: string; } interface ExportListUsersRequest extends ListUsersRequest { reportType: FileTypeEnum; } interface FycDocumentsRequest extends FilterParams { userId?: string; govIdType?: EGovIdType; } type SearchUserDocumentsRequest = PagedRequest<{ userId?: string; typeId?: string; status?: DocumentStatusEnum; }>; interface ListUserDocumentsRequest extends FilterParams { userId?: string; typeId?: string; status?: DocumentStatusEnum; } interface ShareUserDeepLinkRequest extends FilterParams { to?: { email: string; name?: string; }[]; } declare enum InviteTypeEnum { Internal = "INTERNAL", External = "EXTERNAL" } interface ListInvitesRequest extends FilterParams { email?: string; appName?: string; orgId?: string; userIds?: string[]; type?: InviteTypeEnum; } interface ShareableInfo { all: boolean; who: { age: boolean; dateOfBirth: boolean; fullName: boolean; firstName: boolean; middleName: boolean; lastName: boolean; beingIdHistory: true; }; what: any; where: { fullAddress: boolean; city: boolean; state: boolean; country: boolean; addressOnId: true; }; tokens: { currentlyOwned: boolean; associated: boolean; previouslyOwned: true; }; } type IvdtRequestShareableRequest = ShareableInfo; interface IvdtRequestShareableResponse { qrImgUrl: string; token: string; } interface IvdtShareableRequest { token: string; } interface IvdtShareableResponse { who: { age: number; dateOfBirth: string; fullName: string; firstName: string; middleName: string; lastName: string; beingIdHistory: BeingIdHistory$1[]; }; what: any; where: { address: string; city: string; state: string; country: string; addressOnId: string; }; tokens: { currentlyOwned: true; associated: true; previouslyOwned: true; }; } interface SendVerificationCodeRequest { phone: string; } interface VerifyCodeRequest { phone: string; code: string; } interface VerifyCodeResponse { verified: boolean; } type UserServiceOptions = BaseServiceOptions & { userType: UserTypeEnum; }; declare class UserService extends BaseService implements WithAddress { protected usersApiUrl: string; private userType; address: AddressService; constructor(opts: UserServiceOptions); getEndUser(id: string): Promise<EndUser>; searchUsers(req: SearchUsersRequest): Promise<PagedResponse<User>>; listUsers(req: ListUsersRequest): Promise<User[]>; getUser(id: string): Promise<User>; editUser(id: string, req: EditUserRequest): Promise<User>; removeUser(id: string): Promise<void>; getUserRoles(id: string): Promise<GetUserRolesResponse>; changeEmail(id: string, req: ChangeEmailRequest): Promise<void>; requestEmailVerification(id: string): Promise<void>; verifyEmail(id: string, req: VerifyEmailRequest): Promise<void>; changePhone(id: string, req: ChangePhoneRequest): Promise<void>; requestPhoneVerification(id: string): Promise<void>; verifyPhone(id: string, req: VerifyPhoneRequest): Promise<void>; assignRoles(id: string, req: ManageUserRolesRequest): Promise<void>; removeRoles(id: string, req: ManageUserRolesRequest): Promise<void>; requestResetPassword(id: string): Promise<void>; blockUser(id: string): Promise<void>; unblockUser(id: string): Promise<void>; verifyCredentials(req: VerifyCredentialsRequest): Promise<VerifyCredentialsResponse>; verifyCredentialsWitness(req: VerifyCredentialsWitnessRequest): Promise<VerifyCredentialsWitnessResponse>; getBeingId(id: string): Promise<BeingId>; setBeingId(id: string, req: SetBeingIdRequest): Promise<BeingId>; recalculateBeingId(id: string, req: RecalculateBeingIdRequest): Promise<BeingId>; completeFycOnboarding(id: string, req: CompleteFycOnboardingRequest): Promise<void>; getPreviousSessionSelfie(id: string): Promise<string>; searchOrganizations(id: string, req?: SearchOrgsRequest): Promise<SearchOrgsResponse>; getCurrentOrganization(id: string): Promise<UserOrganization>; createConsent(req: ConsentActionRequest): Promise<ConsentActionResponse>; setPrivacy(id: string, isPublic: boolean): Promise<void>; getInviteById(id: string): Promise<Invite>; listInvites(req: ListInvitesRequest): Promise<Invite[]>; exportList(req: ExportListUsersRequest): Promise<Blob>; listFycDocuments(req?: FycDocumentsRequest): Promise<FycDocument[]>; searchDocuments(req: SearchUserDocumentsRequest): Promise<PagedResponse<BitDocument>>; listDocuments(req: ListUserDocumentsRequest): Promise<BitDocument[]>; shareDeepLink(userId: string, req: ShareUserDeepLinkRequest): Promise<void>; ivdtRequestShareableInfo(req: IvdtRequestShareableRequest): Promise<IvdtRequestShareableResponse>; ivdtShareableInfo(req: IvdtShareableRequest): Promise<IvdtShareableResponse>; sendVerificationCode(req: SendVerificationCodeRequest): Promise<void>; verifyCode(req: VerifyCodeRequest): Promise<VerifyCodeResponse>; } interface UserRole { userId: string; roleId: number; appName: string; orgId: string; friendlyName: string; } interface User { firstName: string; lastName: string; id: string; dateOfBirth?: string; address: { addressLine1: string; addressLine2: string; city: string; country: string; state: string; zip: string; }; organization?: string; email: string; phone: string; avatar?: string; avatarUrl?: string; emailVerified: boolean; createdAt: string; updatedAt: string; blocked: boolean; flagged?: boolean; roles?: UserRole[]; beingId?: BeingId; organizations?: EndUserOrganizationResponse[]; isPublic?: boolean; } type EndUserAddress = Omit<BaseAddress, 'id'>; interface EndUser { id: string; orgId?: string | null; email?: string; emailVerified?: boolean; phone?: string; firstName?: string; lastName?: string; middleName?: string; username: string; avatarUrl?: string; jobTitle?: string; phoneVerified?: boolean; mainProfileCompleted?: boolean; address?: EndUserAddress | null; dateOfBirth?: string; blocked?: boolean; blockedUntil?: string | null; blockedReason?: string | null; createdAt?: string; updatedAt?: string | null; beingId?: { history?: { level?: number; timestamp?: string; }[]; level?: number; userId?: string; updatedAt?: string; }; } interface Profile { id: string; userId: string; appName: string; isDefault: boolean; createdAt: string; updateAt?: string; } interface SocialMediaSiteData { type: SocialMediaSiteTypeEnum; value: string; } interface CreatorProfile extends Profile { officialSiteUrl?: string; bio?: string; socialMediaSites: SocialMediaSiteData[]; } interface BuyerProfile extends Profile { } interface SellerProfile extends Profile { type: SellerTypeEnum; taxId: string; } declare enum EAddressType { Billing = "Billing", Home = "Home", Office = "Office", Warehouse = "Warehouse", Company = "Company", Factory = "Factory", Others = "Others" } declare enum EBeingLevel { GovWitness = 1, GovRealId = 2, SecGovId = 3, WitnessConfirm = 4, MultiEvents = 5, Human = 6 } interface SocialMedia { type: string; value: string; } interface DocumentAttachments { name: string; data: string; } interface BeingIdHistory { level: number; timestamp: string; } type ShippingDetails = { id?: string; type: EAddressType; name: string; address: string; phoneNumber: string; city: string; state: string; zip: string; country: string; shipInternationally: boolean; isDefault?: boolean; }; interface GetProfilePayload { userId: string; } type GetEndUserAddressesPayload = { userId?: string; name?: string; address?: string; $ids?: string[]; $order?: string; }; interface SocialMediaSite { type: string; value: string; } interface GetCreatorProfileRes { id: string; userId: string; appName: string; isDefault: boolean; createdAt: string; updateAt?: string; officialSiteUrl?: string; bio?: string; socialMediaSites?: SocialMediaSite[]; } type GetCreatorProfilesListRes = GetCreatorProfileRes[]; interface GetSellerProfileRes { document_ids: string[]; shippingDetails: [ { address: string; city: string; country: string; id: string; name: string; phone_number: string; state: string; type: string; zip: string; } ]; id: string; type: string; userId: string; } type CreateProfileRes = ApiResponse<EndUser>; interface UpdateAvatarInput { image: string; } interface UpdateFaceTemplateInput { template: string; } interface VerifyCredentialsPayload { email?: string; photoBase64?: string; userId?: string; transactionId?: string; token?: string; } interface VerifyCredentialsInput { type: string; faceCredentials?: { email: string; photo: string; }; fycCredentials?: { userId?: string; transactionId?: string; token?: string; }; } type VerifyCredentialsRes = ApiResponse<{ token: string; }>; interface GetDeviceByIdPayload { deviceId: string; } interface GetDeviceByExternalIdPayload { externalId: string; } type RegisterDevicePayload = RegisterDeviceInput; interface RegisterDeviceInput { appName: string; owner: { id: string; isPersonal: boolean; }; externalId: string; name: string; typeId: number; deviceInfo?: { model?: string; os?: string; imei?: string; macAddress?: string; }; locationId?: string; latitude: number; longitude: number; meanSeaLevel: number; platform: string; recipientAddress: string; } interface GetDeviceVdtResponse { platform: string; immutableTime: string; nftTokenId: string; nftMetadataUrl: string; nftSmartContractAddress: string; immutableTransactionHash: string; walletAddress: string; deviceId: string; } interface CreatorProfilePayload { id?: string; officialSiteUrl?: string; bio?: string; socialMediaSites?: SocialMedia[]; isDefault: boolean; } interface CreateSellerProfilePayload { type: 'Company' | 'Individual'; userId: string; appName: string; isDefault: boolean; } interface CreateSellerProfileRes { id: string; userId: string; type: 'Company' | 'Individual'; shippingDetails: ShippingDetails[]; document_ids: []; tin: string; paymentDetails: { bankName: string; accountNumber: string; bankIFSCCode: string; }; createdAt: string; updatedAt: string; } interface GetDocumentsTypesRes { items: [ { id: string; name: string; photoRequirements: [ { name: string; } ]; } ]; page: number; perPage: number; totalPages: number; totalCount: number; } interface GetDocumentsRes { attachments: [ { name: string; path: string; url: string; } ]; id: string; number: string; status: string; typeId: string; userId: string; } interface CreateDocumentPayload { userId: string; typeId: number; number: string; attachments: DocumentAttachments[]; } interface CreateDocumentRes { id?: string; userId: string; typeId: string; number: string; attachments: [{ name: string; data: string; url?: string; }]; status?: string; } type CreateAddressesRes = BaseAddress; type UpdateAddressPayload = AddAddressRequest & { id: string; }; type CreateShippingAddressesRes = BaseAddress & { id?: string; userId: string; profileId: string; isDefault: boolean; phoneNumber: string; shipInternationally?: boolean; }; type CreateSellerDocumentPayload = CreateDocumentPayload & { docId?: string; profileId: string; }; type CreateSellerDocumentRes = CreateDocumentRes & { profileId: string; }; type DeleteShippingAddressPayload = { id: string; profileId: string; }; type PaymentDataProps = { bankName?: string; accountNumber?: string; routingNumber?: string; nameOnCard?: string; cardNumber?: string; expiryDate?: string; cvv?: string; username?: string; email?: string; }; type CreatePaymentPayload = { userId?: string; type?: string; isDefault?: boolean; profileId?: string; paymentDetailId?: string; data?: PaymentDataProps; }; type CreatePaymentRes = CreatePaymentPayload & { id?: string; createdAt?: string; updatedAt?: string; }; type GetBuyerProfileRes = { id: string; userId: string; appName: string; isDefault: true; createdAt: string; updateAt: string; }; type CreateBuyerProfilePayload = { userId: string; appName: string; isDefault: boolean; }; interface ValidateDevicePayload { id: string; externalId: string; isPersonal: boolean; } interface GetOrganizationProfileRes { id: string; name: string; description?: string; contacts?: { id: string; name: string; job: string; email: string; phone: string; }[]; logoUrl?: string; isSuper: string; createdAt?: string; updatedAt?: string; } interface GetOrganizationProfileByIdRes { userId: string; orgId: string; startedAt: string; jobTitle: string; endedAt: string; } interface GetUserRolesRes { global?: string[]; apps?: any; } interface UserVdtResponse { platform: string; immutableTime: string; nftTokenId: string; nftMetadataUrl: string; nftSmartContractAddress: string; immutableTransactionHash: string; walletAddress: string; userId: string; } interface UserVdtByQrIdResponse { platform: string; immutableTime: string; nftTokenId: string; nftMetadataUrl: string; nftSmartContractAddress: string; immutableTransactionHash: string; walletAddress: string; userId: string; ipfsMetadata: IpfsMetadata; } interface GetUserBeingIdRes { userId: string; updatedAt: string; level: number; history: BeingIdHistory[]; } interface SetUserBeingIdPayload { userId: string; level: number; } interface RecalculateUserBeingIdPayload { userId: string; sessionId?: number; forceLevel?: boolean; } interface CompleteOnboardingPayload { userId: string; sessionId: string; } interface EndUserOrganizationResponse { userId: string; orgId: string; startedAt: string; jobTitle: string; endedAt: string; } interface GetOrganizationsRes { items: [ { userId: string; orgId: string; startedAt: string; jobTitle: string; endedAt: string; } ]; page: number; perPage: number; totalPages: number; totalCount: number; } interface OrganizationInviteResponse { id: string; type?: { description?: string; }; email: string; appName: string; orgId: string; jobTitle: string; roleIds: string[]; createdAt: string; } interface AuthClaims { aud: string[]; azp: string; exp: number; 'https://blackinktech.io/schemas/claims/email'?: string; 'https://blackinktech.io/schemas/claims/email_verified'?: boolean; 'https://blackinktech.io/schemas/claims/roles'?: string[]; iat: number; iss: string; permissions: string[]; scope: string; sub: string; } interface IIdentityOrganizationPermission { blocked: boolean; roles: UserRoleEnum[]; products: string[]; } interface IIdentityOrganization { [orgId: string]: IIdentityOrganizationPermission; } interface BitAuthClaims { externalId: string; userId: string; userType: string; email: string; emailVerified: boolean; application: string; mainProfileCompleted: boolean; profileCompleted: boolean; biometricsVerified: boolean; roles: { global: UserRoleEnum[]; orgs: IIdentityOrganization; }; iat: number; exp: number; aud: number; iss: number; } declare enum RelationTypeEnum { Official = "CHECKIN_OFFICIAL", Witness = "CHECKIN_WITNESS", Inspector = "CHECKIN_INSPECTOR", Archive = "CHECKIN_ARCHIVE", Buyer = "CHECKIN_BUYER", Seller = "CHECKIN_SELLER", ChildVdt = "CHILD_VDT", ParentVdt = "PARENT_VDT" } interface GeolocationData { latitude: number; longitude: number; meanSeaLevel: number; } declare enum DeviceTypeIdEnum { STATIONARY_KIOSK = 1, MOBILE_KIOSK = 2, TABLET_KIOSK = 3, PHONE = 4, TABLET = 5 } declare enum DeviceTypeEnum { STATIONARY_KIOSK = "STATIONARY_KIOSK", MOBILE_KIOSK = "MOBILE_KIOSK", TABLET_KIOSK = "TABLET_KIOSK", PHONE = "PHONE", TABLET = "TABLET" } type DeviceData = { deviceId: string; deviceName: string; deviceType: DeviceTypeEnum; geolocation: GeolocationData; ipAddress?: string; date: string; hardwareLevel?: number; }; interface EventData { eventType: string; eventId: string; } declare enum StepEnum { DATA = "DATA", PHOTO = "PHOTO", CONFIRM = "CONFIRM", OFFICIAL = "OFFICIAL", QRCODE = "QRCODE", RFID = "RFID", PRIVACY = "PRIVACY", WITNESS = "WITNESS", DOCUMENT = "DOCUMENT", REFERENCE_VDTS = "REFERENCE_VDTS", VDT_MINTED = "VDT_MINTED" } type EventRelationType = 'CHECKIN_OFFICIAL' | 'CHECKIN_WITNESS'; interface BaseRefVdt { bitSysId: string; tokenId: string; ipfsUrl: string; } interface LevelDetail { activeAt: string; level: string | number; } interface UserRefVdt extends BaseRefVdt { beingIdLevel: LevelDetail; } interface DeviceRefVdt extends BaseRefVdt { hardwareLevel: LevelDetail; } declare enum TraitTypeEnum { Type = "Type", TypeWitness = "Type-Witness", Who = "Who", WhoBiometrics = "Who-Biometrics", What = "What", When = "When", Where = "Where", WhereDevice = "Where-Device" } interface VdtAttribute { trait_type: TraitTypeEnum; value: string; } interface IpfsMetadata { ipfs: string; name: string; image: string; qrCode: { image: string; url: string; }; eventId: string; refVdts: { userVdt: UserRefVdt; deviceVdt: DeviceRefVdt; }; vdtType: string; bitSysId: string; attributes: VdtAttribute[]; description: string; beingIdLevel: { current: { activeAt: Date; endedAt?: Date; level: string; }; history: { activeAt: Date; endedAt?: Date; level: string; }[]; }; } type LogLevels = 'debug' | 'info' | 'warn' | 'error'; type LoggerType = { [key in LogLevels]: (...args: unknown[]) => void; }; type PaginationPayload = { page: string; limit: string; }; interface FilterParams { $ids?: string[]; $orderBy?: string; $order?: 'asc' | 'desc'; $resolveImages?: boolean; } interface PaginationParams { $page?: number; $perPage?: number; } type SerializableValue = object | number | number[] | number[][] | string | string[] | boolean | number | undefined; type FilteredRequest<TRequest> = TRequest & FilterParams; type PagedRequest<TRequest> = TRequest & FilterParams & PaginationParams; type PagedResponse<TResponse> = { items: TResponse[]; page: number; perPage: number; totalPages: number; totalCount: number; }; declare enum QrPackageTypeEnum { OBJECTS = "OBJECTS", SERVICES = "SERVICES", USERS = "USERS", USER_DEVICES = "USER_DEVICES", USER_OBJECTS = "USER_OBJECTS", USER_SERVICES = "USER_SERVICES", ORGANIZATIONS = "ORGANIZATIONS", DEVICES = "DEVICES", ORG_USERS = "ORG_USERS", ORG_DEVICES = "ORG_DEVICES", ORG_OBJECTS = "ORG_OBJECTS", ORG_SERVICES = "ORG_SERVICES", WITNESS = "WITNESS", OBJECT_WITNESSES = "OBJECT_WITNESSES", SERVICE_WITNESSES = "SERVICE_WITNESSES" } interface RootEventData { id: string; associationType: string; } declare enum ReferenceType { PHONE = "PHONE", DRIVERS_LICENSE = "DRIVERS_LICENSE", EMPLOYEE_ID = "EMPLOYEE_ID", AUTH0_IDENTITY = "AUTH0_IDENTITY", END_USER_ID = "END_USER_ID", ADMIN_USER_ID = "ADMIN_USER_ID" } interface SubjectDataReferenceItem { type: ReferenceType; value: string; } interface SubjectData { subjectType: string; references: SubjectDataReferenceItem[]; orgId?: string; } declare enum SubjectTypeEnum { EMPLOYEE = "EMPLOYEE", DRIVER = "DRIVER", USER = "USER", ASSET_OWNER = "ASSET_OWNER" } interface TemplateRes { name: string; type: number; text: string; createdAt: string; updatedAt: string; } declare enum WalletPlatformEnum { Ethereum = "ethereum", Polygon = "polygon" } interface WeatherData { AbsHumidity: number; AirDensity: number; AvgCorrectedWindDir: number; AvgCorrectedWindSpeed: number; AvgRelativeWindDir: number; AvgRelativeWindSpeed: number; CompassHeading: number; CorrectedGustDirection: number; CorrectedGustSpeed: number; CorrectedWindDir: number; CorrectedWindSpeed: number; Dewpoint: number; GPSHeading: string; GPSLocation: string; GPSSpeedOverGround: string; GPSStatusError: boolean; HeatIndex: number; PositionOfTheSun: number; PrecipIntensity: string; RainPresent: boolean; Pressure: number; PressureAtSeaLevel: number; PressureAtStation: number; RelGustDir: number; RelGustSpeed: number; RelHumidity: number; RelWindDir: number; RelWindSpeed: number; SensorStatusError: boolean; SolarNoonTime: string; SolarRadiation: string; SunriseTime: string; SunsetTime: string; SunshineHours: number; Temperature: number; TotalPrecip: string; TwilightAstronomical: string; TwilightCivil: string; TwilightNautical: string; WetBulbTemperature: number; WindChill: number; WindSensorError: boolean; XTilt: number; YTilt: number; ZOrientation: string; } interface ViewAttachmentResponse { url: string; } interface UpdateAttachmentResponse { docId: string; status: EAttachmentUploadStatus; message: string; } declare enum FileFormatEnum { CSV = "CSV", PDF = "PDF" } declare enum InfoTypeEnum { Who = "Who", What = "What", When = "When", Where = "Where" } declare enum WitnessTypeEnum { Witness = "witness", Buyer = "buyer", Seller = "seller" } declare function getAuth0Id(claims: AuthClaims, opts?: { keepPrefix: boolean; }): Promise<string>; declare function getAuthEmail(claims: AuthClaims): Promise<string | undefined>; declare function isTokenExpired(token: string): boolean; declare const createQueryParams: (params?: Record<any, SerializableValue>) => string; declare const debounce: <TFunction extends (...args: any[]) => any>(fn: TFunction, ms?: number) => (this: any, ...args: any[]) => void; declare function formatDate(date: string): string; declare function formatNumber(n: string): string; /** * This is a no-man's land function that tries * to handle every possible error scenario from ChainIT frontend & backend. * Handles simple error messages, axios errors, and now FATAL server error objects */ declare function getErrorMessage(err: unknown): string; declare function makeSampleGeolocation(): { latitude: number; longitude: number; meanSeaLevel: number; }; declare function makeSampleWeatherData(): { AbsHumidity: number; AirDensity: number; AvgCorrectedWindDir: number; AvgCorrectedWindSpeed: number; AvgRelativeWindDir: number; AvgRelativeWindSpeed: number; CompassHeading: number; CorrectedGustDirection: number; CorrectedGustSpeed: number; CorrectedWindDir: number; CorrectedWindSpeed: number; Dewpoint: number; GPSHeading: string; GPSLocation: string; GPSSpeedOverGround: string; GPSStatusError: boolean; HeatIndex: number; PositionOfTheSun: number; PrecipIntensity: string; RainPresent: boolean; Pressure: number; PressureAtSeaLevel: number; PressureAtStation: number; RelGustDir: number; RelGustSpeed: number; RelHumidity: number; RelWindDir: number; RelWindSpeed: number; SensorStatusError: boolean; SolarNoonTime: string; SolarRadiation: string; SunriseTime: string; SunsetTime: string; SunshineHours: number; Temperature: number; TotalPrecip: str