Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

plex-oauth

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

plex-oauth - npm Package Compare versions

Comparing version 1.0.2 to 1.1.2

6

build/src/class/AuthPin.js

@@ -37,5 +37,2 @@ "use strict";

return RequestHelper_1.RequestHelper.get(`${LinkHelper_1.LinkHelper.PLEX_PIN_BASE_PATH}/pins/${pinId}`, { ...LinkHelper_1.LinkHelper.getHeaders(clientInfo) }).then(response => {
if (maxRetries <= 0) {
return null;
}
if (response) {

@@ -47,2 +44,5 @@ let pinData = response;

else {
if (maxRetries <= 0) {
return null;
}
return Util_1.Util.wait(() => this.pollForAuthToken(clientInfo, pinId, requestDelay, maxRetries -= 1), requestDelay);

@@ -49,0 +49,0 @@ }

@@ -26,3 +26,3 @@ import { IPlexClientDetails } from "../models/PlexCodeModels";

*/
checkForAuthToken(pinId: number, requestDelay: number, maxRetries: number): Promise<string | null>;
checkForAuthToken(pinId: number, requestDelay?: number, maxRetries?: number): Promise<string | null>;
}

@@ -23,3 +23,3 @@ "use strict";

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}`,
`${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

@@ -45,2 +45,6 @@ ];

}
// 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(authToken => {

@@ -47,0 +51,0 @@ return authToken;

@@ -60,2 +60,6 @@ /**

/**
* Optional - Url to forward back to your application
*/
forwardUrl: string;
/**
* Optional - Defaults to 'Web'

@@ -62,0 +66,0 @@ */

@@ -9,3 +9,4 @@ "use strict";

product: "TEST DEVICE",
version: "1"
version: "1",
forwardUrl: "https://localhost/"
});

@@ -12,0 +13,0 @@ it("loads and initializes", () => {

{
"name": "plex-oauth",
"version": "1.0.2",
"version": "1.1.2",
"description": "Small library to handle simple OAuth with Plex",

@@ -5,0 +5,0 @@ "repository": {

@@ -23,6 +23,7 @@ ![testing](https://github.com/Dmbob/plex-oauth/workflows/testing/badge.svg)

clientIdentifier: "<PROVIDE_UNIQUE_VALUE>", // This is a unique identifier used to identify your app with Plex.
product: "<NAME_OF_YOUR_APP>", // Name of your application
device: "<NAME_OF_YOUR_DEVICE>", // The type of device your application is running on
version: "1", // Version of your application
platform: "Web" // Optional - Platform your application runs on - Defaults to 'Web'
product: "<NAME_OF_YOUR_APP>", // Name of your application
device: "<NAME_OF_YOUR_DEVICE>", // The type of device your application is running on
version: "1", // Version of your application
forwardUrl: "https://localhost:3000", // Url to forward back to after signing in.
platform: "Web", // Optional - Platform your application runs on - Defaults to 'Web'
}

@@ -39,12 +40,10 @@

/*
* After requesting the hosted UI URL, you use it to open a page in the user's
* browser, so they can sign into Plex. While this is happening, you can start
* polling Plex for the auth token using the function below. This will all depend
* on how long it takes the user to put in their information and login, so you may
* need to adjust the request delay and request amount to what you think is enough
* time.
* You can now navigate the user's browser to the 'hostedUILink'. This will include the forward URL
* for your application, so when they have finished signing into Plex, they will be redirected back
* to the specified URL. From there, you just need to perform a query to check for the auth token.
* (See Below)
*/
// Check for the auth token every 2 seconds up to 10 times
plexOauth.checkForAuthToken(pinId, 2000, 10).then(authToken => {
// Check for the auth token, once returning to the application
plexOauth.checkForAuthToken(pinId).then(authToken => {
console.log(authToken); // Returns the auth token if set, otherwise returns null

@@ -51,0 +50,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc