ox 0.14.16 → 0.14.17
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/CHANGELOG.md +10 -0
- package/_cjs/tempo/TransactionRequest.js +10 -1
- package/_cjs/tempo/TransactionRequest.js.map +1 -1
- package/_cjs/tempo/ZoneId.js +13 -0
- package/_cjs/tempo/ZoneId.js.map +1 -0
- package/_cjs/tempo/ZoneRpcAuthentication.js +101 -0
- package/_cjs/tempo/ZoneRpcAuthentication.js.map +1 -0
- package/_cjs/tempo/index.js +3 -1
- package/_cjs/tempo/index.js.map +1 -1
- package/_cjs/version.js +1 -1
- package/_esm/tempo/TransactionRequest.js +10 -1
- package/_esm/tempo/TransactionRequest.js.map +1 -1
- package/_esm/tempo/ZoneId.js +47 -0
- package/_esm/tempo/ZoneId.js.map +1 -0
- package/_esm/tempo/ZoneRpcAuthentication.js +256 -0
- package/_esm/tempo/ZoneRpcAuthentication.js.map +1 -0
- package/_esm/tempo/index.js +55 -0
- package/_esm/tempo/index.js.map +1 -1
- package/_esm/version.js +1 -1
- package/_types/tempo/TransactionRequest.d.ts +6 -4
- package/_types/tempo/TransactionRequest.d.ts.map +1 -1
- package/_types/tempo/ZoneId.d.ts +50 -0
- package/_types/tempo/ZoneId.d.ts.map +1 -0
- package/_types/tempo/ZoneRpcAuthentication.d.ts +268 -0
- package/_types/tempo/ZoneRpcAuthentication.d.ts.map +1 -0
- package/_types/tempo/index.d.ts +55 -0
- package/_types/tempo/index.d.ts.map +1 -1
- package/_types/version.d.ts +1 -1
- package/package.json +11 -1
- package/tempo/TransactionRequest.test.ts +26 -2
- package/tempo/TransactionRequest.ts +17 -7
- package/tempo/ZoneId/package.json +6 -0
- package/tempo/ZoneId.test.ts +42 -0
- package/tempo/ZoneId.ts +58 -0
- package/tempo/ZoneRpcAuthentication/package.json +6 -0
- package/tempo/ZoneRpcAuthentication.test.ts +226 -0
- package/tempo/ZoneRpcAuthentication.ts +423 -0
- package/tempo/e2e.test.ts +2 -0
- package/tempo/index.ts +55 -8
- package/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# ox
|
|
2
2
|
|
|
3
|
+
## 0.14.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#220](https://github.com/wevm/ox/pull/220) [`da7a62c`](https://github.com/wevm/ox/commit/da7a62cfbecb99b3cc24f275703e33b1320abb1b) Thanks [@Zygimantass](https://github.com/Zygimantass)! - Added Tempo zones support
|
|
8
|
+
|
|
9
|
+
- [#219](https://github.com/wevm/ox/pull/219) [`a934992`](https://github.com/wevm/ox/commit/a934992257add3724f16538c7a14d72e647a2b66) Thanks [@jxom](https://github.com/jxom)! - Added `feePayer` to `TransactionRequest` in `ox/tempo`.
|
|
10
|
+
|
|
11
|
+
- [#217](https://github.com/wevm/ox/pull/217) [`5e2ae4d`](https://github.com/wevm/ox/commit/5e2ae4d9a007bb4071896c5e4c0f258e9a637a54) Thanks [@jxom](https://github.com/jxom)! - Fixed `TransactionRequest.fromRpc` in `ox/tempo`. `TransactionRequest.toRpc` now folds top-level `to`/`data`/`value` into `calls` when `calls` is not provided.
|
|
12
|
+
|
|
3
13
|
## 0.14.16
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -28,7 +28,7 @@ function fromRpc(request) {
|
|
|
28
28
|
return mapped;
|
|
29
29
|
});
|
|
30
30
|
if (typeof request.feeToken !== 'undefined')
|
|
31
|
-
request_.feeToken =
|
|
31
|
+
request_.feeToken = request.feeToken;
|
|
32
32
|
if (request.keyAuthorization)
|
|
33
33
|
request_.keyAuthorization = KeyAuthorization.fromRpc(request.keyAuthorization);
|
|
34
34
|
if (typeof request.validBefore !== 'undefined')
|
|
@@ -52,6 +52,14 @@ function toRpc(request) {
|
|
|
52
52
|
value: call.value ? Hex.fromNumber(call.value) : '0x',
|
|
53
53
|
data: call.data ?? '0x',
|
|
54
54
|
}));
|
|
55
|
+
else if (request.to || request.data || request.value)
|
|
56
|
+
request_rpc.calls = [
|
|
57
|
+
{
|
|
58
|
+
to: request.to ? TempoAddress.resolve(request.to) : undefined,
|
|
59
|
+
value: request.value ? Hex.fromNumber(request.value) : '0x',
|
|
60
|
+
data: request.data ?? '0x',
|
|
61
|
+
},
|
|
62
|
+
];
|
|
55
63
|
if (typeof request.feeToken !== 'undefined')
|
|
56
64
|
request_rpc.feeToken = TokenId.toAddress(request.feeToken);
|
|
57
65
|
if (request.keyAuthorization)
|
|
@@ -70,6 +78,7 @@ function toRpc(request) {
|
|
|
70
78
|
if (nonceKey)
|
|
71
79
|
request_rpc.nonceKey = nonceKey;
|
|
72
80
|
if (typeof request.calls !== 'undefined' ||
|
|
81
|
+
typeof request.feePayer !== 'undefined' ||
|
|
73
82
|
typeof request.feeToken !== 'undefined' ||
|
|
74
83
|
typeof request.keyAuthorization !== 'undefined' ||
|
|
75
84
|
typeof request.nonceKey !== 'undefined' ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionRequest.js","sourceRoot":"","sources":["../../tempo/TransactionRequest.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"TransactionRequest.js","sourceRoot":"","sources":["../../tempo/TransactionRequest.ts"],"names":[],"mappings":";;AA6EA,0BAwCC;AA2DD,sBA6DC;AA5OD,sCAAqC;AAErC,uEAAsE;AACtE,8DAA6D;AAC7D,0DAAyD;AACzD,kDAAiD;AACjD,wCAAuC;AACvC,gDAA+C;AAqE/C,SAAgB,OAAO,CAAC,OAAY;IAClC,MAAM,EAAE,iBAAiB,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAA;IACjD,MAAM,QAAQ,GAAG,qBAAqB,CAAC,OAAO,CAC5C,IAAW,CACU,CAAA;IAEvB,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,WAAW;QACrC,QAAQ,CAAC,IAAI;YACX,WAAW,CAAC,WAAW,CACrB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;QACzC,OAAO,CAAC,IAAI,KAAK,OAAO,EACxB,CAAC;QACD,WAAW,CAAC,IAAI,GAAG,WAAW,CAAC,SAAS,CAAC,KAAK,CAAA;QAC9C,OAAO,WAAW,CAAC,IAAI,CAAA;QACvB,OAAO,WAAW,CAAC,KAAK,CAAA;QACxB,OAAO,WAAW,CAAC,EAAE,CAAA;QACrB,OAAO,WAAW,CAAC,KAAK,CAAA;IAC1B,CAAC;IAED,OAAO,WAAW,CAAA;AACpB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.chainIdBase = void 0;
|
|
4
|
+
exports.fromChainId = fromChainId;
|
|
5
|
+
exports.toChainId = toChainId;
|
|
6
|
+
exports.chainIdBase = 4_217_000_000;
|
|
7
|
+
function fromChainId(chainId) {
|
|
8
|
+
return chainId - exports.chainIdBase;
|
|
9
|
+
}
|
|
10
|
+
function toChainId(zoneId) {
|
|
11
|
+
return exports.chainIdBase + zoneId;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=ZoneId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZoneId.js","sourceRoot":"","sources":["../../tempo/ZoneId.ts"],"names":[],"mappings":";;;AA0BA,kCAEC;AAuBD,8BAEC;AA9CY,QAAA,WAAW,GAAG,aAAsB,CAAA;AAmBjD,SAAgB,WAAW,CAAC,OAAe;IACzC,OAAO,OAAO,GAAG,mBAAW,CAAA;AAC9B,CAAC;AAuBD,SAAgB,SAAS,CAAC,MAAc;IACtC,OAAO,mBAAW,GAAG,MAAM,CAAA;AAC7B,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MissingSignatureError = exports.InvalidSerializedError = exports.version = exports.fieldsSize = exports.magicBytes = exports.headerName = void 0;
|
|
4
|
+
exports.from = from;
|
|
5
|
+
exports.deserialize = deserialize;
|
|
6
|
+
exports.getFields = getFields;
|
|
7
|
+
exports.getSignPayload = getSignPayload;
|
|
8
|
+
exports.hash = hash;
|
|
9
|
+
exports.serialize = serialize;
|
|
10
|
+
const Errors = require("../core/Errors.js");
|
|
11
|
+
const Hash = require("../core/Hash.js");
|
|
12
|
+
const Hex = require("../core/Hex.js");
|
|
13
|
+
const SignatureEnvelope = require("./SignatureEnvelope.js");
|
|
14
|
+
const TempoAddress = require("./TempoAddress.js");
|
|
15
|
+
exports.headerName = 'X-Authorization-Token';
|
|
16
|
+
exports.magicBytes = '0x54656d706f5a6f6e655250430000000000000000000000000000000000000000';
|
|
17
|
+
exports.fieldsSize = 29;
|
|
18
|
+
exports.version = 0;
|
|
19
|
+
function from(authentication, options = {}) {
|
|
20
|
+
const auth = authentication;
|
|
21
|
+
const resolved = {
|
|
22
|
+
...auth,
|
|
23
|
+
version: exports.version,
|
|
24
|
+
};
|
|
25
|
+
if (options.signature)
|
|
26
|
+
return {
|
|
27
|
+
...resolved,
|
|
28
|
+
signature: SignatureEnvelope.from(options.signature),
|
|
29
|
+
};
|
|
30
|
+
return resolved;
|
|
31
|
+
}
|
|
32
|
+
function deserialize(serialized) {
|
|
33
|
+
const size = Hex.size(serialized);
|
|
34
|
+
if (size <= exports.fieldsSize)
|
|
35
|
+
throw new InvalidSerializedError({
|
|
36
|
+
reason: `Serialized authentication must be longer than ${exports.fieldsSize} bytes.`,
|
|
37
|
+
serialized,
|
|
38
|
+
});
|
|
39
|
+
const fieldsOffset = size - exports.fieldsSize;
|
|
40
|
+
const signature = Hex.slice(serialized, 0, fieldsOffset);
|
|
41
|
+
const fields = Hex.slice(serialized, fieldsOffset);
|
|
42
|
+
const parsedVersion = Hex.toNumber(Hex.slice(fields, 0, 1), { size: 1 });
|
|
43
|
+
if (parsedVersion !== exports.version)
|
|
44
|
+
throw new InvalidSerializedError({
|
|
45
|
+
reason: `Unsupported authentication version "${parsedVersion}". Expected "${exports.version}".`,
|
|
46
|
+
serialized,
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
chainId: Hex.toNumber(Hex.slice(fields, 5, 13), { size: 8 }),
|
|
50
|
+
expiresAt: Hex.toNumber(Hex.slice(fields, 21, 29), { size: 8 }),
|
|
51
|
+
issuedAt: Hex.toNumber(Hex.slice(fields, 13, 21), { size: 8 }),
|
|
52
|
+
signature: SignatureEnvelope.deserialize(signature),
|
|
53
|
+
version: exports.version,
|
|
54
|
+
zoneId: Hex.toNumber(Hex.slice(fields, 1, 5), { size: 4 }),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function getFields(authentication) {
|
|
58
|
+
return Hex.concat(Hex.fromNumber(exports.version, { size: 1 }), Hex.fromNumber(authentication.zoneId, { size: 4 }), Hex.fromNumber(authentication.chainId, { size: 8 }), Hex.fromNumber(authentication.issuedAt, { size: 8 }), Hex.fromNumber(authentication.expiresAt, { size: 8 }));
|
|
59
|
+
}
|
|
60
|
+
function getSignPayload(authentication, options = {}) {
|
|
61
|
+
const authHash = hash(authentication);
|
|
62
|
+
if (options.userAddress)
|
|
63
|
+
return Hash.keccak256(Hex.concat('0x04', authHash, TempoAddress.resolve(options.userAddress)));
|
|
64
|
+
return authHash;
|
|
65
|
+
}
|
|
66
|
+
function hash(authentication) {
|
|
67
|
+
return Hash.keccak256(Hex.concat(exports.magicBytes, getFields(authentication)));
|
|
68
|
+
}
|
|
69
|
+
function serialize(authentication, options = {}) {
|
|
70
|
+
const signature = options.signature || authentication.signature;
|
|
71
|
+
if (!signature)
|
|
72
|
+
throw new MissingSignatureError();
|
|
73
|
+
return Hex.concat(SignatureEnvelope.serialize(SignatureEnvelope.from(signature)), getFields(authentication));
|
|
74
|
+
}
|
|
75
|
+
class InvalidSerializedError extends Errors.BaseError {
|
|
76
|
+
constructor({ reason, serialized }) {
|
|
77
|
+
super(`Unable to deserialize Zone RPC authentication: ${reason}`, {
|
|
78
|
+
metaMessages: [`Serialized: ${serialized}`],
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(this, "name", {
|
|
81
|
+
enumerable: true,
|
|
82
|
+
configurable: true,
|
|
83
|
+
writable: true,
|
|
84
|
+
value: 'ZoneRpcAuthentication.InvalidSerializedError'
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.InvalidSerializedError = InvalidSerializedError;
|
|
89
|
+
class MissingSignatureError extends Errors.BaseError {
|
|
90
|
+
constructor() {
|
|
91
|
+
super('Zone RPC authentication is missing a signature.');
|
|
92
|
+
Object.defineProperty(this, "name", {
|
|
93
|
+
enumerable: true,
|
|
94
|
+
configurable: true,
|
|
95
|
+
writable: true,
|
|
96
|
+
value: 'ZoneRpcAuthentication.MissingSignatureError'
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.MissingSignatureError = MissingSignatureError;
|
|
101
|
+
//# sourceMappingURL=ZoneRpcAuthentication.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZoneRpcAuthentication.js","sourceRoot":"","sources":["../../tempo/ZoneRpcAuthentication.ts"],"names":[],"mappings":";;;AAwHA,oBAkBC;AA8CD,kCA2BC;AA+BD,8BAUC;AAiCD,wCAUC;AAsCD,oBAIC;AAyCD,8BAWC;AArYD,4CAA2C;AAC3C,wCAAuC;AACvC,sCAAqC;AAErC,4DAA2D;AAC3D,kDAAiD;AAKpC,QAAA,UAAU,GAAG,uBAAgC,CAAA;AAK7C,QAAA,UAAU,GACrB,oEAA6E,CAAA;AAKlE,QAAA,UAAU,GAAG,EAAW,CAAA;AAGxB,QAAA,OAAO,GAAG,CAAU,CAAA;AAgGjC,SAAgB,IAAI,CAIlB,cAAsD,EACtD,UAAmC,EAAE;IAErC,MAAM,IAAI,GAAG,cAAuC,CAAA;IACpD,MAAM,QAAQ,GAAG;QACf,GAAG,IAAI;QACP,OAAO,EAAP,eAAO;KACR,CAAA;IACD,IAA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AQ,CAAA;AACjB,CAAC;AAsCD,SAAgB,IAAI,CAClB,cAA2D;IAE3D,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,kBAAU,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAA;AAC1E,CAAC;AAyCD,SAAgB,SAAS,CACvB,cAA2D,EAC3D,UAA6B,EAAE;IAE/B,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,cAAc,CAAC,SAAS,CAAA;IAC/D,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,qBAAqB,EAAE,CAAA;IAEjD,OAAO,GAAG,CAAC,MAAM,CACf,iBAAiB,CAAC,SAAS,CAAC,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAC9D,SAAS,CAAC,cAAc,CAAC,CAC1B,CAAA;AACH,CAAC;AAgBD,MAAa,sBAAuB,SAAQ,MAAM,CAAC,SAAS;IAG1D,YAAY,EAAE,MAAM,EAAE,UAAU,EAA2C;QACzE,KAAK,CAAC,kDAAkD,MAAM,EAAE,EAAE;YAChE,YAAY,EAAE,CAAC,eAAe,UAAU,EAAE,CAAC;SAC5C,CAAC,CAAA;QALc;;;;mBAAO,8CAA8C;WAAA;IAMvE,CAAC;CACF;AARD,wDAQC;AAGD,MAAa,qBAAsB,SAAQ,MAAM,CAAC,SAAS;IAGzD;QACE,KAAK,CAAC,iDAAiD,CAAC,CAAA;QAHxC;;;;mBAAO,6CAA6C;WAAA;IAItE,CAAC;CACF;AAND,sDAMC"}
|
package/_cjs/tempo/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TxEnvelopeTempo = exports.TransactionRequest = exports.TransactionReceipt = exports.Transaction = exports.TokenRole = exports.TokenId = exports.Tick = exports.TempoAddress = exports.SignatureEnvelope = exports.RpcSchemaTempo = exports.PoolId = exports.Period = exports.KeyAuthorization = exports.AuthorizationTempo = void 0;
|
|
3
|
+
exports.ZoneRpcAuthentication = exports.ZoneId = exports.TxEnvelopeTempo = exports.TransactionRequest = exports.TransactionReceipt = exports.Transaction = exports.TokenRole = exports.TokenId = exports.Tick = exports.TempoAddress = exports.SignatureEnvelope = exports.RpcSchemaTempo = exports.PoolId = exports.Period = exports.KeyAuthorization = exports.AuthorizationTempo = void 0;
|
|
4
4
|
exports.AuthorizationTempo = require("./AuthorizationTempo.js");
|
|
5
5
|
exports.KeyAuthorization = require("./KeyAuthorization.js");
|
|
6
6
|
exports.Period = require("./Period.js");
|
|
@@ -15,4 +15,6 @@ exports.Transaction = require("./Transaction.js");
|
|
|
15
15
|
exports.TransactionReceipt = require("./TransactionReceipt.js");
|
|
16
16
|
exports.TransactionRequest = require("./TransactionRequest.js");
|
|
17
17
|
exports.TxEnvelopeTempo = require("./TxEnvelopeTempo.js");
|
|
18
|
+
exports.ZoneId = require("./ZoneId.js");
|
|
19
|
+
exports.ZoneRpcAuthentication = require("./ZoneRpcAuthentication.js");
|
|
18
20
|
//# sourceMappingURL=index.js.map
|
package/_cjs/tempo/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../tempo/index.ts"],"names":[],"mappings":";;;AAoCA,gEAA6D;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../tempo/index.ts"],"names":[],"mappings":";;;AAoCA,gEAA6D;AAwC7D,4DAAyD;AA6BzD,wCAAqC;AAsBrC,wCAAqC;AAmBrC,wDAAqD;AAuBrD,8DAA2D;AAmB3D,oDAAiD;AAoBjD,oCAAiC;AAqBjC,0CAAuC;AAkBvC,8CAA2C;AAkD3C,kDAA+C;AAuB/C,gEAA6D;AAqB7D,gEAA6D;AA6B7D,0DAAuD;AAoBvD,wCAAqC;AAmCrC,sEAAmE"}
|
package/_cjs/version.js
CHANGED
|
@@ -44,7 +44,7 @@ export function fromRpc(request) {
|
|
|
44
44
|
return mapped;
|
|
45
45
|
});
|
|
46
46
|
if (typeof request.feeToken !== 'undefined')
|
|
47
|
-
request_.feeToken =
|
|
47
|
+
request_.feeToken = request.feeToken;
|
|
48
48
|
if (request.keyAuthorization)
|
|
49
49
|
request_.keyAuthorization = KeyAuthorization.fromRpc(request.keyAuthorization);
|
|
50
50
|
if (typeof request.validBefore !== 'undefined')
|
|
@@ -117,6 +117,14 @@ export function toRpc(request) {
|
|
|
117
117
|
value: call.value ? Hex.fromNumber(call.value) : '0x',
|
|
118
118
|
data: call.data ?? '0x',
|
|
119
119
|
}));
|
|
120
|
+
else if (request.to || request.data || request.value)
|
|
121
|
+
request_rpc.calls = [
|
|
122
|
+
{
|
|
123
|
+
to: request.to ? TempoAddress.resolve(request.to) : undefined,
|
|
124
|
+
value: request.value ? Hex.fromNumber(request.value) : '0x',
|
|
125
|
+
data: request.data ?? '0x',
|
|
126
|
+
},
|
|
127
|
+
];
|
|
120
128
|
if (typeof request.feeToken !== 'undefined')
|
|
121
129
|
request_rpc.feeToken = TokenId.toAddress(request.feeToken);
|
|
122
130
|
if (request.keyAuthorization)
|
|
@@ -135,6 +143,7 @@ export function toRpc(request) {
|
|
|
135
143
|
if (nonceKey)
|
|
136
144
|
request_rpc.nonceKey = nonceKey;
|
|
137
145
|
if (typeof request.calls !== 'undefined' ||
|
|
146
|
+
typeof request.feePayer !== 'undefined' ||
|
|
138
147
|
typeof request.feeToken !== 'undefined' ||
|
|
139
148
|
typeof request.keyAuthorization !== 'undefined' ||
|
|
140
149
|
typeof request.nonceKey !== 'undefined' ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransactionRequest.js","sourceRoot":"","sources":["../../tempo/TransactionRequest.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AAErC,OAAO,KAAK,qBAAqB,MAAM,+BAA+B,CAAA;AACtE,OAAO,KAAK,kBAAkB,MAAM,yBAAyB,CAAA;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K,CAAA;IAC1B,CAAC;IAED,OAAO,WAAW,CAAA;AACpB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base offset for deriving zone chain IDs.
|
|
3
|
+
*
|
|
4
|
+
* Zone chain IDs are computed as `chainIdBase + zoneId`.
|
|
5
|
+
*/
|
|
6
|
+
export const chainIdBase = 4_217_000_000;
|
|
7
|
+
/**
|
|
8
|
+
* Derives a zone ID from a zone chain ID.
|
|
9
|
+
*
|
|
10
|
+
* Zone chain IDs follow the formula `4_217_000_000 + zoneId`, so a chain ID
|
|
11
|
+
* of `4217000006` corresponds to zone ID `6`.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts twoslash
|
|
15
|
+
* import { ZoneId } from 'ox/tempo'
|
|
16
|
+
*
|
|
17
|
+
* const zoneId = ZoneId.fromChainId(4_217_000_006)
|
|
18
|
+
* // @log: 6
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @param chainId - The zone chain ID.
|
|
22
|
+
* @returns The zone ID.
|
|
23
|
+
*/
|
|
24
|
+
export function fromChainId(chainId) {
|
|
25
|
+
return chainId - chainIdBase;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Derives a zone chain ID from a zone ID.
|
|
29
|
+
*
|
|
30
|
+
* Zone chain IDs follow the formula `4_217_000_000 + zoneId`, so zone ID
|
|
31
|
+
* `6` corresponds to chain ID `4217000006`.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts twoslash
|
|
35
|
+
* import { ZoneId } from 'ox/tempo'
|
|
36
|
+
*
|
|
37
|
+
* const chainId = ZoneId.toChainId(6)
|
|
38
|
+
* // @log: 4217000006
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @param zoneId - The zone ID.
|
|
42
|
+
* @returns The zone chain ID.
|
|
43
|
+
*/
|
|
44
|
+
export function toChainId(zoneId) {
|
|
45
|
+
return chainIdBase + zoneId;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=ZoneId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZoneId.js","sourceRoot":"","sources":["../../tempo/ZoneId.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,aAAsB,CAAA;AAEjD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,OAAO,OAAO,GAAG,WAAW,CAAA;AAC9B,CAAC;AAMD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,SAAS,CAAC,MAAc;IACtC,OAAO,WAAW,GAAG,MAAM,CAAA;AAC7B,CAAC"}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import * as Errors from '../core/Errors.js';
|
|
2
|
+
import * as Hash from '../core/Hash.js';
|
|
3
|
+
import * as Hex from '../core/Hex.js';
|
|
4
|
+
import * as SignatureEnvelope from './SignatureEnvelope.js';
|
|
5
|
+
import * as TempoAddress from './TempoAddress.js';
|
|
6
|
+
/**
|
|
7
|
+
* Header name used to transport Zone RPC authentication tokens.
|
|
8
|
+
*/
|
|
9
|
+
export const headerName = 'X-Authorization-Token';
|
|
10
|
+
/**
|
|
11
|
+
* 32-byte domain separator used when hashing Zone RPC authentication tokens.
|
|
12
|
+
*/
|
|
13
|
+
export const magicBytes = '0x54656d706f5a6f6e655250430000000000000000000000000000000000000000';
|
|
14
|
+
/**
|
|
15
|
+
* Size, in bytes, of the fixed Zone RPC authentication fields.
|
|
16
|
+
*/
|
|
17
|
+
export const fieldsSize = 29;
|
|
18
|
+
/** Current Zone RPC authentication version. */
|
|
19
|
+
export const version = 0;
|
|
20
|
+
/**
|
|
21
|
+
* Instantiates a typed Zone RPC authentication token.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts twoslash
|
|
25
|
+
* import { ZoneRpcAuthentication } from 'ox/tempo'
|
|
26
|
+
*
|
|
27
|
+
* const authentication = ZoneRpcAuthentication.from({
|
|
28
|
+
* chainId: 4217000026,
|
|
29
|
+
* expiresAt: 1711235160,
|
|
30
|
+
* issuedAt: 1711234560,
|
|
31
|
+
* zoneId: 26,
|
|
32
|
+
* })
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ### Attaching Signatures
|
|
37
|
+
*
|
|
38
|
+
* ```ts twoslash
|
|
39
|
+
* import { Secp256k1 } from 'ox'
|
|
40
|
+
* import { ZoneRpcAuthentication } from 'ox/tempo'
|
|
41
|
+
*
|
|
42
|
+
* const authentication = ZoneRpcAuthentication.from({
|
|
43
|
+
* chainId: 4217000026,
|
|
44
|
+
* expiresAt: 1711235160,
|
|
45
|
+
* issuedAt: 1711234560,
|
|
46
|
+
* zoneId: 26,
|
|
47
|
+
* })
|
|
48
|
+
*
|
|
49
|
+
* const signature = Secp256k1.sign({
|
|
50
|
+
* payload: ZoneRpcAuthentication.getSignPayload(authentication),
|
|
51
|
+
* privateKey: '0x...',
|
|
52
|
+
* })
|
|
53
|
+
*
|
|
54
|
+
* const authentication_signed = ZoneRpcAuthentication.from(authentication, {
|
|
55
|
+
* signature,
|
|
56
|
+
* })
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @param authentication - Zone RPC authentication token fields.
|
|
60
|
+
* @param options - Zone RPC authentication options.
|
|
61
|
+
* @returns The instantiated Zone RPC authentication token.
|
|
62
|
+
*/
|
|
63
|
+
export function from(authentication, options = {}) {
|
|
64
|
+
const auth = authentication;
|
|
65
|
+
const resolved = {
|
|
66
|
+
...auth,
|
|
67
|
+
version,
|
|
68
|
+
};
|
|
69
|
+
if (options.signature)
|
|
70
|
+
return {
|
|
71
|
+
...resolved,
|
|
72
|
+
signature: SignatureEnvelope.from(options.signature),
|
|
73
|
+
};
|
|
74
|
+
return resolved;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Parses a serialized Zone RPC authentication token.
|
|
78
|
+
*
|
|
79
|
+
* The serialized format is `<signature><29-byte fields>`. The signature is parsed
|
|
80
|
+
* from the prefix and the fixed-length fields are parsed from the suffix.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts twoslash
|
|
84
|
+
* import { ZoneRpcAuthentication } from 'ox/tempo'
|
|
85
|
+
*
|
|
86
|
+
* const authentication = ZoneRpcAuthentication.deserialize('0x...')
|
|
87
|
+
* ```
|
|
88
|
+
*
|
|
89
|
+
* @param serialized - The serialized Zone RPC authentication token.
|
|
90
|
+
* @returns The parsed Zone RPC authentication token.
|
|
91
|
+
*/
|
|
92
|
+
export function deserialize(serialized) {
|
|
93
|
+
const size = Hex.size(serialized);
|
|
94
|
+
if (size <= fieldsSize)
|
|
95
|
+
throw new InvalidSerializedError({
|
|
96
|
+
reason: `Serialized authentication must be longer than ${fieldsSize} bytes.`,
|
|
97
|
+
serialized,
|
|
98
|
+
});
|
|
99
|
+
const fieldsOffset = size - fieldsSize;
|
|
100
|
+
const signature = Hex.slice(serialized, 0, fieldsOffset);
|
|
101
|
+
const fields = Hex.slice(serialized, fieldsOffset);
|
|
102
|
+
const parsedVersion = Hex.toNumber(Hex.slice(fields, 0, 1), { size: 1 });
|
|
103
|
+
if (parsedVersion !== version)
|
|
104
|
+
throw new InvalidSerializedError({
|
|
105
|
+
reason: `Unsupported authentication version "${parsedVersion}". Expected "${version}".`,
|
|
106
|
+
serialized,
|
|
107
|
+
});
|
|
108
|
+
return {
|
|
109
|
+
chainId: Hex.toNumber(Hex.slice(fields, 5, 13), { size: 8 }),
|
|
110
|
+
expiresAt: Hex.toNumber(Hex.slice(fields, 21, 29), { size: 8 }),
|
|
111
|
+
issuedAt: Hex.toNumber(Hex.slice(fields, 13, 21), { size: 8 }),
|
|
112
|
+
signature: SignatureEnvelope.deserialize(signature),
|
|
113
|
+
version,
|
|
114
|
+
zoneId: Hex.toNumber(Hex.slice(fields, 1, 5), { size: 4 }),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Returns the 29-byte fixed field suffix for a Zone RPC authentication token.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```ts twoslash
|
|
122
|
+
* import { ZoneRpcAuthentication } from 'ox/tempo'
|
|
123
|
+
*
|
|
124
|
+
* const fields = ZoneRpcAuthentication.getFields({
|
|
125
|
+
* chainId: 4217000026,
|
|
126
|
+
* expiresAt: 1711235160,
|
|
127
|
+
* issuedAt: 1711234560,
|
|
128
|
+
* zoneId: 26,
|
|
129
|
+
* })
|
|
130
|
+
* ```
|
|
131
|
+
*
|
|
132
|
+
* @param authentication - The Zone RPC authentication token.
|
|
133
|
+
* @returns The fixed 29-byte field suffix.
|
|
134
|
+
*/
|
|
135
|
+
export function getFields(authentication) {
|
|
136
|
+
return Hex.concat(Hex.fromNumber(version, { size: 1 }), Hex.fromNumber(authentication.zoneId, { size: 4 }), Hex.fromNumber(authentication.chainId, { size: 8 }), Hex.fromNumber(authentication.issuedAt, { size: 8 }), Hex.fromNumber(authentication.expiresAt, { size: 8 }));
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Computes the sign payload for a Zone RPC authentication token.
|
|
140
|
+
*
|
|
141
|
+
* When `userAddress` is provided, the payload is wrapped as
|
|
142
|
+
* `keccak256(0x04 || authHash || userAddress)` to match V2 keychain signing.
|
|
143
|
+
*
|
|
144
|
+
* @example
|
|
145
|
+
* ```ts twoslash
|
|
146
|
+
* import { ZoneRpcAuthentication } from 'ox/tempo'
|
|
147
|
+
*
|
|
148
|
+
* const authentication = ZoneRpcAuthentication.from({
|
|
149
|
+
* chainId: 4217000026,
|
|
150
|
+
* expiresAt: 1711235160,
|
|
151
|
+
* issuedAt: 1711234560,
|
|
152
|
+
* zoneId: 26,
|
|
153
|
+
* })
|
|
154
|
+
*
|
|
155
|
+
* const payload = ZoneRpcAuthentication.getSignPayload(authentication)
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @param authentication - The Zone RPC authentication token.
|
|
159
|
+
* @param options - Options.
|
|
160
|
+
* @returns The sign payload.
|
|
161
|
+
*/
|
|
162
|
+
export function getSignPayload(authentication, options = {}) {
|
|
163
|
+
const authHash = hash(authentication);
|
|
164
|
+
if (options.userAddress)
|
|
165
|
+
return Hash.keccak256(Hex.concat('0x04', authHash, TempoAddress.resolve(options.userAddress)));
|
|
166
|
+
return authHash;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Computes the raw authorization hash for a Zone RPC authentication token.
|
|
170
|
+
*
|
|
171
|
+
* The hash is `keccak256(magicBytes || fields)`.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts twoslash
|
|
175
|
+
* import { ZoneRpcAuthentication } from 'ox/tempo'
|
|
176
|
+
*
|
|
177
|
+
* const authentication = ZoneRpcAuthentication.from({
|
|
178
|
+
* chainId: 4217000026,
|
|
179
|
+
* expiresAt: 1711235160,
|
|
180
|
+
* issuedAt: 1711234560,
|
|
181
|
+
* zoneId: 26,
|
|
182
|
+
* })
|
|
183
|
+
*
|
|
184
|
+
* const hash = ZoneRpcAuthentication.hash(authentication)
|
|
185
|
+
* ```
|
|
186
|
+
*
|
|
187
|
+
* @param authentication - The Zone RPC authentication token.
|
|
188
|
+
* @returns The authorization hash.
|
|
189
|
+
*/
|
|
190
|
+
export function hash(authentication) {
|
|
191
|
+
return Hash.keccak256(Hex.concat(magicBytes, getFields(authentication)));
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Serializes a Zone RPC authentication token to hex.
|
|
195
|
+
*
|
|
196
|
+
* The serialized format is `<signature><29-byte fields>`.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts twoslash
|
|
200
|
+
* import { Secp256k1 } from 'ox'
|
|
201
|
+
* import { ZoneRpcAuthentication } from 'ox/tempo'
|
|
202
|
+
*
|
|
203
|
+
* const authentication = ZoneRpcAuthentication.from({
|
|
204
|
+
* chainId: 4217000026,
|
|
205
|
+
* expiresAt: 1711235160,
|
|
206
|
+
* issuedAt: 1711234560,
|
|
207
|
+
* zoneId: 26,
|
|
208
|
+
* })
|
|
209
|
+
*
|
|
210
|
+
* const signature = Secp256k1.sign({
|
|
211
|
+
* payload: ZoneRpcAuthentication.getSignPayload(authentication),
|
|
212
|
+
* privateKey: '0x...',
|
|
213
|
+
* })
|
|
214
|
+
*
|
|
215
|
+
* const serialized = ZoneRpcAuthentication.serialize(authentication, {
|
|
216
|
+
* signature,
|
|
217
|
+
* })
|
|
218
|
+
* ```
|
|
219
|
+
*
|
|
220
|
+
* @param authentication - The Zone RPC authentication token.
|
|
221
|
+
* @param options - Serialization options.
|
|
222
|
+
* @returns The serialized authentication token.
|
|
223
|
+
*/
|
|
224
|
+
export function serialize(authentication, options = {}) {
|
|
225
|
+
const signature = options.signature || authentication.signature;
|
|
226
|
+
if (!signature)
|
|
227
|
+
throw new MissingSignatureError();
|
|
228
|
+
return Hex.concat(SignatureEnvelope.serialize(SignatureEnvelope.from(signature)), getFields(authentication));
|
|
229
|
+
}
|
|
230
|
+
/** Error thrown when a serialized authentication token cannot be deserialized. */
|
|
231
|
+
export class InvalidSerializedError extends Errors.BaseError {
|
|
232
|
+
constructor({ reason, serialized }) {
|
|
233
|
+
super(`Unable to deserialize Zone RPC authentication: ${reason}`, {
|
|
234
|
+
metaMessages: [`Serialized: ${serialized}`],
|
|
235
|
+
});
|
|
236
|
+
Object.defineProperty(this, "name", {
|
|
237
|
+
enumerable: true,
|
|
238
|
+
configurable: true,
|
|
239
|
+
writable: true,
|
|
240
|
+
value: 'ZoneRpcAuthentication.InvalidSerializedError'
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/** Error thrown when serializing an authentication token without a signature. */
|
|
245
|
+
export class MissingSignatureError extends Errors.BaseError {
|
|
246
|
+
constructor() {
|
|
247
|
+
super('Zone RPC authentication is missing a signature.');
|
|
248
|
+
Object.defineProperty(this, "name", {
|
|
249
|
+
enumerable: true,
|
|
250
|
+
configurable: true,
|
|
251
|
+
writable: true,
|
|
252
|
+
value: 'ZoneRpcAuthentication.MissingSignatureError'
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=ZoneRpcAuthentication.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ZoneRpcAuthentication.js","sourceRoot":"","sources":["../../tempo/ZoneRpcAuthentication.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAA;AAC3C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAA;AACvC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAA;AAErC,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAA;AAC3D,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AAEjD;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,uBAAgC,CAAA;AAE1D;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GACrB,oEAA6E,CAAA;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,EAAW,CAAA;AAErC,+CAA+C;AAC/C,MAAM,CAAC,MAAM,OAAO,GAAG,CAAU,CAAA;AAqDjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAM,UAAU,IAAI,CAIlB,cAAsD,EACtD,UAAmC,EAAE;IAErC,MAAM,IAAI,GAAG,cAAuC,CAAA;IACpD,MAAM,QAAQ,GAAG;QACf,GAAG,IAAI;QACP,OAAO;KACR,CAAA;IACD,IAAI,OAAO,CAAC,SAAS;QACnB,OAAO;YACL,GAAG,QAAQ;YACX,SAAS,EAAE,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;SAC5C,CAAA;IACZ,OAAO,QAAiB,CAAA;AAC1B,CAAC;AA8BD;;;;;;;;;;;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;IAE3D,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,cAAc,CAAC,CAAC,CAAC,CAAA;AAC1E,CAAC;AAUD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,SAAS,CACvB,cAA2D,EAC3D,UAA6B,EAAE;IAE/B,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,cAAc,CAAC,SAAS,CAAA;IAC/D,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,qBAAqB,EAAE,CAAA;IAEjD,OAAO,GAAG,CAAC,MAAM,CACf,iBAAiB,CAAC,SAAS,CAAC,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAC9D,SAAS,CAAC,cAAc,CAAC,CAC1B,CAAA;AACH,CAAC;AAeD,kFAAkF;AAClF,MAAM,OAAO,sBAAuB,SAAQ,MAAM,CAAC,SAAS;IAG1D,YAAY,EAAE,MAAM,EAAE,UAAU,EAA2C;QACzE,KAAK,CAAC,kDAAkD,MAAM,EAAE,EAAE;YAChE,YAAY,EAAE,CAAC,eAAe,UAAU,EAAE,CAAC;SAC5C,CAAC,CAAA;QALc;;;;mBAAO,8CAA8C;WAAA;IAMvE,CAAC;CACF;AAED,iFAAiF;AACjF,MAAM,OAAO,qBAAsB,SAAQ,MAAM,CAAC,SAAS;IAGzD;QACE,KAAK,CAAC,iDAAiD,CAAC,CAAA;QAHxC;;;;mBAAO,6CAA6C;WAAA;IAItE,CAAC;CACF"}
|
package/_esm/tempo/index.js
CHANGED
|
@@ -363,4 +363,59 @@ export * as TransactionRequest from './TransactionRequest.js';
|
|
|
363
363
|
* @category Reference
|
|
364
364
|
*/
|
|
365
365
|
export * as TxEnvelopeTempo from './TxEnvelopeTempo.js';
|
|
366
|
+
/**
|
|
367
|
+
* Zone ID utilities for converting between zone IDs and zone chain IDs.
|
|
368
|
+
*
|
|
369
|
+
* Zone chain IDs are deterministically derived from zone IDs using the formula
|
|
370
|
+
* `421_700_000 + zoneId`. This module provides helpers to convert between them.
|
|
371
|
+
*
|
|
372
|
+
* @example
|
|
373
|
+
* ```ts twoslash
|
|
374
|
+
* import { ZoneId } from 'ox/tempo'
|
|
375
|
+
*
|
|
376
|
+
* const zoneId = ZoneId.fromChainId(421_700_026)
|
|
377
|
+
* // @log: 26
|
|
378
|
+
*
|
|
379
|
+
* const chainId = ZoneId.toChainId(26)
|
|
380
|
+
* // @log: 421700026
|
|
381
|
+
* ```
|
|
382
|
+
*
|
|
383
|
+
* @category Reference
|
|
384
|
+
*/
|
|
385
|
+
export * as ZoneId from './ZoneId.js';
|
|
386
|
+
/**
|
|
387
|
+
* Zone RPC authentication token utilities for private zone RPC access.
|
|
388
|
+
*
|
|
389
|
+
* Zone RPC authentication tokens are short-lived, read-only credentials used in
|
|
390
|
+
* the `X-Authorization-Token` header when talking to private zone RPC endpoints.
|
|
391
|
+
* They reuse Tempo's multi-signature model, so secp256k1, P256, WebAuthn, and
|
|
392
|
+
* keychain access-key signatures all share the same wire format as Tempo
|
|
393
|
+
* transaction signatures.
|
|
394
|
+
*
|
|
395
|
+
* [Zone RPC Specification](https://docs.tempo.xyz/protocol/privacy/rpc#authorization-tokens)
|
|
396
|
+
*
|
|
397
|
+
* @example
|
|
398
|
+
* ```ts twoslash
|
|
399
|
+
* import { Secp256k1 } from 'ox'
|
|
400
|
+
* import { ZoneRpcAuthentication } from 'ox/tempo'
|
|
401
|
+
*
|
|
402
|
+
* const authentication = ZoneRpcAuthentication.from({
|
|
403
|
+
* chainId: 4217000026,
|
|
404
|
+
* expiresAt: 1711235160,
|
|
405
|
+
* issuedAt: 1711234560,
|
|
406
|
+
* zoneId: 26,
|
|
407
|
+
* zonePortal: 'tempox0x0f1b0cedd7e8226e39ecb161f522c8b1ac45e9c8',
|
|
408
|
+
* })
|
|
409
|
+
*
|
|
410
|
+
* const signature = Secp256k1.sign({
|
|
411
|
+
* payload: ZoneRpcAuthentication.getSignPayload(authentication),
|
|
412
|
+
* privateKey: '0x...',
|
|
413
|
+
* })
|
|
414
|
+
*
|
|
415
|
+
* const token = ZoneRpcAuthentication.serialize(authentication, { signature })
|
|
416
|
+
* ```
|
|
417
|
+
*
|
|
418
|
+
* @category Reference
|
|
419
|
+
*/
|
|
420
|
+
export * as ZoneRpcAuthentication from './ZoneRpcAuthentication.js';
|
|
366
421
|
//# sourceMappingURL=index.js.map
|