Socket
Socket
Sign inDemoInstall

twitch-auth

Package Overview
Dependencies
Maintainers
2
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

twitch-auth - npm Package Compare versions

Comparing version 4.4.0-pre.1 to 4.4.0-pre.2

es/Errors/InvalidTokenTypeError.mjs

4

lib/AccessToken.d.ts

@@ -15,3 +15,3 @@ /** @private */

/** @private */
constructor(_data: AccessTokenData, obtainmentDate?: Date);
constructor(data: AccessTokenData, obtainmentDate?: Date);
/**

@@ -34,5 +34,5 @@ * The access token which is necessary for every request to the Twitch API.

/**
* The scope the access token is valid for, i.e. what this token enables you to do.
* The scope the access token is valid for, i.e. what the token enables you to do.
*/
get scope(): string[];
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AccessToken = void 0;
var tslib_1 = require("tslib");
var shared_utils_1 = require("@d-fischer/shared-utils");
var twitch_common_1 = require("twitch-common");
/**

@@ -9,5 +12,5 @@ * Represents the data of an OAuth access token returned by Twitch.

/** @private */
function AccessToken(_data, obtainmentDate) {
this._data = _data;
this._obtainmentDate = obtainmentDate || new Date();
function AccessToken(data, obtainmentDate) {
this._data = data;
this._obtainmentDate = obtainmentDate !== null && obtainmentDate !== void 0 ? obtainmentDate : new Date();
}

@@ -62,6 +65,7 @@ Object.defineProperty(AccessToken.prototype, "accessToken", {

/**
* The scope the access token is valid for, i.e. what this token enables you to do.
* The scope the access token is valid for, i.e. what the token enables you to do.
*/
get: function () {
return this._data.scope || [];
var _a;
return (_a = this._data.scope) !== null && _a !== void 0 ? _a : [];
},

@@ -71,4 +75,10 @@ enumerable: false,

});
tslib_1.__decorate([
shared_utils_1.Enumerable(false)
], AccessToken.prototype, "_data", void 0);
AccessToken = tslib_1.__decorate([
twitch_common_1.rtfm('twitch-auth', 'AccessToken')
], AccessToken);
return AccessToken;
}());
exports.AccessToken = AccessToken;

@@ -44,5 +44,5 @@ import type { AccessToken } from '../AccessToken';

*/
getAccessToken(scopes?: string | string[]): Promise<AccessToken | null>;
getAccessToken: (scopes?: string | string[]) => Promise<AccessToken | null>;
/** @private */
setAccessToken(token: AccessToken): void;
setAccessToken: (token: AccessToken) => void;
/**

@@ -55,3 +55,3 @@ * Requests that the provider fetches a new token from Twitch.

*/
refresh?(): Promise<AccessToken | null>;
refresh?: () => Promise<AccessToken | null>;
}

@@ -11,3 +11,3 @@ import type { AccessToken } from '../AccessToken';

/**
* The type of tokens this provider generates.
* The type of tokens the provider generates.
*

@@ -14,0 +14,0 @@ * This auth provider generates app tokens.

@@ -6,2 +6,3 @@ "use strict";

var shared_utils_1 = require("@d-fischer/shared-utils");
var twitch_common_1 = require("twitch-common");
var helpers_1 = require("../helpers");

@@ -20,3 +21,3 @@ /**

/**
* The type of tokens this provider generates.
* The type of tokens the provider generates.
*

@@ -91,5 +92,2 @@ * This auth provider generates app tokens.

shared_utils_1.Enumerable(false)
], ClientCredentialsAuthProvider.prototype, "_clientId", void 0);
tslib_1.__decorate([
shared_utils_1.Enumerable(false)
], ClientCredentialsAuthProvider.prototype, "_clientSecret", void 0);

@@ -99,4 +97,7 @@ tslib_1.__decorate([

], ClientCredentialsAuthProvider.prototype, "_token", void 0);
ClientCredentialsAuthProvider = tslib_1.__decorate([
twitch_common_1.rtfm('twitch-auth', 'ClientCredentialsAuthProvider', 'clientId')
], ClientCredentialsAuthProvider);
return ClientCredentialsAuthProvider;
}());
exports.ClientCredentialsAuthProvider = ClientCredentialsAuthProvider;

@@ -45,3 +45,3 @@ import type { AccessToken } from '../AccessToken';

/**
* The type of tokens this provider generates.
* The type of tokens the provider generates.
*

@@ -48,0 +48,0 @@ * It is the same as the underlying base auth provider's token type.

@@ -6,2 +6,3 @@ "use strict";

var shared_utils_1 = require("@d-fischer/shared-utils");
var twitch_common_1 = require("twitch-common");
var helpers_1 = require("../helpers");

@@ -29,3 +30,3 @@ /**

/**
* The type of tokens this provider generates.
* The type of tokens the provider generates.
*

@@ -149,4 +150,7 @@ * It is the same as the underlying base auth provider's token type.

], RefreshableAuthProvider.prototype, "_refreshToken", void 0);
RefreshableAuthProvider = tslib_1.__decorate([
twitch_common_1.rtfm('twitch-auth', 'RefreshableAuthProvider', 'clientId')
], RefreshableAuthProvider);
return RefreshableAuthProvider;
}());
exports.RefreshableAuthProvider = RefreshableAuthProvider;

@@ -25,3 +25,3 @@ import { AccessToken } from '../AccessToken';

* You need to obtain one using one of the [Twitch OAuth flows](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/).
* @param scopes The scopes this token has.
* @param scopes The scopes the supplied token has.
* @param tokenType The type of the supplied token.

@@ -28,0 +28,0 @@ */

@@ -6,2 +6,3 @@ "use strict";

var shared_utils_1 = require("@d-fischer/shared-utils");
var twitch_common_1 = require("twitch-common");
var AccessToken_1 = require("../AccessToken");

@@ -24,3 +25,3 @@ var helpers_1 = require("../helpers");

* You need to obtain one using one of the [Twitch OAuth flows](https://dev.twitch.tv/docs/authentication/getting-tokens-oauth/).
* @param scopes The scopes this token has.
* @param scopes The scopes the supplied token has.
* @param tokenType The type of the supplied token.

@@ -53,7 +54,8 @@ */

StaticAuthProvider.prototype.getAccessToken = function (scopes) {
var _a;
return tslib_1.__awaiter(this, void 0, void 0, function () {
var tokenInfo;
var _this = this;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:

@@ -67,5 +69,5 @@ if (!(scopes && scopes.length > 0)) return [3 /*break*/, 3];

case 1:
tokenInfo = _a.sent();
tokenInfo = _b.sent();
this._scopes = tokenInfo.scopes;
_a.label = 2;
_b.label = 2;
case 2:

@@ -78,4 +80,4 @@ if (typeof scopes === 'string') {

}
_a.label = 3;
case 3: return [2 /*return*/, this._accessToken || null];
_b.label = 3;
case 3: return [2 /*return*/, (_a = this._accessToken) !== null && _a !== void 0 ? _a : null];
}

@@ -104,3 +106,4 @@ });

get: function () {
return this._scopes || [];
var _a;
return (_a = this._scopes) !== null && _a !== void 0 ? _a : [];
},

@@ -116,4 +119,7 @@ enumerable: false,

], StaticAuthProvider.prototype, "_accessToken", void 0);
StaticAuthProvider = tslib_1.__decorate([
twitch_common_1.rtfm('twitch-auth', 'StaticAuthProvider', 'clientId')
], StaticAuthProvider);
return StaticAuthProvider;
}());
exports.StaticAuthProvider = StaticAuthProvider;

@@ -1,2 +0,2 @@

import { CustomError } from './CustomError';
import { CustomError } from 'twitch-common';
/**

@@ -3,0 +3,0 @@ * Thrown whenever an invalid token is supplied.

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

var tslib_1 = require("tslib");
var CustomError_1 = require("./CustomError");
var twitch_common_1 = require("twitch-common");
/**

@@ -17,3 +17,3 @@ * Thrown whenever an invalid token is supplied.

return InvalidTokenError;
}(CustomError_1.CustomError));
}(twitch_common_1.CustomError));
exports.InvalidTokenError = InvalidTokenError;

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

return [3 /*break*/, 12];
case 12: throw lastTokenError || new Error('Could not retrieve a valid token');
case 12: throw lastTokenError !== null && lastTokenError !== void 0 ? lastTokenError : new Error('Could not retrieve a valid token');
}

@@ -217,0 +217,0 @@ });

@@ -12,3 +12,4 @@ export { AccessToken } from './AccessToken';

export { InvalidTokenError } from './Errors/InvalidTokenError';
export { InvalidTokenTypeError } from './Errors/InvalidTokenTypeError';
export { getAppAccessToken, getUserAccessToken, refreshUserAccessToken } from './legacy';
export type { LegacyAuthCredentials } from './legacy';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.refreshUserAccessToken = exports.getUserAccessToken = exports.getAppAccessToken = exports.InvalidTokenError = exports.StaticAuthProvider = exports.RefreshableAuthProvider = exports.ClientCredentialsAuthProvider = exports.TokenInfo = exports.revokeToken = exports.refreshUserToken = exports.getValidTokenFromProvider = exports.getTokenInfo = exports.getAppToken = exports.exchangeCode = exports.AccessToken = void 0;
exports.refreshUserAccessToken = exports.getUserAccessToken = exports.getAppAccessToken = exports.InvalidTokenTypeError = exports.InvalidTokenError = exports.StaticAuthProvider = exports.RefreshableAuthProvider = exports.ClientCredentialsAuthProvider = exports.TokenInfo = exports.revokeToken = exports.refreshUserToken = exports.getValidTokenFromProvider = exports.getTokenInfo = exports.getAppToken = exports.exchangeCode = exports.AccessToken = void 0;
var AccessToken_1 = require("./AccessToken");

@@ -23,2 +23,4 @@ Object.defineProperty(exports, "AccessToken", { enumerable: true, get: function () { return AccessToken_1.AccessToken; } });

Object.defineProperty(exports, "InvalidTokenError", { enumerable: true, get: function () { return InvalidTokenError_1.InvalidTokenError; } });
var InvalidTokenTypeError_1 = require("./Errors/InvalidTokenTypeError");
Object.defineProperty(exports, "InvalidTokenTypeError", { enumerable: true, get: function () { return InvalidTokenTypeError_1.InvalidTokenTypeError; } });
// twitch-auth@^1 compat

@@ -25,0 +27,0 @@ var legacy_1 = require("./legacy");

@@ -1,2 +0,1 @@

/** @private */
export interface TokenInfoData {

@@ -13,6 +12,6 @@ client_id: string;

export declare class TokenInfo {
private readonly _obtainmentDate;
private readonly _data;
private readonly _obtainmentDate;
/** @private */
constructor(_data: TokenInfoData);
constructor(data: TokenInfoData);
/**

@@ -31,3 +30,3 @@ * The client ID.

/**
* The scopes for which this token is valid.
* The scopes for which the token is valid.
*/

@@ -34,0 +33,0 @@ get scopes(): string[];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TokenInfo = void 0;
var tslib_1 = require("tslib");
/** @private */
var shared_utils_1 = require("@d-fischer/shared-utils");
var twitch_common_1 = require("twitch-common");
/**

@@ -9,4 +13,4 @@ * Information about an access token.

/** @private */
function TokenInfo(_data) {
this._data = _data;
function TokenInfo(data) {
this._data = data;
this._obtainmentDate = new Date();

@@ -46,3 +50,3 @@ }

/**
* The scopes for which this token is valid.
* The scopes for which the token is valid.
*/

@@ -70,4 +74,10 @@ get: function () {

});
tslib_1.__decorate([
shared_utils_1.Enumerable(false)
], TokenInfo.prototype, "_data", void 0);
TokenInfo = tslib_1.__decorate([
twitch_common_1.rtfm('twitch-auth', 'TokenInfo', 'clientId')
], TokenInfo);
return TokenInfo;
}());
exports.TokenInfo = TokenInfo;
{
"name": "twitch-auth",
"version": "4.4.0-pre.1",
"version": "4.4.0-pre.2",
"description": "Authenticate with Twitch and stop caring about refreshing tokens.",

@@ -34,5 +34,6 @@ "keywords": [

"@d-fischer/logger": "^2.1.1",
"@d-fischer/shared-utils": "^2.4.1",
"@d-fischer/shared-utils": "^3.0.1",
"tslib": "^2.0.3",
"twitch-api-call": "^4.4.0-pre.1"
"twitch-api-call": "^4.4.0-pre.2",
"twitch-common": "^4.4.0-pre.2"
},

@@ -49,3 +50,3 @@ "files": [

},
"gitHead": "eb3b84e3ac4e7fc336c9e88dfed78ec5778c48e0"
"gitHead": "9fc5915b557ae6f0ce2ff3a797062016b576f99b"
}

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

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

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