
Security News
Bun 1.2.19 Adds Isolated Installs for Better Monorepo Support
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
@ordercloud/catalyst
Advanced tools
Starter middleware, extensions, and tools for building APIs when working with OrderCloud.
Starter middleware, extensions, and tools for building APIs when working with OrderCloud.
npm i @ordercloud/catalyst
Protect your webhook API routes by blocking requests that are not from OrderCloud.
import { withOcWebhookAuth } from '@ordercloud/catalyst';
router.post('api/checkout/shippingRates',
// Verifies that the request header "x-oc-hash" is valid given the secret key.
withOcWebhookAuth(shippingRatesHandler, 'my-secret-hash-key')
);
router.post('api/webhooks/shippingRates',
// If a hashKey parameter is not included, it defaults to process.env.OC_WEBHOOK_HASH_KEY.
withOcWebhookAuth(shippingRatesHandler)
);
function shippingRatesHandler(req, res, next) { ... }
Protect your API routes by using OrderCloud's user authentication - require an OrderCloud token with correct permissions.
import { withOcUserAuth, FullDecodedToken } from '@ordercloud/catalyst';
router.post('api/checkout/payment',
// Verifies the request has an active OrderCloud bearer token with the "Shopper" role, the user type "Buyer"
// and an api client ID of "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
withOcUserAuth(createPaymentHandler, ["Shopper"], ["Buyer"], ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"])
)
// Permission parameters are optional. A token with any roles and user type can access this.
// However, process.env.OC_API_CLIENTS_WITH_ACCESS must be defined (comma-separated).
router.post('api/checkout/payment', withOcUserAuth(createPaymentHandler))
// Same as above except the "*" character gives access to any client ID.
// This can be a serious security hole, so only use if you understand the consequences.
router.post('api/checkout/payment', withOcUserAuth(createPaymentHandler, [], [], ["*"]))
function createPaymentHandler(req, res, next) {
// req.ocToken property has been added by withOcUserAuth.
var token: FullDecodedToken = req.ocToken;
...
}
Create custom errors that will result in JSON responses matching OrderCloud's format.
import { CatalystBaseError } from '@ordercloud/catalyst';
export class CardTypeNotAcceptedError extends CatalystBaseError {
constructor(type: string) {
super("CardTypeNotAccepted", `This merchant does not accept ${type} type credit cards`, 400)
}
}
...
if (!acceptedCardTypes.includes(type)) {
throw new CardTypeNotAcceptedError(type);
}
FAQs
Starter middleware, extensions, and tools for building APIs when working with OrderCloud.
The npm package @ordercloud/catalyst receives a total of 751 weekly downloads. As such, @ordercloud/catalyst popularity was classified as not popular.
We found that @ordercloud/catalyst demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 10 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
Security News
Popular npm packages like eslint-config-prettier were compromised after a phishing attack stole a maintainer’s token, spreading malicious updates.
Security News
/Research
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.