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

@sapphire/plugin-api

Package Overview
Dependencies
Maintainers
3
Versions
798
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sapphire/plugin-api - npm Package Compare versions

Comparing version 3.0.0-next.5e97bc7.0 to 3.0.0-next.658ce91.0

30

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./lib/structures/api/ApiRequest"), exports);
tslib_1.__exportStar(require("./lib/structures/api/ApiResponse"), exports);
tslib_1.__exportStar(require("./lib/structures/api/CookieStore"), exports);
tslib_1.__exportStar(require("./lib/structures/http/Auth"), exports);
tslib_1.__exportStar(require("./lib/structures/http/HttpCodes"), exports);
tslib_1.__exportStar(require("./lib/structures/http/HttpMethods"), exports);
tslib_1.__exportStar(require("./lib/structures/http/Server"), exports);
tslib_1.__exportStar(require("./lib/structures/MediaParser"), exports);
tslib_1.__exportStar(require("./lib/structures/MediaParserStore"), exports);
tslib_1.__exportStar(require("./lib/structures/Middleware"), exports);
tslib_1.__exportStar(require("./lib/structures/MiddlewareStore"), exports);
tslib_1.__exportStar(require("./lib/structures/Route"), exports);
tslib_1.__exportStar(require("./lib/structures/RouteStore"), exports);
tslib_1.__exportStar(require("./lib/utils/MimeTypes"), exports);
tslib_1.__exportStar(require("./lib/utils/RouteData"), exports);
(0, tslib_1.__exportStar)(require("./lib/structures/api/ApiRequest"), exports);
(0, tslib_1.__exportStar)(require("./lib/structures/api/ApiResponse"), exports);
(0, tslib_1.__exportStar)(require("./lib/structures/api/CookieStore"), exports);
(0, tslib_1.__exportStar)(require("./lib/structures/http/Auth"), exports);
(0, tslib_1.__exportStar)(require("./lib/structures/http/HttpCodes"), exports);
(0, tslib_1.__exportStar)(require("./lib/structures/http/HttpMethods"), exports);
(0, tslib_1.__exportStar)(require("./lib/structures/http/Server"), exports);
(0, tslib_1.__exportStar)(require("./lib/structures/MediaParser"), exports);
(0, tslib_1.__exportStar)(require("./lib/structures/MediaParserStore"), exports);
(0, tslib_1.__exportStar)(require("./lib/structures/Middleware"), exports);
(0, tslib_1.__exportStar)(require("./lib/structures/MiddlewareStore"), exports);
(0, tslib_1.__exportStar)(require("./lib/structures/Route"), exports);
(0, tslib_1.__exportStar)(require("./lib/structures/RouteStore"), exports);
(0, tslib_1.__exportStar)(require("./lib/utils/MimeTypes"), exports);
(0, tslib_1.__exportStar)(require("./lib/utils/RouteData"), exports);
//# sourceMappingURL=index.js.map

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

const tslib_1 = require("tslib");
const psl_1 = tslib_1.__importDefault(require("psl"));
const psl_1 = (0, tslib_1.__importDefault)(require("psl"));
class CookieStore extends Map {

@@ -10,0 +10,0 @@ constructor(request, response, secure, domainOverwrite) {

import { Awaited } from '@sapphire/utilities';
import type { RESTGetAPICurrentUserConnectionsResult, RESTGetAPICurrentUserGuildsResult, RESTGetAPICurrentUserResult, Snowflake } from 'discord-api-types/v8';
import { RESTGetAPICurrentUserConnectionsResult, RESTGetAPICurrentUserGuildsResult, RESTGetAPICurrentUserResult, Snowflake } from 'discord-api-types/v9';
export declare class Auth {

@@ -4,0 +4,0 @@ #private;

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

const crypto_1 = require("crypto");
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
const v9_1 = require("discord-api-types/v9");
const node_fetch_1 = (0, tslib_1.__importDefault)(require("node-fetch"));
class Auth {

@@ -74,3 +75,3 @@ constructor(options) {

this.redirect = options.redirect;
tslib_1.__classPrivateFieldSet(this, _Auth_secret, options.secret, "f");
(0, tslib_1.__classPrivateFieldSet)(this, _Auth_secret, options.secret, "f");
this.transformers = options.transformers ?? [];

@@ -84,3 +85,3 @@ this.domainOverwrite = options.domainOverwrite ?? null;

get secret() {
return tslib_1.__classPrivateFieldGet(this, _Auth_secret, "f");
return (0, tslib_1.__classPrivateFieldGet)(this, _Auth_secret, "f");
}

@@ -94,4 +95,4 @@ /**

encrypt(data) {
const iv = crypto_1.randomBytes(16);
const cipher = crypto_1.createCipheriv('aes-256-cbc', tslib_1.__classPrivateFieldGet(this, _Auth_secret, "f"), iv);
const iv = (0, crypto_1.randomBytes)(16);
const cipher = (0, crypto_1.createCipheriv)('aes-256-cbc', (0, tslib_1.__classPrivateFieldGet)(this, _Auth_secret, "f"), iv);
return `${cipher.update(JSON.stringify(data), 'utf8', 'base64') + cipher.final('base64')}.${iv.toString('base64')}`;

@@ -107,3 +108,3 @@ }

const [data, iv] = token.split('.');
const decipher = crypto_1.createDecipheriv('aes-256-cbc', tslib_1.__classPrivateFieldGet(this, _Auth_secret, "f"), Buffer.from(iv, 'base64'));
const decipher = (0, crypto_1.createDecipheriv)('aes-256-cbc', (0, tslib_1.__classPrivateFieldGet)(this, _Auth_secret, "f"), Buffer.from(iv, 'base64'));
try {

@@ -126,5 +127,5 @@ const parsed = JSON.parse(decipher.update(data, 'base64', 'utf8') + decipher.final('utf8'));

const [user, guilds, connections] = await Promise.all([
this.fetchInformation('identify', token, 'https://discord.com/api/v8/users/@me'),
this.fetchInformation('guilds', token, 'https://discord.com/api/v8/users/@me/guilds'),
this.fetchInformation('connections', token, 'https://discord.com/api/v8/users/@me/connections')
this.fetchInformation('identify', token, `${v9_1.RouteBases.api}${v9_1.Routes.user()}`),
this.fetchInformation('guilds', token, `${v9_1.RouteBases.api}${v9_1.Routes.userGuilds()}`),
this.fetchInformation('connections', token, `${v9_1.RouteBases.api}${v9_1.Routes.userConnections()}`)
]);

@@ -135,3 +136,3 @@ // Transform the information:

const result = transformer(data);
if (utilities_1.isThenable(result))
if ((0, utilities_1.isThenable)(result))
data = await result;

@@ -146,3 +147,3 @@ else

return undefined;
const result = await node_fetch_1.default(url, {
const result = await (0, node_fetch_1.default)(url, {
headers: {

@@ -149,0 +150,0 @@ authorization: `Bearer ${token}`

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

this.options = options;
this.server = http_1.createServer({
this.server = (0, http_1.createServer)({
// eslint-disable-next-line @typescript-eslint/naming-convention

@@ -99,0 +99,0 @@ IncomingMessage: ApiRequest_1.ApiRequest,

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

case 'deflate': {
const stream = zlib_1.createInflate();
const stream = (0, zlib_1.createInflate)();
request.pipe(stream);

@@ -70,3 +70,3 @@ return stream;

case 'gzip': {
const stream = zlib_1.createGunzip();
const stream = (0, zlib_1.createGunzip)();
request.pipe(stream);

@@ -79,3 +79,3 @@ return stream;

case 'br': {
const stream = zlib_1.createBrotliDecompress();
const stream = (0, zlib_1.createBrotliDecompress)();
request.pipe(stream);

@@ -82,0 +82,0 @@ return stream;

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

}
export interface ParsedPart {
value: string;
type: TypeState;
}
//# sourceMappingURL=RouteData.d.ts.map

@@ -21,6 +21,6 @@ "use strict";

.register(this.server.middlewares);
this.stores.get('listeners').registerPath(path_1.join(__dirname, 'listeners'));
this.server.routes.registerPath(path_1.join(__dirname, 'routes'));
this.server.middlewares.registerPath(path_1.join(__dirname, 'middlewares'));
this.server.mediaParsers.registerPath(path_1.join(__dirname, 'mediaParsers'));
this.stores.get('listeners').registerPath((0, path_1.join)(__dirname, 'listeners'));
this.server.routes.registerPath((0, path_1.join)(__dirname, 'routes'));
this.server.middlewares.registerPath((0, path_1.join)(__dirname, 'middlewares'));
this.server.mediaParsers.registerPath((0, path_1.join)(__dirname, 'mediaParsers'));
}

@@ -27,0 +27,0 @@ /**

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

const tslib_1 = require("tslib");
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
const v9_1 = require("discord-api-types/v9");
const node_fetch_1 = (0, tslib_1.__importDefault)(require("node-fetch"));
const querystring_1 = require("querystring");

@@ -59,5 +60,5 @@ require("../../lib/structures/http/HttpCodes");

};
const result = await node_fetch_1.default('https://discord.com/api/v8/oauth2/token', {
const result = await (0, node_fetch_1.default)(v9_1.OAuth2Routes.tokenURL, {
method: 'POST',
body: querystring_1.stringify(data),
body: (0, querystring_1.stringify)(data),
headers: {

@@ -64,0 +65,0 @@ 'content-type': 'application/x-www-form-urlencoded'

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

const tslib_1 = require("tslib");
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
const v9_1 = require("discord-api-types/v9");
const node_fetch_1 = (0, tslib_1.__importDefault)(require("node-fetch"));
const querystring_1 = require("querystring");

@@ -12,3 +13,3 @@ const util_1 = require("util");

const Route_1 = require("../../lib/structures/Route");
const sleep = util_1.promisify(setTimeout);
const sleep = (0, util_1.promisify)(setTimeout);
class PluginRoute extends Route_1.Route {

@@ -74,5 +75,5 @@ constructor(context) {

// The content of the response body is ignored by the client as all necessary information is conveyed in the response code.
const result = await node_fetch_1.default('https://discord.com/api/v8/oauth2/token/revoke', {
const result = await (0, node_fetch_1.default)(v9_1.OAuth2Routes.tokenRevocationURL, {
method: 'POST',
body: querystring_1.stringify({
body: (0, querystring_1.stringify)({
token,

@@ -79,0 +80,0 @@ /* eslint-disable @typescript-eslint/naming-convention */

{
"name": "@sapphire/plugin-api",
"version": "3.0.0-next.5e97bc7.0",
"version": "3.0.0-next.658ce91.0",
"description": "Plugin for @sapphire/framework to expose a REST API",

@@ -10,2 +10,3 @@ "author": "@sapphire",

"types": "dist/index.d.ts",
"typedocMain": "src/index.ts",
"exports": {

@@ -39,6 +40,6 @@ ".": {

"@types/psl": "^1.1.0",
"@types/ws": "7.4.7",
"node-fetch": "^2.6.1",
"@types/ws": "8.2.0",
"node-fetch": "^2.6.5",
"psl": "^1.8.0",
"tslib": "^2.3.0"
"tslib": "^2.3.1"
},

@@ -75,3 +76,3 @@ "repository": {

},
"gitHead": "5e97bc7ef6809edd5f7bb76018b0b4d209589a54"
"gitHead": "658ce917d5f402c47ee57e14561bea48fb417dba"
}

@@ -13,3 +13,2 @@ <div align="center">

[![npm](https://img.shields.io/npm/v/@sapphire/plugin-api?color=crimson&logo=npm&style=flat-square)](https://www.npmjs.com/package/@sapphire/plugin-api)
[![Depfu](https://badges.depfu.com/badges/11bbf7392987e6fd51fc6559e1d42dfc/count.svg)](https://depfu.com/github/sapphiredev/plugins?project_id=15201)

@@ -133,2 +132,3 @@ </div>

<td align="center"><a href="https://github.com/PlatinBae"><img src="https://avatars.githubusercontent.com/u/50950966?v=4?s=100" width="100px;" alt=""/><br /><sub><b>PlatinBae</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=PlatinBae" title="Documentation">πŸ“–</a></td>
<td align="center"><a href="https://kaname.netlify.app"><img src="https://avatars.githubusercontent.com/u/56084970?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Kaname</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=kaname-png" title="Code">πŸ’»</a> <a href="https://github.com/sapphiredev/plugins/commits?author=kaname-png" title="Documentation">πŸ“–</a></td>
</tr>

@@ -135,0 +135,0 @@ </table>

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

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