@technova-tech/connect-cba 0.0.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/bank-one/BankOne.d.ts +31 -0
  2. package/bank-one/BankOne.js +848 -0
  3. package/bank-one/index.d.ts +2 -0
  4. package/bank-one/index.js +18 -0
  5. package/bank-one/interface/index.d.ts +439 -0
  6. package/bank-one/interface/index.js +2 -0
  7. package/common/constants/cba.constant.d.ts +3 -0
  8. package/common/constants/cba.constant.js +7 -0
  9. package/common/constants/index.d.ts +1 -0
  10. package/common/constants/index.js +17 -0
  11. package/common/errors/BadRequest.d.ts +4 -0
  12. package/common/errors/BadRequest.js +31 -0
  13. package/common/errors/HttpRequest.d.ts +3 -0
  14. package/common/errors/HttpRequest.js +26 -0
  15. package/common/errors/InternalServer.d.ts +4 -0
  16. package/common/errors/InternalServer.js +31 -0
  17. package/common/errors/index.d.ts +4 -0
  18. package/common/errors/index.js +11 -0
  19. package/common/errors/messages.d.ts +3 -0
  20. package/common/errors/messages.js +6 -0
  21. package/common/http/index.d.ts +14 -0
  22. package/common/http/index.js +82 -0
  23. package/common/index.d.ts +5 -0
  24. package/common/index.js +21 -0
  25. package/common/interface/ICBA.d.ts +33 -0
  26. package/common/interface/ICBA.js +33 -0
  27. package/common/interface/account.d.ts +80 -0
  28. package/common/interface/account.js +2 -0
  29. package/common/interface/customer.d.ts +63 -0
  30. package/common/interface/customer.js +8 -0
  31. package/common/interface/index.d.ts +4 -0
  32. package/common/interface/index.js +20 -0
  33. package/common/interface/transaction.d.ts +40 -0
  34. package/common/interface/transaction.js +14 -0
  35. package/common/interface/transfer.d.ts +50 -0
  36. package/common/interface/transfer.js +2 -0
  37. package/common/util/index.d.ts +3 -0
  38. package/common/util/index.js +40 -0
  39. package/common/util/phone.d.ts +1 -0
  40. package/common/util/phone.js +15 -0
  41. package/index.d.ts +4 -0
  42. package/index.js +30 -0
  43. package/package.json +42 -0
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
3
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
4
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
5
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
6
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
7
+ var _, done = false;
8
+ for (var i = decorators.length - 1; i >= 0; i--) {
9
+ var context = {};
10
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
11
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
12
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
13
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
14
+ if (kind === "accessor") {
15
+ if (result === void 0) continue;
16
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
17
+ if (_ = accept(result.get)) descriptor.get = _;
18
+ if (_ = accept(result.set)) descriptor.set = _;
19
+ if (_ = accept(result.init)) initializers.unshift(_);
20
+ }
21
+ else if (_ = accept(result)) {
22
+ if (kind === "field") initializers.unshift(_);
23
+ else descriptor[key] = _;
24
+ }
25
+ }
26
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
27
+ done = true;
28
+ };
29
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
30
+ var useValue = arguments.length > 2;
31
+ for (var i = 0; i < initializers.length; i++) {
32
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
33
+ }
34
+ return useValue ? value : void 0;
35
+ };
36
+ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
37
+ if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
38
+ return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
39
+ };
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.HttpClientResponseHandler = void 0;
42
+ var typedi_1 = require("typedi");
43
+ var errors_1 = require("../errors");
44
+ var HttpClientResponseHandler = function () {
45
+ var _classDecorators = [(0, typedi_1.Service)()];
46
+ var _classDescriptor;
47
+ var _classExtraInitializers = [];
48
+ var _classThis;
49
+ var HttpClientResponseHandler = _classThis = (function () {
50
+ function HttpClientResponseHandler_1() {
51
+ }
52
+ HttpClientResponseHandler_1.prototype.errorResponse = function (message, responseCode) {
53
+ return {
54
+ success: false,
55
+ message: message !== null && message !== void 0 ? message : errors_1.ERROR_MESSAGES.DEFAULT,
56
+ timestamps: new Date(),
57
+ responseCode: responseCode !== null && responseCode !== void 0 ? responseCode : '99',
58
+ };
59
+ };
60
+ HttpClientResponseHandler_1.prototype.successResponse = function (payload) {
61
+ var message = payload.message, data = payload.data;
62
+ return {
63
+ success: true,
64
+ message: message !== null && message !== void 0 ? message : 'request successful',
65
+ timestamps: new Date(),
66
+ responseCode: '00',
67
+ data: data,
68
+ };
69
+ };
70
+ return HttpClientResponseHandler_1;
71
+ }());
72
+ __setFunctionName(_classThis, "HttpClientResponseHandler");
73
+ (function () {
74
+ var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
75
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
76
+ HttpClientResponseHandler = _classThis = _classDescriptor.value;
77
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
78
+ __runInitializers(_classThis, _classExtraInitializers);
79
+ })();
80
+ return HttpClientResponseHandler = _classThis;
81
+ }();
82
+ exports.HttpClientResponseHandler = HttpClientResponseHandler;
@@ -0,0 +1,5 @@
1
+ export * from './constants';
2
+ export * from './errors';
3
+ export * from './http';
4
+ export * from './interface';
5
+ export * from './util';
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./constants"), exports);
18
+ __exportStar(require("./errors"), exports);
19
+ __exportStar(require("./http"), exports);
20
+ __exportStar(require("./interface"), exports);
21
+ __exportStar(require("./util"), exports);
@@ -0,0 +1,33 @@
1
+ import { Axios } from 'axios';
2
+ import { HttpClientResponseHandler, ServiceResponse } from '../http';
3
+ import { AccountListResponse, AccountResponseData, CreateAccountRequest, DeactivatePNDRequest, DeactivatePNDResponse, GetAccountRequest, GetBankListRequest, GetBankListResponse, PerformAccountTransactionRequest, UpdateAccountTierRequest } from './account';
4
+ import { CreateBusinessCustomerRequest, CreateCustomerRequest, CustomerResponseData, GetCustomerByPhoneNumberRequest, GetCustomerRequest, UpdateCustomerRequest } from './customer';
5
+ import { BankTransferRequest, BankTransferResponse, IntraBankTransferRequest, IntraBankTransferResponse, NameEnquiryRequest, NameEnquiryResponse, TransactionStatusQueryRequest, TransactionStatusQueryResponse } from './transfer';
6
+ export interface ICBAHttpClientConfig {
7
+ baseURL: string;
8
+ headers?: Record<string, any>;
9
+ }
10
+ export declare abstract class ICoreBankingApplication {
11
+ protected responseHandler: HttpClientResponseHandler;
12
+ protected httpClient: Axios;
13
+ constructor(config?: ICBAHttpClientConfig);
14
+ protected handleResponseError(responseData: any, errorMessage?: string): void;
15
+ abstract createCustomer(request: CreateCustomerRequest): Promise<ServiceResponse<CustomerResponseData>>;
16
+ abstract createBusinessCustomer(request: CreateBusinessCustomerRequest): Promise<ServiceResponse<CustomerResponseData>>;
17
+ abstract getCustomerById(request: GetCustomerRequest): Promise<ServiceResponse<CustomerResponseData>>;
18
+ abstract getCustomerByPhoneNumber(request: GetCustomerByPhoneNumberRequest): Promise<ServiceResponse<CustomerResponseData>>;
19
+ abstract updateCustomer(request: UpdateCustomerRequest): Promise<ServiceResponse<CustomerResponseData>>;
20
+ abstract createAccount(request: CreateAccountRequest): Promise<ServiceResponse<AccountResponseData>>;
21
+ abstract createBusinessAccount(request: CreateAccountRequest): Promise<ServiceResponse<AccountResponseData>>;
22
+ abstract getAccount(request: GetAccountRequest): Promise<ServiceResponse<AccountResponseData>>;
23
+ abstract getCustomerAccounts(request: GetCustomerRequest): Promise<ServiceResponse<AccountListResponse>>;
24
+ abstract creditAccount(request: PerformAccountTransactionRequest): Promise<ServiceResponse<null>>;
25
+ abstract debitAccount(request: PerformAccountTransactionRequest): Promise<ServiceResponse<null>>;
26
+ abstract getBankList(request: GetBankListRequest): Promise<ServiceResponse<GetBankListResponse>>;
27
+ abstract updateAccountTier(request: UpdateAccountTierRequest): Promise<ServiceResponse<AccountResponseData>>;
28
+ abstract bankTransfer(request: BankTransferRequest): Promise<ServiceResponse<BankTransferResponse>>;
29
+ abstract intraBankTransfer(request: IntraBankTransferRequest): Promise<ServiceResponse<IntraBankTransferResponse>>;
30
+ abstract transactionStatusQuery(request: TransactionStatusQueryRequest): Promise<ServiceResponse<TransactionStatusQueryResponse>>;
31
+ abstract nameEnquiry(request: NameEnquiryRequest): Promise<ServiceResponse<NameEnquiryResponse>>;
32
+ abstract deactivatePND(request: DeactivatePNDRequest): Promise<ServiceResponse<DeactivatePNDResponse>>;
33
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.ICoreBankingApplication = void 0;
18
+ var axios_1 = __importDefault(require("axios"));
19
+ var typedi_1 = __importDefault(require("typedi"));
20
+ var errors_1 = require("../errors");
21
+ var http_1 = require("../http");
22
+ var ICoreBankingApplication = (function () {
23
+ function ICoreBankingApplication(config) {
24
+ this.responseHandler = typedi_1.default.get(http_1.HttpClientResponseHandler);
25
+ this.httpClient = axios_1.default.create(__assign(__assign({}, (config ? config : {})), { validateStatus: function (status) { return status <= 504; } }));
26
+ }
27
+ ICoreBankingApplication.prototype.handleResponseError = function (responseData, errorMessage) {
28
+ console.error(errorMessage, responseData);
29
+ throw new errors_1.BadRequestError(errors_1.ERROR_MESSAGES.DEFAULT);
30
+ };
31
+ return ICoreBankingApplication;
32
+ }());
33
+ exports.ICoreBankingApplication = ICoreBankingApplication;
@@ -0,0 +1,80 @@
1
+ import { Customer } from './customer';
2
+ export interface Account {
3
+ customer: string | Customer;
4
+ id: number;
5
+ name: string;
6
+ number: string;
7
+ status: string;
8
+ balance: number;
9
+ ledgerBalance: number;
10
+ type: string;
11
+ tier: string;
12
+ per_transaction_limit: number;
13
+ daily_transaction_limit: number;
14
+ }
15
+ export interface CreateAccountRequest {
16
+ account: Partial<Account>;
17
+ customer: Partial<Customer>;
18
+ }
19
+ export interface CreateAccountResponseData {
20
+ account: Account;
21
+ }
22
+ export interface GetCustomerAccountsRequest {
23
+ customer: string;
24
+ }
25
+ export interface GetAccountRequest {
26
+ accountNumber: string;
27
+ }
28
+ export interface AccountResponseData {
29
+ account: Partial<Account>;
30
+ }
31
+ export interface UpdateAccountRequest {
32
+ id: string;
33
+ update: Partial<Account>;
34
+ }
35
+ export interface UpdateAccountTierRequest {
36
+ accountNumber: string;
37
+ accountTier: '1' | '2' | '3';
38
+ }
39
+ export interface PerformAccountTransactionRequest {
40
+ accountNumber: string;
41
+ amount: number;
42
+ reference: string;
43
+ narration?: string;
44
+ }
45
+ export interface Bank {
46
+ code: string;
47
+ name: string;
48
+ }
49
+ export interface GetBankListRequest {
50
+ }
51
+ export interface GetBankListResponse {
52
+ banks: Bank[];
53
+ }
54
+ export interface DeleteAccountRequest {
55
+ id: string;
56
+ }
57
+ export interface AccountListResponse {
58
+ accounts: Partial<Account>[];
59
+ }
60
+ export interface DeactivatePNDRequest {
61
+ accountNumber: string;
62
+ }
63
+ export interface DeactivatePNDResponse {
64
+ }
65
+ export interface IntraNameEnquiryRequest {
66
+ accountNumber: string;
67
+ }
68
+ export interface IntraNameEnquiryResponse {
69
+ accountName: string;
70
+ accountNumber: string;
71
+ bankName: string;
72
+ tier: string;
73
+ }
74
+ export interface FreezeAccountRequest {
75
+ accountNumber: string;
76
+ reference: string;
77
+ reason: string;
78
+ }
79
+ export interface FreezeAccountResponse {
80
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,63 @@
1
+ export declare enum Gender {
2
+ MALE = "Male",
3
+ FEMALE = "Female"
4
+ }
5
+ export interface KycData {
6
+ type: string;
7
+ id_number: string;
8
+ bvn: string;
9
+ nin: string;
10
+ imageBase64: string;
11
+ date_of_birth: string;
12
+ place_of_birth: string;
13
+ address: string;
14
+ email: string;
15
+ metadata: Record<string, any>;
16
+ }
17
+ export interface Customer {
18
+ id: string;
19
+ first_name: string;
20
+ last_name: string;
21
+ middle_name?: string;
22
+ other_name?: string;
23
+ gender: Gender;
24
+ phone_number: string;
25
+ kyc: Partial<KycData>;
26
+ email?: string;
27
+ }
28
+ export interface CreateCustomerRequest {
29
+ id: string;
30
+ first_name: string;
31
+ last_name: string;
32
+ middle_name?: string;
33
+ other_name?: string;
34
+ gender: Gender;
35
+ kyc: KycData;
36
+ }
37
+ export interface CreateBusinessCustomerRequest {
38
+ name: string;
39
+ phone_number: string;
40
+ business_name: string;
41
+ email: string;
42
+ address: string;
43
+ company_reg_no: string;
44
+ company_reg_date: string;
45
+ tax_id_no: string;
46
+ customers: string[];
47
+ }
48
+ export interface UpdateCustomerRequest {
49
+ id: string;
50
+ update: Partial<Customer>;
51
+ }
52
+ export interface DeleteCustomerRequest {
53
+ id: string;
54
+ }
55
+ export interface GetCustomerRequest {
56
+ id: string;
57
+ }
58
+ export interface GetCustomerByPhoneNumberRequest {
59
+ phone_number: string;
60
+ }
61
+ export interface CustomerResponseData {
62
+ customer: Partial<Customer>;
63
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Gender = void 0;
4
+ var Gender;
5
+ (function (Gender) {
6
+ Gender["MALE"] = "Male";
7
+ Gender["FEMALE"] = "Female";
8
+ })(Gender || (exports.Gender = Gender = {}));
@@ -0,0 +1,4 @@
1
+ export * from './account';
2
+ export * from './customer';
3
+ export * from './ICBA';
4
+ export * from './transaction';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./account"), exports);
18
+ __exportStar(require("./customer"), exports);
19
+ __exportStar(require("./ICBA"), exports);
20
+ __exportStar(require("./transaction"), exports);
@@ -0,0 +1,40 @@
1
+ import { Account } from './account';
2
+ export declare enum TransactionType {
3
+ CREDIT = "credit",
4
+ DEBIT = "debit"
5
+ }
6
+ export declare enum TransactionStatus {
7
+ SUCCESS = "success",
8
+ PENDING = "pending",
9
+ FAILED = "failed"
10
+ }
11
+ export interface Transaction {
12
+ id: string;
13
+ account: string;
14
+ amount: number;
15
+ source: string | Account;
16
+ destination: string | Account;
17
+ narration: string;
18
+ type: TransactionType;
19
+ status: TransactionStatus;
20
+ metadata?: Record<string, any>;
21
+ }
22
+ export interface CreateTransactionRequest {
23
+ amount: number;
24
+ account: string;
25
+ type: TransactionType;
26
+ narration: string;
27
+ metadata?: Record<string, any>;
28
+ }
29
+ export interface GetTransactionRequest {
30
+ id: string;
31
+ }
32
+ export interface GetAccountTransactionsRequest {
33
+ account: string;
34
+ }
35
+ export interface TransactionResponse {
36
+ transaction: Transaction;
37
+ }
38
+ export interface TransactionListResponse {
39
+ transactions: Transaction[];
40
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TransactionStatus = exports.TransactionType = void 0;
4
+ var TransactionType;
5
+ (function (TransactionType) {
6
+ TransactionType["CREDIT"] = "credit";
7
+ TransactionType["DEBIT"] = "debit";
8
+ })(TransactionType || (exports.TransactionType = TransactionType = {}));
9
+ var TransactionStatus;
10
+ (function (TransactionStatus) {
11
+ TransactionStatus["SUCCESS"] = "success";
12
+ TransactionStatus["PENDING"] = "pending";
13
+ TransactionStatus["FAILED"] = "failed";
14
+ })(TransactionStatus || (exports.TransactionStatus = TransactionStatus = {}));
@@ -0,0 +1,50 @@
1
+ export interface NameEnquiryRequest {
2
+ accountNumber: string;
3
+ bankCode: string;
4
+ }
5
+ export interface NameEnquiryResponse {
6
+ accountName: string;
7
+ bvn: string | null;
8
+ kyc: string | null;
9
+ sessionID: string;
10
+ institutionCode: string | null;
11
+ }
12
+ export interface BankTransferRequest {
13
+ amount: number;
14
+ beneficiaryAccountNumber: string;
15
+ beneficiaryBankCode: string;
16
+ beneficiaryAccountName: string;
17
+ beneficiaryPhoneNumber: string;
18
+ originatorAccountNumber: string;
19
+ originatorAccountName: string;
20
+ narration: string;
21
+ reference: string;
22
+ sessionID: string;
23
+ }
24
+ export interface BankTransferResponse {
25
+ transactionReference: string;
26
+ status: string;
27
+ sessionID: string;
28
+ responseCode: string;
29
+ }
30
+ export interface IntraBankTransferRequest {
31
+ sourceAccountNumber: string;
32
+ destinationAccountNumber: string;
33
+ amount: number;
34
+ reference: string;
35
+ narration?: string;
36
+ }
37
+ export interface IntraBankTransferResponse {
38
+ transactionReference?: string;
39
+ }
40
+ export interface TransactionStatusQueryRequest {
41
+ transactionReference: string;
42
+ date?: string;
43
+ amount?: string;
44
+ transactionType?: string;
45
+ }
46
+ export interface TransactionStatusQueryResponse {
47
+ status: string;
48
+ responseCode: string;
49
+ responseMessage: string;
50
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ import 'dotenv/config';
2
+ export declare function getEnv(key: string): string;
3
+ export declare function generateRandomString(length: number, charset?: string): string;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateRandomString = exports.getEnv = void 0;
4
+ require("dotenv/config");
5
+ var crypto_1 = require("crypto");
6
+ function getEnv(key) {
7
+ if (!process.env[key])
8
+ throw new Error("Missing env key ".concat(key));
9
+ return process.env[key];
10
+ }
11
+ exports.getEnv = getEnv;
12
+ function generateRandomString(length, charset) {
13
+ if (charset === void 0) { charset = 'alphanumeric'; }
14
+ var numericChars = '0123456789';
15
+ var alphabetChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
16
+ var alphanumericChars = numericChars + alphabetChars;
17
+ var charsToUse;
18
+ switch (charset) {
19
+ case 'numeric':
20
+ charsToUse = numericChars;
21
+ break;
22
+ case 'alphabet':
23
+ charsToUse = alphabetChars;
24
+ break;
25
+ case 'alphanumeric':
26
+ charsToUse = alphanumericChars;
27
+ break;
28
+ default:
29
+ throw new Error('Invalid charset type. Must be one of: "numeric", "alphabet", or "alphanumeric"');
30
+ }
31
+ var charsetLength = charsToUse.length;
32
+ var result = '';
33
+ for (var i = 0; i < length; i++) {
34
+ var randomBytesArray = (0, crypto_1.randomBytes)(1);
35
+ var randomIndex = randomBytesArray[0] % charsetLength;
36
+ result += charsToUse.charAt(randomIndex);
37
+ }
38
+ return result;
39
+ }
40
+ exports.generateRandomString = generateRandomString;
@@ -0,0 +1 @@
1
+ export declare function removeCountryCodeFromPhone(phone: string, availableCountryCodes?: string[]): string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.removeCountryCodeFromPhone = void 0;
4
+ function removeCountryCodeFromPhone(phone, availableCountryCodes) {
5
+ if (availableCountryCodes === void 0) { availableCountryCodes = ['234', '+234']; }
6
+ for (var _i = 0, availableCountryCodes_1 = availableCountryCodes; _i < availableCountryCodes_1.length; _i++) {
7
+ var code = availableCountryCodes_1[_i];
8
+ if (phone.startsWith(code)) {
9
+ phone = phone.slice(code.length);
10
+ return phone;
11
+ }
12
+ }
13
+ return phone;
14
+ }
15
+ exports.removeCountryCodeFromPhone = removeCountryCodeFromPhone;
package/index.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { CBA, ICoreBankingApplication } from './common';
2
+ export declare const initializeCoreBanking: (cba: CBA) => ICoreBankingApplication;
3
+ export * from './bank-one';
4
+ export * from './common';
package/index.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.initializeCoreBanking = void 0;
18
+ var BankOne_1 = require("./bank-one/BankOne");
19
+ var common_1 = require("./common");
20
+ var initializeCoreBanking = function (cba) {
21
+ switch (cba) {
22
+ case common_1.CBA.BANK_ONE:
23
+ return new BankOne_1.BankOne();
24
+ default:
25
+ throw new Error('Invalid Core Banking Application');
26
+ }
27
+ };
28
+ exports.initializeCoreBanking = initializeCoreBanking;
29
+ __exportStar(require("./bank-one"), exports);
30
+ __exportStar(require("./common"), exports);
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@technova-tech/connect-cba",
3
+ "version": "0.0.60",
4
+ "description": "",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "scripts": {
8
+ "build": "rm -rf lib/ && tsc -p tsconfig.json && cp package.json lib",
9
+ "test": "mocha --require ts-node/register --timeout 0 --ui bdd src/**/*.spec.ts"
10
+ },
11
+ "keywords": [],
12
+ "author": "Technova Technologies",
13
+ "license": "ISC",
14
+ "dependencies": {
15
+ "app-root-path": "^3.1.0",
16
+ "axios": "^1.6.8",
17
+ "dayjs": "^1.11.10",
18
+ "ioredis": "^5.3.2",
19
+ "reflect-metadata": "^0.2.2",
20
+ "typedi": "^0.10.0"
21
+ },
22
+ "devDependencies": {
23
+ "@types/mocha": "^10.0.6",
24
+ "@types/node": "^20.11.17",
25
+ "@types/randomstring": "^1.3.0",
26
+ "@typescript-eslint/eslint-plugin": "^6.21.0",
27
+ "dotenv": "^16.4.1",
28
+ "eslint": "^8.56.0",
29
+ "eslint-config-prettier": "^9.1.0",
30
+ "eslint-config-standard": "^17.1.0",
31
+ "eslint-plugin-node": "^11.1.0",
32
+ "eslint-plugin-prettier": "^5.1.3",
33
+ "mocha": "^10.4.0",
34
+ "prettier": "^3.2.5",
35
+ "ts-node": "^10.9.2",
36
+ "typescript": "^5.3.3"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git@github.com:technova-technologies/connect-cba.git"
41
+ }
42
+ }