Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ an error and the second being the successfully validated SNS message.
The message validator checks the `SigningCertURL`, `SignatureVersion`, and
`Signature` to make sure they are valid and consistent with the message data.

#### Javascript
```javascript
var MessageValidator = require('sns-validator'),
validator = new MessageValidator();
Expand All @@ -47,6 +48,21 @@ validator.validate(message, function (err, message) {
});
```

#### Typescript
```typescript
import { MessageValidator } from "sns-validator"
const validator = new MessageValidator();

validator.validate(message, function (err, message) {
if (err) {
// Your message could not be validated.
return;
}

// message has been validated and its signature checked.
});
```

## Installation

The SNS Message Validator relies on the Node crypto module and is only designed
Expand Down
4 changes: 4 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export declare class MessageValidator {
encoding: string;
validate(hash: any, cb: (err: string, message: string) => any);
}
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,6 @@ MessageValidator.prototype.validate = function (hash, cb) {
validateSignature(hash, cb, this.encoding);
};

MessageValidator.MessageValidator = MessageValidator;

module.exports = MessageValidator;