ondc-auth-middleware-nodejs
v1.0.2
Published
A crypto middleware package offering features for signature and verification
Downloads
31
Maintainers
Readme
A signing and verification utility that is necessary for creation and verification of authentication signature between network participants of ONDC.
Signing Authorisation Header
For signing the verification header, you can use the createAuthorizationHeader
method.
import { createAuthorizationHeader } from "ondc-auth-middleware-nodejs"
const header = await createAuthorizationHeader({
body: JSON.stringify({ context: {...}, message: {...} }),
privateKey: privateKey,
subscriberId: "abcd.com/ondc", // Subscriber ID that you get after registering to ONDC Network
subscriberUniqueKeyId: "584", // Unique Key Id or uKid that you get after registering to ONDC Network
});
The method returns a set a unique signature that is ONDC-compliant and can be verified across NPs by looking up your public key from the registry.
Verifying Authorisation Header
For verifying the verification header, you can use the SignatureValidationMiddleware
method.
import { SignatureValidationMiddleware } from "ondc-auth-middleware-nodejs"
const app = Express()
app.use(SignatureValidationMiddleware({
environment:"preprod",
signInPrivateKey:"Signin Private Key",
subscriberID:"your Subscriber ID",
type:"buyerApp"
}))
The method returns a boolean value whether the signature is valid or not.