@calimero-network/mero-js 15.3.4 → 16.1.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/admin-api/admin-types.d.ts +30 -16
- package/dist/index.browser.mjs +2 -2
- package/dist/index.browser.mjs.map +3 -3
- package/dist/index.cjs +9 -10
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +9 -10
- package/dist/index.mjs.map +2 -2
- package/dist/namespace-op/namespace-op.js +9 -9
- package/package.json +1 -1
|
@@ -51,12 +51,6 @@ function borshString(value) {
|
|
|
51
51
|
const bytes = new TextEncoder().encode(value);
|
|
52
52
|
return concat(u32le(bytes.length), bytes);
|
|
53
53
|
}
|
|
54
|
-
function encodeAdmitterHint(hint) {
|
|
55
|
-
if ('multiaddr' in hint) {
|
|
56
|
-
return concat(new Uint8Array([0]), borshString(hint.multiaddr));
|
|
57
|
-
}
|
|
58
|
-
return concat(new Uint8Array([1]), borshString(hint.url));
|
|
59
|
-
}
|
|
60
54
|
/**
|
|
61
55
|
* Borsh-encode a `SignedGroupOpenInvitation`.
|
|
62
56
|
*
|
|
@@ -70,7 +64,7 @@ function encodeAdmitterHint(hint) {
|
|
|
70
64
|
export function encodeSignedInvitation(signed) {
|
|
71
65
|
const body = signed.invitation;
|
|
72
66
|
const admitters = body.admitters ?? [];
|
|
73
|
-
const
|
|
67
|
+
const admitterAddrs = signed.admitter_addrs ?? [];
|
|
74
68
|
return concat(
|
|
75
69
|
// GroupInvitationFromAdmin.
|
|
76
70
|
//
|
|
@@ -79,11 +73,17 @@ export function encodeSignedInvitation(signed) {
|
|
|
79
73
|
// wrong way yields 32 bytes that encode cleanly and verify as nothing.
|
|
80
74
|
bytes32(body.inviter_identity, 'inviter_identity'), bytes32(body.group_id, 'group_id'), u64le(body.expiration_timestamp), bytes32(body.secret_salt, 'secret_salt'), new Uint8Array([body.invited_role]), u32le(admitters.length), ...admitters.map((a, i) => fromHex(a, `admitters[${i}]`, 32)),
|
|
81
75
|
// ...then the enclosing SignedGroupOpenInvitation, in declaration order.
|
|
82
|
-
// `inviter_account` sits between the signature and the
|
|
76
|
+
// `inviter_account` sits between the signature and the addresses; putting it
|
|
83
77
|
// anywhere else still encodes 32 bytes and still verifies as nothing.
|
|
84
78
|
borshString(signed.inviter_signature), signed.inviter_account
|
|
85
79
|
? concat(new Uint8Array([1]), fromHex(signed.inviter_account, 'inviter_account', 32))
|
|
86
|
-
: new Uint8Array([0]),
|
|
80
|
+
: new Uint8Array([0]),
|
|
81
|
+
// A `Vec<String>`, so each entry is a bare borsh string. This carried an
|
|
82
|
+
// enum until core dropped the URL variant, and an enum writes a
|
|
83
|
+
// discriminant byte ahead of each entry — encoding one here now would shift
|
|
84
|
+
// every following byte and fail as `invalid invitation signature`, pointing
|
|
85
|
+
// nowhere near this line.
|
|
86
|
+
u32le(admitterAddrs.length), ...admitterAddrs.map(borshString), optionalBytes32(signed.application_id, 'application_id'),
|
|
87
87
|
// Borsh order follows core's field order, where this is `bytecode_id`; the
|
|
88
88
|
// JSON key is `app_key`, a rename covering both directions that core pins in
|
|
89
89
|
// a test. Encoding by the Rust name would read `undefined` and emit a None
|