line-ts 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.
@@ -1,4 +1,2 @@
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 declare function randomString(length?: number): string;
@@ -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 authorization. Must match one of the the callback URLs registered for your channel in the console.
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 request forgery. This value should be randomly generated by your application. Cannot be a URL-encoded string.
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 scopes.
23
- * To obtain the email address of a user, you must first apply for permission.
24
- * An access token with the profile scope is required to get the friendship status between a user and a LINE Official Account.
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 already granted all requested permissions.
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 authenticated. Corresponds to the max_age parameter defined in the "Authentication Request" section of OpenID Connect Core 1.0.
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) language tags, separated by spaces, in order of preference. Corresponds to the ui_locales parameter defined in the "Authentication Request" section of OpenID Connect Core 1.0.
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 either normal or aggressive. For more information, see Add a LINE Official Account as a friend when logged in (bot link).
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: https://developers.line.biz/en/docs/line-login/integrate-line-login/#making-an-authorization-request
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} the `https://access.line.me/oauth2/v2.1/authorize${query}` URL with correct query
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;
@@ -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: https://developers.line.biz/en/docs/line-login/integrate-line-login/#making-an-authorization-request
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} the `https://access.line.me/oauth2/v2.1/authorize${query}` URL with correct query
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 can only be used once.
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
- * state parameter included in the authorization URL of original request. Your application should verify that this value matches the one in the original request.
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
- * true if the friendship status between the user and the LINE Official Account changes during login. Otherwise, the value is false. This parameter is only returned if the bot_prompt query parameter is specified when making an authorization request and the option to add your LINE Official Account as a friend when the user logged in is displayed. For more information, see Add a LINE Official Account as a friend when logged in (bot link).
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 parameter.
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 parameters are returned in the callback URL. This function converts the callback URL to an object with the query parameters.
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 eg. https://client.example.org/cb?code=abcd1234&state=0987poi&friendship_status_changed=true
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 parameters are returned in the callback URL. This function converts the callback URL to an object with the query parameters.
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
- * @param {string} callbackUrlTriggered eg. https://client.example.org/cb?code=abcd1234&state=0987poi&friendship_status_changed=true
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];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "line-ts",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "LINE SDK for TypeScript",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -10,19 +10,15 @@
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
  "devDependencies": {
20
- "@types/jsonwebtoken": "^9.0.6",
21
- "del-cli": "^5.1.0",
22
- "np": "^10.0.5",
23
- "vitest": "^1.6.0",
24
- "@cycraft/eslint": "^0.3.0",
25
- "@cycraft/tsconfig": "^0.1.2"
14
+ "@cycraft/eslint": "^0.4.11",
15
+ "@cycraft/tsconfig": "^0.1.2",
16
+ "@types/jsonwebtoken": "^9.0.10",
17
+ "bumpp": "^12.3.0",
18
+ "del-cli": "^7.0.0",
19
+ "eslint": "^9.20.1",
20
+ "typescript": "^5.9.3",
21
+ "vitest": "^5.0.2"
26
22
  },
27
23
  "files": [
28
24
  "dist"
@@ -41,5 +37,11 @@
41
37
  "url": "https://github.com/mesqueeb/line-ts.git"
42
38
  },
43
39
  "homepage": "https://github.com/mesqueeb/line-ts#readme",
44
- "bugs": "https://github.com/mesqueeb/line-ts/issues"
45
- }
40
+ "bugs": "https://github.com/mesqueeb/line-ts/issues",
41
+ "scripts": {
42
+ "test": "echo todo",
43
+ "lint": "tsc --noEmit && eslint ./src",
44
+ "build": "del-cli dist && tsc",
45
+ "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)\""
46
+ }
47
+ }