diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 48a9d8d75..763033fff 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,12 +14,13 @@ jobs: node-version: 18 registry-url: 'https://registry.npmjs.org' - run: npm install - - name: Update version in package.json, package-lock.json + - name: Update version in package.json, package-lock.json, and lib/version.ts run: | VERSION=${{ github.event.release.tag_name }} VERSION=${VERSION#v} sed -i "s/__LINE_BOT_SDK_NODEJS_VERSION__/$VERSION/g" package.json sed -i "s/__LINE_BOT_SDK_NODEJS_VERSION__/$VERSION/g" package-lock.json + sed -i "s/__LINE_BOT_SDK_NODEJS_VERSION__/$VERSION/g" lib/version.ts - run: npm run release env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/generator/src/main/resources/line-bot-sdk-nodejs-generator/api_test.pebble b/generator/src/main/resources/line-bot-sdk-nodejs-generator/api_test.pebble index 0b0ba2498..74005d494 100644 --- a/generator/src/main/resources/line-bot-sdk-nodejs-generator/api_test.pebble +++ b/generator/src/main/resources/line-bot-sdk-nodejs-generator/api_test.pebble @@ -10,8 +10,6 @@ import { {{import.classname}} } from '../{{import.filename}}'; import { createServer } from "node:http"; import { deepEqual, equal, ok } from "node:assert"; -const pkg = require("../../../../package.json"); - const channel_access_token = "test_channel_access_token"; {% macro paramDummyValue(param) %} @@ -73,7 +71,7 @@ const channel_access_token = "test_channel_access_token"; {% endif -%} equal( req.headers["user-agent"], - `${pkg.name}/${pkg.version}`, + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", ); {% if op.isMultipart %} ok( diff --git a/lib/channel-access-token/tests/api/ChannelAccessTokenClientTest.spec.ts b/lib/channel-access-token/tests/api/ChannelAccessTokenClientTest.spec.ts index 60e555bac..cd55897d2 100644 --- a/lib/channel-access-token/tests/api/ChannelAccessTokenClientTest.spec.ts +++ b/lib/channel-access-token/tests/api/ChannelAccessTokenClientTest.spec.ts @@ -10,8 +10,6 @@ import { VerifyChannelAccessTokenResponse } from "../../model/verifyChannelAcces import { createServer } from "node:http"; import { deepEqual, equal, ok } from "node:assert"; -const pkg = require("../../../../package.json"); - const channel_access_token = "test_channel_access_token"; describe("ChannelAccessTokenClient", () => { @@ -47,7 +45,10 @@ describe("ChannelAccessTokenClient", () => { ), ); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -110,7 +111,10 @@ describe("ChannelAccessTokenClient", () => { ), ); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -157,7 +161,10 @@ describe("ChannelAccessTokenClient", () => { .replace("{clientSecret}", "DUMMY"), // string ); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -207,7 +214,10 @@ describe("ChannelAccessTokenClient", () => { .replace("{clientSecret}", "DUMMY"), // string ); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -257,7 +267,10 @@ describe("ChannelAccessTokenClient", () => { .replace("{clientAssertion}", "DUMMY"), // string ); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -307,7 +320,10 @@ describe("ChannelAccessTokenClient", () => { .replace("{clientAssertion}", "DUMMY"), // string ); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -359,7 +375,10 @@ describe("ChannelAccessTokenClient", () => { .replace("{clientSecret}", "DUMMY"), // string ); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -417,7 +436,10 @@ describe("ChannelAccessTokenClient", () => { .replace("{clientSecret}", "DUMMY"), // string ); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -470,7 +492,10 @@ describe("ChannelAccessTokenClient", () => { "/v2/oauth/revoke".replace("{accessToken}", "DUMMY"), // string ); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -511,7 +536,10 @@ describe("ChannelAccessTokenClient", () => { "/v2/oauth/revoke".replace("{accessToken}", "DUMMY"), // string ); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -555,7 +583,10 @@ describe("ChannelAccessTokenClient", () => { .replace("{accessToken}", "DUMMY"), // string ); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -605,7 +636,10 @@ describe("ChannelAccessTokenClient", () => { .replace("{accessToken}", "DUMMY"), // string ); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -652,7 +686,10 @@ describe("ChannelAccessTokenClient", () => { "/v2/oauth/verify".replace("{accessToken}", "DUMMY"), // string ); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -693,7 +730,10 @@ describe("ChannelAccessTokenClient", () => { "/v2/oauth/verify".replace("{accessToken}", "DUMMY"), // string ); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -744,7 +784,10 @@ describe("ChannelAccessTokenClient", () => { ), ); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -795,7 +838,10 @@ describe("ChannelAccessTokenClient", () => { ), ); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); diff --git a/lib/http-axios.ts b/lib/http-axios.ts index 9a3f8a5d7..aa6176f78 100644 --- a/lib/http-axios.ts +++ b/lib/http-axios.ts @@ -6,8 +6,7 @@ import axios, { } from "axios"; import { Readable } from "node:stream"; import { HTTPError, ReadError, RequestError } from "./exceptions"; - -const pkg = require("../package.json"); +import { USER_AGENT } from "./version"; interface httpClientConfig extends Partial { baseURL?: string; @@ -25,7 +24,7 @@ export default class HTTPClient { this.instance = axios.create({ baseURL, headers: Object.assign({}, defaultHeaders, { - "User-Agent": `${pkg.name}/${pkg.version}`, + "User-Agent": USER_AGENT, }), }); diff --git a/lib/http-fetch.ts b/lib/http-fetch.ts index ab290800e..9e731ed99 100644 --- a/lib/http-fetch.ts +++ b/lib/http-fetch.ts @@ -1,7 +1,7 @@ import { Readable } from "node:stream"; import { HTTPFetchError } from "./exceptions"; +import { USER_AGENT } from "./version"; -const pkg = require("../package.json"); export interface FetchRequestConfig { headers?: Record; } @@ -32,7 +32,7 @@ export default class HTTPFetchClient { constructor(config: httpFetchClientConfig) { this.baseURL = config.baseURL; this.defaultHeaders = { - "User-Agent": `${pkg.name}/${pkg.version}`, + "User-Agent": USER_AGENT, ...config.defaultHeaders, }; } diff --git a/lib/insight/tests/api/InsightClientTest.spec.ts b/lib/insight/tests/api/InsightClientTest.spec.ts index c4d9f00c8..920c04a63 100644 --- a/lib/insight/tests/api/InsightClientTest.spec.ts +++ b/lib/insight/tests/api/InsightClientTest.spec.ts @@ -9,8 +9,6 @@ import { GetStatisticsPerUnitResponse } from "../../model/getStatisticsPerUnitRe import { createServer } from "node:http"; import { deepEqual, equal, ok } from "node:assert"; -const pkg = require("../../../../package.json"); - const channel_access_token = "test_channel_access_token"; describe("InsightClient", () => { @@ -25,7 +23,10 @@ describe("InsightClient", () => { equal(reqUrl.pathname, "/v2/bot/insight/demographic"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -62,7 +63,10 @@ describe("InsightClient", () => { equal(reqUrl.pathname, "/v2/bot/insight/demographic"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -112,7 +116,10 @@ describe("InsightClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -165,7 +172,10 @@ describe("InsightClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -218,7 +228,10 @@ describe("InsightClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -271,7 +284,10 @@ describe("InsightClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -324,7 +340,10 @@ describe("InsightClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -377,7 +396,10 @@ describe("InsightClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -447,7 +469,10 @@ describe("InsightClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -523,7 +548,10 @@ describe("InsightClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); diff --git a/lib/liff/tests/api/LiffClientTest.spec.ts b/lib/liff/tests/api/LiffClientTest.spec.ts index 2593dd9ee..192bc6952 100644 --- a/lib/liff/tests/api/LiffClientTest.spec.ts +++ b/lib/liff/tests/api/LiffClientTest.spec.ts @@ -8,8 +8,6 @@ import { UpdateLiffAppRequest } from "../../model/updateLiffAppRequest"; import { createServer } from "node:http"; import { deepEqual, equal, ok } from "node:assert"; -const pkg = require("../../../../package.json"); - const channel_access_token = "test_channel_access_token"; describe("LiffClient", () => { @@ -24,7 +22,10 @@ describe("LiffClient", () => { equal(reqUrl.pathname, "/liff/v1/apps"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -64,7 +65,10 @@ describe("LiffClient", () => { equal(reqUrl.pathname, "/liff/v1/apps"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -107,7 +111,10 @@ describe("LiffClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -150,7 +157,10 @@ describe("LiffClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -190,7 +200,10 @@ describe("LiffClient", () => { equal(reqUrl.pathname, "/liff/v1/apps"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -227,7 +240,10 @@ describe("LiffClient", () => { equal(reqUrl.pathname, "/liff/v1/apps"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -267,7 +283,10 @@ describe("LiffClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -313,7 +332,10 @@ describe("LiffClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); diff --git a/lib/manage-audience/tests/api/ManageAudienceBlobClientTest.spec.ts b/lib/manage-audience/tests/api/ManageAudienceBlobClientTest.spec.ts index ebf6cad8f..05bd67a7f 100644 --- a/lib/manage-audience/tests/api/ManageAudienceBlobClientTest.spec.ts +++ b/lib/manage-audience/tests/api/ManageAudienceBlobClientTest.spec.ts @@ -5,8 +5,6 @@ import { CreateAudienceGroupResponse } from "../../model/createAudienceGroupResp import { createServer } from "node:http"; import { deepEqual, equal, ok } from "node:assert"; -const pkg = require("../../../../package.json"); - const channel_access_token = "test_channel_access_token"; describe("ManageAudienceBlobClient", () => { @@ -26,7 +24,10 @@ describe("ManageAudienceBlobClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); ok( req.headers["content-type"].startsWith( @@ -83,7 +84,10 @@ describe("ManageAudienceBlobClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); ok( req.headers["content-type"].startsWith( @@ -140,7 +144,10 @@ describe("ManageAudienceBlobClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); ok( req.headers["content-type"].startsWith( @@ -200,7 +207,10 @@ describe("ManageAudienceBlobClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); ok( req.headers["content-type"].startsWith( diff --git a/lib/manage-audience/tests/api/ManageAudienceClientTest.spec.ts b/lib/manage-audience/tests/api/ManageAudienceClientTest.spec.ts index 52139b855..c42077d8a 100644 --- a/lib/manage-audience/tests/api/ManageAudienceClientTest.spec.ts +++ b/lib/manage-audience/tests/api/ManageAudienceClientTest.spec.ts @@ -19,8 +19,6 @@ import { UpdateAudienceGroupDescriptionRequest } from "../../model/updateAudienc import { createServer } from "node:http"; import { deepEqual, equal, ok } from "node:assert"; -const pkg = require("../../../../package.json"); - const channel_access_token = "test_channel_access_token"; describe("ManageAudienceClient", () => { @@ -41,7 +39,10 @@ describe("ManageAudienceClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -87,7 +88,10 @@ describe("ManageAudienceClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -127,7 +131,10 @@ describe("ManageAudienceClient", () => { equal(reqUrl.pathname, "/v2/bot/audienceGroup/upload"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -167,7 +174,10 @@ describe("ManageAudienceClient", () => { equal(reqUrl.pathname, "/v2/bot/audienceGroup/upload"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -207,7 +217,10 @@ describe("ManageAudienceClient", () => { equal(reqUrl.pathname, "/v2/bot/audienceGroup/upload"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -247,7 +260,10 @@ describe("ManageAudienceClient", () => { equal(reqUrl.pathname, "/v2/bot/audienceGroup/upload"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -287,7 +303,10 @@ describe("ManageAudienceClient", () => { equal(reqUrl.pathname, "/v2/bot/audienceGroup/click"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -327,7 +346,10 @@ describe("ManageAudienceClient", () => { equal(reqUrl.pathname, "/v2/bot/audienceGroup/click"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -367,7 +389,10 @@ describe("ManageAudienceClient", () => { equal(reqUrl.pathname, "/v2/bot/audienceGroup/imp"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -407,7 +432,10 @@ describe("ManageAudienceClient", () => { equal(reqUrl.pathname, "/v2/bot/audienceGroup/imp"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -453,7 +481,10 @@ describe("ManageAudienceClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -499,7 +530,10 @@ describe("ManageAudienceClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -545,7 +579,10 @@ describe("ManageAudienceClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -591,7 +628,10 @@ describe("ManageAudienceClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -631,7 +671,10 @@ describe("ManageAudienceClient", () => { equal(reqUrl.pathname, "/v2/bot/audienceGroup/authorityLevel"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -668,7 +711,10 @@ describe("ManageAudienceClient", () => { equal(reqUrl.pathname, "/v2/bot/audienceGroup/authorityLevel"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -756,7 +802,10 @@ describe("ManageAudienceClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -862,7 +911,10 @@ describe("ManageAudienceClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -917,7 +969,10 @@ describe("ManageAudienceClient", () => { equal(reqUrl.pathname, "/v2/bot/audienceGroup/authorityLevel"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -957,7 +1012,10 @@ describe("ManageAudienceClient", () => { equal(reqUrl.pathname, "/v2/bot/audienceGroup/authorityLevel"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -1003,7 +1061,10 @@ describe("ManageAudienceClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -1052,7 +1113,10 @@ describe("ManageAudienceClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); diff --git a/lib/messaging-api/tests/api/MessagingApiBlobClientTest.spec.ts b/lib/messaging-api/tests/api/MessagingApiBlobClientTest.spec.ts index dc9759328..d1ac1d4dc 100644 --- a/lib/messaging-api/tests/api/MessagingApiBlobClientTest.spec.ts +++ b/lib/messaging-api/tests/api/MessagingApiBlobClientTest.spec.ts @@ -5,8 +5,6 @@ import { GetMessageContentTranscodingResponse } from "../../model/getMessageCont import { createServer } from "node:http"; import { deepEqual, equal, ok } from "node:assert"; -const pkg = require("../../../../package.json"); - const channel_access_token = "test_channel_access_token"; describe("MessagingApiBlobClient", () => { @@ -24,7 +22,10 @@ describe("MessagingApiBlobClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -67,7 +68,10 @@ describe("MessagingApiBlobClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -113,7 +117,10 @@ describe("MessagingApiBlobClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -159,7 +166,10 @@ describe("MessagingApiBlobClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -205,7 +215,10 @@ describe("MessagingApiBlobClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -252,7 +265,10 @@ describe("MessagingApiBlobClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -298,7 +314,10 @@ describe("MessagingApiBlobClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -344,7 +363,10 @@ describe("MessagingApiBlobClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -390,7 +412,10 @@ describe("MessagingApiBlobClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -439,7 +464,10 @@ describe("MessagingApiBlobClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); diff --git a/lib/messaging-api/tests/api/MessagingApiClientTest.spec.ts b/lib/messaging-api/tests/api/MessagingApiClientTest.spec.ts index 7bcc5b1ab..fb7021cbc 100644 --- a/lib/messaging-api/tests/api/MessagingApiClientTest.spec.ts +++ b/lib/messaging-api/tests/api/MessagingApiClientTest.spec.ts @@ -48,8 +48,6 @@ import { ValidateMessageRequest } from "../../model/validateMessageRequest"; import { createServer } from "node:http"; import { deepEqual, equal, ok } from "node:assert"; -const pkg = require("../../../../package.json"); - const channel_access_token = "test_channel_access_token"; describe("MessagingApiClient", () => { @@ -64,7 +62,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/bot/ad/multicast/phone"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -104,7 +105,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/bot/ad/multicast/phone"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -147,7 +151,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -193,7 +200,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -236,7 +246,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/user/all/richmenu"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -273,7 +286,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/user/all/richmenu"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -310,7 +326,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/richmenu"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -350,7 +369,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/richmenu"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -390,7 +412,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/richmenu/alias"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -430,7 +455,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/richmenu/alias"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -473,7 +501,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -516,7 +547,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -562,7 +596,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -608,7 +645,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -661,7 +701,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -714,7 +757,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -776,7 +822,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -841,7 +890,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -884,7 +936,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/message/aggregation/info"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -921,7 +976,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/message/aggregation/info"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -958,7 +1016,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/info"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -995,7 +1056,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/info"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -1032,7 +1096,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/user/all/richmenu"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -1069,7 +1136,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/user/all/richmenu"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -1128,7 +1198,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -1193,7 +1266,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -1239,7 +1315,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -1282,7 +1361,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -1327,7 +1409,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -1375,7 +1460,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -1433,7 +1521,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -1491,7 +1582,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -1537,7 +1631,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -1580,7 +1677,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -1620,7 +1720,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/message/quota"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -1657,7 +1760,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/message/quota"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -1694,7 +1800,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/message/quota/consumption"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -1731,7 +1840,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/message/quota/consumption"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -1781,7 +1893,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -1834,7 +1949,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -1887,7 +2005,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -1940,7 +2061,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -1993,7 +2117,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -2046,7 +2173,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -2099,7 +2229,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -2152,7 +2285,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -2205,7 +2341,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -2258,7 +2397,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -2311,7 +2453,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -2364,7 +2509,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -2407,7 +2555,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -2450,7 +2601,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -2493,7 +2647,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -2536,7 +2693,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -2582,7 +2742,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -2628,7 +2791,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -2668,7 +2834,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/richmenu/alias/list"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -2705,7 +2874,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/richmenu/alias/list"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -2755,7 +2927,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -2808,7 +2983,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -2851,7 +3029,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -2894,7 +3075,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -2934,7 +3118,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/richmenu/list"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -2971,7 +3158,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/richmenu/list"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -3011,7 +3201,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -3054,7 +3247,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -3099,7 +3295,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -3147,7 +3346,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -3205,7 +3407,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -3263,7 +3468,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -3306,7 +3514,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/channel/webhook/endpoint"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -3343,7 +3554,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/channel/webhook/endpoint"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -3383,7 +3597,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -3426,7 +3643,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -3469,7 +3689,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -3512,7 +3735,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -3555,7 +3781,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -3598,7 +3827,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -3643,7 +3875,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -3691,7 +3926,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -3734,7 +3972,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/richmenu/bulk/link"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -3774,7 +4015,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/richmenu/bulk/link"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -3814,7 +4058,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/message/markAsRead"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -3854,7 +4101,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/message/markAsRead"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -3897,7 +4147,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -3943,7 +4196,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -3989,7 +4245,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -4035,7 +4294,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -4081,7 +4343,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -4127,7 +4392,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -4173,7 +4441,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -4219,7 +4490,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -4262,7 +4536,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/message/reply"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -4302,7 +4579,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/message/reply"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -4342,7 +4622,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/richmenu/batch"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -4382,7 +4665,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/richmenu/batch"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -4428,7 +4714,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -4474,7 +4763,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -4514,7 +4806,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/channel/webhook/endpoint"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -4554,7 +4849,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/channel/webhook/endpoint"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -4594,7 +4892,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/channel/webhook/test"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -4634,7 +4935,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/channel/webhook/test"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -4677,7 +4981,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -4720,7 +5027,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -4760,7 +5070,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/richmenu/bulk/unlink"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -4800,7 +5113,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/richmenu/bulk/unlink"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -4846,7 +5162,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -4895,7 +5214,10 @@ describe("MessagingApiClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -4938,7 +5260,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/message/validate/broadcast"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -4978,7 +5303,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/message/validate/broadcast"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -5018,7 +5346,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/message/validate/multicast"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -5058,7 +5389,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/message/validate/multicast"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -5098,7 +5432,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/message/validate/narrowcast"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -5138,7 +5475,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/message/validate/narrowcast"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -5178,7 +5518,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/message/validate/push"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -5218,7 +5561,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/message/validate/push"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -5258,7 +5604,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/message/validate/reply"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -5298,7 +5647,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/message/validate/reply"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -5338,7 +5690,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/richmenu/validate/batch"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -5378,7 +5733,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/richmenu/validate/batch"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -5418,7 +5776,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/richmenu/validate"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -5458,7 +5819,10 @@ describe("MessagingApiClient", () => { equal(reqUrl.pathname, "/v2/bot/richmenu/validate"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); diff --git a/lib/module-attach/tests/api/LineModuleAttachClientTest.spec.ts b/lib/module-attach/tests/api/LineModuleAttachClientTest.spec.ts index 0e39ab223..d7c9f0081 100644 --- a/lib/module-attach/tests/api/LineModuleAttachClientTest.spec.ts +++ b/lib/module-attach/tests/api/LineModuleAttachClientTest.spec.ts @@ -5,8 +5,6 @@ import { AttachModuleResponse } from "../../model/attachModuleResponse"; import { createServer } from "node:http"; import { deepEqual, equal, ok } from "node:assert"; -const pkg = require("../../../../package.json"); - const channel_access_token = "test_channel_access_token"; describe("LineModuleAttachClient", () => { @@ -34,7 +32,10 @@ describe("LineModuleAttachClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -114,7 +115,10 @@ describe("LineModuleAttachClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); diff --git a/lib/module/tests/api/LineModuleClientTest.spec.ts b/lib/module/tests/api/LineModuleClientTest.spec.ts index e1b30adee..9132ba8a4 100644 --- a/lib/module/tests/api/LineModuleClientTest.spec.ts +++ b/lib/module/tests/api/LineModuleClientTest.spec.ts @@ -7,8 +7,6 @@ import { GetModulesResponse } from "../../model/getModulesResponse"; import { createServer } from "node:http"; import { deepEqual, equal, ok } from "node:assert"; -const pkg = require("../../../../package.json"); - const channel_access_token = "test_channel_access_token"; describe("LineModuleClient", () => { @@ -26,7 +24,10 @@ describe("LineModuleClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -72,7 +73,10 @@ describe("LineModuleClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -115,7 +119,10 @@ describe("LineModuleClient", () => { equal(reqUrl.pathname, "/v2/bot/channel/detach"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -155,7 +162,10 @@ describe("LineModuleClient", () => { equal(reqUrl.pathname, "/v2/bot/channel/detach"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -217,7 +227,10 @@ describe("LineModuleClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -282,7 +295,10 @@ describe("LineModuleClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -328,7 +344,10 @@ describe("LineModuleClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -371,7 +390,10 @@ describe("LineModuleClient", () => { ); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); diff --git a/lib/shop/tests/api/ShopClientTest.spec.ts b/lib/shop/tests/api/ShopClientTest.spec.ts index abe05e6f3..957d5d229 100644 --- a/lib/shop/tests/api/ShopClientTest.spec.ts +++ b/lib/shop/tests/api/ShopClientTest.spec.ts @@ -5,8 +5,6 @@ import { MissionStickerRequest } from "../../model/missionStickerRequest"; import { createServer } from "node:http"; import { deepEqual, equal, ok } from "node:assert"; -const pkg = require("../../../../package.json"); - const channel_access_token = "test_channel_access_token"; describe("ShopClient", () => { @@ -21,7 +19,10 @@ describe("ShopClient", () => { equal(reqUrl.pathname, "/shop/v3/mission"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); @@ -61,7 +62,10 @@ describe("ShopClient", () => { equal(reqUrl.pathname, "/shop/v3/mission"); equal(req.headers["authorization"], `Bearer ${channel_access_token}`); - equal(req.headers["user-agent"], `${pkg.name}/${pkg.version}`); + equal( + req.headers["user-agent"], + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({})); diff --git a/lib/version.ts b/lib/version.ts new file mode 100644 index 000000000..07283cc65 --- /dev/null +++ b/lib/version.ts @@ -0,0 +1,2 @@ +const LINE_BOT_SDK_VERSION = "__LINE_BOT_SDK_NODEJS_VERSION__"; +export const USER_AGENT = `@line/bot-sdk/${LINE_BOT_SDK_VERSION}`; diff --git a/test/client.spec.ts b/test/client.spec.ts index 221e4be20..5c6a55ca5 100644 --- a/test/client.spec.ts +++ b/test/client.spec.ts @@ -14,8 +14,6 @@ import { OAUTH_BASE_PREFIX_V2_1, } from "../lib/endpoints"; -const pkg = require("../package.json"); - const channelAccessToken = "test_channel_access_token"; const client = new Client({ @@ -95,7 +93,7 @@ describe("client", () => { const interceptionOption: Record = { authorization: `Bearer ${channelAccessToken}`, - "User-Agent": `${pkg.name}/${pkg.version}`, + "User-Agent": "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", }; const mockGet = ( @@ -1355,7 +1353,7 @@ describe("oauth", () => { const interceptionOption: Record = { "content-type": "application/x-www-form-urlencoded", - "User-Agent": `${pkg.name}/${pkg.version}`, + "User-Agent": "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", }; it("issueAccessToken", async () => { const client_id = "test_client_id"; diff --git a/test/http-axios.spec.ts b/test/http-axios.spec.ts index ca8cf482c..27b0c94c7 100644 --- a/test/http-axios.spec.ts +++ b/test/http-axios.spec.ts @@ -8,7 +8,6 @@ import { createReadStream, readFileSync } from "node:fs"; import { join } from "node:path"; import * as fs from "node:fs"; -const pkg = require("../package.json"); const baseURL = "https://line.me"; describe("http", () => { const httpClient = new HTTPClient({ @@ -31,7 +30,7 @@ describe("http", () => { const interceptionOption: Record = { "test-header-key": "Test-Header-Value", - "User-Agent": `${pkg.name}/${pkg.version}`, + "User-Agent": "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", }; class MSWResult { @@ -265,7 +264,10 @@ describe("http", () => { server.use( http.get(baseURL + "/404", async ({ request, params, cookies }) => { scope.done(); - equal(request.headers.get("user-agent"), `${pkg.name}/${pkg.version}`); + equal( + request.headers.get("user-agent"), + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); return HttpResponse.json(404, { status: 404 }); }), ); @@ -285,7 +287,10 @@ describe("http", () => { server.use( http.get(baseURL + "/get", async ({ request }) => { scope.done(); - equal(request.headers.get("user-agent"), `${pkg.name}/${pkg.version}`); + equal( + request.headers.get("user-agent"), + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); return HttpResponse.json({}); }), ); diff --git a/test/http-fetch.spec.ts b/test/http-fetch.spec.ts index f14829252..42211b633 100644 --- a/test/http-fetch.spec.ts +++ b/test/http-fetch.spec.ts @@ -7,7 +7,6 @@ import { setupServer } from "msw/node"; import { join } from "node:path"; import * as fs from "node:fs"; -const pkg = require("../package.json"); const baseURL = "https://line.me"; describe("http(fetch)", () => { @@ -31,7 +30,7 @@ describe("http(fetch)", () => { const interceptionOption: Record = { "test-header-key": "Test-Header-Value", - "User-Agent": `${pkg.name}/${pkg.version}`, + "User-Agent": "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", }; class MSWResult { @@ -206,7 +205,10 @@ describe("http(fetch)", () => { server.use( http.get(baseURL + "/404", async ({ request, params, cookies }) => { scope.done(); - equal(request.headers.get("user-agent"), `${pkg.name}/${pkg.version}`); + equal( + request.headers.get("user-agent"), + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); return HttpResponse.json({ reason: "not found" }, { status: 404 }); }), ); @@ -228,7 +230,10 @@ describe("http(fetch)", () => { server.use( http.get(baseURL + "/get", async ({ request }) => { scope.done(); - equal(request.headers.get("user-agent"), `${pkg.name}/${pkg.version}`); + equal( + request.headers.get("user-agent"), + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", + ); return HttpResponse.json({}); }), ); diff --git a/test/libs-channelAccessToken.spec.ts b/test/libs-channelAccessToken.spec.ts index e12cf5b08..fad748919 100644 --- a/test/libs-channelAccessToken.spec.ts +++ b/test/libs-channelAccessToken.spec.ts @@ -3,8 +3,6 @@ import { http, HttpResponse } from "msw"; import { setupServer } from "msw/node"; import { deepEqual, equal } from "node:assert"; -const pkg = require("../package.json"); - const client = new channelAccessToken.ChannelAccessTokenClient({}); describe("channelAccessToken", () => { @@ -26,7 +24,7 @@ describe("channelAccessToken", () => { async ({ request, params, cookies }) => { equal( request.headers.get("User-Agent"), - `${pkg.name}/${pkg.version}`, + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", ); equal( request.headers.get("content-type"), diff --git a/test/libs-manageAudience.spec.ts b/test/libs-manageAudience.spec.ts index 1d9fa3aad..ffe782471 100644 --- a/test/libs-manageAudience.spec.ts +++ b/test/libs-manageAudience.spec.ts @@ -3,8 +3,6 @@ import { http, HttpResponse } from "msw"; import { setupServer } from "msw/node"; import { deepEqual, equal, match } from "node:assert"; -const pkg = require("../package.json"); - const channelAccessToken = "test_channel_access_token"; const client = new manageAudience.ManageAudienceClient({ @@ -41,7 +39,7 @@ describe("manageAudience", () => { ); equal( request.headers.get("User-Agent"), - `${pkg.name}/${pkg.version}`, + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", ); match( request.headers.get("content-type")!!, diff --git a/test/libs-messagingApi.spec.ts b/test/libs-messagingApi.spec.ts index eab38cb37..0fb1bada5 100644 --- a/test/libs-messagingApi.spec.ts +++ b/test/libs-messagingApi.spec.ts @@ -3,8 +3,6 @@ import { http, HttpResponse } from "msw"; import { setupServer } from "msw/node"; import { deepEqual, equal } from "node:assert"; -const pkg = require("../package.json"); - const channelAccessToken = "test_channel_access_token"; const client = new messagingApi.MessagingApiClient({ @@ -41,7 +39,7 @@ describe("messagingApi", () => { ); equal( request.headers.get("User-Agent"), - `${pkg.name}/${pkg.version}`, + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", ); equal(request.headers.get("content-type"), "image/jpeg"); equal(await request.text(), "GREAT_JPEG"); @@ -73,7 +71,7 @@ describe("messagingApi", () => { ); equal( request.headers.get("User-Agent"), - `${pkg.name}/${pkg.version}`, + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", ); equal(request.headers.get("content-type"), "application/json"); equal(request.headers.get("x-line-retry-key"), "KEYKEYKEYKEY"); @@ -104,7 +102,7 @@ describe("messagingApi", () => { ); equal( request.headers.get("User-Agent"), - `${pkg.name}/${pkg.version}`, + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", ); equal(request.headers.get("content-type"), "application/json"); equal(request.headers.get("x-line-retry-key"), undefined); @@ -135,7 +133,7 @@ describe("messagingApi", () => { ); equal( request.headers.get("User-Agent"), - `${pkg.name}/${pkg.version}`, + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", ); const url = new URL(request.url); @@ -172,7 +170,7 @@ describe("messagingApi", () => { ); equal( request.headers.get("User-Agent"), - `${pkg.name}/${pkg.version}`, + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", ); const url = new URL(request.url); diff --git a/test/libs-shop.spec.ts b/test/libs-shop.spec.ts index 2e423005e..ce1cacace 100644 --- a/test/libs-shop.spec.ts +++ b/test/libs-shop.spec.ts @@ -3,8 +3,6 @@ import { http, HttpResponse } from "msw"; import { setupServer } from "msw/node"; import { deepEqual, equal } from "node:assert"; -const pkg = require("../package.json"); - const channelAccessToken = "test_channel_access_token"; const client = new shop.ShopClient({ @@ -34,7 +32,7 @@ describe("shop", () => { ); equal( request.headers.get("User-Agent"), - `${pkg.name}/${pkg.version}`, + "@line/bot-sdk/__LINE_BOT_SDK_NODEJS_VERSION__", ); return HttpResponse.json({}); },