Coder Social home page Coder Social logo

nodery / get-sri Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 297 KB

Generates the SRI hash of the given string to use with CDN resources without publishing the content to CDN.

Home Page: https://www.npmjs.com/package/get-sri

License: MIT License

JavaScript 100.00%
sri cdn hash sha256 sha384 sha512 subresource integrity subresource-integrity

get-sri's Introduction

get-sri

Node.js Version Travis CI - Build Status AppVeyor CI - Build Status Coveralls - Code Coverage Status JavaScript Style Guide PRs Welcome

Generates the SRI (Subresource Integrity) hash of the given string to use as the SRIs of CDN files without publishing the content to CDN (e.g. when generating the readme file before release and publish).

With get-sri, you can just simply generate the sha256-j7UhB[...]5ni2s= part of the integrity attribute for <link> and <script> elements, e.g.:

<script src="https://example.com/example-framework.js" 
        integrity="sha256-j7UhB8zxegHMV59uYb38Ho75sqloISge2+fsjN5ni2s=" 
        crossorigin="anonymous"></script>

Installation

# Using NPM
npm install get-sri --save-dev
# Using Yarn
yarn add get-sri --dev

Usage

The API documentation can be found here.

const getSRI = require('get-sri')

// returns the SRI hash without prefix ('sha256' by default)
getSRI('... file content as string ...') // 'OXPgIukyI[...]6SgMU3pmfURI='

// returns the SRI hash with prefix ('sha256' by default, can be 'sha256', 'sha384', or 'sha512')
getSRI('... file content as string ...', getSRI.SHA256, true) // 'sha256-OXPgIukyI[...]6SgMU3pmfURI='

Contribution

Any contribution is appreciated. To get going, check out the contribution guidelines. Thank you and have fun!

License

MIT @ Richard Szakacs

get-sri's People

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.