Skip to content

Commit

Permalink
Merge pull request #12 from CookieGMVN/1.5.0
Browse files Browse the repository at this point in the history
fix: Fixed login problems.
  • Loading branch information
CookieGMVN authored Jul 10, 2024
2 parents 2cbd491 + d151e51 commit 7961718
Show file tree
Hide file tree
Showing 30 changed files with 4,007 additions and 340 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
node-version: [20.x]

steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,4 @@ out
.pnp.*

Test.local.ts
Test.local.js

dist/
Test.local.js
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
106 changes: 106 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { Client } from 'undici';

interface BalanceData {
number: string;
name: string;
currency: string;
balance: string;
}
interface BalanceList {
balances?: BalanceData[];
internationalBalances?: BalanceData[];
currencyEquivalent: string;
totalBalance: string;
}
interface TransactionInfo {
postDate: string;
transactionDate: string;
accountNumber: string;
creditAmount: string;
debitAmount: string;
transactionCurrency: string;
transactionDesc: string;
balanceAvailable: string;
refNo: string;
toAccountName?: string;
toBank?: string;
toAccountNumber?: string;
type?: string;
}

/**
* Main client class for all activities.
*/
declare class MB {
/**
* @readonly
* Your MB account username.
*/
readonly username: string;
/**
* @readonly
* Your MB account password.
*/
readonly password: string;
/**
* @private
* MB-returned Session ID. Use it to validate the request.
*/
private sessionId;
/**
* @private
* Your non-unique, time-based Device ID.
*/
private deviceId;
/**
* Undici client. Use it for sending the request to API.
*/
client: Client;
private wasmData;
/**
* Login to your MB account via username and password.
* @param data - Your MB Bank login credentials: username and password.
* @param data.username Your MB Bank login username, usually your registered phone number.
* @param data.password Your MB Bank login password.
*/
constructor(data: {
username: string;
password: string;
});
/**
* A private function to process MB's captcha and get Session ID.
*/
private login;
/**
* A private function to calculate the reference ID required by MB.
* @returns The reference ID that is required by MB.
*/
private getRefNo;
private mbRequest;
/**
* Gets your account's balance info.
* @returns Your MB account's balance object.
*/
getBalance(): Promise<BalanceList | undefined>;
/**
* Gets all your transactions on MB.
* @param data The data that function requires.
* @param data.accountNumber The MB's account number needs to be checked.
* @param data.fromDate The date you want to start looking up, format dd/mm/yyyy. Make sure this is not smaller than 90 days from the ending date.
* @param data.toDate The date you want to end the lookup, format dd/mm/yyyy. Make sure this is not bigger than 90 days from the starting date.
* @returns TransactionInfo object as an array, see TransactionInfo for more details.
*
* @example
* If you want to get transactions history from account "1234567890", from 1/12/2023 to 1/1/2024:
* ```ts
* <MB>.getTransactionsHistory({ accountNumber: "1234567890", fromDate: "1/12/2023", toDate: "1/1/2024" });
* ```
*/
getTransactionsHistory(data: {
accountNumber: string;
fromDate: string;
toDate: string;
}): Promise<TransactionInfo[] | undefined>;
}

export { MB };
Loading

0 comments on commit 7961718

Please sign in to comment.