@super-protocol/sdk-js 0.10.2-beta.3 → 0.10.2-beta.4
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.
- package/build/crypto/nodejs/AES.js +4 -4
- package/build/crypto/nodejs/ARIA.js +4 -4
- package/build/crypto/nodejs/ECIES.js +2 -2
- package/build/crypto/nodejs/NativeCrypto.d.ts +2 -2
- package/build/crypto/nodejs/NativeCrypto.js +8 -8
- package/build/models/Order.js +3 -3
- package/build/staticModels/OffersFactory.js +1 -1
- package/build/staticModels/TeeOffersFactory.js +1 -1
- package/build/types/Order.d.ts +3 -2
- package/build/types/Order.js +2 -1
- package/build/types/Provider.d.ts +2 -1
- package/build/types/Provider.js +2 -1
- package/package.json +1 -1
|
@@ -49,7 +49,7 @@ var AES = /** @class */ (function () {
|
|
|
49
49
|
var keyBuffer, encrypted;
|
|
50
50
|
return __generator(this, function (_a) {
|
|
51
51
|
if (!encryption.key)
|
|
52
|
-
throw Error(
|
|
52
|
+
throw Error("Encryption key is not provided");
|
|
53
53
|
encryption.cipher = encryption.cipher || dto_js_1.Cipher.AES_256_GCM;
|
|
54
54
|
keyBuffer = Buffer.from(encryption.key, encryption.encoding);
|
|
55
55
|
encrypted = NativeCrypto_1.default.encrypt(keyBuffer, content, encryption.cipher);
|
|
@@ -79,7 +79,7 @@ var AES = /** @class */ (function () {
|
|
|
79
79
|
switch (_a.label) {
|
|
80
80
|
case 0:
|
|
81
81
|
if (!encryption.key)
|
|
82
|
-
throw Error(
|
|
82
|
+
throw Error("Encryption key is not provided");
|
|
83
83
|
encryption.cipher = encryption.cipher || dto_js_1.Cipher.AES_256_GCM;
|
|
84
84
|
keyBuffer = Buffer.from(encryption.key, encryption.encoding);
|
|
85
85
|
return [4 /*yield*/, NativeCrypto_1.default.encryptStream(keyBuffer, inputStream, outputStream, encryption.cipher)];
|
|
@@ -104,7 +104,7 @@ var AES = /** @class */ (function () {
|
|
|
104
104
|
switch (_a.label) {
|
|
105
105
|
case 0:
|
|
106
106
|
if (!encryption.key)
|
|
107
|
-
throw Error(
|
|
107
|
+
throw Error("Decryption key is not provided");
|
|
108
108
|
key = Buffer.from(encryption.key, encryption.encoding);
|
|
109
109
|
params = {
|
|
110
110
|
iv: Buffer.from(encryption.iv, encryption.encoding),
|
|
@@ -131,7 +131,7 @@ var AES = /** @class */ (function () {
|
|
|
131
131
|
switch (_a.label) {
|
|
132
132
|
case 0:
|
|
133
133
|
if (!encryption.key)
|
|
134
|
-
throw Error(
|
|
134
|
+
throw Error("Decryption key is not provided");
|
|
135
135
|
key = Buffer.from(encryption.key, encryption.encoding);
|
|
136
136
|
params = {
|
|
137
137
|
iv: Buffer.from(encryption.iv, encryption.encoding),
|
|
@@ -49,7 +49,7 @@ var ARIA = /** @class */ (function () {
|
|
|
49
49
|
var keyBuffer, encrypted;
|
|
50
50
|
return __generator(this, function (_a) {
|
|
51
51
|
if (!encryption.key)
|
|
52
|
-
throw Error(
|
|
52
|
+
throw Error("Encryption key is not provided");
|
|
53
53
|
encryption.cipher = encryption.cipher || dto_js_1.Cipher.ARIA_256_GCM;
|
|
54
54
|
keyBuffer = Buffer.from(encryption.key, encryption.encoding);
|
|
55
55
|
encrypted = NativeCrypto_1.default.encrypt(keyBuffer, content, encryption.cipher);
|
|
@@ -79,7 +79,7 @@ var ARIA = /** @class */ (function () {
|
|
|
79
79
|
switch (_a.label) {
|
|
80
80
|
case 0:
|
|
81
81
|
if (!encryption.key)
|
|
82
|
-
throw Error(
|
|
82
|
+
throw Error("Encryption key is not provided");
|
|
83
83
|
encryption.cipher = encryption.cipher || dto_js_1.Cipher.ARIA_256_GCM;
|
|
84
84
|
keyBuffer = Buffer.from(encryption.key, encryption.encoding);
|
|
85
85
|
return [4 /*yield*/, NativeCrypto_1.default.encryptStream(keyBuffer, inputStream, outputStream, encryption.cipher)];
|
|
@@ -103,7 +103,7 @@ var ARIA = /** @class */ (function () {
|
|
|
103
103
|
switch (_a.label) {
|
|
104
104
|
case 0:
|
|
105
105
|
if (!encryption.key)
|
|
106
|
-
throw Error(
|
|
106
|
+
throw Error("Decryption key is not provided");
|
|
107
107
|
key = Buffer.from(encryption.key, encryption.encoding);
|
|
108
108
|
params = {
|
|
109
109
|
iv: Buffer.from(encryption.iv, encryption.encoding),
|
|
@@ -130,7 +130,7 @@ var ARIA = /** @class */ (function () {
|
|
|
130
130
|
switch (_a.label) {
|
|
131
131
|
case 0:
|
|
132
132
|
if (!encryption.key)
|
|
133
|
-
throw Error(
|
|
133
|
+
throw Error("Decryption key is not provided");
|
|
134
134
|
key = Buffer.from(encryption.key, encryption.encoding);
|
|
135
135
|
params = {
|
|
136
136
|
iv: Buffer.from(encryption.iv, encryption.encoding),
|
|
@@ -51,7 +51,7 @@ var ECIES = /** @class */ (function () {
|
|
|
51
51
|
switch (_a.label) {
|
|
52
52
|
case 0:
|
|
53
53
|
if (!encryption.key)
|
|
54
|
-
throw Error(
|
|
54
|
+
throw Error("Encryption key is not provided");
|
|
55
55
|
return [4 /*yield*/, eccrypto_1.default.encrypt(Buffer.from(encryption.key, encryption.encoding), Buffer.from(content, "binary"))];
|
|
56
56
|
case 1:
|
|
57
57
|
result = _a.sent();
|
|
@@ -74,7 +74,7 @@ var ECIES = /** @class */ (function () {
|
|
|
74
74
|
switch (_a.label) {
|
|
75
75
|
case 0:
|
|
76
76
|
if (!encryption.key)
|
|
77
|
-
throw Error(
|
|
77
|
+
throw Error("Decryption key is not provided");
|
|
78
78
|
encryptedObject = {
|
|
79
79
|
iv: Buffer.from(encryption.iv, encryption.encoding),
|
|
80
80
|
ephemPublicKey: Buffer.from(encryption.ephemPublicKey, encryption.encoding),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
/// <reference types="node" />
|
|
4
|
-
import { ReadStream, WriteStream } from
|
|
5
|
-
import { Cipher, Decipher } from
|
|
4
|
+
import { ReadStream, WriteStream } from "fs";
|
|
5
|
+
import { Cipher, Decipher } from "crypto";
|
|
6
6
|
import { Encoding, EncryptionWithMacIV } from "@super-protocol/dto-js";
|
|
7
7
|
/**
|
|
8
8
|
*
|
|
@@ -56,12 +56,10 @@ var NativeCrypto = /** @class */ (function () {
|
|
|
56
56
|
if (/256\-xts/.test(cipher)) {
|
|
57
57
|
return 64;
|
|
58
58
|
}
|
|
59
|
-
if (/256|128\-xts|chacha20/.test(cipher)
|
|
60
|
-
&& cipher !== 'aes-128-cbc-hmac-sha256') {
|
|
59
|
+
if (/256|128\-xts|chacha20/.test(cipher) && cipher !== "aes-128-cbc-hmac-sha256") {
|
|
61
60
|
return 32;
|
|
62
61
|
}
|
|
63
|
-
if (/192|des\-ede3|desx|des3$/.test(cipher) ||
|
|
64
|
-
cipher === 'id-smime-alg-cms3deswrap') {
|
|
62
|
+
if (/192|des\-ede3|desx|des3$/.test(cipher) || cipher === "id-smime-alg-cms3deswrap") {
|
|
65
63
|
return 24;
|
|
66
64
|
}
|
|
67
65
|
if (/128|des\-ede/.test(cipher)) {
|
|
@@ -134,7 +132,7 @@ var NativeCrypto = /** @class */ (function () {
|
|
|
134
132
|
// TODO: replace BufferEncoding with Encoding
|
|
135
133
|
inputEncoding) {
|
|
136
134
|
if (outputEncoding === void 0) { outputEncoding = dto_js_1.Encoding.base64; }
|
|
137
|
-
if (inputEncoding === void 0) { inputEncoding =
|
|
135
|
+
if (inputEncoding === void 0) { inputEncoding = "binary"; }
|
|
138
136
|
var iv = this.createIV(cipherName);
|
|
139
137
|
var result = {};
|
|
140
138
|
var cipher = this.createCipher(cipherName, key, iv);
|
|
@@ -175,7 +173,7 @@ var NativeCrypto = /** @class */ (function () {
|
|
|
175
173
|
// TODO: replace BufferEncoding with Encoding
|
|
176
174
|
outputEncoding) {
|
|
177
175
|
if (inputEncoding === void 0) { inputEncoding = dto_js_1.Encoding.base64; }
|
|
178
|
-
if (outputEncoding === void 0) { outputEncoding =
|
|
176
|
+
if (outputEncoding === void 0) { outputEncoding = "binary"; }
|
|
179
177
|
var decipher = this.createDecipher(cipherName, key, params === null || params === void 0 ? void 0 : params.iv, params === null || params === void 0 ? void 0 : params.mac);
|
|
180
178
|
var decrypted = decipher.update(content, inputEncoding, outputEncoding);
|
|
181
179
|
decrypted += decipher.final(outputEncoding);
|
|
@@ -204,10 +202,12 @@ var NativeCrypto = /** @class */ (function () {
|
|
|
204
202
|
* ```
|
|
205
203
|
* but it doesn't work in browser
|
|
206
204
|
*/
|
|
207
|
-
NativeCrypto.isCCM = function (cipher) { return /ccm/i.test(cipher) || cipher ===
|
|
205
|
+
NativeCrypto.isCCM = function (cipher) { return /ccm/i.test(cipher) || cipher === "chacha20-poly1305"; };
|
|
208
206
|
NativeCrypto.isGCM = function (cipher) { return /gcm/i.test(cipher); };
|
|
209
207
|
NativeCrypto.isOCB = function (cipher) { return /ocb/i.test(cipher); };
|
|
210
|
-
NativeCrypto.isECB = function (cipher) {
|
|
208
|
+
NativeCrypto.isECB = function (cipher) {
|
|
209
|
+
return /ecb/i.test(cipher) || cipher === "des-ede" || cipher === "des-ede3";
|
|
210
|
+
};
|
|
211
211
|
NativeCrypto.isRC4 = function (cipher) { return /^rc4/i.test(cipher); };
|
|
212
212
|
return NativeCrypto;
|
|
213
213
|
}());
|
package/build/models/Order.js
CHANGED
|
@@ -137,7 +137,7 @@ var Order = /** @class */ (function () {
|
|
|
137
137
|
result[1] = orderInfoParams[2][0];
|
|
138
138
|
else
|
|
139
139
|
result[0] = orderInfoParams[2][0];
|
|
140
|
-
return [2 /*return*/, this.orderResult = (0, utils_1.tupleToObject)(result, Order_1.OrderResultStructure)];
|
|
140
|
+
return [2 /*return*/, (this.orderResult = (0, utils_1.tupleToObject)(result, Order_1.OrderResultStructure))];
|
|
141
141
|
}
|
|
142
142
|
});
|
|
143
143
|
});
|
|
@@ -420,7 +420,7 @@ var Order = /** @class */ (function () {
|
|
|
420
420
|
* @returns {Promise<void>} - Does not return id of created sub order!
|
|
421
421
|
*/
|
|
422
422
|
Order.prototype.createSubOrder = function (subOrderInfo, blocking, holdSum, transactionOptions) {
|
|
423
|
-
if (holdSum === void 0) { holdSum =
|
|
423
|
+
if (holdSum === void 0) { holdSum = "0"; }
|
|
424
424
|
return __awaiter(this, void 0, void 0, function () {
|
|
425
425
|
var preparedInfo, tupleSubOrder, params;
|
|
426
426
|
return __generator(this, function (_a) {
|
|
@@ -501,7 +501,7 @@ var Order = /** @class */ (function () {
|
|
|
501
501
|
return [4 /*yield*/, Order.contract.getPastEvents("SubOrderCreated", { filter: filter })];
|
|
502
502
|
case 1:
|
|
503
503
|
foundIds = _a.sent();
|
|
504
|
-
notFound = { consumer: consumer, externalId: externalId, subOfferId:
|
|
504
|
+
notFound = { consumer: consumer, externalId: externalId, subOfferId: "-1", subOrderId: "-1", parentOrderId: "-1" };
|
|
505
505
|
response = foundIds.length > 0 ? foundIds[0].returnValues : notFound;
|
|
506
506
|
return [2 /*return*/, response];
|
|
507
507
|
}
|
|
@@ -135,7 +135,7 @@ var TeeOffersFactory = /** @class */ (function () {
|
|
|
135
135
|
notFound = {
|
|
136
136
|
creator: creator,
|
|
137
137
|
externalId: externalId,
|
|
138
|
-
offerId:
|
|
138
|
+
offerId: "-1",
|
|
139
139
|
};
|
|
140
140
|
response = foundIds.length > 0 ? foundIds[0].returnValues : notFound;
|
|
141
141
|
return [2 /*return*/, response];
|
package/build/types/Order.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseBytes32String } from "ethers/lib/utils";
|
|
1
2
|
export declare enum OrderStatus {
|
|
2
3
|
New = "0",
|
|
3
4
|
Processing = "1",
|
|
@@ -30,7 +31,7 @@ export declare const OrderInfoStructure: {
|
|
|
30
31
|
inputOffers: StringConstructor[];
|
|
31
32
|
selectedOffers: StringConstructor[];
|
|
32
33
|
};
|
|
33
|
-
externalId:
|
|
34
|
+
externalId: typeof parseBytes32String;
|
|
34
35
|
};
|
|
35
36
|
export declare const OrderInfoStructureArray: {
|
|
36
37
|
offer: StringConstructor;
|
|
@@ -43,7 +44,7 @@ export declare const OrderInfoStructureArray: {
|
|
|
43
44
|
inputOffers: StringConstructor[];
|
|
44
45
|
selectedOffers: StringConstructor[];
|
|
45
46
|
};
|
|
46
|
-
externalId:
|
|
47
|
+
externalId: typeof parseBytes32String;
|
|
47
48
|
}[];
|
|
48
49
|
export declare type OrderInfo = {
|
|
49
50
|
offer: string;
|
package/build/types/Order.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OrderResultStructure = exports.OrderInfoStructureArray = exports.OrderInfoStructure = exports.OrderArgsStructure = exports.OrderStatus = void 0;
|
|
4
|
+
var utils_1 = require("ethers/lib/utils");
|
|
4
5
|
var OrderStatus;
|
|
5
6
|
(function (OrderStatus) {
|
|
6
7
|
OrderStatus["New"] = "0";
|
|
@@ -27,7 +28,7 @@ exports.OrderInfoStructure = {
|
|
|
27
28
|
encryptedArgs: String,
|
|
28
29
|
status: OrderStatus,
|
|
29
30
|
args: exports.OrderArgsStructure,
|
|
30
|
-
externalId:
|
|
31
|
+
externalId: utils_1.parseBytes32String,
|
|
31
32
|
};
|
|
32
33
|
// Array of order info structures
|
|
33
34
|
exports.OrderInfoStructureArray = [exports.OrderInfoStructure];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseBytes32String } from "ethers/lib/utils";
|
|
1
2
|
export declare const ProviderInfoStructure: {
|
|
2
3
|
tokenReceiver: StringConstructor;
|
|
3
4
|
actionAccount: StringConstructor;
|
|
@@ -11,7 +12,7 @@ export declare const ProviderInfoStructureV2: {
|
|
|
11
12
|
name: StringConstructor;
|
|
12
13
|
description: StringConstructor;
|
|
13
14
|
metadata: StringConstructor;
|
|
14
|
-
externalId:
|
|
15
|
+
externalId: typeof parseBytes32String;
|
|
15
16
|
};
|
|
16
17
|
export declare type ProviderInfo = {
|
|
17
18
|
tokenReceiver: string;
|
package/build/types/Provider.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProviderInfoStructureV2 = exports.ProviderInfoStructure = void 0;
|
|
4
|
+
var utils_1 = require("ethers/lib/utils");
|
|
4
5
|
// Order of keys and type conversion functions for this object in blockchain contract
|
|
5
6
|
exports.ProviderInfoStructure = {
|
|
6
7
|
tokenReceiver: String,
|
|
@@ -15,5 +16,5 @@ exports.ProviderInfoStructureV2 = {
|
|
|
15
16
|
name: String,
|
|
16
17
|
description: String,
|
|
17
18
|
metadata: String,
|
|
18
|
-
externalId:
|
|
19
|
+
externalId: utils_1.parseBytes32String,
|
|
19
20
|
};
|