@calimero-network/mero-js 18.3.0 → 19.0.0
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/dist/index.browser.mjs +2 -2
- package/dist/index.browser.mjs.map +3 -3
- package/dist/index.cjs +33 -1
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +33 -1
- package/dist/index.mjs.map +2 -2
- package/dist/warrant/warrant.d.ts +89 -10
- package/dist/warrant/warrant.js +109 -12
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3082,8 +3082,10 @@ async function derivePublicKey(secretHex) {
|
|
|
3082
3082
|
}
|
|
3083
3083
|
|
|
3084
3084
|
// src/warrant/warrant.ts
|
|
3085
|
-
var SIGN_DOMAIN = new TextEncoder().encode("calimero.warrant.
|
|
3085
|
+
var SIGN_DOMAIN = new TextEncoder().encode("calimero.warrant.v2");
|
|
3086
3086
|
var INTENT_DOMAIN = new TextEncoder().encode("calimero.warrant.intent.v1");
|
|
3087
|
+
var MAX_CITED_HEADS = 64;
|
|
3088
|
+
var UNPINNED_APP = "00".repeat(32);
|
|
3087
3089
|
async function intentHash(method, argsJson) {
|
|
3088
3090
|
const args = new TextEncoder().encode(JSON.stringify(argsJson));
|
|
3089
3091
|
return domainHash(INTENT_DOMAIN, [new TextEncoder().encode(method), args]);
|
|
@@ -3092,8 +3094,16 @@ async function signWarrant(input) {
|
|
|
3092
3094
|
const context = fromHex(input.context, "context", 32);
|
|
3093
3095
|
const authorAccount = fromHex(input.authorAccount, "authorAccount", 32);
|
|
3094
3096
|
const executor = fromHex(input.executor, "executor", 32);
|
|
3097
|
+
const appVersion = fromHex(
|
|
3098
|
+
input.appVersion ?? UNPINNED_APP,
|
|
3099
|
+
"appVersion",
|
|
3100
|
+
32
|
|
3101
|
+
);
|
|
3102
|
+
const accountHeads = citedHeads(input.accountHeads, "accountHeads");
|
|
3103
|
+
const governanceFloor = citedHeads(input.governanceFloor, "governanceFloor");
|
|
3095
3104
|
const key = await importSigningKey(input.deviceSecret);
|
|
3096
3105
|
const publicKey = await derivePublicKey(input.deviceSecret);
|
|
3106
|
+
const method = new TextEncoder().encode(input.method);
|
|
3097
3107
|
const commitment = await intentHash(input.method, input.argsJson);
|
|
3098
3108
|
const nonce = u64le(input.nonce);
|
|
3099
3109
|
const notAfter = u64le(input.notAfter);
|
|
@@ -3102,7 +3112,13 @@ async function signWarrant(input) {
|
|
|
3102
3112
|
authorAccount,
|
|
3103
3113
|
publicKey,
|
|
3104
3114
|
executor,
|
|
3115
|
+
appVersion,
|
|
3116
|
+
method,
|
|
3105
3117
|
commitment,
|
|
3118
|
+
u64le(accountHeads.length),
|
|
3119
|
+
...accountHeads,
|
|
3120
|
+
u64le(governanceFloor.length),
|
|
3121
|
+
...governanceFloor,
|
|
3106
3122
|
nonce,
|
|
3107
3123
|
notAfter
|
|
3108
3124
|
]);
|
|
@@ -3115,13 +3131,29 @@ async function signWarrant(input) {
|
|
|
3115
3131
|
authorAccount,
|
|
3116
3132
|
publicKey,
|
|
3117
3133
|
executor,
|
|
3134
|
+
appVersion,
|
|
3135
|
+
u32le(method.length),
|
|
3136
|
+
method,
|
|
3118
3137
|
commitment,
|
|
3138
|
+
u32le(accountHeads.length),
|
|
3139
|
+
...accountHeads,
|
|
3140
|
+
u32le(governanceFloor.length),
|
|
3141
|
+
...governanceFloor,
|
|
3119
3142
|
nonce,
|
|
3120
3143
|
notAfter,
|
|
3121
3144
|
signature
|
|
3122
3145
|
)
|
|
3123
3146
|
);
|
|
3124
3147
|
}
|
|
3148
|
+
function citedHeads(heads, label) {
|
|
3149
|
+
const list = heads ?? [];
|
|
3150
|
+
if (list.length > MAX_CITED_HEADS) {
|
|
3151
|
+
throw new Error(
|
|
3152
|
+
`${label} cites ${list.length} heads, over the ${MAX_CITED_HEADS} a node accepts`
|
|
3153
|
+
);
|
|
3154
|
+
}
|
|
3155
|
+
return list.map((head, i) => fromHex(head, `${label}[${i}]`, 32));
|
|
3156
|
+
}
|
|
3125
3157
|
|
|
3126
3158
|
// src/relay/relay-client.ts
|
|
3127
3159
|
var DEFAULT_TTL_SECONDS = 300;
|