@dynamic-labs/logger 5.9.3 → 5.9.6
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/CHANGELOG.md +13 -1
- package/package.json +5 -4
- package/src/index.cjs +73 -36
- package/src/index.js +73 -36
- package/src/types.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
|
|
2
|
-
### [5.9.
|
|
2
|
+
### [5.9.6](https://github.com/dynamic-labs/dynamic-auth/compare/v5.9.5...v5.9.6) (2026-10-06)
|
|
3
|
+
|
|
4
|
+
### [5.9.5](https://github.com/dynamic-labs/dynamic-auth/compare/v5.9.4...v5.9.5) (2026-10-06)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
* **ton:** move encodeComment to base TonWalletConnector ([#12459](https://github.com/dynamic-labs/dynamic-auth/issues/12459)) ([647df5b](https://github.com/dynamic-labs/dynamic-auth/commit/647df5bc3986d59d89dbe31bbd3ebe1c4605ec40))
|
|
10
|
+
* **waas-svm:** apply overrideBlockhash before sponsorship ([#12319](https://github.com/dynamic-labs/dynamic-auth/issues/12319)) ([074ce3c](https://github.com/dynamic-labs/dynamic-auth/commit/074ce3c4ecfa080b683c84120fa7643e8fe064d4)), closes [#10599](https://github.com/dynamic-labs/dynamic-auth/issues/10599) [#10599](https://github.com/dynamic-labs/dynamic-auth/issues/10599) [#10599](https://github.com/dynamic-labs/dynamic-auth/issues/10599) [#10599](https://github.com/dynamic-labs/dynamic-auth/issues/10599)
|
|
11
|
+
* **wallet-book:** use phantom.com for Phantom in-app-browser links ([#12456](https://github.com/dynamic-labs/dynamic-auth/issues/12456)) ([e762553](https://github.com/dynamic-labs/dynamic-auth/commit/e7625534f8beda3e649f121e637451e2188faef6))
|
|
3
12
|
|
|
13
|
+
### [5.9.4](https://github.com/dynamic-labs/dynamic-auth/compare/v5.9.3...v5.9.4) (2026-10-02)
|
|
14
|
+
|
|
15
|
+
### [5.9.3](https://github.com/dynamic-labs/dynamic-auth/compare/v5.9.2...v5.9.3) (2026-10-02)
|
|
4
16
|
|
|
5
17
|
### Bug Fixes
|
|
6
18
|
|
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/logger",
|
|
3
|
-
"version": "5.9.
|
|
3
|
+
"version": "5.9.6",
|
|
4
4
|
"description": "A simple client side logging library used in Dynamic SDK",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@dynamic-labs/redaction": "1.1.0",
|
|
9
|
+
"eventemitter3": "5.0.1"
|
|
10
|
+
},
|
|
7
11
|
"main": "./src/index.cjs",
|
|
8
12
|
"module": "./src/index.js",
|
|
9
13
|
"types": "./src/index.d.ts",
|
|
@@ -17,8 +21,5 @@
|
|
|
17
21
|
},
|
|
18
22
|
"./package.json": "./package.json"
|
|
19
23
|
},
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"eventemitter3": "5.0.1"
|
|
22
|
-
},
|
|
23
24
|
"peerDependencies": {}
|
|
24
25
|
}
|
package/src/index.cjs
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var _tslib = require('../_virtual/_tslib.cjs');
|
|
6
6
|
var EventEmitter = require('eventemitter3');
|
|
7
|
+
var redaction = require('@dynamic-labs/redaction');
|
|
7
8
|
var MetaData = require('./MetaData/MetaData.cjs');
|
|
8
9
|
var types = require('./types.cjs');
|
|
9
10
|
var createCircularReferenceReplacer = require('./utils/createCircularReferenceReplacer.cjs');
|
|
@@ -149,16 +150,25 @@ class Logger {
|
|
|
149
150
|
}
|
|
150
151
|
captureAndSend(level, message, ...args) {
|
|
151
152
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
153
|
+
// `fetch` (not `window`) is the actual requirement: this also lets Node
|
|
154
|
+
// (which has had a global `fetch` since v18) forward logs, not just browsers.
|
|
152
155
|
if (globalState.keys.emitErrors &&
|
|
153
156
|
!IGNORE_MESSAGES.includes(message === null || message === void 0 ? void 0 : message.toString()) &&
|
|
154
|
-
typeof
|
|
157
|
+
typeof fetch !== 'undefined') {
|
|
155
158
|
this.emitHttpLogs(level, message, { args });
|
|
156
159
|
}
|
|
157
160
|
});
|
|
158
161
|
}
|
|
159
162
|
emitHttpLogs(level, message, { args = [], transformMeta = (meta) => meta }) {
|
|
160
163
|
const stack = getStack.getStack(this.emitHttpLogs);
|
|
161
|
-
|
|
164
|
+
// Captured now, not at flush time — see MessageQueueMessage.environmentId.
|
|
165
|
+
messageQueue.push({
|
|
166
|
+
args,
|
|
167
|
+
environmentId: globalState.keys.environmentId,
|
|
168
|
+
level,
|
|
169
|
+
message,
|
|
170
|
+
stack,
|
|
171
|
+
});
|
|
162
172
|
if (messageQueue.length === 1) {
|
|
163
173
|
/**
|
|
164
174
|
* Batching the logs to send them in a single request
|
|
@@ -173,43 +183,70 @@ class Logger {
|
|
|
173
183
|
try {
|
|
174
184
|
// Grab all pending messages immediately and clear the queue
|
|
175
185
|
const currentBatch = messageQueue.splice(0, messageQueue.length);
|
|
176
|
-
|
|
186
|
+
// Group by the environmentId each message was queued under (not
|
|
187
|
+
// whatever is globally current now) and send one request per
|
|
188
|
+
// group, so a concurrent Logger.setEnvironmentId() call — a
|
|
189
|
+
// different tenant/request in the same Node process — can't
|
|
190
|
+
// redirect an already-queued message to the wrong destination.
|
|
191
|
+
const batchesByEnvironmentId = new Map();
|
|
177
192
|
currentBatch.forEach((msg) => {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
+
const existing = batchesByEnvironmentId.get(msg.environmentId);
|
|
194
|
+
if (existing) {
|
|
195
|
+
existing.push(msg);
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
batchesByEnvironmentId.set(msg.environmentId, [msg]);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
yield Promise.all(Array.from(batchesByEnvironmentId.entries()).map((_a) => _tslib.__awaiter(this, [_a], void 0, function* ([environmentId, msgs]) {
|
|
202
|
+
if (!environmentId) {
|
|
203
|
+
throw new Error('Environment ID not set');
|
|
204
|
+
}
|
|
205
|
+
const messages = [];
|
|
206
|
+
msgs.forEach((msg) => {
|
|
207
|
+
var _a, _b, _c, _d, _e, _f;
|
|
208
|
+
const body = {};
|
|
209
|
+
const { objectArgs, remainingArgs } = processArgs.processArgs(msg);
|
|
210
|
+
Object.assign(body, ...objectArgs);
|
|
211
|
+
const hasWindow = typeof window !== 'undefined';
|
|
212
|
+
Object.assign(body, {
|
|
213
|
+
level: types.LogLevel[msg.level],
|
|
214
|
+
message: [msg.message, ...remainingArgs].join(' '),
|
|
215
|
+
meta: transformMeta(globalState.metaData.merge(this.metaData).get()),
|
|
216
|
+
stack: msg.stack,
|
|
217
|
+
// Node/server environments have no window/location/navigator.
|
|
218
|
+
url: hasWindow
|
|
219
|
+
? {
|
|
220
|
+
hostname: (_a = window.location) === null || _a === void 0 ? void 0 : _a.hostname,
|
|
221
|
+
origin: (_b = window.location) === null || _b === void 0 ? void 0 : _b.origin,
|
|
222
|
+
pathname: (_c = window.location) === null || _c === void 0 ? void 0 : _c.pathname,
|
|
223
|
+
port: (_d = window.location) === null || _d === void 0 ? void 0 : _d.port,
|
|
224
|
+
protocol: (_e = window.location) === null || _e === void 0 ? void 0 : _e.protocol,
|
|
225
|
+
}
|
|
226
|
+
: undefined,
|
|
227
|
+
userAgent: hasWindow
|
|
228
|
+
? (_f = window.navigator) === null || _f === void 0 ? void 0 : _f.userAgent
|
|
229
|
+
: undefined,
|
|
230
|
+
});
|
|
231
|
+
// Credential/key-material redaction (@dynamic-labs/redaction) —
|
|
232
|
+
// scrubs both denylisted keys and credential-shaped free text
|
|
233
|
+
// (JWTs, Bearer/Basic, dyn_* keys) anywhere in the payload,
|
|
234
|
+
// including inside `message`/`stack`/caller-supplied context.
|
|
235
|
+
messages.push(redaction.redact(body, redaction.DEFAULT_REDACT_KEYS));
|
|
236
|
+
});
|
|
237
|
+
yield fetch(`https://logs.dynamicauth.com/api/v1/${environmentId}`, {
|
|
238
|
+
body: JSON.stringify(messages, createLogPayloadReplacer.createLogPayloadReplacer()),
|
|
239
|
+
headers: {
|
|
240
|
+
'Content-Type': 'application/json',
|
|
193
241
|
},
|
|
194
|
-
|
|
242
|
+
// keepalive lets queued logs (e.g. wallet-creation timeout /
|
|
243
|
+
// abandonment events) flush even as the tab is unloading.
|
|
244
|
+
keepalive: true,
|
|
245
|
+
method: 'POST',
|
|
246
|
+
mode: 'cors',
|
|
247
|
+
referrerPolicy: 'origin-when-cross-origin',
|
|
195
248
|
});
|
|
196
|
-
|
|
197
|
-
});
|
|
198
|
-
if (!globalState.keys.environmentId) {
|
|
199
|
-
throw new Error('Environment ID not set');
|
|
200
|
-
}
|
|
201
|
-
yield fetch(`https://logs.dynamicauth.com/api/v1/${globalState.keys.environmentId}`, {
|
|
202
|
-
body: JSON.stringify(messages, createLogPayloadReplacer.createLogPayloadReplacer()),
|
|
203
|
-
headers: {
|
|
204
|
-
'Content-Type': 'application/json',
|
|
205
|
-
},
|
|
206
|
-
// keepalive lets queued logs (e.g. wallet-creation timeout /
|
|
207
|
-
// abandonment events) flush even as the tab is unloading.
|
|
208
|
-
keepalive: true,
|
|
209
|
-
method: 'POST',
|
|
210
|
-
mode: 'cors',
|
|
211
|
-
referrerPolicy: 'origin-when-cross-origin',
|
|
212
|
-
});
|
|
249
|
+
})));
|
|
213
250
|
}
|
|
214
251
|
catch (error) {
|
|
215
252
|
this.debug('Failed to send logs to server', error);
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from '../_virtual/_tslib.js';
|
|
2
2
|
import EventEmitter from 'eventemitter3';
|
|
3
|
+
import { redact, DEFAULT_REDACT_KEYS } from '@dynamic-labs/redaction';
|
|
3
4
|
import { MetaData } from './MetaData/MetaData.js';
|
|
4
5
|
import { LogLevel } from './types.js';
|
|
5
6
|
export { LogLevel } from './types.js';
|
|
@@ -142,16 +143,25 @@ class Logger {
|
|
|
142
143
|
}
|
|
143
144
|
captureAndSend(level, message, ...args) {
|
|
144
145
|
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
+
// `fetch` (not `window`) is the actual requirement: this also lets Node
|
|
147
|
+
// (which has had a global `fetch` since v18) forward logs, not just browsers.
|
|
145
148
|
if (globalState.keys.emitErrors &&
|
|
146
149
|
!IGNORE_MESSAGES.includes(message === null || message === void 0 ? void 0 : message.toString()) &&
|
|
147
|
-
typeof
|
|
150
|
+
typeof fetch !== 'undefined') {
|
|
148
151
|
this.emitHttpLogs(level, message, { args });
|
|
149
152
|
}
|
|
150
153
|
});
|
|
151
154
|
}
|
|
152
155
|
emitHttpLogs(level, message, { args = [], transformMeta = (meta) => meta }) {
|
|
153
156
|
const stack = getStack(this.emitHttpLogs);
|
|
154
|
-
|
|
157
|
+
// Captured now, not at flush time — see MessageQueueMessage.environmentId.
|
|
158
|
+
messageQueue.push({
|
|
159
|
+
args,
|
|
160
|
+
environmentId: globalState.keys.environmentId,
|
|
161
|
+
level,
|
|
162
|
+
message,
|
|
163
|
+
stack,
|
|
164
|
+
});
|
|
155
165
|
if (messageQueue.length === 1) {
|
|
156
166
|
/**
|
|
157
167
|
* Batching the logs to send them in a single request
|
|
@@ -166,43 +176,70 @@ class Logger {
|
|
|
166
176
|
try {
|
|
167
177
|
// Grab all pending messages immediately and clear the queue
|
|
168
178
|
const currentBatch = messageQueue.splice(0, messageQueue.length);
|
|
169
|
-
|
|
179
|
+
// Group by the environmentId each message was queued under (not
|
|
180
|
+
// whatever is globally current now) and send one request per
|
|
181
|
+
// group, so a concurrent Logger.setEnvironmentId() call — a
|
|
182
|
+
// different tenant/request in the same Node process — can't
|
|
183
|
+
// redirect an already-queued message to the wrong destination.
|
|
184
|
+
const batchesByEnvironmentId = new Map();
|
|
170
185
|
currentBatch.forEach((msg) => {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
+
const existing = batchesByEnvironmentId.get(msg.environmentId);
|
|
187
|
+
if (existing) {
|
|
188
|
+
existing.push(msg);
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
batchesByEnvironmentId.set(msg.environmentId, [msg]);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
yield Promise.all(Array.from(batchesByEnvironmentId.entries()).map((_a) => __awaiter(this, [_a], void 0, function* ([environmentId, msgs]) {
|
|
195
|
+
if (!environmentId) {
|
|
196
|
+
throw new Error('Environment ID not set');
|
|
197
|
+
}
|
|
198
|
+
const messages = [];
|
|
199
|
+
msgs.forEach((msg) => {
|
|
200
|
+
var _a, _b, _c, _d, _e, _f;
|
|
201
|
+
const body = {};
|
|
202
|
+
const { objectArgs, remainingArgs } = processArgs(msg);
|
|
203
|
+
Object.assign(body, ...objectArgs);
|
|
204
|
+
const hasWindow = typeof window !== 'undefined';
|
|
205
|
+
Object.assign(body, {
|
|
206
|
+
level: LogLevel[msg.level],
|
|
207
|
+
message: [msg.message, ...remainingArgs].join(' '),
|
|
208
|
+
meta: transformMeta(globalState.metaData.merge(this.metaData).get()),
|
|
209
|
+
stack: msg.stack,
|
|
210
|
+
// Node/server environments have no window/location/navigator.
|
|
211
|
+
url: hasWindow
|
|
212
|
+
? {
|
|
213
|
+
hostname: (_a = window.location) === null || _a === void 0 ? void 0 : _a.hostname,
|
|
214
|
+
origin: (_b = window.location) === null || _b === void 0 ? void 0 : _b.origin,
|
|
215
|
+
pathname: (_c = window.location) === null || _c === void 0 ? void 0 : _c.pathname,
|
|
216
|
+
port: (_d = window.location) === null || _d === void 0 ? void 0 : _d.port,
|
|
217
|
+
protocol: (_e = window.location) === null || _e === void 0 ? void 0 : _e.protocol,
|
|
218
|
+
}
|
|
219
|
+
: undefined,
|
|
220
|
+
userAgent: hasWindow
|
|
221
|
+
? (_f = window.navigator) === null || _f === void 0 ? void 0 : _f.userAgent
|
|
222
|
+
: undefined,
|
|
223
|
+
});
|
|
224
|
+
// Credential/key-material redaction (@dynamic-labs/redaction) —
|
|
225
|
+
// scrubs both denylisted keys and credential-shaped free text
|
|
226
|
+
// (JWTs, Bearer/Basic, dyn_* keys) anywhere in the payload,
|
|
227
|
+
// including inside `message`/`stack`/caller-supplied context.
|
|
228
|
+
messages.push(redact(body, DEFAULT_REDACT_KEYS));
|
|
229
|
+
});
|
|
230
|
+
yield fetch(`https://logs.dynamicauth.com/api/v1/${environmentId}`, {
|
|
231
|
+
body: JSON.stringify(messages, createLogPayloadReplacer()),
|
|
232
|
+
headers: {
|
|
233
|
+
'Content-Type': 'application/json',
|
|
186
234
|
},
|
|
187
|
-
|
|
235
|
+
// keepalive lets queued logs (e.g. wallet-creation timeout /
|
|
236
|
+
// abandonment events) flush even as the tab is unloading.
|
|
237
|
+
keepalive: true,
|
|
238
|
+
method: 'POST',
|
|
239
|
+
mode: 'cors',
|
|
240
|
+
referrerPolicy: 'origin-when-cross-origin',
|
|
188
241
|
});
|
|
189
|
-
|
|
190
|
-
});
|
|
191
|
-
if (!globalState.keys.environmentId) {
|
|
192
|
-
throw new Error('Environment ID not set');
|
|
193
|
-
}
|
|
194
|
-
yield fetch(`https://logs.dynamicauth.com/api/v1/${globalState.keys.environmentId}`, {
|
|
195
|
-
body: JSON.stringify(messages, createLogPayloadReplacer()),
|
|
196
|
-
headers: {
|
|
197
|
-
'Content-Type': 'application/json',
|
|
198
|
-
},
|
|
199
|
-
// keepalive lets queued logs (e.g. wallet-creation timeout /
|
|
200
|
-
// abandonment events) flush even as the tab is unloading.
|
|
201
|
-
keepalive: true,
|
|
202
|
-
method: 'POST',
|
|
203
|
-
mode: 'cors',
|
|
204
|
-
referrerPolicy: 'origin-when-cross-origin',
|
|
205
|
-
});
|
|
242
|
+
})));
|
|
206
243
|
}
|
|
207
244
|
catch (error) {
|
|
208
245
|
this.debug('Failed to send logs to server', error);
|