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
810
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-pr-97.11c4df4.0 to 3.0.0

2

dist/index.d.ts

@@ -34,3 +34,3 @@ import type { Server, ServerOptions } from './lib/structures/http/Server';

}
interface PieceContextExtras {
interface Container {
server: Server;

@@ -37,0 +37,0 @@ }

"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) {

@@ -1,3 +0,3 @@

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

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

*/
(data: LoginData): Awaited<T>;
(data: LoginData): Awaitable<T>;
}
//# sourceMappingURL=Auth.d.ts.map

@@ -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}`

@@ -172,7 +172,2 @@ /// <reference types="node" />

}
declare module '@sapphire/pieces' {
interface PieceContextExtras {
server: Server;
}
}
//# sourceMappingURL=Server.d.ts.map

@@ -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,

/// <reference types="node" />
import { Piece } from '@sapphire/pieces';
import type { Awaited } from '@sapphire/utilities';
import type { Awaitable } from '@sapphire/utilities';
import type { ApiRequest } from './api/ApiRequest';

@@ -15,3 +15,3 @@ import type { Route } from './Route';

*/
abstract run(request: ApiRequest): Awaited<unknown>;
abstract run(request: ApiRequest): Awaitable<unknown>;
/**

@@ -40,4 +40,4 @@ * Checks if a route accepts the media type from this parser.

*/
protected contentStream(request: ApiRequest): import("zlib").BrotliDecompress | ApiRequest | null;
protected contentStream(request: ApiRequest): ApiRequest | import("zlib").Gunzip | null;
}
//# sourceMappingURL=MediaParser.d.ts.map

@@ -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;

import { Piece, PieceContext, PieceOptions } from '@sapphire/pieces';
import type { Awaited } from '@sapphire/utilities';
import type { Awaitable } from '@sapphire/utilities';
import type { ApiRequest } from './api/ApiRequest';

@@ -28,3 +28,3 @@ import type { ApiResponse } from './api/ApiResponse';

*/
abstract run(request: ApiRequest, response: ApiResponse, route: Route | null): Awaited<unknown>;
abstract run(request: ApiRequest, response: ApiResponse, route: Route | null): Awaitable<unknown>;
}

@@ -31,0 +31,0 @@ /**

import { Piece, PieceContext, PieceOptions } from '@sapphire/pieces';
import type { Awaited } from '@sapphire/utilities';
import type { Awaitable } from '@sapphire/utilities';
import { Collection } from 'discord.js';

@@ -33,3 +33,3 @@ import { RouteData } from '../utils/RouteData';

*/
onLoad(): Awaited<unknown>;
onLoad(): Awaitable<unknown>;
/**

@@ -39,3 +39,3 @@ * Per-piece listener that is called when the piece is unloaded from the store.

*/
onUnload(): Awaited<unknown>;
onUnload(): Awaitable<unknown>;
}

@@ -42,0 +42,0 @@ export interface RouteOptions extends PieceOptions {

@@ -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-pr-97.11c4df4.0",
"version": "3.0.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": {

@@ -30,4 +31,3 @@ ".": {

"lint": "eslint src tests --ext ts --fix",
"build": "tsc -b src",
"postbuild": "run-p esm:**",
"build": "tsc -b src && yarn esm:register && yarn esm:default",
"esm:register": "gen-esm-wrapper dist/register.js dist/register.mjs",

@@ -40,6 +40,6 @@ "esm:default": "gen-esm-wrapper dist/index.js dist/index.mjs",

"@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"
},

@@ -57,4 +57,4 @@ "repository": {

"engines": {
"node": ">=14",
"npm": ">=6"
"node": ">=v14.18.0",
"npm": ">=7.24.2"
},

@@ -77,3 +77,3 @@ "keywords": [

},
"gitHead": "11c4df4ce62a35848da82592c9c13c81fb4f5215"
"gitHead": "e3d1ccc0ae912fbf13313c83bb322d613661e2ad"
}

@@ -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)

@@ -35,3 +34,2 @@ </div>

- [`@sapphire/framework`](https://www.npmjs.com/package/@sapphire/framework)
- [`@sapphire/pieces v1.x`](https://www.npmjs.com/package/@sapphire/pieces/v/1.2.5)
- [`discord.js`](https://www.npmjs.com/package/discord.js)

@@ -43,3 +41,3 @@ - [`discord-api-types`](https://www.npmjs.com/package/discord-api-types)

```sh
npm install @sapphire/plugin-api @sapphire/framework @sapphire/pieces@1 discord.js discord-api-types
npm install @sapphire/plugin-api @sapphire/framework discord.js discord-api-types
```

@@ -125,3 +123,3 @@

<td align="center"><a href="https://favware.tech/"><img src="https://avatars3.githubusercontent.com/u/4019718?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jeroen Claassens</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=Favna" title="Code">πŸ’»</a> <a href="#infra-Favna" title="Infrastructure (Hosting, Build-Tools, etc)">πŸš‡</a> <a href="#projectManagement-Favna" title="Project Management">πŸ“†</a></td>
<td align="center"><a href="https://quantumlytangled.com"><img src="https://avatars1.githubusercontent.com/u/7919610?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nejc Drobnic</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=QuantumlyTangled" title="Code">πŸ’»</a> <a href="https://github.com/sapphiredev/plugins/commits?author=QuantumlyTangled" title="Documentation">πŸ“–</a></td>
<td align="center"><a href="https://Quantumlyy.com"><img src="https://avatars1.githubusercontent.com/u/7919610?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nejc Drobnic</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=Quantumlyy" title="Code">πŸ’»</a> <a href="https://github.com/sapphiredev/plugins/commits?author=Quantumlyy" title="Documentation">πŸ“–</a></td>
<td align="center"><a href="https://github.com/kyranet"><img src="https://avatars0.githubusercontent.com/u/24852502?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Antonio RomΓ‘n</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=kyranet" title="Code">πŸ’»</a></td>

@@ -134,5 +132,9 @@ <td align="center"><a href="https://github.com/vladfrangu"><img src="https://avatars3.githubusercontent.com/u/17960496?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vlad Frangu</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/pulls?q=is%3Apr+reviewed-by%3Avladfrangu" title="Reviewed Pull Requests">πŸ‘€</a></td>

<tr>
<td align="center"><a href="https://github.com/Nytelife26"><img src="https://avatars1.githubusercontent.com/u/22531310?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tyler J Russell</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=Nytelife26" title="Code">πŸ’»</a></td>
<td align="center"><a href="https://github.com/Nytelife26"><img src="https://avatars1.githubusercontent.com/u/22531310?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tyler J Russell</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=Nytelife26" title="Code">πŸ’»</a> <a href="https://github.com/sapphiredev/plugins/commits?author=Nytelife26" title="Documentation">πŸ“–</a></td>
<td align="center"><a href="https://github.com/Stitch07"><img src="https://avatars.githubusercontent.com/u/29275227?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stitch07</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=Stitch07" title="Code">πŸ’»</a> <a href="https://github.com/sapphiredev/plugins/issues?q=author%3AStitch07" title="Bug reports">πŸ›</a></td>
<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>
<td align="center"><a href="https://github.com/noftaly"><img src="https://avatars.githubusercontent.com/u/34779161?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Elliot</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=noftaly" title="Code">πŸ’»</a></td>
<td align="center"><a href="https://github.com/Lioness100"><img src="https://avatars.githubusercontent.com/u/65814829?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Lioness100</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=Lioness100" title="Code">πŸ’»</a></td>
<td align="center"><a href="https://github.com/UndiedGamer"><img src="https://avatars.githubusercontent.com/u/84702365?v=4?s=100" width="100px;" alt=""/><br /><sub><b>UndiedGamer</b></sub></a><br /><a href="https://github.com/sapphiredev/plugins/commits?author=UndiedGamer" title="Code">πŸ’»</a></td>
</tr>

@@ -139,0 +141,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

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