From 14a064f72a128ac3501eec246626e9f66cdd1c99 Mon Sep 17 00:00:00 2001 From: Niels Klomp Date: Wed, 25 Sep 2024 11:40:19 +0200 Subject: [PATCH] fix: json-ld fix for crypto changes --- ...lcredentials+jsonld-signatures+9.4.0.patch | 22 +++++++++++++ ...igitalcredentials+rdf-canonize+1.0.0.patch | 31 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 patches/@digitalcredentials+jsonld-signatures+9.4.0.patch create mode 100644 patches/@digitalcredentials+rdf-canonize+1.0.0.patch diff --git a/patches/@digitalcredentials+jsonld-signatures+9.4.0.patch b/patches/@digitalcredentials+jsonld-signatures+9.4.0.patch new file mode 100644 index 00000000..560d4db2 --- /dev/null +++ b/patches/@digitalcredentials+jsonld-signatures+9.4.0.patch @@ -0,0 +1,22 @@ +diff --git a/node_modules/@digitalcredentials/jsonld-signatures/lib/sha256digest-reactnative.js b/node_modules/@digitalcredentials/jsonld-signatures/lib/sha256digest-reactnative.js +index d4012ad..8443cf3 100644 +--- a/node_modules/@digitalcredentials/jsonld-signatures/lib/sha256digest-reactnative.js ++++ b/node_modules/@digitalcredentials/jsonld-signatures/lib/sha256digest-reactnative.js +@@ -3,7 +3,7 @@ + */ + 'use strict'; + +-const crypto = require('isomorphic-webcrypto'); ++// const crypto = require('isomorphic-webcrypto'); + require('fast-text-encoding'); + + module.exports = { +@@ -17,7 +17,7 @@ module.exports = { + async sha256digest({string}) { + const bytes = new TextEncoder().encode(string); + return new Uint8Array( +- await crypto.subtle.digest({name: 'SHA-256'}, bytes) ++ await global.crypto.subtle.digest({name: 'SHA-256'}, bytes) + ); + } + }; diff --git a/patches/@digitalcredentials+rdf-canonize+1.0.0.patch b/patches/@digitalcredentials+rdf-canonize+1.0.0.patch new file mode 100644 index 00000000..963edd0c --- /dev/null +++ b/patches/@digitalcredentials+rdf-canonize+1.0.0.patch @@ -0,0 +1,31 @@ +diff --git a/node_modules/@digitalcredentials/rdf-canonize/lib/MessageDigest-reactnative.js b/node_modules/@digitalcredentials/rdf-canonize/lib/MessageDigest-reactnative.js +index 3d50b27..243abe5 100644 +--- a/node_modules/@digitalcredentials/rdf-canonize/lib/MessageDigest-reactnative.js ++++ b/node_modules/@digitalcredentials/rdf-canonize/lib/MessageDigest-reactnative.js +@@ -3,7 +3,7 @@ + */ + 'use strict'; + +-const crypto = require('isomorphic-webcrypto'); ++// const crypto = require('isomorphic-webcrypto'); + require('fast-text-encoding'); + + module.exports = class MessageDigest { +@@ -15,7 +15,7 @@ module.exports = class MessageDigest { + constructor(algorithm) { + // check if crypto.subtle is available + // check is here rather than top-level to only fail if class is used +- if(!(crypto && crypto.subtle)) { ++ if(!(global.crypto && global.crypto.subtle)) { + throw new Error('crypto.subtle not found.'); + } + if(algorithm === 'sha256') { +@@ -35,7 +35,7 @@ module.exports = class MessageDigest { + async digest() { + const data = new TextEncoder().encode(this._content); + const buffer = new Uint8Array( +- await crypto.subtle.digest(this.algorithm, data)); ++ await global.crypto.subtle.digest(this.algorithm, data)); + // return digest in hex + let hex = ''; + for(let i = 0; i < buffer.length; ++i) {