Tehanu

in books UrsulaK.LeGuin

South Pole Electrical Infrastructure

in quicklink

the power plant is home to the World’s Southernmost Flush Toilet!

Heide

in fotos

(galerij)

The Farthest Shore

in books UrsulaK.LeGuin

Doom Guy

in books JohnRomero

The Frugal Wizard's Handbook for Surviving Medieval England

in books BrandonSanderson

The Tombs of Atuan (The Earthsea Cycle, Book 2)

in books UrsulaK.LeGuin

Validating SNS message in NodeJS, promisified

in aws programming

Validating SNS message in NodeJS, promisified

If you want to subscribe to an SNS topic, it's a good idea to validate if the received request is an actual valid SNS message. AWS has a (rather old) NPM package for validation. To prevent callback hell, I've created a convenience function that validates the message using the provided signature.

The function uses the sns-validator package under the hood, which:

After this validation, you can be sure that:

You still don't know if it was provided by the topic you're actually subscribed to/wanting to subscribe to. I'd strongly recommend at least checking the topic ARN against an allowlist before doing something with the payload.

The function expects an SNS message delivered via http, formatted like this:

{
  "Type" : "Notification",
  "MessageId" : "da41e39f-ea4d-435a-b922-c6aae3915ebe",
  "TopicArn" : "arn:aws:sns:us-west-2:123456789012:MyTopic",
  "Subject" : "test",
  "Message" : "test message",
  "Timestamp" : "2012-04-25T21:49:25.719Z",
  "SignatureVersion" : "1",
  "Signature" : "EXAMPLElDMXvB8r9R83tGoNn0ecwd5UjllzsvSvbItzfaMpN2nk5HVSw7XnOn/49IkxDKz8YrlH2qJXj2iZB0Zo2O71c4qQk1fMUDi3LGpij7RCW7AW9vYYsSqIKRnFS94ilu7NFhUzLiieYr4BKHpdTmdD6c0esKEYBpabxDSc=",
  "SigningCertURL" : "https://sns.us-west-2.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem",
   "UnsubscribeURL" : "https://sns.us-west-2.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-west-2:123456789012:MyTopic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55"
}

source

Besides validating if the message is valid, the function will subscribe to the topic if the provided message is a 'SubscriptionConfirmation' type notification. In all other cases it just returns the original message.

import * as https from 'https';
import MessageValidator from 'sns-validator';

async function validateMessage(message: any): Promise<any> {
  const validator = new MessageValidator();
  return new Promise((resolve, reject) => {
    validator.validate(message, (err, aMessage) => {
      if (err) {
        return reject(err);
      }
      if (aMessage?.Type === 'SubscriptionConfirmation' && aMessage.SubscribeURL) {
        https.get(aMessage.SubscribeURL, function (_res) {
          // You have confirmed your endpoint subscription
        });
      }
      resolve(aMessage);
    });
  });
}

A wizard of Earthsea

in books UrsulaK.LeGuin

Nettle and Bone

in books T.Kingfisher

Happy City: Transforming Our Lives Through Urban Design

in books CharlesMontgomery

Corsica (Capo Rosso)

in fotos

(galerij)

Daughter of Doctor Moreau

in books SilviaMoreno-Garcia

Terraformers

in books AnnaleeNewitz

Een bonte verzameling mensen in allerlei vormen en maten, tot levende vliegende treinen aan toe, probeert een planeet te terraformen, te ontkomen aan het bedrijf dat ze tot en als slaaf gemaakt heeft, en een manier van samenleven te vinden.

Witch King

in books MarthaWells

Heel anders dan haar 'Murderbot'-serie. Er wordt zonder dat het vervelend wordt een uitgebreide wereld geschetst, waarin het verhaal geen moment verveeld.

Finding the Mother Tree

in books SuzanneSimard

Deels autobiografie, deels populair-wetenschappelijk boek over de manier waarop bomen en bossen communiceren en elkaar ondersteunen. De schrijfster komt uit een Canadese bosbouwersfamilie. Zowel interessant vanwege de wetenschappelijke inhoud, als vanwege het inkijkje in het leven van de auteur, als in het (vaak afgelegen) Canada van de afgelopen 100 jaar.

Translation State

in books AnnLeckie

Een nieuwe in haar langere serie SF-boeken ('Imperial Radch'), waarin wat meer bekend wordt van de mysterieuze aliens. De conflicten van de eerdere boeken spelen slechts op de achtergrond een rol.

The Ballad Of Songbirds And Snakes

in books SuzanneCollins

Onnodige prequel op de Hunger Games. De hoofdpersoon (de slechterik uit de serie, in zijnj jongere jaren) verandert zonder aanleiding zijn volledige karakter (meer dan eens?), de vrouwelijke hoofdpersoon valt wel erg snel en volledig voor haar executeur, de ontknoping slaat nergens op. Misschien is het de set-up voor een deel 2 waarin dit allemaal verklaard wordt, maar ik vrees het ergste. Als dat je niks kan schelen is het geen vervelend boek om te lezen.

Doe zelf normaal

in books MaximFebruari

Ik ben er nog over aan het nadenken. Het punt dat de schrijver probeert te maken is belangrijk. Ik geloof ook dat ik het er mee eens kan zijn. Ik zie alleen in het boek geen goed argument voor het probleem dat hij beschrijft, en ik heb het idee dat er stappen overgeslagen worden, verbanden gelegd worden die ik niet zo zie, of gefocused wordt op de verkeerde dingen. Het kan ook zijn dat ik het niet goed gelezen heb.

Red Team Blues

in books CoryDoctorow

Wederom een goed leesbare (korte) van Doctorow. Met vooral rollen voor mensen van middelbare leeftijd, waarbij de hoofdrolspeler accountant is, en toch spannend tot het laatst.