line-node 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers/randomString.d.ts +1 -3
- package/dist/helpers/randomString.js +1 -3
- package/dist/lib/getLineLogin.d.ts +29 -23
- package/dist/lib/getLineLogin.js +4 -2
- package/dist/lib/getParamsFromLoginCallback.d.ts +27 -17
- package/dist/lib/getParamsFromLoginCallback.js +14 -7
- package/dist/libNode/decodeIdToken.d.ts +22 -28
- package/dist/libNode/decodeIdToken.js +3 -3
- package/dist/libNode/issueAccessToken.d.ts +24 -32
- package/dist/libNode/issueAccessToken.js +8 -6
- package/package.json +19 -17
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates a non-safe random string which can have duplicates around 7 million generations.
|
|
3
|
-
*/
|
|
1
|
+
/** Generates a non-safe random string which can have duplicates around 7 million generations. */
|
|
4
2
|
export function randomString(length = 20) {
|
|
5
3
|
return Array(length)
|
|
6
4
|
.fill(0)
|
|
@@ -1,56 +1,62 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* https://developers.line.biz/en/docs/line-login/integrate-line-login/#making-an-authorization-request
|
|
3
|
-
*/
|
|
1
|
+
/** https://developers.line.biz/en/docs/line-login/integrate-line-login/#making-an-authorization-request */
|
|
4
2
|
export type LineLoginUrlParams = {
|
|
5
|
-
/**
|
|
6
|
-
* (Optional - default 'code') code. This tells the LINE Platform to return an authorization code.
|
|
7
|
-
*/
|
|
3
|
+
/** (Optional - default 'code') code. This tells the LINE Platform to return an authorization code. */
|
|
8
4
|
response_type?: string;
|
|
9
|
-
/**
|
|
10
|
-
* (Required) Channel ID. Unique identifier for your channel issued by LINE.
|
|
11
|
-
*/
|
|
5
|
+
/** (Required) Channel ID. Unique identifier for your channel issued by LINE. */
|
|
12
6
|
client_id: string;
|
|
13
7
|
/**
|
|
14
|
-
* (Required) Callback URL. URL that users are redirected to after authentication and
|
|
8
|
+
* (Required) Callback URL. URL that users are redirected to after authentication and
|
|
9
|
+
* authorization. Must match one of the the callback URLs registered for your channel in the
|
|
10
|
+
* console.
|
|
15
11
|
*/
|
|
16
12
|
redirect_uri: string;
|
|
17
13
|
/**
|
|
18
|
-
* (Optional - default to a random string) A unique alphanumeric string used to prevent cross-site
|
|
14
|
+
* (Optional - default to a random string) A unique alphanumeric string used to prevent cross-site
|
|
15
|
+
* request forgery. This value should be randomly generated by your application. Cannot be a
|
|
16
|
+
* URL-encoded string.
|
|
19
17
|
*/
|
|
20
18
|
state?: string;
|
|
21
19
|
/**
|
|
22
|
-
* (Optional - default 'openid') Permissions requested to the user. For more information, see
|
|
23
|
-
* To obtain the email address of a user, you must first apply for permission.
|
|
24
|
-
*
|
|
20
|
+
* (Optional - default 'openid') Permissions requested to the user. For more information, see
|
|
21
|
+
* scopes. To obtain the email address of a user, you must first apply for permission. An access
|
|
22
|
+
* token with the profile scope is required to get the friendship status between a user and a LINE
|
|
23
|
+
* Official Account.
|
|
25
24
|
*/
|
|
26
25
|
scope?: 'profile' | 'profile%20openid' | 'profile%20openid%20email' | 'openid' | 'openid%20email';
|
|
27
|
-
/**
|
|
28
|
-
* (Optional) A string used to prevent replay attacks. This value is returned in an ID token.
|
|
29
|
-
*/
|
|
26
|
+
/** (Optional) A string used to prevent replay attacks. This value is returned in an ID token. */
|
|
30
27
|
nonce?: string;
|
|
31
28
|
/**
|
|
32
|
-
* (Optional) consent. Used to force the consent screen to be displayed even if the user has
|
|
29
|
+
* (Optional) consent. Used to force the consent screen to be displayed even if the user has
|
|
30
|
+
* already granted all requested permissions.
|
|
33
31
|
*/
|
|
34
32
|
prompt?: string;
|
|
35
33
|
/**
|
|
36
|
-
* (Optional) The allowable elapsed time in seconds since the last time the user was
|
|
34
|
+
* (Optional) The allowable elapsed time in seconds since the last time the user was
|
|
35
|
+
* authenticated. Corresponds to the max_age parameter defined in the "Authentication Request"
|
|
36
|
+
* section of OpenID Connect Core 1.0.
|
|
37
37
|
*/
|
|
38
38
|
max_age?: number;
|
|
39
39
|
/**
|
|
40
|
-
* (Optional) Display language for LINE Login screens. Specify as one or more RFC 5646 (BCP 47)
|
|
40
|
+
* (Optional) Display language for LINE Login screens. Specify as one or more RFC 5646 (BCP 47)
|
|
41
|
+
* language tags, separated by spaces, in order of preference. Corresponds to the ui_locales
|
|
42
|
+
* parameter defined in the "Authentication Request" section of OpenID Connect Core 1.0.
|
|
41
43
|
*/
|
|
42
44
|
ui_locales?: string;
|
|
43
45
|
/**
|
|
44
|
-
* (Optional) Displays an option to add a LINE Official Account as a friend during login. Set to
|
|
46
|
+
* (Optional) Displays an option to add a LINE Official Account as a friend during login. Set to
|
|
47
|
+
* either normal or aggressive. For more information, see Add a LINE Official Account as a friend
|
|
48
|
+
* when logged in (bot link).
|
|
45
49
|
*/
|
|
46
50
|
bot_prompt?: string;
|
|
47
51
|
};
|
|
48
52
|
/**
|
|
49
53
|
* Get a URL that users can access to login with LINE and be redirected to your app again.
|
|
50
54
|
*
|
|
51
|
-
* LINE documentation:
|
|
55
|
+
* LINE documentation:
|
|
56
|
+
* https://developers.line.biz/en/docs/line-login/integrate-line-login/#making-an-authorization-request
|
|
52
57
|
*
|
|
53
58
|
* @param {LineLoginUrlParams} params Only client_id & redirect_uri are required props.
|
|
54
|
-
* @returns {string}
|
|
59
|
+
* @returns {string} The `https://access.line.me/oauth2/v2.1/authorize${query}` URL with correct
|
|
60
|
+
* query
|
|
55
61
|
*/
|
|
56
62
|
export declare function getLineLoginUrl(params: LineLoginUrlParams): string;
|
package/dist/lib/getLineLogin.js
CHANGED
|
@@ -2,10 +2,12 @@ import { randomString } from '../helpers/randomString.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Get a URL that users can access to login with LINE and be redirected to your app again.
|
|
4
4
|
*
|
|
5
|
-
* LINE documentation:
|
|
5
|
+
* LINE documentation:
|
|
6
|
+
* https://developers.line.biz/en/docs/line-login/integrate-line-login/#making-an-authorization-request
|
|
6
7
|
*
|
|
7
8
|
* @param {LineLoginUrlParams} params Only client_id & redirect_uri are required props.
|
|
8
|
-
* @returns {string}
|
|
9
|
+
* @returns {string} The `https://access.line.me/oauth2/v2.1/authorize${query}` URL with correct
|
|
10
|
+
* query
|
|
9
11
|
*/
|
|
10
12
|
export function getLineLoginUrl(params) {
|
|
11
13
|
const { response_type = 'code', state = randomString(), scope = 'openid', redirect_uri: _redirect_uri, } = params;
|
|
@@ -1,40 +1,50 @@
|
|
|
1
1
|
export type LoginCallbackParamsSuccess = {
|
|
2
2
|
/**
|
|
3
|
-
* Authorization code used to get an access token. Valid for 10 minutes. This authorization code
|
|
3
|
+
* Authorization code used to get an access token. Valid for 10 minutes. This authorization code
|
|
4
|
+
* can only be used once.
|
|
4
5
|
*/
|
|
5
6
|
code: string;
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* State parameter included in the authorization URL of original request. Your application should
|
|
9
|
+
* verify that this value matches the one in the original request.
|
|
8
10
|
*/
|
|
9
11
|
state: string;
|
|
10
12
|
/**
|
|
11
|
-
*
|
|
13
|
+
* True if the friendship status between the user and the LINE Official Account changes during
|
|
14
|
+
* login. Otherwise, the value is false. This parameter is only returned if the bot_prompt query
|
|
15
|
+
* parameter is specified when making an authorization request and the option to add your LINE
|
|
16
|
+
* Official Account as a friend when the user logged in is displayed. For more information, see
|
|
17
|
+
* Add a LINE Official Account as a friend when logged in (bot link).
|
|
12
18
|
*/
|
|
13
19
|
friendship_status_changed?: boolean;
|
|
14
20
|
};
|
|
15
21
|
export type LoginCallbackParamsError = {
|
|
16
|
-
/**
|
|
17
|
-
* (Optional) Error code.
|
|
18
|
-
*/
|
|
22
|
+
/** (Optional) Error code. */
|
|
19
23
|
error: 'access_denied' | string;
|
|
20
|
-
/**
|
|
21
|
-
* (Optional) Details of the error.
|
|
22
|
-
*/
|
|
24
|
+
/** (Optional) Details of the error. */
|
|
23
25
|
error_description?: string;
|
|
24
26
|
/**
|
|
25
|
-
* (Optional) OAuth 2.0 state value. Required if the authorization Request included the state
|
|
27
|
+
* (Optional) OAuth 2.0 state value. Required if the authorization Request included the state
|
|
28
|
+
* parameter.
|
|
26
29
|
*/
|
|
27
30
|
state?: string;
|
|
28
31
|
};
|
|
29
32
|
/**
|
|
30
|
-
* Once the user is authenticated and authorization is complete, the HTTP status code 302 and query
|
|
33
|
+
* Once the user is authenticated and authorization is complete, the HTTP status code 302 and query
|
|
34
|
+
* parameters are returned in the callback URL. This function converts the callback URL to an object
|
|
35
|
+
* with the query parameters.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* // Success example:
|
|
39
|
+
* HTTP/1.1 302 Found
|
|
40
|
+
* Location: https://client.example.org/cb?code=abcd1234&state=0987poi&friendship_status_changed=true
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* // Error example:
|
|
44
|
+
* Location: https://example.com/callback?error=access_denied&error_description=The+resource+owner+denied+the+request.&state=0987poi
|
|
31
45
|
*
|
|
32
|
-
* @param {string} callbackUrlTriggered
|
|
46
|
+
* @param {string} callbackUrlTriggered Eg.
|
|
47
|
+
* https://client.example.org/cb?code=abcd1234&state=0987poi&friendship_status_changed=true
|
|
33
48
|
* @returns {LoginCallbackParamsSuccess | LoginCallbackParamsError}
|
|
34
|
-
* @example // Success example:
|
|
35
|
-
HTTP/1.1 302 Found
|
|
36
|
-
Location: https://client.example.org/cb?code=abcd1234&state=0987poi&friendship_status_changed=true
|
|
37
|
-
* @example // Error example:
|
|
38
|
-
Location: https://example.com/callback?error=access_denied&error_description=The+resource+owner+denied+the+request.&state=0987poi
|
|
39
49
|
*/
|
|
40
50
|
export declare function getParamsFromLoginCallback(callbackUrlTriggered: string): LoginCallbackParamsSuccess | LoginCallbackParamsError;
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Once the user is authenticated and authorization is complete, the HTTP status code 302 and query
|
|
2
|
+
* Once the user is authenticated and authorization is complete, the HTTP status code 302 and query
|
|
3
|
+
* parameters are returned in the callback URL. This function converts the callback URL to an object
|
|
4
|
+
* with the query parameters.
|
|
3
5
|
*
|
|
4
|
-
* @
|
|
6
|
+
* @example
|
|
7
|
+
* // Success example:
|
|
8
|
+
* HTTP/1.1 302 Found
|
|
9
|
+
* Location: https://client.example.org/cb?code=abcd1234&state=0987poi&friendship_status_changed=true
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Error example:
|
|
13
|
+
* Location: https://example.com/callback?error=access_denied&error_description=The+resource+owner+denied+the+request.&state=0987poi
|
|
14
|
+
*
|
|
15
|
+
* @param {string} callbackUrlTriggered Eg.
|
|
16
|
+
* https://client.example.org/cb?code=abcd1234&state=0987poi&friendship_status_changed=true
|
|
5
17
|
* @returns {LoginCallbackParamsSuccess | LoginCallbackParamsError}
|
|
6
|
-
* @example // Success example:
|
|
7
|
-
HTTP/1.1 302 Found
|
|
8
|
-
Location: https://client.example.org/cb?code=abcd1234&state=0987poi&friendship_status_changed=true
|
|
9
|
-
* @example // Error example:
|
|
10
|
-
Location: https://example.com/callback?error=access_denied&error_description=The+resource+owner+denied+the+request.&state=0987poi
|
|
11
18
|
*/
|
|
12
19
|
export function getParamsFromLoginCallback(callbackUrlTriggered) {
|
|
13
20
|
const query = callbackUrlTriggered.split('?')[1];
|
|
@@ -4,60 +4,54 @@ export type DecodedIdToken = {
|
|
|
4
4
|
alg: 'HS256';
|
|
5
5
|
};
|
|
6
6
|
payload: {
|
|
7
|
-
/**
|
|
8
|
-
* https://access.line.me. URL where the ID token is generated.
|
|
9
|
-
*/
|
|
7
|
+
/** https://access.line.me. URL where the ID token is generated. */
|
|
10
8
|
iss: 'https://access.line.me' | string;
|
|
11
|
-
/**
|
|
12
|
-
* User ID for which the ID token is generated
|
|
13
|
-
*/
|
|
9
|
+
/** User ID for which the ID token is generated */
|
|
14
10
|
sub: string;
|
|
15
|
-
/**
|
|
16
|
-
* Channel ID
|
|
17
|
-
*/
|
|
11
|
+
/** Channel ID */
|
|
18
12
|
aud: string;
|
|
19
|
-
/**
|
|
20
|
-
* The expiry date of the token in UNIX time.
|
|
21
|
-
*/
|
|
13
|
+
/** The expiry date of the token in UNIX time. */
|
|
22
14
|
exp: number;
|
|
23
|
-
/**
|
|
24
|
-
* Time when the ID token was generated in UNIX time.
|
|
25
|
-
*/
|
|
15
|
+
/** Time when the ID token was generated in UNIX time. */
|
|
26
16
|
iat: number;
|
|
27
17
|
/**
|
|
28
|
-
* (Optional) Time when the user was authenticated in UNIX time. Not included if the max_age
|
|
18
|
+
* (Optional) Time when the user was authenticated in UNIX time. Not included if the max_age
|
|
19
|
+
* parameter wasn't specified in the authorization request.
|
|
29
20
|
*/
|
|
30
21
|
auth_time?: number;
|
|
31
22
|
/**
|
|
32
|
-
* (Optional) The nonce value specified in the authorization URL. Not included if the nonce
|
|
23
|
+
* (Optional) The nonce value specified in the authorization URL. Not included if the nonce
|
|
24
|
+
* value was not specified in the authorization request.
|
|
33
25
|
*/
|
|
34
26
|
nonce?: string;
|
|
35
27
|
/**
|
|
36
|
-
* List of authentication methods used by the user. For each authentication method, see
|
|
37
|
-
* pwd: Log in with email and password
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* linesso: Log in with single sign-on
|
|
28
|
+
* List of authentication methods used by the user. For each authentication method, see
|
|
29
|
+
* Authentication process. One of: pwd: Log in with email and password lineautologin: LINE
|
|
30
|
+
* automatic login (including through LINE SDK) lineqr: Log in with QR code linesso: Log in with
|
|
31
|
+
* single sign-on
|
|
41
32
|
*/
|
|
42
33
|
amr: ('pwd' | 'lineautologin' | 'lineqr' | 'linesso' | 'name')[];
|
|
43
34
|
/**
|
|
44
|
-
* User's display name. Not included if the profile scope was not specified in the authorization
|
|
35
|
+
* User's display name. Not included if the profile scope was not specified in the authorization
|
|
36
|
+
* request.
|
|
45
37
|
*/
|
|
46
38
|
name: string;
|
|
47
39
|
/**
|
|
48
|
-
* (Optional) User's profile image URL. Not included if the profile scope was not specified in
|
|
40
|
+
* (Optional) User's profile image URL. Not included if the profile scope was not specified in
|
|
41
|
+
* the authorization request.
|
|
49
42
|
*/
|
|
50
43
|
picture?: string;
|
|
51
44
|
/**
|
|
52
|
-
* (Optional) User's email address. Not included if the email scope was not specified in the
|
|
45
|
+
* (Optional) User's email address. Not included if the email scope was not specified in the
|
|
46
|
+
* authorization request.
|
|
53
47
|
*/
|
|
54
48
|
email?: string;
|
|
55
49
|
};
|
|
56
50
|
signature: string;
|
|
57
51
|
};
|
|
58
52
|
/**
|
|
59
|
-
* (Node only) Returns a decoded LINE id token. Uses the nodeJS 'jsonwebtoken' dependency.
|
|
60
|
-
*
|
|
61
|
-
*
|
|
53
|
+
* (Node only) Returns a decoded LINE id token. Uses the nodeJS 'jsonwebtoken' dependency. This id
|
|
54
|
+
* Token should be validated! LINE documentation:
|
|
55
|
+
* https://developers.line.biz/en/docs/line-login/integrate-line-login/#decode-and-validate-id-token
|
|
62
56
|
*/
|
|
63
57
|
export declare function decodeIdToken(idToken: string): DecodedIdToken;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import jwt from 'jsonwebtoken';
|
|
2
2
|
const { decode } = jwt;
|
|
3
3
|
/**
|
|
4
|
-
* (Node only) Returns a decoded LINE id token. Uses the nodeJS 'jsonwebtoken' dependency.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* (Node only) Returns a decoded LINE id token. Uses the nodeJS 'jsonwebtoken' dependency. This id
|
|
5
|
+
* Token should be validated! LINE documentation:
|
|
6
|
+
* https://developers.line.biz/en/docs/line-login/integrate-line-login/#decode-and-validate-id-token
|
|
7
7
|
*/
|
|
8
8
|
export function decodeIdToken(idToken) {
|
|
9
9
|
// get the decoded payload ignoring signature, no secretOrPrivateKey needed
|
|
@@ -1,63 +1,55 @@
|
|
|
1
1
|
export type IssueAccessTokenParams = {
|
|
2
|
-
/**
|
|
3
|
-
* (Optional - default: 'authorization_code') authorization_code. Specifies the grant type.
|
|
4
|
-
*/
|
|
2
|
+
/** (Optional - default: 'authorization_code') authorization_code. Specifies the grant type. */
|
|
5
3
|
grant_type?: string;
|
|
6
|
-
/**
|
|
7
|
-
* (Required) Authorization code. Code returned in the authorization request.
|
|
8
|
-
*/
|
|
4
|
+
/** (Required) Authorization code. Code returned in the authorization request. */
|
|
9
5
|
code: string;
|
|
10
6
|
/**
|
|
11
|
-
* (Required) Callback URL. Must match one of the the callback URLs registered for your channel in
|
|
7
|
+
* (Required) Callback URL. Must match one of the the callback URLs registered for your channel in
|
|
8
|
+
* the console.
|
|
12
9
|
*/
|
|
13
10
|
redirect_uri: string;
|
|
14
|
-
/**
|
|
15
|
-
* (Required) Channel ID. Found in the console.
|
|
16
|
-
*/
|
|
11
|
+
/** (Required) Channel ID. Found in the console. */
|
|
17
12
|
client_id: string;
|
|
18
|
-
/**
|
|
19
|
-
* (Required) Channel secret. Found in the console.
|
|
20
|
-
*/
|
|
13
|
+
/** (Required) Channel secret. Found in the console. */
|
|
21
14
|
client_secret: string;
|
|
22
15
|
};
|
|
23
16
|
/**
|
|
24
|
-
* The LINE Platform validates the request and returns an access token and other data as shown in
|
|
17
|
+
* The LINE Platform validates the request and returns an access token and other data as shown in
|
|
18
|
+
* the table below.
|
|
25
19
|
*
|
|
26
|
-
* New or changed LINE Login functions may cause changes in the structure of the payload JSON
|
|
20
|
+
* New or changed LINE Login functions may cause changes in the structure of the payload JSON
|
|
21
|
+
* object. These changes may include added properties, variations in property order, and
|
|
22
|
+
* added/removed white space and line breaks. Design your backend so that it can handle payload data
|
|
23
|
+
* objects with unexpected structures.
|
|
27
24
|
*
|
|
28
25
|
* Returns status code 200 and a JSON object with the following information.
|
|
29
26
|
*/
|
|
30
27
|
export type IssueAccessTokenResponse = {
|
|
31
|
-
/**
|
|
32
|
-
* Access token. Valid for 30 days.
|
|
33
|
-
*/
|
|
28
|
+
/** Access token. Valid for 30 days. */
|
|
34
29
|
access_token: string;
|
|
35
|
-
/**
|
|
36
|
-
* Amount of time in seconds until the access token expires.
|
|
37
|
-
*/
|
|
30
|
+
/** Amount of time in seconds until the access token expires. */
|
|
38
31
|
expires_in: number;
|
|
39
32
|
/**
|
|
40
|
-
* JSON Web Token (JWT) that includes information about the user. This field is returned only if
|
|
33
|
+
* JSON Web Token (JWT) that includes information about the user. This field is returned only if
|
|
34
|
+
* openid is specified in the scope. For more information, see Verify ID token.
|
|
41
35
|
*/
|
|
42
36
|
id_token: string;
|
|
43
|
-
/**
|
|
44
|
-
* Token used to get a new access token. Valid up until 90 days after the access token issued.
|
|
45
|
-
*/
|
|
37
|
+
/** Token used to get a new access token. Valid up until 90 days after the access token issued. */
|
|
46
38
|
refresh_token: string;
|
|
47
39
|
/**
|
|
48
|
-
* Permissions granted by the user. However, the email scope is not returned as a value of the
|
|
40
|
+
* Permissions granted by the user. However, the email scope is not returned as a value of the
|
|
41
|
+
* scope property even if the permission has been granted.
|
|
49
42
|
*/
|
|
50
43
|
scope: string;
|
|
51
|
-
/**
|
|
52
|
-
* Bearer
|
|
53
|
-
*/
|
|
44
|
+
/** Bearer */
|
|
54
45
|
token_type: string;
|
|
55
46
|
};
|
|
56
47
|
/**
|
|
57
|
-
* (Node only) Makes a POST request to retrieve an access token from LINE. This uses GOT as a
|
|
58
|
-
* Can throw errors.
|
|
48
|
+
* (Node only) Makes a POST request to retrieve an access token from LINE. This uses GOT as a
|
|
49
|
+
* dependency to make the request. Can throw errors.
|
|
59
50
|
*
|
|
60
|
-
* LINE documentation:
|
|
51
|
+
* LINE documentation:
|
|
52
|
+
* https://developers.line.biz/en/docs/line-login/integrate-line-login/#get-access-token
|
|
61
53
|
*
|
|
62
54
|
* @param {IssueAccessTokenParams} params
|
|
63
55
|
* @returns {Promise<IssueAccessTokenResponse>}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import got from 'got';
|
|
2
2
|
const post = got.post;
|
|
3
3
|
/**
|
|
4
|
-
* (Node only) Makes a POST request to retrieve an access token from LINE. This uses GOT as a
|
|
5
|
-
* Can throw errors.
|
|
4
|
+
* (Node only) Makes a POST request to retrieve an access token from LINE. This uses GOT as a
|
|
5
|
+
* dependency to make the request. Can throw errors.
|
|
6
6
|
*
|
|
7
|
-
* LINE documentation:
|
|
7
|
+
* LINE documentation:
|
|
8
|
+
* https://developers.line.biz/en/docs/line-login/integrate-line-login/#get-access-token
|
|
8
9
|
*
|
|
9
10
|
* @param {IssueAccessTokenParams} params
|
|
10
11
|
* @returns {Promise<IssueAccessTokenResponse>}
|
|
@@ -15,9 +16,10 @@ export async function issueAccessToken(params) {
|
|
|
15
16
|
throw new Error('Missing information in params');
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
|
-
* To get an access token, make an HTTP POST request with the authorization code. Once you have an
|
|
19
|
-
* The
|
|
20
|
-
* Content-Type:
|
|
19
|
+
* To get an access token, make an HTTP POST request with the authorization code. Once you have an
|
|
20
|
+
* access token, you can use it to make API calls. The access token is issued at the following
|
|
21
|
+
* endpoint. The information in the request body should be: Content-Type:
|
|
22
|
+
* application/x-www-form-urlencoded
|
|
21
23
|
*/
|
|
22
24
|
const form = { grant_type, code, redirect_uri, client_id, client_secret };
|
|
23
25
|
const response = await post('https://api.line.me/oauth2/v2.1/token', {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "line-node",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "LINE SDK for TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -10,23 +10,19 @@
|
|
|
10
10
|
"engines": {
|
|
11
11
|
"node": ">=18"
|
|
12
12
|
},
|
|
13
|
-
"scripts": {
|
|
14
|
-
"test": "echo todo",
|
|
15
|
-
"lint": "tsc --noEmit && eslint ./src",
|
|
16
|
-
"build": "del-cli dist && tsc",
|
|
17
|
-
"release": "npm run lint && npm run build && np"
|
|
18
|
-
},
|
|
19
13
|
"dependencies": {
|
|
20
|
-
"got": "^
|
|
21
|
-
"jsonwebtoken": "^9.0.
|
|
14
|
+
"got": "^16.0.0",
|
|
15
|
+
"jsonwebtoken": "^9.0.3"
|
|
22
16
|
},
|
|
23
17
|
"devDependencies": {
|
|
24
|
-
"@
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
18
|
+
"@cycraft/eslint": "^0.4.11",
|
|
19
|
+
"@cycraft/tsconfig": "^0.1.2",
|
|
20
|
+
"@types/jsonwebtoken": "^9.0.10",
|
|
21
|
+
"bumpp": "^12.3.0",
|
|
22
|
+
"del-cli": "^7.0.0",
|
|
23
|
+
"eslint": "^9.20.1",
|
|
24
|
+
"typescript": "^5.9.3",
|
|
25
|
+
"vitest": "^5.0.2"
|
|
30
26
|
},
|
|
31
27
|
"files": [
|
|
32
28
|
"dist"
|
|
@@ -45,5 +41,11 @@
|
|
|
45
41
|
"url": "https://github.com/mesqueeb/line-node.git"
|
|
46
42
|
},
|
|
47
43
|
"homepage": "https://github.com/mesqueeb/line-node#readme",
|
|
48
|
-
"bugs": "https://github.com/mesqueeb/line-node/issues"
|
|
49
|
-
|
|
44
|
+
"bugs": "https://github.com/mesqueeb/line-node/issues",
|
|
45
|
+
"scripts": {
|
|
46
|
+
"test": "echo todo",
|
|
47
|
+
"lint": "tsc --noEmit && eslint ./src",
|
|
48
|
+
"build": "del-cli dist && tsc",
|
|
49
|
+
"release": "pnpm run lint && pnpm run build && pnpm test && bumpp --no-push --all && pnpm publish --no-git-checks && npx jsr publish && git push --follow-tags && gh release create $(git describe --tags --abbrev=0) --generate-notes --notes \"$(git log --pretty='- %s %h' $(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || git rev-list --max-parents=0 HEAD)..HEAD~1)\""
|
|
50
|
+
}
|
|
51
|
+
}
|