@larksuiteoapi/node-sdk 1.62.0 → 1.62.1

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/es/index.js CHANGED
@@ -146,19 +146,21 @@ function getSdkVersion() {
146
146
  function sanitizeSource(raw) {
147
147
  return raw.replace(/[^a-zA-Z0-9._-]/g, '_').slice(0, 64);
148
148
  }
149
- /**
150
- * Build the User-Agent value. When `source` is provided it appends a
151
- * `source/<sanitized>` product token, e.g.
152
- * oapi-node-sdk/1.62.0 source/cursor-bot
153
- * Falsy or all-invalid-char `source` values produce the base UA without
154
- * the extra token.
155
- */
156
- function buildUserAgent(source) {
157
- const base = `oapi-node-sdk/${getSdkVersion()}`;
158
- if (!source)
159
- return base;
160
- const clean = sanitizeSource(source);
161
- return clean ? `${base} source/${clean}` : base;
149
+ function buildUserAgent(source, opts) {
150
+ let ua = `oapi-node-sdk/${getSdkVersion()}`;
151
+ if (source) {
152
+ const clean = sanitizeSource(source);
153
+ if (clean)
154
+ ua += ` source/${clean}`;
155
+ }
156
+ if (opts === null || opts === void 0 ? void 0 : opts.extraTags) {
157
+ for (const t of opts.extraTags) {
158
+ const clean = sanitizeSource(t);
159
+ if (clean)
160
+ ua += ` ${clean}`;
161
+ }
162
+ }
163
+ return ua;
162
164
  }
163
165
 
164
166
  const defaultHttpInstance = axios.create();
@@ -83993,7 +83995,7 @@ class Client extends Client$1 {
83993
83995
  this.appId = params.appId;
83994
83996
  this.appSecret = params.appSecret;
83995
83997
  this.disableTokenCache = params.disableTokenCache;
83996
- this.userAgent = buildUserAgent(params.source);
83998
+ this.userAgent = buildUserAgent(params.source, { extraTags: params.extraUaTags });
83997
83999
  assert(!this.appId, () => this.logger.error('appId is needed'));
83998
84000
  assert(!this.appSecret, () => this.logger.error('appSecret is needed'));
83999
84001
  this.helpDeskId = params.helpDeskId;
@@ -85362,8 +85364,8 @@ class WSClient {
85362
85364
  /** True if the WS has ever connected successfully in this client's
85363
85365
  * lifetime — used to distinguish first-connect from reconnect. */
85364
85366
  this.hasEverConnected = false;
85365
- const { appId, appSecret, agent, domain = Domain.Feishu, httpInstance = defaultHttpInstance, loggerLevel = LoggerLevel.info, logger = defaultLogger, autoReconnect = true, source, onReady, onError, onReconnecting, onReconnected, } = params;
85366
- this.userAgent = buildUserAgent(source);
85367
+ const { appId, appSecret, agent, domain = Domain.Feishu, httpInstance = defaultHttpInstance, loggerLevel = LoggerLevel.info, logger = defaultLogger, autoReconnect = true, source, extraUaTags, onReady, onError, onReconnecting, onReconnected, } = params;
85368
+ this.userAgent = buildUserAgent(source, { extraTags: extraUaTags });
85367
85369
  this.logger = new LoggerProxy(loggerLevel, logger);
85368
85370
  assert(!appId, () => this.logger.error('appId is needed'));
85369
85371
  assert(!appSecret, () => this.logger.error('appSecret is needed'));
@@ -89328,6 +89330,7 @@ class LarkChannel {
89328
89330
  logger: opts.logger,
89329
89331
  loggerLevel: opts.loggerLevel,
89330
89332
  source: opts.source,
89333
+ extraUaTags: ['channel'],
89331
89334
  });
89332
89335
  this.dispatcher = new EventDispatcher({
89333
89336
  verificationToken: (_d = opts.webhook) === null || _d === void 0 ? void 0 : _d.verificationToken,
@@ -89405,6 +89408,7 @@ class LarkChannel {
89405
89408
  httpInstance: this.opts.httpInstance,
89406
89409
  autoReconnect: true,
89407
89410
  source: this.opts.source,
89411
+ extraUaTags: ['channel'],
89408
89412
  onReady: () => {
89409
89413
  if (settled)
89410
89414
  return;
package/lib/index.js CHANGED
@@ -164,19 +164,21 @@ function getSdkVersion() {
164
164
  function sanitizeSource(raw) {
165
165
  return raw.replace(/[^a-zA-Z0-9._-]/g, '_').slice(0, 64);
166
166
  }
167
- /**
168
- * Build the User-Agent value. When `source` is provided it appends a
169
- * `source/<sanitized>` product token, e.g.
170
- * oapi-node-sdk/1.62.0 source/cursor-bot
171
- * Falsy or all-invalid-char `source` values produce the base UA without
172
- * the extra token.
173
- */
174
- function buildUserAgent(source) {
175
- const base = `oapi-node-sdk/${getSdkVersion()}`;
176
- if (!source)
177
- return base;
178
- const clean = sanitizeSource(source);
179
- return clean ? `${base} source/${clean}` : base;
167
+ function buildUserAgent(source, opts) {
168
+ let ua = `oapi-node-sdk/${getSdkVersion()}`;
169
+ if (source) {
170
+ const clean = sanitizeSource(source);
171
+ if (clean)
172
+ ua += ` source/${clean}`;
173
+ }
174
+ if (opts === null || opts === void 0 ? void 0 : opts.extraTags) {
175
+ for (const t of opts.extraTags) {
176
+ const clean = sanitizeSource(t);
177
+ if (clean)
178
+ ua += ` ${clean}`;
179
+ }
180
+ }
181
+ return ua;
180
182
  }
181
183
 
182
184
  const defaultHttpInstance = axios__default["default"].create();
@@ -84011,7 +84013,7 @@ class Client extends Client$1 {
84011
84013
  this.appId = params.appId;
84012
84014
  this.appSecret = params.appSecret;
84013
84015
  this.disableTokenCache = params.disableTokenCache;
84014
- this.userAgent = buildUserAgent(params.source);
84016
+ this.userAgent = buildUserAgent(params.source, { extraTags: params.extraUaTags });
84015
84017
  assert(!this.appId, () => this.logger.error('appId is needed'));
84016
84018
  assert(!this.appSecret, () => this.logger.error('appSecret is needed'));
84017
84019
  this.helpDeskId = params.helpDeskId;
@@ -85380,8 +85382,8 @@ class WSClient {
85380
85382
  /** True if the WS has ever connected successfully in this client's
85381
85383
  * lifetime — used to distinguish first-connect from reconnect. */
85382
85384
  this.hasEverConnected = false;
85383
- const { appId, appSecret, agent, domain = exports.Domain.Feishu, httpInstance = defaultHttpInstance, loggerLevel = exports.LoggerLevel.info, logger = defaultLogger, autoReconnect = true, source, onReady, onError, onReconnecting, onReconnected, } = params;
85384
- this.userAgent = buildUserAgent(source);
85385
+ const { appId, appSecret, agent, domain = exports.Domain.Feishu, httpInstance = defaultHttpInstance, loggerLevel = exports.LoggerLevel.info, logger = defaultLogger, autoReconnect = true, source, extraUaTags, onReady, onError, onReconnecting, onReconnected, } = params;
85386
+ this.userAgent = buildUserAgent(source, { extraTags: extraUaTags });
85385
85387
  this.logger = new LoggerProxy(loggerLevel, logger);
85386
85388
  assert(!appId, () => this.logger.error('appId is needed'));
85387
85389
  assert(!appSecret, () => this.logger.error('appSecret is needed'));
@@ -89346,6 +89348,7 @@ class LarkChannel {
89346
89348
  logger: opts.logger,
89347
89349
  loggerLevel: opts.loggerLevel,
89348
89350
  source: opts.source,
89351
+ extraUaTags: ['channel'],
89349
89352
  });
89350
89353
  this.dispatcher = new EventDispatcher({
89351
89354
  verificationToken: (_d = opts.webhook) === null || _d === void 0 ? void 0 : _d.verificationToken,
@@ -89423,6 +89426,7 @@ class LarkChannel {
89423
89426
  httpInstance: this.opts.httpInstance,
89424
89427
  autoReconnect: true,
89425
89428
  source: this.opts.source,
89429
+ extraUaTags: ['channel'],
89426
89430
  onReady: () => {
89427
89431
  if (settled)
89428
89432
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@larksuiteoapi/node-sdk",
3
- "version": "1.62.0",
3
+ "version": "1.62.1",
4
4
  "description": "larksuite open sdk for nodejs",
5
5
  "keywords": [
6
6
  "feishu",
package/types/index.d.ts CHANGED
@@ -112,6 +112,8 @@ interface IClientParams {
112
112
  httpInstance?: HttpInstance;
113
113
  /** Caller tag appended to User-Agent as `source/<name>`. */
114
114
  source?: string;
115
+ /** @internal Extra bare tokens appended to User-Agent, set by sub-modules. */
116
+ extraUaTags?: string[];
115
117
  }
116
118
  interface IPayload {
117
119
  params?: Record<string, any>;
@@ -293052,6 +293054,8 @@ interface IConstructorParams {
293052
293054
  agent?: any;
293053
293055
  /** Caller tag appended to User-Agent as `source/<name>`. */
293054
293056
  source?: string;
293057
+ /** @internal Extra bare tokens appended to User-Agent, set by sub-modules. */
293058
+ extraUaTags?: string[];
293055
293059
  /** Fires once when the first WebSocket handshake succeeds. */
293056
293060
  onReady?: () => void;
293057
293061
  /**