dgc-core 2.0.7 → 2.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/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/pub.js +3 -2
- package/dist/task.js +10 -3
- package/package.json +1 -1
- package/dist/tw/utils.d.ts +0 -1
- package/dist/tw/utils.js +0 -19
- package/dist/tw/wallet.d.ts +0 -1
- package/dist/tw/wallet.js +0 -57
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -18,8 +18,6 @@ __exportStar(require("./types"), exports);
|
|
|
18
18
|
__exportStar(require("./db/mongo"), exports);
|
|
19
19
|
__exportStar(require("./db/mongo2"), exports);
|
|
20
20
|
__exportStar(require("./db/mongo3"), exports);
|
|
21
|
-
__exportStar(require("./tw/utils"), exports);
|
|
22
|
-
__exportStar(require("./tw/wallet"), exports);
|
|
23
21
|
__exportStar(require("./auth"), exports);
|
|
24
22
|
__exportStar(require("./chunk"), exports);
|
|
25
23
|
__exportStar(require("./env"), exports);
|
package/dist/pub.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.publishMessage = publishMessage;
|
|
4
4
|
// src/pub.ts
|
|
5
5
|
const pubsub_1 = require("@google-cloud/pubsub");
|
|
6
|
+
const logger_1 = require("./logger");
|
|
6
7
|
let cachedPubSub = null;
|
|
7
8
|
function getPubSub(projectId) {
|
|
8
9
|
if (!projectId)
|
|
@@ -26,11 +27,11 @@ async function publishMessage(projectId, topicName, envelope) {
|
|
|
26
27
|
const messageId = await topic.publishMessage({
|
|
27
28
|
data
|
|
28
29
|
});
|
|
29
|
-
|
|
30
|
+
(0, logger_1.log)(logger_1.LogLevel.INFO, 'Pub/Sub publish', { topicName, messageId });
|
|
30
31
|
return messageId;
|
|
31
32
|
}
|
|
32
33
|
catch (err) {
|
|
33
|
-
|
|
34
|
+
(0, logger_1.log)(logger_1.LogLevel.ERROR, 'publish failed', { error: err });
|
|
34
35
|
throw err;
|
|
35
36
|
}
|
|
36
37
|
}
|
package/dist/task.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.isRetryableCloudTasks = isRetryableCloudTasks;
|
|
|
4
4
|
exports.createTask = createTask;
|
|
5
5
|
// src/cloud-tasks.ts
|
|
6
6
|
const tasks_1 = require("@google-cloud/tasks");
|
|
7
|
+
const logger_1 = require("./logger");
|
|
7
8
|
const retry_1 = require("./retry");
|
|
8
9
|
const tasksClient = new tasks_1.CloudTasksClient();
|
|
9
10
|
// cloud-tasks errors can be gRPC-style (numeric code) or an Error with code string.
|
|
@@ -67,7 +68,11 @@ async function createTask(projectId, region, queueId, data, serviceAccount, audi
|
|
|
67
68
|
timeoutMs: 15000,
|
|
68
69
|
isRetryable: isRetryableCloudTasks,
|
|
69
70
|
onRetry: (err, attempt, delay) => {
|
|
70
|
-
|
|
71
|
+
(0, logger_1.log)(logger_1.LogLevel.WARNING, 'createTask retry', {
|
|
72
|
+
attempt,
|
|
73
|
+
delayMs: delay,
|
|
74
|
+
error: String(err?.message ?? err)
|
|
75
|
+
});
|
|
71
76
|
},
|
|
72
77
|
...opts.retryOptions // allow overrides
|
|
73
78
|
};
|
|
@@ -93,11 +98,13 @@ async function createTask(projectId, region, queueId, data, serviceAccount, audi
|
|
|
93
98
|
if (err?.original?.code === 6 ||
|
|
94
99
|
err?.code === 6 ||
|
|
95
100
|
String(err?.original?.code).toUpperCase().includes('ALREADY_EXISTS')) {
|
|
96
|
-
|
|
101
|
+
(0, logger_1.log)(logger_1.LogLevel.WARNING, 'createTask — task already exists, returning existing name', {
|
|
102
|
+
taskName: expectedName
|
|
103
|
+
});
|
|
97
104
|
return expectedName;
|
|
98
105
|
}
|
|
99
106
|
}
|
|
100
|
-
|
|
107
|
+
(0, logger_1.log)(logger_1.LogLevel.ERROR, 'createTask — final failure after retries', { error: err?.message ?? err });
|
|
101
108
|
throw err; // rethrow (or return null if you prefer)
|
|
102
109
|
}
|
|
103
110
|
}
|
package/package.json
CHANGED
package/dist/tw/utils.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isValidWebhookSignature(secret: string, body: string, signature: string): boolean;
|
package/dist/tw/utils.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isValidWebhookSignature = isValidWebhookSignature;
|
|
7
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
-
const generateSignature = (body, secret) => {
|
|
9
|
-
return crypto_1.default.createHmac('sha256', secret).update(body).digest('hex');
|
|
10
|
-
};
|
|
11
|
-
function isValidWebhookSignature(secret, body, signature) {
|
|
12
|
-
const expectedSignature = generateSignature(body, secret);
|
|
13
|
-
const expectedBuffer = Buffer.from(expectedSignature);
|
|
14
|
-
const signatureBuffer = Buffer.from(signature);
|
|
15
|
-
if (expectedBuffer.length !== signatureBuffer.length) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
return crypto_1.default.timingSafeEqual(expectedBuffer, signatureBuffer);
|
|
19
|
-
}
|
package/dist/tw/wallet.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function pregenerateInAppWallet(twClientId: string, twSecretKey: string, email: string): Promise<string | null>;
|
package/dist/tw/wallet.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.pregenerateInAppWallet = pregenerateInAppWallet;
|
|
7
|
-
// src/tw/wallet.ts
|
|
8
|
-
const axios_1 = __importDefault(require("axios"));
|
|
9
|
-
const retry_1 = require("../retry");
|
|
10
|
-
async function pregenerateInAppWallet(twClientId, twSecretKey, email) {
|
|
11
|
-
if (!twClientId || !twSecretKey || !email) {
|
|
12
|
-
console.error('Missing client id or secret or email');
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
const doRequest = async () => {
|
|
16
|
-
const res = await axios_1.default.post('https://in-app-wallet.thirdweb.com/api/v1/pregenerate', { strategy: 'email', email }, {
|
|
17
|
-
headers: {
|
|
18
|
-
'Content-Type': 'application/json',
|
|
19
|
-
'x-client-id': twClientId,
|
|
20
|
-
'x-secret-key': twSecretKey
|
|
21
|
-
},
|
|
22
|
-
timeout: 10000
|
|
23
|
-
});
|
|
24
|
-
const wallet = res.data?.wallet;
|
|
25
|
-
if (!wallet || !wallet.address) {
|
|
26
|
-
// server returned 2xx but unexpected shape — don't retry, treat as final failure
|
|
27
|
-
console.error('Invalid wallet response shape', { status: res.status, data: res.data });
|
|
28
|
-
throw new Error('Invalid wallet response');
|
|
29
|
-
}
|
|
30
|
-
return wallet.address;
|
|
31
|
-
};
|
|
32
|
-
const opts = {
|
|
33
|
-
retries: 3,
|
|
34
|
-
baseDelayMs: 300,
|
|
35
|
-
maxDelayMs: 2000,
|
|
36
|
-
timeoutMs: 15000,
|
|
37
|
-
isRetryable: retry_1.isRetryableAxios,
|
|
38
|
-
onRetry: (err, attempt, delay) => {
|
|
39
|
-
console.warn(`pregenerateInAppWallet: retry #${attempt} in ${delay}ms — ${String(err?.message)}`);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
try {
|
|
43
|
-
const address = await (0, retry_1.retry)(() => doRequest(), opts);
|
|
44
|
-
return address;
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
|
-
}
|
|
47
|
-
catch (err) {
|
|
48
|
-
// final failure after retries
|
|
49
|
-
console.error('pregenerateInAppWallet: final failure', {
|
|
50
|
-
message: err?.message,
|
|
51
|
-
// include axios response data when possible
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
|
-
responseData: err?.response?.data ?? err?.cause ?? err.original ?? null
|
|
54
|
-
});
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
}
|