mirror of
https://github.com/LukeHagar/plex-api-oauth.git
synced 2025-12-07 20:47:46 +00:00
Node_modules
This commit is contained in:
22
node_modules/plex-oauth/build/src/class/AuthPin.d.ts
generated
vendored
Normal file
22
node_modules/plex-oauth/build/src/class/AuthPin.d.ts
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
import { IPlexCodeResponse, IPlexClientDetails } from "../models/PlexCodeModels";
|
||||
export declare class AuthPin {
|
||||
constructor();
|
||||
/**
|
||||
* Request's an OAuth Pin from the Plex API, which is used to get the Auth Token
|
||||
* @param {IPlexClientDetails} clientInfo Client information to send to the Plex API
|
||||
*
|
||||
* @returns {Promise<IPlexCodeResponse>} The hosted ui URL
|
||||
*/
|
||||
getPin(clientInfo: IPlexClientDetails): Promise<IPlexCodeResponse>;
|
||||
/**
|
||||
* Sends repeated requests to the Plex Pin API with the provided pin id. It will then return
|
||||
* the auth token if it gets one, or null if it runs out of retries.
|
||||
* @param {IPlexClientDetails} clientInfo Client information to send to the Plex API
|
||||
* @param {number} pinId The id of the Plex pin to query for
|
||||
* @param {number} requestDelay The delay in seconds to wait between each poll
|
||||
* @param {number} maxRetries The number of retries before returning null
|
||||
*
|
||||
* @returns {Promise<string | null>} The auth token if found or null
|
||||
*/
|
||||
pollForAuthToken(clientInfo: IPlexClientDetails, pinId: number, requestDelay: number, maxRetries: number): Promise<string | null>;
|
||||
}
|
||||
72
node_modules/plex-oauth/build/src/class/AuthPin.js
generated
vendored
Normal file
72
node_modules/plex-oauth/build/src/class/AuthPin.js
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
"use strict";
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthPin = void 0;
|
||||
var RequestHelper_1 = require("../helpers/RequestHelper");
|
||||
var LinkHelper_1 = require("../helpers/LinkHelper");
|
||||
var Util_1 = require("../helpers/Util");
|
||||
var AuthPin = /** @class */ (function () {
|
||||
function AuthPin() {
|
||||
}
|
||||
/**
|
||||
* Request's an OAuth Pin from the Plex API, which is used to get the Auth Token
|
||||
* @param {IPlexClientDetails} clientInfo Client information to send to the Plex API
|
||||
*
|
||||
* @returns {Promise<IPlexCodeResponse>} The hosted ui URL
|
||||
*/
|
||||
AuthPin.prototype.getPin = function (clientInfo) {
|
||||
return RequestHelper_1.RequestHelper.post(LinkHelper_1.LinkHelper.PLEX_PIN_BASE_PATH + "/pins?strong=true", "", __assign({}, LinkHelper_1.LinkHelper.getHeaders(clientInfo))).then(function (response) {
|
||||
return response;
|
||||
}).catch(function (err) {
|
||||
throw err;
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Sends repeated requests to the Plex Pin API with the provided pin id. It will then return
|
||||
* the auth token if it gets one, or null if it runs out of retries.
|
||||
* @param {IPlexClientDetails} clientInfo Client information to send to the Plex API
|
||||
* @param {number} pinId The id of the Plex pin to query for
|
||||
* @param {number} requestDelay The delay in seconds to wait between each poll
|
||||
* @param {number} maxRetries The number of retries before returning null
|
||||
*
|
||||
* @returns {Promise<string | null>} The auth token if found or null
|
||||
*/
|
||||
AuthPin.prototype.pollForAuthToken = function (clientInfo, pinId, requestDelay, maxRetries) {
|
||||
var _this = this;
|
||||
if (requestDelay < 1000) {
|
||||
requestDelay = 1000;
|
||||
}
|
||||
return RequestHelper_1.RequestHelper.get(LinkHelper_1.LinkHelper.PLEX_PIN_BASE_PATH + "/pins/" + pinId, __assign({}, LinkHelper_1.LinkHelper.getHeaders(clientInfo))).then(function (response) {
|
||||
if (response) {
|
||||
var pinData = response;
|
||||
if (pinData.authToken) {
|
||||
return pinData.authToken;
|
||||
}
|
||||
else {
|
||||
if (maxRetries <= 0) {
|
||||
return null;
|
||||
}
|
||||
return Util_1.Util.wait(function () { return _this.pollForAuthToken(clientInfo, pinId, requestDelay, maxRetries -= 1); }, requestDelay);
|
||||
}
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}).catch(function (err) {
|
||||
throw err;
|
||||
});
|
||||
};
|
||||
return AuthPin;
|
||||
}());
|
||||
exports.AuthPin = AuthPin;
|
||||
//# sourceMappingURL=AuthPin.js.map
|
||||
1
node_modules/plex-oauth/build/src/class/AuthPin.js.map
generated
vendored
Normal file
1
node_modules/plex-oauth/build/src/class/AuthPin.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"AuthPin.js","sourceRoot":"","sources":["../../../src/class/AuthPin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,0DAAyD;AACzD,oDAAmD;AACnD,wCAAuC;AAEvC;IACI;IAAe,CAAC;IAEhB;;;;;OAKG;IACI,wBAAM,GAAb,UAAc,UAA8B;QACxC,OAAO,6BAAa,CAAC,IAAI,CAAI,uBAAU,CAAC,kBAAkB,sBAAmB,EAAE,EAAE,eAAM,uBAAU,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,CAAC,UAAA,QAAQ;YACpI,OAAO,QAA6B,CAAC;QACzC,CAAC,CAAC,CAAC,KAAK,CAAC,UAAA,GAAG;YACR,MAAM,GAAG,CAAC;QACd,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;;;OASG;IACI,kCAAgB,GAAvB,UAAwB,UAA8B,EAAE,KAAa,EAAE,YAAoB,EAAE,UAAkB;QAA/G,iBAqBC;QApBG,IAAG,YAAY,GAAG,IAAI,EAAE;YACpB,YAAY,GAAG,IAAI,CAAC;SACvB;QAED,OAAO,6BAAa,CAAC,GAAG,CAAI,uBAAU,CAAC,kBAAkB,cAAS,KAAO,eAAM,uBAAU,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,CAAC,UAAA,QAAQ;YAC5H,IAAG,QAAQ,EAAE;gBACT,IAAI,OAAO,GAAG,QAA6B,CAAC;gBAE5C,IAAG,OAAO,CAAC,SAAS,EAAE;oBAClB,OAAO,OAAO,CAAC,SAAS,CAAC;iBAC5B;qBAAK;oBACF,IAAG,UAAU,IAAI,CAAC,EAAE;wBAAE,OAAO,IAAI,CAAA;qBAAE;oBACnC,OAAO,WAAI,CAAC,IAAI,CAAgB,cAAM,OAAA,KAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,IAAE,CAAC,CAAC,EAArE,CAAqE,EAAE,YAAY,CAAC,CAAC;iBAC9H;aACJ;iBAAK;gBACF,OAAO,IAAI,CAAC;aACf;QACL,CAAC,CAAC,CAAC,KAAK,CAAC,UAAA,GAAG;YACR,MAAM,GAAG,CAAC;QACd,CAAC,CAAC,CAAC;IACP,CAAC;IACL,cAAC;AAAD,CAAC,AAjDD,IAiDC;AAjDY,0BAAO"}
|
||||
27
node_modules/plex-oauth/build/src/class/PlexOauth.d.ts
generated
vendored
Normal file
27
node_modules/plex-oauth/build/src/class/PlexOauth.d.ts
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import { IPlexClientDetails } from "../models/PlexCodeModels";
|
||||
export declare class PlexOauth {
|
||||
private clientInfo;
|
||||
private authPin;
|
||||
/**
|
||||
* Create an instance of the 'PlexOauth' class
|
||||
* @param {IPlexClientDetails} clientIdentifier Unique identifier for your client (Should be different for every client)
|
||||
*/
|
||||
constructor(clientInfo: IPlexClientDetails);
|
||||
/**
|
||||
* Request the hosted UI link for your app. A user will use this link to sign in and authenticate with Plex.
|
||||
* This gets returned with the pin id needed to query the Plex Pin API for the auth token
|
||||
* @returns {Promise<[string, number]} [hostedUIUrl, pinId] - Returns a promise of the hosted login URL and the pin Id as a tuple
|
||||
*/
|
||||
requestHostedLoginURL(): Promise<[string, number]>;
|
||||
/**
|
||||
* After a user signs in with the hosted UI, we need to check the Plex API for the auth token.
|
||||
* This function will poll their API looking for the auth token and returning it if found.
|
||||
* If the auth token is not found, this function will return null
|
||||
* @param {number} pinId The pinId to query for
|
||||
* @param {number} requestDelay The amount of delay in milliseconds. Can not go below 1000 (1 second)
|
||||
* @param {number} maxRetries The maximum number of retries until an auth token is received
|
||||
*
|
||||
* @returns {Promise<string | null>} The authtoken if found or null
|
||||
*/
|
||||
checkForAuthToken(pinId: number, requestDelay?: number, maxRetries?: number): Promise<string | null>;
|
||||
}
|
||||
58
node_modules/plex-oauth/build/src/class/PlexOauth.js
generated
vendored
Normal file
58
node_modules/plex-oauth/build/src/class/PlexOauth.js
generated
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PlexOauth = void 0;
|
||||
var AuthPin_1 = require("./AuthPin");
|
||||
var LinkHelper_1 = require("../helpers/LinkHelper");
|
||||
var PlexOauth = /** @class */ (function () {
|
||||
/**
|
||||
* Create an instance of the 'PlexOauth' class
|
||||
* @param {IPlexClientDetails} clientIdentifier Unique identifier for your client (Should be different for every client)
|
||||
*/
|
||||
function PlexOauth(clientInfo) {
|
||||
this.clientInfo = clientInfo;
|
||||
this.authPin = new AuthPin_1.AuthPin();
|
||||
}
|
||||
/**
|
||||
* Request the hosted UI link for your app. A user will use this link to sign in and authenticate with Plex.
|
||||
* This gets returned with the pin id needed to query the Plex Pin API for the auth token
|
||||
* @returns {Promise<[string, number]} [hostedUIUrl, pinId] - Returns a promise of the hosted login URL and the pin Id as a tuple
|
||||
*/
|
||||
PlexOauth.prototype.requestHostedLoginURL = function () {
|
||||
var _this = this;
|
||||
return this.authPin.getPin(this.clientInfo).then(function (codeResponse) {
|
||||
return [
|
||||
LinkHelper_1.LinkHelper.PLEX_AUTH_BASE_PATH + "#?code=" + codeResponse.code + "&context[device][product]=" + _this.clientInfo.product + "&context[device][device]=" + _this.clientInfo.device + "&clientID=" + codeResponse.clientIdentifier + "&forwardUrl=" + _this.clientInfo.forwardUrl,
|
||||
codeResponse.id
|
||||
];
|
||||
}).catch(function (err) {
|
||||
throw err;
|
||||
});
|
||||
};
|
||||
/**
|
||||
* After a user signs in with the hosted UI, we need to check the Plex API for the auth token.
|
||||
* This function will poll their API looking for the auth token and returning it if found.
|
||||
* If the auth token is not found, this function will return null
|
||||
* @param {number} pinId The pinId to query for
|
||||
* @param {number} requestDelay The amount of delay in milliseconds. Can not go below 1000 (1 second)
|
||||
* @param {number} maxRetries The maximum number of retries until an auth token is received
|
||||
*
|
||||
* @returns {Promise<string | null>} The authtoken if found or null
|
||||
*/
|
||||
PlexOauth.prototype.checkForAuthToken = function (pinId, requestDelay, maxRetries) {
|
||||
if (!pinId) {
|
||||
throw new Error("Pin Id is not set - Unable to poll for auth token without id");
|
||||
}
|
||||
// If 'requestDelay' or 'maxRetries' is not set, then we will treat this
|
||||
// as a single request, so we only request the auth token from the api once
|
||||
requestDelay = requestDelay || 1000;
|
||||
maxRetries = maxRetries || 0;
|
||||
return this.authPin.pollForAuthToken(this.clientInfo, pinId, requestDelay, maxRetries).then(function (authToken) {
|
||||
return authToken;
|
||||
}).catch(function (err) {
|
||||
throw err;
|
||||
});
|
||||
};
|
||||
return PlexOauth;
|
||||
}());
|
||||
exports.PlexOauth = PlexOauth;
|
||||
//# sourceMappingURL=PlexOauth.js.map
|
||||
1
node_modules/plex-oauth/build/src/class/PlexOauth.js.map
generated
vendored
Normal file
1
node_modules/plex-oauth/build/src/class/PlexOauth.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"PlexOauth.js","sourceRoot":"","sources":["../../../src/class/PlexOauth.ts"],"names":[],"mappings":";;;AACA,qCAAoC;AACpC,oDAAmD;AAEnD;IAGI;;;OAGG;IACH,mBAAqB,UAA8B;QAA9B,eAAU,GAAV,UAAU,CAAoB;QAC/C,IAAI,CAAC,OAAO,GAAG,IAAI,iBAAO,EAAE,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACI,yCAAqB,GAA5B;QAAA,iBASC;QARG,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,UAAA,YAAY;YACzD,OAAO;gBACA,uBAAU,CAAC,mBAAmB,eAAU,YAAY,CAAC,IAAI,kCAA6B,KAAI,CAAC,UAAU,CAAC,OAAO,iCAA4B,KAAI,CAAC,UAAU,CAAC,MAAM,kBAAa,YAAY,CAAC,gBAAgB,oBAAe,KAAI,CAAC,UAAU,CAAC,UAAY;gBACvP,YAAY,CAAC,EAAE;aACE,CAAC;QAC1B,CAAC,CAAC,CAAC,KAAK,CAAC,UAAA,GAAG;YACR,MAAM,GAAG,CAAC;QACd,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;;;OASG;IACI,qCAAiB,GAAxB,UAAyB,KAAa,EAAE,YAAqB,EAAE,UAAmB;QAC9E,IAAG,CAAC,KAAK,EAAE;YAAE,MAAM,IAAI,KAAK,CAAE,8DAA8D,CAAC,CAAC;SAAE;QAEhG,wEAAwE;QACxE,2EAA2E;QAC3E,YAAY,GAAG,YAAY,IAAI,IAAI,CAAC;QACpC,UAAU,GAAG,UAAU,IAAI,CAAC,CAAC;QAE7B,OAAO,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,UAAA,SAAS;YACjG,OAAO,SAAS,CAAC;QACrB,CAAC,CAAC,CAAC,KAAK,CAAC,UAAA,GAAG;YACR,MAAM,GAAG,CAAC;QACd,CAAC,CAAC,CAAC;IACP,CAAC;IACL,gBAAC;AAAD,CAAC,AAnDD,IAmDC;AAnDY,8BAAS"}
|
||||
17
node_modules/plex-oauth/build/src/helpers/LinkHelper.d.ts
generated
vendored
Normal file
17
node_modules/plex-oauth/build/src/helpers/LinkHelper.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
import { IPlexPinHeaders, IPlexClientDetails } from "../models/PlexCodeModels";
|
||||
/**
|
||||
* Contains a series of helper functions and values for getting and building the url's needed to
|
||||
* request a Plex pin and token
|
||||
*/
|
||||
export declare class LinkHelper {
|
||||
static readonly PLEX_PIN_BASE_PATH = "https://plex.tv/api/v2";
|
||||
static readonly PLEX_AUTH_BASE_PATH = "https://app.plex.tv/auth";
|
||||
static readonly PLEX_DEFAULT_PLATFORM = "Web";
|
||||
/**
|
||||
* Returns the headers needed to make requests to the Plex API using the client info
|
||||
* @param {IPlexClientDetails} clientInfo Client info to build headers from
|
||||
*
|
||||
* @returns {IPlexPinHeaders} The headers needed to make the requests to the Plex API
|
||||
*/
|
||||
static getHeaders(clientInfo: IPlexClientDetails): IPlexPinHeaders;
|
||||
}
|
||||
32
node_modules/plex-oauth/build/src/helpers/LinkHelper.js
generated
vendored
Normal file
32
node_modules/plex-oauth/build/src/helpers/LinkHelper.js
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.LinkHelper = void 0;
|
||||
/**
|
||||
* Contains a series of helper functions and values for getting and building the url's needed to
|
||||
* request a Plex pin and token
|
||||
*/
|
||||
var LinkHelper = /** @class */ (function () {
|
||||
function LinkHelper() {
|
||||
}
|
||||
/**
|
||||
* Returns the headers needed to make requests to the Plex API using the client info
|
||||
* @param {IPlexClientDetails} clientInfo Client info to build headers from
|
||||
*
|
||||
* @returns {IPlexPinHeaders} The headers needed to make the requests to the Plex API
|
||||
*/
|
||||
LinkHelper.getHeaders = function (clientInfo) {
|
||||
return {
|
||||
"X-Plex-Client-Identifier": clientInfo.clientIdentifier,
|
||||
"X-Plex-Device": clientInfo.device,
|
||||
"X-Plex-Platform": clientInfo.platform || this.PLEX_DEFAULT_PLATFORM,
|
||||
"X-Plex-Product": clientInfo.product,
|
||||
"X-Plex-Version": clientInfo.version
|
||||
};
|
||||
};
|
||||
LinkHelper.PLEX_PIN_BASE_PATH = "https://plex.tv/api/v2";
|
||||
LinkHelper.PLEX_AUTH_BASE_PATH = "https://app.plex.tv/auth";
|
||||
LinkHelper.PLEX_DEFAULT_PLATFORM = "Web";
|
||||
return LinkHelper;
|
||||
}());
|
||||
exports.LinkHelper = LinkHelper;
|
||||
//# sourceMappingURL=LinkHelper.js.map
|
||||
1
node_modules/plex-oauth/build/src/helpers/LinkHelper.js.map
generated
vendored
Normal file
1
node_modules/plex-oauth/build/src/helpers/LinkHelper.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"LinkHelper.js","sourceRoot":"","sources":["../../../src/helpers/LinkHelper.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACH;IAAA;IAqBA,CAAC;IAfG;;;;;OAKG;IACW,qBAAU,GAAxB,UAAyB,UAA8B;QACnD,OAAO;YACH,0BAA0B,EAAE,UAAU,CAAC,gBAAgB;YACvD,eAAe,EAAE,UAAU,CAAC,MAAM;YAClC,iBAAiB,EAAE,UAAU,CAAC,QAAQ,IAAI,IAAI,CAAC,qBAAqB;YACpE,gBAAgB,EAAE,UAAU,CAAC,OAAO;YACpC,gBAAgB,EAAE,UAAU,CAAC,OAAO;SACvC,CAAA;IACL,CAAC;IAnBsB,6BAAkB,GAAG,wBAAwB,CAAC;IAC9C,8BAAmB,GAAG,0BAA0B,CAAC;IAEjD,gCAAqB,GAAG,KAAK,CAAC;IAiBzD,iBAAC;CAAA,AArBD,IAqBC;AArBY,gCAAU"}
|
||||
23
node_modules/plex-oauth/build/src/helpers/RequestHelper.d.ts
generated
vendored
Normal file
23
node_modules/plex-oauth/build/src/helpers/RequestHelper.d.ts
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import { AxiosRequestConfig } from "axios";
|
||||
/**
|
||||
* Class to facilitate the different web requests needed to query the Plex OAuth API
|
||||
*/
|
||||
export declare class RequestHelper {
|
||||
/**
|
||||
* Make a GET request to the specified endpoint
|
||||
* @param {string} url Request URL
|
||||
* @param {OutgoingHttpHeaders} headers Additional headers to be passed to the request
|
||||
*
|
||||
* @returns {Promise<any>} A promise containing the result of the GET request
|
||||
*/
|
||||
static get(url: string, headers: AxiosRequestConfig["headers"]): Promise<any>;
|
||||
/**
|
||||
* Make a POST request to the specified endpoint
|
||||
* @param {string} url Request URL
|
||||
* @param {string} body Body as a JSON String
|
||||
* @param {OutgoingHttpHeaders} headers Additional headers to be passed to the request
|
||||
*
|
||||
* @returns {Promise<any>} A promise containing the result of the POST request
|
||||
*/
|
||||
static post(url: string, body: string, headers: AxiosRequestConfig["headers"]): Promise<any>;
|
||||
}
|
||||
57
node_modules/plex-oauth/build/src/helpers/RequestHelper.js
generated
vendored
Normal file
57
node_modules/plex-oauth/build/src/helpers/RequestHelper.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
"use strict";
|
||||
var __assign = (this && this.__assign) || function () {
|
||||
__assign = Object.assign || function(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||
t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RequestHelper = void 0;
|
||||
var axios_1 = __importDefault(require("axios"));
|
||||
/**
|
||||
* Class to facilitate the different web requests needed to query the Plex OAuth API
|
||||
*/
|
||||
var RequestHelper = /** @class */ (function () {
|
||||
function RequestHelper() {
|
||||
}
|
||||
/**
|
||||
* Make a GET request to the specified endpoint
|
||||
* @param {string} url Request URL
|
||||
* @param {OutgoingHttpHeaders} headers Additional headers to be passed to the request
|
||||
*
|
||||
* @returns {Promise<any>} A promise containing the result of the GET request
|
||||
*/
|
||||
RequestHelper.get = function (url, headers) {
|
||||
return axios_1.default.get(url, {
|
||||
headers: __assign({ "Content-Type": "application/json", "Accept": "application/json" }, headers)
|
||||
}).then(function (response) {
|
||||
return response.data;
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Make a POST request to the specified endpoint
|
||||
* @param {string} url Request URL
|
||||
* @param {string} body Body as a JSON String
|
||||
* @param {OutgoingHttpHeaders} headers Additional headers to be passed to the request
|
||||
*
|
||||
* @returns {Promise<any>} A promise containing the result of the POST request
|
||||
*/
|
||||
RequestHelper.post = function (url, body, headers) {
|
||||
return axios_1.default.post(url, body, {
|
||||
headers: __assign({ "Content-Type": "application/json", "Accept": "application/json" }, headers)
|
||||
}).then(function (response) {
|
||||
return response.data;
|
||||
});
|
||||
};
|
||||
return RequestHelper;
|
||||
}());
|
||||
exports.RequestHelper = RequestHelper;
|
||||
//# sourceMappingURL=RequestHelper.js.map
|
||||
1
node_modules/plex-oauth/build/src/helpers/RequestHelper.js.map
generated
vendored
Normal file
1
node_modules/plex-oauth/build/src/helpers/RequestHelper.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"RequestHelper.js","sourceRoot":"","sources":["../../../src/helpers/RequestHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,gDAAkD;AAElD;;GAEG;AACH;IAAA;IAuCA,CAAC;IAtCG;;;;;;OAMG;IACW,iBAAG,GAAjB,UAAkB,GAAW,EAAE,OAAsC;QAClE,OAAO,eAAK,CAAC,GAAG,CAAC,GAAG,EAAE;YACjB,OAAO,aACH,cAAc,EAAE,kBAAkB,EAClC,QAAQ,EAAE,kBAAkB,IACzB,OAAO,CACb;SACJ,CAAC,CAAC,IAAI,CAAC,UAAA,QAAQ;YACZ,OAAO,QAAQ,CAAC,IAAI,CAAC;QACzB,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;;;;;;OAOG;IACW,kBAAI,GAAlB,UAAmB,GAAW,EAAE,IAAY,EAAE,OAAsC;QAChF,OAAO,eAAK,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE;YACzB,OAAO,aACH,cAAc,EAAE,kBAAkB,EAClC,QAAQ,EAAE,kBAAkB,IACzB,OAAO,CACb;SACJ,CAAC,CAAC,IAAI,CAAC,UAAA,QAAQ;YACZ,OAAO,QAAQ,CAAC,IAAI,CAAC;QACzB,CAAC,CAAC,CAAC;IACP,CAAC;IACL,oBAAC;AAAD,CAAC,AAvCD,IAuCC;AAvCY,sCAAa"}
|
||||
10
node_modules/plex-oauth/build/src/helpers/Util.d.ts
generated
vendored
Normal file
10
node_modules/plex-oauth/build/src/helpers/Util.d.ts
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
export declare class Util {
|
||||
/**
|
||||
* Returns the input function after waiting the specified amount of time
|
||||
* @param {Function} func The input function
|
||||
* @param {number} waitTime The amount of time in milliseconds to wait
|
||||
*
|
||||
* @returns {Promise<T>} A promise containing the value of the input function
|
||||
*/
|
||||
static wait<T>(func: Function, waitTime: number): Promise<T>;
|
||||
}
|
||||
24
node_modules/plex-oauth/build/src/helpers/Util.js
generated
vendored
Normal file
24
node_modules/plex-oauth/build/src/helpers/Util.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Util = void 0;
|
||||
var Util = /** @class */ (function () {
|
||||
function Util() {
|
||||
}
|
||||
/**
|
||||
* Returns the input function after waiting the specified amount of time
|
||||
* @param {Function} func The input function
|
||||
* @param {number} waitTime The amount of time in milliseconds to wait
|
||||
*
|
||||
* @returns {Promise<T>} A promise containing the value of the input function
|
||||
*/
|
||||
Util.wait = function (func, waitTime) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
setTimeout(function () {
|
||||
resolve(func());
|
||||
}, waitTime);
|
||||
});
|
||||
};
|
||||
return Util;
|
||||
}());
|
||||
exports.Util = Util;
|
||||
//# sourceMappingURL=Util.js.map
|
||||
1
node_modules/plex-oauth/build/src/helpers/Util.js.map
generated
vendored
Normal file
1
node_modules/plex-oauth/build/src/helpers/Util.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Util.js","sourceRoot":"","sources":["../../../src/helpers/Util.ts"],"names":[],"mappings":";;;AAAA;IAAA;IAeA,CAAC;IAdG;;;;;;OAMG;IACW,SAAI,GAAlB,UAAsB,IAAc,EAAE,QAAgB;QAClD,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;YAC/B,UAAU,CAAC;gBACP,OAAO,CAAC,IAAI,EAAkB,CAAC,CAAC;YACpC,CAAC,EAAE,QAAQ,CAAC,CAAA;QAChB,CAAC,CAAC,CAAC;IACP,CAAC;IACL,WAAC;AAAD,CAAC,AAfD,IAeC;AAfY,oBAAI"}
|
||||
2
node_modules/plex-oauth/build/src/index.d.ts
generated
vendored
Normal file
2
node_modules/plex-oauth/build/src/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./class/PlexOauth";
|
||||
export { IPlexClientDetails } from "./models/PlexCodeModels";
|
||||
14
node_modules/plex-oauth/build/src/index.js
generated
vendored
Normal file
14
node_modules/plex-oauth/build/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./class/PlexOauth"), exports);
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/plex-oauth/build/src/index.js.map
generated
vendored
Normal file
1
node_modules/plex-oauth/build/src/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oDAAkC"}
|
||||
68
node_modules/plex-oauth/build/src/models/PlexCodeModels.d.ts
generated
vendored
Normal file
68
node_modules/plex-oauth/build/src/models/PlexCodeModels.d.ts
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* Represents the location of the user requesting the pin code
|
||||
*/
|
||||
interface IPlexCodeLocation {
|
||||
city: string;
|
||||
code: string;
|
||||
coordinates: string;
|
||||
country: string;
|
||||
postal_code: string;
|
||||
subdivisions: string;
|
||||
time_zone: string;
|
||||
}
|
||||
/**
|
||||
* Represents the response from the Plex Pins API
|
||||
*/
|
||||
export interface IPlexCodeResponse {
|
||||
authToken: string | null;
|
||||
clientIdentifier: string;
|
||||
code: string;
|
||||
createdAt: string;
|
||||
expiresAt: string;
|
||||
expiresIn: number;
|
||||
id: number;
|
||||
location: IPlexCodeLocation;
|
||||
newRegistration: boolean | null;
|
||||
product: string;
|
||||
trusted: boolean;
|
||||
}
|
||||
/**
|
||||
* Represents the headers needed when sending requests to the Plex Pins API
|
||||
*/
|
||||
export interface IPlexPinHeaders {
|
||||
"X-Plex-Client-Identifier": string;
|
||||
"X-Plex-Device": string;
|
||||
"X-Plex-Platform": string;
|
||||
"X-Plex-Product": string;
|
||||
"X-Plex-Version": string;
|
||||
}
|
||||
/**
|
||||
* Represents info about your Plex application
|
||||
*/
|
||||
export interface IPlexClientDetails {
|
||||
/**
|
||||
* Unique Id that identifies your client
|
||||
*/
|
||||
clientIdentifier: string;
|
||||
/**
|
||||
* Name of your application
|
||||
*/
|
||||
product: string;
|
||||
/**
|
||||
* The type of device your application is running on
|
||||
*/
|
||||
device: string;
|
||||
/**
|
||||
* Version of your application
|
||||
*/
|
||||
version: string;
|
||||
/**
|
||||
* Optional - Url to forward back to your application
|
||||
*/
|
||||
forwardUrl: string;
|
||||
/**
|
||||
* Optional - Defaults to 'Web'
|
||||
*/
|
||||
platform?: string;
|
||||
}
|
||||
export {};
|
||||
3
node_modules/plex-oauth/build/src/models/PlexCodeModels.js
generated
vendored
Normal file
3
node_modules/plex-oauth/build/src/models/PlexCodeModels.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=PlexCodeModels.js.map
|
||||
1
node_modules/plex-oauth/build/src/models/PlexCodeModels.js.map
generated
vendored
Normal file
1
node_modules/plex-oauth/build/src/models/PlexCodeModels.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"PlexCodeModels.js","sourceRoot":"","sources":["../../../src/models/PlexCodeModels.ts"],"names":[],"mappings":""}
|
||||
1
node_modules/plex-oauth/build/test/index.spec.d.ts
generated
vendored
Normal file
1
node_modules/plex-oauth/build/test/index.spec.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export {};
|
||||
29
node_modules/plex-oauth/build/test/index.spec.js
generated
vendored
Normal file
29
node_modules/plex-oauth/build/test/index.spec.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var src_1 = require("../src");
|
||||
describe("Module", function () {
|
||||
var plexOauth = new src_1.PlexOauth({
|
||||
clientIdentifier: "dhjoasoidjapoiwdmamlw",
|
||||
device: "TEST DEVICE",
|
||||
product: "TEST DEVICE",
|
||||
version: "1",
|
||||
forwardUrl: "https://localhost/"
|
||||
});
|
||||
it("loads and initializes", function () {
|
||||
expect(plexOauth).toBeDefined();
|
||||
});
|
||||
it("returns a hosted ui link and poll for an auth token", function () {
|
||||
plexOauth.requestHostedLoginURL().then(function (response) {
|
||||
var hostedUiLink = response[0], pinId = response[1];
|
||||
expect(hostedUiLink).toBeDefined();
|
||||
expect(hostedUiLink).toContain("https://app.plex.tv/auth");
|
||||
expect(hostedUiLink).not.toContain("undefined");
|
||||
expect(hostedUiLink).not.toContain("null");
|
||||
plexOauth.checkForAuthToken(pinId, 1000, 1).then(function (pinResponse) {
|
||||
var authToken = pinResponse;
|
||||
expect(authToken).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=index.spec.js.map
|
||||
1
node_modules/plex-oauth/build/test/index.spec.js.map
generated
vendored
Normal file
1
node_modules/plex-oauth/build/test/index.spec.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.spec.js","sourceRoot":"","sources":["../../test/index.spec.ts"],"names":[],"mappings":";;AAAA,8BAAmC;AAEnC,QAAQ,CAAC,QAAQ,EAAE;IACf,IAAI,SAAS,GAAG,IAAI,eAAS,CAAC;QAC1B,gBAAgB,EAAE,uBAAuB;QACzC,MAAM,EAAE,aAAa;QACrB,OAAO,EAAE,aAAa;QACtB,OAAO,EAAE,GAAG;QACZ,UAAU,EAAE,oBAAoB;KACnC,CAAC,CAAC;IAEH,EAAE,CAAC,uBAAuB,EAAE;QACxB,MAAM,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qDAAqD,EAAE;QACtD,SAAS,CAAC,qBAAqB,EAAE,CAAC,IAAI,CAAC,UAAA,QAAQ;YACtC,IAAA,YAAY,GAAW,QAAQ,GAAnB,EAAE,KAAK,GAAI,QAAQ,GAAZ,CAAa;YAErC,MAAM,CAAC,YAAY,CAAC,CAAC,WAAW,EAAE,CAAC;YACnC,MAAM,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC,0BAA0B,CAAC,CAAC;YAC3D,MAAM,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;YAChD,MAAM,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAE3C,SAAS,CAAC,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAA,WAAW;gBACxD,IAAI,SAAS,GAAG,WAAW,CAAC;gBAE5B,MAAM,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC;YACjC,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
||||
Reference in New Issue
Block a user