@cfxlabsinc/b2b-services
    Preparing search index...

    Hierarchy

    • MetcapBaseClient
      • MetcapAccountClient
    Index
    • Parameters

      • args: {
            apiUsername: string;
            apiUserPassword: string;
            bankUsername: string;
            bankUserPassword: string;
            baseUrl: string;
        }

      Returns MetcapAccountClient

    client: Client<paths>
    • Parameters

      • args: { accountNumber: string; apiUserToken: string; bankUserToken: string }

      Returns Promise<
          {
              balance?: number;
              error?: {
                  code?: | "InvalidToken"
                  | "TimedOut"
                  | "InvalidAccount"
                  | "InvalidTransferId"
                  | "MissingUsername"
                  | "DuplicateUser"
                  | "InvalidUserCredentials"
                  | "InternalError"
                  | "TokenExpired"
                  | "MissingPassword"
                  | "Q2Error";
                  description?: string;
              };
          },
      >

    • Parameters

      • args: {
            accountNumber: string;
            apiUserToken: string;
            bankUserToken: string;
            fromDate?: Date;
            pageNumber?: number;
            pageSize?: number;
            toDate?: Date;
        }

      Returns Promise<
          {
              count: number;
              error?: {
                  code?: | "InvalidToken"
                  | "TimedOut"
                  | "InvalidAccount"
                  | "InvalidTransferId"
                  | "MissingUsername"
                  | "DuplicateUser"
                  | "InvalidUserCredentials"
                  | "InternalError"
                  | "TokenExpired"
                  | "MissingPassword"
                  | "Q2Error";
                  description?: string;
              };
              returned?: number;
              transactions: MetcapAccountClientTransaction[];
          },
      >

    • Log in as both users and return the pair, valid until the sooner expiry.

      Retried once as a unit, because the two logins are not independent: the bank-user login authenticates with the api-user token minted a line above it, and a login by ANY other holder of this credential in that window revokes it. That is not hypothetical — it is WIRE-EMAIL-HANDLER-A, an InvalidToken on getBankUserToken against a token microseconds old.

      Re-minting the api token is the whole remedy, so the retry restarts from getApiUserToken. One extra attempt only: a credential losing this race twice running is contention no amount of local retrying resolves, and each further attempt revokes someone else's token on the way past.

      Returns Promise<{ apiUserToken: string; bankUserToken: string; expiresAt: Date }>