b5-api-client 0.0.6 → 0.0.8

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/dist/APITester.js CHANGED
@@ -72,7 +72,7 @@ function testCreateOrder() {
72
72
  paymentMethods: [
73
73
  {
74
74
  type: 'MERCADO_PAGO',
75
- username: 'blas'
75
+ alias: 'blas'
76
76
  }
77
77
  ],
78
78
  creatorId: '7b74abef-f1b2-4431-aa95-ce565893d47c'
@@ -0,0 +1,6 @@
1
+ /// <reference types="node" />
2
+ export declare function generateSecretAndHash(): {
3
+ secret: Buffer;
4
+ hash: Buffer;
5
+ hashHex: string;
6
+ };
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateSecretAndHash = void 0;
4
+ const crypto_1 = require("crypto");
5
+ function generateSecretAndHash() {
6
+ const secret = (0, crypto_1.randomBytes)(32);
7
+ const hash = (0, crypto_1.createHash)("sha256").update(new Uint8Array(secret)).digest();
8
+ const hashHex = "0x" + hash.toString("hex");
9
+ return { secret, hash, hashHex };
10
+ }
11
+ exports.generateSecretAndHash = generateSecretAndHash;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { default as P2PMarketplaceAPIClient } from './P2PMarketplaceAPIClient';
2
+ export { generateSecretAndHash } from './cryptoUtils';
2
3
  export * from './types';
package/dist/index.js CHANGED
@@ -17,7 +17,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.P2PMarketplaceAPIClient = void 0;
20
+ exports.generateSecretAndHash = exports.P2PMarketplaceAPIClient = void 0;
21
21
  var P2PMarketplaceAPIClient_1 = require("./P2PMarketplaceAPIClient");
22
22
  Object.defineProperty(exports, "P2PMarketplaceAPIClient", { enumerable: true, get: function () { return __importDefault(P2PMarketplaceAPIClient_1).default; } });
23
+ var cryptoUtils_1 = require("./cryptoUtils");
24
+ Object.defineProperty(exports, "generateSecretAndHash", { enumerable: true, get: function () { return cryptoUtils_1.generateSecretAndHash; } });
23
25
  __exportStar(require("./types"), exports);
package/dist/types.d.ts CHANGED
@@ -1,9 +1,5 @@
1
1
  export type OrderType = 'SELL' | 'BUY';
2
2
  export type OrderStatus = 'WAITING_PAYMENT' | 'WAITING_BUYER_ADDRESS' | 'PENDING' | 'ACTIVE' | 'FIAT_SENT' | 'RELEASED' | 'CLOSED' | 'DISPUTE' | 'CANCELED' | 'SUCCESS' | 'PAID_HOLD_INVOICE' | 'CANCELED_BY_ADMIN' | 'EXPIRED' | 'COMPLETED_BY_ADMIN';
3
- export interface PaymentMethod {
4
- type: string;
5
- username: string;
6
- }
7
3
  export interface TransactionStatusResponse {
8
4
  hash: string;
9
5
  block_number: number | null;
@@ -27,16 +23,21 @@ export interface Order {
27
23
  tokenCode?: string;
28
24
  fiatAmount?: string;
29
25
  fiatCode: string;
30
- paymentMethod?: PaymentMethod[];
26
+ paymentMethods?: PaymentMethod[];
31
27
  createdAt?: string;
32
28
  transaction?: string;
29
+ buyerHash?: string;
30
+ sellerHash?: string;
33
31
  }
34
32
  export interface OrderResponse {
35
33
  orders: Order[];
36
34
  }
37
35
  export interface PaymentMethod {
38
36
  type: string;
39
- username: string;
37
+ alias?: string;
38
+ cbu?: string;
39
+ fullName?: string;
40
+ entity?: string;
40
41
  }
41
42
  export interface CreateOrderRequest {
42
43
  type: OrderType;
@@ -53,6 +54,8 @@ export interface CreateOrderRequest {
53
54
  walletAddress?: string;
54
55
  creatorId?: string;
55
56
  creatorUsername?: string;
57
+ buyerHash?: string;
58
+ sellerHash?: string;
56
59
  }
57
60
  export interface GetOrdersParams {
58
61
  status?: OrderStatus[];
@@ -67,6 +70,7 @@ export interface TakeSellOrderRequest {
67
70
  buyerAddress?: string;
68
71
  fiatAmount?: string;
69
72
  username?: string;
73
+ hash?: string;
70
74
  }
71
75
  export interface TakeBuyOrderRequest {
72
76
  type: string;
@@ -74,6 +78,8 @@ export interface TakeBuyOrderRequest {
74
78
  userId: string;
75
79
  amount: string;
76
80
  username?: string;
81
+ paymentMethods?: PaymentMethod[];
82
+ hash?: string;
77
83
  }
78
84
  export interface CreateUserRequest {
79
85
  username: string;
@@ -81,6 +87,11 @@ export interface CreateUserRequest {
81
87
  export interface UpdateOrderRequest {
82
88
  status: string;
83
89
  orderId: string;
90
+ sellerId?: string;
91
+ takenAt?: string;
92
+ isLocked?: boolean;
93
+ txLock?: string;
94
+ txRelease?: string;
84
95
  }
85
96
  export interface OrderLockedEvent {
86
97
  type: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "b5-api-client",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "Escrow Backend API client",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,7 +14,6 @@
14
14
  "lodash": "^4.17.21"
15
15
  },
16
16
  "devDependencies": {
17
- "@types/axios": "^1.6.7",
18
17
  "@types/lodash": "^4.17.7",
19
18
  "@types/node": "^14.14.10",
20
19
  "ts-node": "^10.9.2",
@@ -23,4 +22,4 @@
23
22
  "engines": {
24
23
  "node": ">=18.0.0"
25
24
  }
26
- }
25
+ }
package/src/APITester.ts CHANGED
@@ -54,7 +54,7 @@ async function testCreateOrder() {
54
54
  paymentMethods: [
55
55
  {
56
56
  type: 'MERCADO_PAGO',
57
- username: 'blas'
57
+ alias: 'blas'
58
58
  }
59
59
  ],
60
60
  creatorId: '7b74abef-f1b2-4431-aa95-ce565893d47c'
@@ -0,0 +1,8 @@
1
+ import { randomBytes, createHash } from 'crypto';
2
+
3
+ export function generateSecretAndHash(): { secret: Buffer, hash: Buffer, hashHex: string } {
4
+ const secret: Buffer = randomBytes(32);
5
+ const hash: Buffer = createHash("sha256").update(new Uint8Array(secret)).digest();
6
+ const hashHex = "0x" + hash.toString("hex");
7
+ return { secret, hash, hashHex };
8
+ }
package/src/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { default as P2PMarketplaceAPIClient } from './P2PMarketplaceAPIClient';
2
+ export { generateSecretAndHash } from './cryptoUtils'
2
3
  export * from './types';
package/src/types.ts CHANGED
@@ -16,12 +16,6 @@ export type OrderStatus =
16
16
  'EXPIRED' |
17
17
  'COMPLETED_BY_ADMIN';
18
18
 
19
-
20
- export interface PaymentMethod {
21
- type: string;
22
- username: string;
23
- }
24
-
25
19
  export interface TransactionStatusResponse {
26
20
  hash: string;
27
21
  block_number: number | null;
@@ -46,9 +40,11 @@ export interface Order {
46
40
  tokenCode?: string;
47
41
  fiatAmount?: string;
48
42
  fiatCode: string;
49
- paymentMethod?: PaymentMethod[];
43
+ paymentMethods?: PaymentMethod[];
50
44
  createdAt?: string; // ISO 8601 string
51
45
  transaction?: string;
46
+ buyerHash?: string;
47
+ sellerHash?: string;
52
48
  }
53
49
 
54
50
  export interface OrderResponse {
@@ -57,7 +53,10 @@ export interface OrderResponse {
57
53
 
58
54
  export interface PaymentMethod {
59
55
  type: string;
60
- username: string;
56
+ alias?: string;
57
+ cbu?: string;
58
+ fullName?: string;
59
+ entity?: string;
61
60
  }
62
61
 
63
62
  export interface CreateOrderRequest {
@@ -75,6 +74,8 @@ export interface CreateOrderRequest {
75
74
  walletAddress?: string;
76
75
  creatorId?: string;
77
76
  creatorUsername?: string;
77
+ buyerHash?: string;
78
+ sellerHash?: string;
78
79
  }
79
80
 
80
81
  export interface GetOrdersParams {
@@ -92,6 +93,7 @@ export interface TakeSellOrderRequest {
92
93
  buyerAddress?: string;
93
94
  fiatAmount?: string;
94
95
  username?: string;
96
+ hash?: string;
95
97
  }
96
98
 
97
99
  export interface TakeBuyOrderRequest {
@@ -100,6 +102,8 @@ export interface TakeBuyOrderRequest {
100
102
  userId: string;
101
103
  amount: string;
102
104
  username?: string;
105
+ paymentMethods?: PaymentMethod[];
106
+ hash?: string;
103
107
  }
104
108
 
105
109
  export interface CreateUserRequest {
@@ -109,6 +113,11 @@ export interface CreateUserRequest {
109
113
  export interface UpdateOrderRequest {
110
114
  status: string;
111
115
  orderId: string;
116
+ sellerId?: string;
117
+ takenAt?: string;
118
+ isLocked?: boolean;
119
+ txLock?: string;
120
+ txRelease?: string;
112
121
  }
113
122
 
114
123
  export interface OrderLockedEvent {