@mbanq/core-sdk-js 0.20.0 → 0.22.0

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.
package/README.md CHANGED
@@ -444,8 +444,242 @@ The SDK uses a Command Pattern for all operations. Commands are created using fa
444
444
 
445
445
  | Command | Description |
446
446
  |---------|-------------|
447
+ | `GetCards` | Retrieve all cards for a specific client |
448
+ | `GetCardById` | Get detailed information about a specific card by ID |
449
+ | `GetCardAuthorizations` | List card authorizations with filtering options (status, pagination, sorting) |
450
+ | `GetCardAuthorizationById` | Retrieve detailed information about a specific card authorization including transaction details, merchant information, and optional associations (notes/media) |
447
451
  | `SendAuthorizationToCore` | Send card authorization request to core system |
448
- | `UpdateCardID` | Update card identification information |
452
+ | `UpdateCardID` | Update client card identification information (URL and QR code) |
453
+ | `GetCards` | Retrieve all cards associated with a specific client |
454
+ | `GetCardById` | Get detailed information for a specific card by ID |
455
+ | `GetCardImageUrl` | Get the URL for a card's visual representation/image |
456
+ | `GetCardAuthorizations` | Retrieve all card authorizations with filtering and pagination |
457
+ | `CreateCard` | Create a new debit or credit card (virtual or physical) |
458
+ | `ChangeCardType` | Change the product type of an existing card |
459
+ | `ActivatePhysicalCard` | Activate a physical card that has been issued |
460
+ | `OrderPhysicalCard` | Request fulfillment/shipment of a physical card |
461
+ | `SetPIN` | Generate a secure URL for card PIN changes |
462
+ | `AddCardToMobileWallet` | Provision a card for Apple Pay or Google Pay |
463
+ | `UpdateCardFeature` | Enable/disable card features (POS, online, ATM, international) |
464
+ | `UpdateCardLimit` | Update card limits and velocity rules (purchase and ATM) |
465
+
466
+ ### Card Operations Usage Examples
467
+
468
+ #### Card Creation and Management
469
+
470
+ ```javascript
471
+ import {
472
+ createInstance,
473
+ CreateCard,
474
+ GetCards,
475
+ GetCardById,
476
+ ChangeCardType,
477
+ ActivatePhysicalCard,
478
+ OrderPhysicalCard
479
+ } from '@mbanq/core-sdk-js';
480
+
481
+ const client = createInstance({
482
+ secret: 'your-secret',
483
+ signee: 'YOUR-SIGNEE',
484
+ baseUrl: 'https://api.cloud.mbanq.com',
485
+ tenantId: 'your-tenant-id'
486
+ });
487
+
488
+ // Create a debit card with existing savings account
489
+ const debitCard = await client.request(CreateCard({
490
+ productId: 123,
491
+ savingsAccountId: 456789,
492
+ clientId: 98765
493
+ }));
494
+
495
+ // Create a credit card
496
+ const creditCard = await client.request(CreateCard({
497
+ productId: 124,
498
+ creditAccountId: 456790,
499
+ userId: 555
500
+ }));
501
+
502
+ // Get all cards for a client
503
+ const clientCards = await client.request(GetCards(98765));
504
+ console.log('Client cards:', clientCards);
505
+
506
+ // Get specific card details
507
+ const cardDetails = await client.request(GetCardById(debitCard.id));
508
+ console.log('Card status:', cardDetails.status);
509
+
510
+ // Change card product type
511
+ await client.request(ChangeCardType(debitCard.id, { productId: 125 }));
512
+
513
+ // Order physical card for virtual card
514
+ const physicalCard = await client.request(OrderPhysicalCard(debitCard.id));
515
+
516
+ // Activate physical card once received
517
+ const activation = await client.request(ActivatePhysicalCard(physicalCard.id));
518
+ console.log('Card token:', activation.cardToken);
519
+ ```
520
+
521
+ #### Card Features and Limits
522
+
523
+ ```javascript
524
+ import {
525
+ UpdateCardFeature,
526
+ UpdateCardLimit
527
+ } from '@mbanq/core-sdk-js';
528
+
529
+ // Update card features
530
+ const features = await client.request(UpdateCardFeature(cardId, {
531
+ posPaymentEnabled: true,
532
+ onlinePaymentEnabled: true,
533
+ atmWithdrawalsEnabled: false,
534
+ internationalPaymentsEnabled: true,
535
+ blockedCountries: ['US', 'CA']
536
+ }));
537
+
538
+ // Update card limits and velocity rules
539
+ const limits = await client.request(UpdateCardLimit(cardId, {
540
+ purchase: [{
541
+ single: {
542
+ transactionAmount: 1000,
543
+ numberOfTransactions: 5
544
+ },
545
+ daily: {
546
+ transactionAmount: 5000,
547
+ numberOfTransactions: 20
548
+ },
549
+ monthly: {
550
+ transactionAmount: 15000,
551
+ numberOfTransactions: 100
552
+ }
553
+ }],
554
+ atm: [{
555
+ daily: {
556
+ transactionAmount: 2000,
557
+ numberOfTransactions: 10
558
+ },
559
+ weekly: {
560
+ transactionAmount: 5000,
561
+ numberOfTransactions: 25
562
+ }
563
+ }]
564
+ }));
565
+ ```
566
+
567
+ #### Mobile Wallet Integration
568
+
569
+ ```javascript
570
+ import { AddCardToMobileWallet } from '@mbanq/core-sdk-js';
571
+
572
+ // Apple Pay provisioning
573
+ const applePaySetup = await client.request(AddCardToMobileWallet(cardId, {
574
+ walletProvider: 'APPLE_PAY',
575
+ certificate1: 'apple-cert-1-data',
576
+ certificate2: 'apple-cert-2-data',
577
+ nonce: 'apple-nonce-value'
578
+ }));
579
+
580
+ // Google Pay provisioning
581
+ const googlePaySetup = await client.request(AddCardToMobileWallet(cardId, {
582
+ walletProvider: 'GOOGLE_PAY',
583
+ deviceID: 'android-device-id',
584
+ walletAccountID: 'google-wallet-account-id'
585
+ }));
586
+
587
+ console.log('Provisioning data:', applePaySetup.data.activationData);
588
+ ```
589
+
590
+ #### Card Authorization Management
591
+
592
+ ```javascript
593
+ import {
594
+ GetCardAuthorizations,
595
+ SendAuthorizationToCore,
596
+ GetCardImageUrl,
597
+ SetPIN
598
+ } from '@mbanq/core-sdk-js';
599
+
600
+ // Get card authorizations with filtering
601
+ const authorizations = await client.request(GetCardAuthorizations({
602
+ cardToken: 'card-uuid-token',
603
+ status: 'ACTIVE',
604
+ limit: 50,
605
+ offset: 0,
606
+ orderBy: 'createdAt',
607
+ sortOrder: 'desc',
608
+ isActiveCardAuthorizations: true
609
+ }));
610
+
611
+ console.log('Total authorizations:', authorizations.totalFilteredRecords);
612
+ console.log('Recent transactions:', authorizations.pageItems);
613
+
614
+ // Send authorization to core system
615
+ await client.request(SendAuthorizationToCore({
616
+ card: {
617
+ internalCardId: 'card-123',
618
+ cardType: 'DEBIT'
619
+ },
620
+ payload: {
621
+ amount: 1000,
622
+ currency: 'USD',
623
+ merchant: 'Merchant Name'
624
+ },
625
+ flag: 'AUTH_CAPTURE',
626
+ skipNotification: false
627
+ }));
628
+
629
+ // Get card image URL for display
630
+ const { imageUrl } = await client.request(GetCardImageUrl(cardId));
631
+
632
+ // Generate PIN change URL
633
+ const pinSetup = await client.request(SetPIN(cardId));
634
+ console.log('PIN change URL:', pinSetup.data);
635
+ ```
636
+
637
+ #### Card ID and Visual Updates
638
+
639
+ ```javascript
640
+ import { UpdateCardID } from '@mbanq/core-sdk-js';
641
+
642
+ // Update card identification with custom branding
643
+ await client.request(UpdateCardID({
644
+ clientId: 98765,
645
+ businessCardIDURL: 'https://your-brand.com/card-design.png',
646
+ businessCardIDQRCode: 'base64-encoded-qr-code-data'
647
+ }));
648
+ ```
649
+
650
+ ### Card Types and Features
651
+
652
+ #### Card Types
653
+ - **Debit Cards**: Linked to savings accounts for spending available balance
654
+ - **Credit Cards**: Linked to credit accounts with revolving credit limits
655
+ - **Virtual Cards**: Digital-only cards for online and mobile payments
656
+ - **Physical Cards**: Physical plastic cards with EMV chip and contactless support
657
+
658
+ #### Supported Mobile Wallets
659
+ - **Apple Pay**: iPhone, iPad, Apple Watch support
660
+ - **Google Pay**: Android devices and Google Wallet integration
661
+
662
+ #### Card Features Control
663
+ - **POS Payments**: Enable/disable point-of-sale transactions
664
+ - **Online Payments**: Control e-commerce and online purchases
665
+ - **ATM Withdrawals**: Manage cash withdrawal capabilities
666
+ - **International Payments**: Allow/restrict international transactions
667
+ - **Contactless Payments**: Tap-to-pay functionality
668
+ - **Blocked Countries**: Geographically restrict card usage
669
+
670
+ #### Velocity Limits and Controls
671
+ - **Single Transaction**: Maximum amount per transaction
672
+ - **Daily Limits**: Total amount and transaction count per day
673
+ - **Weekly Limits**: Total amount and transaction count per week
674
+ - **Monthly Limits**: Total amount and transaction count per month
675
+ - **ATM vs Purchase**: Separate limits for ATM withdrawals vs purchases
676
+
677
+ #### Authorization Management
678
+ - **Real-time Authorizations**: Process card transactions in real-time
679
+ - **Authorization History**: Track all card transaction attempts
680
+ - **Status Tracking**: Monitor authorization statuses (ACTIVE, COMPLETED, REJECTED, etc.)
681
+ - **Filtering and Search**: Find specific transactions by criteria
682
+ - **Merchant Details**: Complete transaction merchant information
449
683
 
450
684
  #### Card Product Operations
451
685
 
@@ -0,0 +1 @@
1
+ import{a as u,b as p}from"./chunk-2PLZ534I.mjs";var m=n=>{let s=[];if(!n.baseUrl)s.push("baseUrl is required");else if(typeof n.baseUrl!="string")s.push("baseUrl must be a string");else try{new URL(n.baseUrl)}catch{s.push("baseUrl must be a valid URL")}return n.axiosConfig?.timeout!==void 0&&(typeof n.axiosConfig.timeout!="number"||n.axiosConfig.timeout<0)&&s.push("timeout must be a positive number"),s};import C from"axios";import b from"jsonwebtoken";var w=(n,s)=>{if(!n)throw u({message:"Missing JWT secret",code:"missing_jwt_secret"});return b.sign({signee:s},n,{algorithm:"HS512",expiresIn:"1d"})||""},k=async(n,s,a)=>{let o={method:"POST",url:`${n}/oauth/token`,headers:{"Content-Type":"application/x-www-form-urlencoded",tenantId:s},data:a},{data:{access_token:c}}=await C.request(o);return c};var O=n=>{let s=m(n);if(s.length>0)throw u({message:`Invalid configuration: ${s.join(", ")}`,code:"invalid_config"});let a=n,o={accessToken:"",tokenType:"bearer",authConfig:null},c=async(e,t,r)=>{if(a.middlewares)for(let i of a.middlewares)e==="before"&&i.before?await i.before(t):e==="after"&&i.after?await i.after(t,r):e==="onError"&&i.onError&&await i.onError(t,r)},f=e=>{let t={...e,[o.tokenType==="jwt"?"jwtToken":"bearerToken"]:o.accessToken};return o.authConfig?.tenantId&&(t.tenantId=o.authConfig.tenantId),t},d=(e,t)=>t?{...e,axiosConfig:{...e.axiosConfig,...t.timeout&&{timeout:t.timeout},...t.keepAlive!==void 0&&{keepAlive:t.keepAlive},headers:{...e.axiosConfig?.headers,...t.headers}}}:e,l=async e=>{if(e.credential){let t=e.tenantId||a.tenantId;if(!t)throw u({message:"Tenant ID is required when using credential-based authentication",code:"missing_tenant_id"});return{token:await k(a.baseUrl,t,e.credential),type:"bearer"}}else{if(e.signee&&e.secret)return{token:w(e.secret,e.signee||""),type:"jwt"};if(e.bearerToken)return{token:e.bearerToken,type:"bearer"};if(e.jwtToken)return{token:e.jwtToken,type:"jwt"};throw u({message:"No valid authentication method provided in config",code:"missing_authentication"})}};return{connect:async e=>{let{token:t,type:r}=await l(e);o.accessToken=t,o.tokenType=r,o.authConfig=e},request:async(e,t)=>{try{if(await c("before",e),!o.accessToken)throw u({message:"No authentication token found. Please await instance.connect() first.",code:"missing_authentication"});let r=d(a,t);r=f(r);try{let i=await e.execute(r);return await c("after",e,i),i}catch(i){if(p(i)&&i.statusCode===401&&o.authConfig){let{token:T,type:h}=await l(o.authConfig);o.accessToken=T,o.tokenType=h,r=d(a,t),r=f(r);let g=await e.execute(r);return await c("after",e,g),g}else throw await c("onError",e,i),i}}catch(r){throw await c("onError",e,r),r}}}};export{O as a};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunk6M772WIBjs = require('./chunk-6M772WIB.js');var m=n=>{let s=[];if(!n.baseUrl)s.push("baseUrl is required");else if(typeof n.baseUrl!="string")s.push("baseUrl must be a string");else try{new URL(n.baseUrl)}catch (e2){s.push("baseUrl must be a valid URL")}return _optionalChain([n, 'access', _ => _.axiosConfig, 'optionalAccess', _2 => _2.timeout])!==void 0&&(typeof n.axiosConfig.timeout!="number"||n.axiosConfig.timeout<0)&&s.push("timeout must be a positive number"),s};var _axios = require('axios'); var _axios2 = _interopRequireDefault(_axios);var _jsonwebtoken = require('jsonwebtoken'); var _jsonwebtoken2 = _interopRequireDefault(_jsonwebtoken);var w=(n,s)=>{if(!n)throw _chunk6M772WIBjs.a.call(void 0, {message:"Missing JWT secret",code:"missing_jwt_secret"});return _jsonwebtoken2.default.sign({signee:s},n,{algorithm:"HS512",expiresIn:"1d"})||""},k=async(n,s,a)=>{let o={method:"POST",url:`${n}/oauth/token`,headers:{"Content-Type":"application/x-www-form-urlencoded",tenantId:s},data:a},{data:{access_token:c}}=await _axios2.default.request(o);return c};var O=n=>{let s=m(n);if(s.length>0)throw _chunk6M772WIBjs.a.call(void 0, {message:`Invalid configuration: ${s.join(", ")}`,code:"invalid_config"});let a=n,o={accessToken:"",tokenType:"bearer",authConfig:null},c=async(e,t,r)=>{if(a.middlewares)for(let i of a.middlewares)e==="before"&&i.before?await i.before(t):e==="after"&&i.after?await i.after(t,r):e==="onError"&&i.onError&&await i.onError(t,r)},f=e=>{let t={...e,[o.tokenType==="jwt"?"jwtToken":"bearerToken"]:o.accessToken};return _optionalChain([o, 'access', _3 => _3.authConfig, 'optionalAccess', _4 => _4.tenantId])&&(t.tenantId=o.authConfig.tenantId),t},d=(e,t)=>t?{...e,axiosConfig:{...e.axiosConfig,...t.timeout&&{timeout:t.timeout},...t.keepAlive!==void 0&&{keepAlive:t.keepAlive},headers:{..._optionalChain([e, 'access', _5 => _5.axiosConfig, 'optionalAccess', _6 => _6.headers]),...t.headers}}}:e,l=async e=>{if(e.credential){let t=e.tenantId||a.tenantId;if(!t)throw _chunk6M772WIBjs.a.call(void 0, {message:"Tenant ID is required when using credential-based authentication",code:"missing_tenant_id"});return{token:await k(a.baseUrl,t,e.credential),type:"bearer"}}else{if(e.signee&&e.secret)return{token:w(e.secret,e.signee||""),type:"jwt"};if(e.bearerToken)return{token:e.bearerToken,type:"bearer"};if(e.jwtToken)return{token:e.jwtToken,type:"jwt"};throw _chunk6M772WIBjs.a.call(void 0, {message:"No valid authentication method provided in config",code:"missing_authentication"})}};return{connect:async e=>{let{token:t,type:r}=await l(e);o.accessToken=t,o.tokenType=r,o.authConfig=e},request:async(e,t)=>{try{if(await c("before",e),!o.accessToken)throw _chunk6M772WIBjs.a.call(void 0, {message:"No authentication token found. Please await instance.connect() first.",code:"missing_authentication"});let r=d(a,t);r=f(r);try{let i=await e.execute(r);return await c("after",e,i),i}catch(i){if(_chunk6M772WIBjs.b.call(void 0, i)&&i.statusCode===401&&o.authConfig){let{token:T,type:h}=await l(o.authConfig);o.accessToken=T,o.tokenType=h,r=d(a,t),r=f(r);let g=await e.execute(r);return await c("after",e,g),g}else throw await c("onError",e,i),i}}catch(r){throw await c("onError",e,r),r}}}};exports.a = O;
@@ -1,9 +1,9 @@
1
- import { C as Config, a as Command, R as RequestOptions } from '../config.d-CmOFH4fX.mjs';
1
+ import { C as Config, A as AuthConfig, a as Command, R as RequestOptions } from '../config.d-3z0BBs0n.mjs';
2
2
  import 'graphql';
3
3
  import 'axios';
4
4
 
5
5
  declare const createInstance: (initialConfig: Config) => {
6
- connect: () => Promise<void>;
6
+ connect: (credentials: AuthConfig) => Promise<void>;
7
7
  request: <TInput, TOutput>(command: Command<TInput, TOutput>, options?: RequestOptions) => Promise<TOutput | undefined>;
8
8
  };
9
9
 
@@ -1,9 +1,9 @@
1
- import { C as Config, a as Command, R as RequestOptions } from '../config.d-CmOFH4fX.js';
1
+ import { C as Config, A as AuthConfig, a as Command, R as RequestOptions } from '../config.d-3z0BBs0n.js';
2
2
  import 'graphql';
3
3
  import 'axios';
4
4
 
5
5
  declare const createInstance: (initialConfig: Config) => {
6
- connect: () => Promise<void>;
6
+ connect: (credentials: AuthConfig) => Promise<void>;
7
7
  request: <TInput, TOutput>(command: Command<TInput, TOutput>, options?: RequestOptions) => Promise<TOutput | undefined>;
8
8
  };
9
9
 
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkWTF6KI43js = require('../chunk-WTF6KI43.js');require('../chunk-6M772WIB.js');exports.createInstance = _chunkWTF6KI43js.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkARR7PVSUjs = require('../chunk-ARR7PVSU.js');require('../chunk-6M772WIB.js');exports.createInstance = _chunkARR7PVSUjs.a;
@@ -1 +1 @@
1
- import{a}from"../chunk-W7K7QE4S.mjs";import"../chunk-2PLZ534I.mjs";export{a as createInstance};
1
+ import{a}from"../chunk-5SFHDAQT.mjs";import"../chunk-2PLZ534I.mjs";export{a as createInstance};