Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions examples/echo-bot-ts-cjs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/echo-bot-ts-cjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
"@types/express": "^4.17.17",
"@types/node": "^20.6.3",
"rimraf": "^5.0.1",
"typescript": "^5.2.2"
"typescript": "^6.0.0"
}
}
3 changes: 1 addition & 2 deletions examples/echo-bot-ts-cjs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"module": "commonjs",
"outDir": "./dist",
"strict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true
"types": ["node"]
},
"exclude": ["node_modules"]
}
8 changes: 5 additions & 3 deletions examples/echo-bot-ts-esm/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/echo-bot-ts-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"@types/express": "^4.17.17",
"@types/node": "^20.6.3",
"rimraf": "^5.0.1",
"typescript": "^5.2.2"
"typescript": "^6.0.0"
}
}
4 changes: 2 additions & 2 deletions examples/echo-bot-ts-esm/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"module": "NodeNext",
"moduleResolution": "NodeNext",
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true
"strict": true,
"types": ["node"]
},
"exclude": ["node_modules"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,36 @@
"{{param.baseName}}": {{param.paramName}},
{% endfor %}
};
Object.keys(formParams).forEach((key: keyof typeof formParams) => {
if (formParams[key] === undefined) {
delete formParams[key];
}
});

{% for param in op.formParams -%}
{% if param.required == false %}
if (formParams["{{param.baseName}}"] === undefined) {
delete formParams["{{param.baseName}}"];
}
{% endif -%}
{% endfor %}

{% elseif op.hasQueryParams %}const queryParams = {
{% for param in op.queryParams -%}
{% if param.isArray -%}
{% if param.isArray and param.required == false -%}
"{{param.baseName}}": {{param.paramName}} != null
? [...{{param.paramName}}].join(",")
: undefined,
{% elseif param.isArray -%}
"{{param.baseName}}": [...{{param.paramName}}].join(","),
{% else -%}
"{{param.baseName}}": {{param.paramName}},
{% endif -%}
{% endfor %}
};
Object.keys(queryParams).forEach((key: keyof typeof queryParams) => {
if (queryParams[key] === undefined) {
delete queryParams[key];
}
});

{% for param in op.queryParams -%}
{% if param.required == false %}
if (queryParams["{{param.baseName}}"] === undefined) {
delete queryParams["{{param.baseName}}"];
}
{% endif -%}
{% endfor %}
{% endif %}
{% if op.hasHeaderParams %}const headerParams = {
{% for param in op.headerParams -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ function parseForm(
requestCount++;

equal(req.method, "{{ op.httpMethod }}");
ok(req.url)
const reqUrl = new URL(req.url, "http://localhost/");
equal(reqUrl.pathname, "{{ op.path }}"
{% for param in op.allParams -%}
Expand Down Expand Up @@ -151,8 +152,10 @@ function parseForm(
"@line/bot-sdk/1.0.0-test",
);
{% if op.isMultipart %}
const contentType = req.headers["content-type"];
ok(contentType);
ok(
req.headers["content-type"]
contentType
.startsWith(`multipart/form-data; boundary=`),
);
{% endif %}
Expand Down
60 changes: 20 additions & 40 deletions lib/channel-access-token/api/channelAccessTokenClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,6 @@ export class ChannelAccessTokenClient {
client_assertion_type: clientAssertionType,
client_assertion: clientAssertion,
};
Object.keys(queryParams).forEach((key: keyof typeof queryParams) => {
if (queryParams[key] === undefined) {
delete queryParams[key];
}
});

const res = await this.httpClient.get(
"/oauth2/v2.1/tokens/kid",
Expand Down Expand Up @@ -138,11 +133,6 @@ export class ChannelAccessTokenClient {
client_id: clientId,
client_secret: clientSecret,
};
Object.keys(formParams).forEach((key: keyof typeof formParams) => {
if (formParams[key] === undefined) {
delete formParams[key];
}
});

const res = await this.httpClient.postForm(
"/v2/oauth/accessToken",
Expand Down Expand Up @@ -193,11 +183,6 @@ export class ChannelAccessTokenClient {
client_assertion_type: clientAssertionType,
client_assertion: clientAssertion,
};
Object.keys(formParams).forEach((key: keyof typeof formParams) => {
if (formParams[key] === undefined) {
delete formParams[key];
}
});

const res = await this.httpClient.postForm(
"/oauth2/v2.1/token",
Expand Down Expand Up @@ -262,11 +247,26 @@ export class ChannelAccessTokenClient {
client_id: clientId,
client_secret: clientSecret,
};
Object.keys(formParams).forEach((key: keyof typeof formParams) => {
if (formParams[key] === undefined) {
delete formParams[key];
}
});

if (formParams["grant_type"] === undefined) {
delete formParams["grant_type"];
}

if (formParams["client_assertion_type"] === undefined) {
delete formParams["client_assertion_type"];
}

if (formParams["client_assertion"] === undefined) {
delete formParams["client_assertion"];
}

if (formParams["client_id"] === undefined) {
delete formParams["client_id"];
}

if (formParams["client_secret"] === undefined) {
delete formParams["client_secret"];
}

const res = await this.httpClient.postForm("/oauth2/v3/token", formParams);
const text = await res.text();
Expand Down Expand Up @@ -298,11 +298,6 @@ export class ChannelAccessTokenClient {
const formParams = {
access_token: accessToken,
};
Object.keys(formParams).forEach((key: keyof typeof formParams) => {
if (formParams[key] === undefined) {
delete formParams[key];
}
});

const res = await this.httpClient.postForm("/v2/oauth/revoke", formParams);
const text = await res.text();
Expand Down Expand Up @@ -350,11 +345,6 @@ export class ChannelAccessTokenClient {
client_secret: clientSecret,
access_token: accessToken,
};
Object.keys(formParams).forEach((key: keyof typeof formParams) => {
if (formParams[key] === undefined) {
delete formParams[key];
}
});

const res = await this.httpClient.postForm(
"/oauth2/v2.1/revoke",
Expand Down Expand Up @@ -389,11 +379,6 @@ export class ChannelAccessTokenClient {
const formParams = {
access_token: accessToken,
};
Object.keys(formParams).forEach((key: keyof typeof formParams) => {
if (formParams[key] === undefined) {
delete formParams[key];
}
});

const res = await this.httpClient.postForm("/v2/oauth/verify", formParams);
const text = await res.text();
Expand Down Expand Up @@ -425,11 +410,6 @@ export class ChannelAccessTokenClient {
const queryParams = {
access_token: accessToken,
};
Object.keys(queryParams).forEach((key: keyof typeof queryParams) => {
if (queryParams[key] === undefined) {
delete queryParams[key];
}
});

const res = await this.httpClient.get("/oauth2/v2.1/verify", queryParams);
const text = await res.text();
Expand Down
Loading