@slipher/chartjs
Advanced tools
@@ -1,2 +0,2 @@ | ||
| import type { Plugin as ChartJSPlugin, Chart as ChartJS } from 'chart.js'; | ||
| import type { Chart as ChartJS, Plugin as ChartJSPlugin } from 'chart.js'; | ||
| export declare class BackgroundColourPlugin implements ChartJSPlugin { | ||
@@ -3,0 +3,0 @@ private readonly _width; |
@@ -0,3 +1,3 @@ | ||
| import { type Canvas } from '@napi-rs/canvas'; | ||
| import type { ChartConfiguration, Chart as ChartJS } from 'chart.js/auto'; | ||
| import { type Canvas } from '@napi-rs/canvas'; | ||
| import type { ChartJSNapiRSCanvasOptions } from './options'; | ||
@@ -12,3 +12,3 @@ export declare class NapiChartjsCanvas { | ||
| }; | ||
| renderToBuffer(configuration: ChartConfiguration): Buffer; | ||
| renderToBuffer(configuration: ChartConfiguration): Buffer<ArrayBufferLike>; | ||
| } |
+1
-1
@@ -5,4 +5,4 @@ "use strict"; | ||
| const canvas_1 = require("@napi-rs/canvas"); | ||
| const backgroundcolorplugin_1 = require("./backgroundcolorplugin"); | ||
| const freshRequire_1 = require("./freshRequire"); | ||
| const backgroundcolorplugin_1 = require("./backgroundcolorplugin"); | ||
| class NapiChartjsCanvas { | ||
@@ -9,0 +9,0 @@ options; |
+4
-4
@@ -1,2 +0,2 @@ | ||
| import type { Chart as ChartJS, ChartComponentLike } from 'chart.js'; | ||
| import type { ChartComponentLike, Chart as ChartJS } from 'chart.js'; | ||
| export type ChartCallback = (chartJS: typeof ChartJS) => void | Promise<void>; | ||
@@ -37,11 +37,11 @@ export interface ChartJSNapiRSCanvasOptions { | ||
| */ | ||
| readonly requireChartJSLegacy?: ReadonlyArray<string>; | ||
| readonly requireChartJSLegacy?: readonly string[]; | ||
| /** | ||
| * This should work for any plugin that expects a global Chart variable. | ||
| */ | ||
| readonly globalVariableLegacy?: ReadonlyArray<string>; | ||
| readonly globalVariableLegacy?: readonly string[]; | ||
| /** | ||
| * This will work with plugins that just return a plugin object and do no specific loading themselves. | ||
| */ | ||
| readonly requireLegacy?: ReadonlyArray<string>; | ||
| readonly requireLegacy?: readonly string[]; | ||
| }; |
+7
-6
| { | ||
| "name": "@slipher/chartjs", | ||
| "version": "0.0.1", | ||
| "version": "0.0.2", | ||
| "private": false, | ||
@@ -16,8 +16,8 @@ "license": "MIT", | ||
| "devDependencies": { | ||
| "@types/node": "^22.3.0", | ||
| "typescript": "^5.5.4" | ||
| "@types/node": "^22.10.2", | ||
| "typescript": "^5.7.2" | ||
| }, | ||
| "dependencies": { | ||
| "@napi-rs/canvas": "^0.1.54", | ||
| "chart.js": "^4.4.4" | ||
| "@napi-rs/canvas": "^0.1.65", | ||
| "chart.js": "^4.4.7" | ||
| }, | ||
@@ -28,4 +28,5 @@ "scripts": { | ||
| "lint": "biome lint --write ./src", | ||
| "format": "biome format --write ./src" | ||
| "format": "biome format --write ./src", | ||
| "checkb": "biome check --write --no-errors-on-unmatched ./src" | ||
| } | ||
| } |
| import type { HttpClient, Logger } from 'seyfert'; | ||
| import { type APIInteraction } from 'seyfert/lib/types'; | ||
| import type { HttpServerAdapter } from 'seyfert/lib/client/types'; | ||
| export declare class GenericAdapter implements HttpServerAdapter { | ||
| client: HttpClient; | ||
| publicKeyHex: Buffer; | ||
| applicationId: string; | ||
| debugger?: Logger; | ||
| logger: Logger; | ||
| constructor(client: HttpClient); | ||
| start(): Promise<void>; | ||
| protected verifySignature(req: Request): Promise<APIInteraction | undefined>; | ||
| fetch(req: Request): Promise<unknown>; | ||
| } |
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.GenericAdapter = void 0; | ||
| const types_1 = require("seyfert/lib/types"); | ||
| const tweetnacl_1 = __importDefault(require("tweetnacl")); | ||
| const common_1 = require("seyfert/lib/common"); | ||
| class GenericAdapter { | ||
| client; | ||
| publicKeyHex; | ||
| applicationId; | ||
| debugger; | ||
| logger; | ||
| constructor(client) { | ||
| this.client = client; | ||
| this.logger = client.logger; | ||
| } | ||
| async start() { | ||
| if (this.client.debugger) | ||
| this.debugger = this.client.debugger; | ||
| const { publicKey, applicationId } = await this.client.getRC(); | ||
| if (!publicKey) { | ||
| throw new Error('Expected a publicKey, check your config file'); | ||
| } | ||
| if (applicationId) { | ||
| this.applicationId = applicationId; | ||
| } | ||
| this.publicKeyHex = Buffer.from(publicKey, 'hex'); | ||
| this.logger.info('Running on <url>'); | ||
| } | ||
| async verifySignature(req) { | ||
| const timestamp = req.headers.get('x-signature-timestamp'); | ||
| const ed25519 = req.headers.get('x-signature-ed25519') ?? ''; | ||
| const body = (await req.json()); | ||
| if (tweetnacl_1.default.sign.detached.verify(Buffer.from(timestamp + JSON.stringify(body)), Buffer.from(ed25519, 'hex'), this.publicKeyHex)) { | ||
| return body; | ||
| } | ||
| return; | ||
| } | ||
| async fetch(req) { | ||
| const rawBody = await this.verifySignature(req); | ||
| if (!rawBody) { | ||
| this.debugger?.debug('Invalid request/No info, returning 418 status.'); | ||
| // I'm a teapot | ||
| return new Response('', { status: 418 }); | ||
| } | ||
| switch (rawBody.type) { | ||
| case types_1.InteractionType.Ping: | ||
| this.debugger?.debug('Ping interaction received, responding.'); | ||
| return Response.json({ type: types_1.InteractionResponseType.Pong }, { | ||
| headers: { | ||
| 'Content-Type': 'application/json', | ||
| }, | ||
| }); | ||
| default: | ||
| if ((0, common_1.isCloudfareWorker)()) { | ||
| // you can not do more net requests after responding. | ||
| // so we use discord api instead | ||
| return this.client.handleCommand | ||
| .interaction(rawBody, -1) | ||
| .then(() => new Response()) | ||
| .catch(() => new Response()); | ||
| } | ||
| return new Promise(async (r) => { | ||
| const { headers, response } = await this.client.onPacket(rawBody); | ||
| r(response instanceof FormData | ||
| ? new Response(response, { headers }) | ||
| : Response.json(response, { | ||
| headers, | ||
| })); | ||
| }); | ||
| } | ||
| } | ||
| } | ||
| exports.GenericAdapter = GenericAdapter; |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
0
-100%8086
-30.36%12
-14.29%188
-32.62%Updated
Updated