summaryrefslogtreecommitdiffstats
path: root/node_modules/cipher-base
diff options
context:
space:
mode:
authorGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
committerGravatar Piotr Russ <mail@pruss.it> 2020-11-16 00:10:28 +0100
commite06ec920f7a5d784e674c4c4b4e6d1da3dc7391d (patch)
tree55713f725f77b44ebfec86e4eec3ce33e71458ca /node_modules/cipher-base
downloadwebsite_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.gz
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.tar.bz2
website_creator-e06ec920f7a5d784e674c4c4b4e6d1da3dc7391d.zip
api, login, auth
Diffstat (limited to 'node_modules/cipher-base')
-rw-r--r--node_modules/cipher-base/.eslintrc3
-rw-r--r--node_modules/cipher-base/.npmignore1
-rw-r--r--node_modules/cipher-base/.travis.yml6
-rw-r--r--node_modules/cipher-base/LICENSE21
-rw-r--r--node_modules/cipher-base/README.md17
-rw-r--r--node_modules/cipher-base/index.js99
-rw-r--r--node_modules/cipher-base/package.json63
-rw-r--r--node_modules/cipher-base/test.js111
8 files changed, 321 insertions, 0 deletions
diff --git a/node_modules/cipher-base/.eslintrc b/node_modules/cipher-base/.eslintrc
new file mode 100644
index 0000000..a755cdb
--- /dev/null
+++ b/node_modules/cipher-base/.eslintrc
@@ -0,0 +1,3 @@
+{
+ "extends": ["standard"]
+}
diff --git a/node_modules/cipher-base/.npmignore b/node_modules/cipher-base/.npmignore
new file mode 100644
index 0000000..3c3629e
--- /dev/null
+++ b/node_modules/cipher-base/.npmignore
@@ -0,0 +1 @@
+node_modules
diff --git a/node_modules/cipher-base/.travis.yml b/node_modules/cipher-base/.travis.yml
new file mode 100644
index 0000000..eb83acd
--- /dev/null
+++ b/node_modules/cipher-base/.travis.yml
@@ -0,0 +1,6 @@
+language: node_js
+node_js:
+ - "0.11"
+ - "0.10"
+ - "0.12"
+ - "iojs"
diff --git a/node_modules/cipher-base/LICENSE b/node_modules/cipher-base/LICENSE
new file mode 100644
index 0000000..f06007a
--- /dev/null
+++ b/node_modules/cipher-base/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2017 crypto-browserify contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/node_modules/cipher-base/README.md b/node_modules/cipher-base/README.md
new file mode 100644
index 0000000..db9a781
--- /dev/null
+++ b/node_modules/cipher-base/README.md
@@ -0,0 +1,17 @@
+cipher-base
+===
+
+[![Build Status](https://travis-ci.org/crypto-browserify/cipher-base.svg)](https://travis-ci.org/crypto-browserify/cipher-base)
+
+Abstract base class to inherit from if you want to create streams implementing
+the same api as node crypto streams.
+
+Requires you to implement 2 methods `_final` and `_update`. `_update` takes a
+buffer and should return a buffer, `_final` takes no arguments and should return
+a buffer.
+
+
+The constructor takes one argument and that is a string which if present switches
+it into hash mode, i.e. the object you get from crypto.createHash or
+crypto.createSign, this switches the name of the final method to be the string
+you passed instead of `final` and returns `this` from update.
diff --git a/node_modules/cipher-base/index.js b/node_modules/cipher-base/index.js
new file mode 100644
index 0000000..6728005
--- /dev/null
+++ b/node_modules/cipher-base/index.js
@@ -0,0 +1,99 @@
+var Buffer = require('safe-buffer').Buffer
+var Transform = require('stream').Transform
+var StringDecoder = require('string_decoder').StringDecoder
+var inherits = require('inherits')
+
+function CipherBase (hashMode) {
+ Transform.call(this)
+ this.hashMode = typeof hashMode === 'string'
+ if (this.hashMode) {
+ this[hashMode] = this._finalOrDigest
+ } else {
+ this.final = this._finalOrDigest
+ }
+ if (this._final) {
+ this.__final = this._final
+ this._final = null
+ }
+ this._decoder = null
+ this._encoding = null
+}
+inherits(CipherBase, Transform)
+
+CipherBase.prototype.update = function (data, inputEnc, outputEnc) {
+ if (typeof data === 'string') {
+ data = Buffer.from(data, inputEnc)
+ }
+
+ var outData = this._update(data)
+ if (this.hashMode) return this
+
+ if (outputEnc) {
+ outData = this._toString(outData, outputEnc)
+ }
+
+ return outData
+}
+
+CipherBase.prototype.setAutoPadding = function () {}
+CipherBase.prototype.getAuthTag = function () {
+ throw new Error('trying to get auth tag in unsupported state')
+}
+
+CipherBase.prototype.setAuthTag = function () {
+ throw new Error('trying to set auth tag in unsupported state')
+}
+
+CipherBase.prototype.setAAD = function () {
+ throw new Error('trying to set aad in unsupported state')
+}
+
+CipherBase.prototype._transform = function (data, _, next) {
+ var err
+ try {
+ if (this.hashMode) {
+ this._update(data)
+ } else {
+ this.push(this._update(data))
+ }
+ } catch (e) {
+ err = e
+ } finally {
+ next(err)
+ }
+}
+CipherBase.prototype._flush = function (done) {
+ var err
+ try {
+ this.push(this.__final())
+ } catch (e) {
+ err = e
+ }
+
+ done(err)
+}
+CipherBase.prototype._finalOrDigest = function (outputEnc) {
+ var outData = this.__final() || Buffer.alloc(0)
+ if (outputEnc) {
+ outData = this._toString(outData, outputEnc, true)
+ }
+ return outData
+}
+
+CipherBase.prototype._toString = function (value, enc, fin) {
+ if (!this._decoder) {
+ this._decoder = new StringDecoder(enc)
+ this._encoding = enc
+ }
+
+ if (this._encoding !== enc) throw new Error('can\'t switch encodings')
+
+ var out = this._decoder.write(value)
+ if (fin) {
+ out += this._decoder.end()
+ }
+
+ return out
+}
+
+module.exports = CipherBase
diff --git a/node_modules/cipher-base/package.json b/node_modules/cipher-base/package.json
new file mode 100644
index 0000000..6721155
--- /dev/null
+++ b/node_modules/cipher-base/package.json
@@ -0,0 +1,63 @@
+{
+ "_from": "cipher-base@^1.0.0",
+ "_id": "cipher-base@1.0.4",
+ "_inBundle": false,
+ "_integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==",
+ "_location": "/cipher-base",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "cipher-base@^1.0.0",
+ "name": "cipher-base",
+ "escapedName": "cipher-base",
+ "rawSpec": "^1.0.0",
+ "saveSpec": null,
+ "fetchSpec": "^1.0.0"
+ },
+ "_requiredBy": [
+ "/browserify-aes",
+ "/browserify-des",
+ "/create-hash",
+ "/create-hmac"
+ ],
+ "_resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz",
+ "_shasum": "8760e4ecc272f4c363532f926d874aae2c1397de",
+ "_spec": "cipher-base@^1.0.0",
+ "_where": "/home/pruss/Dev/3-minute-website/node_modules/browserify-aes",
+ "author": {
+ "name": "Calvin Metcalf",
+ "email": "calvin.metcalf@gmail.com"
+ },
+ "bugs": {
+ "url": "https://github.com/crypto-browserify/cipher-base/issues"
+ },
+ "bundleDependencies": false,
+ "dependencies": {
+ "inherits": "^2.0.1",
+ "safe-buffer": "^5.0.1"
+ },
+ "deprecated": false,
+ "description": "abstract base class for crypto-streams",
+ "devDependencies": {
+ "standard": "^10.0.2",
+ "tap-spec": "^4.1.0",
+ "tape": "^4.2.0"
+ },
+ "homepage": "https://github.com/crypto-browserify/cipher-base#readme",
+ "keywords": [
+ "cipher",
+ "stream"
+ ],
+ "license": "MIT",
+ "main": "index.js",
+ "name": "cipher-base",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/crypto-browserify/cipher-base.git"
+ },
+ "scripts": {
+ "test": "node test.js | tspec"
+ },
+ "version": "1.0.4"
+}
diff --git a/node_modules/cipher-base/test.js b/node_modules/cipher-base/test.js
new file mode 100644
index 0000000..29d3492
--- /dev/null
+++ b/node_modules/cipher-base/test.js
@@ -0,0 +1,111 @@
+var Buffer = require('safe-buffer').Buffer
+var CipherBase = require('./')
+
+var test = require('tape')
+var inherits = require('inherits')
+
+test('basic version', function (t) {
+ function Cipher () {
+ CipherBase.call(this)
+ }
+ inherits(Cipher, CipherBase)
+ Cipher.prototype._update = function (input) {
+ t.ok(Buffer.isBuffer(input))
+ return input
+ }
+ Cipher.prototype._final = function () {
+ // noop
+ }
+ var cipher = new Cipher()
+ var utf8 = 'abc123abcd'
+ var update = cipher.update(utf8, 'utf8', 'base64') + cipher.final('base64')
+ var string = (Buffer.from(update, 'base64')).toString()
+ t.equals(utf8, string)
+ t.end()
+})
+test('hash mode', function (t) {
+ function Cipher () {
+ CipherBase.call(this, 'finalName')
+ this._cache = []
+ }
+ inherits(Cipher, CipherBase)
+ Cipher.prototype._update = function (input) {
+ t.ok(Buffer.isBuffer(input))
+ this._cache.push(input)
+ }
+ Cipher.prototype._final = function () {
+ return Buffer.concat(this._cache)
+ }
+ var cipher = new Cipher()
+ var utf8 = 'abc123abcd'
+ var update = cipher.update(utf8, 'utf8').finalName('base64')
+ var string = (Buffer.from(update, 'base64')).toString()
+
+ t.equals(utf8, string)
+ t.end()
+})
+test('hash mode as stream', function (t) {
+ function Cipher () {
+ CipherBase.call(this, 'finalName')
+ this._cache = []
+ }
+ inherits(Cipher, CipherBase)
+ Cipher.prototype._update = function (input) {
+ t.ok(Buffer.isBuffer(input))
+ this._cache.push(input)
+ }
+ Cipher.prototype._final = function () {
+ return Buffer.concat(this._cache)
+ }
+ var cipher = new Cipher()
+ cipher.on('error', function (e) {
+ t.notOk(e)
+ })
+ var utf8 = 'abc123abcd'
+ cipher.end(utf8, 'utf8')
+ var update = cipher.read().toString('base64')
+ var string = (Buffer.from(update, 'base64')).toString()
+
+ t.equals(utf8, string)
+ t.end()
+})
+
+test('encodings', function (t) {
+ inherits(Cipher, CipherBase)
+ function Cipher () {
+ CipherBase.call(this)
+ }
+ Cipher.prototype._update = function (input) {
+ return input
+ }
+ Cipher.prototype._final = function () {
+ // noop
+ }
+ t.test('mix and match encoding', function (t) {
+ t.plan(2)
+
+ var cipher = new Cipher()
+ cipher.update('foo', 'utf8', 'utf8')
+ t.throws(function () {
+ cipher.update('foo', 'utf8', 'base64')
+ })
+ cipher = new Cipher()
+ cipher.update('foo', 'utf8', 'base64')
+ t.doesNotThrow(function () {
+ cipher.update('foo', 'utf8')
+ cipher.final('base64')
+ })
+ })
+ t.test('handle long uft8 plaintexts', function (t) {
+ t.plan(1)
+ var txt = 'ふっかつ あきる すぶり はやい つける まゆげ たんさん みんぞく ねほりはほり せまい たいまつばな ひはん'
+
+ var cipher = new Cipher()
+ var decipher = new Cipher()
+ var enc = decipher.update(cipher.update(txt, 'utf8', 'base64'), 'base64', 'utf8')
+ enc += decipher.update(cipher.final('base64'), 'base64', 'utf8')
+ enc += decipher.final('utf8')
+
+ t.equals(txt, enc)
+ })
+})