Socket
Socket
Sign inDemoInstall

@twurple/api-call

Package Overview
Dependencies
Maintainers
2
Versions
146
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@twurple/api-call - npm Package Compare versions

Comparing version 5.0.0-pre.5 to 5.0.0-pre.6

13

lib/apiCall.js

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

const url_1 = require("./helpers/url");
const TwitchApiCallOptions_1 = require("./TwitchApiCallOptions");
/**

@@ -21,7 +20,7 @@ * Makes a call to the Twitch API using the given credentials, returning the raw Response object.

var _a;
const type = options.type === undefined ? TwitchApiCallOptions_1.TwitchApiCallType.Kraken : options.type;
const type = options.type === undefined ? 'kraken' : options.type;
const url = url_1.getTwitchApiUrl(options.url, type);
const params = qs_1.stringify(options.query, { arrayFormat: 'repeat' });
const headers = new cross_fetch_1.Headers({
Accept: type === TwitchApiCallOptions_1.TwitchApiCallType.Kraken ? 'application/vnd.twitchtv.v5+json' : 'application/json'
Accept: type === 'kraken' ? 'application/vnd.twitchtv.v5+json' : 'application/json'
});

@@ -33,7 +32,7 @@ let body = undefined;

}
if (clientId && type !== TwitchApiCallOptions_1.TwitchApiCallType.Auth) {
if (clientId && type !== 'auth') {
headers.append('Client-ID', clientId);
}
if (accessToken) {
headers.append('Authorization', `${type === TwitchApiCallOptions_1.TwitchApiCallType.Helix ? 'Bearer' : 'OAuth'} ${accessToken}`);
headers.append('Authorization', `${type === 'helix' ? 'Bearer' : 'OAuth'} ${accessToken}`);
}

@@ -46,3 +45,3 @@ const requestOptions = {

};
return cross_fetch_1.default(params ? `${url}?${params}` : url, requestOptions);
return await cross_fetch_1.default(params ? `${url}?${params}` : url, requestOptions);
}

@@ -63,4 +62,4 @@ exports.callTwitchApiRaw = callTwitchApiRaw;

const response = await callTwitchApiRaw(options, clientId, accessToken, fetchOptions);
return transform_1.transformTwitchApiResponse(response);
return await transform_1.transformTwitchApiResponse(response);
}
exports.callTwitchApi = callTwitchApi;

@@ -1,4 +0,4 @@

import { TwitchApiCallType } from '../TwitchApiCallOptions';
import type { TwitchApiCallType } from '../TwitchApiCallOptions';
/** @private */
export declare function getTwitchApiUrl(url: string, type: TwitchApiCallType): string;
//# sourceMappingURL=url.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTwitchApiUrl = void 0;
const TwitchApiCallOptions_1 = require("../TwitchApiCallOptions");
/** @private */
function getTwitchApiUrl(url, type) {
switch (type) {
case TwitchApiCallOptions_1.TwitchApiCallType.Kraken:
case TwitchApiCallOptions_1.TwitchApiCallType.Helix:
const typeName = type === TwitchApiCallOptions_1.TwitchApiCallType.Kraken ? 'kraken' : 'helix';
case 'kraken':
case 'helix':
const typeName = type === 'kraken' ? 'kraken' : 'helix';
return `https://api.twitch.tv/${typeName}/${url.replace(/^\//, '')}`;
case TwitchApiCallOptions_1.TwitchApiCallType.Auth:
case 'auth':
return `https://id.twitch.tv/oauth2/${url.replace(/^\//, '')}`;
case TwitchApiCallOptions_1.TwitchApiCallType.Custom:
case 'custom':
return url;

@@ -16,0 +15,0 @@ default:

export { callTwitchApi, callTwitchApiRaw } from './apiCall';
export { TwitchApiCallType } from './TwitchApiCallOptions';
export type { TwitchApiCallFetchOptions, TwitchApiCallOptions } from './TwitchApiCallOptions';
export type { TwitchApiCallFetchOptions, TwitchApiCallOptions, TwitchApiCallType } from './TwitchApiCallOptions';
export { transformTwitchApiResponse } from './helpers/transform';
export { HttpStatusCodeError } from './errors/HttpStatusCodeError';
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpStatusCodeError = exports.transformTwitchApiResponse = exports.TwitchApiCallType = exports.callTwitchApiRaw = exports.callTwitchApi = void 0;
exports.HttpStatusCodeError = exports.transformTwitchApiResponse = exports.callTwitchApiRaw = exports.callTwitchApi = void 0;
var apiCall_1 = require("./apiCall");
Object.defineProperty(exports, "callTwitchApi", { enumerable: true, get: function () { return apiCall_1.callTwitchApi; } });
Object.defineProperty(exports, "callTwitchApiRaw", { enumerable: true, get: function () { return apiCall_1.callTwitchApiRaw; } });
var TwitchApiCallOptions_1 = require("./TwitchApiCallOptions");
Object.defineProperty(exports, "TwitchApiCallType", { enumerable: true, get: function () { return TwitchApiCallOptions_1.TwitchApiCallType; } });
var transform_1 = require("./helpers/transform");

@@ -10,0 +8,0 @@ Object.defineProperty(exports, "transformTwitchApiResponse", { enumerable: true, get: function () { return transform_1.transformTwitchApiResponse; } });

@@ -6,20 +6,3 @@ /// <reference lib="dom" />

*/
export declare enum TwitchApiCallType {
/**
* Call a Kraken API endpoint.
*/
Kraken = 0,
/**
* Call a Helix API endpoint.
*/
Helix = 1,
/**
* Call an authentication endpoint.
*/
Auth = 2,
/**
* Call a custom (potentially unsupported) endpoint.
*/
Custom = 3
}
export declare type TwitchApiCallType = 'kraken' | 'helix' | 'auth' | 'custom';
/**

@@ -26,0 +9,0 @@ * Configuration for a single API call.

"use strict";
/// <reference lib="dom" />
Object.defineProperty(exports, "__esModule", { value: true });
exports.TwitchApiCallType = void 0;
var TwitchApiCallType;
(function (TwitchApiCallType) {
/**
* Call a Kraken API endpoint.
*/
TwitchApiCallType[TwitchApiCallType["Kraken"] = 0] = "Kraken";
/**
* Call a Helix API endpoint.
*/
TwitchApiCallType[TwitchApiCallType["Helix"] = 1] = "Helix";
/**
* Call an authentication endpoint.
*/
TwitchApiCallType[TwitchApiCallType["Auth"] = 2] = "Auth";
/**
* Call a custom (potentially unsupported) endpoint.
*/
TwitchApiCallType[TwitchApiCallType["Custom"] = 3] = "Custom";
})(TwitchApiCallType || (TwitchApiCallType = {}));
exports.TwitchApiCallType = TwitchApiCallType;
{
"name": "@twurple/api-call",
"version": "5.0.0-pre.5",
"version": "5.0.0-pre.6",
"publishConfig": {

@@ -35,3 +35,3 @@ "access": "public"

"@d-fischer/qs": "^7.0.2",
"@twurple/common": "^5.0.0-pre.5",
"@twurple/common": "^5.0.0-pre.6",
"@types/node-fetch": "^2.5.7",

@@ -52,3 +52,3 @@ "node-fetch": "^2.6.1",

},
"gitHead": "6426110a30531a5b3aaff025d7b4babeec3790de"
"gitHead": "ce8b79e0eb955f087a58cb92269de8e0a1f42373"
}

@@ -0,1 +1,5 @@

# ⚠ WARNING
This is a future version still in development. For a stable version, check out [the `twitch-api-call` package](https://www.npmjs.com/package/twitch-api-call).
# Twurple - API call

@@ -2,0 +6,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

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