Socket
Socket
Sign inDemoInstall

octoflare

Package Overview
Dependencies
Maintainers
1
Versions
146
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

octoflare - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

dist/types/index.d.ts

2

dist/index.d.ts
export { octoflare } from './octoflare.js';
export type { OctoflareHandler } from './types/OctoflareHandler.js';
export type * from './types/index.js';

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

import { InternalEnv } from './types/InternalEnv.js';
import { OctoflareEnv } from './types/OctoflareEnv.js';
import { OctoflareHandler } from './types/OctoflareHandler.js';
export declare const octoflare: <Env extends InternalEnv>(handler: OctoflareHandler<Env>) => {
export declare const octoflare: <Env extends OctoflareEnv = OctoflareEnv>(handler: OctoflareHandler<Env>) => {
fetch(request: Request, env: Env): Promise<Response>;
};
import { attempt } from '@jill64/attempt';
import crypto from 'node:crypto';
import { App } from 'octokit';
import { verifyRequest } from './verifyRequest.js';
export const octoflare = (handler) => ({
async fetch(request, env) {
const { headers, method } = request;
if (method === 'GET' || method === 'HEAD') {
return new Response(null, {
status: 204
});
}
if (method !== 'POST') {
return new Response(null, {
status: 405,
headers: {
Allow: 'GET, HEAD, POST'
}
});
}
const body = await request.text();
const invalidResponse = verifyRequest({ body, request, env });
if (invalidResponse) {
return invalidResponse;
const signature = crypto
.createHmac('sha256', env.OCTOFLARE_WEBHOOK_SECRET)
.update(body)
.digest('hex');
if (`sha256=${signature}` !== headers.get('X-Hub-Signature-256')) {
return new Response(null, {
status: 403
});
}

@@ -11,0 +30,0 @@ const payload = JSON.parse(body);

import { WebhookEvent } from '@octokit/webhooks-types';
import { App } from 'octokit';
import { InternalEnv } from './InternalEnv.js';
export type OctoflareHandler<Env extends InternalEnv = InternalEnv> = (context: {
import { OctoflareEnv } from './OctoflareEnv.js';
export type OctoflareHandler<Env extends OctoflareEnv = OctoflareEnv> = (context: {
request: Request;

@@ -6,0 +6,0 @@ env: Env;

{
"name": "octoflare",
"version": "0.3.0",
"version": "0.3.1",
"description": "A framework for building GitHub Apps with Cloudflare Worker",

@@ -5,0 +5,0 @@ "type": "module",

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