@cobo/cobo-waas2 1.2.0 → 1.2.1
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/README.md +1 -1
- package/dist/ApiClient.js +1 -1
- package/dist/PreRequestScript.js +640 -0
- package/dist/model/CoboSafeDelegate.js +27 -2
- package/dist/model/ContractCallDestination.js +23 -2
- package/dist/model/ContractCallSource.js +41 -4
- package/dist/model/CreateSmartContractWalletParams.js +23 -2
- package/dist/model/CreateStakeActivityExtra.js +51 -6
- package/dist/model/CreateWalletParams.js +51 -6
- package/dist/model/CreatedWalletInfo.js +51 -6
- package/dist/model/EstimateFeeParams.js +37 -4
- package/dist/model/EstimatedFee.js +65 -8
- package/dist/model/FeeRate.js +65 -8
- package/dist/model/MessageSignDestination.js +37 -4
- package/dist/model/MessageSignSource.js +27 -2
- package/dist/model/PoolDetailsAllOfValidatorsInfo.js +20 -4
- package/dist/model/SmartContractWalletInfo.js +23 -2
- package/dist/model/StakingSource.js +41 -4
- package/dist/model/TransactionDestination.js +107 -14
- package/dist/model/TransactionFee.js +65 -8
- package/dist/model/TransactionRbfSource.js +27 -2
- package/dist/model/TransactionRequestFee.js +65 -8
- package/dist/model/TransactionResult.js +23 -2
- package/dist/model/TransactionSource.js +115 -14
- package/dist/model/TransferDestination.js +37 -4
- package/dist/model/TransferSource.js +73 -8
- package/dist/model/UpdateWalletParams.js +65 -8
- package/dist/model/WalletInfo.js +65 -8
- package/dist/model/WebhookEventData.js +37 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ For more information about the WaaS 2.0 API, see [Introduction to WaaS 2.0](http
|
|
|
15
15
|
This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
|
16
16
|
|
|
17
17
|
- API version: v2
|
|
18
|
-
- Package version: 1.2.
|
|
18
|
+
- Package version: 1.2.1
|
|
19
19
|
- Generator version: 7.6.0
|
|
20
20
|
- Build package: org.openapitools.codegen.languages.JavascriptClientCodegen
|
|
21
21
|
For more information, please visit [https://www.cobo.com/waas](https://www.cobo.com/waas)
|
package/dist/ApiClient.js
CHANGED
|
@@ -0,0 +1,640 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
4
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
6
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
7
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
8
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
9
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
10
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
11
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
12
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
13
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
14
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
15
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
16
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
18
|
+
var P = Math.pow(2n, 255n) - 19n,
|
|
19
|
+
N = Math.pow(2n, 252n) + 27742317777372353535851937790883648493n,
|
|
20
|
+
Gx = 0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,
|
|
21
|
+
Gy = 0x6666666666666666666666666666666666666666666666666666666666666658n,
|
|
22
|
+
CURVE = {
|
|
23
|
+
a: -1n,
|
|
24
|
+
d: 37095705934669439343138083508754565189542113879843219016388785533085940283555n,
|
|
25
|
+
p: P,
|
|
26
|
+
n: N,
|
|
27
|
+
h: 8,
|
|
28
|
+
Gx: Gx,
|
|
29
|
+
Gy: Gy
|
|
30
|
+
},
|
|
31
|
+
err = function err() {
|
|
32
|
+
var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
33
|
+
throw new Error(e);
|
|
34
|
+
},
|
|
35
|
+
str = function str(e) {
|
|
36
|
+
return "string" == typeof e;
|
|
37
|
+
},
|
|
38
|
+
isu8 = function isu8(e) {
|
|
39
|
+
return e instanceof Uint8Array || null != e && "object" == _typeof(e) && "Uint8Array" === e.constructor.name;
|
|
40
|
+
},
|
|
41
|
+
au8 = function au8(e, t) {
|
|
42
|
+
return !isu8(e) || "number" == typeof t && t > 0 && e.length !== t ? err("Uint8Array of valid length expected") : e;
|
|
43
|
+
},
|
|
44
|
+
u8n = function u8n(e) {
|
|
45
|
+
return new Uint8Array(e);
|
|
46
|
+
},
|
|
47
|
+
toU8 = function toU8(e, t) {
|
|
48
|
+
return au8(str(e) ? h2b(e) : u8n(au8(e)), t);
|
|
49
|
+
},
|
|
50
|
+
mod = function mod(e) {
|
|
51
|
+
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : P;
|
|
52
|
+
var n = e % t;
|
|
53
|
+
return n >= 0n ? n : t + n;
|
|
54
|
+
},
|
|
55
|
+
isPoint = function isPoint(e) {
|
|
56
|
+
return e instanceof Point ? e : err("Point expected");
|
|
57
|
+
};
|
|
58
|
+
var Point = /*#__PURE__*/function () {
|
|
59
|
+
function Point(e, t, n, o) {
|
|
60
|
+
_classCallCheck(this, Point);
|
|
61
|
+
this.ex = e, this.ey = t, this.ez = n, this.et = o;
|
|
62
|
+
}
|
|
63
|
+
return _createClass(Point, [{
|
|
64
|
+
key: "x",
|
|
65
|
+
get: function get() {
|
|
66
|
+
return this.toAffine().x;
|
|
67
|
+
}
|
|
68
|
+
}, {
|
|
69
|
+
key: "y",
|
|
70
|
+
get: function get() {
|
|
71
|
+
return this.toAffine().y;
|
|
72
|
+
}
|
|
73
|
+
}, {
|
|
74
|
+
key: "equals",
|
|
75
|
+
value: function equals(e) {
|
|
76
|
+
var t = this.ex,
|
|
77
|
+
n = this.ey,
|
|
78
|
+
o = this.ez,
|
|
79
|
+
_isPoint = isPoint(e),
|
|
80
|
+
r = _isPoint.ex,
|
|
81
|
+
s = _isPoint.ey,
|
|
82
|
+
i = _isPoint.ez,
|
|
83
|
+
a = mod(t * i),
|
|
84
|
+
d = mod(r * o),
|
|
85
|
+
c = mod(n * i),
|
|
86
|
+
u = mod(s * o);
|
|
87
|
+
return a === d && c === u;
|
|
88
|
+
}
|
|
89
|
+
}, {
|
|
90
|
+
key: "is0",
|
|
91
|
+
value: function is0() {
|
|
92
|
+
return this.equals(I);
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
key: "negate",
|
|
96
|
+
value: function negate() {
|
|
97
|
+
return new Point(mod(-this.ex), this.ey, this.ez, mod(-this.et));
|
|
98
|
+
}
|
|
99
|
+
}, {
|
|
100
|
+
key: "double",
|
|
101
|
+
value: function _double() {
|
|
102
|
+
var e = this.ex,
|
|
103
|
+
t = this.ey,
|
|
104
|
+
n = this.ez,
|
|
105
|
+
o = CURVE.a,
|
|
106
|
+
r = mod(e * e),
|
|
107
|
+
s = mod(t * t),
|
|
108
|
+
i = mod(2n * mod(n * n)),
|
|
109
|
+
a = mod(o * r),
|
|
110
|
+
d = e + t,
|
|
111
|
+
c = mod(mod(d * d) - r - s),
|
|
112
|
+
u = a + s,
|
|
113
|
+
h = u - i,
|
|
114
|
+
l = a - s,
|
|
115
|
+
y = mod(c * h),
|
|
116
|
+
m = mod(u * l),
|
|
117
|
+
f = mod(c * l),
|
|
118
|
+
b = mod(h * u);
|
|
119
|
+
return new Point(y, m, b, f);
|
|
120
|
+
}
|
|
121
|
+
}, {
|
|
122
|
+
key: "add",
|
|
123
|
+
value: function add(e) {
|
|
124
|
+
var t = this.ex,
|
|
125
|
+
n = this.ey,
|
|
126
|
+
o = this.ez,
|
|
127
|
+
r = this.et,
|
|
128
|
+
_isPoint2 = isPoint(e),
|
|
129
|
+
s = _isPoint2.ex,
|
|
130
|
+
i = _isPoint2.ey,
|
|
131
|
+
a = _isPoint2.ez,
|
|
132
|
+
d = _isPoint2.et,
|
|
133
|
+
c = CURVE.a,
|
|
134
|
+
u = CURVE.d,
|
|
135
|
+
h = mod(t * s),
|
|
136
|
+
l = mod(n * i),
|
|
137
|
+
y = mod(r * u * d),
|
|
138
|
+
m = mod(o * a),
|
|
139
|
+
f = mod((t + n) * (s + i) - h - l),
|
|
140
|
+
b = mod(m - y),
|
|
141
|
+
p = mod(m + y),
|
|
142
|
+
P = mod(l - c * h),
|
|
143
|
+
x = mod(f * b),
|
|
144
|
+
g = mod(p * P),
|
|
145
|
+
w = mod(f * P),
|
|
146
|
+
_ = mod(b * p);
|
|
147
|
+
return new Point(x, g, _, w);
|
|
148
|
+
}
|
|
149
|
+
}, {
|
|
150
|
+
key: "mul",
|
|
151
|
+
value: function mul(e) {
|
|
152
|
+
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !0;
|
|
153
|
+
if (0n === e) return !0 === t ? err("cannot multiply by 0") : I;
|
|
154
|
+
if ("bigint" == typeof e && 0n < e && e < N || err("invalid scalar, must be < L"), !t && this.is0() || 1n === e) return this;
|
|
155
|
+
if (this.equals(G)) return wNAF(e).p;
|
|
156
|
+
var n = I,
|
|
157
|
+
o = G;
|
|
158
|
+
for (var r = this; e > 0n; r = r["double"](), e >>= 1n) 1n & e ? n = n.add(r) : t && (o = o.add(r));
|
|
159
|
+
return n;
|
|
160
|
+
}
|
|
161
|
+
}, {
|
|
162
|
+
key: "multiply",
|
|
163
|
+
value: function multiply(e) {
|
|
164
|
+
return this.mul(e);
|
|
165
|
+
}
|
|
166
|
+
}, {
|
|
167
|
+
key: "clearCofactor",
|
|
168
|
+
value: function clearCofactor() {
|
|
169
|
+
return this.mul(BigInt(CURVE.h), !1);
|
|
170
|
+
}
|
|
171
|
+
}, {
|
|
172
|
+
key: "isSmallOrder",
|
|
173
|
+
value: function isSmallOrder() {
|
|
174
|
+
return this.clearCofactor().is0();
|
|
175
|
+
}
|
|
176
|
+
}, {
|
|
177
|
+
key: "isTorsionFree",
|
|
178
|
+
value: function isTorsionFree() {
|
|
179
|
+
var e = this.mul(N / 2n, !1)["double"]();
|
|
180
|
+
return e = e.add(this), e.is0();
|
|
181
|
+
}
|
|
182
|
+
}, {
|
|
183
|
+
key: "toAffine",
|
|
184
|
+
value: function toAffine() {
|
|
185
|
+
var e = this.ex,
|
|
186
|
+
t = this.ey,
|
|
187
|
+
n = this.ez;
|
|
188
|
+
if (this.equals(I)) return {
|
|
189
|
+
x: 0n,
|
|
190
|
+
y: 1n
|
|
191
|
+
};
|
|
192
|
+
var o = invert(n);
|
|
193
|
+
return 1n !== mod(n * o) && err("invalid inverse"), {
|
|
194
|
+
x: mod(e * o),
|
|
195
|
+
y: mod(t * o)
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}, {
|
|
199
|
+
key: "toRawBytes",
|
|
200
|
+
value: function toRawBytes() {
|
|
201
|
+
var _this$toAffine = this.toAffine(),
|
|
202
|
+
e = _this$toAffine.x,
|
|
203
|
+
t = _this$toAffine.y,
|
|
204
|
+
n = n2b_32LE(t);
|
|
205
|
+
return n[31] |= 1n & e ? 128 : 0, n;
|
|
206
|
+
}
|
|
207
|
+
}, {
|
|
208
|
+
key: "toHex",
|
|
209
|
+
value: function toHex() {
|
|
210
|
+
return b2h(this.toRawBytes());
|
|
211
|
+
}
|
|
212
|
+
}], [{
|
|
213
|
+
key: "fromAffine",
|
|
214
|
+
value: function fromAffine(e) {
|
|
215
|
+
return new Point(e.x, e.y, 1n, mod(e.x * e.y));
|
|
216
|
+
}
|
|
217
|
+
}, {
|
|
218
|
+
key: "fromHex",
|
|
219
|
+
value: function fromHex(e) {
|
|
220
|
+
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
|
|
221
|
+
var n = CURVE.d,
|
|
222
|
+
o = (e = toU8(e, 32)).slice(),
|
|
223
|
+
r = e[31];
|
|
224
|
+
o[31] = -129 & r;
|
|
225
|
+
var s = b2n_LE(o);
|
|
226
|
+
!t || 0n <= s && s < Math.pow(2n, 256n) || err("bad y coord 1"), t || 0n <= s && s < P || err("bad y coord 2");
|
|
227
|
+
var i = mod(s * s),
|
|
228
|
+
a = mod(i - 1n),
|
|
229
|
+
d = mod(n * i + 1n);
|
|
230
|
+
var _uvRatio = uvRatio(a, d),
|
|
231
|
+
c = _uvRatio.isValid,
|
|
232
|
+
u = _uvRatio.value;
|
|
233
|
+
c || err("bad y coordinate 3");
|
|
234
|
+
var h = 1n === (1n & u),
|
|
235
|
+
l = !!(128 & r);
|
|
236
|
+
return !t && 0n === u && l && err("bad y coord 3"), l !== h && (u = mod(-u)), new Point(u, s, 1n, mod(u * s));
|
|
237
|
+
}
|
|
238
|
+
}]);
|
|
239
|
+
}();
|
|
240
|
+
Point.BASE = new Point(Gx, Gy, 1n, mod(Gx * Gy)), Point.ZERO = new Point(0n, 1n, 1n, 0n);
|
|
241
|
+
var G = Point.BASE,
|
|
242
|
+
I = Point.ZERO,
|
|
243
|
+
padh = function padh(e, t) {
|
|
244
|
+
return e.toString(16).padStart(t, "0");
|
|
245
|
+
},
|
|
246
|
+
b2h = function b2h(e) {
|
|
247
|
+
return Array.from(e).map(function (e) {
|
|
248
|
+
return padh(e, 2);
|
|
249
|
+
}).join("");
|
|
250
|
+
},
|
|
251
|
+
h2b = function h2b(e) {
|
|
252
|
+
var t = e.length;
|
|
253
|
+
(!str(e) || t % 2) && err("hex invalid 1");
|
|
254
|
+
var n = u8n(t / 2);
|
|
255
|
+
for (var _t = 0; _t < n.length; _t++) {
|
|
256
|
+
var o = 2 * _t,
|
|
257
|
+
r = e.slice(o, o + 2),
|
|
258
|
+
s = Number.parseInt(r, 16);
|
|
259
|
+
(Number.isNaN(s) || s < 0) && err("hex invalid 2"), n[_t] = s;
|
|
260
|
+
}
|
|
261
|
+
return n;
|
|
262
|
+
},
|
|
263
|
+
n2b_32LE = function n2b_32LE(e) {
|
|
264
|
+
return h2b(padh(e, 64)).reverse();
|
|
265
|
+
},
|
|
266
|
+
b2n_LE = function b2n_LE(e) {
|
|
267
|
+
return BigInt("0x" + b2h(u8n(au8(e)).reverse()));
|
|
268
|
+
},
|
|
269
|
+
concatB = function concatB() {
|
|
270
|
+
for (var _len = arguments.length, e = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
271
|
+
e[_key] = arguments[_key];
|
|
272
|
+
}
|
|
273
|
+
var t = u8n(e.reduce(function (e, t) {
|
|
274
|
+
return e + au8(t).length;
|
|
275
|
+
}, 0));
|
|
276
|
+
var n = 0;
|
|
277
|
+
return e.forEach(function (e) {
|
|
278
|
+
t.set(e, n), n += e.length;
|
|
279
|
+
}), t;
|
|
280
|
+
},
|
|
281
|
+
invert = function invert(e) {
|
|
282
|
+
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : P;
|
|
283
|
+
(0n === e || t <= 0n) && err("no inverse n=" + e + " mod=" + t);
|
|
284
|
+
var n = mod(e, t),
|
|
285
|
+
o = t,
|
|
286
|
+
r = 0n,
|
|
287
|
+
s = 1n,
|
|
288
|
+
i = 1n,
|
|
289
|
+
a = 0n;
|
|
290
|
+
for (; 0n !== n;) {
|
|
291
|
+
var _e = o / n,
|
|
292
|
+
_t2 = o % n,
|
|
293
|
+
d = r - i * _e,
|
|
294
|
+
c = s - a * _e;
|
|
295
|
+
o = n, n = _t2, r = i, s = a, i = d, a = c;
|
|
296
|
+
}
|
|
297
|
+
return 1n === o ? mod(r, t) : err("no inverse");
|
|
298
|
+
},
|
|
299
|
+
pow2 = function pow2(e, t) {
|
|
300
|
+
var n = e;
|
|
301
|
+
for (; t-- > 0n;) n *= n, n %= P;
|
|
302
|
+
return n;
|
|
303
|
+
},
|
|
304
|
+
pow_2_252_3 = function pow_2_252_3(e) {
|
|
305
|
+
var t = e * e % P * e % P,
|
|
306
|
+
n = pow2(t, 2n) * t % P,
|
|
307
|
+
o = pow2(n, 1n) * e % P,
|
|
308
|
+
r = pow2(o, 5n) * o % P,
|
|
309
|
+
s = pow2(r, 10n) * r % P,
|
|
310
|
+
i = pow2(s, 20n) * s % P,
|
|
311
|
+
a = pow2(i, 40n) * i % P,
|
|
312
|
+
d = pow2(a, 80n) * a % P,
|
|
313
|
+
c = pow2(d, 80n) * a % P,
|
|
314
|
+
u = pow2(c, 10n) * r % P;
|
|
315
|
+
return {
|
|
316
|
+
pow_p_5_8: pow2(u, 2n) * e % P,
|
|
317
|
+
b2: t
|
|
318
|
+
};
|
|
319
|
+
},
|
|
320
|
+
RM1 = 19681161376707505956807079304988542015446066515923890162744021073123829784752n,
|
|
321
|
+
uvRatio = function uvRatio(e, t) {
|
|
322
|
+
var n = mod(t * t * t),
|
|
323
|
+
o = mod(n * n * t),
|
|
324
|
+
r = pow_2_252_3(e * o).pow_p_5_8;
|
|
325
|
+
var s = mod(e * n * r);
|
|
326
|
+
var i = mod(t * s * s),
|
|
327
|
+
a = s,
|
|
328
|
+
d = mod(s * RM1),
|
|
329
|
+
c = i === e,
|
|
330
|
+
u = i === mod(-e),
|
|
331
|
+
h = i === mod(-e * RM1);
|
|
332
|
+
return c && (s = a), (u || h) && (s = d), 1n === (1n & mod(s)) && (s = mod(-s)), {
|
|
333
|
+
isValid: c || u,
|
|
334
|
+
value: s
|
|
335
|
+
};
|
|
336
|
+
},
|
|
337
|
+
modL_LE = function modL_LE(e) {
|
|
338
|
+
return mod(b2n_LE(e), N);
|
|
339
|
+
};
|
|
340
|
+
var _shaS;
|
|
341
|
+
var sha512a = function sha512a() {
|
|
342
|
+
return etc.sha512Async.apply(etc, arguments);
|
|
343
|
+
},
|
|
344
|
+
sha512s = function sha512s() {
|
|
345
|
+
return "function" == typeof _shaS ? _shaS.apply(void 0, arguments) : err("etc.sha512Sync not set");
|
|
346
|
+
},
|
|
347
|
+
hash2extK = function hash2extK(e) {
|
|
348
|
+
var t = e.slice(0, 32);
|
|
349
|
+
t[0] &= 248, t[31] &= 127, t[31] |= 64;
|
|
350
|
+
var n = e.slice(32, 64),
|
|
351
|
+
o = modL_LE(t),
|
|
352
|
+
r = G.mul(o),
|
|
353
|
+
s = r.toRawBytes();
|
|
354
|
+
return {
|
|
355
|
+
head: t,
|
|
356
|
+
prefix: n,
|
|
357
|
+
scalar: o,
|
|
358
|
+
point: r,
|
|
359
|
+
pointBytes: s
|
|
360
|
+
};
|
|
361
|
+
},
|
|
362
|
+
getExtendedPublicKeyAsync = function getExtendedPublicKeyAsync(e) {
|
|
363
|
+
return sha512a(toU8(e, 32)).then(hash2extK);
|
|
364
|
+
},
|
|
365
|
+
getExtendedPublicKey = function getExtendedPublicKey(e) {
|
|
366
|
+
return hash2extK(sha512s(toU8(e, 32)));
|
|
367
|
+
},
|
|
368
|
+
getPublicKeyAsync = function getPublicKeyAsync(e) {
|
|
369
|
+
return getExtendedPublicKeyAsync(e).then(function (e) {
|
|
370
|
+
return e.pointBytes;
|
|
371
|
+
});
|
|
372
|
+
},
|
|
373
|
+
getPublicKey = function getPublicKey(e) {
|
|
374
|
+
return getExtendedPublicKey(e).pointBytes;
|
|
375
|
+
};
|
|
376
|
+
function hashFinish(e, t) {
|
|
377
|
+
return e ? sha512a(t.hashable).then(t.finish) : t.finish(sha512s(t.hashable));
|
|
378
|
+
}
|
|
379
|
+
var _sign = function _sign(e, t, n) {
|
|
380
|
+
var o = e.pointBytes,
|
|
381
|
+
r = e.scalar,
|
|
382
|
+
s = modL_LE(t),
|
|
383
|
+
i = G.mul(s).toRawBytes();
|
|
384
|
+
return {
|
|
385
|
+
hashable: concatB(i, o, n),
|
|
386
|
+
finish: function finish(e) {
|
|
387
|
+
var t = mod(s + modL_LE(e) * r, N);
|
|
388
|
+
return au8(concatB(i, n2b_32LE(t)), 64);
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
},
|
|
392
|
+
signAsync = /*#__PURE__*/function () {
|
|
393
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e, t) {
|
|
394
|
+
var n, o, r;
|
|
395
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
396
|
+
while (1) switch (_context.prev = _context.next) {
|
|
397
|
+
case 0:
|
|
398
|
+
n = toU8(e);
|
|
399
|
+
_context.next = 3;
|
|
400
|
+
return getExtendedPublicKeyAsync(t);
|
|
401
|
+
case 3:
|
|
402
|
+
o = _context.sent;
|
|
403
|
+
_context.next = 6;
|
|
404
|
+
return sha512a(o.prefix, n);
|
|
405
|
+
case 6:
|
|
406
|
+
r = _context.sent;
|
|
407
|
+
return _context.abrupt("return", hashFinish(!0, _sign(o, r, n)));
|
|
408
|
+
case 8:
|
|
409
|
+
case "end":
|
|
410
|
+
return _context.stop();
|
|
411
|
+
}
|
|
412
|
+
}, _callee);
|
|
413
|
+
}));
|
|
414
|
+
return function signAsync(_x, _x2) {
|
|
415
|
+
return _ref.apply(this, arguments);
|
|
416
|
+
};
|
|
417
|
+
}(),
|
|
418
|
+
sign = function sign(e, t) {
|
|
419
|
+
var n = toU8(e),
|
|
420
|
+
o = getExtendedPublicKey(t),
|
|
421
|
+
r = sha512s(o.prefix, n);
|
|
422
|
+
return hashFinish(!1, _sign(o, r, n));
|
|
423
|
+
},
|
|
424
|
+
dvo = {
|
|
425
|
+
zip215: !0
|
|
426
|
+
},
|
|
427
|
+
_verify = function _verify(e, t, n) {
|
|
428
|
+
var o = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : dvo;
|
|
429
|
+
t = toU8(t), e = toU8(e, 64);
|
|
430
|
+
var r = o.zip215;
|
|
431
|
+
var s,
|
|
432
|
+
i,
|
|
433
|
+
a,
|
|
434
|
+
d,
|
|
435
|
+
c = new Uint8Array();
|
|
436
|
+
try {
|
|
437
|
+
s = Point.fromHex(n, r), i = Point.fromHex(e.slice(0, 32), r), a = b2n_LE(e.slice(32, 64)), d = G.mul(a, !1), c = concatB(i.toRawBytes(), s.toRawBytes(), t);
|
|
438
|
+
} catch (e) {}
|
|
439
|
+
return {
|
|
440
|
+
hashable: c,
|
|
441
|
+
finish: function finish(e) {
|
|
442
|
+
if (null == d) return !1;
|
|
443
|
+
if (!r && s.isSmallOrder()) return !1;
|
|
444
|
+
var t = modL_LE(e);
|
|
445
|
+
return i.add(s.mul(t, !1)).add(d.negate()).clearCofactor().is0();
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
},
|
|
449
|
+
verifyAsync = /*#__PURE__*/function () {
|
|
450
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(e, t, n) {
|
|
451
|
+
var o,
|
|
452
|
+
_args2 = arguments;
|
|
453
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
454
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
455
|
+
case 0:
|
|
456
|
+
o = _args2.length > 3 && _args2[3] !== undefined ? _args2[3] : dvo;
|
|
457
|
+
return _context2.abrupt("return", hashFinish(!0, _verify(e, t, n, o)));
|
|
458
|
+
case 2:
|
|
459
|
+
case "end":
|
|
460
|
+
return _context2.stop();
|
|
461
|
+
}
|
|
462
|
+
}, _callee2);
|
|
463
|
+
}));
|
|
464
|
+
return function verifyAsync(_x3, _x4, _x5) {
|
|
465
|
+
return _ref2.apply(this, arguments);
|
|
466
|
+
};
|
|
467
|
+
}(),
|
|
468
|
+
verify = function verify(e, t, n) {
|
|
469
|
+
var o = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : dvo;
|
|
470
|
+
return hashFinish(!1, _verify(e, t, n, o));
|
|
471
|
+
},
|
|
472
|
+
cr = function cr() {
|
|
473
|
+
return "object" == (typeof globalThis === "undefined" ? "undefined" : _typeof(globalThis)) && "crypto" in globalThis ? globalThis.crypto : void 0;
|
|
474
|
+
},
|
|
475
|
+
etc = {
|
|
476
|
+
bytesToHex: b2h,
|
|
477
|
+
hexToBytes: h2b,
|
|
478
|
+
concatBytes: concatB,
|
|
479
|
+
mod: mod,
|
|
480
|
+
invert: invert,
|
|
481
|
+
randomBytes: function randomBytes() {
|
|
482
|
+
var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 32;
|
|
483
|
+
var t = cr();
|
|
484
|
+
return t && t.getRandomValues || err("crypto.getRandomValues must be defined"), t.getRandomValues(u8n(e));
|
|
485
|
+
},
|
|
486
|
+
sha512Async: function () {
|
|
487
|
+
var _sha512Async = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
488
|
+
var t,
|
|
489
|
+
n,
|
|
490
|
+
_args3 = arguments;
|
|
491
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
492
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
493
|
+
case 0:
|
|
494
|
+
t = cr();
|
|
495
|
+
t && t.subtle || err("crypto.subtle or etc.sha512Async must be defined");
|
|
496
|
+
n = concatB.apply(void 0, _args3);
|
|
497
|
+
_context3.t0 = u8n;
|
|
498
|
+
_context3.next = 6;
|
|
499
|
+
return t.subtle.digest("SHA-512", n.buffer);
|
|
500
|
+
case 6:
|
|
501
|
+
_context3.t1 = _context3.sent;
|
|
502
|
+
return _context3.abrupt("return", (0, _context3.t0)(_context3.t1));
|
|
503
|
+
case 8:
|
|
504
|
+
case "end":
|
|
505
|
+
return _context3.stop();
|
|
506
|
+
}
|
|
507
|
+
}, _callee3);
|
|
508
|
+
}));
|
|
509
|
+
function sha512Async() {
|
|
510
|
+
return _sha512Async.apply(this, arguments);
|
|
511
|
+
}
|
|
512
|
+
return sha512Async;
|
|
513
|
+
}(),
|
|
514
|
+
sha512Sync: void 0
|
|
515
|
+
};
|
|
516
|
+
Object.defineProperties(etc, {
|
|
517
|
+
sha512Sync: {
|
|
518
|
+
configurable: !1,
|
|
519
|
+
get: function get() {
|
|
520
|
+
return _shaS;
|
|
521
|
+
},
|
|
522
|
+
set: function set(e) {
|
|
523
|
+
_shaS || (_shaS = e);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
var utils = {
|
|
528
|
+
getExtendedPublicKeyAsync: getExtendedPublicKeyAsync,
|
|
529
|
+
getExtendedPublicKey: getExtendedPublicKey,
|
|
530
|
+
randomPrivateKey: function randomPrivateKey() {
|
|
531
|
+
return etc.randomBytes(32);
|
|
532
|
+
},
|
|
533
|
+
precompute: function precompute() {
|
|
534
|
+
var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 8;
|
|
535
|
+
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : G;
|
|
536
|
+
return t.multiply(3n), t;
|
|
537
|
+
}
|
|
538
|
+
},
|
|
539
|
+
W = 8,
|
|
540
|
+
precompute = function precompute() {
|
|
541
|
+
var e = [];
|
|
542
|
+
var t = G,
|
|
543
|
+
n = t;
|
|
544
|
+
for (var o = 0; o < 33; o++) {
|
|
545
|
+
n = t, e.push(n);
|
|
546
|
+
for (var _o = 1; _o < 128; _o++) n = n.add(t), e.push(n);
|
|
547
|
+
t = n["double"]();
|
|
548
|
+
}
|
|
549
|
+
return e;
|
|
550
|
+
};
|
|
551
|
+
var Gpows;
|
|
552
|
+
var wNAF = function wNAF(e) {
|
|
553
|
+
var t = Gpows || (Gpows = precompute()),
|
|
554
|
+
n = function n(e, t) {
|
|
555
|
+
var n = t.negate();
|
|
556
|
+
return e ? n : t;
|
|
557
|
+
};
|
|
558
|
+
var o = I,
|
|
559
|
+
r = G;
|
|
560
|
+
var s = BigInt(255),
|
|
561
|
+
i = BigInt(8);
|
|
562
|
+
for (var a = 0; a < 33; a++) {
|
|
563
|
+
var d = 128 * a;
|
|
564
|
+
var c = Number(e & s);
|
|
565
|
+
e >>= i, c > 128 && (c -= 256, e += 1n);
|
|
566
|
+
var u = d,
|
|
567
|
+
h = d + Math.abs(c) - 1,
|
|
568
|
+
l = a % 2 != 0,
|
|
569
|
+
y = c < 0;
|
|
570
|
+
0 === c ? r = r.add(n(l, t[u])) : o = o.add(n(y, t[h]));
|
|
571
|
+
}
|
|
572
|
+
return {
|
|
573
|
+
p: o,
|
|
574
|
+
f: r
|
|
575
|
+
};
|
|
576
|
+
};
|
|
577
|
+
var crypto = require('crypto-js');
|
|
578
|
+
function hexToUint8Array(hex) {
|
|
579
|
+
if (hex.length % 2 !== 0) {
|
|
580
|
+
throw new Error('Invalid hex string');
|
|
581
|
+
}
|
|
582
|
+
var byteArray = new Uint8Array(hex.length / 2);
|
|
583
|
+
for (var i = 0; i < hex.length; i += 2) {
|
|
584
|
+
byteArray[i / 2] = parseInt(hex.substr(i, 2), 16);
|
|
585
|
+
}
|
|
586
|
+
return byteArray;
|
|
587
|
+
}
|
|
588
|
+
etc.sha512Sync = function () {
|
|
589
|
+
var concatenatedBytes = etc.concatBytes.apply(etc, arguments);
|
|
590
|
+
var wordArray = crypto.lib.WordArray.create(concatenatedBytes);
|
|
591
|
+
var hash = crypto.SHA512(wordArray);
|
|
592
|
+
ret = hash.toString(crypto.enc.Hex);
|
|
593
|
+
return hexToUint8Array(ret);
|
|
594
|
+
};
|
|
595
|
+
function constructSignContent(request, nonce) {
|
|
596
|
+
console.log(request.url.getPath(), request.url.host);
|
|
597
|
+
var originalPath = request.url.getPath();
|
|
598
|
+
var path = originalPath.startsWith("/v2") ? originalPath : "/v2" + originalPath;
|
|
599
|
+
var method = request.method;
|
|
600
|
+
var body = pm.request.body != null && pm.request.body.raw != null ? pm.request.body.raw : '';
|
|
601
|
+
var queryString = request.url.getQueryString();
|
|
602
|
+
if (queryString != "") {
|
|
603
|
+
var params = queryString.split('&').map(function (param) {
|
|
604
|
+
var _param$split = param.split('='),
|
|
605
|
+
_param$split2 = _slicedToArray(_param$split, 2),
|
|
606
|
+
key = _param$split2[0],
|
|
607
|
+
value = _param$split2[1];
|
|
608
|
+
return {
|
|
609
|
+
key: key,
|
|
610
|
+
value: value
|
|
611
|
+
};
|
|
612
|
+
});
|
|
613
|
+
queryString = params.map(function (param) {
|
|
614
|
+
return "".concat(param.key, "=").concat(encodeURIComponent(param.value));
|
|
615
|
+
}).join('&').replace(/%20/g, "+");
|
|
616
|
+
}
|
|
617
|
+
var strToSign = [method, path, nonce, queryString, body].join('|');
|
|
618
|
+
console.log("strToSign:", strToSign);
|
|
619
|
+
return crypto.SHA256(crypto.SHA256(strToSign)).toString();
|
|
620
|
+
}
|
|
621
|
+
var nonce = String(new Date().getTime());
|
|
622
|
+
var hash = constructSignContent(pm.request, nonce);
|
|
623
|
+
|
|
624
|
+
// get private key from environment
|
|
625
|
+
var privateKey = pm.environment.get('privateKey');
|
|
626
|
+
// sign the request
|
|
627
|
+
var sig = sign(hash, privateKey);
|
|
628
|
+
// add authorization headers
|
|
629
|
+
pm.request.addHeader({
|
|
630
|
+
key: 'Biz-Api-Nonce',
|
|
631
|
+
value: nonce
|
|
632
|
+
});
|
|
633
|
+
pm.request.addHeader({
|
|
634
|
+
key: 'Biz-Api-Signature',
|
|
635
|
+
value: Buffer.from(sig).toString('hex')
|
|
636
|
+
});
|
|
637
|
+
pm.request.addHeader({
|
|
638
|
+
key: 'Biz-Api-Key',
|
|
639
|
+
value: pm.environment.get('apiKey')
|
|
640
|
+
});
|