@glasstrace/sdk 0.18.0 → 0.20.0
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/README.md +79 -0
- package/dist/{chunk-GSGX76Q5.js → chunk-5N2IR4EO.js} +146 -3
- package/dist/chunk-5N2IR4EO.js.map +1 -0
- package/dist/{chunk-XNDHQN4S.js → chunk-6JRI4OGB.js} +286 -54
- package/dist/chunk-6JRI4OGB.js.map +1 -0
- package/dist/{chunk-IOPCSX6C.js → chunk-F2TZRBEH.js} +2 -2
- package/dist/{chunk-E33Y7BQH.js → chunk-VN3GZDV6.js} +2 -2
- package/dist/{chunk-J5BW7V2D.js → chunk-YPXW2TN3.js} +2 -2
- package/dist/cli/init.cjs +548 -153
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.d.cts +48 -2
- package/dist/cli/init.d.ts +48 -2
- package/dist/cli/init.js +106 -6
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/mcp-add.cjs +66 -0
- package/dist/cli/mcp-add.cjs.map +1 -1
- package/dist/cli/mcp-add.js +2 -2
- package/dist/cli/uninit.cjs +172 -54
- package/dist/cli/uninit.cjs.map +1 -1
- package/dist/cli/uninit.d.cts +2 -0
- package/dist/cli/uninit.d.ts +2 -0
- package/dist/cli/uninit.js +2 -1
- package/dist/index.cjs +157 -34
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -12
- package/dist/index.d.ts +43 -12
- package/dist/index.js +19 -39
- package/dist/index.js.map +1 -1
- package/dist/{source-map-uploader-26QPRSCG.js → source-map-uploader-VPDZWWM2.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-GSGX76Q5.js.map +0 -1
- package/dist/chunk-XNDHQN4S.js.map +0 -1
- /package/dist/{chunk-IOPCSX6C.js.map → chunk-F2TZRBEH.js.map} +0 -0
- /package/dist/{chunk-E33Y7BQH.js.map → chunk-VN3GZDV6.js.map} +0 -0
- /package/dist/{chunk-J5BW7V2D.js.map → chunk-YPXW2TN3.js.map} +0 -0
- /package/dist/{source-map-uploader-26QPRSCG.js.map → source-map-uploader-VPDZWWM2.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -14489,7 +14489,84 @@ function createAnonApiKey() {
|
|
|
14489
14489
|
function createBuildHash(hash2) {
|
|
14490
14490
|
return BuildHashSchema.parse(hash2);
|
|
14491
14491
|
}
|
|
14492
|
-
|
|
14492
|
+
function rotr(x, n) {
|
|
14493
|
+
return (x >>> n | x << 32 - n) >>> 0;
|
|
14494
|
+
}
|
|
14495
|
+
function sha256Hex(input) {
|
|
14496
|
+
const message = new TextEncoder().encode(input);
|
|
14497
|
+
const bitLength = message.length * 8;
|
|
14498
|
+
const paddedLength = Math.ceil((message.length + 9) / 64) * 64;
|
|
14499
|
+
const padded = new Uint8Array(paddedLength);
|
|
14500
|
+
padded.set(message);
|
|
14501
|
+
padded[message.length] = 128;
|
|
14502
|
+
const view = new DataView(padded.buffer);
|
|
14503
|
+
view.setUint32(paddedLength - 8, Math.floor(bitLength / 4294967296), false);
|
|
14504
|
+
view.setUint32(paddedLength - 4, bitLength >>> 0, false);
|
|
14505
|
+
const H = new Uint32Array([
|
|
14506
|
+
1779033703,
|
|
14507
|
+
3144134277,
|
|
14508
|
+
1013904242,
|
|
14509
|
+
2773480762,
|
|
14510
|
+
1359893119,
|
|
14511
|
+
2600822924,
|
|
14512
|
+
528734635,
|
|
14513
|
+
1541459225
|
|
14514
|
+
]);
|
|
14515
|
+
const W = new Uint32Array(64);
|
|
14516
|
+
for (let offset = 0; offset < paddedLength; offset += 64) {
|
|
14517
|
+
for (let i = 0; i < 16; i++) {
|
|
14518
|
+
W[i] = view.getUint32(offset + i * 4, false);
|
|
14519
|
+
}
|
|
14520
|
+
for (let i = 16; i < 64; i++) {
|
|
14521
|
+
const s0 = rotr(W[i - 15], 7) ^ rotr(W[i - 15], 18) ^ W[i - 15] >>> 3;
|
|
14522
|
+
const s1 = rotr(W[i - 2], 17) ^ rotr(W[i - 2], 19) ^ W[i - 2] >>> 10;
|
|
14523
|
+
W[i] = W[i - 16] + s0 + W[i - 7] + s1 >>> 0;
|
|
14524
|
+
}
|
|
14525
|
+
let a = H[0];
|
|
14526
|
+
let b = H[1];
|
|
14527
|
+
let c = H[2];
|
|
14528
|
+
let d = H[3];
|
|
14529
|
+
let e = H[4];
|
|
14530
|
+
let f = H[5];
|
|
14531
|
+
let g = H[6];
|
|
14532
|
+
let h = H[7];
|
|
14533
|
+
for (let i = 0; i < 64; i++) {
|
|
14534
|
+
const S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
|
|
14535
|
+
const ch = e & f ^ ~e & g;
|
|
14536
|
+
const temp1 = h + S1 + ch + K[i] + W[i] >>> 0;
|
|
14537
|
+
const S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
|
|
14538
|
+
const maj = a & b ^ a & c ^ b & c;
|
|
14539
|
+
const temp2 = S0 + maj >>> 0;
|
|
14540
|
+
h = g;
|
|
14541
|
+
g = f;
|
|
14542
|
+
f = e;
|
|
14543
|
+
e = d + temp1 >>> 0;
|
|
14544
|
+
d = c;
|
|
14545
|
+
c = b;
|
|
14546
|
+
b = a;
|
|
14547
|
+
a = temp1 + temp2 >>> 0;
|
|
14548
|
+
}
|
|
14549
|
+
H[0] = H[0] + a >>> 0;
|
|
14550
|
+
H[1] = H[1] + b >>> 0;
|
|
14551
|
+
H[2] = H[2] + c >>> 0;
|
|
14552
|
+
H[3] = H[3] + d >>> 0;
|
|
14553
|
+
H[4] = H[4] + e >>> 0;
|
|
14554
|
+
H[5] = H[5] + f >>> 0;
|
|
14555
|
+
H[6] = H[6] + g >>> 0;
|
|
14556
|
+
H[7] = H[7] + h >>> 0;
|
|
14557
|
+
}
|
|
14558
|
+
let out = "";
|
|
14559
|
+
for (let i = 0; i < 8; i++) {
|
|
14560
|
+
out += H[i].toString(16).padStart(8, "0");
|
|
14561
|
+
}
|
|
14562
|
+
return out;
|
|
14563
|
+
}
|
|
14564
|
+
function deriveSessionId(apiKey, origin, date5, windowIndex) {
|
|
14565
|
+
const input = JSON.stringify([apiKey, origin, date5, windowIndex]);
|
|
14566
|
+
const digest = sha256Hex(input).slice(0, 16);
|
|
14567
|
+
return SessionIdSchema.parse(digest);
|
|
14568
|
+
}
|
|
14569
|
+
var DevApiKeySchema, AnonApiKeySchema, SessionIdSchema, BuildHashSchema, SdkDiagnosticCodeSchema, CaptureConfigSchema, SdkCachedConfigSchema, GlasstraceOptionsSchema, GlasstraceEnvVarsSchema, ImportGraphPayloadSchema, SdkHealthReportSchema, TierLimitsSchema, SdkInitResponseSchema, DiscoveryResponseSchema, SourceMapUploadResponseSchema, PresignedUploadRequestSchema, PresignedUploadResponseSchema, SourceMapManifestRequestSchema, SourceMapManifestResponseSchema, GLASSTRACE_ATTRIBUTE_NAMES, DEFAULT_CAPTURE_CONFIG, K;
|
|
14493
14570
|
var init_dist = __esm({
|
|
14494
14571
|
"../protocol/dist/index.js"() {
|
|
14495
14572
|
"use strict";
|
|
@@ -14668,6 +14745,72 @@ var init_dist = __esm({
|
|
|
14668
14745
|
consoleErrors: false,
|
|
14669
14746
|
errorResponseBodies: false
|
|
14670
14747
|
};
|
|
14748
|
+
K = new Uint32Array([
|
|
14749
|
+
1116352408,
|
|
14750
|
+
1899447441,
|
|
14751
|
+
3049323471,
|
|
14752
|
+
3921009573,
|
|
14753
|
+
961987163,
|
|
14754
|
+
1508970993,
|
|
14755
|
+
2453635748,
|
|
14756
|
+
2870763221,
|
|
14757
|
+
3624381080,
|
|
14758
|
+
310598401,
|
|
14759
|
+
607225278,
|
|
14760
|
+
1426881987,
|
|
14761
|
+
1925078388,
|
|
14762
|
+
2162078206,
|
|
14763
|
+
2614888103,
|
|
14764
|
+
3248222580,
|
|
14765
|
+
3835390401,
|
|
14766
|
+
4022224774,
|
|
14767
|
+
264347078,
|
|
14768
|
+
604807628,
|
|
14769
|
+
770255983,
|
|
14770
|
+
1249150122,
|
|
14771
|
+
1555081692,
|
|
14772
|
+
1996064986,
|
|
14773
|
+
2554220882,
|
|
14774
|
+
2821834349,
|
|
14775
|
+
2952996808,
|
|
14776
|
+
3210313671,
|
|
14777
|
+
3336571891,
|
|
14778
|
+
3584528711,
|
|
14779
|
+
113926993,
|
|
14780
|
+
338241895,
|
|
14781
|
+
666307205,
|
|
14782
|
+
773529912,
|
|
14783
|
+
1294757372,
|
|
14784
|
+
1396182291,
|
|
14785
|
+
1695183700,
|
|
14786
|
+
1986661051,
|
|
14787
|
+
2177026350,
|
|
14788
|
+
2456956037,
|
|
14789
|
+
2730485921,
|
|
14790
|
+
2820302411,
|
|
14791
|
+
3259730800,
|
|
14792
|
+
3345764771,
|
|
14793
|
+
3516065817,
|
|
14794
|
+
3600352804,
|
|
14795
|
+
4094571909,
|
|
14796
|
+
275423344,
|
|
14797
|
+
430227734,
|
|
14798
|
+
506948616,
|
|
14799
|
+
659060556,
|
|
14800
|
+
883997877,
|
|
14801
|
+
958139571,
|
|
14802
|
+
1322822218,
|
|
14803
|
+
1537002063,
|
|
14804
|
+
1747873779,
|
|
14805
|
+
1955562222,
|
|
14806
|
+
2024104815,
|
|
14807
|
+
2227730452,
|
|
14808
|
+
2361852424,
|
|
14809
|
+
2428436474,
|
|
14810
|
+
2756734187,
|
|
14811
|
+
3204031479,
|
|
14812
|
+
3329325298
|
|
14813
|
+
]);
|
|
14671
14814
|
}
|
|
14672
14815
|
});
|
|
14673
14816
|
|
|
@@ -16789,37 +16932,8 @@ init_env_detection();
|
|
|
16789
16932
|
// src/session.ts
|
|
16790
16933
|
init_dist();
|
|
16791
16934
|
var FOUR_HOURS_MS = 4 * 60 * 60 * 1e3;
|
|
16792
|
-
var hashFn = null;
|
|
16793
|
-
function fnv1aHash(input) {
|
|
16794
|
-
let hash2 = 2166136261;
|
|
16795
|
-
for (let i = 0; i < input.length; i++) {
|
|
16796
|
-
hash2 ^= input.charCodeAt(i);
|
|
16797
|
-
hash2 = Math.imul(hash2, 16777619);
|
|
16798
|
-
hash2 >>>= 0;
|
|
16799
|
-
}
|
|
16800
|
-
return hash2.toString(16).padStart(8, "0");
|
|
16801
|
-
}
|
|
16802
|
-
function getHashFn() {
|
|
16803
|
-
if (hashFn) return hashFn;
|
|
16804
|
-
try {
|
|
16805
|
-
const { createHash: createHash3 } = require("node:crypto");
|
|
16806
|
-
hashFn = (input) => createHash3("sha256").update(input).digest("hex").slice(0, 16);
|
|
16807
|
-
} catch {
|
|
16808
|
-
hashFn = (input) => {
|
|
16809
|
-
const h1 = fnv1aHash(input);
|
|
16810
|
-
const h2 = fnv1aHash(input + "\0");
|
|
16811
|
-
return (h1 + h2).slice(0, 16);
|
|
16812
|
-
};
|
|
16813
|
-
}
|
|
16814
|
-
return hashFn;
|
|
16815
|
-
}
|
|
16816
16935
|
var cachedGlasstraceEnv = process.env.GLASSTRACE_ENV;
|
|
16817
16936
|
var cachedPort = process.env.PORT ?? "3000";
|
|
16818
|
-
function deriveSessionId(apiKey, origin, date5, windowIndex) {
|
|
16819
|
-
const input = JSON.stringify([apiKey, origin, date5, windowIndex]);
|
|
16820
|
-
const hash2 = getHashFn()(input);
|
|
16821
|
-
return SessionIdSchema.parse(hash2);
|
|
16822
|
-
}
|
|
16823
16937
|
function getOrigin() {
|
|
16824
16938
|
if (cachedGlasstraceEnv) {
|
|
16825
16939
|
return cachedGlasstraceEnv;
|
|
@@ -18056,6 +18170,14 @@ function deriveErrorCategory(errorType) {
|
|
|
18056
18170
|
}
|
|
18057
18171
|
|
|
18058
18172
|
// src/discovery-endpoint.ts
|
|
18173
|
+
var runtimeHandlerDeprecationWarned = false;
|
|
18174
|
+
function warnRuntimeHandlerDeprecatedOnce() {
|
|
18175
|
+
if (runtimeHandlerDeprecationWarned) return;
|
|
18176
|
+
runtimeHandlerDeprecationWarned = true;
|
|
18177
|
+
console.warn(
|
|
18178
|
+
"[glasstrace] createDiscoveryHandler is deprecated. Run `npx glasstrace init` to generate a static file at public/.well-known/glasstrace.json (or static/.well-known/glasstrace.json on SvelteKit). The runtime handler will be removed in v1.0.0."
|
|
18179
|
+
);
|
|
18180
|
+
}
|
|
18059
18181
|
function isAllowedOrigin(origin) {
|
|
18060
18182
|
if (origin === null) return true;
|
|
18061
18183
|
if (origin.startsWith("chrome-extension://")) return true;
|
|
@@ -18084,6 +18206,7 @@ function createDiscoveryHandler(getAnonKey, getSessionId, getClaimState) {
|
|
|
18084
18206
|
if (url2.pathname !== "/__glasstrace/config") {
|
|
18085
18207
|
return null;
|
|
18086
18208
|
}
|
|
18209
|
+
warnRuntimeHandlerDeprecatedOnce();
|
|
18087
18210
|
const origin = request.headers.get("Origin");
|
|
18088
18211
|
const corsHeaders = buildCorsHeaders(origin);
|
|
18089
18212
|
if (request.method === "OPTIONS") {
|
|
@@ -21721,7 +21844,7 @@ function registerGlasstrace(options) {
|
|
|
21721
21844
|
setCoreState(CoreState.REGISTERING);
|
|
21722
21845
|
startRuntimeStateWriter({
|
|
21723
21846
|
projectRoot: process.cwd(),
|
|
21724
|
-
sdkVersion: "0.
|
|
21847
|
+
sdkVersion: "0.20.0"
|
|
21725
21848
|
});
|
|
21726
21849
|
const config2 = resolveConfig(options);
|
|
21727
21850
|
if (config2.verbose) {
|
|
@@ -21887,8 +22010,8 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
|
|
|
21887
22010
|
if (config2.verbose) {
|
|
21888
22011
|
console.info("[glasstrace] Background init firing.");
|
|
21889
22012
|
}
|
|
21890
|
-
const healthReport = collectHealthReport("0.
|
|
21891
|
-
const initResult = await performInit(config2, anonKeyForInit, "0.
|
|
22013
|
+
const healthReport = collectHealthReport("0.20.0");
|
|
22014
|
+
const initResult = await performInit(config2, anonKeyForInit, "0.20.0", healthReport);
|
|
21892
22015
|
if (generation !== registrationGeneration) return;
|
|
21893
22016
|
const currentState = getCoreState();
|
|
21894
22017
|
if (currentState === CoreState.SHUTTING_DOWN || currentState === CoreState.SHUTDOWN) {
|
|
@@ -21911,7 +22034,7 @@ async function backgroundInit(config2, anonKeyForInit, generation) {
|
|
|
21911
22034
|
}
|
|
21912
22035
|
maybeInstallConsoleCapture();
|
|
21913
22036
|
if (didLastInitSucceed()) {
|
|
21914
|
-
startHeartbeat(config2, anonKeyForInit, "0.
|
|
22037
|
+
startHeartbeat(config2, anonKeyForInit, "0.20.0", generation, (newApiKey, accountId) => {
|
|
21915
22038
|
setAuthState(AuthState.CLAIMING);
|
|
21916
22039
|
emitLifecycleEvent("auth:claim_started", { accountId });
|
|
21917
22040
|
setResolvedApiKey(newApiKey);
|