1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.OAuth = void 0;
|
4 | const http_axios_js_1 = require("./http-axios.js");
|
5 | const Types = require("./types.js");
|
6 | const utils_js_1 = require("./utils.js");
|
7 | const endpoints_js_1 = require("./endpoints.js");
|
8 |
|
9 |
|
10 |
|
11 | class Client {
|
12 | constructor(config) {
|
13 | this.requestOption = {};
|
14 | if (!config.channelAccessToken) {
|
15 | throw new Error("no channel access token");
|
16 | }
|
17 | this.config = config;
|
18 | this.http = new http_axios_js_1.default(Object.assign({ defaultHeaders: {
|
19 | Authorization: "Bearer " + this.config.channelAccessToken,
|
20 | }, responseParser: this.parseHTTPResponse.bind(this) }, config.httpConfig));
|
21 | }
|
22 | setRequestOptionOnce(option) {
|
23 | this.requestOption = option;
|
24 | }
|
25 | generateRequestConfig() {
|
26 | const config = { headers: {} };
|
27 | if (this.requestOption.retryKey) {
|
28 | config.headers["X-Line-Retry-Key"] = this.requestOption.retryKey;
|
29 | }
|
30 |
|
31 | this.requestOption = {};
|
32 | return config;
|
33 | }
|
34 | parseHTTPResponse(response) {
|
35 | const { LINE_REQUEST_ID_HTTP_HEADER_NAME } = Types;
|
36 | let resBody = Object.assign({}, response.data);
|
37 | if (response.headers[LINE_REQUEST_ID_HTTP_HEADER_NAME]) {
|
38 | resBody[LINE_REQUEST_ID_HTTP_HEADER_NAME] =
|
39 | response.headers[LINE_REQUEST_ID_HTTP_HEADER_NAME];
|
40 | }
|
41 | return resBody;
|
42 | }
|
43 | pushMessage(to, messages, notificationDisabled = false, customAggregationUnits) {
|
44 | return this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/message/push`, {
|
45 | messages: (0, utils_js_1.toArray)(messages),
|
46 | to,
|
47 | notificationDisabled,
|
48 | customAggregationUnits,
|
49 | }, this.generateRequestConfig());
|
50 | }
|
51 | replyMessage(replyToken, messages, notificationDisabled = false) {
|
52 | return this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/message/reply`, {
|
53 | messages: (0, utils_js_1.toArray)(messages),
|
54 | replyToken,
|
55 | notificationDisabled,
|
56 | });
|
57 | }
|
58 | async multicast(to, messages, notificationDisabled = false, customAggregationUnits) {
|
59 | return this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/message/multicast`, {
|
60 | messages: (0, utils_js_1.toArray)(messages),
|
61 | to,
|
62 | notificationDisabled,
|
63 | customAggregationUnits,
|
64 | }, this.generateRequestConfig());
|
65 | }
|
66 | async narrowcast(messages, recipient, filter, limit, notificationDisabled) {
|
67 | return this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/message/narrowcast`, {
|
68 | messages: (0, utils_js_1.toArray)(messages),
|
69 | recipient,
|
70 | filter,
|
71 | limit,
|
72 | notificationDisabled,
|
73 | }, this.generateRequestConfig());
|
74 | }
|
75 | async broadcast(messages, notificationDisabled = false) {
|
76 | return this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/message/broadcast`, {
|
77 | messages: (0, utils_js_1.toArray)(messages),
|
78 | notificationDisabled,
|
79 | }, this.generateRequestConfig());
|
80 | }
|
81 | validatePushMessageObjects(messages) {
|
82 | return this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/message/validate/push`, {
|
83 | messages: (0, utils_js_1.toArray)(messages),
|
84 | }, this.generateRequestConfig());
|
85 | }
|
86 | validateReplyMessageObjects(messages) {
|
87 | return this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/message/validate/reply`, {
|
88 | messages: (0, utils_js_1.toArray)(messages),
|
89 | });
|
90 | }
|
91 | async validateMulticastMessageObjects(messages) {
|
92 | return this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/message/validate/multicast`, {
|
93 | messages: (0, utils_js_1.toArray)(messages),
|
94 | }, this.generateRequestConfig());
|
95 | }
|
96 | async validateNarrowcastMessageObjects(messages) {
|
97 | return this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/message/validate/narrowcast`, {
|
98 | messages: (0, utils_js_1.toArray)(messages),
|
99 | }, this.generateRequestConfig());
|
100 | }
|
101 | async validateBroadcastMessageObjects(messages) {
|
102 | return this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/message/validate/broadcast`, {
|
103 | messages: (0, utils_js_1.toArray)(messages),
|
104 | }, this.generateRequestConfig());
|
105 | }
|
106 | validateCustomAggregationUnits(units) {
|
107 | const messages = [];
|
108 | if (units.length > 1) {
|
109 | messages.push("customAggregationUnits can only contain one unit");
|
110 | }
|
111 | units.forEach((unit, index) => {
|
112 | if (unit.length > 30) {
|
113 | messages.push(`customAggregationUnits[${index}] must be less than or equal to 30 characters`);
|
114 | }
|
115 | if (!/^[a-zA-Z0-9_]+$/.test(unit)) {
|
116 | messages.push(`customAggregationUnits[${index}] must be alphanumeric characters or underscores`);
|
117 | }
|
118 | });
|
119 | return {
|
120 | messages,
|
121 | valid: messages.length === 0,
|
122 | };
|
123 | }
|
124 | async getProfile(userId) {
|
125 | const profile = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/profile/${userId}`);
|
126 | return (0, utils_js_1.ensureJSON)(profile);
|
127 | }
|
128 | async getChatMemberProfile(chatType, chatId, userId) {
|
129 | const profile = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/${chatType}/${chatId}/member/${userId}`);
|
130 | return (0, utils_js_1.ensureJSON)(profile);
|
131 | }
|
132 | async getGroupMemberProfile(groupId, userId) {
|
133 | return this.getChatMemberProfile("group", groupId, userId);
|
134 | }
|
135 | async getRoomMemberProfile(roomId, userId) {
|
136 | return this.getChatMemberProfile("room", roomId, userId);
|
137 | }
|
138 | async getChatMemberIds(chatType, chatId) {
|
139 | let memberIds = [];
|
140 | let start;
|
141 | do {
|
142 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/${chatType}/${chatId}/members/ids`, start ? { start } : null);
|
143 | (0, utils_js_1.ensureJSON)(res);
|
144 | memberIds = memberIds.concat(res.memberIds);
|
145 | start = res.next;
|
146 | } while (start);
|
147 | return memberIds;
|
148 | }
|
149 | async getGroupMemberIds(groupId) {
|
150 | return this.getChatMemberIds("group", groupId);
|
151 | }
|
152 | async getRoomMemberIds(roomId) {
|
153 | return this.getChatMemberIds("room", roomId);
|
154 | }
|
155 | async getBotFollowersIds() {
|
156 | let userIds = [];
|
157 | let start;
|
158 | do {
|
159 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/followers/ids`, start ? { start, limit: 1000 } : { limit: 1000 });
|
160 | (0, utils_js_1.ensureJSON)(res);
|
161 | userIds = userIds.concat(res.userIds);
|
162 | start = res.next;
|
163 | } while (start);
|
164 | return userIds;
|
165 | }
|
166 | async getGroupMembersCount(groupId) {
|
167 | const groupMemberCount = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/group/${groupId}/members/count`);
|
168 | return (0, utils_js_1.ensureJSON)(groupMemberCount);
|
169 | }
|
170 | async getRoomMembersCount(roomId) {
|
171 | const roomMemberCount = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/room/${roomId}/members/count`);
|
172 | return (0, utils_js_1.ensureJSON)(roomMemberCount);
|
173 | }
|
174 | async getGroupSummary(groupId) {
|
175 | const groupSummary = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/group/${groupId}/summary`);
|
176 | return (0, utils_js_1.ensureJSON)(groupSummary);
|
177 | }
|
178 | async getMessageContent(messageId) {
|
179 | return this.http.getStream(`${endpoints_js_1.DATA_API_PREFIX}/message/${messageId}/content`);
|
180 | }
|
181 | leaveChat(chatType, chatId) {
|
182 | return this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/${chatType}/${chatId}/leave`);
|
183 | }
|
184 | async leaveGroup(groupId) {
|
185 | return this.leaveChat("group", groupId);
|
186 | }
|
187 | async leaveRoom(roomId) {
|
188 | return this.leaveChat("room", roomId);
|
189 | }
|
190 | async getRichMenu(richMenuId) {
|
191 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/richmenu/${richMenuId}`);
|
192 | return (0, utils_js_1.ensureJSON)(res);
|
193 | }
|
194 | async createRichMenu(richMenu) {
|
195 | const res = await this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/richmenu`, richMenu);
|
196 | return (0, utils_js_1.ensureJSON)(res).richMenuId;
|
197 | }
|
198 | async deleteRichMenu(richMenuId) {
|
199 | return this.http.delete(`${endpoints_js_1.MESSAGING_API_PREFIX}/richmenu/${richMenuId}`);
|
200 | }
|
201 | async getRichMenuAliasList() {
|
202 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/richmenu/alias/list`);
|
203 | return (0, utils_js_1.ensureJSON)(res);
|
204 | }
|
205 | async getRichMenuAlias(richMenuAliasId) {
|
206 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/richmenu/alias/${richMenuAliasId}`);
|
207 | return (0, utils_js_1.ensureJSON)(res);
|
208 | }
|
209 | async createRichMenuAlias(richMenuId, richMenuAliasId) {
|
210 | const res = await this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/richmenu/alias`, {
|
211 | richMenuId,
|
212 | richMenuAliasId,
|
213 | });
|
214 | return (0, utils_js_1.ensureJSON)(res);
|
215 | }
|
216 | async deleteRichMenuAlias(richMenuAliasId) {
|
217 | const res = this.http.delete(`${endpoints_js_1.MESSAGING_API_PREFIX}/richmenu/alias/${richMenuAliasId}`);
|
218 | return (0, utils_js_1.ensureJSON)(res);
|
219 | }
|
220 | async updateRichMenuAlias(richMenuAliasId, richMenuId) {
|
221 | const res = await this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/richmenu/alias/${richMenuAliasId}`, {
|
222 | richMenuId,
|
223 | });
|
224 | return (0, utils_js_1.ensureJSON)(res);
|
225 | }
|
226 | async getRichMenuIdOfUser(userId) {
|
227 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/user/${userId}/richmenu`);
|
228 | return (0, utils_js_1.ensureJSON)(res).richMenuId;
|
229 | }
|
230 | async linkRichMenuToUser(userId, richMenuId) {
|
231 | return this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/user/${userId}/richmenu/${richMenuId}`);
|
232 | }
|
233 | async unlinkRichMenuFromUser(userId) {
|
234 | return this.http.delete(`${endpoints_js_1.MESSAGING_API_PREFIX}/user/${userId}/richmenu`);
|
235 | }
|
236 | async linkRichMenuToMultipleUsers(richMenuId, userIds) {
|
237 | return this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/richmenu/bulk/link`, {
|
238 | richMenuId,
|
239 | userIds,
|
240 | });
|
241 | }
|
242 | async unlinkRichMenusFromMultipleUsers(userIds) {
|
243 | return this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/richmenu/bulk/unlink`, {
|
244 | userIds,
|
245 | });
|
246 | }
|
247 | async getRichMenuImage(richMenuId) {
|
248 | return this.http.getStream(`${endpoints_js_1.DATA_API_PREFIX}/richmenu/${richMenuId}/content`);
|
249 | }
|
250 | async setRichMenuImage(richMenuId, data, contentType) {
|
251 | return this.http.postBinary(`${endpoints_js_1.DATA_API_PREFIX}/richmenu/${richMenuId}/content`, data, contentType);
|
252 | }
|
253 | async getRichMenuList() {
|
254 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/richmenu/list`);
|
255 | return (0, utils_js_1.ensureJSON)(res).richmenus;
|
256 | }
|
257 | async setDefaultRichMenu(richMenuId) {
|
258 | return this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/user/all/richmenu/${richMenuId}`);
|
259 | }
|
260 | async getDefaultRichMenuId() {
|
261 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/user/all/richmenu`);
|
262 | return (0, utils_js_1.ensureJSON)(res).richMenuId;
|
263 | }
|
264 | async deleteDefaultRichMenu() {
|
265 | return this.http.delete(`${endpoints_js_1.MESSAGING_API_PREFIX}/user/all/richmenu`);
|
266 | }
|
267 | async getLinkToken(userId) {
|
268 | const res = await this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/user/${userId}/linkToken`);
|
269 | return (0, utils_js_1.ensureJSON)(res).linkToken;
|
270 | }
|
271 | async getNumberOfSentReplyMessages(date) {
|
272 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/message/delivery/reply?date=${date}`);
|
273 | return (0, utils_js_1.ensureJSON)(res);
|
274 | }
|
275 | async getNumberOfSentPushMessages(date) {
|
276 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/message/delivery/push?date=${date}`);
|
277 | return (0, utils_js_1.ensureJSON)(res);
|
278 | }
|
279 | async getNumberOfSentMulticastMessages(date) {
|
280 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/message/delivery/multicast?date=${date}`);
|
281 | return (0, utils_js_1.ensureJSON)(res);
|
282 | }
|
283 | async getNarrowcastProgress(requestId) {
|
284 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/message/progress/narrowcast?requestId=${requestId}`);
|
285 | return (0, utils_js_1.ensureJSON)(res);
|
286 | }
|
287 | async getTargetLimitForAdditionalMessages() {
|
288 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/message/quota`);
|
289 | return (0, utils_js_1.ensureJSON)(res);
|
290 | }
|
291 | async getNumberOfMessagesSentThisMonth() {
|
292 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/message/quota/consumption`);
|
293 | return (0, utils_js_1.ensureJSON)(res);
|
294 | }
|
295 | async getNumberOfSentBroadcastMessages(date) {
|
296 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/message/delivery/broadcast?date=${date}`);
|
297 | return (0, utils_js_1.ensureJSON)(res);
|
298 | }
|
299 | async getNumberOfMessageDeliveries(date) {
|
300 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/insight/message/delivery?date=${date}`);
|
301 | return (0, utils_js_1.ensureJSON)(res);
|
302 | }
|
303 | async getNumberOfFollowers(date) {
|
304 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/insight/followers?date=${date}`);
|
305 | return (0, utils_js_1.ensureJSON)(res);
|
306 | }
|
307 | async getFriendDemographics() {
|
308 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/insight/demographic`);
|
309 | return (0, utils_js_1.ensureJSON)(res);
|
310 | }
|
311 | async getUserInteractionStatistics(requestId) {
|
312 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/insight/message/event?requestId=${requestId}`);
|
313 | return (0, utils_js_1.ensureJSON)(res);
|
314 | }
|
315 | async getStatisticsPerUnit(customAggregationUnit, from, to) {
|
316 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/insight/message/event/aggregation?customAggregationUnit=${customAggregationUnit}&from=${from}&to=${to}`);
|
317 | return (0, utils_js_1.ensureJSON)(res);
|
318 | }
|
319 | async createUploadAudienceGroup(uploadAudienceGroup) {
|
320 | const res = await this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/audienceGroup/upload`, Object.assign({}, uploadAudienceGroup));
|
321 | return (0, utils_js_1.ensureJSON)(res);
|
322 | }
|
323 | async createUploadAudienceGroupByFile(uploadAudienceGroup) {
|
324 | const file = await this.http.toBuffer(uploadAudienceGroup.file);
|
325 | const body = (0, utils_js_1.createMultipartFormData)(Object.assign(Object.assign({}, uploadAudienceGroup), { file }));
|
326 | const res = await this.http.postFormMultipart(`${endpoints_js_1.DATA_API_PREFIX}/audienceGroup/upload/byFile`, body);
|
327 | return (0, utils_js_1.ensureJSON)(res);
|
328 | }
|
329 | async updateUploadAudienceGroup(uploadAudienceGroup,
|
330 |
|
331 | httpConfig) {
|
332 | const res = await this.http.put(`${endpoints_js_1.MESSAGING_API_PREFIX}/audienceGroup/upload`, Object.assign({}, uploadAudienceGroup), httpConfig);
|
333 | return (0, utils_js_1.ensureJSON)(res);
|
334 | }
|
335 | async updateUploadAudienceGroupByFile(uploadAudienceGroup,
|
336 |
|
337 | httpConfig) {
|
338 | const file = await this.http.toBuffer(uploadAudienceGroup.file);
|
339 | const body = (0, utils_js_1.createMultipartFormData)(Object.assign(Object.assign({}, uploadAudienceGroup), { file }));
|
340 | const res = await this.http.putFormMultipart(`${endpoints_js_1.DATA_API_PREFIX}/audienceGroup/upload/byFile`, body, httpConfig);
|
341 | return (0, utils_js_1.ensureJSON)(res);
|
342 | }
|
343 | async createClickAudienceGroup(clickAudienceGroup) {
|
344 | const res = await this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/audienceGroup/click`, Object.assign({}, clickAudienceGroup));
|
345 | return (0, utils_js_1.ensureJSON)(res);
|
346 | }
|
347 | async createImpAudienceGroup(impAudienceGroup) {
|
348 | const res = await this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/audienceGroup/imp`, Object.assign({}, impAudienceGroup));
|
349 | return (0, utils_js_1.ensureJSON)(res);
|
350 | }
|
351 | async setDescriptionAudienceGroup(description, audienceGroupId) {
|
352 | const res = await this.http.put(`${endpoints_js_1.MESSAGING_API_PREFIX}/audienceGroup/${audienceGroupId}/updateDescription`, {
|
353 | description,
|
354 | });
|
355 | return (0, utils_js_1.ensureJSON)(res);
|
356 | }
|
357 | async deleteAudienceGroup(audienceGroupId) {
|
358 | const res = await this.http.delete(`${endpoints_js_1.MESSAGING_API_PREFIX}/audienceGroup/${audienceGroupId}`);
|
359 | return (0, utils_js_1.ensureJSON)(res);
|
360 | }
|
361 | async getAudienceGroup(audienceGroupId) {
|
362 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/audienceGroup/${audienceGroupId}`);
|
363 | return (0, utils_js_1.ensureJSON)(res);
|
364 | }
|
365 | async getAudienceGroups(page, description, status, size, createRoute, includesExternalPublicGroups) {
|
366 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/audienceGroup/list`, {
|
367 | page,
|
368 | description,
|
369 | status,
|
370 | size,
|
371 | createRoute,
|
372 | includesExternalPublicGroups,
|
373 | });
|
374 | return (0, utils_js_1.ensureJSON)(res);
|
375 | }
|
376 | async getAudienceGroupAuthorityLevel() {
|
377 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/audienceGroup/authorityLevel`);
|
378 | return (0, utils_js_1.ensureJSON)(res);
|
379 | }
|
380 | async changeAudienceGroupAuthorityLevel(authorityLevel) {
|
381 | const res = await this.http.put(`${endpoints_js_1.MESSAGING_API_PREFIX}/audienceGroup/authorityLevel`, { authorityLevel });
|
382 | return (0, utils_js_1.ensureJSON)(res);
|
383 | }
|
384 | async getBotInfo() {
|
385 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/info`);
|
386 | return (0, utils_js_1.ensureJSON)(res);
|
387 | }
|
388 | async setWebhookEndpointUrl(endpoint) {
|
389 | return this.http.put(`${endpoints_js_1.MESSAGING_API_PREFIX}/channel/webhook/endpoint`, { endpoint });
|
390 | }
|
391 | async getWebhookEndpointInfo() {
|
392 | const res = await this.http.get(`${endpoints_js_1.MESSAGING_API_PREFIX}/channel/webhook/endpoint`);
|
393 | return (0, utils_js_1.ensureJSON)(res);
|
394 | }
|
395 | async testWebhookEndpoint(endpoint) {
|
396 | const res = await this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/channel/webhook/test`, { endpoint });
|
397 | return (0, utils_js_1.ensureJSON)(res);
|
398 | }
|
399 | async validateRichMenu(richMenu) {
|
400 | return await this.http.post(`${endpoints_js_1.MESSAGING_API_PREFIX}/richmenu/validate`, richMenu);
|
401 | }
|
402 | }
|
403 | exports.default = Client;
|
404 | class OAuth {
|
405 | constructor() {
|
406 | this.http = new http_axios_js_1.default();
|
407 | }
|
408 | issueAccessToken(client_id, client_secret) {
|
409 | return this.http.postForm(`${endpoints_js_1.OAUTH_BASE_PREFIX}/accessToken`, {
|
410 | grant_type: "client_credentials",
|
411 | client_id,
|
412 | client_secret,
|
413 | });
|
414 | }
|
415 | revokeAccessToken(access_token) {
|
416 | return this.http.postForm(`${endpoints_js_1.OAUTH_BASE_PREFIX}/revoke`, { access_token });
|
417 | }
|
418 | verifyAccessToken(access_token) {
|
419 | return this.http.get(`${endpoints_js_1.OAUTH_BASE_PREFIX_V2_1}/verify`, { access_token });
|
420 | }
|
421 | verifyIdToken(id_token, client_id, nonce, user_id) {
|
422 | const body = {
|
423 | id_token,
|
424 | client_id,
|
425 | };
|
426 | if (nonce) {
|
427 | body.nonce = nonce;
|
428 | }
|
429 | if (user_id) {
|
430 | body.user_id = user_id;
|
431 | }
|
432 | return this.http.postForm(`${endpoints_js_1.OAUTH_BASE_PREFIX_V2_1}/verify`, body);
|
433 | }
|
434 | issueChannelAccessTokenV2_1(client_assertion) {
|
435 | return this.http.postForm(`${endpoints_js_1.OAUTH_BASE_PREFIX_V2_1}/token`, {
|
436 | grant_type: "client_credentials",
|
437 | client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
|
438 | client_assertion,
|
439 | });
|
440 | }
|
441 | getChannelAccessTokenKeyIdsV2_1(client_assertion) {
|
442 | return this.http.get(`${endpoints_js_1.OAUTH_BASE_PREFIX_V2_1}/tokens/kid`, {
|
443 | client_assertion_type: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
|
444 | client_assertion,
|
445 | });
|
446 | }
|
447 | revokeChannelAccessTokenV2_1(client_id, client_secret, access_token) {
|
448 | return this.http.postForm(`${endpoints_js_1.OAUTH_BASE_PREFIX_V2_1}/revoke`, {
|
449 | client_id,
|
450 | client_secret,
|
451 | access_token,
|
452 | });
|
453 | }
|
454 | }
|
455 | exports.OAuth = OAuth;
|
456 |
|
\ | No newline at end of file |