@blaxel/core 0.2.54 → 0.2.55-preview.17
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/cjs/.tsbuildinfo +1 -1
- package/dist/cjs/common/browser.js +2 -1
- package/dist/cjs/common/node.js +5 -1
- package/dist/cjs/common/sentry-browser.js +27 -0
- package/dist/cjs/common/settings.js +5 -4
- package/dist/cjs/common/webhook.js +7 -3
- package/dist/cjs/types/common/browser.d.ts +1 -0
- package/dist/cjs/types/common/node.d.ts +2 -1
- package/dist/cjs/types/common/sentry-browser.d.ts +12 -0
- package/dist/cjs-browser/.tsbuildinfo +1 -1
- package/dist/cjs-browser/common/node.js +2 -1
- package/dist/cjs-browser/common/sentry.js +11 -210
- package/dist/cjs-browser/common/settings.js +5 -4
- package/dist/cjs-browser/common/webhook.js +7 -3
- package/dist/cjs-browser/types/common/browser.d.ts +1 -0
- package/dist/cjs-browser/types/common/node.d.ts +2 -1
- package/dist/cjs-browser/types/common/sentry-browser.d.ts +12 -0
- package/dist/esm/.tsbuildinfo +1 -1
- package/dist/esm/common/browser.js +1 -0
- package/dist/esm/common/node.js +4 -1
- package/dist/esm/common/sentry-browser.js +22 -0
- package/dist/esm/common/settings.js +5 -4
- package/dist/esm/common/webhook.js +7 -3
- package/dist/esm-browser/.tsbuildinfo +1 -1
- package/dist/esm-browser/common/node.js +1 -0
- package/dist/esm-browser/common/sentry.js +11 -177
- package/dist/esm-browser/common/settings.js +5 -4
- package/dist/esm-browser/common/webhook.js +7 -3
- package/package.json +4 -2
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.dotenv = exports.path = exports.os = exports.fs = void 0;
|
|
4
|
+
exports.dotenv = exports.path = exports.os = exports.fs = exports.crypto = void 0;
|
|
5
5
|
exports.getWebSocket = getWebSocket;
|
|
6
6
|
// Browser-compatible exports for Node.js modules
|
|
7
7
|
// In browser environments, Node.js built-in modules are not available
|
|
8
8
|
// All Node.js modules are null in browser
|
|
9
|
+
exports.crypto = null;
|
|
9
10
|
exports.fs = null;
|
|
10
11
|
exports.os = null;
|
|
11
12
|
exports.path = null;
|
|
@@ -1,226 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
2
|
+
/* eslint-disable */
|
|
35
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
4
|
exports.initSentry = initSentry;
|
|
37
5
|
exports.flushSentry = flushSentry;
|
|
38
6
|
exports.isSentryInitialized = isSentryInitialized;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// Isolated Sentry client for SDK-only error tracking (doesn't interfere with user's Sentry)
|
|
43
|
-
let sentryClient = null;
|
|
44
|
-
const capturedExceptions = new Set();
|
|
45
|
-
let handlersRegistered = false;
|
|
46
|
-
// SDK path patterns to identify errors originating from our SDK
|
|
47
|
-
const SDK_PATTERNS = [
|
|
48
|
-
"@blaxel/",
|
|
49
|
-
"blaxel-sdk",
|
|
50
|
-
"/node_modules/@blaxel/",
|
|
51
|
-
"/@blaxel/core/",
|
|
52
|
-
"/@blaxel/telemetry/",
|
|
53
|
-
];
|
|
7
|
+
// Browser/Edge-compatible exports for Sentry
|
|
8
|
+
// In browser/edge environments, @sentry/node is not available
|
|
9
|
+
// All functions are no-ops
|
|
54
10
|
/**
|
|
55
|
-
*
|
|
56
|
-
* Returns true if the stack trace contains any SDK-related paths.
|
|
57
|
-
*/
|
|
58
|
-
function isFromSDK(error) {
|
|
59
|
-
const stack = error.stack || "";
|
|
60
|
-
return SDK_PATTERNS.some((pattern) => stack.includes(pattern));
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Initialize an isolated Sentry client for SDK error tracking.
|
|
64
|
-
* This creates a separate Sentry instance that won't interfere with any
|
|
65
|
-
* Sentry configuration the user might have in their application.
|
|
11
|
+
* Initialize Sentry - no-op in browser/edge environments.
|
|
66
12
|
*/
|
|
67
13
|
function initSentry() {
|
|
68
|
-
|
|
69
|
-
// Check if tracking is disabled
|
|
70
|
-
if (!settings_js_1.settings.tracking) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const dsn = settings_js_1.settings.sentryDsn;
|
|
74
|
-
if (!dsn) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
// Create an isolated Sentry client that doesn't touch the global scope
|
|
78
|
-
// This allows users to have their own Sentry.init() without conflicts
|
|
79
|
-
sentryClient = new Sentry.NodeClient({
|
|
80
|
-
dsn,
|
|
81
|
-
environment: settings_js_1.settings.env,
|
|
82
|
-
release: `sdk-typescript@${settings_js_1.settings.version}`,
|
|
83
|
-
transport: node_1.makeNodeTransport,
|
|
84
|
-
stackParser: Sentry.defaultStackParser,
|
|
85
|
-
// No integrations - we handle error capturing manually
|
|
86
|
-
integrations: [],
|
|
87
|
-
// Disable traces for the SDK client
|
|
88
|
-
tracesSampleRate: 0,
|
|
89
|
-
// Filter errors before sending - only send SDK errors
|
|
90
|
-
beforeSend(event, hint) {
|
|
91
|
-
if (event.environment !== 'dev' && event.environment !== 'prod') {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
const error = hint.originalException;
|
|
95
|
-
if (error instanceof Error) {
|
|
96
|
-
if (!isFromSDK(error)) {
|
|
97
|
-
// Drop errors that don't originate from SDK
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return event;
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
sentryClient.init();
|
|
105
|
-
// Set SDK-specific tags
|
|
106
|
-
const scope = new Sentry.Scope();
|
|
107
|
-
scope.setTag("blaxel.workspace", settings_js_1.settings.workspace);
|
|
108
|
-
scope.setTag("blaxel.version", settings_js_1.settings.version);
|
|
109
|
-
scope.setTag("blaxel.commit", settings_js_1.settings.commit);
|
|
110
|
-
scope.setClient(sentryClient);
|
|
111
|
-
// Register process handlers for uncaught errors (Node.js only)
|
|
112
|
-
// Only register once to prevent memory leaks
|
|
113
|
-
if (typeof process !== "undefined" &&
|
|
114
|
-
typeof process.on === "function" &&
|
|
115
|
-
!handlersRegistered) {
|
|
116
|
-
handlersRegistered = true;
|
|
117
|
-
// For SIGTERM/SIGINT, flush before exit
|
|
118
|
-
const signalHandler = (signal) => {
|
|
119
|
-
flushSentry(500)
|
|
120
|
-
.catch(() => {
|
|
121
|
-
// Silently fail
|
|
122
|
-
})
|
|
123
|
-
.finally(() => {
|
|
124
|
-
process.exit(signal === "SIGTERM" ? 143 : 130);
|
|
125
|
-
});
|
|
126
|
-
};
|
|
127
|
-
// Uncaught exception handler - only capture SDK errors
|
|
128
|
-
const uncaughtExceptionHandler = (error) => {
|
|
129
|
-
if (isFromSDK(error)) {
|
|
130
|
-
captureException(error);
|
|
131
|
-
}
|
|
132
|
-
// Let the default Node.js behavior handle the process exit
|
|
133
|
-
};
|
|
134
|
-
// Unhandled rejection handler - only capture SDK errors
|
|
135
|
-
const unhandledRejectionHandler = (reason) => {
|
|
136
|
-
const error = reason instanceof Error ? reason : new Error(String(reason));
|
|
137
|
-
if (isFromSDK(error)) {
|
|
138
|
-
captureException(error);
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
process.on("SIGTERM", () => signalHandler("SIGTERM"));
|
|
142
|
-
process.on("SIGINT", () => signalHandler("SIGINT"));
|
|
143
|
-
process.on("uncaughtException", uncaughtExceptionHandler);
|
|
144
|
-
process.on("unhandledRejection", unhandledRejectionHandler);
|
|
145
|
-
// Intercept console.error to capture SDK errors that are caught and logged
|
|
146
|
-
const originalConsoleError = console.error;
|
|
147
|
-
console.error = function (...args) {
|
|
148
|
-
// Call the original console.error first
|
|
149
|
-
originalConsoleError.apply(console, args);
|
|
150
|
-
// Check if any argument is an Error from SDK and capture it
|
|
151
|
-
for (const arg of args) {
|
|
152
|
-
if (arg instanceof Error && isFromSDK(arg)) {
|
|
153
|
-
captureException(arg);
|
|
154
|
-
break; // Only capture the first SDK error to avoid duplicates
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
catch (error) {
|
|
161
|
-
// Silently fail - Sentry initialization should never break the SDK
|
|
162
|
-
if (settings_js_1.settings.env !== "production") {
|
|
163
|
-
console.error("[Blaxel SDK] Error initializing Sentry:", error);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Capture an exception to the SDK's isolated Sentry client.
|
|
169
|
-
* Only errors originating from SDK code will be captured.
|
|
170
|
-
*
|
|
171
|
-
* @param error - The error to capture
|
|
172
|
-
*/
|
|
173
|
-
function captureException(error) {
|
|
174
|
-
if (sentryClient === null) {
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
// Double-check that error is from SDK (defense in depth)
|
|
178
|
-
if (!isFromSDK(error)) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
try {
|
|
182
|
-
// Create a unique identifier for this exception to avoid duplicates
|
|
183
|
-
const errorKey = `${error.name}:${error.message}:${error.stack?.slice(0, 200)}`;
|
|
184
|
-
if (capturedExceptions.has(errorKey)) {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
capturedExceptions.add(errorKey);
|
|
188
|
-
// Clean up old exception keys to prevent memory leak
|
|
189
|
-
if (capturedExceptions.size > 1000) {
|
|
190
|
-
capturedExceptions.clear();
|
|
191
|
-
}
|
|
192
|
-
// Create a scope with SDK tags and capture the exception
|
|
193
|
-
const scope = new Sentry.Scope();
|
|
194
|
-
scope.setTag("blaxel.workspace", settings_js_1.settings.workspace);
|
|
195
|
-
scope.setTag("blaxel.version", settings_js_1.settings.version);
|
|
196
|
-
scope.setTag("blaxel.commit", settings_js_1.settings.commit);
|
|
197
|
-
scope.setClient(sentryClient);
|
|
198
|
-
scope.captureException(error);
|
|
199
|
-
}
|
|
200
|
-
catch {
|
|
201
|
-
// Silently fail - error capturing should never break the SDK
|
|
202
|
-
}
|
|
14
|
+
// No-op in browser/edge environments
|
|
203
15
|
}
|
|
204
16
|
/**
|
|
205
|
-
* Flush pending Sentry events.
|
|
206
|
-
* This should be called before the process exits to ensure all events are sent.
|
|
207
|
-
*
|
|
208
|
-
* @param timeout - Maximum time in milliseconds to wait for flush (default: 2000)
|
|
17
|
+
* Flush pending Sentry events - no-op in browser/edge environments.
|
|
209
18
|
*/
|
|
210
|
-
async function flushSentry(
|
|
211
|
-
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
try {
|
|
215
|
-
await sentryClient.flush(timeout);
|
|
216
|
-
}
|
|
217
|
-
catch {
|
|
218
|
-
// Silently fail
|
|
219
|
-
}
|
|
19
|
+
async function flushSentry(_timeout = 2000) {
|
|
20
|
+
// No-op in browser/edge environments
|
|
220
21
|
}
|
|
221
22
|
/**
|
|
222
|
-
* Check if Sentry is initialized
|
|
23
|
+
* Check if Sentry is initialized - always returns false in browser/edge environments.
|
|
223
24
|
*/
|
|
224
25
|
function isSentryInitialized() {
|
|
225
|
-
return
|
|
26
|
+
return false;
|
|
226
27
|
}
|
|
@@ -9,8 +9,8 @@ const index_js_1 = require("../authentication/index.js");
|
|
|
9
9
|
const env_js_1 = require("../common/env.js");
|
|
10
10
|
const node_js_1 = require("../common/node.js");
|
|
11
11
|
// Build info - these placeholders are replaced at build time by build:replace-imports
|
|
12
|
-
const BUILD_VERSION = "0.2.
|
|
13
|
-
const BUILD_COMMIT = "
|
|
12
|
+
const BUILD_VERSION = "0.2.55-preview.17";
|
|
13
|
+
const BUILD_COMMIT = "1efcf3565af2e54805e7526888bebaf2347c5886";
|
|
14
14
|
const BUILD_SENTRY_DSN = "https://fd5e60e1c9820e1eef5ccebb84a07127@o4508714045276160.ingest.us.sentry.io/4510465864564736";
|
|
15
15
|
// Cache for config.yaml tracking value
|
|
16
16
|
let configTrackingValue = null;
|
|
@@ -169,8 +169,9 @@ class Settings {
|
|
|
169
169
|
}
|
|
170
170
|
get tracking() {
|
|
171
171
|
// Environment variable has highest priority
|
|
172
|
-
if (env_js_1.env.
|
|
173
|
-
|
|
172
|
+
if (env_js_1.env.DO_NOT_TRACK !== undefined) {
|
|
173
|
+
// DO_NOT_TRACK has inverted semantics: true means tracking disabled
|
|
174
|
+
return env_js_1.env.DO_NOT_TRACK !== "true" && env_js_1.env.DO_NOT_TRACK !== "1";
|
|
174
175
|
}
|
|
175
176
|
// Then check config.yaml
|
|
176
177
|
const configValue = getConfigTracking();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.verifyWebhookSignature = verifyWebhookSignature;
|
|
4
4
|
exports.verifyWebhookFromRequest = verifyWebhookFromRequest;
|
|
5
|
-
const
|
|
5
|
+
const node_js_1 = require("./node.js");
|
|
6
6
|
/**
|
|
7
7
|
* Verify the HMAC-SHA256 signature of a webhook callback from async-sidecar
|
|
8
8
|
*
|
|
@@ -35,6 +35,10 @@ function verifyWebhookSignature(options) {
|
|
|
35
35
|
if (!body || !signature || !secret) {
|
|
36
36
|
return false;
|
|
37
37
|
}
|
|
38
|
+
// crypto is only available in Node.js environments
|
|
39
|
+
if (!node_js_1.crypto) {
|
|
40
|
+
throw new Error('verifyWebhookSignature is only available in Node.js environments');
|
|
41
|
+
}
|
|
38
42
|
try {
|
|
39
43
|
// Verify timestamp if provided (prevents replay attacks)
|
|
40
44
|
if (timestamp) {
|
|
@@ -48,11 +52,11 @@ function verifyWebhookSignature(options) {
|
|
|
48
52
|
// Extract hex signature from "sha256=<hex>" format
|
|
49
53
|
const expectedSignature = signature.replace('sha256=', '');
|
|
50
54
|
// Compute HMAC-SHA256 signature
|
|
51
|
-
const hmac =
|
|
55
|
+
const hmac = node_js_1.crypto.createHmac('sha256', secret);
|
|
52
56
|
hmac.update(body);
|
|
53
57
|
const computedSignature = hmac.digest('hex');
|
|
54
58
|
// Timing-safe comparison to prevent timing attacks
|
|
55
|
-
return
|
|
59
|
+
return node_js_1.crypto.timingSafeEqual(Buffer.from(expectedSignature, 'hex'), Buffer.from(computedSignature, 'hex'));
|
|
56
60
|
}
|
|
57
61
|
catch {
|
|
58
62
|
// Invalid signature format or other error
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
declare let fs: typeof import("fs") | null;
|
|
2
2
|
declare let os: typeof import("os") | null;
|
|
3
3
|
declare let path: typeof import("path") | null;
|
|
4
|
+
declare let crypto: typeof import("crypto") | null;
|
|
4
5
|
declare let dotenv: typeof import("dotenv") | null;
|
|
5
6
|
export declare function getWebSocket(): Promise<any>;
|
|
6
|
-
export { dotenv, fs, os, path };
|
|
7
|
+
export { crypto, dotenv, fs, os, path };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Initialize Sentry - no-op in browser/edge environments.
|
|
3
|
+
*/
|
|
4
|
+
export declare function initSentry(): void;
|
|
5
|
+
/**
|
|
6
|
+
* Flush pending Sentry events - no-op in browser/edge environments.
|
|
7
|
+
*/
|
|
8
|
+
export declare function flushSentry(_timeout?: number): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* Check if Sentry is initialized - always returns false in browser/edge environments.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isSentryInitialized(): boolean;
|