@calimero-network/mero-js 16.1.0 → 17.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.
@@ -15,7 +15,7 @@
15
15
  */
16
16
  import type { SignedGroupOpenInvitation } from '../admin-api/admin-types.js';
17
17
  /** Core's `SIGNED_NAMESPACE_OP_SCHEMA_VERSION`. A node refuses any other value. */
18
- export declare const SIGNED_NAMESPACE_OP_SCHEMA_VERSION = 7;
18
+ export declare const SIGNED_NAMESPACE_OP_SCHEMA_VERSION = 8;
19
19
  /**
20
20
  * Borsh-encode a `SignedGroupOpenInvitation`.
21
21
  *
@@ -1,6 +1,6 @@
1
1
  import { concat, derivePublicKey, fromHex, hex, importSigningKey, u32le, u64le, } from '../crypto/internal.js';
2
2
  /** Core's `SIGNED_NAMESPACE_OP_SCHEMA_VERSION`. A node refuses any other value. */
3
- export const SIGNED_NAMESPACE_OP_SCHEMA_VERSION = 7;
3
+ export const SIGNED_NAMESPACE_OP_SCHEMA_VERSION = 8;
4
4
  /** Domain prefixed to the signable bytes; core's `NAMESPACE_GOVERNANCE_SIGN_DOMAIN`. */
5
5
  const NAMESPACE_SIGN_DOMAIN = new TextEncoder().encode('calimero.namespace.v1');
6
6
  /** `NamespaceOp::Root` is the first variant. */
@@ -112,7 +112,19 @@ export async function signMemberJoinOp(input) {
112
112
  const signer = await derivePublicKey(input.deviceSecret);
113
113
  const signable = concat(new Uint8Array([SIGNED_NAMESPACE_OP_SCHEMA_VERSION]), fromHex(input.namespaceId, 'namespaceId', 32), u32le(parents.length), ...parents.map((p, i) => fromHex(p, `parentOpHashes[${i}]`, 32)), signer, u64le(input.nonce), op);
114
114
  const signature = new Uint8Array(await crypto.subtle.sign('Ed25519', key, concat(NAMESPACE_SIGN_DOMAIN, signable)));
115
- // The signed struct repeats the signable fields, then the signature. The domain
116
- // is a signing prefix only and is never part of the encoded op.
117
- return hex(concat(signable, signature));
115
+ // The signed struct repeats the signable fields, then the signature, then the
116
+ // admitter endorsement. The domain is a signing prefix only and is never part
117
+ // of the encoded op.
118
+ //
119
+ // The endorsement is written as borsh `None` — a single `0x00` — and that is
120
+ // the correct value from here, not a placeholder. It authorises the membership
121
+ // and can only be signed by an account the invitation named as an admitter,
122
+ // which a keyholder is not. The admitter attaches its own as it relays the op
123
+ // through `admitJoin`.
124
+ //
125
+ // It sits outside `signable`, so it is outside this signature and outside the
126
+ // op's id. That is what makes attaching it possible: the admitter changes
127
+ // neither what was signed here nor which op this is.
128
+ const unendorsed = new Uint8Array([0]);
129
+ return hex(concat(signable, signature, unendorsed));
118
130
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@calimero-network/mero-js",
3
- "version": "16.1.0",
3
+ "version": "17.0.0",
4
4
  "description": "Pure JavaScript SDK for Calimero",
5
5
  "type": "module",
6
6
  "exports": {