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,487 lines (1,486 loc) 296 kB
{ "type": "File", "start": 0, "end": 3244, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 92, "column": 1 } }, "program": { "type": "Program", "start": 0, "end": 3244, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 92, "column": 1 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 25, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 25 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 7, "end": 12, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 12 } }, "local": { "type": "Identifier", "start": 7, "end": 12, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 12 }, "identifierName": "axios" }, "name": "axios" } } ], "source": { "type": "StringLiteral", "start": 18, "end": 25, "loc": { "start": { "line": 1, "column": 18 }, "end": { "line": 1, "column": 25 } }, "extra": { "rawValue": "axios", "raw": "'axios'" }, "value": "axios" } }, { "type": "ImportDeclaration", "start": 26, "end": 65, "loc": { "start": { "line": 2, "column": 0 }, "end": { "line": 2, "column": 39 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 34, "end": 43, "loc": { "start": { "line": 2, "column": 8 }, "end": { "line": 2, "column": 17 } }, "imported": { "type": "Identifier", "start": 34, "end": 43, "loc": { "start": { "line": 2, "column": 8 }, "end": { "line": 2, "column": 17 }, "identifierName": "authError" }, "name": "authError" }, "local": { "type": "Identifier", "start": 34, "end": 43, "loc": { "start": { "line": 2, "column": 8 }, "end": { "line": 2, "column": 17 }, "identifierName": "authError" }, "name": "authError" } } ], "source": { "type": "StringLiteral", "start": 50, "end": 65, "loc": { "start": { "line": 2, "column": 24 }, "end": { "line": 2, "column": 39 } }, "extra": { "rawValue": "../catchError", "raw": "'../catchError'" }, "value": "../catchError" } }, { "type": "ImportDeclaration", "start": 66, "end": 103, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 37 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 73, "end": 84, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 18 } }, "local": { "type": "Identifier", "start": 73, "end": 84, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 18 }, "identifierName": "querystring" }, "name": "querystring" } } ], "source": { "type": "StringLiteral", "start": 90, "end": 103, "loc": { "start": { "line": 3, "column": 24 }, "end": { "line": 3, "column": 37 } }, "extra": { "rawValue": "querystring", "raw": "'querystring'" }, "value": "querystring" } }, { "type": "ImportDeclaration", "start": 104, "end": 166, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 62 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 112, "end": 146, "loc": { "start": { "line": 4, "column": 8 }, "end": { "line": 4, "column": 42 } }, "imported": { "type": "Identifier", "start": 112, "end": 122, "loc": { "start": { "line": 4, "column": 8 }, "end": { "line": 4, "column": 18 }, "identifierName": "DeviceCode" }, "name": "DeviceCode" }, "local": { "type": "Identifier", "start": 126, "end": 146, "loc": { "start": { "line": 4, "column": 22 }, "end": { "line": 4, "column": 42 }, "identifierName": "ENDPOINT_DEVICE_CODE" }, "name": "ENDPOINT_DEVICE_CODE" } } ], "source": { "type": "StringLiteral", "start": 153, "end": 166, "loc": { "start": { "line": 4, "column": 49 }, "end": { "line": 4, "column": 62 } }, "extra": { "rawValue": "../Endpoint", "raw": "'../Endpoint'" }, "value": "../Endpoint" } }, { "type": "ImportDeclaration", "start": 167, "end": 238, "loc": { "start": { "line": 5, "column": 0 }, "end": { "line": 5, "column": 71 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 175, "end": 218, "loc": { "start": { "line": 5, "column": 8 }, "end": { "line": 5, "column": 51 } }, "imported": { "type": "Identifier", "start": 175, "end": 189, "loc": { "start": { "line": 5, "column": 8 }, "end": { "line": 5, "column": 22 }, "identifierName": "GenerateQRCode" }, "name": "GenerateQRCode" }, "local": { "type": "Identifier", "start": 193, "end": 218, "loc": { "start": { "line": 5, "column": 26 }, "end": { "line": 5, "column": 51 }, "identifierName": "ENDPOINT_GENERATE_QR_CODE" }, "name": "ENDPOINT_GENERATE_QR_CODE" } } ], "source": { "type": "StringLiteral", "start": 225, "end": 238, "loc": { "start": { "line": 5, "column": 58 }, "end": { "line": 5, "column": 71 } }, "extra": { "rawValue": "../Endpoint", "raw": "'../Endpoint'" }, "value": "../Endpoint", "leadingComments": null, "trailingComments": null }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * @see https://docs.kkbox.codes/docs/oauth-20-for-devices-flow\n ", "start": 240, "end": 311, "loc": { "start": { "line": 7, "column": 0 }, "end": { "line": 9, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 312, "end": 3244, "loc": { "start": { "line": 10, "column": 0 }, "end": { "line": 92, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 327, "end": 3244, "loc": { "start": { "line": 10, "column": 15 }, "end": { "line": 92, "column": 1 } }, "id": { "type": "Identifier", "start": 333, "end": 339, "loc": { "start": { "line": 10, "column": 21 }, "end": { "line": 10, "column": 27 }, "identifierName": "Device" }, "name": "Device", "leadingComments": null }, "superClass": null, "body": { "type": "ClassBody", "start": 340, "end": 3244, "loc": { "start": { "line": 10, "column": 28 }, "end": { "line": 92, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 377, "end": 746, "loc": { "start": { "line": 14, "column": 4 }, "end": { "line": 34, "column": 5 } }, "computed": false, "key": { "type": "Identifier", "start": 377, "end": 388, "loc": { "start": { "line": 14, "column": 4 }, "end": { "line": 14, "column": 15 }, "identifierName": "constructor" }, "name": "constructor", "leadingComments": null }, "static": false, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 389, "end": 398, "loc": { "start": { "line": 14, "column": 16 }, "end": { "line": 14, "column": 25 }, "identifierName": "client_id" }, "name": "client_id" }, { "type": "Identifier", "start": 400, "end": 413, "loc": { "start": { "line": 14, "column": 27 }, "end": { "line": 14, "column": 40 }, "identifierName": "client_secret" }, "name": "client_secret" }, { "type": "Identifier", "start": 415, "end": 420, "loc": { "start": { "line": 14, "column": 42 }, "end": { "line": 14, "column": 47 }, "identifierName": "token" }, "name": "token" } ], "body": { "type": "BlockStatement", "start": 422, "end": 746, "loc": { "start": { "line": 14, "column": 49 }, "end": { "line": 34, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 475, "end": 501, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 34 } }, "expression": { "type": "AssignmentExpression", "start": 475, "end": 501, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 34 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 475, "end": 489, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 22 } }, "object": { "type": "ThisExpression", "start": 475, "end": 479, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 480, "end": 489, "loc": { "start": { "line": 18, "column": 13 }, "end": { "line": 18, "column": 22 }, "identifierName": "client_id" }, "name": "client_id" }, "computed": false, "leadingComments": null }, "right": { "type": "Identifier", "start": 492, "end": 501, "loc": { "start": { "line": 18, "column": 25 }, "end": { "line": 18, "column": 34 }, "identifierName": "client_id" }, "name": "client_id", "leadingComments": null, "trailingComments": null }, "leadingComments": null, "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 432, "end": 466, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 17, "column": 11 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 511, "end": 545, "loc": { "start": { "line": 20, "column": 8 }, "end": { "line": 22, "column": 11 } } } ] }, { "type": "ExpressionStatement", "start": 554, "end": 588, "loc": { "start": { "line": 23, "column": 8 }, "end": { "line": 23, "column": 42 } }, "expression": { "type": "AssignmentExpression", "start": 554, "end": 588, "loc": { "start": { "line": 23, "column": 8 }, "end": { "line": 23, "column": 42 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 554, "end": 572, "loc": { "start": { "line": 23, "column": 8 }, "end": { "line": 23, "column": 26 } }, "object": { "type": "ThisExpression", "start": 554, "end": 558, "loc": { "start": { "line": 23, "column": 8 }, "end": { "line": 23, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 559, "end": 572, "loc": { "start": { "line": 23, "column": 13 }, "end": { "line": 23, "column": 26 }, "identifierName": "client_secret" }, "name": "client_secret" }, "computed": false, "leadingComments": null }, "right": { "type": "Identifier", "start": 575, "end": 588, "loc": { "start": { "line": 23, "column": 29 }, "end": { "line": 23, "column": 42 }, "identifierName": "client_secret" }, "name": "client_secret", "leadingComments": null, "trailingComments": null }, "leadingComments": null, "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 511, "end": 545, "loc": { "start": { "line": 20, "column": 8 }, "end": { "line": 22, "column": 11 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 598, "end": 632, "loc": { "start": { "line": 25, "column": 8 }, "end": { "line": 27, "column": 11 } } } ] }, { "type": "ExpressionStatement", "start": 641, "end": 659, "loc": { "start": { "line": 28, "column": 8 }, "end": { "line": 28, "column": 26 } }, "expression": { "type": "AssignmentExpression", "start": 641, "end": 659, "loc": { "start": { "line": 28, "column": 8 }, "end": { "line": 28, "column": 26 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 641, "end": 651, "loc": { "start": { "line": 28, "column": 8 }, "end": { "line": 28, "column": 18 } }, "object": { "type": "ThisExpression", "start": 641, "end": 645, "loc": { "start": { "line": 28, "column": 8 }, "end": { "line": 28, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 646, "end": 651, "loc": { "start": { "line": 28, "column": 13 }, "end": { "line": 28, "column": 18 }, "identifierName": "token" }, "name": "token" }, "computed": false, "leadingComments": null }, "right": { "type": "Identifier", "start": 654, "end": 659, "loc": { "start": { "line": 28, "column": 21 }, "end": { "line": 28, "column": 26 }, "identifierName": "token" }, "name": "token", "leadingComments": null, "trailingComments": null }, "leadingComments": null, "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 598, "end": 632, "loc": { "start": { "line": 25, "column": 8 }, "end": { "line": 27, "column": 11 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 669, "end": 703, "loc": { "start": { "line": 30, "column": 8 }, "end": { "line": 32, "column": 11 } } } ] }, { "type": "ExpressionStatement", "start": 712, "end": 740, "loc": { "start": { "line": 33, "column": 8 }, "end": { "line": 33, "column": 36 } }, "expression": { "type": "AssignmentExpression", "start": 712, "end": 740, "loc": { "start": { "line": 33, "column": 8 }, "end": { "line": 33, "column": 36 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 712, "end": 728, "loc": { "start": { "line": 33, "column": 8 }, "end": { "line": 33, "column": 24 } }, "object": { "type": "ThisExpression", "start": 712, "end": 716, "loc": { "start": { "line": 33, "column": 8 }, "end": { "line": 33, "column": 12 } }, "leadingComments": null }, "property": { "type": "Identifier", "start": 717, "end": 728, "loc": { "start": { "line": 33, "column": 13 }, "end": { "line": 33, "column": 24 }, "identifierName": "device_code" }, "name": "device_code" }, "computed": false, "leadingComments": null }, "right": { "type": "Identifier", "start": 731, "end": 740, "loc": { "start": { "line": 33, "column": 27 }, "end": { "line": 33, "column": 36 }, "identifierName": "undefined" }, "name": "undefined" }, "leadingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 669, "end": 703, "loc": { "start": { "line": 30, "column": 8 }, "end": { "line": 32, "column": 11 } } } ] } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * @ignore\n ", "start": 346, "end": 372, "loc": { "start": { "line": 11, "column": 4 }, "end": { "line": 13, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Generate 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 * @return {Promise}\n * @example auth.device.generateAuthorizationUri('user_profile user_territory user_account_status')\n * @see https://docs.kkbox.codes/docs/kkbox-oauth-20-device-code-api\n ", "start": 752, "end": 1222, "loc": { "start": { "line": 36, "column": 4 }, "end": { "line": 43, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 1227, "end": 1657, "loc": { "start": { "line": 44, "column": 4 }, "end": { "line": 53, "column": 5 } }, "computed": false, "key": { "type": "Identifier", "start": 1227, "end": 1251, "loc": { "start": { "line": 44, "column": 4 }, "end": { "line": 44, "column": 28 }, "identifierName": "generateAuthorizationUri" }, "name": "generateAuthorizationUri", "leadingComments": null }, "static": false, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 1252, "end": 1257, "loc": { "start": { "line": 44, "column": 29 }, "end": { "line": 44, "column": 34 }, "identifierName": "scope" }, "name": "scope" } ], "body": { "type": "BlockStatement", "start": 1259, "end": 1657, "loc": { "start": { "line": 44, "column": 36 }, "end": { "line": 53, "column": 5 } }, "body": [ { "type": "ReturnStatement", "start": 1298, "end": 1651, "loc": { "start": { "line": 46, "column": 8 }, "end": { "line": 52, "column": 27 } }, "argument": { "type": "CallExpression", "start": 1305, "end": 1651, "loc": { "start": { "line": 46, "column": 15 }, "end": { "line": 52, "column": 27 } }, "callee": { "type": "MemberExpression", "start": 1305, "end": 1640, "loc": { "start": { "line": 46, "column": 15 }, "end": { "line": 52, "column": 16 } }, "object": { "type": "CallExpression", "start": 1305, "end": 1634, "loc": { "start": { "line": 46, "column": 15 }, "end": { "line": 52, "column": 10 } }, "callee": { "type": "MemberExpression", "start": 1305, "end": 1493, "loc": { "start": { "line": 46, "column": 15 }, "end": { "line": 49, "column": 67 } }, "object": { "type": "CallExpression", "start": 1305, "end": 1488, "loc": { "start": { "line": 46, "column": 15 }, "end": { "line": 49, "column": 62 } }, "callee": { "type": "MemberExpression", "start": 1305, "end": 1315, "loc": { "start": { "line": 46, "column": 15 }, "end": { "line": 46, "column": 25 } }, "object": { "type": "Identifier", "start": 1305, "end": 1310, "loc": { "start": { "line": 46, "column": 15 }, "end": { "line": 46, "column": 20 }, "identifierName": "axios" }, "name": "axios", "leadingComments": null }, "property": { "type": "Identifier", "start": 1311, "end": 1315, "loc": { "start": { "line": 46, "column": 21 }, "end": { "line": 46, "column": 25 }, "identifierName": "post" }, "name": "post" }, "computed": false, "leadingComments": null }, "arguments": [ { "type": "Identifier", "start": 1316, "end": 1336, "loc": { "start": { "line": 46, "column": 26 }, "end": { "line": 46, "column": 46 }, "identifierName": "ENDPOINT_DEVICE_CODE" }, "name": "ENDPOINT_DEVICE_CODE" }, { "type": "CallExpression", "start": 1338, "end": 1436, "loc": { "start": { "line": 46, "column": 48 }, "end": { "line": 49, "column": 10 } }, "callee": { "type": "MemberExpression", "start": 1338, "end": 1359, "loc": { "start": { "line": 46, "column": 48 }, "end": { "line": 46, "column": 69 } }, "object": { "type": "Identifier", "start": 1338, "end": 1349, "loc": { "start": { "line": 46, "column": 48 }, "end": { "line": 46, "column": 59 }, "identifierName": "querystring" }, "name": "querystring" }, "property": { "type": "Identifier", "start": 1350, "end": 1359, "loc": { "start": { "line": 46, "column": 60 }, "end": { "line": 46, "column": 69 }, "identifierName": "stringify" }, "name": "stringify" }, "computed": false }, "arguments": [ { "type": "ObjectExpression", "start": 1360, "end": 1435, "loc": { "start": { "line": 46,