azure-sas-token

    0.0.43 • Public • Published

    Azure SAS token generator

    A simple JavaScript Azure SAS token generator

    The current project is about how to programmatically generate a Shared Access Signature (SAS) token to use with Postman in order to post messages to Azure Service Bus Topic/Queue.

    NPM GitHub issues Snyk Vulnerabilities for npm package npm bundle size npm bundle size npm

    Motivation

    After googling for a while in order to generate the necessary token, to post messages to Azure service bus, i noticed that there is no clear explanations, how to achieve it in JavaScript!! I'm proud to offer you a simple JS way to generate Azure SAS token - using node - or angular.

    Don't forget to let me a Star ⭐ :-)

    How to use?

    Only by adding the dependency to your code, see example section

    Installation

    npm install azure-sas-token

    Code Example

    js-standard-style

    const azureSasToken = require('azure-sas-token');
     
    // default token validity is 7 days
    let sasToken = azureSasToken.createSharedAccessToken('https://<service namespace>.servicebus.windows.net/<topic name or queue>',
                                    '<signature key name>',
                                    '<signature hash>');
    console.log(`sasToken: ${sasToken}`);
     
    // Specify your own validity in secs, two hours in this example
    sasToken = azureSasToken.createSharedAccessToken('https://<service namespace>.servicebus.windows.net/<topic name or queue>',
                                    '<signature key name>',
                                    '<signature hash>', 
                                    60 * 60 * 2);
    console.log(`sasToken: ${sasToken}`);

    Posting messages in Azure service-bus queue - tutorial

    https://github.com/ah584d/azure-send-message-to-service-bus-with-postman

    Tests

    100% coverage

    Build status [under construction]

    Contribute

    Feel free to open PR.

    Credits

    Icon from: http://www.kameleon.pics

    License

    A short snippet describing the license (MIT, Apache etc)

    MIT © Avraham Hamu

    Install

    npm i azure-sas-token

    DownloadsWeekly Downloads

    28

    Version

    0.0.43

    License

    ISC

    Unpacked Size

    4.39 kB

    Total Files

    3

    Last publish

    Collaborators

    • ahamu