@riocrypto/common-server 1.0.2852 → 1.0.2853
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/clients/axios-with-logging.js +19 -3
- package/build/helpers/sanitize-crypto-address-doc.js +1 -0
- package/build/helpers/sanitize-user-doc.js +1 -0
- package/build/models/crypto-address.d.ts +4 -0
- package/build/models/crypto-address.js +6 -0
- package/build/models/user.d.ts +4 -0
- package/build/models/user.js +7 -0
- package/package.json +2 -2
|
@@ -6,6 +6,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.buildAxiosWithLogging = void 0;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
8
|
const logger_1 = __importDefault(require("../services/logger"));
|
|
9
|
+
// Cap how much of a request/response body we serialize into a single log line.
|
|
10
|
+
// The full body is essentially never needed for observability, and large
|
|
11
|
+
// exchange payloads (deposit/withdrawal history, order lists, transfer lists)
|
|
12
|
+
// otherwise flood the logs. Only the log string is truncated - the value
|
|
13
|
+
// returned to callers (and rejected on errors) still carries the full data.
|
|
14
|
+
const MAX_LOG_BODY_LENGTH = 1000;
|
|
15
|
+
function stringifyForLog(data) {
|
|
16
|
+
const serialized = JSON.stringify(data);
|
|
17
|
+
if (serialized === undefined) {
|
|
18
|
+
return "undefined";
|
|
19
|
+
}
|
|
20
|
+
if (serialized.length <= MAX_LOG_BODY_LENGTH) {
|
|
21
|
+
return serialized;
|
|
22
|
+
}
|
|
23
|
+
return `${serialized.slice(0, MAX_LOG_BODY_LENGTH)}...[truncated ${serialized.length - MAX_LOG_BODY_LENGTH} chars]`;
|
|
24
|
+
}
|
|
9
25
|
function buildAxiosWithLogging() {
|
|
10
26
|
const axiosWithLogging = axios_1.default.create();
|
|
11
27
|
const sensitiveSubstrings = [
|
|
@@ -89,7 +105,7 @@ function buildAxiosWithLogging() {
|
|
|
89
105
|
// Mask sensitive headers in the configuration
|
|
90
106
|
const maskedHeaders = maskHeaders(customConfig.headers);
|
|
91
107
|
// Combine and log the full request configuration with masked headers
|
|
92
|
-
const logMessage = `Request: method=${customConfig.method}, url=${maskUrl(customConfig.url)}, headers=${JSON.stringify(maskedHeaders)}, data=${
|
|
108
|
+
const logMessage = `Request: method=${customConfig.method}, url=${maskUrl(customConfig.url)}, headers=${JSON.stringify(maskedHeaders)}, data=${stringifyForLog(maskData(customConfig.data))}`;
|
|
93
109
|
((_a = logger_1.default.getLogger()) === null || _a === void 0 ? void 0 : _a.info(logMessage)) || console.log(logMessage);
|
|
94
110
|
}
|
|
95
111
|
return config;
|
|
@@ -107,7 +123,7 @@ function buildAxiosWithLogging() {
|
|
|
107
123
|
// Check if logging is disabled for this request
|
|
108
124
|
if (!customConfig.skipLogging) {
|
|
109
125
|
// Combine and log the full response details
|
|
110
|
-
const logMessage = `Response: url=${maskUrl(customConfig.url)}, status=${response.status}, data=${
|
|
126
|
+
const logMessage = `Response: url=${maskUrl(customConfig.url)}, status=${response.status}, data=${stringifyForLog(maskData(response.data))}`;
|
|
111
127
|
((_a = logger_1.default.getLogger()) === null || _a === void 0 ? void 0 : _a.info(logMessage)) || console.log(logMessage);
|
|
112
128
|
}
|
|
113
129
|
return response;
|
|
@@ -116,7 +132,7 @@ function buildAxiosWithLogging() {
|
|
|
116
132
|
// Combine and log the response error details without headers
|
|
117
133
|
let logMessage = `Response Error: url=${maskUrl((_a = error.config) === null || _a === void 0 ? void 0 : _a.url)}, message=${error.message}`;
|
|
118
134
|
if (error.response) {
|
|
119
|
-
logMessage += `, status=${error.response.status}, data=${
|
|
135
|
+
logMessage += `, status=${error.response.status}, data=${stringifyForLog(maskData(error.response.data))}`;
|
|
120
136
|
}
|
|
121
137
|
((_b = logger_1.default.getLogger()) === null || _b === void 0 ? void 0 : _b.info(logMessage)) || console.log(logMessage);
|
|
122
138
|
return Promise.reject({
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.sanitizeUserDoc = void 0;
|
|
4
4
|
const sanitizeUserDoc = (doc) => {
|
|
5
5
|
const obj = doc.toJSON();
|
|
6
|
+
delete obj.privyUserId;
|
|
6
7
|
delete obj.authorizedPhoneNumbers;
|
|
7
8
|
delete obj.authIds;
|
|
8
9
|
delete obj.cosignerGroupId;
|
|
@@ -14,6 +14,8 @@ interface CryptoAddressAttrs {
|
|
|
14
14
|
fireblocksExternalWalletId?: string;
|
|
15
15
|
isFireblocksWhitelisted?: boolean;
|
|
16
16
|
availablePayoutAdvancesAmount?: number;
|
|
17
|
+
isPrivyWallet?: boolean;
|
|
18
|
+
privyWalletId?: string;
|
|
17
19
|
}
|
|
18
20
|
interface CryptoAddressDoc extends mongoose.Document {
|
|
19
21
|
createdAt: Date;
|
|
@@ -29,6 +31,8 @@ interface CryptoAddressDoc extends mongoose.Document {
|
|
|
29
31
|
fireblocksExternalWalletId?: string;
|
|
30
32
|
isFireblocksWhitelisted?: boolean;
|
|
31
33
|
availablePayoutAdvancesAmount?: number;
|
|
34
|
+
isPrivyWallet?: boolean;
|
|
35
|
+
privyWalletId?: string;
|
|
32
36
|
}
|
|
33
37
|
interface CryptoAddressModel extends mongoose.Model<CryptoAddressDoc> {
|
|
34
38
|
build(attrs: CryptoAddressAttrs): HydratedDocument<CryptoAddressDoc>;
|
package/build/models/user.d.ts
CHANGED
|
@@ -18,6 +18,8 @@ interface UserAttrs {
|
|
|
18
18
|
phoneNumber?: string;
|
|
19
19
|
email: string;
|
|
20
20
|
cosignerGroupId?: string;
|
|
21
|
+
privyUserId?: string;
|
|
22
|
+
privyRegisteredAt?: Date;
|
|
21
23
|
attributes?: UserAttribute[];
|
|
22
24
|
brokerId?: string;
|
|
23
25
|
platformFeeRanges?: {
|
|
@@ -163,6 +165,8 @@ interface UserDoc extends Document {
|
|
|
163
165
|
phoneNumber?: string;
|
|
164
166
|
email: string;
|
|
165
167
|
cosignerGroupId?: string;
|
|
168
|
+
privyUserId?: string;
|
|
169
|
+
privyRegisteredAt?: Date;
|
|
166
170
|
attributes?: UserAttribute[];
|
|
167
171
|
brokerId?: string;
|
|
168
172
|
platformFeeRanges?: {
|
package/build/models/user.js
CHANGED
|
@@ -32,6 +32,12 @@ const buildUser = (mongoose) => {
|
|
|
32
32
|
cosignerGroupId: {
|
|
33
33
|
type: String,
|
|
34
34
|
},
|
|
35
|
+
privyUserId: {
|
|
36
|
+
type: String,
|
|
37
|
+
},
|
|
38
|
+
privyRegisteredAt: {
|
|
39
|
+
type: Date,
|
|
40
|
+
},
|
|
35
41
|
attioRecordId: {
|
|
36
42
|
type: String,
|
|
37
43
|
},
|
|
@@ -415,6 +421,7 @@ const buildUser = (mongoose) => {
|
|
|
415
421
|
ret.id = ret._id.valueOf();
|
|
416
422
|
delete ret._id;
|
|
417
423
|
delete ret.__v;
|
|
424
|
+
delete ret.privyUserId;
|
|
418
425
|
},
|
|
419
426
|
},
|
|
420
427
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riocrypto/common-server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2853",
|
|
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.
|
|
31
|
+
"@riocrypto/common": "1.0.2654",
|
|
32
32
|
"@slack/web-api": "^7.15.0",
|
|
33
33
|
"@types/express": "^4.17.25",
|
|
34
34
|
"axios": "1.16.0",
|