@riocrypto/common-server 1.0.2865 → 1.0.2867

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/index.d.ts CHANGED
@@ -90,6 +90,8 @@ export * from "./models/STP-settings";
90
90
  export * from "./models/alfin-virtual-cci";
91
91
  export * from "./models/alfin-settings";
92
92
  export * from "./models/alfin-withdrawal";
93
+ export * from "./models/alfin-payin-notification";
94
+ export * from "./models/alfin-webhook-token";
93
95
  export * from "./models/dashboard-push-notification-subscription";
94
96
  export * from "./models/webauthn-credential";
95
97
  export * from "./models/admin-webauthn-credential";
package/build/index.js CHANGED
@@ -106,6 +106,8 @@ __exportStar(require("./models/STP-settings"), exports);
106
106
  __exportStar(require("./models/alfin-virtual-cci"), exports);
107
107
  __exportStar(require("./models/alfin-settings"), exports);
108
108
  __exportStar(require("./models/alfin-withdrawal"), exports);
109
+ __exportStar(require("./models/alfin-payin-notification"), exports);
110
+ __exportStar(require("./models/alfin-webhook-token"), exports);
109
111
  __exportStar(require("./models/dashboard-push-notification-subscription"), exports);
110
112
  __exportStar(require("./models/webauthn-credential"), exports);
111
113
  __exportStar(require("./models/admin-webauthn-credential"), exports);
@@ -0,0 +1,28 @@
1
+ import { Mongoose, Model, Document, HydratedDocument } from "mongoose";
2
+ import { Fiat } from "@riocrypto/common";
3
+ interface AlfinPayinNotificationAttrs {
4
+ uniqueCompositeKey: string;
5
+ trace: number;
6
+ CCI: string;
7
+ CCIV: string;
8
+ fiat?: Fiat;
9
+ amount: number;
10
+ processedAt: Date;
11
+ payload: Record<string, any>;
12
+ }
13
+ interface AlfinPayinNotificationDoc extends Document {
14
+ uniqueCompositeKey: string;
15
+ trace: number;
16
+ CCI: string;
17
+ CCIV: string;
18
+ fiat?: Fiat;
19
+ amount: number;
20
+ processedAt: Date;
21
+ payload: Record<string, any>;
22
+ reconciledMovimientoUId?: number;
23
+ }
24
+ interface AlfinPayinNotificationModel extends Model<AlfinPayinNotificationDoc> {
25
+ build(attrs: AlfinPayinNotificationAttrs): HydratedDocument<AlfinPayinNotificationDoc>;
26
+ }
27
+ declare const buildAlfinPayinNotification: (mongoose: Mongoose) => AlfinPayinNotificationModel;
28
+ export { buildAlfinPayinNotification, AlfinPayinNotificationDoc, AlfinPayinNotificationAttrs, };
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildAlfinPayinNotification = void 0;
4
+ // Records each payin notification we process so retries (Alfin resends up to 3
5
+ // times) are idempotent. Dedupe is on the composite `uniqueCompositeKey` rather
6
+ // than `trace` alone, since Alfin's Trace is not documented as globally unique.
7
+ const buildAlfinPayinNotification = (mongoose) => {
8
+ if (mongoose.models.AlfinPayinNotification) {
9
+ return mongoose.model("AlfinPayinNotification");
10
+ }
11
+ const AlfinPayinNotificationSchema = new mongoose.Schema({
12
+ uniqueCompositeKey: {
13
+ type: String,
14
+ required: true,
15
+ unique: true,
16
+ },
17
+ trace: {
18
+ type: Number,
19
+ required: true,
20
+ },
21
+ CCI: {
22
+ type: String,
23
+ },
24
+ CCIV: {
25
+ type: String,
26
+ },
27
+ fiat: {
28
+ type: String,
29
+ },
30
+ amount: {
31
+ type: Number,
32
+ },
33
+ processedAt: {
34
+ type: mongoose.Schema.Types.Date,
35
+ required: true,
36
+ },
37
+ payload: {
38
+ type: mongoose.Schema.Types.Mixed,
39
+ },
40
+ reconciledMovimientoUId: {
41
+ type: Number,
42
+ },
43
+ }, {
44
+ toJSON: {
45
+ transform(doc, ret) {
46
+ ret.id = ret._id.valueOf();
47
+ delete ret._id;
48
+ delete ret.__v;
49
+ },
50
+ },
51
+ });
52
+ // Supports the treasury import's reconciliation lookup, which searches for an
53
+ // unreconciled payin of a given currency and amount around a movement's date.
54
+ AlfinPayinNotificationSchema.index({
55
+ fiat: 1,
56
+ amount: 1,
57
+ reconciledMovimientoUId: 1,
58
+ processedAt: 1,
59
+ });
60
+ AlfinPayinNotificationSchema.statics.build = (attrs) => {
61
+ return new AlfinPayinNotification(attrs);
62
+ };
63
+ const AlfinPayinNotification = mongoose.model("AlfinPayinNotification", AlfinPayinNotificationSchema);
64
+ return AlfinPayinNotification;
65
+ };
66
+ exports.buildAlfinPayinNotification = buildAlfinPayinNotification;
@@ -0,0 +1,16 @@
1
+ import { Mongoose, Model, Document, HydratedDocument } from "mongoose";
2
+ interface AlfinWebhookTokenAttrs {
3
+ tokenHash: string;
4
+ createdAt: Date;
5
+ expiresAt: Date;
6
+ }
7
+ interface AlfinWebhookTokenDoc extends Document {
8
+ tokenHash: string;
9
+ createdAt: Date;
10
+ expiresAt: Date;
11
+ }
12
+ interface AlfinWebhookTokenModel extends Model<AlfinWebhookTokenDoc> {
13
+ build(attrs: AlfinWebhookTokenAttrs): HydratedDocument<AlfinWebhookTokenDoc>;
14
+ }
15
+ declare const buildAlfinWebhookToken: (mongoose: Mongoose) => AlfinWebhookTokenModel;
16
+ export { buildAlfinWebhookToken, AlfinWebhookTokenDoc, AlfinWebhookTokenAttrs };
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildAlfinWebhookToken = void 0;
4
+ // Session tokens we issue to Alfin so it can call our payin webhook. We only
5
+ // ever store the SHA-256 hash of the token (never the raw value), and rely on a
6
+ // TTL index to expire records automatically.
7
+ const buildAlfinWebhookToken = (mongoose) => {
8
+ if (mongoose.models.AlfinWebhookToken) {
9
+ return mongoose.model("AlfinWebhookToken");
10
+ }
11
+ const AlfinWebhookTokenSchema = new mongoose.Schema({
12
+ tokenHash: {
13
+ type: String,
14
+ required: true,
15
+ index: true,
16
+ },
17
+ createdAt: {
18
+ type: mongoose.Schema.Types.Date,
19
+ required: true,
20
+ },
21
+ expiresAt: {
22
+ type: mongoose.Schema.Types.Date,
23
+ required: true,
24
+ // TTL index: Mongo removes the document once expiresAt is reached.
25
+ expires: 0,
26
+ },
27
+ }, {
28
+ toJSON: {
29
+ transform(doc, ret) {
30
+ ret.id = ret._id.valueOf();
31
+ delete ret._id;
32
+ delete ret.__v;
33
+ },
34
+ },
35
+ });
36
+ AlfinWebhookTokenSchema.statics.build = (attrs) => {
37
+ return new AlfinWebhookToken(attrs);
38
+ };
39
+ const AlfinWebhookToken = mongoose.model("AlfinWebhookToken", AlfinWebhookTokenSchema);
40
+ return AlfinWebhookToken;
41
+ };
42
+ exports.buildAlfinWebhookToken = buildAlfinWebhookToken;
@@ -76,6 +76,9 @@ interface InternalBalancesDoc extends mongoose.Document {
76
76
  stoneXPaymentAccount: {
77
77
  [key in Fiat & Crypto]: number;
78
78
  };
79
+ cobre: {
80
+ [key in Fiat & Crypto]: number;
81
+ };
79
82
  }
80
83
  interface InternalBalancesModel extends mongoose.Model<InternalBalancesDoc> {
81
84
  build(attrs: InternalBalancesAttrs): HydratedDocument<InternalBalancesDoc>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riocrypto/common-server",
3
- "version": "1.0.2865",
3
+ "version": "1.0.2867",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "@google-cloud/secret-manager": "^5.6.0",
29
29
  "@google-cloud/storage": "^7.19.0",
30
30
  "@hyperdx/node-opentelemetry": "^0.10.3",
31
- "@riocrypto/common": "1.0.2676",
31
+ "@riocrypto/common": "1.0.2687",
32
32
  "@slack/web-api": "^7.15.0",
33
33
  "@types/express": "^4.17.25",
34
34
  "axios": "1.16.0",