New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@redwoodjs-stripe/api

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@redwoodjs-stripe/api - npm Package Compare versions

Comparing version 0.1.0-rc.14 to 0.1.0-rc.15

2

./dist/index.js

@@ -21,2 +21,3 @@ var __defProp = Object.defineProperty;

__export(src_exports, {
generateStripeMockEvent: () => import_lib.generateStripeMockEvent,
handleStripeWebhooks: () => import_lib.handleStripeWebhooks,

@@ -31,2 +32,3 @@ stripe: () => import_lib.stripe

0 && (module.exports = {
generateStripeMockEvent,
handleStripeWebhooks,

@@ -33,0 +35,0 @@ stripe,

@@ -21,2 +21,3 @@ var __defProp = Object.defineProperty;

__export(src_exports, {
generateStripeMockEvent: () => import_lib.generateStripeMockEvent,
handleStripeWebhooks: () => import_lib.handleStripeWebhooks,

@@ -31,2 +32,3 @@ stripe: () => import_lib.stripe

0 && (module.exports = {
generateStripeMockEvent,
handleStripeWebhooks,

@@ -33,0 +35,0 @@ stripe,

@@ -30,2 +30,3 @@ var __create = Object.create;

__export(lib_exports, {
generateStripeMockEvent: () => generateStripeMockEvent,
handleStripeWebhooks: () => handleStripeWebhooks,

@@ -36,2 +37,3 @@ lastEntry: () => lastEntry,

module.exports = __toCommonJS(lib_exports);
var import_api = require("@redwoodjs/testing/api");
var import_stripe = __toESM(require("stripe"));

@@ -54,3 +56,3 @@ const stripe = new import_stripe.default(process.env.STRIPE_SECRET_KEY, {

};
const handleStripeWebhooks = (event, context, webhooksObj, secure = true) => {
const handleStripeWebhooks = (event, context, webhooksObj = {}, secure = true) => {
if (secure) {

@@ -90,4 +92,27 @@ const endpointSecret = process.env.STRIPE_WEBHOOK_KEY;

};
const generateStripeMockEvent = () => {
const payload = JSON.stringify(
{
id: "evt_test_webhook",
object: "event"
},
null,
2
);
process.env.STRIPE_WEBHOOK_SK = "whsec_test_secret";
const header = stripe.webhooks.generateTestHeaderString({
payload,
secret: process.env.STRIPE_WEBHOOK_SK
});
const httpEvent = (0, import_api.mockHttpEvent)({
body: payload,
headers: {
"stripe-signature": header
}
});
return httpEvent;
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
generateStripeMockEvent,
handleStripeWebhooks,

@@ -94,0 +119,0 @@ lastEntry,

4

package.json
{
"name": "@redwoodjs-stripe/api",
"version": "0.1.0-rc.14",
"version": "0.1.0-rc.15",
"main": "./dist/index.js",

@@ -25,3 +25,3 @@ "files": [

"license": "MIT",
"gitHead": "b052b464ecc8fd7044b3bec6d1e112f703087e86",
"gitHead": "0b69891d17143d26361fd56f31d5744a942bceff",
"publishConfig": {

@@ -28,0 +28,0 @@ "access": "public"

export {
handleStripeWebhooks,
generateStripeMockEvent,
stripe

@@ -4,0 +5,0 @@ } from './lib'

@@ -0,1 +1,2 @@

import { mockHttpEvent } from '@redwoodjs/testing/api'

@@ -22,3 +23,3 @@ import Stripe from 'stripe'

export const handleStripeWebhooks = (event, context, webhooksObj, secure = true) => {
export const handleStripeWebhooks = (event, context, webhooksObj = {}, secure = true) => {
if (secure) {

@@ -35,3 +36,4 @@ const endpointSecret = process.env.STRIPE_WEBHOOK_KEY

// Find event type in webhookObject
if (typeof webhooksObj[stripeEvent.type] !== 'undefined') {
if (typeof webhooksObj[stripeEvent.type] !== 'undefined') {
// execute function for the event
webhooksObj[stripeEvent.type](stripeEvent, context)

@@ -62,2 +64,34 @@ }

}
}
// Generates a test Stripe mock event
export const generateStripeMockEvent = () => {
const payload = JSON.stringify(
{
id: 'evt_test_webhook',
object: 'event',
},
null,
2
)
process.env.STRIPE_WEBHOOK_SK = 'whsec_test_secret'
/**
* @see {@link https://github.com/stripe/stripe-node/blob/master/README.md#testing-webhook-signing}
*/
const header = stripe.webhooks.generateTestHeaderString({
payload,
secret: process.env.STRIPE_WEBHOOK_SK,
})
const httpEvent = mockHttpEvent({
body: payload,
headers: {
'stripe-signature': header,
},
})
return httpEvent
}
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