@dynamic-labs-sdk/client 0.21.0 → 0.22.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/dist/{InvalidParamError-D7XZbzuT.esm.js → InvalidParamError-CxahHqE2.esm.js} +458 -11
- package/dist/InvalidParamError-CxahHqE2.esm.js.map +1 -0
- package/dist/{InvalidParamError-CIGCphfb.cjs.js → InvalidParamError-D7xRBKr4.cjs.js} +506 -35
- package/dist/InvalidParamError-D7xRBKr4.cjs.js.map +1 -0
- package/dist/{NotWaasWalletAccountError-BvzlkqKx.esm.js → NotWaasWalletAccountError-CoqWYjd1.esm.js} +18 -6
- package/dist/{NotWaasWalletAccountError-BvzlkqKx.esm.js.map → NotWaasWalletAccountError-CoqWYjd1.esm.js.map} +1 -1
- package/dist/{NotWaasWalletAccountError-DOi9OAsI.cjs.js → NotWaasWalletAccountError-Da0wXVcL.cjs.js} +19 -7
- package/dist/NotWaasWalletAccountError-Da0wXVcL.cjs.js.map +1 -0
- package/dist/client/defaultClient/defaultClient.d.ts.map +1 -1
- package/dist/core.cjs.js +121 -49
- package/dist/core.cjs.js.map +1 -1
- package/dist/core.esm.js +82 -10
- package/dist/core.esm.js.map +1 -1
- package/dist/errors/base/BaseError.d.ts.map +1 -1
- package/dist/exports/index.d.ts +1 -1
- package/dist/exports/index.d.ts.map +1 -1
- package/dist/{getNetworkProviderFromNetworkId-yH4_BUi0.esm.js → getNetworkProviderFromNetworkId-DFfDAd0n.esm.js} +264 -12
- package/dist/getNetworkProviderFromNetworkId-DFfDAd0n.esm.js.map +1 -0
- package/dist/{getNetworkProviderFromNetworkId-DcEjbjOm.cjs.js → getNetworkProviderFromNetworkId-nk9uXEoJ.cjs.js} +321 -69
- package/dist/getNetworkProviderFromNetworkId-nk9uXEoJ.cjs.js.map +1 -0
- package/dist/{getSignedSessionId-DPZjqpdm.cjs.js → getSignedSessionId-BVPDe38W.cjs.js} +33 -9
- package/dist/{getSignedSessionId-DPZjqpdm.cjs.js.map → getSignedSessionId-BVPDe38W.cjs.js.map} +1 -1
- package/dist/{getSignedSessionId-CADCZ36G.esm.js → getSignedSessionId-Bpb-PAHO.esm.js} +30 -6
- package/dist/{getSignedSessionId-CADCZ36G.esm.js.map → getSignedSessionId-Bpb-PAHO.esm.js.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-nfQS96Xr.cjs.js → getVerifiedCredentialForWalletAccount-C8Po-OFi.cjs.js} +164 -56
- package/dist/getVerifiedCredentialForWalletAccount-C8Po-OFi.cjs.js.map +1 -0
- package/dist/{getVerifiedCredentialForWalletAccount--OXuJ-DH.esm.js → getVerifiedCredentialForWalletAccount-C8SCA6xu.esm.js} +118 -10
- package/dist/getVerifiedCredentialForWalletAccount-C8SCA6xu.esm.js.map +1 -0
- package/dist/index.cjs.js +1328 -320
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1229 -221
- package/dist/index.esm.js.map +1 -1
- package/dist/{isMfaRequiredForAction-Bq5ETrIg.cjs.js → isMfaRequiredForAction-BOZQJorF.cjs.js} +32 -8
- package/dist/isMfaRequiredForAction-BOZQJorF.cjs.js.map +1 -0
- package/dist/{isMfaRequiredForAction-C4DOmn6q.esm.js → isMfaRequiredForAction-DFFSz7P4.esm.js} +29 -5
- package/dist/isMfaRequiredForAction-DFFSz7P4.esm.js.map +1 -0
- package/dist/modules/apiClient/utils/convertToApiErrorMiddleware/convertToApiErrorMiddleware.d.ts.map +1 -1
- package/dist/modules/checkout/checkout.types.d.ts +1 -1
- package/dist/modules/checkout/checkout.types.d.ts.map +1 -1
- package/dist/modules/checkout/submitCheckoutTransaction/submitCheckoutTransaction.d.ts.map +1 -1
- package/dist/modules/clientEvents/clientEvents.d.ts.map +1 -1
- package/dist/modules/legacyWalletBook/getWalletConnectCatalog/getChainFromWalletSchema/getChainFromWalletSchema.d.ts.map +1 -1
- package/dist/modules/projectSettings/fetchProjectSettings/fetchProjectSettings.d.ts +1 -2
- package/dist/modules/projectSettings/fetchProjectSettings/fetchProjectSettings.d.ts.map +1 -1
- package/dist/modules/wallets/proveWalletAccountOwnership/proveWalletAccountOwnership.d.ts +1 -1
- package/dist/modules/wallets/proveWalletAccountOwnership/proveWalletAccountOwnership.d.ts.map +1 -1
- package/dist/modules/wallets/utils/getSignInMessage/getSignInMessage.d.ts +2 -1
- package/dist/modules/wallets/utils/getSignInMessage/getSignInMessage.d.ts.map +1 -1
- package/dist/modules/wallets/walletProvider/walletProvider.types.d.ts +8 -1
- package/dist/modules/wallets/walletProvider/walletProvider.types.d.ts.map +1 -1
- package/dist/services/instrumentation/connectLoggerToInstrumentation/connectLoggerToInstrumentation.d.ts.map +1 -1
- package/dist/services/instrumentation/createInstrumentation/createInstrumentation.d.ts.map +1 -1
- package/dist/services/instrumentation/instrumentFunction/instrumentFunction.d.ts +1 -0
- package/dist/services/instrumentation/instrumentFunction/instrumentFunction.d.ts.map +1 -1
- package/dist/services/instrumentation/instrumentation.types.d.ts +13 -1
- package/dist/services/instrumentation/instrumentation.types.d.ts.map +1 -1
- package/dist/services/instrumentation/scrubParameters/scrubParameters.d.ts.map +1 -1
- package/dist/services/instrumentation/transports/createDynamicTransport/createDynamicTransport.d.ts.map +1 -1
- package/dist/services/realtime/createRealtimeService/createRealtimeService.d.ts.map +1 -1
- package/dist/services/storage/createStorage/formatForStorage/storageFormat.d.ts.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/utils/isMobile/isMobile.d.ts.map +1 -1
- package/dist/waas.cjs.js +12 -11
- package/dist/waas.cjs.js.map +1 -1
- package/dist/waas.esm.js +11 -10
- package/dist/waas.esm.js.map +1 -1
- package/dist/waasCore.cjs.js +26 -26
- package/dist/waasCore.cjs.js.map +1 -1
- package/dist/waasCore.esm.js +25 -25
- package/dist/waasCore.esm.js.map +1 -1
- package/package.json +3 -3
- package/dist/InvalidParamError-CIGCphfb.cjs.js.map +0 -1
- package/dist/InvalidParamError-D7XZbzuT.esm.js.map +0 -1
- package/dist/NotWaasWalletAccountError-DOi9OAsI.cjs.js.map +0 -1
- package/dist/getNetworkProviderFromNetworkId-DcEjbjOm.cjs.js.map +0 -1
- package/dist/getNetworkProviderFromNetworkId-yH4_BUi0.esm.js.map +0 -1
- package/dist/getVerifiedCredentialForWalletAccount--OXuJ-DH.esm.js.map +0 -1
- package/dist/getVerifiedCredentialForWalletAccount-nfQS96Xr.cjs.js.map +0 -1
- package/dist/isMfaRequiredForAction-Bq5ETrIg.cjs.js.map +0 -1
- package/dist/isMfaRequiredForAction-C4DOmn6q.esm.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
const require_getNetworkProviderFromNetworkId = require('./getNetworkProviderFromNetworkId-
|
|
1
|
+
const require_getNetworkProviderFromNetworkId = require('./getNetworkProviderFromNetworkId-nk9uXEoJ.cjs.js');
|
|
2
2
|
let _dynamic_labs_sdk_api_core = require("@dynamic-labs/sdk-api-core");
|
|
3
3
|
|
|
4
4
|
//#region package.json
|
|
5
5
|
var name = "@dynamic-labs-sdk/client";
|
|
6
|
-
var version = "0.
|
|
6
|
+
var version = "0.22.0";
|
|
7
7
|
var dependencies = {
|
|
8
8
|
"@dynamic-labs-sdk/assert-package-version": "workspace:*",
|
|
9
9
|
"@dynamic-labs-wallet/browser-wallet-client": "0.0.286",
|
|
10
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
10
|
+
"@dynamic-labs/sdk-api-core": "0.0.921",
|
|
11
11
|
"@simplewebauthn/browser": "13.1.0",
|
|
12
12
|
"ably": "2.17.1",
|
|
13
13
|
"buffer": "6.0.3",
|
|
@@ -195,6 +195,357 @@ const isCookieEnabled = (client) => {
|
|
|
195
195
|
return dynamicCookiesEnabled || byoJwtCookieEnabled;
|
|
196
196
|
};
|
|
197
197
|
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/modules/auth/extractSessionId/extractSessionId.ts
|
|
200
|
+
/**
|
|
201
|
+
* Extracts the session ID (`sid` claim) from a JWT token string.
|
|
202
|
+
*
|
|
203
|
+
* Decodes the base64url-encoded payload segment of the token and reads the
|
|
204
|
+
* `sid` field. This is used to correlate instrumentation events with the
|
|
205
|
+
* authenticated session, without ever forwarding the full token.
|
|
206
|
+
*
|
|
207
|
+
* Returns `null` when no token is present, when the token is malformed, or
|
|
208
|
+
* when the payload does not contain a `sid` claim.
|
|
209
|
+
* @not-instrumented
|
|
210
|
+
*/
|
|
211
|
+
const extractSessionId = (token) => {
|
|
212
|
+
try {
|
|
213
|
+
const payload = token.split(".")[1];
|
|
214
|
+
return JSON.parse(atob(payload)).sid ?? null;
|
|
215
|
+
} catch {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/utils/getUserAgent/getUserAgent.ts
|
|
222
|
+
/**
|
|
223
|
+
* Returns the browser's `navigator.userAgent` string for inclusion in
|
|
224
|
+
* instrumentation events.
|
|
225
|
+
*
|
|
226
|
+
* Falls back to an empty string in environments where `navigator` is not
|
|
227
|
+
* available (e.g., Node.js SSR, service workers) so that callers never need
|
|
228
|
+
* to guard against undefined.
|
|
229
|
+
* @not-instrumented
|
|
230
|
+
*/
|
|
231
|
+
const getUserAgent = () => {
|
|
232
|
+
try {
|
|
233
|
+
return navigator.userAgent;
|
|
234
|
+
} catch {
|
|
235
|
+
return "";
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/services/instrumentation/constants.ts
|
|
241
|
+
const DEFAULT_PII_FIELDS = [
|
|
242
|
+
"password",
|
|
243
|
+
"token",
|
|
244
|
+
"secret",
|
|
245
|
+
"privateKey",
|
|
246
|
+
"mnemonic",
|
|
247
|
+
"seed",
|
|
248
|
+
"email",
|
|
249
|
+
"phone",
|
|
250
|
+
"ssn",
|
|
251
|
+
"address",
|
|
252
|
+
"authorization"
|
|
253
|
+
];
|
|
254
|
+
const REDACTED_VALUE = "[REDACTED]";
|
|
255
|
+
const MAX_STRING_LENGTH = 500;
|
|
256
|
+
const TRUNCATED_SUFFIX = "...[truncated]";
|
|
257
|
+
/**
|
|
258
|
+
* Label prefix for binary data placeholders. The full placeholder includes the
|
|
259
|
+
* byte length, e.g. `[Binary:16 bytes]`, so consumers can gauge data size
|
|
260
|
+
* without the actual bytes appearing in logs.
|
|
261
|
+
*/
|
|
262
|
+
const BINARY_LABEL = "Binary";
|
|
263
|
+
/**
|
|
264
|
+
* Placeholder emitted when a circular reference is detected in the value tree.
|
|
265
|
+
* Using a named constant makes it easy to search for or filter in downstream
|
|
266
|
+
* log tooling.
|
|
267
|
+
*/
|
|
268
|
+
const CIRCULAR_VALUE = "[Circular]";
|
|
269
|
+
|
|
270
|
+
//#endregion
|
|
271
|
+
//#region src/services/instrumentation/scrubParameters/scrubParameters.ts
|
|
272
|
+
const scrubString = ({ key, piiFieldsLower, redactAll, value }) => {
|
|
273
|
+
if (piiFieldsLower.includes(key.toLowerCase())) return REDACTED_VALUE;
|
|
274
|
+
if (redactAll) return REDACTED_VALUE;
|
|
275
|
+
if (value.length > MAX_STRING_LENGTH) return value.slice(0, MAX_STRING_LENGTH) + TRUNCATED_SUFFIX;
|
|
276
|
+
return value;
|
|
277
|
+
};
|
|
278
|
+
const scrubArray = ({ context, value }) => {
|
|
279
|
+
if (context.visited.has(value)) return [CIRCULAR_VALUE];
|
|
280
|
+
context.visited.add(value);
|
|
281
|
+
const result = value.map((item, index) => scrubValue({
|
|
282
|
+
context,
|
|
283
|
+
key: String(index),
|
|
284
|
+
value: item
|
|
285
|
+
}));
|
|
286
|
+
context.visited.delete(value);
|
|
287
|
+
return result;
|
|
288
|
+
};
|
|
289
|
+
const scrubObject = ({ context, value }) => {
|
|
290
|
+
if (context.visited.has(value)) return { [CIRCULAR_VALUE]: true };
|
|
291
|
+
context.visited.add(value);
|
|
292
|
+
const result = Object.create(null);
|
|
293
|
+
for (const key of Object.keys(value)) result[key] = scrubValue({
|
|
294
|
+
context,
|
|
295
|
+
key,
|
|
296
|
+
value: value[key]
|
|
297
|
+
});
|
|
298
|
+
context.visited.delete(value);
|
|
299
|
+
return result;
|
|
300
|
+
};
|
|
301
|
+
const scrubValue = ({ context, key, value }) => {
|
|
302
|
+
if (value === null || value === void 0) return value;
|
|
303
|
+
if (value instanceof Uint8Array) return `[${BINARY_LABEL}:${value.byteLength} bytes]`;
|
|
304
|
+
if (context.piiFieldsLower.includes(key.toLowerCase())) return REDACTED_VALUE;
|
|
305
|
+
if (typeof value === "string") return scrubString({
|
|
306
|
+
key,
|
|
307
|
+
piiFieldsLower: context.piiFieldsLower,
|
|
308
|
+
redactAll: context.redactAll,
|
|
309
|
+
value
|
|
310
|
+
});
|
|
311
|
+
if (Array.isArray(value)) return scrubArray({
|
|
312
|
+
context,
|
|
313
|
+
value
|
|
314
|
+
});
|
|
315
|
+
if (value instanceof Set) {
|
|
316
|
+
if (context.visited.has(value)) return [CIRCULAR_VALUE];
|
|
317
|
+
context.visited.add(value);
|
|
318
|
+
const setResult = scrubArray({
|
|
319
|
+
context,
|
|
320
|
+
value: [...value]
|
|
321
|
+
});
|
|
322
|
+
context.visited.delete(value);
|
|
323
|
+
return setResult;
|
|
324
|
+
}
|
|
325
|
+
if (value instanceof Map) {
|
|
326
|
+
if (context.visited.has(value)) return { [CIRCULAR_VALUE]: true };
|
|
327
|
+
context.visited.add(value);
|
|
328
|
+
const asObject = Object.create(null);
|
|
329
|
+
for (const [k, v] of value.entries()) asObject[String(k)] = v;
|
|
330
|
+
const mapResult = scrubObject({
|
|
331
|
+
context,
|
|
332
|
+
value: asObject
|
|
333
|
+
});
|
|
334
|
+
context.visited.delete(value);
|
|
335
|
+
return mapResult;
|
|
336
|
+
}
|
|
337
|
+
if (value instanceof WeakMap) return "[WeakMap]";
|
|
338
|
+
if (value instanceof WeakSet) return "[WeakSet]";
|
|
339
|
+
if (value instanceof Date) return value.toISOString();
|
|
340
|
+
if (value instanceof Error) return `[Error: ${value.message}]`;
|
|
341
|
+
if (typeof value === "object") return scrubObject({
|
|
342
|
+
context,
|
|
343
|
+
value
|
|
344
|
+
});
|
|
345
|
+
return value;
|
|
346
|
+
};
|
|
347
|
+
/** @not-instrumented */
|
|
348
|
+
const scrubParameters = ({ piiFields, redactAll, value }) => {
|
|
349
|
+
return scrubObject({
|
|
350
|
+
context: {
|
|
351
|
+
piiFieldsLower: piiFields.map((field) => field.toLowerCase()),
|
|
352
|
+
redactAll,
|
|
353
|
+
visited: /* @__PURE__ */ new WeakSet()
|
|
354
|
+
},
|
|
355
|
+
value
|
|
356
|
+
});
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
//#endregion
|
|
360
|
+
//#region src/services/instrumentation/instrumentFunction/extractParams/extractParams.ts
|
|
361
|
+
/**
|
|
362
|
+
* Normalises the raw positional arguments of an instrumented function call
|
|
363
|
+
* into a flat `Record<string, unknown>` suitable for structured logging.
|
|
364
|
+
*
|
|
365
|
+
* ## Why this is needed
|
|
366
|
+
*
|
|
367
|
+
* Instrumented functions are wrapped with `(...args: unknown[])`, so their
|
|
368
|
+
* parameters arrive as an array. Logging a raw array loses the semantic names
|
|
369
|
+
* of each argument. This function recovers a named representation:
|
|
370
|
+
*
|
|
371
|
+
* - **No arguments** → `{}`
|
|
372
|
+
* - **Single plain-object argument** → that object is returned as-is, because
|
|
373
|
+
* SDK functions follow the single-object-parameter convention, so the object
|
|
374
|
+
* already carries named keys (`{ amount, to }`, etc.).
|
|
375
|
+
* - **Everything else** (multiple args, a single primitive, a single array) →
|
|
376
|
+
* each value is indexed as `arg0`, `arg1`, …
|
|
377
|
+
*
|
|
378
|
+
* ## Why arrays are NOT treated as plain objects
|
|
379
|
+
*
|
|
380
|
+
* `typeof [] === 'object'` and `[] !== null`, so without the `Array.isArray`
|
|
381
|
+
* guard a single-array argument would be returned as-is. That would produce
|
|
382
|
+
* an object with numeric string keys (`{ '0': ..., '1': ... }`), which is
|
|
383
|
+
* misleading and inconsistent with how multi-arg calls are handled. Instead,
|
|
384
|
+
* arrays fall through to the indexed `arg0` path.
|
|
385
|
+
* @not-instrumented
|
|
386
|
+
*/
|
|
387
|
+
const extractParams = (args) => {
|
|
388
|
+
if (args.length === 0) return {};
|
|
389
|
+
if (args.length === 1 && typeof args[0] === "object" && args[0] !== null && !Array.isArray(args[0])) return args[0];
|
|
390
|
+
const result = {};
|
|
391
|
+
for (let i = 0; i < args.length; i++) result[`arg${i}`] = args[i];
|
|
392
|
+
return result;
|
|
393
|
+
};
|
|
394
|
+
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region src/services/instrumentation/instrumentFunction/scrubResolvedValue/scrubResolvedValue.ts
|
|
397
|
+
/**
|
|
398
|
+
* Scrubs a resolved return value of any type before logging it.
|
|
399
|
+
* Routes through `scrubParameters` by wrapping the value so that strings,
|
|
400
|
+
* arrays, Dates, Errors, and all other types are handled identically to
|
|
401
|
+
* nested object fields.
|
|
402
|
+
* @not-instrumented
|
|
403
|
+
*/
|
|
404
|
+
const scrubResolvedValue = ({ piiFields, redactAll, value }) => scrubParameters({
|
|
405
|
+
piiFields,
|
|
406
|
+
redactAll,
|
|
407
|
+
value: { result: value }
|
|
408
|
+
}).result;
|
|
409
|
+
|
|
410
|
+
//#endregion
|
|
411
|
+
//#region src/services/instrumentation/instrumentFunction/instrumentFunction.ts
|
|
412
|
+
const serializeError = (error) => {
|
|
413
|
+
if (error instanceof Error) return {
|
|
414
|
+
message: error.message,
|
|
415
|
+
name: error.name,
|
|
416
|
+
stack: error.stack
|
|
417
|
+
};
|
|
418
|
+
return {
|
|
419
|
+
message: String(error),
|
|
420
|
+
name: "UnknownError"
|
|
421
|
+
};
|
|
422
|
+
};
|
|
423
|
+
/**
|
|
424
|
+
* Wraps a function so that each invocation emits a structured
|
|
425
|
+
* `FunctionInstrumentationEvent` at three lifecycle points:
|
|
426
|
+
*
|
|
427
|
+
* - **started** — immediately before the function body executes, with the
|
|
428
|
+
* PII-scrubbed call parameters.
|
|
429
|
+
* - **resolved** — after the function (or its returned Promise) settles
|
|
430
|
+
* successfully, with the PII-scrubbed return value.
|
|
431
|
+
* - **rejected** — if the function throws synchronously or its returned
|
|
432
|
+
* Promise rejects.
|
|
433
|
+
*
|
|
434
|
+
* The original return value (or thrown error) is always forwarded to the
|
|
435
|
+
* caller unchanged — instrumentation is purely observational.
|
|
436
|
+
*
|
|
437
|
+
* ## Usage
|
|
438
|
+
*
|
|
439
|
+
* ```ts
|
|
440
|
+
* const transfer = instrumentFunction({
|
|
441
|
+
* fn: rawTransfer,
|
|
442
|
+
* functionName: 'transfer',
|
|
443
|
+
* getCore: () => core,
|
|
444
|
+
* });
|
|
445
|
+
*
|
|
446
|
+
* // When called, three events are emitted automatically:
|
|
447
|
+
* await transfer({ amount: 1, to: '0xabc' });
|
|
448
|
+
* ```
|
|
449
|
+
*
|
|
450
|
+
* ## How functions are wrapped
|
|
451
|
+
*
|
|
452
|
+
* `instrumentFunction` is not called manually in application code. Instead,
|
|
453
|
+
* the esbuild instrumentation plugin (`tools/instrumentation-plugin`) injects
|
|
454
|
+
* it at build time: any exported function annotated with `@instrumented` in its
|
|
455
|
+
* JSDoc is automatically wrapped by the plugin during the build step.
|
|
456
|
+
* The plugin strips the original `export`, renames the function, and re-exports
|
|
457
|
+
* it under the original name via `instrumentFunction(...)` — so the public API
|
|
458
|
+
* is unchanged and no call sites need to be updated.
|
|
459
|
+
*
|
|
460
|
+
* ## Opting out
|
|
461
|
+
*
|
|
462
|
+
* Instrumentation is skipped entirely when:
|
|
463
|
+
* - `getCore()` returns `undefined` (SDK not initialised), or
|
|
464
|
+
* - `core.instrumentation.config.enabled` is `false`.
|
|
465
|
+
*
|
|
466
|
+
* In both cases the original function is called directly with no overhead.
|
|
467
|
+
*
|
|
468
|
+
* ## PII scrubbing
|
|
469
|
+
*
|
|
470
|
+
* All string values whose key appears in `piiFields` are replaced with
|
|
471
|
+
* `"[redacted]"` before events are emitted. Pass `redactAll: true` to redact
|
|
472
|
+
* every field, regardless of key name.
|
|
473
|
+
* @not-instrumented
|
|
474
|
+
*/
|
|
475
|
+
const instrumentFunction = ({ fn, functionName, getCore: getCore$1, redactAll }) => {
|
|
476
|
+
const wrapped = (...args) => {
|
|
477
|
+
const core = getCore$1();
|
|
478
|
+
if (!core) return fn(...args);
|
|
479
|
+
if (!core.instrumentation.config.enabled) return fn(...args);
|
|
480
|
+
const instrumentation = core.instrumentation;
|
|
481
|
+
const state = core.state.get();
|
|
482
|
+
const baseEvent = {
|
|
483
|
+
environmentId: core.environmentId,
|
|
484
|
+
functionName,
|
|
485
|
+
parameters: scrubParameters({
|
|
486
|
+
piiFields: instrumentation.config.piiFields,
|
|
487
|
+
redactAll,
|
|
488
|
+
value: extractParams(args)
|
|
489
|
+
}),
|
|
490
|
+
sdkSessionId: core.sdkSessionId,
|
|
491
|
+
sdkVersion: core.version,
|
|
492
|
+
status: "info",
|
|
493
|
+
tokenSessionId: state.token ? extractSessionId(state.token) : null,
|
|
494
|
+
userAgent: getUserAgent(),
|
|
495
|
+
userId: state.user?.id ?? null
|
|
496
|
+
};
|
|
497
|
+
instrumentation.logFunction({
|
|
498
|
+
...baseEvent,
|
|
499
|
+
phase: "started",
|
|
500
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
501
|
+
});
|
|
502
|
+
try {
|
|
503
|
+
const result = fn(...args);
|
|
504
|
+
if (result instanceof Promise) return result.then((value) => {
|
|
505
|
+
instrumentation.logFunction({
|
|
506
|
+
...baseEvent,
|
|
507
|
+
phase: "resolved",
|
|
508
|
+
resolvedValue: scrubResolvedValue({
|
|
509
|
+
piiFields: instrumentation.config.piiFields,
|
|
510
|
+
redactAll,
|
|
511
|
+
value
|
|
512
|
+
}),
|
|
513
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
514
|
+
});
|
|
515
|
+
return value;
|
|
516
|
+
}).catch((error) => {
|
|
517
|
+
instrumentation.logFunction({
|
|
518
|
+
...baseEvent,
|
|
519
|
+
phase: "rejected",
|
|
520
|
+
rejectedError: serializeError(error),
|
|
521
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
522
|
+
});
|
|
523
|
+
throw error;
|
|
524
|
+
});
|
|
525
|
+
instrumentation.logFunction({
|
|
526
|
+
...baseEvent,
|
|
527
|
+
phase: "resolved",
|
|
528
|
+
resolvedValue: scrubResolvedValue({
|
|
529
|
+
piiFields: instrumentation.config.piiFields,
|
|
530
|
+
redactAll,
|
|
531
|
+
value: result
|
|
532
|
+
}),
|
|
533
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
534
|
+
});
|
|
535
|
+
return result;
|
|
536
|
+
} catch (error) {
|
|
537
|
+
instrumentation.logFunction({
|
|
538
|
+
...baseEvent,
|
|
539
|
+
phase: "rejected",
|
|
540
|
+
rejectedError: serializeError(error),
|
|
541
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
542
|
+
});
|
|
543
|
+
throw error;
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
return wrapped;
|
|
547
|
+
};
|
|
548
|
+
|
|
198
549
|
//#endregion
|
|
199
550
|
//#region src/modules/sessionKeys/getSessionKeys/getSessionKeys.ts
|
|
200
551
|
/** @instrumented */
|
|
@@ -203,6 +554,18 @@ const getSessionKeys = (client) => {
|
|
|
203
554
|
if (!publicKey) return;
|
|
204
555
|
return { publicKey };
|
|
205
556
|
};
|
|
557
|
+
const __getSessionKeys_impl = getSessionKeys;
|
|
558
|
+
const __getSessionKeys_wrapped = instrumentFunction({
|
|
559
|
+
fn: __getSessionKeys_impl,
|
|
560
|
+
functionName: "getSessionKeys",
|
|
561
|
+
getCore: () => {
|
|
562
|
+
try {
|
|
563
|
+
return getCore(getDefaultClient());
|
|
564
|
+
} catch {
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
});
|
|
206
569
|
|
|
207
570
|
//#endregion
|
|
208
571
|
//#region src/modules/auth/getElevatedAccessToken/getElevatedAccessToken.ts
|
|
@@ -246,6 +609,18 @@ const getElevatedAccessToken = ({ consume = true, scope }, client = getDefaultCl
|
|
|
246
609
|
}
|
|
247
610
|
return token.token;
|
|
248
611
|
};
|
|
612
|
+
const __getElevatedAccessToken_impl = getElevatedAccessToken;
|
|
613
|
+
const __getElevatedAccessToken_wrapped = instrumentFunction({
|
|
614
|
+
fn: __getElevatedAccessToken_impl,
|
|
615
|
+
functionName: "getElevatedAccessToken",
|
|
616
|
+
getCore: () => {
|
|
617
|
+
try {
|
|
618
|
+
return getCore(getDefaultClient());
|
|
619
|
+
} catch {
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
});
|
|
249
624
|
|
|
250
625
|
//#endregion
|
|
251
626
|
//#region src/errors/APIError/APIError.ts
|
|
@@ -428,6 +803,18 @@ const getNonce = async (client) => {
|
|
|
428
803
|
await fetchAndStoreNonces(client);
|
|
429
804
|
return getNonce(client);
|
|
430
805
|
};
|
|
806
|
+
const __getNonce_impl = getNonce;
|
|
807
|
+
const __getNonce_wrapped = instrumentFunction({
|
|
808
|
+
fn: __getNonce_impl,
|
|
809
|
+
functionName: "getNonce",
|
|
810
|
+
getCore: () => {
|
|
811
|
+
try {
|
|
812
|
+
return getCore(getDefaultClient());
|
|
813
|
+
} catch {
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
});
|
|
431
818
|
|
|
432
819
|
//#endregion
|
|
433
820
|
//#region src/modules/deviceRegistration/getDeviceSigner/getDeviceSigner.ts
|
|
@@ -446,6 +833,18 @@ const getDeviceSigner = async (client) => {
|
|
|
446
833
|
sign: (payload) => keychain.sign(keyName, payload)
|
|
447
834
|
};
|
|
448
835
|
};
|
|
836
|
+
const __getDeviceSigner_impl = getDeviceSigner;
|
|
837
|
+
const __getDeviceSigner_wrapped = instrumentFunction({
|
|
838
|
+
fn: __getDeviceSigner_impl,
|
|
839
|
+
functionName: "getDeviceSigner",
|
|
840
|
+
getCore: () => {
|
|
841
|
+
try {
|
|
842
|
+
return getCore(getDefaultClient());
|
|
843
|
+
} catch {
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
});
|
|
449
848
|
|
|
450
849
|
//#endregion
|
|
451
850
|
//#region src/modules/deviceRegistration/getHeadersForNonceSignedByDeviceSigners/getHeadersForNonceSignedByDeviceSigners.ts
|
|
@@ -459,8 +858,8 @@ const getHeadersForNonceSignedByDeviceSigners = async (client) => {
|
|
|
459
858
|
* Then we dont need to provide the headers
|
|
460
859
|
*/
|
|
461
860
|
if (isCookieEnabled(client)) return {};
|
|
462
|
-
const deviceSigner = await
|
|
463
|
-
const nonce = await
|
|
861
|
+
const deviceSigner = await __getDeviceSigner_wrapped(client);
|
|
862
|
+
const nonce = await __getNonce_wrapped(client);
|
|
464
863
|
const signedNonce = await deviceSigner.sign(nonce);
|
|
465
864
|
const publicKey = await deviceSigner.getPublicKey();
|
|
466
865
|
return {
|
|
@@ -469,6 +868,18 @@ const getHeadersForNonceSignedByDeviceSigners = async (client) => {
|
|
|
469
868
|
"x-dynamic-device-signed-nonce": signedNonce
|
|
470
869
|
};
|
|
471
870
|
};
|
|
871
|
+
const __getHeadersForNonceSignedByDeviceSigners_impl = getHeadersForNonceSignedByDeviceSigners;
|
|
872
|
+
const __getHeadersForNonceSignedByDeviceSigners_wrapped = instrumentFunction({
|
|
873
|
+
fn: __getHeadersForNonceSignedByDeviceSigners_impl,
|
|
874
|
+
functionName: "getHeadersForNonceSignedByDeviceSigners",
|
|
875
|
+
getCore: () => {
|
|
876
|
+
try {
|
|
877
|
+
return getCore(getDefaultClient());
|
|
878
|
+
} catch {
|
|
879
|
+
return;
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
});
|
|
472
883
|
|
|
473
884
|
//#endregion
|
|
474
885
|
//#region src/modules/apiClient/utils/deviceSignatureHeadersMiddleware/createDeviceSignatureHeadersMiddleware.ts
|
|
@@ -479,7 +890,7 @@ const createDeviceSignatureHeadersMiddleware = (client) => {
|
|
|
479
890
|
* The signed nonce is not required for cookie based environments.
|
|
480
891
|
*/
|
|
481
892
|
if ((0, _dynamic_labs_sdk_api_core.isDeviceNonceSignatureRequiredForUrl)(context.url) && !isCookieEnabled(client)) {
|
|
482
|
-
const deviceSignerHeaders = await
|
|
893
|
+
const deviceSignerHeaders = await __getHeadersForNonceSignedByDeviceSigners_wrapped(client);
|
|
483
894
|
return {
|
|
484
895
|
init: {
|
|
485
896
|
...context.init,
|
|
@@ -493,6 +904,18 @@ const createDeviceSignatureHeadersMiddleware = (client) => {
|
|
|
493
904
|
}
|
|
494
905
|
} };
|
|
495
906
|
};
|
|
907
|
+
const __createDeviceSignatureHeadersMiddleware_impl = createDeviceSignatureHeadersMiddleware;
|
|
908
|
+
const __createDeviceSignatureHeadersMiddleware_wrapped = instrumentFunction({
|
|
909
|
+
fn: __createDeviceSignatureHeadersMiddleware_impl,
|
|
910
|
+
functionName: "createDeviceSignatureHeadersMiddleware",
|
|
911
|
+
getCore: () => {
|
|
912
|
+
try {
|
|
913
|
+
return getCore(getDefaultClient());
|
|
914
|
+
} catch {
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
});
|
|
496
919
|
|
|
497
920
|
//#endregion
|
|
498
921
|
//#region src/errors/UnauthorizedError.ts
|
|
@@ -550,22 +973,34 @@ const createApiClient = (options = {}, client) => {
|
|
|
550
973
|
if (client.projectSettings && isCookieEnabled(client)) settings.credentials = "include";
|
|
551
974
|
if (options.includeMfaToken && coreState.mfaToken) settings.headers[MFA_TOKEN_HEADER] = coreState.mfaToken;
|
|
552
975
|
if (options.elevatedAccessTokenScope) {
|
|
553
|
-
const elevatedToken =
|
|
976
|
+
const elevatedToken = __getElevatedAccessToken_wrapped({ scope: options.elevatedAccessTokenScope }, client);
|
|
554
977
|
if (elevatedToken) settings.headers[ELEVATED_ACCESS_TOKEN_HEADER] = elevatedToken;
|
|
555
978
|
}
|
|
556
|
-
const sessionPublicKey =
|
|
979
|
+
const sessionPublicKey = __getSessionKeys_wrapped(client)?.publicKey;
|
|
557
980
|
const isSessionPublicKeyHeaderPresent = settings.headers[SESSION_PUBLIC_KEY_HEADER] !== void 0;
|
|
558
981
|
if (sessionPublicKey && !isSessionPublicKeyHeaderPresent) settings.headers[SESSION_PUBLIC_KEY_HEADER] = sessionPublicKey;
|
|
559
982
|
return new _dynamic_labs_sdk_api_core.SDKApi(new _dynamic_labs_sdk_api_core.Configuration({
|
|
560
983
|
...settings,
|
|
561
984
|
fetchApi: core.fetch,
|
|
562
985
|
middleware: [
|
|
563
|
-
|
|
986
|
+
__createDeviceSignatureHeadersMiddleware_wrapped(client),
|
|
564
987
|
createConvertToApiErrorMiddleware({ errorMappers: [...options.errorMappers || [], clientErrorMapper] }),
|
|
565
988
|
createUnauthorizedMiddleware()
|
|
566
989
|
]
|
|
567
990
|
}));
|
|
568
991
|
};
|
|
992
|
+
const __createApiClient_impl = createApiClient;
|
|
993
|
+
const __createApiClient_wrapped = instrumentFunction({
|
|
994
|
+
fn: __createApiClient_impl,
|
|
995
|
+
functionName: "createApiClient",
|
|
996
|
+
getCore: () => {
|
|
997
|
+
try {
|
|
998
|
+
return getCore(getDefaultClient());
|
|
999
|
+
} catch {
|
|
1000
|
+
return;
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
});
|
|
569
1004
|
|
|
570
1005
|
//#endregion
|
|
571
1006
|
//#region src/utils/getNonce/fetchAndStoreNonces/fetchAndStoreNonces.ts
|
|
@@ -583,7 +1018,7 @@ const createApiClient = (options = {}, client) => {
|
|
|
583
1018
|
const fetchAndStoreNonces = async (client) => {
|
|
584
1019
|
const core = getCore(client);
|
|
585
1020
|
const { environmentId } = core;
|
|
586
|
-
const { nonces } = await
|
|
1021
|
+
const { nonces } = await __createApiClient_wrapped({}, client).getNonces({
|
|
587
1022
|
count: NONCE_POOL_SIZE,
|
|
588
1023
|
environmentId
|
|
589
1024
|
});
|
|
@@ -692,6 +1127,18 @@ const getChainFromVerifiedCredentialChain = (verifiedCredentialChain) => {
|
|
|
692
1127
|
assertDefined(chain, `Unknown chain: ${verifiedCredentialChain}`);
|
|
693
1128
|
return chain;
|
|
694
1129
|
};
|
|
1130
|
+
const __getChainFromVerifiedCredentialChain_impl = getChainFromVerifiedCredentialChain;
|
|
1131
|
+
const __getChainFromVerifiedCredentialChain_wrapped = instrumentFunction({
|
|
1132
|
+
fn: __getChainFromVerifiedCredentialChain_impl,
|
|
1133
|
+
functionName: "getChainFromVerifiedCredentialChain",
|
|
1134
|
+
getCore: () => {
|
|
1135
|
+
try {
|
|
1136
|
+
return getCore(getDefaultClient());
|
|
1137
|
+
} catch {
|
|
1138
|
+
return;
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
695
1142
|
|
|
696
1143
|
//#endregion
|
|
697
1144
|
//#region src/constants.ts
|
|
@@ -753,6 +1200,12 @@ Object.defineProperty(exports, 'ClientNotFoundError', {
|
|
|
753
1200
|
return ClientNotFoundError;
|
|
754
1201
|
}
|
|
755
1202
|
});
|
|
1203
|
+
Object.defineProperty(exports, 'DEFAULT_PII_FIELDS', {
|
|
1204
|
+
enumerable: true,
|
|
1205
|
+
get: function () {
|
|
1206
|
+
return DEFAULT_PII_FIELDS;
|
|
1207
|
+
}
|
|
1208
|
+
});
|
|
756
1209
|
Object.defineProperty(exports, 'DEFAULT_WAAS_BASE_API_URL', {
|
|
757
1210
|
enumerable: true,
|
|
758
1211
|
get: function () {
|
|
@@ -843,76 +1296,94 @@ Object.defineProperty(exports, 'ValueMustBeDefinedError', {
|
|
|
843
1296
|
return ValueMustBeDefinedError;
|
|
844
1297
|
}
|
|
845
1298
|
});
|
|
846
|
-
Object.defineProperty(exports, '
|
|
1299
|
+
Object.defineProperty(exports, '__createApiClient_wrapped', {
|
|
847
1300
|
enumerable: true,
|
|
848
1301
|
get: function () {
|
|
849
|
-
return
|
|
1302
|
+
return __createApiClient_wrapped;
|
|
850
1303
|
}
|
|
851
1304
|
});
|
|
852
|
-
Object.defineProperty(exports, '
|
|
1305
|
+
Object.defineProperty(exports, '__createDeviceSignatureHeadersMiddleware_wrapped', {
|
|
853
1306
|
enumerable: true,
|
|
854
1307
|
get: function () {
|
|
855
|
-
return
|
|
1308
|
+
return __createDeviceSignatureHeadersMiddleware_wrapped;
|
|
856
1309
|
}
|
|
857
1310
|
});
|
|
858
|
-
Object.defineProperty(exports, '
|
|
1311
|
+
Object.defineProperty(exports, '__getChainFromVerifiedCredentialChain_wrapped', {
|
|
859
1312
|
enumerable: true,
|
|
860
1313
|
get: function () {
|
|
861
|
-
return
|
|
1314
|
+
return __getChainFromVerifiedCredentialChain_wrapped;
|
|
862
1315
|
}
|
|
863
1316
|
});
|
|
864
|
-
Object.defineProperty(exports, '
|
|
1317
|
+
Object.defineProperty(exports, '__getDeviceSigner_wrapped', {
|
|
865
1318
|
enumerable: true,
|
|
866
1319
|
get: function () {
|
|
867
|
-
return
|
|
1320
|
+
return __getDeviceSigner_wrapped;
|
|
868
1321
|
}
|
|
869
1322
|
});
|
|
870
|
-
Object.defineProperty(exports, '
|
|
1323
|
+
Object.defineProperty(exports, '__getElevatedAccessToken_wrapped', {
|
|
871
1324
|
enumerable: true,
|
|
872
1325
|
get: function () {
|
|
873
|
-
return
|
|
1326
|
+
return __getElevatedAccessToken_wrapped;
|
|
874
1327
|
}
|
|
875
1328
|
});
|
|
876
|
-
Object.defineProperty(exports, '
|
|
1329
|
+
Object.defineProperty(exports, '__getHeadersForNonceSignedByDeviceSigners_wrapped', {
|
|
877
1330
|
enumerable: true,
|
|
878
1331
|
get: function () {
|
|
879
|
-
return
|
|
1332
|
+
return __getHeadersForNonceSignedByDeviceSigners_wrapped;
|
|
880
1333
|
}
|
|
881
1334
|
});
|
|
882
|
-
Object.defineProperty(exports, '
|
|
1335
|
+
Object.defineProperty(exports, '__getNonce_wrapped', {
|
|
883
1336
|
enumerable: true,
|
|
884
1337
|
get: function () {
|
|
885
|
-
return
|
|
1338
|
+
return __getNonce_wrapped;
|
|
886
1339
|
}
|
|
887
1340
|
});
|
|
888
|
-
Object.defineProperty(exports, '
|
|
1341
|
+
Object.defineProperty(exports, '__getSessionKeys_wrapped', {
|
|
889
1342
|
enumerable: true,
|
|
890
1343
|
get: function () {
|
|
891
|
-
return
|
|
1344
|
+
return __getSessionKeys_wrapped;
|
|
892
1345
|
}
|
|
893
1346
|
});
|
|
894
|
-
Object.defineProperty(exports, '
|
|
1347
|
+
Object.defineProperty(exports, 'assertDefined', {
|
|
895
1348
|
enumerable: true,
|
|
896
1349
|
get: function () {
|
|
897
|
-
return
|
|
1350
|
+
return assertDefined;
|
|
1351
|
+
}
|
|
1352
|
+
});
|
|
1353
|
+
Object.defineProperty(exports, 'extractSessionId', {
|
|
1354
|
+
enumerable: true,
|
|
1355
|
+
get: function () {
|
|
1356
|
+
return extractSessionId;
|
|
898
1357
|
}
|
|
899
1358
|
});
|
|
900
|
-
Object.defineProperty(exports, '
|
|
1359
|
+
Object.defineProperty(exports, 'fetchAndStoreNonces', {
|
|
901
1360
|
enumerable: true,
|
|
902
1361
|
get: function () {
|
|
903
|
-
return
|
|
1362
|
+
return fetchAndStoreNonces;
|
|
1363
|
+
}
|
|
1364
|
+
});
|
|
1365
|
+
Object.defineProperty(exports, 'getCore', {
|
|
1366
|
+
enumerable: true,
|
|
1367
|
+
get: function () {
|
|
1368
|
+
return getCore;
|
|
1369
|
+
}
|
|
1370
|
+
});
|
|
1371
|
+
Object.defineProperty(exports, 'getDefaultClient', {
|
|
1372
|
+
enumerable: true,
|
|
1373
|
+
get: function () {
|
|
1374
|
+
return getDefaultClient;
|
|
904
1375
|
}
|
|
905
1376
|
});
|
|
906
|
-
Object.defineProperty(exports, '
|
|
1377
|
+
Object.defineProperty(exports, 'getUserAgent', {
|
|
907
1378
|
enumerable: true,
|
|
908
1379
|
get: function () {
|
|
909
|
-
return
|
|
1380
|
+
return getUserAgent;
|
|
910
1381
|
}
|
|
911
1382
|
});
|
|
912
|
-
Object.defineProperty(exports, '
|
|
1383
|
+
Object.defineProperty(exports, 'instrumentFunction', {
|
|
913
1384
|
enumerable: true,
|
|
914
1385
|
get: function () {
|
|
915
|
-
return
|
|
1386
|
+
return instrumentFunction;
|
|
916
1387
|
}
|
|
917
1388
|
});
|
|
918
1389
|
Object.defineProperty(exports, 'isCookieEnabled', {
|
|
@@ -945,4 +1416,4 @@ Object.defineProperty(exports, 'version', {
|
|
|
945
1416
|
return version;
|
|
946
1417
|
}
|
|
947
1418
|
});
|
|
948
|
-
//# sourceMappingURL=InvalidParamError-
|
|
1419
|
+
//# sourceMappingURL=InvalidParamError-D7xRBKr4.cjs.js.map
|