@trustvc/trustvc 1.0.0-alpha.4 → 1.0.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var stringUtils = require('src/utils/stringUtils');
3
+ var stringUtils = require('../utils/stringUtils');
4
4
  var tsChacha20 = require('ts-chacha20');
5
5
 
6
6
  var __defProp = Object.defineProperty;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var stringUtils = require('src/utils/stringUtils');
3
+ var stringUtils = require('../utils/stringUtils');
4
4
  var tsChacha20 = require('ts-chacha20');
5
5
 
6
6
  var __defProp = Object.defineProperty;
@@ -14,7 +14,7 @@ function encrypt(message, key, nonce) {
14
14
  const keyBuffer = stringUtils.stringToUint8Array(key);
15
15
  const nonceBuffer = stringUtils.stringToUint8Array(nonce);
16
16
  const chacha20 = new tsChacha20.Chacha20(keyBuffer, nonceBuffer);
17
- const messageBuffer = Buffer.from(message, "utf-8");
17
+ const messageBuffer = stringUtils.stringToUint8Array(message);
18
18
  const encrypted = chacha20.encrypt(messageBuffer);
19
19
  return Buffer.from(encrypted).toString("hex");
20
20
  }
@@ -1,4 +1,4 @@
1
- import { generate32ByteKey, generate12ByteNonce, stringToUint8Array } from 'src/utils/stringUtils';
1
+ import { generate32ByteKey, generate12ByteNonce, stringToUint8Array } from '../utils/stringUtils';
2
2
  import { Chacha20 } from 'ts-chacha20';
3
3
 
4
4
  var __defProp = Object.defineProperty;
@@ -1,4 +1,4 @@
1
- import { generate32ByteKey, generate12ByteNonce, stringToUint8Array } from 'src/utils/stringUtils';
1
+ import { generate32ByteKey, generate12ByteNonce, stringToUint8Array } from '../utils/stringUtils';
2
2
  import { Chacha20 } from 'ts-chacha20';
3
3
 
4
4
  var __defProp = Object.defineProperty;
@@ -12,7 +12,7 @@ function encrypt(message, key, nonce) {
12
12
  const keyBuffer = stringToUint8Array(key);
13
13
  const nonceBuffer = stringToUint8Array(nonce);
14
14
  const chacha20 = new Chacha20(keyBuffer, nonceBuffer);
15
- const messageBuffer = Buffer.from(message, "utf-8");
15
+ const messageBuffer = stringToUint8Array(message);
16
16
  const encrypted = chacha20.encrypt(messageBuffer);
17
17
  return Buffer.from(encrypted).toString("hex");
18
18
  }
@@ -3,8 +3,7 @@ import { shake256 } from 'js-sha3';
3
3
  var __defProp = Object.defineProperty;
4
4
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
5
  function stringToUint8Array(str) {
6
- const encoder = new TextEncoder();
7
- return encoder.encode(str);
6
+ return new Uint8Array(Buffer.from(str, "utf-8"));
8
7
  }
9
8
  __name(stringToUint8Array, "stringToUint8Array");
10
9
  function generate32ByteKey(input) {
@@ -5,8 +5,7 @@ var jsSha3 = require('js-sha3');
5
5
  var __defProp = Object.defineProperty;
6
6
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
7
  function stringToUint8Array(str) {
8
- const encoder = new TextEncoder();
9
- return encoder.encode(str);
8
+ return new Uint8Array(Buffer.from(str, "utf-8"));
10
9
  }
11
10
  __name(stringToUint8Array, "stringToUint8Array");
12
11
  function generate32ByteKey(input) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trustvc/trustvc",
3
- "version": "1.0.0-alpha.4",
3
+ "version": "1.0.0-alpha.6",
4
4
  "description": "TrustVC library",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.js",