Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

Commit

Permalink
Fix hashes for browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
wschella committed Feb 18, 2019
1 parent 94d61b0 commit cbaef73
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 23 deletions.
13 changes: 7 additions & 6 deletions lib/functions/RegularFunctions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as RDFDM from '@rdfjs/data-model';
import * as hasha from 'hasha';
import * as hash from 'create-hash';
import * as uuid from 'uuid';

import { Hash } from 'crypto';
import { Map } from 'immutable';

import * as E from '../expressions';
Expand Down Expand Up @@ -495,35 +496,35 @@ const tz = {
const MD5 = {
arity: 1,
overloads: declare()
.onString1Typed((str) => string(hasha(str, { algorithm: 'md5' })))
.onString1Typed((str) => string(hash('md5').update(str).digest('hex')))
.collect(),
};

const SHA1 = {
arity: 1,
overloads: declare()
.onString1Typed((str) => string(hasha(str, { algorithm: 'sha1' })))
.onString1Typed((str) => string(hash('sha1').update(str).digest('hex')))
.collect(),
};

const SHA256 = {
arity: 1,
overloads: declare()
.onString1Typed((str) => string(hasha(str, { algorithm: 'sha256' })))
.onString1Typed((str) => string(hash('sha256').update(str).digest('hex')))
.collect(),
};

const SHA384 = {
arity: 1,
overloads: declare()
.onString1Typed((str) => string(hasha(str, { algorithm: 'sha384' })))
.onString1Typed((str) => string(hash('sha384').update(str).digest('hex')))
.collect(),
};

const SHA512 = {
arity: 1,
overloads: declare()
.onString1Typed((str) => string(hasha(str, { algorithm: 'sha512' })))
.onString1Typed((str) => string(hash('sha512').update(str).digest('hex')))
.collect(),
};

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"homepage": "https://github.com/comunica/sparqlee#readme",
"devDependencies": {
"@types/benchmark": "^1.0.30",
"@types/hasha": "^3.0.0",
"@types/create-hash": "^1.2.0",
"@types/jest": "^24.0.0",
"@types/uuid": "^3.4.4",
"asynciterator": "^2.0.0",
Expand All @@ -64,7 +64,7 @@
"@types/lodash": "^4.14.105",
"@types/lodash.isequal": "^4.5.2",
"@types/rdf-js": "^2.0.1",
"hasha": "^3.0.0",
"create-hash": "^1.2.0",
"immutable": "^3.8.2",
"rdf-string": "^1.1.1",
"sparqlalgebrajs": "^1.1.0",
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"index.ts",
"lib/**/*.ts",
"bin/**/*.ts",
"util/**/*.ts", "test/EBVCoercion.test.ts", "test/EBVCoercion.ts",
"util/**/*.ts",
"typings/**/*.d.ts",
],
"exclude": [
"**/dist",
Expand Down
74 changes: 60 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@
version "1.0.31"
resolved "https://registry.yarnpkg.com/@types/benchmark/-/benchmark-1.0.31.tgz#2dd3514e93396f362ba5551a7c9ff0da405c1d38"

"@types/events@*":
"@types/create-hash@^1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@types/events/-/events-1.2.0.tgz#81a6731ce4df43619e5c8c945383b3e62a89ea86"

"@types/hasha@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/hasha/-/hasha-3.0.0.tgz#5878e307014ee19246ca39203466ddbcbb591670"
integrity sha512-MRLyPajsu7/w0XRe5KnH/UcmFzjpMTQyjZwKWq8E0lrCXl4qX1Fq4sz8Bx3pRavaDMW4lZV3xnGB+2AXfjQ/ZA==
resolved "https://registry.yarnpkg.com/@types/create-hash/-/create-hash-1.2.0.tgz#a30e091ce5904652dd6cee76d1b5e4ce6e883a68"
integrity sha512-tvo2dQ4TRKi0GYsblpWnhpJKR7Dvyyu+JdWhu4K5J8MKKONQfD9imAI/RIZn9brZXJ7n5DHxjwMpB4XOIVvGaw==
dependencies:
"@types/node" "*"

"@types/events@*":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@types/events/-/events-1.2.0.tgz#81a6731ce4df43619e5c8c945383b3e62a89ea86"

"@types/jest@^24.0.0":
version "24.0.0"
resolved "https://registry.yarnpkg.com/@types/jest/-/jest-24.0.0.tgz#848492026c327b3548d92be0352a545c36a21e8a"
Expand Down Expand Up @@ -538,6 +538,14 @@ ci-info@^1.5.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.6.0.tgz#2ca20dbb9ceb32d4524a683303313f0304b1e497"

cipher-base@^1.0.1:
version "1.0.4"
resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.4.tgz#8760e4ecc272f4c363532f926d874aae2c1397de"
integrity sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==
dependencies:
inherits "^2.0.1"
safe-buffer "^5.0.1"

class-utils@^0.3.5:
version "0.3.6"
resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463"
Expand Down Expand Up @@ -650,6 +658,17 @@ coveralls@^3.0.2:
minimist "^1.2.0"
request "^2.85.0"

create-hash@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/create-hash/-/create-hash-1.2.0.tgz#889078af11a63756bcfb59bd221996be3a9ef196"
integrity sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==
dependencies:
cipher-base "^1.0.1"
inherits "^2.0.1"
md5.js "^1.3.4"
ripemd160 "^2.0.1"
sha.js "^2.4.0"

cross-spawn@^5.0.1:
version "5.1.0"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
Expand Down Expand Up @@ -1208,12 +1227,13 @@ has@^1.0.1:
dependencies:
function-bind "^1.1.1"

hasha@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/hasha/-/hasha-3.0.0.tgz#52a32fab8569d41ca69a61ff1a214f8eb7c8bd39"
integrity sha1-UqMvq4Vp1BymmmH/GiFPjrfIvTk=
hash-base@^3.0.0:
version "3.0.4"
resolved "https://registry.yarnpkg.com/hash-base/-/hash-base-3.0.4.tgz#5fc8686847ecd73499403319a6b0a3f3f6ae4918"
integrity sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=
dependencies:
is-stream "^1.0.1"
inherits "^2.0.1"
safe-buffer "^5.0.1"

home-or-tmp@^2.0.0:
version "2.0.0"
Expand Down Expand Up @@ -1284,7 +1304,7 @@ inflight@^1.0.4:
once "^1.3.0"
wrappy "1"

inherits@2, inherits@^2.0.3, inherits@~2.0.3:
inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"

Expand Down Expand Up @@ -1456,9 +1476,10 @@ is-regex@^1.0.4:
dependencies:
has "^1.0.1"

is-stream@^1.0.1, is-stream@^1.1.0:
is-stream@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"
integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ=

is-symbol@^1.0.1:
version "1.0.2"
Expand Down Expand Up @@ -2070,6 +2091,15 @@ math-random@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/math-random/-/math-random-1.0.1.tgz#8b3aac588b8a66e4975e3cdea67f7bb329601fac"

md5.js@^1.3.4:
version "1.3.5"
resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f"
integrity sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==
dependencies:
hash-base "^3.0.0"
inherits "^2.0.1"
safe-buffer "^5.1.2"

mem@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/mem/-/mem-1.1.0.tgz#5edd52b485ca1d900fe64895505399a0dfa45f76"
Expand Down Expand Up @@ -2740,6 +2770,14 @@ rimraf@^2.5.4, rimraf@^2.6.1:
dependencies:
glob "^7.0.5"

ripemd160@^2.0.1:
version "2.0.2"
resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c"
integrity sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==
dependencies:
hash-base "^3.0.0"
inherits "^2.0.1"

rsvp@^3.3.3:
version "3.6.2"
resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-3.6.2.tgz#2e96491599a96cde1b515d5674a8f7a91452926a"
Expand Down Expand Up @@ -2803,6 +2841,14 @@ set-value@^2.0.0:
is-plain-object "^2.0.3"
split-string "^3.0.1"

sha.js@^2.4.0:
version "2.4.11"
resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.11.tgz#37a5cf0b81ecbc6943de109ba2960d1b26584ae7"
integrity sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==
dependencies:
inherits "^2.0.1"
safe-buffer "^5.0.1"

shebang-command@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"
Expand Down

0 comments on commit cbaef73

Please sign in to comment.