UNPKG

@kkbox/kkbox-js-sdk

Version:

KKBOX Open API developer SDK for JavaScript. Use it to easily access KKBOX open API to get various metadata about KKBOX's tracks, albums, artists, playlists and stations.

1,404 lines (1,403 loc) 158 kB
{ "type": "File", "start": 0, "end": 2247, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 65, "column": 1 } }, "program": { "type": "Program", "start": 0, "end": 2247, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 65, "column": 1 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 53, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 53 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 8, "end": 33, "loc": { "start": { "line": 1, "column": 8 }, "end": { "line": 1, "column": 33 } }, "imported": { "type": "Identifier", "start": 8, "end": 21, "loc": { "start": { "line": 1, "column": 8 }, "end": { "line": 1, "column": 21 }, "identifierName": "Authorization" }, "name": "Authorization" }, "local": { "type": "Identifier", "start": 25, "end": 33, "loc": { "start": { "line": 1, "column": 25 }, "end": { "line": 1, "column": 33 }, "identifierName": "ENDPOINT" }, "name": "ENDPOINT" } } ], "source": { "type": "StringLiteral", "start": 40, "end": 53, "loc": { "start": { "line": 1, "column": 40 }, "end": { "line": 1, "column": 53 } }, "extra": { "rawValue": "../Endpoint", "raw": "'../Endpoint'" }, "value": "../Endpoint", "leadingComments": null, "trailingComments": null }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * @see https://docs.kkbox.codes/docs/authorization-code-flow\n ", "start": 55, "end": 124, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 5, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 125, "end": 2247, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 65, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 140, "end": 2247, "loc": { "start": { "line": 6, "column": 15 }, "end": { "line": 65, "column": 1 } }, "id": { "type": "Identifier", "start": 146, "end": 163, "loc": { "start": { "line": 6, "column": 21 }, "end": { "line": 6, "column": 38 }, "identifierName": "AuthorizationCode" }, "name": "AuthorizationCode", "leadingComments": null }, "superClass": null, "body": { "type": "ClassBody", "start": 164, "end": 2247, "loc": { "start": { "line": 6, "column": 39 }, "end": { "line": 65, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 201, "end": 564, "loc": { "start": { "line": 10, "column": 4 }, "end": { "line": 30, "column": 5 } }, "computed": false, "key": { "type": "Identifier", "start": 201, "end": 212, "loc": { "start": { "line": 10, "column": 4 }, "end": { "line": 10, "column": 15 }, "identifierName": "constructor" }, "name": "constructor", "leadingComments": null }, "static": false, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 213, "end": 222, "loc": { "start": { "line": 10, "column": 16 }, "end": { "line": 10, "column": 25 }, "identifierName": "client_id" }, "name": "client_id" }, { "type": "Identifier", "start": 224, "end": 237, "loc": { "start": { "line": 10, "column": 27 }, "end": { "line": 10, "column": 40 }, "identifierName": "client_secret" }, "name": "client_secret" }, { "type": "Identifier", "start": 239, "end": 244, "loc": { "start": { "line": 10, "column": 42 }, "end": { "line": 10, "column": 47 }, "identifierName": "token" }, "name": "token" } ], "body": { "type": "BlockStatement", "start": 246, "end": 564, "loc": { "start": { "line": 10, "column": 49 }, "end": { "line": 30, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 299, "end": 325, "loc": { "start": { "line": 14, "column": 8 }, "end": { "line": 14, "column": 34 } }, "expression": { "type": "AssignmentExpression", "start": 299, "end": 325, "loc": { "start": { "line": 14, "column": 8 }, "end": { "line": 14, "column": 34 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 299, "end": 313, "loc": { "start": { "line": 14, "column": 8 }, "end": { "line": 14, "column": 22 } }, "object": { "type": "ThisExpression", "start": 299, "end": 303, "loc": { "start": { "line": 14, "column": 8 }, "end": { "line": 14, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 304, "end": 313, "loc": { "start": { "line": 14, "column": 13 }, "end": { "line": 14, "column": 22 }, "identifierName": "client_id" }, "name": "client_id" }, "computed": false, "leadingComments": null }, "right": { "type": "Identifier", "start": 316, "end": 325, "loc": { "start": { "line": 14, "column": 25 }, "end": { "line": 14, "column": 34 }, "identifierName": "client_id" }, "name": "client_id", "leadingComments": null, "trailingComments": null }, "leadingComments": null, "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 256, "end": 290, "loc": { "start": { "line": 11, "column": 8 }, "end": { "line": 13, "column": 11 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 335, "end": 369, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 18, "column": 11 } } } ] }, { "type": "ExpressionStatement", "start": 378, "end": 412, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 42 } }, "expression": { "type": "AssignmentExpression", "start": 378, "end": 412, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 42 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 378, "end": 396, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 26 } }, "object": { "type": "ThisExpression", "start": 378, "end": 382, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 19, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 383, "end": 396, "loc": { "start": { "line": 19, "column": 13 }, "end": { "line": 19, "column": 26 }, "identifierName": "client_secret" }, "name": "client_secret" }, "computed": false, "leadingComments": null }, "right": { "type": "Identifier", "start": 399, "end": 412, "loc": { "start": { "line": 19, "column": 29 }, "end": { "line": 19, "column": 42 }, "identifierName": "client_secret" }, "name": "client_secret", "leadingComments": null, "trailingComments": null }, "leadingComments": null, "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 335, "end": 369, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 18, "column": 11 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 422, "end": 456, "loc": { "start": { "line": 21, "column": 8 }, "end": { "line": 23, "column": 11 } } } ] }, { "type": "ExpressionStatement", "start": 465, "end": 483, "loc": { "start": { "line": 24, "column": 8 }, "end": { "line": 24, "column": 26 } }, "expression": { "type": "AssignmentExpression", "start": 465, "end": 483, "loc": { "start": { "line": 24, "column": 8 }, "end": { "line": 24, "column": 26 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 465, "end": 475, "loc": { "start": { "line": 24, "column": 8 }, "end": { "line": 24, "column": 18 } }, "object": { "type": "ThisExpression", "start": 465, "end": 469, "loc": { "start": { "line": 24, "column": 8 }, "end": { "line": 24, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 470, "end": 475, "loc": { "start": { "line": 24, "column": 13 }, "end": { "line": 24, "column": 18 }, "identifierName": "token" }, "name": "token" }, "computed": false, "leadingComments": null }, "right": { "type": "Identifier", "start": 478, "end": 483, "loc": { "start": { "line": 24, "column": 21 }, "end": { "line": 24, "column": 26 }, "identifierName": "token" }, "name": "token", "leadingComments": null, "trailingComments": null }, "leadingComments": null, "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 422, "end": 456, "loc": { "start": { "line": 21, "column": 8 }, "end": { "line": 23, "column": 11 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 493, "end": 527, "loc": { "start": { "line": 26, "column": 8 }, "end": { "line": 28, "column": 11 } } } ] }, { "type": "ExpressionStatement", "start": 536, "end": 558, "loc": { "start": { "line": 29, "column": 8 }, "end": { "line": 29, "column": 30 } }, "expression": { "type": "AssignmentExpression", "start": 536, "end": 558, "loc": { "start": { "line": 29, "column": 8 }, "end": { "line": 29, "column": 30 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 536, "end": 546, "loc": { "start": { "line": 29, "column": 8 }, "end": { "line": 29, "column": 18 } }, "object": { "type": "ThisExpression", "start": 536, "end": 540, "loc": { "start": { "line": 29, "column": 8 }, "end": { "line": 29, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 541, "end": 546, "loc": { "start": { "line": 29, "column": 13 }, "end": { "line": 29, "column": 18 }, "identifierName": "scope" }, "name": "scope" }, "computed": false, "leadingComments": null }, "right": { "type": "Identifier", "start": 549, "end": 558, "loc": { "start": { "line": 29, "column": 21 }, "end": { "line": 29, "column": 30 }, "identifierName": "undefined" }, "name": "undefined" }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 493, "end": 527, "loc": { "start": { "line": 26, "column": 8 }, "end": { "line": 28, "column": 11 } } } ] } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 170, "end": 196, "loc": { "start": { "line": 7, "column": 4 }, "end": { "line": 9, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Get the KKBOX authorization uri for user agreeing to authorize your application.\n *\n * @param {string} scope - ['user_profile', 'user_territory', 'user_account_status'] The scope of resource that developers ask KKBOX users to authorize.\n * @param {string} redirect_uri - The redirect URI for callback behavior of developer application.\n * @param {string} [response_type='code'] - The type of response.\n * @param {string} [state] - Developer may use this parameter freely.\n * @return {string} - Uri.\n * @example auth.authorizationCode.generateAuthorizationUri('user_profile user_territory user_account_status', 'https://text.com')\n * @see https://docs.kkbox.codes/docs/kkbox-oauth-20-authorize-api\n ", "start": 570, "end": 1317, "loc": { "start": { "line": 32, "column": 4 }, "end": { "line": 42, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 1322, "end": 1580, "loc": { "start": { "line": 43, "column": 4 }, "end": { "line": 46, "column": 5 } }, "computed": false, "key": { "type": "Identifier", "start": 1322, "end": 1341, "loc": { "start": { "line": 43, "column": 4 }, "end": { "line": 43, "column": 23 }, "identifierName": "getAuthorizationUri" }, "name": "getAuthorizationUri", "leadingComments": null }, "static": false, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 1342, "end": 1347, "loc": { "start": { "line": 43, "column": 24 }, "end": { "line": 43, "column": 29 }, "identifierName": "scope" }, "name": "scope" }, { "type": "Identifier", "start": 1349, "end": 1361, "loc": { "start": { "line": 43, "column": 31 }, "end": { "line": 43, "column": 43 }, "identifierName": "redirect_uri" }, "name": "redirect_uri" }, { "type": "AssignmentPattern", "start": 1363, "end": 1385, "loc": { "start": { "line": 43, "column": 45 }, "end": { "line": 43, "column": 67 } }, "left": { "type": "Identifier", "start": 1363, "end": 1376, "loc": { "start": { "line": 43, "column": 45 }, "end": { "line": 43, "column": 58 }, "identifierName": "response_type" }, "name": "response_type" }, "right": { "type": "StringLiteral", "start": 1379, "end": 1385, "loc": { "start": { "line": 43, "column": 61 }, "end": { "line": 43, "column": 67 } }, "extra": { "rawValue": "code", "raw": "'code'" }, "value": "code" } }, { "type": "AssignmentPattern", "start": 1387, "end": 1397, "loc": { "start": { "line": 43, "column": 69 }, "end": { "line": 43, "column": 79 } }, "left": { "type": "Identifier", "start": 1387, "end": 1392, "loc": { "start": { "line": 43, "column": 69 }, "end": { "line": 43, "column": 74 }, "identifierName": "state" }, "name": "state" }, "right": { "type": "StringLiteral", "start": 1395, "end": 1397, "loc": { "start": { "line": 43, "column": 77 }, "end": { "line": 43, "column": 79 } }, "extra": { "rawValue": "", "raw": "''" }, "value": "" } } ], "body": { "type": "BlockStatement", "start": 1399, "end": 1580, "loc": { "start": { "line": 43, "column": 81 }, "end": { "line": 46, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 1409, "end": 1427, "loc": { "start": { "line": 44, "column": 8 }, "end": { "line": 44, "column": 26 } }, "expression": { "type": "AssignmentExpression", "start": 1409, "end": 1427, "loc": { "start": { "line": 44, "column": 8 }, "end": { "line": 44, "column": 26 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 1409, "end": 1419, "loc": { "start": { "line": 44, "column": 8 }, "end": { "line": 44, "column": 18 } }, "object": { "type": "ThisExpression", "start": 1409, "end": 1413, "loc": { "start": { "line": 44, "column": 8 }, "end": { "line": 44, "column": 12 } } }, "property": { "type": "Identifier", "start": 1414, "end": 1419, "loc": { "start": { "line": 44, "column": 13 }, "end": { "line": 44, "column": 18 }, "identifierName": "scope" }, "name": "scope" }, "computed": false }, "right": { "type": "Identifier", "start": 1422, "end": 1427, "loc": { "start": { "line": 44, "column": 21 }, "end": { "line": 44, "column": 26 }, "identifierName": "scope" }, "name": "scope" } } }, { "type": "ReturnStatement", "start": 1436, "end": 1574, "loc": { "start": { "line": 45, "column": 8 }, "end": { "line": 45, "column": 146 } }, "argument": { "type": "BinaryExpression", "start": 1443, "end": 1574, "loc": { "start": { "line": 45, "column": 15 }, "end": { "line": 45, "column": 146 } }, "left": { "type": "Identifier", "start": 1443, "end": 1451, "loc": { "start": { "line": 45, "column": 15 }, "end": { "line": 45, "column": 23 }, "identifierName": "ENDPOINT" }, "name": "ENDPOINT" }, "operator": "+", "right": { "type": "TemplateLiteral", "start": 1454, "end": 1574, "loc": { "start": { "line": 45, "column": 26 }, "end": { "line": 45, "column": 146 } }, "expressions": [ { "type": "Identifier", "start": 1464, "end": 1469, "loc": { "start": { "line": 45, "column": 36 }, "end": { "line": 45, "column": 41 }, "identifierName": "scope" }, "name": "scope" }, { "type": "Identifier", "start": 1486, "end": 1498, "loc": { "start": { "line": 45, "column": 58 }, "end": { "line": 45, "column": 70 }, "identifierName": "redirect_uri" }, "name": "redirect_uri" }, { "type": "MemberExpression", "start": 1512, "end": 1526, "loc": { "start": { "line": 45, "column": 84 }, "end": { "line": 45, "column": 98 } }, "object": { "type": "ThisExpression", "start": 1512, "end": 1516, "loc": { "start": { "line": 45, "column": 84 }, "end": { "line": 45, "column": 88 } } }, "property": { "type": "Identifier", "start": 1517, "end": 1526, "loc": { "start": { "line": 45, "column": 89 }, "end": { "line": 45, "column": 98 }, "identifierName": "client_id" }, "name": "client_id" }, "computed": false }, { "type": "Identifier", "start": 1544, "end": 1557, "loc": { "start": { "line": 45, "column": 116 }, "end": { "line": 45, "column": 129 }, "identifierName": "response_type" }, "name": "response_type" }, { "type": "Identifier", "start": 1567, "end": 1572, "loc": { "start": { "line": 45, "column": 139 }, "end": { "line": 45, "column": 144 }, "identifierName": "state" }, "name": "state" } ], "quasis": [ { "type": "TemplateElement", "start": 1455, "end": 1462, "loc": { "start": { "line": 45, "column": 27 }, "end": { "line": 45, "column": 34 } }, "value": { "raw": "?scope=", "cooked": "?scope=" }, "tail": false }, { "type": "TemplateElement", "start": 1470, "end": 1484, "loc": { "start": { "line": 45, "column": 42 }, "end": { "line": 45, "column": 56 } }, "value": { "raw": "&redirect_uri=", "cooked": "&redirect_uri=" }, "tail": false }, { "type": "TemplateElement", "start": 1499, "end": 1510, "loc": { "start": { "line": 45, "column": 71 }, "end": { "line": 45, "column": 82 } }, "value": { "raw": "&client_id=", "cooked": "&client_id="