diff --git a/config.yaml b/config.yaml index ffbc5bb6..7aff2c95 100644 --- a/config.yaml +++ b/config.yaml @@ -5,7 +5,7 @@ files: destinationFilename: package.json npmName: plexjs npmRepository: lukehagar -npmVersion: 0.0.19 +npmVersion: 0.0.20 useSingleRequestParameter: true sortParamsByRequiredFlag: true gitUserID: lukehagar diff --git a/plexjs/README.md b/plexjs/README.md index 445582a5..5bd10920 100644 --- a/plexjs/README.md +++ b/plexjs/README.md @@ -1,4 +1,4 @@ -## plexjs@0.0.19 +## plexjs@0.0.20 This generator creates TypeScript/JavaScript client that utilizes [axios](https://github.com/axios/axios). The generated Node module can be used in the following environments: @@ -36,7 +36,7 @@ navigate to the folder of your consuming project and run one of the following co _published:_ ``` -npm install plexjs@0.0.19 --save +npm install plexjs@0.0.20 --save ``` _unPublished (not recommended):_ diff --git a/plexjs/configuration.ts b/plexjs/configuration.ts index 5e8fb05c..9b501b22 100644 --- a/plexjs/configuration.ts +++ b/plexjs/configuration.ts @@ -15,13 +15,82 @@ import { IAxiosRetryConfig } from "axios-retry"; export interface ConfigurationParameters { - - apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); + plexToken?: string; + clientIdentifier?: string; + device?: string; + deviceName?: string; + platform?: string; + platformVersion?: string; + product?: string; + version?: string; basePath?: string; - } export class Configuration { + /** + * Plex Media Server or Plex.TV Authentication token + * + * @type {string} + * @memberof Configuration + */ + plexToken?: string; + + /** + * UUID, serial number, or other number unique per device + * + * @type {string} + * @memberof Configuration + */ + clientIdentifier?: string; + + /** + * Device name and model number, eg iPhone3,2, Motorola XOOMâ„¢, LG5200TV + * + * @type {string} + * @memberof Configuration + */ + device?: string; + + /** + * Customized Device Name + * + * @type {string} + * @memberof Configuration + */ + deviceName?: string; + + /** + * Platform name, eg iOS, MacOSX, Android, LG, etc + * + * @type {string} + * @memberof Configuration + */ + platform?: string; + + /** + * Operating system version, eg 4.3.1, 10.6.7, 3.2 + * + * @type {string} + * @memberof Configuration + */ + platformVersion?: string; + + /** + * Plex application name, eg Laika, Plex Media Server, Media Link + * + * @type {string} + * @memberof Configuration + */ + product?: string; + + /** + * Plex application version number + * + * @type {string} + * @memberof Configuration + */ + version?: string; + /** * parameter for apiKey security * @param name security name @@ -63,10 +132,42 @@ export class Configuration { retriesConfig?: IAxiosRetryConfig constructor(param: ConfigurationParameters = {}) { + this.plexToken = param.plexToken; + this.clientIdentifier = param.clientIdentifier || "Plexjs"; + this.device = param.device || "Unspecified"; + this.deviceName = param.deviceName || "Unspecified"; + this.platform = param.platform || "Plexjs"; + this.platformVersion = param.platformVersion || process.env.npm_package_version; + this.product = param.product || "Plexjs"; + this.version = param.version || process.env.npm_package_version; - this.apiKey = param.apiKey; + this.apiKey = (header: string) => { + switch (header) { + case "X-Plex-Token": + return this.plexToken + case "X-Plex-Client-Identifier": + return this.clientIdentifier + case "X-Plex-Device-Name": + return this.deviceName + case "X-Plex-Device": + return this.device + case "X-Plex-Platform-Version": + return this.platformVersion + case "X-Plex-Platform": + return this.platform + case "X-Plex-Product": + return this.product + case "X-Plex-Version": + return this.version + default: + return ""; + } + } this.basePath = param.basePath; + } + public setAuthToken(token: string) { + this.plexToken = token } /** diff --git a/plexjs/package-lock.json b/plexjs/package-lock.json index 7206976c..a144d6f3 100644 --- a/plexjs/package-lock.json +++ b/plexjs/package-lock.json @@ -1,12 +1,12 @@ { "name": "@lukehagar/plexjs", - "version": "0.0.19", + "version": "0.0.20", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@lukehagar/plexjs", - "version": "0.0.19", + "version": "0.0.20", "license": "MIT", "dependencies": { "axios": "^0.26.1", diff --git a/plexjs/package.json b/plexjs/package.json index e5eae637..9bbb2781 100644 --- a/plexjs/package.json +++ b/plexjs/package.json @@ -1,6 +1,6 @@ { "name": "@lukehagar/plexjs", - "version": "0.0.19", + "version": "0.0.20", "description": "Community Made Plex JS/TS Module", "author": "Luke Hagar", "repository": {