@riocrypto/common-server 1.0.1993 → 1.0.1995
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/build/helpers/generate-idempotency-key-from-order.d.ts +2 -0
- package/build/helpers/generate-idempotency-key-from-order.js +16 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/models/bank-payout.d.ts +2 -0
- package/build/models/coincover-transaction.d.ts +2 -0
- package/build/models/coincover-transaction.js +3 -0
- package/build/models/fireblocks-transfer.d.ts +2 -0
- package/build/models/fireblocks-transfer.js +3 -0
- package/build/models/invoice.d.ts +2 -0
- package/build/models/invoice.js +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateIdempotencyKeyFromOrder = void 0;
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
const generateIdempotencyKeyFromOrder = (order) => {
|
|
6
|
+
const orderMongoId = order.id;
|
|
7
|
+
const orderVersion = order.version.toString();
|
|
8
|
+
// Create a consistent string to hash
|
|
9
|
+
const inputString = `${orderMongoId}-${orderVersion}`;
|
|
10
|
+
// Create a SHA-1 hash of the input string
|
|
11
|
+
const hash = (0, crypto_1.createHash)("sha1").update(inputString).digest("hex");
|
|
12
|
+
// Format as UUID v5
|
|
13
|
+
return `${hash.slice(0, 8)}-${hash.slice(8, 12)}-5${hash.slice(13, 16)}-${((parseInt(hash.slice(16, 18), 16) & 0x3f) |
|
|
14
|
+
0x80).toString(16)}${hash.slice(18, 20)}-${hash.slice(20, 32)}`;
|
|
15
|
+
};
|
|
16
|
+
exports.generateIdempotencyKeyFromOrder = generateIdempotencyKeyFromOrder;
|
package/build/index.d.ts
CHANGED
|
@@ -104,3 +104,4 @@ export * from "./helpers/generate-payment-reference";
|
|
|
104
104
|
export * from "./helpers/get-order-from-reference";
|
|
105
105
|
export * from "./helpers/send-with-xss-guard";
|
|
106
106
|
export * from "./helpers/generate-idempotency-key-from-mongo-id";
|
|
107
|
+
export * from "./helpers/generate-idempotency-key-from-order";
|
package/build/index.js
CHANGED
|
@@ -120,3 +120,4 @@ __exportStar(require("./helpers/generate-payment-reference"), exports);
|
|
|
120
120
|
__exportStar(require("./helpers/get-order-from-reference"), exports);
|
|
121
121
|
__exportStar(require("./helpers/send-with-xss-guard"), exports);
|
|
122
122
|
__exportStar(require("./helpers/generate-idempotency-key-from-mongo-id"), exports);
|
|
123
|
+
__exportStar(require("./helpers/generate-idempotency-key-from-order"), exports);
|
|
@@ -2,6 +2,7 @@ import { Processor } from "@riocrypto/common";
|
|
|
2
2
|
import { Mongoose, Model, Document } from "mongoose";
|
|
3
3
|
interface BankPayoutAttrs {
|
|
4
4
|
orderId: string;
|
|
5
|
+
orderVersion: number;
|
|
5
6
|
bankAccountId: string;
|
|
6
7
|
originBank: Processor;
|
|
7
8
|
status: "initialized" | "processing" | "complete" | "failed" | "cancelled";
|
|
@@ -14,6 +15,7 @@ interface BankPayoutAttrs {
|
|
|
14
15
|
}
|
|
15
16
|
interface BankPayoutDoc extends Document {
|
|
16
17
|
orderId: string;
|
|
18
|
+
orderVersion: number;
|
|
17
19
|
bankAccountId: string;
|
|
18
20
|
originBank: Processor;
|
|
19
21
|
status: "initialized" | "processing" | "complete" | "failed" | "cancelled";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Mongoose, Model, Document } from "mongoose";
|
|
2
2
|
interface CoincoverTransactionAttrs {
|
|
3
3
|
coincoverTransactionId: string;
|
|
4
|
+
orderVersion?: number;
|
|
4
5
|
status: "GREEN" | "RED";
|
|
5
6
|
rejectionCode?: string;
|
|
6
7
|
orderId?: string;
|
|
@@ -16,6 +17,7 @@ interface CoincoverTransactionDoc extends Document {
|
|
|
16
17
|
rejectionCode?: string;
|
|
17
18
|
orderId?: string;
|
|
18
19
|
orderPart?: number;
|
|
20
|
+
orderVersion?: number;
|
|
19
21
|
}
|
|
20
22
|
declare const buildCoincoverTransaction: (mongoose: Mongoose) => CoincoverTransactionModel;
|
|
21
23
|
export { buildCoincoverTransaction, CoincoverTransactionDoc, CoincoverTransactionAttrs, };
|
|
@@ -3,6 +3,7 @@ interface FireblocksTransferAttrs {
|
|
|
3
3
|
userId?: string;
|
|
4
4
|
type: "transaction" | "addressVerification" | "liquidityOrder";
|
|
5
5
|
orderId?: string;
|
|
6
|
+
orderVersion?: number;
|
|
6
7
|
multipartLiquidityOrderId?: string;
|
|
7
8
|
addressVerificationId?: string;
|
|
8
9
|
fireblocksTransferId?: string;
|
|
@@ -18,6 +19,7 @@ interface FireblocksTransferDoc extends mongoose.Document {
|
|
|
18
19
|
userId?: string;
|
|
19
20
|
type: "transaction" | "addressVerification" | "liquidityOrder";
|
|
20
21
|
orderId?: string;
|
|
22
|
+
orderVersion?: number;
|
|
21
23
|
multipartLiquidityOrderId?: string;
|
|
22
24
|
addressVerificationId?: string;
|
|
23
25
|
fireblocksTransferId?: string;
|
|
@@ -5,6 +5,7 @@ interface InvoiceAttrs {
|
|
|
5
5
|
status: "created" | "completed" | "failed";
|
|
6
6
|
userId: string;
|
|
7
7
|
orderId: string;
|
|
8
|
+
orderVersion: number;
|
|
8
9
|
country: Country;
|
|
9
10
|
provider: string;
|
|
10
11
|
providerId: string;
|
|
@@ -16,6 +17,7 @@ interface InvoiceDoc extends mongoose.Document {
|
|
|
16
17
|
status: "created" | "completed" | "failed";
|
|
17
18
|
userId: string;
|
|
18
19
|
orderId: string;
|
|
20
|
+
orderVersion: number;
|
|
19
21
|
country: Country;
|
|
20
22
|
provider: string;
|
|
21
23
|
providerId: string;
|
package/build/models/invoice.js
CHANGED