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
793
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 2.1.4 to 2.1.5-next.29bb43f.0

2

dist/lib/structures/api/CookieStore.d.ts

@@ -14,3 +14,3 @@ import type { ApiRequest } from './ApiRequest';

/**
* Parses a host using the {@link https://github.com/lupomontero/psl psl} library to extract the domain.
* Parses a host using the {@linkplain https://github.com/lupomontero/psl psl} library to extract the domain.
* This is used for the domain of the cookie

@@ -17,0 +17,0 @@ * @param host The hot to parse

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

/**
* Parses a host using the {@link https://github.com/lupomontero/psl psl} library to extract the domain.
* Parses a host using the {@linkplain https://github.com/lupomontero/psl psl} library to extract the domain.
* This is used for the domain of the cookie

@@ -106,0 +106,0 @@ * @param host The hot to parse

@@ -26,3 +26,3 @@ import { Awaited } from '@sapphire/utilities';

/**
* The transformers used for [[Auth.fetchData]].
* The transformers used for {@link Auth.fetchData}.
* @since 1.4.0

@@ -115,3 +115,3 @@ */

/**
* The redirect uri. This will default to [[OAuth2BodyData.redirectUri]] if missing.
* The redirect uri. This will default to {@link OAuth2BodyData.redirectUri} if missing.
* @since 1.0.0

@@ -121,3 +121,3 @@ */

/**
* The login data transformers used for [[Auth.fetchData]].
* The login data transformers used for {@link Auth.fetchData}.
* @since 1.4.0

@@ -124,0 +124,0 @@ * @default []

"use strict";
var _secret;
var _Auth_secret;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -53,3 +53,3 @@ exports.Auth = void 0;

/**
* The transformers used for [[Auth.fetchData]].
* The transformers used for {@link Auth.fetchData}.
* @since 1.4.0

@@ -70,3 +70,3 @@ */

// eslint-disable-next-line @typescript-eslint/explicit-member-accessibility
_secret.set(this, void 0);
_Auth_secret.set(this, void 0);
this.id = options.id;

@@ -76,3 +76,3 @@ this.cookie = (_a = options.cookie) !== null && _a !== void 0 ? _a : 'SAPPHIRE_AUTH';

this.redirect = options.redirect;
tslib_1.__classPrivateFieldSet(this, _secret, options.secret);
tslib_1.__classPrivateFieldSet(this, _Auth_secret, options.secret, "f");
this.transformers = (_c = options.transformers) !== null && _c !== void 0 ? _c : [];

@@ -86,3 +86,3 @@ this.domainOverwrite = (_d = options.domainOverwrite) !== null && _d !== void 0 ? _d : null;

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

@@ -97,3 +97,3 @@ /**

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

@@ -109,3 +109,3 @@ }

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

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

exports.Auth = Auth;
_secret = new WeakMap();
_Auth_secret = new WeakMap();
//# sourceMappingURL=Auth.js.map

@@ -147,3 +147,3 @@ /// <reference types="node" />

/**
* The [[ServerOptions]] without [[ServerOptions.auth]].
* The {@link ServerOptions} without {@link ServerOptions.auth}.
* @since 1.0.0

@@ -150,0 +150,0 @@ */

{
"name": "@sapphire/plugin-api",
"version": "2.1.4",
"version": "2.1.5-next.29bb43f.0",
"description": "Plugin for @sapphire/framework to expose a REST API",

@@ -20,2 +20,7 @@ "author": "@sapphire",

},
"sideEffects": [
"./dist/register.js",
"./register.js",
"./register.mjs"
],
"homepage": "https://github.com/sapphiredev/plugins/tree/main/packages/api",

@@ -32,26 +37,9 @@ "scripts": {

"dependencies": {
"@types/node-fetch": "^2.5.10",
"@types/psl": "^1.1.0",
"@types/ws": "latest",
"node-fetch": "^2.6.1",
"psl": "^1.8.0",
"tslib": "^2.2.0"
"tslib": "^2.3.0"
},
"peerDependencies": {
"@sapphire/framework": "^1.x",
"@sapphire/pieces": "1.x",
"@types/node-fetch": "^2.x",
"@types/ws": "latest",
"discord-api-types": "^0.18.x",
"discord.js": "12.x"
},
"peerDependenciesMeta": {
"@types/ws": {
"optional": true
},
"@types/node-fetch": {
"optional": true
},
"discord-api-types": {
"optional": true
}
},
"repository": {

@@ -87,3 +75,3 @@ "type": "git",

},
"gitHead": "41f78721aaaeca636969c4270b1db12cc59d0cbb"
"gitHead": "29bb43fda77f722c3481380a5dafe9288fd204cc"
}

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

T.B.D.
This plugin provides an API endpoint for your bot that can be called from external services. A good exemplary use case for this is once your bot grows to have enough configuration options that you want to offer a website to your end-users to change those settings, and your website needs to interface with the bot for this to work.

@@ -28,7 +28,17 @@ ## Features

- Includes ESM ready entrypoint
- Premade OAuth 2.0 endpoints
## Installation
`@sapphire/plugin-api` depends on the following packages. Be sure to install these along with this package!
- [`@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)
- [`discord-api-types`](https://www.npmjs.com/package/discord-api-types)
You can use the following command to install this package, or replace `npm install` with your package manager of choice.
```sh
yarn add @sapphire/plugin-api
npm install @sapphire/plugin-api @sapphire/framework @sapphire/pieces@1 discord.js discord-api-types
```

@@ -40,4 +50,49 @@

T.B.D.
Start by importing the registration file in your project to use the plugin:
**JavaScript**
```js
require('@sapphire/plugin-api/register');
```
**TypeScript**
```ts
import '@sapphire/plugin-api/register';
```
Then, you can use the following configuration options in your SapphireClient extension class or initializer. This will either be located in your `new SapphireClient` constructor call, or `super` in your constructor method if you use an extension class.
```js
{
auth: {
// The application/client ID of your bot.
// You can find this at https://discord.com/developers/applications
id: '',
// The client secret of your bot.
// You can find this at https://discord.com/developers/applications
secret: '',
// The name of the authentication cookie.
cookie: 'SAPPHIRE_AUTH',
// The URL that users should be redirected to after a successful authentication
redirect: '',
// The scopes that should be given to the authentication.
scopes: ['identify'],
// Transformers to transform the raw data from Discord to a different structure.
transformers: []
},
// The prefix for all routes, e.g. / or v1/.
prefix: '',
// The origin header to be set on every request at 'Access-Control-Allow-Origin.
origin: '*',
// Any options passed to the NodeJS "net" internal server.listen function
// See https://nodejs.org/api/net.html#net_server_listen_options_callback
listenOptions: {
// The port the API will listen on.
port: 4000
}
}
```
## API Documentation

@@ -80,2 +135,3 @@

<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>
</tr>

@@ -82,0 +138,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

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