@coinbase/cdp-sdk 1.38.5 → 1.38.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # CDP SDK Changelog
2
2
 
3
+ ## 1.38.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#492](https://github.com/coinbase/cdp-sdk/pull/492) [`60e6a1a`](https://github.com/coinbase/cdp-sdk/commit/60e6a1a5ae6da6b704c33fd7f72ee334108deb76) Thanks [@0xRAG](https://github.com/0xRAG)! - Replaced error-tracking wrappers with a WeakSet-based recursion guard to prevent memory leaks from strong references to wrapped instances.
8
+
3
9
  ## 1.38.5
4
10
 
5
11
  ### Patch Changes
package/_cjs/analytics.js CHANGED
@@ -3,11 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Analytics = void 0;
6
+ exports.AnalyticsDeprecated = exports.Analytics = void 0;
7
7
  const md5_1 = __importDefault(require("md5"));
8
8
  const errors_js_1 = require("./errors.js");
9
9
  const errors_js_2 = require("./openapi-client/errors.js");
10
10
  const version_js_1 = require("./version.js");
11
+ // Symbol to store the original method on wrapped functions
12
+ const ORIGINAL_METHOD = Symbol("originalMethod");
11
13
  // This is a public client id for the analytics service
12
14
  const publicClientId = "54f2ee2fb3d2b901a829940d70fbfc13";
13
15
  exports.Analytics = {
@@ -17,6 +19,22 @@ exports.Analytics = {
17
19
  sendEvent,
18
20
  trackAction,
19
21
  };
22
+ /*
23
+ * Deprecated implementation - kept for test compatibility
24
+ * Shares the same identifier reference as Analytics
25
+ */
26
+ exports.AnalyticsDeprecated = {
27
+ get identifier() {
28
+ return exports.Analytics.identifier;
29
+ },
30
+ set identifier(value) {
31
+ exports.Analytics.identifier = value;
32
+ },
33
+ wrapClassWithErrorTracking: wrapClassWithErrorTrackingDeprecated,
34
+ wrapObjectMethodsWithErrorTracking: wrapObjectMethodsWithErrorTrackingDeprecated,
35
+ sendEvent,
36
+ trackAction,
37
+ };
20
38
  /**
21
39
  * Sends an analytics event to the default endpoint
22
40
  *
@@ -89,6 +107,98 @@ function trackAction(params) {
89
107
  // ignore error
90
108
  });
91
109
  }
110
+ /**
111
+ * Gets the original method from a wrapped method, or returns the method itself if it's not wrapped.
112
+ *
113
+ * @param method - The method to get the original version of.
114
+ * @returns The original unwrapped method, or the method itself if it's not wrapped.
115
+ */
116
+ function getOriginalMethod(method) {
117
+ return (method[ORIGINAL_METHOD] || method);
118
+ }
119
+ /**
120
+ * Creates an interceptor function that prevents recursive calls by checking if the instance is already executing.
121
+ *
122
+ * @param executingInstances - A WeakSet tracking instances that are currently executing.
123
+ * @param fallbackMethod - The method to call if recursion is not detected.
124
+ * @returns A function that intercepts calls and prevents recursion.
125
+ */
126
+ function createRecursiveInterceptor(executingInstances, fallbackMethod) {
127
+ return function (...callArgs) {
128
+ if (executingInstances.has(this)) {
129
+ return Promise.resolve(callArgs[0]);
130
+ }
131
+ return fallbackMethod.apply(this, callArgs);
132
+ };
133
+ }
134
+ /**
135
+ * Executes a method with recursion protection by tracking executing instances.
136
+ *
137
+ * @param executingInstances - A WeakSet tracking instances that are currently executing.
138
+ * @param originalMethod - The original method to execute.
139
+ * @param context - The context (this) to bind the method to.
140
+ * @param args - The arguments to pass to the method.
141
+ * @returns The result of executing the original method.
142
+ */
143
+ async function executeWithRecursionProtection(executingInstances, originalMethod, context, args) {
144
+ if (executingInstances.has(context)) {
145
+ return args[0];
146
+ }
147
+ executingInstances.add(context);
148
+ try {
149
+ return await originalMethod.apply(context, args);
150
+ }
151
+ finally {
152
+ executingInstances.delete(context);
153
+ }
154
+ }
155
+ /**
156
+ * Handles an error that occurred in a method by sending an analytics event and rethrowing the error.
157
+ *
158
+ * @param error - The error that occurred.
159
+ * @param methodName - The name of the method where the error occurred.
160
+ */
161
+ async function handleMethodError(error, methodName) {
162
+ if (!shouldTrackError(error)) {
163
+ throw error;
164
+ }
165
+ const { message, stack } = error;
166
+ sendEvent({
167
+ method: methodName,
168
+ message,
169
+ stack,
170
+ name: "error",
171
+ }).catch(() => {
172
+ // ignore error
173
+ });
174
+ throw error;
175
+ }
176
+ /**
177
+ * Creates a wrapper function that adds error tracking and recursion protection to a method.
178
+ *
179
+ * @param originalMethod - The original method to wrap.
180
+ * @param methodName - The name of the method being wrapped.
181
+ * @param executingInstances - A WeakSet tracking instances that are currently executing.
182
+ * @param setMethod - A function to set the method implementation.
183
+ * @param getMethod - A function to get the current method implementation.
184
+ * @returns A wrapped version of the method with error tracking and recursion protection.
185
+ */
186
+ function createErrorTrackingWrapper(originalMethod, methodName, executingInstances, setMethod, getMethod) {
187
+ return async function (...args) {
188
+ const previousMethod = getMethod();
189
+ const recursiveInterceptor = createRecursiveInterceptor(executingInstances, previousMethod);
190
+ setMethod(recursiveInterceptor);
191
+ try {
192
+ const result = await executeWithRecursionProtection(executingInstances, originalMethod, this, args);
193
+ setMethod(previousMethod);
194
+ return result;
195
+ }
196
+ catch (error) {
197
+ setMethod(previousMethod);
198
+ return handleMethodError(error, methodName);
199
+ }
200
+ };
201
+ }
92
202
  /**
93
203
  * Wraps all methods of a class with error tracking.
94
204
  *
@@ -96,6 +206,54 @@ function trackAction(params) {
96
206
  */
97
207
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
98
208
  function wrapClassWithErrorTracking(ClassToWrap) {
209
+ if (process.env.DISABLE_CDP_ERROR_REPORTING === "true") {
210
+ return;
211
+ }
212
+ const methods = Object.getOwnPropertyNames(ClassToWrap.prototype).filter(name => name !== "constructor" && typeof ClassToWrap.prototype[name] === "function");
213
+ for (const method of methods) {
214
+ const currentMethod = ClassToWrap.prototype[method];
215
+ const originalMethod = getOriginalMethod(currentMethod);
216
+ const executingInstances = new WeakSet();
217
+ const wrappedMethod = createErrorTrackingWrapper(originalMethod, method, executingInstances, newMethod => {
218
+ ClassToWrap.prototype[method] = newMethod;
219
+ }, () => ClassToWrap.prototype[method]);
220
+ wrappedMethod[ORIGINAL_METHOD] = originalMethod;
221
+ ClassToWrap.prototype[method] = wrappedMethod;
222
+ }
223
+ }
224
+ /**
225
+ * Wraps all methods of an object with error tracking.
226
+ *
227
+ * @param object - The object whose methods should be wrapped.
228
+ */
229
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
230
+ function wrapObjectMethodsWithErrorTracking(object) {
231
+ if (process.env.DISABLE_CDP_ERROR_REPORTING === "true") {
232
+ return;
233
+ }
234
+ const methods = Object.getOwnPropertyNames(object).filter(name => name !== "constructor" && typeof object[name] === "function");
235
+ for (const method of methods) {
236
+ const currentMethod = object[method];
237
+ const originalMethod = getOriginalMethod(currentMethod);
238
+ const executingInstances = new WeakSet();
239
+ const wrappedMethod = createErrorTrackingWrapper(originalMethod, method, executingInstances, newMethod => {
240
+ object[method] = newMethod;
241
+ }, () => object[method]);
242
+ wrappedMethod[ORIGINAL_METHOD] = originalMethod;
243
+ object[method] = wrappedMethod;
244
+ }
245
+ }
246
+ /**
247
+ * Wraps all methods of a class with error tracking.
248
+ *
249
+ * @deprecated This is the old implementation that has a bug with methods calling themselves via prototype.
250
+ * Use Analytics.wrapClassWithErrorTracking instead.
251
+ * Kept for test compatibility.
252
+ *
253
+ * @param ClassToWrap - The class whose prototype methods should be wrapped.
254
+ */
255
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
256
+ function wrapClassWithErrorTrackingDeprecated(ClassToWrap) {
99
257
  if (process.env.DISABLE_CDP_ERROR_REPORTING === "true") {
100
258
  return;
101
259
  }
@@ -127,10 +285,14 @@ function wrapClassWithErrorTracking(ClassToWrap) {
127
285
  /**
128
286
  * Wraps all methods of an object with error tracking.
129
287
  *
288
+ * @deprecated This is the old implementation that has a bug with methods calling themselves via object property.
289
+ * Use Analytics.wrapObjectMethodsWithErrorTracking instead.
290
+ * Kept for test compatibility.
291
+ *
130
292
  * @param object - The object whose methods should be wrapped.
131
293
  */
132
294
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
133
- function wrapObjectMethodsWithErrorTracking(object) {
295
+ function wrapObjectMethodsWithErrorTrackingDeprecated(object) {
134
296
  if (process.env.DISABLE_CDP_ERROR_REPORTING === "true") {
135
297
  return;
136
298
  }
@@ -1 +1 @@
1
- {"version":3,"file":"analytics.js","sourceRoot":"","sources":["../analytics.ts"],"names":[],"mappings":";;;;;;AAAA,8CAAsB;AAEtB,2CAAuD;AACvD,0DAAoE;AACpE,6CAAuC;AAgDvC,uDAAuD;AACvD,MAAM,cAAc,GAAG,kCAAkC,CAAC;AAE7C,QAAA,SAAS,GAAG;IACvB,UAAU,EAAE,EAAE,EAAE,gBAAgB;IAChC,0BAA0B;IAC1B,kCAAkC;IAClC,SAAS;IACT,WAAW;CACZ,CAAC;AAEF;;;;;GAKG;AACH,KAAK,UAAU,SAAS,CAAC,KAAgB;IACvC,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,2BAA2B,KAAK,MAAM,EAAE,CAAC;QACjF,OAAO;IACT,CAAC;IAED,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC,0BAA0B,KAAK,MAAM,EAAE,CAAC;QAChF,OAAO;IACT,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAE7B,MAAM,aAAa,GAAG;QACpB,OAAO,EAAE,iBAAS,CAAC,UAAU;QAC7B,UAAU,EAAE,KAAK,CAAC,IAAI;QACtB,QAAQ,EAAE,QAAQ;QAClB,SAAS;QACT,gBAAgB,EAAE;YAChB,YAAY,EAAE,SAAS;YACvB,gBAAgB,EAAE,YAAY;YAC9B,OAAO,EAAP,oBAAO;YACP,GAAG,KAAK;SACT;KACF,CAAC;IAEF,MAAM,MAAM,GAAG,CAAC,aAAa,CAAC,CAAC;IAC/B,MAAM,oBAAoB,GAAG,IAAI,CAAC,SAAS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CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;oBACZ,eAAe;gBACjB,CAAC,CAAC,CAAC;gBAEH,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,KAAc;IACtC,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,KAAK,YAAY,oCAAwB,EAAE,CAAC;QAC9C,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,KAAK,YAAY,wBAAY,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,KAAK,YAAY,oBAAQ,IAAI,KAAK,CAAC,SAAS,KAAK,kBAAkB,EAAE,CAAC;QACxE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -7,6 +7,49 @@ const index_js_1 = require("../../openapi-client/index.js");
7
7
  * The CDP end user client.
8
8
  */
9
9
  class CDPEndUserClient {
10
+ /**
11
+ * Lists end users belonging to the developer's CDP Project.
12
+ * By default, the response is sorted by creation date in ascending order and paginated to 20 users per page.
13
+ *
14
+ * @param options - The options for listing end users.
15
+ *
16
+ * @returns A promise that resolves to a paginated list of end users.
17
+ *
18
+ * @example **List all end users**
19
+ * ```ts
20
+ * const result = await cdp.endUsers.listEndUsers();
21
+ * console.log(result.endUsers);
22
+ * ```
23
+ *
24
+ * @example **With pagination**
25
+ * ```ts
26
+ * let page = await cdp.endUsers.listEndUsers({ pageSize: 10 });
27
+ *
28
+ * while (page.nextPageToken) {
29
+ * page = await cdp.endUsers.listEndUsers({
30
+ * pageSize: 10,
31
+ * pageToken: page.nextPageToken
32
+ * });
33
+ * }
34
+ * ```
35
+ *
36
+ * @example **With sorting**
37
+ * ```ts
38
+ * const result = await cdp.endUsers.listEndUsers({
39
+ * sort: ['createdAt=desc']
40
+ * });
41
+ * ```
42
+ */
43
+ async listEndUsers(options = {}) {
44
+ analytics_js_1.Analytics.trackAction({
45
+ action: "list_end_users",
46
+ });
47
+ const params = {
48
+ ...options,
49
+ ...(options.sort && { sort: options.sort.join(",") }),
50
+ };
51
+ return index_js_1.CdpOpenApiClient.listEndUsers(params);
52
+ }
10
53
  /**
11
54
  * Validates an end user's access token. Throws an error if the access token is invalid.
12
55
  *
@@ -1 +1 @@
1
- {"version":3,"file":"endUser.js","sourceRoot":"","sources":["../../../client/end-user/endUser.ts"],"names":[],"mappings":";;;AACA,qDAA+C;AAC/C,4DAA+E;AAE/E;;GAEG;AACH,MAAa,gBAAgB;IAC3B;;;;;;OAMG;IACH,KAAK,CAAC,mBAAmB,CAAC,OAAmC;QAC3D,wBAAS,CAAC,WAAW,CAAC;YACpB,MAAM,EAAE,uBAAuB;SAChC,CAAC,CAAC;QAEH,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;QAEhC,OAAO,2BAAgB,CAAC,0BAA0B,CAAC;YACjD,WAAW;SACZ,CAAC,CAAC;IACL,CAAC;CACF;AAnBD,4CAmBC"}
1
+ {"version":3,"file":"endUser.js","sourceRoot":"","sources":["../../../client/end-user/endUser.ts"],"names":[],"mappings":";;;AACA,qDAA+C;AAC/C,4DAIuC;AAEvC;;GAEG;AACH,MAAa,gBAAgB;IAC3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,KAAK,CAAC,YAAY,CAAC,UAA+B,EAAE;QAClD,wBAAS,CAAC,WAAW,CAAC;YACpB,MAAM,EAAE,gBAAgB;SACzB,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG;YACb,GAAG,OAAO;YACV,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;SACtD,CAAC;QAEF,OAAO,2BAAgB,CAAC,YAAY,CAAC,MAA6B,CAAC,CAAC;IACtE,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,mBAAmB,CAAC,OAAmC;QAC3D,wBAAS,CAAC,WAAW,CAAC;YACpB,MAAM,EAAE,uBAAuB;SAChC,CAAC,CAAC;QAEH,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;QAEhC,OAAO,2BAAgB,CAAC,0BAA0B,CAAC;YACjD,WAAW;SACZ,CAAC,CAAC;IACL,CAAC;CACF;AAjED,4CAiEC"}
package/_cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,0CAA4C;AAAnC,mGAAA,SAAS,OAAA;AAGlB,gDAK6B;AAJ3B,kHAAA,sBAAsB,OAAA;AACtB,kHAAA,sBAAsB,OAAA;AAIxB,wDAA0D;AAAjD,yGAAA,YAAY,OAAA;AAGrB,iEAG0C;AAFxC,yHAAA,4BAA4B,OAA6B;AACzD,6HAAA,gCAAgC,OAAiC;AAGnE,6BAA8C;AAArC,kGAAA,UAAU,OAAA;AAAE,kGAAA,UAAU,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,0CAA4C;AAAnC,mGAAA,SAAS,OAAA;AAGlB,gDAK6B;AAJ3B,kHAAA,sBAAsB,OAAA;AACtB,kHAAA,sBAAsB,OAAA;AAIxB,wDAA0D;AAAjD,yGAAA,YAAY,OAAA;AAIrB,iEAG0C;AAFxC,yHAAA,4BAA4B,OAA6B;AACzD,6HAAA,gCAAgC,OAAiC;AAGnE,6BAA8C;AAArC,kGAAA,UAAU,OAAA;AAAE,kGAAA,UAAU,OAAA"}
package/_cjs/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
- exports.version = "1.38.5";
4
+ exports.version = "1.38.6";
5
5
  //# sourceMappingURL=version.js.map
package/_esm/analytics.js CHANGED
@@ -2,6 +2,8 @@ import md5 from "md5";
2
2
  import { UserInputValidationError } from "./errors.js";
3
3
  import { APIError, NetworkError } from "./openapi-client/errors.js";
4
4
  import { version } from "./version.js";
5
+ // Symbol to store the original method on wrapped functions
6
+ const ORIGINAL_METHOD = Symbol("originalMethod");
5
7
  // This is a public client id for the analytics service
6
8
  const publicClientId = "54f2ee2fb3d2b901a829940d70fbfc13";
7
9
  export const Analytics = {
@@ -11,6 +13,22 @@ export const Analytics = {
11
13
  sendEvent,
12
14
  trackAction,
13
15
  };
16
+ /*
17
+ * Deprecated implementation - kept for test compatibility
18
+ * Shares the same identifier reference as Analytics
19
+ */
20
+ export const AnalyticsDeprecated = {
21
+ get identifier() {
22
+ return Analytics.identifier;
23
+ },
24
+ set identifier(value) {
25
+ Analytics.identifier = value;
26
+ },
27
+ wrapClassWithErrorTracking: wrapClassWithErrorTrackingDeprecated,
28
+ wrapObjectMethodsWithErrorTracking: wrapObjectMethodsWithErrorTrackingDeprecated,
29
+ sendEvent,
30
+ trackAction,
31
+ };
14
32
  /**
15
33
  * Sends an analytics event to the default endpoint
16
34
  *
@@ -83,6 +101,98 @@ function trackAction(params) {
83
101
  // ignore error
84
102
  });
85
103
  }
104
+ /**
105
+ * Gets the original method from a wrapped method, or returns the method itself if it's not wrapped.
106
+ *
107
+ * @param method - The method to get the original version of.
108
+ * @returns The original unwrapped method, or the method itself if it's not wrapped.
109
+ */
110
+ function getOriginalMethod(method) {
111
+ return (method[ORIGINAL_METHOD] || method);
112
+ }
113
+ /**
114
+ * Creates an interceptor function that prevents recursive calls by checking if the instance is already executing.
115
+ *
116
+ * @param executingInstances - A WeakSet tracking instances that are currently executing.
117
+ * @param fallbackMethod - The method to call if recursion is not detected.
118
+ * @returns A function that intercepts calls and prevents recursion.
119
+ */
120
+ function createRecursiveInterceptor(executingInstances, fallbackMethod) {
121
+ return function (...callArgs) {
122
+ if (executingInstances.has(this)) {
123
+ return Promise.resolve(callArgs[0]);
124
+ }
125
+ return fallbackMethod.apply(this, callArgs);
126
+ };
127
+ }
128
+ /**
129
+ * Executes a method with recursion protection by tracking executing instances.
130
+ *
131
+ * @param executingInstances - A WeakSet tracking instances that are currently executing.
132
+ * @param originalMethod - The original method to execute.
133
+ * @param context - The context (this) to bind the method to.
134
+ * @param args - The arguments to pass to the method.
135
+ * @returns The result of executing the original method.
136
+ */
137
+ async function executeWithRecursionProtection(executingInstances, originalMethod, context, args) {
138
+ if (executingInstances.has(context)) {
139
+ return args[0];
140
+ }
141
+ executingInstances.add(context);
142
+ try {
143
+ return await originalMethod.apply(context, args);
144
+ }
145
+ finally {
146
+ executingInstances.delete(context);
147
+ }
148
+ }
149
+ /**
150
+ * Handles an error that occurred in a method by sending an analytics event and rethrowing the error.
151
+ *
152
+ * @param error - The error that occurred.
153
+ * @param methodName - The name of the method where the error occurred.
154
+ */
155
+ async function handleMethodError(error, methodName) {
156
+ if (!shouldTrackError(error)) {
157
+ throw error;
158
+ }
159
+ const { message, stack } = error;
160
+ sendEvent({
161
+ method: methodName,
162
+ message,
163
+ stack,
164
+ name: "error",
165
+ }).catch(() => {
166
+ // ignore error
167
+ });
168
+ throw error;
169
+ }
170
+ /**
171
+ * Creates a wrapper function that adds error tracking and recursion protection to a method.
172
+ *
173
+ * @param originalMethod - The original method to wrap.
174
+ * @param methodName - The name of the method being wrapped.
175
+ * @param executingInstances - A WeakSet tracking instances that are currently executing.
176
+ * @param setMethod - A function to set the method implementation.
177
+ * @param getMethod - A function to get the current method implementation.
178
+ * @returns A wrapped version of the method with error tracking and recursion protection.
179
+ */
180
+ function createErrorTrackingWrapper(originalMethod, methodName, executingInstances, setMethod, getMethod) {
181
+ return async function (...args) {
182
+ const previousMethod = getMethod();
183
+ const recursiveInterceptor = createRecursiveInterceptor(executingInstances, previousMethod);
184
+ setMethod(recursiveInterceptor);
185
+ try {
186
+ const result = await executeWithRecursionProtection(executingInstances, originalMethod, this, args);
187
+ setMethod(previousMethod);
188
+ return result;
189
+ }
190
+ catch (error) {
191
+ setMethod(previousMethod);
192
+ return handleMethodError(error, methodName);
193
+ }
194
+ };
195
+ }
86
196
  /**
87
197
  * Wraps all methods of a class with error tracking.
88
198
  *
@@ -90,6 +200,54 @@ function trackAction(params) {
90
200
  */
91
201
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
92
202
  function wrapClassWithErrorTracking(ClassToWrap) {
203
+ if (process.env.DISABLE_CDP_ERROR_REPORTING === "true") {
204
+ return;
205
+ }
206
+ const methods = Object.getOwnPropertyNames(ClassToWrap.prototype).filter(name => name !== "constructor" && typeof ClassToWrap.prototype[name] === "function");
207
+ for (const method of methods) {
208
+ const currentMethod = ClassToWrap.prototype[method];
209
+ const originalMethod = getOriginalMethod(currentMethod);
210
+ const executingInstances = new WeakSet();
211
+ const wrappedMethod = createErrorTrackingWrapper(originalMethod, method, executingInstances, newMethod => {
212
+ ClassToWrap.prototype[method] = newMethod;
213
+ }, () => ClassToWrap.prototype[method]);
214
+ wrappedMethod[ORIGINAL_METHOD] = originalMethod;
215
+ ClassToWrap.prototype[method] = wrappedMethod;
216
+ }
217
+ }
218
+ /**
219
+ * Wraps all methods of an object with error tracking.
220
+ *
221
+ * @param object - The object whose methods should be wrapped.
222
+ */
223
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
224
+ function wrapObjectMethodsWithErrorTracking(object) {
225
+ if (process.env.DISABLE_CDP_ERROR_REPORTING === "true") {
226
+ return;
227
+ }
228
+ const methods = Object.getOwnPropertyNames(object).filter(name => name !== "constructor" && typeof object[name] === "function");
229
+ for (const method of methods) {
230
+ const currentMethod = object[method];
231
+ const originalMethod = getOriginalMethod(currentMethod);
232
+ const executingInstances = new WeakSet();
233
+ const wrappedMethod = createErrorTrackingWrapper(originalMethod, method, executingInstances, newMethod => {
234
+ object[method] = newMethod;
235
+ }, () => object[method]);
236
+ wrappedMethod[ORIGINAL_METHOD] = originalMethod;
237
+ object[method] = wrappedMethod;
238
+ }
239
+ }
240
+ /**
241
+ * Wraps all methods of a class with error tracking.
242
+ *
243
+ * @deprecated This is the old implementation that has a bug with methods calling themselves via prototype.
244
+ * Use Analytics.wrapClassWithErrorTracking instead.
245
+ * Kept for test compatibility.
246
+ *
247
+ * @param ClassToWrap - The class whose prototype methods should be wrapped.
248
+ */
249
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
250
+ function wrapClassWithErrorTrackingDeprecated(ClassToWrap) {
93
251
  if (process.env.DISABLE_CDP_ERROR_REPORTING === "true") {
94
252
  return;
95
253
  }
@@ -121,10 +279,14 @@ function wrapClassWithErrorTracking(ClassToWrap) {
121
279
  /**
122
280
  * Wraps all methods of an object with error tracking.
123
281
  *
282
+ * @deprecated This is the old implementation that has a bug with methods calling themselves via object property.
283
+ * Use Analytics.wrapObjectMethodsWithErrorTracking instead.
284
+ * Kept for test compatibility.
285
+ *
124
286
  * @param object - The object whose methods should be wrapped.
125
287
  */
126
288
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
127
- function wrapObjectMethodsWithErrorTracking(object) {
289
+ function wrapObjectMethodsWithErrorTrackingDeprecated(object) {
128
290
  if (process.env.DISABLE_CDP_ERROR_REPORTING === "true") {
129
291
  return;
130
292
  }
@@ -1 +1 @@
1
- {"version":3,"file":"analytics.js","sourceRoot":"","sources":["../analytics.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAC;AAEtB,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAgDvC,uDAAuD;AACvD,MAAM,cAAc,GAAG,kCAAkC,CAAC;AAE1D,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,UAAU,EAAE,EAAE,EAAE,gBAAgB;IAChC,0BAA0B;IAC1B,kCAAkC;IAClC,SAAS;IACT,WAAW;CACZ,CAAC;AAEF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AE,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,KAAK,YAAY,QAAQ,IAAI,KAAK,CAAC,SAAS,KAAK,kBAAkB,EAAE,CAAC;QACxE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -1,9 +1,52 @@
1
1
  import { Analytics } from "../../analytics.js";
2
- import { CdpOpenApiClient } from "../../openapi-client/index.js";
2
+ import { CdpOpenApiClient, } from "../../openapi-client/index.js";
3
3
  /**
4
4
  * The CDP end user client.
5
5
  */
6
6
  export class CDPEndUserClient {
7
+ /**
8
+ * Lists end users belonging to the developer's CDP Project.
9
+ * By default, the response is sorted by creation date in ascending order and paginated to 20 users per page.
10
+ *
11
+ * @param options - The options for listing end users.
12
+ *
13
+ * @returns A promise that resolves to a paginated list of end users.
14
+ *
15
+ * @example **List all end users**
16
+ * ```ts
17
+ * const result = await cdp.endUsers.listEndUsers();
18
+ * console.log(result.endUsers);
19
+ * ```
20
+ *
21
+ * @example **With pagination**
22
+ * ```ts
23
+ * let page = await cdp.endUsers.listEndUsers({ pageSize: 10 });
24
+ *
25
+ * while (page.nextPageToken) {
26
+ * page = await cdp.endUsers.listEndUsers({
27
+ * pageSize: 10,
28
+ * pageToken: page.nextPageToken
29
+ * });
30
+ * }
31
+ * ```
32
+ *
33
+ * @example **With sorting**
34
+ * ```ts
35
+ * const result = await cdp.endUsers.listEndUsers({
36
+ * sort: ['createdAt=desc']
37
+ * });
38
+ * ```
39
+ */
40
+ async listEndUsers(options = {}) {
41
+ Analytics.trackAction({
42
+ action: "list_end_users",
43
+ });
44
+ const params = {
45
+ ...options,
46
+ ...(options.sort && { sort: options.sort.join(",") }),
47
+ };
48
+ return CdpOpenApiClient.listEndUsers(params);
49
+ }
7
50
  /**
8
51
  * Validates an end user's access token. Throws an error if the access token is invalid.
9
52
  *
@@ -1 +1 @@
1
- {"version":3,"file":"endUser.js","sourceRoot":"","sources":["../../../client/end-user/endUser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAgB,MAAM,+BAA+B,CAAC;AAE/E;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAC3B;;;;;;OAMG;IACH,KAAK,CAAC,mBAAmB,CAAC,OAAmC;QAC3D,SAAS,CAAC,WAAW,CAAC;YACpB,MAAM,EAAE,uBAAuB;SAChC,CAAC,CAAC;QAEH,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;QAEhC,OAAO,gBAAgB,CAAC,0BAA0B,CAAC;YACjD,WAAW;SACZ,CAAC,CAAC;IACL,CAAC;CACF"}
1
+ {"version":3,"file":"endUser.js","sourceRoot":"","sources":["../../../client/end-user/endUser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EACL,gBAAgB,GAGjB,MAAM,+BAA+B,CAAC;AAEvC;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAC3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,KAAK,CAAC,YAAY,CAAC,UAA+B,EAAE;QAClD,SAAS,CAAC,WAAW,CAAC;YACpB,MAAM,EAAE,gBAAgB;SACzB,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG;YACb,GAAG,OAAO;YACV,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;SACtD,CAAC;QAEF,OAAO,gBAAgB,CAAC,YAAY,CAAC,MAA6B,CAAC,CAAC;IACtE,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,mBAAmB,CAAC,OAAmC;QAC3D,SAAS,CAAC,WAAW,CAAC;YACpB,MAAM,EAAE,uBAAuB;SAChC,CAAC,CAAC;QAEH,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;QAEhC,OAAO,gBAAgB,CAAC,0BAA0B,CAAC;YACjD,WAAW;SACZ,CAAC,CAAC;IACL,CAAC;CACF"}
package/_esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EACL,sBAAsB,EACtB,sBAAsB,GAGvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG1D,OAAO,EACL,4BAA4B,IAAI,yBAAyB,EACzD,gCAAgC,IAAI,6BAA6B,GAClE,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,OAAO,EACL,sBAAsB,EACtB,sBAAsB,GAGvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAI1D,OAAO,EACL,4BAA4B,IAAI,yBAAyB,EACzD,gCAAgC,IAAI,6BAA6B,GAClE,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC"}
package/_esm/version.js CHANGED
@@ -1,2 +1,2 @@
1
- export const version = "1.38.5";
1
+ export const version = "1.38.6";
2
2
  //# sourceMappingURL=version.js.map
@@ -48,6 +48,13 @@ export declare const Analytics: {
48
48
  sendEvent: typeof sendEvent;
49
49
  trackAction: typeof trackAction;
50
50
  };
51
+ export declare const AnalyticsDeprecated: {
52
+ identifier: string;
53
+ wrapClassWithErrorTracking: typeof wrapClassWithErrorTrackingDeprecated;
54
+ wrapObjectMethodsWithErrorTracking: typeof wrapObjectMethodsWithErrorTrackingDeprecated;
55
+ sendEvent: typeof sendEvent;
56
+ trackAction: typeof trackAction;
57
+ };
51
58
  /**
52
59
  * Sends an analytics event to the default endpoint
53
60
  *
@@ -80,5 +87,25 @@ declare function wrapClassWithErrorTracking(ClassToWrap: any): void;
80
87
  * @param object - The object whose methods should be wrapped.
81
88
  */
82
89
  declare function wrapObjectMethodsWithErrorTracking(object: any): void;
90
+ /**
91
+ * Wraps all methods of a class with error tracking.
92
+ *
93
+ * @deprecated This is the old implementation that has a bug with methods calling themselves via prototype.
94
+ * Use Analytics.wrapClassWithErrorTracking instead.
95
+ * Kept for test compatibility.
96
+ *
97
+ * @param ClassToWrap - The class whose prototype methods should be wrapped.
98
+ */
99
+ declare function wrapClassWithErrorTrackingDeprecated(ClassToWrap: any): void;
100
+ /**
101
+ * Wraps all methods of an object with error tracking.
102
+ *
103
+ * @deprecated This is the old implementation that has a bug with methods calling themselves via object property.
104
+ * Use Analytics.wrapObjectMethodsWithErrorTracking instead.
105
+ * Kept for test compatibility.
106
+ *
107
+ * @param object - The object whose methods should be wrapped.
108
+ */
109
+ declare function wrapObjectMethodsWithErrorTrackingDeprecated(object: any): void;
83
110
  export {};
84
111
  //# sourceMappingURL=analytics.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../analytics.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,KAAK,cAAc,GAAG;IACpB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,KAAK,eAAe,GAAG;IACrB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,WAAW,CAAC,EAAE,YAAY,GAAG,WAAW,GAAG,QAAQ,CAAC;IACpD;;O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ACrC;;OAEG;IACH,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAEF,KAAK,SAAS,GAAG,cAAc,GAAG,eAAe,CAAC;AAQlD,eAAO,MAAM,SAAS;;;;;;CAMrB,CAAC;AAMF,eAAO,MAAM,mBAAmB;gBAIR,MAAM;;;;;CAO7B,CAAC;AAEF;;;;;GAKG;AACH,iBAAe,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAgDxD;AAED;;;;;;;GAOG;AACH,iBAAS,WAAW,CAAC,MAAM,EAAE;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,YAAY,GAAG,WAAW,GAAG,QAAQ,CAAC;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC,GAAG,IAAI,CAmBP;AA6HD;;;;GAIG;AAEH,iBAAS,0BAA0B,CAAC,WAAW,EAAE,GAAG,GAAG,IAAI,CA8B1D;AAED;;;;GAIG;AAEH,iBAAS,kCAAkC,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CA2B7D;AAED;;;;;;;;GAQG;AAEH,iBAAS,oCAAoC,CAAC,WAAW,EAAE,GAAG,GAAG,IAAI,CAkCpE;AAED;;;;;;;;GAQG;AAEH,iBAAS,4CAA4C,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CAkCvE"}
@@ -1,9 +1,43 @@
1
- import { type ValidateAccessTokenOptions } from "./endUser.types.js";
2
- import { type EndUser } from "../../openapi-client/index.js";
1
+ import { type ValidateAccessTokenOptions, type ListEndUsersOptions } from "./endUser.types.js";
2
+ import { type EndUser, type ListEndUsers200 } from "../../openapi-client/index.js";
3
3
  /**
4
4
  * The CDP end user client.
5
5
  */
6
6
  export declare class CDPEndUserClient {
7
+ /**
8
+ * Lists end users belonging to the developer's CDP Project.
9
+ * By default, the response is sorted by creation date in ascending order and paginated to 20 users per page.
10
+ *
11
+ * @param options - The options for listing end users.
12
+ *
13
+ * @returns A promise that resolves to a paginated list of end users.
14
+ *
15
+ * @example **List all end users**
16
+ * ```ts
17
+ * const result = await cdp.endUsers.listEndUsers();
18
+ * console.log(result.endUsers);
19
+ * ```
20
+ *
21
+ * @example **With pagination**
22
+ * ```ts
23
+ * let page = await cdp.endUsers.listEndUsers({ pageSize: 10 });
24
+ *
25
+ * while (page.nextPageToken) {
26
+ * page = await cdp.endUsers.listEndUsers({
27
+ * pageSize: 10,
28
+ * pageToken: page.nextPageToken
29
+ * });
30
+ * }
31
+ * ```
32
+ *
33
+ * @example **With sorting**
34
+ * ```ts
35
+ * const result = await cdp.endUsers.listEndUsers({
36
+ * sort: ['createdAt=desc']
37
+ * });
38
+ * ```
39
+ */
40
+ listEndUsers(options?: ListEndUsersOptions): Promise<ListEndUsers200>;
7
41
  /**
8
42
  * Validates an end user's access token. Throws an error if the access token is invalid.
9
43
  *
@@ -1 +1 @@
1
- {"version":3,"file":"endUser.d.ts","sourceRoot":"","sources":["../../../client/end-user/endUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAErE,OAAO,EAAoB,KAAK,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAE/E;;GAEG;AACH,qBAAa,gBAAgB;IAC3B;;;;;;OAMG;IACG,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,OAAO,CAAC;CAWjF"}
1
+ {"version":3,"file":"endUser.d.ts","sourceRoot":"","sources":["../../../client/end-user/endUser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,0BAA0B,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE/F,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,eAAe,EACrB,MAAM,+BAA+B,CAAC;AAEvC;;GAEG;AACH,qBAAa,gBAAgB;IAC3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACG,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,eAAe,CAAC;IAa/E;;;;;;OAMG;IACG,mBAAmB,CAAC,OAAO,EAAE,0BAA0B,GAAG,OAAO,CAAC,OAAO,CAAC;CAWjF"}
@@ -1,3 +1,4 @@
1
+ import type { ListEndUsersParams } from "../../openapi-client/index.js";
1
2
  /**
2
3
  * The options for validating an access token.
3
4
  */
@@ -7,4 +8,8 @@ export interface ValidateAccessTokenOptions {
7
8
  */
8
9
  accessToken: string;
9
10
  }
11
+ /**
12
+ * The options for listing end users.
13
+ */
14
+ export type ListEndUsersOptions = ListEndUsersParams;
10
15
  //# sourceMappingURL=endUser.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"endUser.types.d.ts","sourceRoot":"","sources":["../../../client/end-user/endUser.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB"}
1
+ {"version":3,"file":"endUser.types.d.ts","sourceRoot":"","sources":["../../../client/end-user/endUser.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAExE;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,CAAC"}
package/_types/index.d.ts CHANGED
@@ -4,7 +4,8 @@ export type { Policy } from "./policies/types.js";
4
4
  export { CreatePolicyBodySchema, UpdatePolicyBodySchema, type CreatePolicyBody, type UpdatePolicyBody, } from "./policies/types.js";
5
5
  export { NetworkError } from "./openapi-client/errors.js";
6
6
  export type { SpendPermission, SpendPermissionInput } from "./spend-permissions/types.js";
7
- export type { SpendPermissionNetwork } from "./openapi-client/index.js";
7
+ export type { SpendPermissionNetwork, ListEndUsers200, EndUser } from "./openapi-client/index.js";
8
+ export type { ListEndUsersOptions } from "./client/end-user/endUser.types.js";
8
9
  export { SPEND_PERMISSION_MANAGER_ABI as spendPermissionManagerAbi, SPEND_PERMISSION_MANAGER_ADDRESS as spendPermissionManagerAddress, } from "./spend-permissions/constants.js";
9
10
  export { parseEther, parseUnits } from "viem";
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACjF,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,YAAY,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAC1F,YAAY,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,EACL,4BAA4B,IAAI,yBAAyB,EACzD,gCAAgC,IAAI,6BAA6B,GAClE,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AACjF,YAAY,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,YAAY,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAC1F,YAAY,EAAE,sBAAsB,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAClG,YAAY,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,EACL,4BAA4B,IAAI,yBAAyB,EACzD,gCAAgC,IAAI,6BAA6B,GAClE,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const version = "1.38.5";
1
+ export declare const version = "1.38.6";
2
2
  //# sourceMappingURL=version.d.ts.map
package/analytics.ts CHANGED
@@ -50,6 +50,9 @@ type ActionEventData = {
50
50
 
51
51
  type EventData = ErrorEventData | ActionEventData;
52
52
 
53
+ // Symbol to store the original method on wrapped functions
54
+ const ORIGINAL_METHOD = Symbol("originalMethod");
55
+
53
56
  // This is a public client id for the analytics service
54
57
  const publicClientId = "54f2ee2fb3d2b901a829940d70fbfc13";
55
58
 
@@ -61,6 +64,23 @@ export const Analytics = {
61
64
  trackAction,
62
65
  };
63
66
 
67
+ /*
68
+ * Deprecated implementation - kept for test compatibility
69
+ * Shares the same identifier reference as Analytics
70
+ */
71
+ export const AnalyticsDeprecated = {
72
+ get identifier() {
73
+ return Analytics.identifier;
74
+ },
75
+ set identifier(value: string) {
76
+ Analytics.identifier = value;
77
+ },
78
+ wrapClassWithErrorTracking: wrapClassWithErrorTrackingDeprecated,
79
+ wrapObjectMethodsWithErrorTracking: wrapObjectMethodsWithErrorTrackingDeprecated,
80
+ sendEvent,
81
+ trackAction,
82
+ };
83
+
64
84
  /**
65
85
  * Sends an analytics event to the default endpoint
66
86
  *
@@ -150,6 +170,129 @@ function trackAction(params: {
150
170
  });
151
171
  }
152
172
 
173
+ /**
174
+ * Gets the original method from a wrapped method, or returns the method itself if it's not wrapped.
175
+ *
176
+ * @param method - The method to get the original version of.
177
+ * @returns The original unwrapped method, or the method itself if it's not wrapped.
178
+ */
179
+ function getOriginalMethod(
180
+ method: (this: unknown, ...args: unknown[]) => Promise<unknown>,
181
+ ): (this: unknown, ...args: unknown[]) => Promise<unknown> {
182
+ return (
183
+ (method as { [ORIGINAL_METHOD]?: (this: unknown, ...args: unknown[]) => Promise<unknown> })[
184
+ ORIGINAL_METHOD
185
+ ] || method
186
+ );
187
+ }
188
+
189
+ /**
190
+ * Creates an interceptor function that prevents recursive calls by checking if the instance is already executing.
191
+ *
192
+ * @param executingInstances - A WeakSet tracking instances that are currently executing.
193
+ * @param fallbackMethod - The method to call if recursion is not detected.
194
+ * @returns A function that intercepts calls and prevents recursion.
195
+ */
196
+ function createRecursiveInterceptor(
197
+ executingInstances: WeakSet<object>,
198
+ fallbackMethod: (...args: unknown[]) => Promise<unknown>,
199
+ ): (...args: unknown[]) => Promise<unknown> {
200
+ return function (this: unknown, ...callArgs: unknown[]) {
201
+ if (executingInstances.has(this as object)) {
202
+ return Promise.resolve(callArgs[0]);
203
+ }
204
+ return fallbackMethod.apply(this, callArgs);
205
+ };
206
+ }
207
+
208
+ /**
209
+ * Executes a method with recursion protection by tracking executing instances.
210
+ *
211
+ * @param executingInstances - A WeakSet tracking instances that are currently executing.
212
+ * @param originalMethod - The original method to execute.
213
+ * @param context - The context (this) to bind the method to.
214
+ * @param args - The arguments to pass to the method.
215
+ * @returns The result of executing the original method.
216
+ */
217
+ async function executeWithRecursionProtection<T>(
218
+ executingInstances: WeakSet<object>,
219
+ originalMethod: (this: unknown, ...args: unknown[]) => Promise<T>,
220
+ context: unknown,
221
+ args: unknown[],
222
+ ): Promise<T> {
223
+ if (executingInstances.has(context as object)) {
224
+ return args[0] as T;
225
+ }
226
+ executingInstances.add(context as object);
227
+ try {
228
+ return await originalMethod.apply(context, args);
229
+ } finally {
230
+ executingInstances.delete(context as object);
231
+ }
232
+ }
233
+
234
+ /**
235
+ * Handles an error that occurred in a method by sending an analytics event and rethrowing the error.
236
+ *
237
+ * @param error - The error that occurred.
238
+ * @param methodName - The name of the method where the error occurred.
239
+ */
240
+ async function handleMethodError(error: unknown, methodName: string): Promise<void> {
241
+ if (!shouldTrackError(error)) {
242
+ throw error;
243
+ }
244
+
245
+ const { message, stack } = error as Error;
246
+ sendEvent({
247
+ method: methodName,
248
+ message,
249
+ stack,
250
+ name: "error",
251
+ }).catch(() => {
252
+ // ignore error
253
+ });
254
+
255
+ throw error;
256
+ }
257
+
258
+ /**
259
+ * Creates a wrapper function that adds error tracking and recursion protection to a method.
260
+ *
261
+ * @param originalMethod - The original method to wrap.
262
+ * @param methodName - The name of the method being wrapped.
263
+ * @param executingInstances - A WeakSet tracking instances that are currently executing.
264
+ * @param setMethod - A function to set the method implementation.
265
+ * @param getMethod - A function to get the current method implementation.
266
+ * @returns A wrapped version of the method with error tracking and recursion protection.
267
+ */
268
+ function createErrorTrackingWrapper(
269
+ originalMethod: (this: unknown, ...args: unknown[]) => Promise<unknown>,
270
+ methodName: string,
271
+ executingInstances: WeakSet<object>,
272
+ setMethod: (method: (...args: unknown[]) => Promise<unknown>) => void,
273
+ getMethod: () => (...args: unknown[]) => Promise<unknown>,
274
+ ): (this: unknown, ...args: unknown[]) => Promise<unknown> {
275
+ return async function (this: unknown, ...args: unknown[]) {
276
+ const previousMethod = getMethod();
277
+ const recursiveInterceptor = createRecursiveInterceptor(executingInstances, previousMethod);
278
+ setMethod(recursiveInterceptor);
279
+
280
+ try {
281
+ const result = await executeWithRecursionProtection(
282
+ executingInstances,
283
+ originalMethod,
284
+ this,
285
+ args,
286
+ );
287
+ setMethod(previousMethod);
288
+ return result;
289
+ } catch (error) {
290
+ setMethod(previousMethod);
291
+ return handleMethodError(error, methodName);
292
+ }
293
+ };
294
+ }
295
+
153
296
  /**
154
297
  * Wraps all methods of a class with error tracking.
155
298
  *
@@ -165,6 +308,83 @@ function wrapClassWithErrorTracking(ClassToWrap: any): void {
165
308
  name => name !== "constructor" && typeof ClassToWrap.prototype[name] === "function",
166
309
  );
167
310
 
311
+ for (const method of methods) {
312
+ const currentMethod = ClassToWrap.prototype[method];
313
+ const originalMethod = getOriginalMethod(currentMethod);
314
+ const executingInstances = new WeakSet<object>();
315
+
316
+ const wrappedMethod = createErrorTrackingWrapper(
317
+ originalMethod,
318
+ method,
319
+ executingInstances,
320
+ newMethod => {
321
+ ClassToWrap.prototype[method] = newMethod as (
322
+ this: unknown,
323
+ ...args: unknown[]
324
+ ) => Promise<unknown>;
325
+ },
326
+ () => ClassToWrap.prototype[method] as (...args: unknown[]) => Promise<unknown>,
327
+ );
328
+
329
+ (wrappedMethod as unknown as { [ORIGINAL_METHOD]: unknown })[ORIGINAL_METHOD] = originalMethod;
330
+ ClassToWrap.prototype[method] = wrappedMethod;
331
+ }
332
+ }
333
+
334
+ /**
335
+ * Wraps all methods of an object with error tracking.
336
+ *
337
+ * @param object - The object whose methods should be wrapped.
338
+ */
339
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
340
+ function wrapObjectMethodsWithErrorTracking(object: any): void {
341
+ if (process.env.DISABLE_CDP_ERROR_REPORTING === "true") {
342
+ return;
343
+ }
344
+
345
+ const methods = Object.getOwnPropertyNames(object).filter(
346
+ name => name !== "constructor" && typeof object[name] === "function",
347
+ );
348
+
349
+ for (const method of methods) {
350
+ const currentMethod = object[method];
351
+ const originalMethod = getOriginalMethod(currentMethod);
352
+ const executingInstances = new WeakSet<object>();
353
+
354
+ const wrappedMethod = createErrorTrackingWrapper(
355
+ originalMethod,
356
+ method,
357
+ executingInstances,
358
+ newMethod => {
359
+ object[method] = newMethod;
360
+ },
361
+ () => object[method] as (...args: unknown[]) => Promise<unknown>,
362
+ );
363
+
364
+ (wrappedMethod as unknown as { [ORIGINAL_METHOD]: unknown })[ORIGINAL_METHOD] = originalMethod;
365
+ object[method] = wrappedMethod;
366
+ }
367
+ }
368
+
369
+ /**
370
+ * Wraps all methods of a class with error tracking.
371
+ *
372
+ * @deprecated This is the old implementation that has a bug with methods calling themselves via prototype.
373
+ * Use Analytics.wrapClassWithErrorTracking instead.
374
+ * Kept for test compatibility.
375
+ *
376
+ * @param ClassToWrap - The class whose prototype methods should be wrapped.
377
+ */
378
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
379
+ function wrapClassWithErrorTrackingDeprecated(ClassToWrap: any): void {
380
+ if (process.env.DISABLE_CDP_ERROR_REPORTING === "true") {
381
+ return;
382
+ }
383
+
384
+ const methods = Object.getOwnPropertyNames(ClassToWrap.prototype).filter(
385
+ name => name !== "constructor" && typeof ClassToWrap.prototype[name] === "function",
386
+ );
387
+
168
388
  for (const method of methods) {
169
389
  const originalMethod = ClassToWrap.prototype[method];
170
390
  ClassToWrap.prototype[method] = async function (...args: unknown[]) {
@@ -195,10 +415,14 @@ function wrapClassWithErrorTracking(ClassToWrap: any): void {
195
415
  /**
196
416
  * Wraps all methods of an object with error tracking.
197
417
  *
418
+ * @deprecated This is the old implementation that has a bug with methods calling themselves via object property.
419
+ * Use Analytics.wrapObjectMethodsWithErrorTracking instead.
420
+ * Kept for test compatibility.
421
+ *
198
422
  * @param object - The object whose methods should be wrapped.
199
423
  */
200
424
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
201
- function wrapObjectMethodsWithErrorTracking(object: any): void {
425
+ function wrapObjectMethodsWithErrorTrackingDeprecated(object: any): void {
202
426
  if (process.env.DISABLE_CDP_ERROR_REPORTING === "true") {
203
427
  return;
204
428
  }
@@ -1,11 +1,61 @@
1
- import { type ValidateAccessTokenOptions } from "./endUser.types.js";
1
+ import { type ValidateAccessTokenOptions, type ListEndUsersOptions } from "./endUser.types.js";
2
2
  import { Analytics } from "../../analytics.js";
3
- import { CdpOpenApiClient, type EndUser } from "../../openapi-client/index.js";
3
+ import {
4
+ CdpOpenApiClient,
5
+ type EndUser,
6
+ type ListEndUsers200,
7
+ } from "../../openapi-client/index.js";
4
8
 
5
9
  /**
6
10
  * The CDP end user client.
7
11
  */
8
12
  export class CDPEndUserClient {
13
+ /**
14
+ * Lists end users belonging to the developer's CDP Project.
15
+ * By default, the response is sorted by creation date in ascending order and paginated to 20 users per page.
16
+ *
17
+ * @param options - The options for listing end users.
18
+ *
19
+ * @returns A promise that resolves to a paginated list of end users.
20
+ *
21
+ * @example **List all end users**
22
+ * ```ts
23
+ * const result = await cdp.endUsers.listEndUsers();
24
+ * console.log(result.endUsers);
25
+ * ```
26
+ *
27
+ * @example **With pagination**
28
+ * ```ts
29
+ * let page = await cdp.endUsers.listEndUsers({ pageSize: 10 });
30
+ *
31
+ * while (page.nextPageToken) {
32
+ * page = await cdp.endUsers.listEndUsers({
33
+ * pageSize: 10,
34
+ * pageToken: page.nextPageToken
35
+ * });
36
+ * }
37
+ * ```
38
+ *
39
+ * @example **With sorting**
40
+ * ```ts
41
+ * const result = await cdp.endUsers.listEndUsers({
42
+ * sort: ['createdAt=desc']
43
+ * });
44
+ * ```
45
+ */
46
+ async listEndUsers(options: ListEndUsersOptions = {}): Promise<ListEndUsers200> {
47
+ Analytics.trackAction({
48
+ action: "list_end_users",
49
+ });
50
+
51
+ const params = {
52
+ ...options,
53
+ ...(options.sort && { sort: options.sort.join(",") }),
54
+ };
55
+
56
+ return CdpOpenApiClient.listEndUsers(params as ListEndUsersOptions);
57
+ }
58
+
9
59
  /**
10
60
  * Validates an end user's access token. Throws an error if the access token is invalid.
11
61
  *
@@ -1,3 +1,5 @@
1
+ import type { ListEndUsersParams } from "../../openapi-client/index.js";
2
+
1
3
  /**
2
4
  * The options for validating an access token.
3
5
  */
@@ -7,3 +9,8 @@ export interface ValidateAccessTokenOptions {
7
9
  */
8
10
  accessToken: string;
9
11
  }
12
+
13
+ /**
14
+ * The options for listing end users.
15
+ */
16
+ export type ListEndUsersOptions = ListEndUsersParams;
package/index.ts CHANGED
@@ -9,7 +9,8 @@ export {
9
9
  } from "./policies/types.js";
10
10
  export { NetworkError } from "./openapi-client/errors.js";
11
11
  export type { SpendPermission, SpendPermissionInput } from "./spend-permissions/types.js";
12
- export type { SpendPermissionNetwork } from "./openapi-client/index.js";
12
+ export type { SpendPermissionNetwork, ListEndUsers200, EndUser } from "./openapi-client/index.js";
13
+ export type { ListEndUsersOptions } from "./client/end-user/endUser.types.js";
13
14
  export {
14
15
  SPEND_PERMISSION_MANAGER_ABI as spendPermissionManagerAbi,
15
16
  SPEND_PERMISSION_MANAGER_ADDRESS as spendPermissionManagerAddress,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cdp-sdk",
3
- "version": "1.38.5",
3
+ "version": "1.38.6",
4
4
  "description": "SDK for interacting with the Coinbase Developer Platform Wallet API",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
package/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = "1.38.5";
1
+ export const version = "1.38.6";