@airgap/aeternity 0.13.45-beta.1 → 0.13.45-beta.3
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/package.json +4 -4
- package/v0/index.js +7 -7
- package/v0/index.js.map +1 -1
- package/v0/protocol/AeternityAddress.js +27 -18
- package/v0/protocol/AeternityAddress.js.map +1 -1
- package/v0/protocol/AeternityCryptoClient.js +21 -84
- package/v0/protocol/AeternityCryptoClient.js.map +1 -1
- package/v0/protocol/AeternityProtocol.js +341 -657
- package/v0/protocol/AeternityProtocol.js.map +1 -1
- package/v0/protocol/AeternityProtocolOptions.js +22 -93
- package/v0/protocol/AeternityProtocolOptions.js.map +1 -1
- package/v0/serializer/validators/transaction-validator.js +30 -83
- package/v0/serializer/validators/transaction-validator.js.map +1 -1
- package/v0/serializer/validators/validators.js +19 -67
- package/v0/serializer/validators/validators.js.map +1 -1
- package/v1/block-explorer/AeternityBlockExplorer.js +12 -61
- package/v1/block-explorer/AeternityBlockExplorer.js.map +1 -1
- package/v1/data/AeternityAddress.js +12 -13
- package/v1/data/AeternityAddress.js.map +1 -1
- package/v1/index.js +3 -3
- package/v1/index.js.map +1 -1
- package/v1/module/AeternityModule.d.ts +1 -1
- package/v1/module/AeternityModule.js +37 -95
- package/v1/module/AeternityModule.js.map +1 -1
- package/v1/module.js +2 -3
- package/v1/module.js.map +1 -1
- package/v1/protocol/AeternityCryptoClient.js +21 -84
- package/v1/protocol/AeternityCryptoClient.js.map +1 -1
- package/v1/protocol/AeternityProtocol.js +282 -497
- package/v1/protocol/AeternityProtocol.js.map +1 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +8 -20
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
- package/v1/serializer/v3/serializer-companion.js +69 -148
- package/v1/serializer/v3/serializer-companion.js.map +1 -1
- package/v1/serializer/v3/validators/transaction-validator.js +15 -63
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -1
- package/v1/serializer/v3/validators/validators.js +19 -67
- package/v1/serializer/v3/validators/validators.js.map +1 -1
- package/v1/types/crypto.d.ts +1 -1
- package/v1/types/protocol.d.ts +1 -1
- package/v1/utils/convert.js +26 -17
- package/v1/utils/convert.js.map +1 -1
- package/v1/utils/key.js +9 -10
- package/v1/utils/key.js.map +1 -1
- package/v1/utils/signature.js +6 -7
- package/v1/utils/signature.js.map +1 -1
- package/v1/utils/transaction.d.ts +0 -1
- package/v1/utils/transaction.js +26 -17
- package/v1/utils/transaction.js.map +1 -1
package/v1/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AeternityBlockExplorer = exports.createAeternityProtocolOptions = exports.createAeternityProtocol = exports.AeternityModule = void 0;
|
|
4
|
-
|
|
4
|
+
const AeternityBlockExplorer_1 = require("./block-explorer/AeternityBlockExplorer");
|
|
5
5
|
Object.defineProperty(exports, "AeternityBlockExplorer", { enumerable: true, get: function () { return AeternityBlockExplorer_1.AeternityBlockExplorer; } });
|
|
6
|
-
|
|
6
|
+
const AeternityModule_1 = require("./module/AeternityModule");
|
|
7
7
|
Object.defineProperty(exports, "AeternityModule", { enumerable: true, get: function () { return AeternityModule_1.AeternityModule; } });
|
|
8
|
-
|
|
8
|
+
const AeternityProtocol_1 = require("./protocol/AeternityProtocol");
|
|
9
9
|
Object.defineProperty(exports, "createAeternityProtocol", { enumerable: true, get: function () { return AeternityProtocol_1.createAeternityProtocol; } });
|
|
10
10
|
Object.defineProperty(exports, "createAeternityProtocolOptions", { enumerable: true, get: function () { return AeternityProtocol_1.createAeternityProtocolOptions; } });
|
|
11
11
|
//# sourceMappingURL=index.js.map
|
package/v1/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v1/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v1/index.ts"],"names":[],"mappings":";;;AAAA,oFAAgF;AAmBvE,uGAnBA,+CAAsB,OAmBA;AAlB/B,8DAA0D;AAUjD,gGAVA,iCAAe,OAUA;AATxB,oEAAyH;AAa7F,wGAbA,2CAAuB,OAaA;AAAE,+GAbA,kDAA8B,OAaA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MainProtocolSymbols } from '@airgap/coinlib-core';
|
|
2
2
|
import { AirGapBlockExplorer, AirGapModule, AirGapOfflineProtocol, AirGapOnlineProtocol, AirGapV3SerializerCompanion, ProtocolConfiguration } from '@airgap/module-kit';
|
|
3
3
|
import { AeternityProtocolNetwork } from '../types/protocol';
|
|
4
|
-
|
|
4
|
+
type SupportedProtocols = MainProtocolSymbols.AE;
|
|
5
5
|
export declare class AeternityModule implements AirGapModule<{
|
|
6
6
|
Protocols: SupportedProtocols;
|
|
7
7
|
ProtocolNetwork: AeternityProtocolNetwork;
|
|
@@ -1,107 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.AeternityModule = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
_a[coinlib_core_1.MainProtocolSymbols.AE] = new module_kit_1.ModuleNetworkRegistry({
|
|
4
|
+
const coinlib_core_1 = require("@airgap/coinlib-core");
|
|
5
|
+
const errors_1 = require("@airgap/coinlib-core/errors");
|
|
6
|
+
const module_kit_1 = require("@airgap/module-kit");
|
|
7
|
+
const AeternityBlockExplorer_1 = require("../block-explorer/AeternityBlockExplorer");
|
|
8
|
+
const AeternityProtocol_1 = require("../protocol/AeternityProtocol");
|
|
9
|
+
const serializer_companion_1 = require("../serializer/v3/serializer-companion");
|
|
10
|
+
class AeternityModule {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.networkRegistries = {
|
|
13
|
+
[coinlib_core_1.MainProtocolSymbols.AE]: new module_kit_1.ModuleNetworkRegistry({
|
|
51
14
|
supportedNetworks: [AeternityProtocol_1.AETERNITY_MAINNET_PROTOCOL_NETWORK]
|
|
52
|
-
})
|
|
53
|
-
|
|
15
|
+
})
|
|
16
|
+
};
|
|
54
17
|
this.supportedProtocols = (0, module_kit_1.createSupportedProtocols)(this.networkRegistries);
|
|
55
18
|
}
|
|
56
|
-
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
var _a;
|
|
78
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
-
var network;
|
|
80
|
-
return __generator(this, function (_b) {
|
|
81
|
-
network = typeof networkOrId === 'object' ? networkOrId : (_a = this.networkRegistries[identifier]) === null || _a === void 0 ? void 0 : _a.findNetwork(networkOrId);
|
|
82
|
-
if (network === undefined) {
|
|
83
|
-
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Block Explorer network not supported.');
|
|
84
|
-
}
|
|
85
|
-
return [2 /*return*/, new AeternityBlockExplorer_1.AeternityBlockExplorer(network.blockExplorerUrl)];
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
};
|
|
89
|
-
AeternityModule.prototype.createV3SerializerCompanion = function () {
|
|
90
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
91
|
-
return __generator(this, function (_a) {
|
|
92
|
-
return [2 /*return*/, new serializer_companion_1.AeternityV3SerializerCompanion()];
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
};
|
|
96
|
-
AeternityModule.prototype.createProtocol = function (identifier, network) {
|
|
19
|
+
async createOfflineProtocol(identifier) {
|
|
20
|
+
return this.createProtocol(identifier);
|
|
21
|
+
}
|
|
22
|
+
async createOnlineProtocol(identifier, networkOrId) {
|
|
23
|
+
const network = typeof networkOrId === 'object' ? networkOrId : this.networkRegistries[identifier]?.findNetwork(networkOrId);
|
|
24
|
+
if (network === undefined) {
|
|
25
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Protocol network not supported.');
|
|
26
|
+
}
|
|
27
|
+
return this.createProtocol(identifier, network);
|
|
28
|
+
}
|
|
29
|
+
async createBlockExplorer(identifier, networkOrId) {
|
|
30
|
+
const network = typeof networkOrId === 'object' ? networkOrId : this.networkRegistries[identifier]?.findNetwork(networkOrId);
|
|
31
|
+
if (network === undefined) {
|
|
32
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Block Explorer network not supported.');
|
|
33
|
+
}
|
|
34
|
+
return new AeternityBlockExplorer_1.AeternityBlockExplorer(network.blockExplorerUrl);
|
|
35
|
+
}
|
|
36
|
+
async createV3SerializerCompanion() {
|
|
37
|
+
return new serializer_companion_1.AeternityV3SerializerCompanion();
|
|
38
|
+
}
|
|
39
|
+
createProtocol(identifier, network) {
|
|
97
40
|
switch (identifier) {
|
|
98
41
|
case coinlib_core_1.MainProtocolSymbols.AE:
|
|
99
|
-
return (0, AeternityProtocol_1.createAeternityProtocol)({ network
|
|
42
|
+
return (0, AeternityProtocol_1.createAeternityProtocol)({ network });
|
|
100
43
|
default:
|
|
101
|
-
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY,
|
|
44
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, `Protocol ${identifier} not supported.`);
|
|
102
45
|
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
}());
|
|
46
|
+
}
|
|
47
|
+
}
|
|
106
48
|
exports.AeternityModule = AeternityModule;
|
|
107
49
|
//# sourceMappingURL=AeternityModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AeternityModule.js","sourceRoot":"","sources":["../../../src/v1/module/AeternityModule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AeternityModule.js","sourceRoot":"","sources":["../../../src/v1/module/AeternityModule.ts"],"names":[],"mappings":";;;AAAA,uDAAkE;AAClE,wDAAqE;AACrE,mDAW2B;AAE3B,qFAAiF;AACjF,qEAA2G;AAC3G,gFAAsF;AAKtF,MAAa,eAAe;IAA5B;QACmB,sBAAiB,GAAsD;YACtF,CAAC,kCAAmB,CAAC,EAAE,CAAC,EAAE,IAAI,kCAAqB,CAAC;gBAClD,iBAAiB,EAAE,CAAC,sDAAkC,CAAC;aACxD,CAAC;SACH,CAAA;QACe,uBAAkB,GAAsD,IAAA,qCAAwB,EAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;IA8C1I,CAAC;IA5CQ,KAAK,CAAC,qBAAqB,CAAC,UAA8B;QAC/D,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAA;IACxC,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAC/B,UAA8B,EAC9B,WAA+C;QAE/C,MAAM,OAAO,GACX,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,WAAW,CAAC,CAAA;QAE9G,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,SAAS,EAAE,iCAAiC,CAAC,CAAA;QACxF,CAAC;QAED,OAAO,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;IACjD,CAAC;IAEM,KAAK,CAAC,mBAAmB,CAC9B,UAA8B,EAC9B,WAA+C;QAE/C,MAAM,OAAO,GACX,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,EAAE,WAAW,CAAC,WAAW,CAAC,CAAA;QAE9G,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,SAAS,EAAE,uCAAuC,CAAC,CAAA;QAC9F,CAAC;QAED,OAAO,IAAI,+CAAsB,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAC7D,CAAC;IAEM,KAAK,CAAC,2BAA2B;QACtC,OAAO,IAAI,qDAA8B,EAAE,CAAA;IAC7C,CAAC;IAEO,cAAc,CAAC,UAA8B,EAAE,OAAyB;QAC9E,QAAQ,UAAU,EAAE,CAAC;YACnB,KAAK,kCAAmB,CAAC,EAAE;gBACzB,OAAO,IAAA,2CAAuB,EAAC,EAAE,OAAO,EAAE,CAAC,CAAA;YAC7C;gBACE,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,SAAS,EAAE,YAAY,UAAU,iBAAiB,CAAC,CAAA;QAChG,CAAC;IACH,CAAC;CACF;AApDD,0CAoDC"}
|
package/v1/module.js
CHANGED
|
@@ -14,11 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.create =
|
|
18
|
-
|
|
17
|
+
exports.create = create;
|
|
18
|
+
const AeternityModule_1 = require("./module/AeternityModule");
|
|
19
19
|
__exportStar(require("./index"), exports);
|
|
20
20
|
function create() {
|
|
21
21
|
return new AeternityModule_1.AeternityModule();
|
|
22
22
|
}
|
|
23
|
-
exports.create = create;
|
|
24
23
|
//# sourceMappingURL=module.js.map
|
package/v1/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/v1/module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/v1/module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAKA,wBAEC;AAND,8DAA0D;AAE1D,0CAAuB;AAEvB,SAAgB,MAAM;IACpB,OAAO,IAAI,iCAAe,EAAE,CAAA;AAC9B,CAAC"}
|
|
@@ -1,95 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
3
|
exports.AeternityCryptoClient = void 0;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
4
|
+
const errors_1 = require("@airgap/coinlib-core/errors");
|
|
5
|
+
const coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
|
|
6
|
+
const Ed25519CryptoClient_1 = require("@airgap/coinlib-core/protocols/Ed25519CryptoClient");
|
|
7
|
+
const ed25519_1 = require("@stablelib/ed25519");
|
|
8
|
+
const personalMessageToBinary = (message) => {
|
|
9
|
+
const prefix = Buffer.from('Æternity Signed Message:\n', 'utf8');
|
|
10
|
+
const messageBuffer = Buffer.from(message, 'utf8');
|
|
62
11
|
if (messageBuffer.length >= 0xfd) {
|
|
63
12
|
throw new errors_1.InvalidValueError(coinlib_error_1.Domain.AETERNITY, 'message too long');
|
|
64
13
|
}
|
|
65
14
|
return Buffer.concat([Buffer.from([prefix.length]), prefix, Buffer.from([messageBuffer.length]), messageBuffer]);
|
|
66
15
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
16
|
+
class AeternityCryptoClient extends Ed25519CryptoClient_1.Ed25519CryptoClient {
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
}
|
|
20
|
+
async signMessage(message, keypair) {
|
|
21
|
+
const messageBuffer = personalMessageToBinary(message);
|
|
22
|
+
const rawSignature = (0, ed25519_1.sign)(Buffer.from(keypair.privateKey, 'hex'), messageBuffer);
|
|
23
|
+
return Buffer.from(rawSignature).toString('hex');
|
|
24
|
+
}
|
|
25
|
+
async verifyMessage(message, signature, publicKey) {
|
|
26
|
+
const rawSignature = Buffer.from(signature, 'hex');
|
|
27
|
+
const messageBuffer = personalMessageToBinary(message);
|
|
28
|
+
return (0, ed25519_1.verify)(Buffer.from(publicKey, 'hex'), messageBuffer, rawSignature);
|
|
71
29
|
}
|
|
72
|
-
|
|
73
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
74
|
-
var messageBuffer, rawSignature;
|
|
75
|
-
return __generator(this, function (_a) {
|
|
76
|
-
messageBuffer = personalMessageToBinary(message);
|
|
77
|
-
rawSignature = (0, ed25519_1.sign)(Buffer.from(keypair.privateKey, 'hex'), messageBuffer);
|
|
78
|
-
return [2 /*return*/, Buffer.from(rawSignature).toString('hex')];
|
|
79
|
-
});
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
AeternityCryptoClient.prototype.verifyMessage = function (message, signature, publicKey) {
|
|
83
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
84
|
-
var rawSignature, messageBuffer;
|
|
85
|
-
return __generator(this, function (_a) {
|
|
86
|
-
rawSignature = Buffer.from(signature, 'hex');
|
|
87
|
-
messageBuffer = personalMessageToBinary(message);
|
|
88
|
-
return [2 /*return*/, (0, ed25519_1.verify)(Buffer.from(publicKey, 'hex'), messageBuffer, rawSignature)];
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
return AeternityCryptoClient;
|
|
93
|
-
}(Ed25519CryptoClient_1.Ed25519CryptoClient));
|
|
30
|
+
}
|
|
94
31
|
exports.AeternityCryptoClient = AeternityCryptoClient;
|
|
95
32
|
//# sourceMappingURL=AeternityCryptoClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AeternityCryptoClient.js","sourceRoot":"","sources":["../../../src/v1/protocol/AeternityCryptoClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AeternityCryptoClient.js","sourceRoot":"","sources":["../../../src/v1/protocol/AeternityCryptoClient.ts"],"names":[],"mappings":";;;AAAA,wDAA+D;AAC/D,6EAAkE;AAClE,4FAAwF;AACxF,gDAAiD;AAEjD,MAAM,uBAAuB,GAAG,CAAC,OAAe,EAAU,EAAE;IAC1D,MAAM,MAAM,GAAW,MAAM,CAAC,IAAI,CAAC,6BAA6B,EAAE,MAAM,CAAC,CAAA;IACzE,MAAM,aAAa,GAAW,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAC1D,IAAI,aAAa,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;QACjC,MAAM,IAAI,0BAAiB,CAAC,sBAAM,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAA;IACnE,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC,CAAA;AAClH,CAAC,CAAA;AAED,MAAa,qBAAsB,SAAQ,yCAAmB;IAC5D;QACE,KAAK,EAAE,CAAA;IACT,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,OAAe,EAAE,OAA+B;QACvE,MAAM,aAAa,GAAW,uBAAuB,CAAC,OAAO,CAAC,CAAA;QAC9D,MAAM,YAAY,GAAe,IAAA,cAAI,EAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,EAAE,aAAa,CAAC,CAAA;QAE5F,OAAO,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IAClD,CAAC;IAEM,KAAK,CAAC,aAAa,CAAC,OAAe,EAAE,SAAiB,EAAE,SAAiB;QAC9E,MAAM,YAAY,GAAW,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;QAC1D,MAAM,aAAa,GAAW,uBAAuB,CAAC,OAAO,CAAC,CAAA;QAE9D,OAAO,IAAA,gBAAM,EAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,aAAa,EAAE,YAAY,CAAC,CAAA;IAC3E,CAAC;CACF;AAlBD,sDAkBC"}
|