Release 0.3.0

API reference

Functions and types from the 0.3.0 package declarations. Each entry shows its import path and links to the release source.

AmountAllowance@1hubengineering/verifier
type AmountAllowance = {
  readonly type: "fixed";
  readonly maxMinor: number;
} | {
  readonly type: "percentage";
  readonly percent: string;
};

Release source · Link to export

AmountCheck@1hubengineering/verifier
type AmountCheck = Exclude<CheckFinding, {
  status: "SKIPPED";
}> & {
  readonly field: "amountMinor";
  readonly rule: "exact" | "within_tolerance";
  readonly expected: number;
  readonly actual: number | null;
  readonly details: AmountCheckDetails;
};

Release source · Link to export

AmountCheckDetails@1hubengineering/verifier
interface AmountCheckDetails {
  readonly policy: AmountPolicy;
  readonly differenceMinor: number | null;
  readonly minimumAcceptedMinor: number;
  readonly maximumAcceptedMinor: number;
  readonly exactMatch: boolean | null;
  readonly toleranceApplied: boolean;
  readonly direction: "UNDERPAID" | "OVERPAID" | null;
}

Release source · Link to export

AmountPolicy@1hubengineering/verifier
type AmountPolicy = {
  readonly mode: "exact";
} | {
  readonly mode: "tolerance";
  readonly underpayment?: AmountAllowance;
  readonly overpayment?: AmountAllowance;
  /** Maximum percentage of the expected principal allowed in either direction. Defaults to 10%. */
  readonly maxPercent?: string;
};

Release source · Link to export

CheckField@1hubengineering/verifier
type CheckField = "provider" | "transactionId" | "paymentStatus" | "amountMinor" | "currency" | "recipientName" | "recipientAccount" | "invoiceReference" | "transactionTime" | "paymentType";

Release source · Link to export

CheckRule@1hubengineering/verifier
type CheckRule = "exact" | "within_tolerance" | "normalized_name" | "account_last4" | "successful_status" | "present_identifier" | "time_window";

Release source · Link to export

CheckStatus@1hubengineering/verifier
type CheckStatus = CheckFinding["status"];

Release source · Link to export

DiagnosticDetails@1hubengineering/verifier
type DiagnosticDetails = Readonly<Record<string, JsonValue>>;

Release source · Link to export

EtbMinorUnits@1hubengineering/verifier
type EtbMinorUnits = number & {
  readonly __etbMinorUnits: unique symbol;
};

Release source · Link to export

EvidenceField@1hubengineering/verifier
type EvidenceField = "provider" | "currency" | "transactionId" | "status" | "amountMinor" | "recipientName" | "recipientAccountLast4" | "reference" | "transactionAt" | "paymentType";

Release source · Link to export

IncompleteEvidenceCode@1hubengineering/verifier
type IncompleteEvidenceCode = "REQUIRED_FIELD_MISSING" | "INVALID_RECEIPT_FIELD" | "AMBIGUOUS_RECEIPT_FIELD";

Release source · Link to export

InvalidInputResult@1hubengineering/verifier
type InvalidInputResult = VerificationResultBase & {
  readonly verified: false;
  readonly status: "INVALID_INPUT";
  readonly code: InputErrorCode | "PROVIDER_MISMATCH";
  readonly stage: "input_parsing" | "input_validation";
  readonly retryable: false;
  readonly receipt: null;
  readonly source: null;
};

Release source · Link to export

JsonValue@1hubengineering/verifier
type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
  readonly [key: string]: JsonValue;
};

Release source · Link to export

MismatchCode@1hubengineering/verifier
type MismatchCode = "RECEIPT_PROVIDER_MISMATCH" | "TRANSACTION_ID_MISMATCH" | "AMOUNT_UNDERPAID" | "AMOUNT_OVERPAID" | "CURRENCY_MISMATCH" | "RECIPIENT_NAME_MISMATCH" | "RECIPIENT_ACCOUNT_MISMATCH" | "INVOICE_REFERENCE_MISMATCH" | "PAYMENT_TIME_OUT_OF_RANGE" | "PAYMENT_TYPE_MISMATCH" | "PAYMENT_PENDING" | "PAYMENT_FAILED" | "PAYMENT_REVERSED" | "PAYMENT_CANCELLED";

Release source · Link to export

OfficialReceiptSource@1hubengineering/verifier
interface OfficialReceiptSource {
  readonly kind: "OFFICIAL_RECEIPT";
  readonly retrievedAt: string;
  readonly parserVersion: string;
  readonly contentHash: string;
}

Release source · Link to export

OperationErrorCode@1hubengineering/verifier
type OperationErrorCode = keyof typeof operationMessages;

Release source · Link to export

OperationStage@1hubengineering/verifier
type OperationStage = "request" | "expectation" | "idempotency" | "provider_configuration" | "adapter" | "completion" | "storage" | "queue";

Release source · Link to export

PaymentExpectation@1hubengineering/verifier
interface PaymentExpectation {
  readonly tenantId: string;
  readonly paymentId: string;
  readonly provider: ProviderId;
  readonly currency: "ETB";
  readonly amountMinor: EtbMinorUnits;
  readonly amountPolicy: AmountPolicy;
  readonly recipientName: string;
  readonly recipientAccountLast4: string;
  readonly reference: string;
  /** Set to false to allow an empty expected reference. The receipt must match it. */
  readonly referenceRequired?: boolean;
  readonly validFrom: number;
  readonly validUntil: number;
}

Release source · Link to export

PaymentScope@1hubengineering/verifier
interface PaymentScope {
  readonly tenantId: string;
  readonly paymentId: string;
}

Release source · Link to export

PreparedVerification@1hubengineering/verifier
interface PreparedVerification {
  readonly [preparedBrand]: true;
}

Release source · Link to export

ProviderFailureCode@1hubengineering/verifier
type ProviderFailureCode = keyof typeof providerMessages;

Release source · Link to export

ProviderFailureStage@1hubengineering/verifier
type ProviderFailureStage = "receipt_retrieval" | "receipt_rendering" | "receipt_parsing";

Release source · Link to export

ProviderId@1hubengineering/verifier
type ProviderId = "telebirr" | "cbe";

Release source · Link to export

ReceiptComparison@1hubengineering/verifier
type ReceiptComparison = {
  readonly status: "MATCH";
  readonly code: null;
  readonly checks: readonly VerificationCheck[];
} | {
  readonly status: "MISMATCH";
  readonly code: MismatchCode | "MULTIPLE_MISMATCHES";
  readonly checks: readonly VerificationCheck[];
} | {
  readonly status: "INCOMPLETE";
  readonly code: IncompleteEvidenceCode | "MULTIPLE_VERIFICATION_ISSUES";
  readonly checks: readonly VerificationCheck[];
};

Release source · Link to export

ReceiptEvidence@1hubengineering/verifier
interface ReceiptEvidence {
  readonly provider: ProviderId | null;
  readonly currency: string | null;
  readonly transactionId: string | null;
  readonly status: "SUCCESSFUL" | "PENDING" | "FAILED" | "REVERSED" | "CANCELLED" | null;
  readonly amountMinor: EtbMinorUnits | null;
  readonly recipientName: string | null;
  readonly recipientAccountLast4: string | null;
  readonly reference: string | null;
  readonly transactionAt: number | null;
  readonly paymentType: string | null;
  readonly ambiguousFields: readonly EvidenceField[];
  readonly invalidFields?: readonly EvidenceField[];
}

Release source · Link to export

ReceiptPaymentStatus@1hubengineering/verifier
type ReceiptPaymentStatus = "SUCCESSFUL" | "PENDING" | "FAILED" | "REVERSED" | "CANCELLED";

Release source · Link to export

ReceiptProvider@1hubengineering/verifier
interface ReceiptProvider {
  retrieve(locator: string, options?: RetrievalOptions): Promise<ProviderResult>;
}

Release source · Link to export

ReceiptSnapshot@1hubengineering/verifier
interface ReceiptSnapshot {
  readonly provider: ProviderId | null;
  readonly transactionId: string | null;
  readonly paymentStatus: ReceiptPaymentStatus | null;
  readonly amountMinor: number | null;
  readonly currency: string | null;
  readonly recipientName: string | null;
  readonly recipientAccount: {
    readonly representation: "LAST4";
    readonly value: string;
  } | null;
  readonly invoiceReference: string | null;
  readonly transactionAt: string | null;
  readonly paymentType: string | null;
}

Release source · Link to export

ReceiptVerifier@1hubengineering/verifier
interface ReceiptVerifier {
  initialize(): Promise<void>;
  registerExpectation(expectation: PaymentExpectation): Promise<void>;
  cancelExpectation(scope: PaymentScope): Promise<void>;
  prepare(input: VerificationSubmission, options?: RetrievalOptions): Promise<PreparedVerification>;
  complete(prepared: PreparedVerification, storage?: VerificationStorage): Promise<VerificationResult>;
  submit(input: VerificationSubmission, options?: RetrievalOptions): Promise<VerificationResult>;
  events(limit?: number): Promise<readonly StoredRecord[]>;
  acknowledgeEvent(key: string): Promise<void>;
}

Release source · Link to export

RecordTransaction@1hubengineering/verifier
interface RecordTransaction {
  get(key: string): Promise<unknown>;
  insert(key: string, value: unknown): Promise<void>;
  set(key: string, value: unknown): Promise<void>;
  delete(key: string): Promise<void>;
  scan(prefix: string, limit: number): Promise<readonly StoredRecord[]>;
}

Release source · Link to export

SerializedVerificationOperationError@1hubengineering/verifier
interface SerializedVerificationOperationError {
  readonly type: "VERIFICATION_OPERATION_ERROR";
  readonly code: OperationErrorCode;
  readonly stage: OperationStage;
  readonly message: string;
  readonly retryable: boolean;
  readonly details: DiagnosticDetails;
}

Release source · Link to export

StorageConflict@1hubengineering/verifier
declare class StorageConflict extends Error {
  constructor();
}

Release source · Link to export

StoredRecord@1hubengineering/verifier
interface StoredRecord {
  readonly key: string;
  readonly value: unknown;
}

Release source · Link to export

UnavailableCode@1hubengineering/verifier
type UnavailableCode = ProviderFailureCode | IncompleteEvidenceCode | "MULTIPLE_VERIFICATION_ISSUES";

Release source · Link to export

VerificationCheck@1hubengineering/verifier
type VerificationCheck = AmountCheck | (CheckFinding & {
  readonly field: Exclude<CheckField, "amountMinor">;
  readonly rule: CheckRule;
  readonly expected?: JsonValue;
  readonly actual?: JsonValue;
});

Release source · Link to export

VerificationOperationError@1hubengineering/verifier
declare class VerificationOperationError extends Error {
  readonly code: OperationErrorCode;
  readonly stage: OperationStage;
  readonly retryable: boolean;
  readonly details: DiagnosticDetails;
  constructor(code: OperationErrorCode, stage: OperationStage, options?: {
    readonly cause?: unknown;
    readonly retryable?: boolean;
    readonly details?: DiagnosticDetails;
  });
  toJSON(): SerializedVerificationOperationError;
}

Release source · Link to export

VerificationResult@1hubengineering/verifier
type VerificationResult = (ObservedResult & {
  readonly verified: true;
  readonly status: "VERIFIED";
  readonly code: "PAYMENT_VERIFIED";
  readonly stage: "completion";
  readonly retryable: false;
  readonly receipt: ReceiptSnapshot & {
    readonly provider: ProviderId;
    readonly transactionId: string;
    readonly paymentStatus: "SUCCESSFUL";
    readonly amountMinor: number;
    readonly currency: "ETB";
  };
  readonly source: OfficialReceiptSource;
}) | InvalidInputResult | (ObservedResult & {
  readonly verified: false;
  readonly status: "MISMATCH";
  readonly code: MismatchCode | "MULTIPLE_MISMATCHES";
  readonly stage: "comparison";
  readonly retryable: boolean;
  readonly receipt: ReceiptSnapshot;
  readonly source: OfficialReceiptSource;
}) | (ObservedResult & {
  readonly verified: false;
  readonly status: "NOT_FOUND";
  readonly code: "RECEIPT_NOT_FOUND";
  readonly stage: "receipt_retrieval";
  readonly retryable: boolean;
  readonly receipt: null;
  readonly source: null;
}) | (ObservedResult & {
  readonly verified: false;
  readonly status: "UNAVAILABLE";
  readonly code: UnavailableCode;
  readonly stage: ProviderFailureStage | "comparison";
  readonly retryable: boolean;
});

Release source · Link to export

VerificationStatus@1hubengineering/verifier
type VerificationStatus = "VERIFIED" | "MISMATCH" | "NOT_FOUND" | "UNAVAILABLE" | "INVALID_INPUT";

Release source · Link to export

VerificationStorage@1hubengineering/verifier
interface VerificationStorage {
  readonly callerTransaction?: boolean;
  read(key: string): Promise<unknown>;
  /** Serializable or equivalent key locking, with unique inserts and no lost checked state.
   * Work may retry; external effects belong outside. Scoped adapters leave commit/rollback/retry to the caller.
   */
  transaction<T>(work: (transaction: RecordTransaction) => Promise<T>): Promise<T>;
}

Release source · Link to export

VerificationSubmission@1hubengineering/verifier
interface VerificationSubmission extends PaymentScope {
  readonly idempotencyKey: string;
  readonly receiptLocator: string;
}

Release source · Link to export

comparePaymentAmount@1hubengineering/verifier
declare function comparePaymentAmount(expectedMinor: number, actualMinor: unknown, policy?: AmountPolicy): AmountCheck;

Release source · Link to export

compareReceipt@1hubengineering/verifier
declare function compareReceipt(expectation: PaymentExpectation, evidence: unknown, expectedTransactionId?: string): ReceiptComparison;

Release source · Link to export

createPaymentExpectation@1hubengineering/verifier
declare function createPaymentExpectation(input: unknown, options?: {
  readonly defaultAmountPolicy?: AmountPolicy;
}): PaymentExpectation;

Release source · Link to export

createReceiptVerifier@1hubengineering/verifier
declare function createReceiptVerifier(config: VerifierConfig): ReceiptVerifier;

Release source · Link to export

parseEtbAmount@1hubengineering/verifier
declare function parseEtbAmount(value: string): EtbMinorUnits;

Release source · Link to export

storageKey@1hubengineering/verifier
declare function storageKey(kind: string, ...parts: string[]): string;

Release source · Link to export

ParsedReceipt@1hubengineering/verifier/providers
interface ParsedReceipt {
  readonly evidence: ReceiptEvidence;
  readonly recognized: boolean;
  readonly provenance: {
    readonly kind: "SAVED_HTML";
    readonly provider: ProviderId;
    readonly parserVersion: "1";
  };
}

Release source · Link to export

ProviderConnectionCheck@1hubengineering/verifier/providers
interface ProviderConnectionCheck {
  readonly hostname: string;
  readonly route: "direct" | "telebirr-tunnel";
  readonly error?: {
    readonly code: RetrievalErrorCode;
    readonly details: DiagnosticDetails;
  };
}

Release source · Link to export

ProviderResult@1hubengineering/verifier/providers
type ProviderResult = {
  readonly kind: "EVIDENCE";
  readonly evidence: ReceiptEvidence;
  readonly pendingRetryable?: boolean;
  readonly provenance: {
    readonly kind: "OFFICIAL_HTTPS";
    readonly url: string;
    readonly retrievedAt: number;
    readonly sha256: string;
    readonly parserVersion: string;
  };
} | {
  readonly kind: "NOT_FOUND";
  readonly retryable?: boolean;
  readonly details?: DiagnosticDetails;
} | {
  readonly kind: "UNAVAILABLE";
  readonly code: ProviderFailureCode;
  readonly stage: ProviderFailureStage;
  readonly retryable: boolean;
  readonly details: DiagnosticDetails;
};

Release source · Link to export

ReceiptLocator@1hubengineering/verifier/providers
interface ReceiptLocator {
  readonly provider: ProviderId;
  readonly url: string;
  readonly transactionId: string | null;
}

Release source · Link to export

RetrievalError@1hubengineering/verifier/providers
declare class RetrievalError extends Error {
  readonly code: RetrievalErrorCode;
  readonly details: DiagnosticDetails;
  readonly retryable: boolean;
  constructor(code: RetrievalErrorCode, details?: DiagnosticDetails, retryable?: boolean, options?: ErrorOptions);
}

Release source · Link to export

RetrievalErrorCode@1hubengineering/verifier/providers
type RetrievalErrorCode = ProviderFailureCode | "INVALID_LOCATOR" | "CANCELLED";

Release source · Link to export

RetrievalOptions@1hubengineering/verifier/providers
interface RetrievalOptions {
  readonly timeoutMs?: number;
  readonly maxBytes?: number;
  readonly signal?: AbortSignal;
  /** Host-configured Unix socket forwarding only to the official Telebirr endpoint. */
  readonly telebirrTunnelSocket?: string;
}

Release source · Link to export

RetrievedHtml@1hubengineering/verifier/providers
interface RetrievedHtml {
  readonly html: string;
  readonly bytes: number;
}

Release source · Link to export

cbeReceiptDataHost@1hubengineering/verifier/providers
declare const cbeReceiptDataHost: string;

Release source · Link to export

checkProviderConnectivity@1hubengineering/verifier/providers
declare function checkProviderConnectivity(provider: ProviderId, options?: Pick<RetrievalOptions, "timeoutMs" | "telebirrTunnelSocket">): Promise<readonly ProviderConnectionCheck[]>;

Release source · Link to export

interpretOfficialHtml@1hubengineering/verifier/providers
declare function interpretOfficialHtml(locator: ReceiptLocator, retrievedHtml: string, parsedHtml: string, retrievedAt: number): ProviderResult;

Release source · Link to export

isPublicDestination@1hubengineering/verifier/providers
declare function isPublicDestination(address: string): boolean;

Release source · Link to export

normalizeReceiptLocator@1hubengineering/verifier/providers
declare function normalizeReceiptLocator(provider: ProviderId, input: string): ReceiptLocator;

Release source · Link to export

parseProviderTime@1hubengineering/verifier/providers
declare function parseProviderTime(value: string): number | null;

Release source · Link to export

parseReceiptHtml@1hubengineering/verifier/providers
declare function parseReceiptHtml(provider: ProviderId, html: string): ParsedReceipt;

Release source · Link to export

providerFailure@1hubengineering/verifier/providers
declare function providerFailure(error: unknown, stage: ProviderFailureStage): ProviderResult;

Release source · Link to export

retrieveHtml@1hubengineering/verifier/providers
declare function retrieveHtml(locator: ReceiptLocator, options?: RetrievalOptions): Promise<RetrievedHtml>;

Release source · Link to export

retrieveTelebirr@1hubengineering/verifier/providers
declare function retrieveTelebirr(input: string, options?: RetrievalOptions): Promise<ProviderResult>;

Release source · Link to export

RecordTransaction@1hubengineering/verifier/storage
interface RecordTransaction {
  get(key: string): Promise<unknown>;
  insert(key: string, value: unknown): Promise<void>;
  set(key: string, value: unknown): Promise<void>;
  delete(key: string): Promise<void>;
  scan(prefix: string, limit: number): Promise<readonly StoredRecord[]>;
}

Release source · Link to export

StorageConflict@1hubengineering/verifier/storage
declare class StorageConflict extends Error {
  constructor();
}

Release source · Link to export

StorageDataError@1hubengineering/verifier/storage
declare class StorageDataError extends Error {
  constructor();
}

Release source · Link to export

StoredRecord@1hubengineering/verifier/storage
interface StoredRecord {
  readonly key: string;
  readonly value: unknown;
}

Release source · Link to export

VerificationStorage@1hubengineering/verifier/storage
interface VerificationStorage {
  readonly callerTransaction?: boolean;
  read(key: string): Promise<unknown>;
  /** Serializable or equivalent key locking, with unique inserts and no lost checked state.
   * Work may retry; external effects belong outside. Scoped adapters leave commit/rollback/retry to the caller.
   */
  transaction<T>(work: (transaction: RecordTransaction) => Promise<T>): Promise<T>;
}

Release source · Link to export

decodeStorageRecord@1hubengineering/verifier/storage
declare function decodeStorageRecord(payload: string | undefined): unknown;

Release source · Link to export

encodeStorageRecord@1hubengineering/verifier/storage
declare function encodeStorageRecord(value: unknown): string;

Release source · Link to export

validateStorageKey@1hubengineering/verifier/storage
declare function validateStorageKey(key: string): void;

Release source · Link to export

validateStorageScan@1hubengineering/verifier/storage
declare function validateStorageScan(prefix: string, limit: number): void;

Release source · Link to export

createDurableVerifier@1hubengineering/verifier/jobs
export declare function createDurableVerifier(config: {
  readonly storage: VerificationStorage;
  readonly providers: Readonly<Partial<Record<ProviderId, ReceiptProvider>>>;
  readonly encryptionKey: Uint8Array;
  readonly policy?: Partial<JobPolicy>;
  readonly now?: () => number;
}): DurableVerifier;

Release source · Link to export

JobPolicy@1hubengineering/verifier/jobs
export interface JobPolicy {
  readonly maxPending: number;
  readonly maxRetained: number;
  readonly concurrency: number;
  readonly maxAttempts: number;
  readonly timeoutMs: number;
  readonly leaseMs: number;
  readonly backoffMs: number;
}

Release source · Link to export

VerificationJob@1hubengineering/verifier/jobs
export type VerificationJob = JobSummary & ({
  readonly state: "QUEUED" | "RUNNING" | "RETRY_WAIT";
  readonly result?: never;
  readonly error?: never;
} | {
  readonly state: "COMPLETED";
  readonly result: VerificationResult;
  readonly error?: never;
} | {
  readonly state: "FAILED";
  readonly error: SerializedVerificationOperationError;
  readonly result?: never;
});

Release source · Link to export

DurableVerifier@1hubengineering/verifier/jobs
export interface DurableVerifier {
  initialize(): Promise<void>;
  enqueue(input: VerificationSubmission): Promise<VerificationJob>;
  status(scope: PaymentScope, jobId: string): Promise<VerificationJob>;
  runOnce(options?: {
    readonly signal?: AbortSignal;
  }): Promise<"IDLE" | "BUSY" | "STALE" | "RETRY_WAIT" | "COMPLETED" | "FAILED">;
  pruneCompleted(before: number, limit?: number): Promise<number>;
}

Release source · Link to export

AmountAllowance@1hubengineering/verifier/comparison
type AmountAllowance = {
  readonly type: "fixed";
  readonly maxMinor: number;
} | {
  readonly type: "percentage";
  readonly percent: string;
};

Release source · Link to export

AmountCheckDetails@1hubengineering/verifier/comparison
interface AmountCheckDetails {
  readonly policy: AmountPolicy;
  readonly differenceMinor: number | null;
  readonly minimumAcceptedMinor: number;
  readonly maximumAcceptedMinor: number;
  readonly exactMatch: boolean | null;
  readonly toleranceApplied: boolean;
  readonly direction: "UNDERPAID" | "OVERPAID" | null;
}

Release source · Link to export

AmountPolicy@1hubengineering/verifier/comparison
type AmountPolicy = {
  readonly mode: "exact";
} | {
  readonly mode: "tolerance";
  readonly underpayment?: AmountAllowance;
  readonly overpayment?: AmountAllowance;
  /** Maximum percentage of the expected principal allowed in either direction. Defaults to 10%. */
  readonly maxPercent?: string;
};

Release source · Link to export

EtbMinorUnits@1hubengineering/verifier/comparison
type EtbMinorUnits = number & {
  readonly __etbMinorUnits: unique symbol;
};

Release source · Link to export

PaymentExpectation@1hubengineering/verifier/comparison
interface PaymentExpectation {
  readonly tenantId: string;
  readonly paymentId: string;
  readonly provider: ProviderId;
  readonly currency: "ETB";
  readonly amountMinor: EtbMinorUnits;
  readonly amountPolicy: AmountPolicy;
  readonly recipientName: string;
  readonly recipientAccountLast4: string;
  readonly reference: string;
  /** Set to false to allow an empty expected reference. The receipt must match it. */
  readonly referenceRequired?: boolean;
  readonly validFrom: number;
  readonly validUntil: number;
}

Release source · Link to export

ProviderId@1hubengineering/verifier/comparison
type ProviderId = "telebirr" | "cbe";

Release source · Link to export

ReceiptComparison@1hubengineering/verifier/comparison
type ReceiptComparison = {
  readonly status: "MATCH";
  readonly code: null;
  readonly checks: readonly VerificationCheck[];
} | {
  readonly status: "MISMATCH";
  readonly code: MismatchCode | "MULTIPLE_MISMATCHES";
  readonly checks: readonly VerificationCheck[];
} | {
  readonly status: "INCOMPLETE";
  readonly code: IncompleteEvidenceCode | "MULTIPLE_VERIFICATION_ISSUES";
  readonly checks: readonly VerificationCheck[];
};

Release source · Link to export

ReceiptEvidence@1hubengineering/verifier/comparison
interface ReceiptEvidence {
  readonly provider: ProviderId | null;
  readonly currency: string | null;
  readonly transactionId: string | null;
  readonly status: "SUCCESSFUL" | "PENDING" | "FAILED" | "REVERSED" | "CANCELLED" | null;
  readonly amountMinor: EtbMinorUnits | null;
  readonly recipientName: string | null;
  readonly recipientAccountLast4: string | null;
  readonly reference: string | null;
  readonly transactionAt: number | null;
  readonly paymentType: string | null;
  readonly ambiguousFields: readonly EvidenceField[];
  readonly invalidFields?: readonly EvidenceField[];
}

Release source · Link to export

VerificationCheck@1hubengineering/verifier/comparison
type VerificationCheck = AmountCheck | (CheckFinding & {
  readonly field: Exclude<CheckField, "amountMinor">;
  readonly rule: CheckRule;
  readonly expected?: JsonValue;
  readonly actual?: JsonValue;
});

Release source · Link to export

comparePaymentAmount@1hubengineering/verifier/comparison
declare function comparePaymentAmount(expectedMinor: number, actualMinor: unknown, policy?: AmountPolicy): AmountCheck;

Release source · Link to export

compareReceipt@1hubengineering/verifier/comparison
declare function compareReceipt(expectation: PaymentExpectation, evidence: unknown, expectedTransactionId?: string): ReceiptComparison;

Release source · Link to export

createPaymentExpectation@1hubengineering/verifier/comparison
declare function createPaymentExpectation(input: unknown, options?: {
  readonly defaultAmountPolicy?: AmountPolicy;
}): PaymentExpectation;

Release source · Link to export

parseEtbAmount@1hubengineering/verifier/comparison
declare function parseEtbAmount(value: string): EtbMinorUnits;

Release source · Link to export

DetectedPaymentInput@1hubengineering/verifier/input
type DetectedPaymentInput = {
  readonly provider: "telebirr";
  readonly inputType: InputType;
  readonly identifierKind: "transaction_id";
  readonly identifier: string;
} | {
  readonly provider: "cbe";
  readonly inputType: InputType;
  readonly identifierKind: "receipt_id";
  readonly identifier: string;
};

Release source · Link to export

InputDetectionResult@1hubengineering/verifier/input
type InputDetectionResult = {
  readonly ok: true;
  readonly value: DetectedPaymentInput;
} | {
  readonly ok: false;
  readonly error: {
    readonly code: InputErrorCode;
    readonly message: string;
    readonly details: Readonly<Record<string, JsonValue>>;
  };
};

Release source · Link to export

InputErrorCode@1hubengineering/verifier/input
type InputErrorCode = keyof typeof messages;

Release source · Link to export

InputType@1hubengineering/verifier/input
type InputType = "identifier" | "receipt_url" | "sms";

Release source · Link to export

PAYMENT_INPUT_LIMIT@1hubengineering/verifier/input
declare const PAYMENT_INPUT_LIMIT = 4096;

Release source · Link to export

detectPaymentInput@1hubengineering/verifier/input
declare function detectPaymentInput(input: string): InputDetectionResult;

Release source · Link to export

SqlEngine@1hubengineering/storage-sql
type SqlEngine = "postgres" | "mysql" | "sqlite";

Release source · Link to export

SqlStorage@1hubengineering/storage-sql
interface SqlStorage extends VerificationStorage {
  /** Apply v1 schema explicitly; no import-time migration or connection ownership. */
  migrate(): Promise<void>;
  /** Use the caller's actual Kysely transaction; caller owns commit, rollback and retry. */
  withTransaction(transaction: Kysely<StorageSchema>): VerificationStorage;
}

Release source · Link to export

StorageDataError@1hubengineering/storage-sql
declare class StorageDataError extends Error {
  constructor();
}

Release source · Link to export

StorageSchema@1hubengineering/storage-sql
interface StorageSchema {
  receipt_verifier_records: {
    record_key: string;
    payload: string;
  };
  receipt_verifier_schema: {
    id: number;
    version: number;
  };
}

Release source · Link to export

createSqlStorage@1hubengineering/storage-sql
declare function createSqlStorage(database: Kysely<StorageSchema>, engine: SqlEngine): SqlStorage;

Release source · Link to export

isSqlConflict@1hubengineering/storage-sql
declare function isSqlConflict(error: unknown): boolean;

Release source · Link to export

postgresStorage@1hubengineering/storage-sql/postgres
export declare function postgresStorage(pool: Pool): SqlStorage;

Release source · Link to export

postgresTransaction@1hubengineering/storage-sql/postgres
export declare function postgresTransaction(client: PoolClient): VerificationStorage;

Release source · Link to export

mysqlStorage@1hubengineering/storage-sql/mysql
export declare function mysqlStorage(pool: Pool): SqlStorage;

Release source · Link to export

mysqlTransaction@1hubengineering/storage-sql/mysql
export declare function mysqlTransaction(connection: PoolConnection): VerificationStorage;

Release source · Link to export

sqliteStorage@1hubengineering/storage-sql/sqlite
export declare function sqliteStorage(database: Database): SqlStorage;

Release source · Link to export

sqliteTransaction@1hubengineering/storage-sql/sqlite
export declare function sqliteTransaction(database: Database): VerificationStorage;

Release source · Link to export

drizzlePostgresStorage@1hubengineering/adapter-drizzle/postgres
export declare function drizzlePostgresStorage<T extends AnyRelations>(database: NodePgDatabase<T>): VerificationStorage;

Release source · Link to export

drizzlePostgresTransaction@1hubengineering/adapter-drizzle/postgres
export declare function drizzlePostgresTransaction<T extends AnyRelations>(transaction: Tx<T>): VerificationStorage;

Release source · Link to export

receiptVerifierRecords@1hubengineering/adapter-drizzle/postgres
export declare const receiptVerifierRecords: ReturnType<typeof pgTable<"receipt_verifier_records", {
  recordKey: ReturnType<PgVarcharBuilder["primaryKey"]>;
  payload: ReturnType<PgTextBuilder["notNull"]>;
}>>;

Release source · Link to export

receiptVerifierSchema@1hubengineering/adapter-drizzle/postgres
export declare const receiptVerifierSchema: ReturnType<typeof pgTable<"receipt_verifier_schema", {
  id: ReturnType<PgIntegerBuilder["primaryKey"]>;
  version: ReturnType<PgIntegerBuilder["notNull"]>;
}>>;

Release source · Link to export

drizzleMysqlStorage@1hubengineering/adapter-drizzle/mysql
export declare function drizzleMysqlStorage<T extends AnyRelations>(database: MySql2Database<T>): VerificationStorage;

Release source · Link to export

drizzleMysqlTransaction@1hubengineering/adapter-drizzle/mysql
export declare function drizzleMysqlTransaction<T extends AnyRelations>(transaction: Tx<T>): VerificationStorage;

Release source · Link to export

receiptVerifierRecords@1hubengineering/adapter-drizzle/mysql
export declare const receiptVerifierRecords: ReturnType<typeof mysqlTable<"receipt_verifier_records", {
  recordKey: ReturnType<MySqlVarCharBuilder<[string, ...string[]]>["primaryKey"]>;
  payload: ReturnType<MySqlTextBuilder<[string, ...string[]]>["notNull"]>;
}>>;

Release source · Link to export

receiptVerifierSchema@1hubengineering/adapter-drizzle/mysql
export declare const receiptVerifierSchema: ReturnType<typeof mysqlTable<"receipt_verifier_schema", {
  id: ReturnType<MySqlIntBuilder<boolean | undefined>["primaryKey"]>;
  version: ReturnType<MySqlIntBuilder<boolean | undefined>["notNull"]>;
}>>;

Release source · Link to export

drizzleSqliteStorage@1hubengineering/adapter-drizzle/sqlite
export declare function drizzleSqliteStorage<T extends AnyRelations>(database: LibSQLDatabase<T>): VerificationStorage;

Release source · Link to export

drizzleSqliteTransaction@1hubengineering/adapter-drizzle/sqlite
export declare function drizzleSqliteTransaction<T extends AnyRelations>(transaction: Tx<T>): VerificationStorage;

Release source · Link to export

receiptVerifierRecords@1hubengineering/adapter-drizzle/sqlite
export declare const receiptVerifierRecords: ReturnType<typeof sqliteTable<"receipt_verifier_records", {
  recordKey: ReturnType<SQLiteTextBuilder<[string, ...string[]]>["primaryKey"]>;
  payload: ReturnType<SQLiteTextBuilder<[string, ...string[]]>["notNull"]>;
}>>;

Release source · Link to export

receiptVerifierSchema@1hubengineering/adapter-drizzle/sqlite
export declare const receiptVerifierSchema: ReturnType<typeof sqliteTable<"receipt_verifier_schema", {
  id: ReturnType<SQLiteIntegerBuilder["primaryKey"]>;
  version: ReturnType<SQLiteIntegerBuilder["notNull"]>;
}>>;

Release source · Link to export

prismaStorage@1hubengineering/adapter-prisma
export declare function prismaStorage(client: PrismaReceiptClient): VerificationStorage;

Release source · Link to export

prismaTransaction@1hubengineering/adapter-prisma
export declare function prismaTransaction(client: PrismaReceiptTransaction, policy: {
  readonly isolationLevel: "Serializable";
}): VerificationStorage;

Release source · Link to export

PrismaRecord@1hubengineering/adapter-prisma
export interface PrismaRecord {
  readonly recordKey: string;
  readonly payload: string;
}

Release source · Link to export

PrismaReceiptTransaction@1hubengineering/adapter-prisma
export interface PrismaReceiptTransaction {
  readonly receiptVerifierRecord: {
    findUnique(args: {
      where: {
        recordKey: string;
      };
    }): Promise<PrismaRecord | null>;
    create(args: {
      data: PrismaRecord;
    }): Promise<PrismaRecord>;
    updateMany(args: {
      where: {
        recordKey: string;
      };
      data: {
        payload: string;
      };
    }): Promise<{
      count: number;
    }>;
    deleteMany(args: {
      where: {
        recordKey: string;
      };
    }): Promise<{
      count: number;
    }>;
    findMany(args: {
      where: {
        recordKey: {
          startsWith: string;
        };
      };
      orderBy: {
        recordKey: "asc";
      };
      take: number;
    }): Promise<PrismaRecord[]>;
  };
}

Release source · Link to export

PrismaReceiptClient@1hubengineering/adapter-prisma
export interface PrismaReceiptClient extends PrismaReceiptTransaction {
  $transaction<T>(work: (transaction: PrismaReceiptTransaction) => Promise<T>, options: {
    isolationLevel: "Serializable";
    maxWait: number;
    timeout: number;
  }): Promise<T>;
}

Release source · Link to export

checkCbeBrowser@1hubengineering/provider-cbe
export declare function checkCbeBrowser(): Promise<void>;

Release source · Link to export

createCbeProvider@1hubengineering/provider-cbe
export declare function createCbeProvider(options?: {
  readonly maxConcurrency?: number;
}): CbeProvider;

Release source · Link to export

CbeProvider@1hubengineering/provider-cbe
export interface CbeProvider {
  retrieve(input: string, options?: RetrievalOptions): Promise<ProviderResult>;
}

Release source · Link to export