{"id":41977,"library":"sns-validator","title":"sns-validator","description":"Standalone AWS SNS HTTP message validator for Node.js. Version 0.3.5. No dependency on AWS SDK. Provides signature verification for SNS notifications, subscriptions, and unsubscribe confirmations. Lightweight alternative to using the full AWS SDK for SNS validation. Works with Node.js crypto module. Not for browser use. Maintained by AWS but low release cadence (last release 2018).","status":"maintenance","version":"0.3.5","language":"javascript","source_language":"en","source_url":"https://github.com/aws/aws-js-sns-message-validator","tags":["javascript","AWS","SNS"],"install":[{"cmd":"npm install sns-validator","lang":"bash","label":"npm"},{"cmd":"yarn add sns-validator","lang":"bash","label":"yarn"},{"cmd":"pnpm add sns-validator","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package uses CommonJS. No default ES module export. Use require() or dynamic import().","wrong":"import MessageValidator from 'sns-validator'","symbol":"MessageValidator","correct":"const MessageValidator = require('sns-validator')"},{"note":"Constructor does not accept options in current version.","wrong":"const validator = new MessageValidator({})","symbol":"new MessageValidator","correct":"const validator = new MessageValidator()"},{"note":"validate uses callback pattern, not Promises.","wrong":"validator.validate(messageObj).then()","symbol":"validate method","correct":"validator.validate(messageObj, (err, message) => {})"}],"quickstart":{"code":"const MessageValidator = require('sns-validator');\nconst validator = new MessageValidator();\n\n// Example SNS message object (from HTTP POST body parsed as JSON)\nconst message = {\n  Type: 'Notification',\n  MessageId: 'da41e39f-ea4d-435a-b922-c6aae3915ebe',\n  TopicArn: 'arn:aws:sns:us-west-2:123456789012:MyTopic',\n  Message: 'Hello from SNS!',\n  Timestamp: '2012-05-03T23:42:17.000Z',\n  SignatureVersion: '1',\n  Signature: 'tcc6faL2yUC6dgZdmrwh1Y4cGa/ebXEkAi6RibDsvpi+tE/1+82j...',\n  SigningCertUrl: 'https://sns.us-west-2.amazonaws.com/SimpleNotificationService-ac565b8b1a6c5d002d285f9598aa1d9b.pem',\n  UnsubscribeUrl: 'https://sns.us-west-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-west-2:123456789012:MyTopic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55'\n};\n\nvalidator.validate(message, (err, validatedMessage) => {\n  if (err) {\n    console.error('Validation failed:', err.message);\n    process.exit(1);\n  }\n  console.log('Validated message:', validatedMessage);\n});","lang":"javascript","description":"Shows how to validate an inbound SNS notification message using callback pattern."},"warnings":[{"fix":"Use util.promisify(validator.validate).call(validator, message) or wrap callback in Promise.","message":"The package does not support Promises or async/await natively. You must use callbacks or wrap with util.promisify.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Call JSON.parse on the HTTP request body before passing to validate.","message":"The validate method expects a parsed JavaScript object (result of JSON.parse), not the raw HTTP body string.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider using @aws-sdk/client-sns with the VerifyMessageSignature command.","message":"Package is in maintenance mode. Last release was in 2018. AWS recommends using the AWS SDK's SNS message validation instead.","severity":"deprecated","affected_versions":">=0.3.5"},{"fix":"Do not bundle for frontend; only use in Node.js server code.","message":"The package uses Node.js crypto module and is not compatible with browser environments.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'0.3.5':13 '2018':58 'altern':30 'aw':5,17,35,51,60 'browser':47 'cadenc':55 'confirm':28 'crypto':43 'depend':15 'full':34 'http':7 'javascript':59 'last':56 'lightweight':29 'low':53 'maintain':49 'messag':8 'modul':44 'node.js':11,42 'notif':24 'provid':19 'releas':54,57 'sdk':18,36 'signatur':20 'sns':2,6,23,38,61 'sns-valid':1 'standalon':4 'subscript':25 'unsubscrib':27 'use':32,48 'valid':3,9,39 'verif':21 'version':12 'work':40","created_at":"2026-06-04T18:55:01.593450+00:00","updated_at":"2026-06-04T18:55:01.593450+00:00","problems":[{"fix":"Use const MessageValidator = require('sns-validator');","cause":"Imported incorrectly (e.g., using ES import instead of require).","error":"TypeError: validator.validate is not a function"},{"fix":"Call JSON.parse(body) before passing to validate.","cause":"Passed raw HTTP body string instead of parsed object.","error":"TypeError: Cannot read property 'SigningCertUrl' of undefined"},{"fix":"Provide a callback: validator.validate(message, (err, msg) => { ... });","cause":"Called validate without a callback function.","error":"TypeError: callback is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/aws/aws-js-sns-message-validator#readme","github":"https://github.com/aws/aws-js-sns-message-validator","docs":null,"changelog":null,"pypi":null,"npm":"sns-validator","openapi_spec":null,"status_page":null,"smithery":null,"categories":["security"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}