@airgap/aeternity 0.13.7-beta.22 → 0.13.7-beta.26

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.
Files changed (105) hide show
  1. package/airgap-coinlib-aeternity.min.js +16507 -4310
  2. package/index.d.ts +1 -8
  3. package/index.js +15 -11
  4. package/index.js.map +1 -1
  5. package/package.json +3 -1
  6. package/v0/index.d.ts +8 -0
  7. package/v0/index.js +24 -0
  8. package/v0/index.js.map +1 -0
  9. package/{protocol → v0/protocol}/AeternityAddress.d.ts +0 -0
  10. package/{protocol → v0/protocol}/AeternityAddress.js +6 -2
  11. package/v0/protocol/AeternityAddress.js.map +1 -0
  12. package/{protocol → v0/protocol}/AeternityCryptoClient.d.ts +0 -0
  13. package/{protocol → v0/protocol}/AeternityCryptoClient.js +4 -2
  14. package/v0/protocol/AeternityCryptoClient.js.map +1 -0
  15. package/{protocol → v0/protocol}/AeternityProtocol.d.ts +0 -0
  16. package/{protocol → v0/protocol}/AeternityProtocol.js +65 -37
  17. package/v0/protocol/AeternityProtocol.js.map +1 -0
  18. package/{protocol → v0/protocol}/AeternityProtocolOptions.d.ts +0 -0
  19. package/{protocol → v0/protocol}/AeternityProtocolOptions.js +4 -2
  20. package/v0/protocol/AeternityProtocolOptions.js.map +1 -0
  21. package/{protocol → v0/protocol}/AeternityTypes.d.ts +3 -1
  22. package/{protocol → v0/protocol}/AeternityTypes.js +0 -0
  23. package/v0/protocol/AeternityTypes.js.map +1 -0
  24. package/v0/serializer/schemas/v2/transaction-sign-request-aeternity.json +32 -0
  25. package/v0/serializer/schemas/v2/transaction-sign-response-aeternity.json +19 -0
  26. package/v0/serializer/schemas/v3/transaction-sign-request-aeternity.json +32 -0
  27. package/v0/serializer/schemas/v3/transaction-sign-response-aeternity.json +19 -0
  28. package/v0/serializer/validators/transaction-validator.d.ts +15 -0
  29. package/v0/serializer/validators/transaction-validator.js +116 -0
  30. package/v0/serializer/validators/transaction-validator.js.map +1 -0
  31. package/v0/serializer/validators/validators.d.ts +1 -0
  32. package/v0/serializer/validators/validators.js +103 -0
  33. package/v0/serializer/validators/validators.js.map +1 -0
  34. package/v0/types/signed-transaction-aeternity.d.ts +5 -0
  35. package/{types → v0/types}/signed-transaction-aeternity.js +0 -0
  36. package/v0/types/signed-transaction-aeternity.js.map +1 -0
  37. package/{types → v0/types}/transaction-aeternity.d.ts +0 -0
  38. package/{types → v0/types}/transaction-aeternity.js +0 -0
  39. package/v0/types/transaction-aeternity.js.map +1 -0
  40. package/v0/types/unsigned-transaction-aeternity.d.ts +9 -0
  41. package/{types → v0/types}/unsigned-transaction-aeternity.js +0 -0
  42. package/v0/types/unsigned-transaction-aeternity.js.map +1 -0
  43. package/v1/block-explorer/AeternityBlockExplorer.d.ts +9 -0
  44. package/v1/block-explorer/AeternityBlockExplorer.js +74 -0
  45. package/v1/block-explorer/AeternityBlockExplorer.js.map +1 -0
  46. package/v1/data/AeternityAddress.d.ts +8 -0
  47. package/v1/data/AeternityAddress.js +23 -0
  48. package/v1/data/AeternityAddress.js.map +1 -0
  49. package/v1/index.d.ts +12 -0
  50. package/v1/index.js +11 -0
  51. package/v1/index.js.map +1 -0
  52. package/v1/module/AeternityModule.d.ts +8 -0
  53. package/v1/module/AeternityModule.js +86 -0
  54. package/v1/module/AeternityModule.js.map +1 -0
  55. package/v1/protocol/AeternityCryptoClient.d.ts +8 -0
  56. package/v1/protocol/AeternityCryptoClient.js +95 -0
  57. package/v1/protocol/AeternityCryptoClient.js.map +1 -0
  58. package/v1/protocol/AeternityProtocol.d.ts +50 -0
  59. package/v1/protocol/AeternityProtocol.js +603 -0
  60. package/v1/protocol/AeternityProtocol.js.map +1 -0
  61. package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +7 -0
  62. package/v1/serializer/v3/schemas/converter/transaction-converter.js +21 -0
  63. package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -0
  64. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-aeternity.d.ts +4 -0
  65. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-aeternity.js +3 -0
  66. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-aeternity.js.map +1 -0
  67. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-aeternity.d.ts +3 -0
  68. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-aeternity.js +3 -0
  69. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-aeternity.js.map +1 -0
  70. package/v1/serializer/v3/schemas/generated/transaction-sign-request-aeternity.json +39 -0
  71. package/v1/serializer/v3/schemas/generated/transaction-sign-response-aeternity.json +19 -0
  72. package/v1/serializer/v3/validators/transaction-validator.d.ts +10 -0
  73. package/v1/serializer/v3/validators/transaction-validator.js +100 -0
  74. package/v1/serializer/v3/validators/transaction-validator.js.map +1 -0
  75. package/v1/serializer/v3/validators/validators.d.ts +5 -0
  76. package/v1/serializer/v3/validators/validators.js +106 -0
  77. package/v1/serializer/v3/validators/validators.js.map +1 -0
  78. package/v1/types/protocol.d.ts +8 -0
  79. package/v1/types/protocol.js +3 -0
  80. package/v1/types/protocol.js.map +1 -0
  81. package/v1/types/transaction.d.ts +11 -0
  82. package/v1/types/transaction.js +3 -0
  83. package/v1/types/transaction.js.map +1 -0
  84. package/v1/utils/convert.d.ts +3 -0
  85. package/v1/utils/convert.js +57 -0
  86. package/v1/utils/convert.js.map +1 -0
  87. package/v1/utils/key.d.ts +3 -0
  88. package/v1/utils/key.js +33 -0
  89. package/v1/utils/key.js.map +1 -0
  90. package/v1/utils/signature.d.ts +2 -0
  91. package/v1/utils/signature.js +24 -0
  92. package/v1/utils/signature.js.map +1 -0
  93. package/v1/utils/transaction.d.ts +3 -0
  94. package/v1/utils/transaction.js +56 -0
  95. package/v1/utils/transaction.js.map +1 -0
  96. package/protocol/AeternityAddress.js.map +0 -1
  97. package/protocol/AeternityCryptoClient.js.map +0 -1
  98. package/protocol/AeternityProtocol.js.map +0 -1
  99. package/protocol/AeternityProtocolOptions.js.map +0 -1
  100. package/protocol/AeternityTypes.js.map +0 -1
  101. package/types/signed-transaction-aeternity.d.ts +0 -5
  102. package/types/signed-transaction-aeternity.js.map +0 -1
  103. package/types/transaction-aeternity.js.map +0 -1
  104. package/types/unsigned-transaction-aeternity.d.ts +0 -9
  105. package/types/unsigned-transaction-aeternity.js.map +0 -1
@@ -0,0 +1,116 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.AeternityTransactionValidatorFactoryV2 = exports.AeternityTransactionValidatorFactory = exports.AeternityTransactionValidator = void 0;
40
+ // tslint:disable: max-classes-per-file
41
+ var validate_1 = require("@airgap/coinlib-core/dependencies/src/validate.js-0.13.1/validate");
42
+ var serializer_1 = require("@airgap/serializer");
43
+ var unsignedTransactionConstraints = {
44
+ transaction: {
45
+ presence: { allowEmpty: false },
46
+ type: 'String',
47
+ isValidAeternityTx: true
48
+ },
49
+ networkId: {
50
+ presence: { allowEmpty: false },
51
+ type: 'String',
52
+ isMainNet: true
53
+ }
54
+ };
55
+ var signedTransactionConstraints = {
56
+ transaction: {
57
+ presence: { allowEmpty: false },
58
+ type: 'String',
59
+ isValidAeternityTx: true
60
+ },
61
+ accountIdentifier: {
62
+ presence: { allowEmpty: false },
63
+ type: 'String'
64
+ }
65
+ };
66
+ var success = function () { return undefined; };
67
+ var error = function (errors) { return errors; };
68
+ var AeternityTransactionValidator = /** @class */ (function () {
69
+ function AeternityTransactionValidator(version) {
70
+ if (version === void 0) { version = 'v3'; }
71
+ this.version = version;
72
+ }
73
+ AeternityTransactionValidator.prototype.validateUnsignedTransaction = function (unsignedTx) {
74
+ return __awaiter(this, void 0, void 0, function () {
75
+ var rawTx;
76
+ return __generator(this, function (_a) {
77
+ rawTx = unsignedTx.transaction;
78
+ if (this.version === 'v3') {
79
+ (0, serializer_1.validateSyncScheme)({});
80
+ }
81
+ else {
82
+ (0, serializer_1.validateSyncSchemeV2)({});
83
+ }
84
+ return [2 /*return*/, (0, validate_1.async)(rawTx, unsignedTransactionConstraints).then(success, error)];
85
+ });
86
+ });
87
+ };
88
+ AeternityTransactionValidator.prototype.validateSignedTransaction = function (signedTx) {
89
+ return __awaiter(this, void 0, void 0, function () {
90
+ return __generator(this, function (_a) {
91
+ return [2 /*return*/, (0, validate_1.async)(signedTx, signedTransactionConstraints).then(success, error)];
92
+ });
93
+ });
94
+ };
95
+ return AeternityTransactionValidator;
96
+ }());
97
+ exports.AeternityTransactionValidator = AeternityTransactionValidator;
98
+ var AeternityTransactionValidatorFactory = /** @class */ (function () {
99
+ function AeternityTransactionValidatorFactory() {
100
+ }
101
+ AeternityTransactionValidatorFactory.prototype.create = function () {
102
+ return new AeternityTransactionValidator('v3');
103
+ };
104
+ return AeternityTransactionValidatorFactory;
105
+ }());
106
+ exports.AeternityTransactionValidatorFactory = AeternityTransactionValidatorFactory;
107
+ var AeternityTransactionValidatorFactoryV2 = /** @class */ (function () {
108
+ function AeternityTransactionValidatorFactoryV2() {
109
+ }
110
+ AeternityTransactionValidatorFactoryV2.prototype.create = function () {
111
+ return new AeternityTransactionValidator('v2');
112
+ };
113
+ return AeternityTransactionValidatorFactoryV2;
114
+ }());
115
+ exports.AeternityTransactionValidatorFactoryV2 = AeternityTransactionValidatorFactoryV2;
116
+ //# sourceMappingURL=transaction-validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-validator.js","sourceRoot":"","sources":["../../../../src/v0/serializer/validators/transaction-validator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAuC;AACvC,8FAAyF;AACzF,iDAO2B;AAM3B,IAAM,8BAA8B,GAAG;IACrC,WAAW,EAAE;QACX,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EAAE,QAAQ;QACd,kBAAkB,EAAE,IAAI;KACzB;IACD,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,IAAI;KAChB;CACF,CAAA;AACD,IAAM,4BAA4B,GAAG;IACnC,WAAW,EAAE;QACX,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EAAE,QAAQ;QACd,kBAAkB,EAAE,IAAI;KACzB;IACD,iBAAiB,EAAE;QACjB,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EAAE,QAAQ;KACf;CACF,CAAA;AACD,IAAM,OAAO,GAAG,cAAM,OAAA,SAAS,EAAT,CAAS,CAAA;AAC/B,IAAM,KAAK,GAAG,UAAC,MAAM,IAAK,OAAA,MAAM,EAAN,CAAM,CAAA;AAEhC;IACE,uCAA6B,OAA2B;QAA3B,wBAAA,EAAA,cAA2B;QAA3B,YAAO,GAAP,OAAO,CAAoB;IAAG,CAAC;IAE/C,mEAA2B,GAAxC,UAAyC,UAAwC;;;;gBACzE,KAAK,GAA4B,UAAU,CAAC,WAAW,CAAA;gBAE7D,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE;oBACzB,IAAA,+BAAkB,EAAC,EAAE,CAAC,CAAA;iBACvB;qBAAM;oBACL,IAAA,iCAAoB,EAAC,EAAE,CAAC,CAAA;iBACzB;gBAED,sBAAO,IAAA,gBAAK,EAAC,KAAK,EAAE,8BAA8B,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,EAAA;;;KACzE;IACY,iEAAyB,GAAtC,UAAuC,QAAoC;;;gBACzE,sBAAO,IAAA,gBAAK,EAAC,QAAQ,EAAE,4BAA4B,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,EAAA;;;KAC1E;IACH,oCAAC;AAAD,CAAC,AAjBD,IAiBC;AAjBY,sEAA6B;AAmB1C;IAAA;IAIA,CAAC;IAHQ,qDAAM,GAAb;QACE,OAAO,IAAI,6BAA6B,CAAC,IAAI,CAAC,CAAA;IAChD,CAAC;IACH,2CAAC;AAAD,CAAC,AAJD,IAIC;AAJY,oFAAoC;AAMjD;IAAA;IAIA,CAAC;IAHQ,uDAAM,GAAb;QACE,OAAO,IAAI,6BAA6B,CAAC,IAAI,CAAC,CAAA;IAChD,CAAC;IACH,6CAAC;AAAD,CAAC,AAJD,IAIC;AAJY,wFAAsC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,103 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var validate_1 = require("@airgap/coinlib-core/dependencies/src/validate.js-0.13.1/validate");
43
+ var base64Check_1 = __importDefault(require("@airgap/coinlib-core/utils/base64Check"));
44
+ var AeternityProtocol_1 = require("../../protocol/AeternityProtocol");
45
+ validate_1.validators.isMainNet = function (value) {
46
+ // allow empty values by default (needs to be checked by "presence" check)
47
+ if (value === null || typeof value === 'undefined') {
48
+ return null;
49
+ }
50
+ if (value !== 'ae_mainnet') {
51
+ return 'is not on mainnet';
52
+ }
53
+ return null;
54
+ };
55
+ validate_1.validators.isValidAeternityTx = function (transaction) {
56
+ // allow empty values by default (needs to be checked by "presence" check)
57
+ if (transaction === null || typeof transaction === 'undefined') {
58
+ return null;
59
+ }
60
+ if (typeof transaction === 'string' && !transaction.startsWith('tx_')) {
61
+ return 'invalid tx format';
62
+ }
63
+ else if (typeof transaction === 'string') {
64
+ try {
65
+ base64Check_1.default.decode(transaction.replace('tx_', ''));
66
+ return null;
67
+ }
68
+ catch (error) {
69
+ return "isn't base64 encoded";
70
+ }
71
+ }
72
+ else {
73
+ return "isn't a string";
74
+ }
75
+ };
76
+ validate_1.validators.isValidAeternityAccount = function (accountIdentifier) {
77
+ return new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
78
+ var protocol, error_1;
79
+ return __generator(this, function (_a) {
80
+ switch (_a.label) {
81
+ case 0:
82
+ if (accountIdentifier === null || typeof accountIdentifier === 'undefined') {
83
+ reject();
84
+ }
85
+ _a.label = 1;
86
+ case 1:
87
+ _a.trys.push([1, 3, , 4]);
88
+ protocol = new AeternityProtocol_1.AeternityProtocol();
89
+ return [4 /*yield*/, protocol.getTransactionsFromPublicKey(accountIdentifier, 1)];
90
+ case 2:
91
+ _a.sent();
92
+ resolve();
93
+ return [3 /*break*/, 4];
94
+ case 3:
95
+ error_1 = _a.sent();
96
+ reject('not a valid Aeternity account');
97
+ return [3 /*break*/, 4];
98
+ case 4: return [2 /*return*/];
99
+ }
100
+ });
101
+ }); });
102
+ };
103
+ //# sourceMappingURL=validators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../../src/v0/serializer/validators/validators.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8FAA8F;AAC9F,uFAA8D;AAE9D,sEAAoE;AAEpE,qBAAU,CAAC,SAAS,GAAG,UAAC,KAAc;IACpC,0EAA0E;IAC1E,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE;QAClD,OAAO,IAAI,CAAA;KACZ;IACD,IAAI,KAAK,KAAK,YAAY,EAAE;QAC1B,OAAO,mBAAmB,CAAA;KAC3B;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,qBAAU,CAAC,kBAAkB,GAAG,UAAC,WAAoB;IACnD,0EAA0E;IAC1E,IAAI,WAAW,KAAK,IAAI,IAAI,OAAO,WAAW,KAAK,WAAW,EAAE;QAC9D,OAAO,IAAI,CAAA;KACZ;IAED,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE;QACrE,OAAO,mBAAmB,CAAA;KAC3B;SAAM,IAAI,OAAO,WAAW,KAAK,QAAQ,EAAE;QAC1C,IAAI;YACF,qBAAS,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAA;YAEhD,OAAO,IAAI,CAAA;SACZ;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,sBAAsB,CAAA;SAC9B;KACF;SAAM;QACL,OAAO,gBAAgB,CAAA;KACxB;AACH,CAAC,CAAA;AAED,qBAAU,CAAC,uBAAuB,GAAG,UAAC,iBAAyB;IAC7D,OAAO,IAAI,OAAO,CAAO,UAAO,OAAO,EAAE,MAAM;;;;;oBAC7C,IAAI,iBAAiB,KAAK,IAAI,IAAI,OAAO,iBAAiB,KAAK,WAAW,EAAE;wBAC1E,MAAM,EAAE,CAAA;qBACT;;;;oBAEO,QAAQ,GAAG,IAAI,qCAAiB,EAAE,CAAA;oBACxC,qBAAM,QAAQ,CAAC,4BAA4B,CAAC,iBAAiB,EAAE,CAAC,CAAC,EAAA;;oBAAjE,SAAiE,CAAA;oBACjE,OAAO,EAAE,CAAA;;;;oBAET,MAAM,CAAC,+BAA+B,CAAC,CAAA;;;;;SAE1C,CAAC,CAAA;AACJ,CAAC,CAAA"}
@@ -0,0 +1,5 @@
1
+ import { TransactionSignResponse, TransactionSignResponseV2 } from '@airgap/serializer';
2
+ export interface SignedAeternityTransaction extends TransactionSignResponse, TransactionSignResponseV2 {
3
+ accountIdentifier: string;
4
+ transaction: string;
5
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signed-transaction-aeternity.js","sourceRoot":"","sources":["../../../src/v0/types/signed-transaction-aeternity.ts"],"names":[],"mappings":""}
File without changes
File without changes
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-aeternity.js","sourceRoot":"","sources":["../../../src/v0/types/transaction-aeternity.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import { TransactionSignRequest, TransactionSignRequestV2 } from '@airgap/serializer';
2
+ interface RawAeternityTransaction {
3
+ networkId: string;
4
+ transaction: string;
5
+ }
6
+ export interface UnsignedAeternityTransaction extends TransactionSignRequest, TransactionSignRequestV2 {
7
+ transaction: RawAeternityTransaction;
8
+ }
9
+ export {};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unsigned-transaction-aeternity.js","sourceRoot":"","sources":["../../../src/v0/types/unsigned-transaction-aeternity.ts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import { AirGapBlockExplorer, BlockExplorerMetadata } from '@airgap/module-kit';
2
+ export declare class AeternityBlockExplorer implements AirGapBlockExplorer {
3
+ readonly url: string;
4
+ constructor(url?: string);
5
+ private readonly metadata;
6
+ getMetadata(): Promise<BlockExplorerMetadata>;
7
+ createAddressUrl(address: string): Promise<string>;
8
+ createTransactionUrl(transactionId: string): Promise<string>;
9
+ }
@@ -0,0 +1,74 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.AeternityBlockExplorer = void 0;
40
+ var BLOCK_EXPLORER_URL = 'https://explorer.aeternity.io';
41
+ var AeternityBlockExplorer = /** @class */ (function () {
42
+ function AeternityBlockExplorer(url) {
43
+ if (url === void 0) { url = BLOCK_EXPLORER_URL; }
44
+ this.url = url;
45
+ this.metadata = {
46
+ name: 'æternity Explorer',
47
+ url: this.url
48
+ };
49
+ }
50
+ AeternityBlockExplorer.prototype.getMetadata = function () {
51
+ return __awaiter(this, void 0, void 0, function () {
52
+ return __generator(this, function (_a) {
53
+ return [2 /*return*/, this.metadata];
54
+ });
55
+ });
56
+ };
57
+ AeternityBlockExplorer.prototype.createAddressUrl = function (address) {
58
+ return __awaiter(this, void 0, void 0, function () {
59
+ return __generator(this, function (_a) {
60
+ return [2 /*return*/, "".concat(this.url, "/account/transactions/").concat(address)];
61
+ });
62
+ });
63
+ };
64
+ AeternityBlockExplorer.prototype.createTransactionUrl = function (transactionId) {
65
+ return __awaiter(this, void 0, void 0, function () {
66
+ return __generator(this, function (_a) {
67
+ return [2 /*return*/, "".concat(this.url, "/transactions/").concat(transactionId)];
68
+ });
69
+ });
70
+ };
71
+ return AeternityBlockExplorer;
72
+ }());
73
+ exports.AeternityBlockExplorer = AeternityBlockExplorer;
74
+ //# sourceMappingURL=AeternityBlockExplorer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AeternityBlockExplorer.js","sourceRoot":"","sources":["../../../src/v1/block-explorer/AeternityBlockExplorer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAM,kBAAkB,GAAW,+BAA+B,CAAA;AAElE;IACE,gCAAmC,GAAgC;QAAhC,oBAAA,EAAA,wBAAgC;QAAhC,QAAG,GAAH,GAAG,CAA6B;QAElD,aAAQ,GAA0B;YACjD,IAAI,EAAE,mBAAmB;YACzB,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAA;IALqE,CAAC;IAO1D,4CAAW,GAAxB;;;gBACE,sBAAO,IAAI,CAAC,QAAQ,EAAA;;;KACrB;IAEY,iDAAgB,GAA7B,UAA8B,OAAe;;;gBAC3C,sBAAO,UAAG,IAAI,CAAC,GAAG,mCAAyB,OAAO,CAAE,EAAA;;;KACrD;IACY,qDAAoB,GAAjC,UAAkC,aAAqB;;;gBACrD,sBAAO,UAAG,IAAI,CAAC,GAAG,2BAAiB,aAAa,CAAE,EAAA;;;KACnD;IACH,6BAAC;AAAD,CAAC,AAlBD,IAkBC;AAlBY,wDAAsB"}
@@ -0,0 +1,8 @@
1
+ import { PublicKey } from '@airgap/module-kit';
2
+ export declare class AeternityAddress {
3
+ private readonly value;
4
+ private constructor();
5
+ static from(publicKey: string | PublicKey): AeternityAddress;
6
+ asString(): string;
7
+ toPublicKey(): PublicKey;
8
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AeternityAddress = void 0;
4
+ var module_kit_1 = require("@airgap/module-kit");
5
+ var key_1 = require("../utils/key");
6
+ var AeternityAddress = /** @class */ (function () {
7
+ function AeternityAddress(value) {
8
+ this.value = value;
9
+ }
10
+ AeternityAddress.from = function (publicKey) {
11
+ var _publicKey = typeof publicKey === 'string' ? (0, key_1.aePublicKey)(publicKey) : publicKey;
12
+ return new AeternityAddress((0, key_1.convertPublicKey)(_publicKey, 'encoded').value);
13
+ };
14
+ AeternityAddress.prototype.asString = function () {
15
+ return this.value;
16
+ };
17
+ AeternityAddress.prototype.toPublicKey = function () {
18
+ return (0, module_kit_1.newPublicKey)(this.value, 'encoded');
19
+ };
20
+ return AeternityAddress;
21
+ }());
22
+ exports.AeternityAddress = AeternityAddress;
23
+ //# sourceMappingURL=AeternityAddress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AeternityAddress.js","sourceRoot":"","sources":["../../../src/v1/data/AeternityAddress.ts"],"names":[],"mappings":";;;AAAA,iDAA4D;AAE5D,oCAA4D;AAE5D;IACE,0BAAqC,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;IAAG,CAAC;IAExC,qBAAI,GAAlB,UAAmB,SAA6B;QAC9C,IAAM,UAAU,GAAG,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAA,iBAAW,EAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;QAErF,OAAO,IAAI,gBAAgB,CAAC,IAAA,sBAAgB,EAAC,UAAU,EAAE,SAAS,CAAC,CAAC,KAAK,CAAC,CAAA;IAC5E,CAAC;IAEM,mCAAQ,GAAf;QACE,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IAEM,sCAAW,GAAlB;QACE,OAAO,IAAA,yBAAY,EAAC,IAAI,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;IAC5C,CAAC;IACH,uBAAC;AAAD,CAAC,AAhBD,IAgBC;AAhBY,4CAAgB"}
package/v1/index.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { AeternityBlockExplorer } from './block-explorer/AeternityBlockExplorer';
2
+ import { AeternityModule } from './module/AeternityModule';
3
+ import { AeternityProtocol, createAeternityProtocol, createAeternityProtocolOptions } from './protocol/AeternityProtocol';
4
+ import { AeternityTransactionSignRequest } from './serializer/v3/schemas/definitions/transaction-sign-request-aeternity';
5
+ import { AeternityTransactionSignResponse } from './serializer/v3/schemas/definitions/transaction-sign-response-aeternity';
6
+ import { AeternityProtocolNetwork, AeternityProtocolOptions, AeternityUnits } from './types/protocol';
7
+ import { AeternitySignedTransaction, AeternityUnsignedTransaction } from './types/transaction';
8
+ export { AeternityModule };
9
+ export { AeternityProtocol, createAeternityProtocol, createAeternityProtocolOptions };
10
+ export { AeternityBlockExplorer };
11
+ export { AeternityUnits, AeternityProtocolOptions, AeternityProtocolNetwork, AeternityUnsignedTransaction, AeternitySignedTransaction };
12
+ export { AeternityTransactionSignRequest, AeternityTransactionSignResponse };
package/v1/index.js ADDED
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AeternityBlockExplorer = exports.createAeternityProtocolOptions = exports.createAeternityProtocol = exports.AeternityModule = void 0;
4
+ var AeternityBlockExplorer_1 = require("./block-explorer/AeternityBlockExplorer");
5
+ Object.defineProperty(exports, "AeternityBlockExplorer", { enumerable: true, get: function () { return AeternityBlockExplorer_1.AeternityBlockExplorer; } });
6
+ var AeternityModule_1 = require("./module/AeternityModule");
7
+ Object.defineProperty(exports, "AeternityModule", { enumerable: true, get: function () { return AeternityModule_1.AeternityModule; } });
8
+ var AeternityProtocol_1 = require("./protocol/AeternityProtocol");
9
+ Object.defineProperty(exports, "createAeternityProtocol", { enumerable: true, get: function () { return AeternityProtocol_1.createAeternityProtocol; } });
10
+ Object.defineProperty(exports, "createAeternityProtocolOptions", { enumerable: true, get: function () { return AeternityProtocol_1.createAeternityProtocolOptions; } });
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v1/index.ts"],"names":[],"mappings":";;;AAAA,kFAAgF;AAkBvE,uGAlBA,+CAAsB,OAkBA;AAjB/B,4DAA0D;AASjD,gGATA,iCAAe,OASA;AARxB,kEAAyH;AAY7F,wGAZA,2CAAuB,OAYA;AAAE,+GAZA,kDAA8B,OAYA"}
@@ -0,0 +1,8 @@
1
+ import { AirGapBlockExplorer, AirGapModule, AirGapOfflineProtocol, AirGapOnlineProtocol, ProtocolNetwork } from '@airgap/module-kit';
2
+ export declare class AeternityModule implements AirGapModule {
3
+ private readonly networkRegistry;
4
+ supportedNetworks: Record<string, ProtocolNetwork>;
5
+ createOfflineProtocol(): Promise<AirGapOfflineProtocol | undefined>;
6
+ createOnlineProtocol(networkId?: string): Promise<AirGapOnlineProtocol | undefined>;
7
+ createBlockExplorer(networkId?: string): Promise<AirGapBlockExplorer | undefined>;
8
+ }
@@ -0,0 +1,86 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.AeternityModule = void 0;
40
+ var coinlib_core_1 = require("@airgap/coinlib-core");
41
+ var errors_1 = require("@airgap/coinlib-core/errors");
42
+ var module_kit_1 = require("@airgap/module-kit");
43
+ var AeternityBlockExplorer_1 = require("../block-explorer/AeternityBlockExplorer");
44
+ var AeternityProtocol_1 = require("../protocol/AeternityProtocol");
45
+ var AeternityModule = /** @class */ (function () {
46
+ function AeternityModule() {
47
+ this.networkRegistry = new module_kit_1.ModuleNetworkRegistry({
48
+ supportedNetworks: [AeternityProtocol_1.AETERNITY_MAINNET_PROTOCOL_NETWORK]
49
+ });
50
+ this.supportedNetworks = this.networkRegistry.supportedNetworks;
51
+ }
52
+ AeternityModule.prototype.createOfflineProtocol = function () {
53
+ return __awaiter(this, void 0, void 0, function () {
54
+ return __generator(this, function (_a) {
55
+ return [2 /*return*/, (0, AeternityProtocol_1.createAeternityProtocol)()];
56
+ });
57
+ });
58
+ };
59
+ AeternityModule.prototype.createOnlineProtocol = function (networkId) {
60
+ return __awaiter(this, void 0, void 0, function () {
61
+ var network;
62
+ return __generator(this, function (_a) {
63
+ network = this.networkRegistry.findNetwork(networkId);
64
+ if (network === undefined) {
65
+ throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Protocol network not supported.');
66
+ }
67
+ return [2 /*return*/, (0, AeternityProtocol_1.createAeternityProtocol)({ network: network })];
68
+ });
69
+ });
70
+ };
71
+ AeternityModule.prototype.createBlockExplorer = function (networkId) {
72
+ return __awaiter(this, void 0, void 0, function () {
73
+ var network;
74
+ return __generator(this, function (_a) {
75
+ network = this.networkRegistry.findNetwork(networkId);
76
+ if ((network === null || network === void 0 ? void 0 : network.type) !== 'mainnet') {
77
+ throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Block Explorer network not supported.');
78
+ }
79
+ return [2 /*return*/, new AeternityBlockExplorer_1.AeternityBlockExplorer()];
80
+ });
81
+ });
82
+ };
83
+ return AeternityModule;
84
+ }());
85
+ exports.AeternityModule = AeternityModule;
86
+ //# sourceMappingURL=AeternityModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AeternityModule.js","sourceRoot":"","sources":["../../../src/v1/module/AeternityModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA6C;AAC7C,sDAAqE;AACrE,iDAO2B;AAE3B,mFAAiF;AACjF,mEAA2G;AAE3G;IAAA;QACmB,oBAAe,GAA0B,IAAI,kCAAqB,CAAC;YAClF,iBAAiB,EAAE,CAAC,sDAAkC,CAAC;SACxD,CAAC,CAAA;QAEK,sBAAiB,GAAoC,IAAI,CAAC,eAAe,CAAC,iBAAiB,CAAA;IAuBpG,CAAC;IArBc,+CAAqB,GAAlC;;;gBACE,sBAAO,IAAA,2CAAuB,GAAE,EAAA;;;KACjC;IAEY,8CAAoB,GAAjC,UAAkC,SAAkB;;;;gBAC5C,OAAO,GAAgC,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;gBACxF,IAAI,OAAO,KAAK,SAAS,EAAE;oBACzB,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,SAAS,EAAE,iCAAiC,CAAC,CAAA;iBACvF;gBAED,sBAAO,IAAA,2CAAuB,EAAC,EAAE,OAAO,SAAA,EAAE,CAAC,EAAA;;;KAC5C;IAEY,6CAAmB,GAAhC,UAAiC,SAAkB;;;;gBAC3C,OAAO,GAAgC,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;gBACxF,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,MAAK,SAAS,EAAE;oBAC/B,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,SAAS,EAAE,uCAAuC,CAAC,CAAA;iBAC7F;gBAED,sBAAO,IAAI,+CAAsB,EAAE,EAAA;;;KACpC;IACH,sBAAC;AAAD,CAAC,AA5BD,IA4BC;AA5BY,0CAAe"}
@@ -0,0 +1,8 @@
1
+ import { Ed25519CryptoClient } from '@airgap/coinlib-core/protocols/Ed25519CryptoClient';
2
+ export declare class AeternityCryptoClient extends Ed25519CryptoClient {
3
+ constructor();
4
+ signMessage(message: string, keypair: {
5
+ privateKey: string;
6
+ }): Promise<string>;
7
+ verifyMessage(message: string, signature: string, publicKey: string): Promise<boolean>;
8
+ }
@@ -0,0 +1,95 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.AeternityCryptoClient = void 0;
55
+ var errors_1 = require("@airgap/coinlib-core/errors");
56
+ var coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
57
+ var Ed25519CryptoClient_1 = require("@airgap/coinlib-core/protocols/Ed25519CryptoClient");
58
+ var ed25519_1 = require("@stablelib/ed25519");
59
+ var personalMessageToBinary = function (message) {
60
+ var prefix = Buffer.from('‎Æternity Signed Message:\n', 'utf8');
61
+ var messageBuffer = Buffer.from(message, 'utf8');
62
+ if (messageBuffer.length >= 0xfd) {
63
+ throw new errors_1.InvalidValueError(coinlib_error_1.Domain.AETERNITY, 'message too long');
64
+ }
65
+ return Buffer.concat([Buffer.from([prefix.length]), prefix, Buffer.from([messageBuffer.length]), messageBuffer]);
66
+ };
67
+ var AeternityCryptoClient = /** @class */ (function (_super) {
68
+ __extends(AeternityCryptoClient, _super);
69
+ function AeternityCryptoClient() {
70
+ return _super.call(this) || this;
71
+ }
72
+ AeternityCryptoClient.prototype.signMessage = function (message, keypair) {
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));
94
+ exports.AeternityCryptoClient = AeternityCryptoClient;
95
+ //# sourceMappingURL=AeternityCryptoClient.js.map