@@ -62,47 +62,66 @@ app.listen(3000, () => console.log("Bot running on port 3000"));
6262``` ts
6363import { login , generateAuthUrl , issueAccessToken } from " @linekit/login" ;
6464
65- // 產生含 CSRF 保護的 OAuth URL
65+ // Generate OAuth URL with CSRF protection
6666const state = login .generateState ();
6767const authUrl = generateAuthUrl ({
6868 channelId: " YOUR_CHANNEL_ID" ,
6969 redirectUri: " https://example.com/callback" ,
7070 state ,
71+ scope: [" profile" , " openid" , " email" ],
7172});
7273
73- // 回調後驗證 state 並交換 token
74+ // Callback handling
7475if (login .validateState (savedState , returnedState )) {
75- const tokens = await issueAccessToken (channelId , channelSecret , code , redirectUri );
76- const user = await login .verify (tokens .id_token , channelId );
76+ const tokens = await issueAccessToken (process . env . CHANNEL_ID ! , process . env . CHANNEL_SECRET ! , code , redirectUri );
77+ const user = await login .verify (tokens .id_token ! , process . env . CHANNEL_ID ! );
7778 console .log (user .name , user .email );
7879}
7980```
8081
81- ## 套件列表
82+ ### LIFF Management
8283
83- - ** @linekit/core ** : Webhook 驗證(時序安全)、Context、Router 含錯誤處理。
84- - ** @linekit/messaging ** : Messaging API 客戶端 (Reply, Push, Multicast, Rich Menu) 含輸入驗證。
85- - ** @linekit/login ** : OAuth 流程、ID Token 驗證、CSRF state 工具。
86- - ** @linekit/express ** : Express.js 的適配器。
84+ ``` ts
85+ import { LiffClient } from " @linekit/liff" ;
86+
87+ const client = new LiffClient ({
88+ channelAccessToken: process .env .CHANNEL_ACCESS_TOKEN ! ,
89+ });
90+
91+ // Manage LIFF apps server-side
92+ const apps = await client .getAll ();
93+ const { liffId } = await client .add ({
94+ view: { type: " full" , url: " https://mysite.com" }
95+ });
96+ ```
97+
98+ ## Packages
99+
100+ - ** @linekit/core ** : Webhook signature verification, Context, Router.
101+ - ** @linekit/messaging ** : Messaging API client (Reply, Push, Multicast) with validation.
102+ - ** @linekit/login ** : OAuth 2.1 flow, ID Token verification, State management.
103+ - ** @linekit/liff ** : Server-side LIFF app management (CRUD).
104+ - ** @linekit/express ** : Express.js middleware adapter.
105+
106+ ## API Compatibility
107+
108+ Built for:
87109
88- ## LINE API 相容性
110+ | API | Version | Reference |
111+ | :--- | :--- | :--- |
112+ | Messaging API | v2 | [ Docs] ( https://developers.line.biz/en/reference/messaging-api/ ) |
113+ | LINE Login | v2.1 | [ Docs] ( https://developers.line.biz/en/reference/line-login/ ) |
114+ | LIFF | v1 (Mgmt) | [ Docs] ( https://developers.line.biz/en/reference/liff-server/ ) |
89115
90- 本工具包基於以下 LINE API 版本開發:
116+ ** Base URLs: **
91117
92- | API | 版本 | 參考文件 |
93- | -----| ------| ---------|
94- | Messaging API | v2 | [ 文件] ( https://developers.line.biz/en/reference/messaging-api/ ) |
95- | LINE Login | v2.1 (OAuth 2.1) | [ 文件] ( https://developers.line.biz/en/reference/line-login/ ) |
96- | LIFF | v2 | [ 文件] ( https://developers.line.biz/en/reference/liff/ ) |
118+ - Messaging: ` https://api.line.me/v2/bot/ `
119+ - Login: ` https://api.line.me/oauth2/v2.1/ `
120+ - LIFF Mgmt: ` https://api.line.me/liff/v1/ `
97121
98- ** API 端點 Base URL:**
99- - Messaging API: ` https://api.line.me/v2/bot/ `
100- - LINE Login: ` https://api.line.me/oauth2/v2.1/ `
101- - 授權: ` https://access.line.me/oauth2/v2.1/ `
122+ ** Safety & Limits:**
102123
103- ** API 限制(由 linekit 強制執行):**
104- - 每次請求最多 5 則訊息
105- - 每次 multicast 請求最多 500 位收件人
124+ - Automating batch size limits (5 msgs/req, 500 users/multicast).
106125
107126## 文件
108127
0 commit comments