@calimero-network/mero-js 19.14.1 → 19.15.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.d.ts CHANGED
@@ -1,33 +1,35 @@
1
- export { MeroJs, createMeroJs } from './mero-js.js';
2
- export type { MeroJsConfig, TokenData } from './mero-js.js';
3
- export * from './http-client/index.js';
4
- export * from './auth-api/index.js';
5
- export * from './admin-api/index.js';
6
- export { parseAuthCallback, buildAuthLoginUrl } from './auth/index.js';
7
- export type { AuthCallbackResult, AuthLoginOptions } from './auth/index.js';
8
- export { MemoryTokenStore, LocalStorageTokenStore } from './token-store/index.js';
9
- export type { TokenStore } from './token-store/index.js';
10
- export { RpcClient, RpcError } from './rpc/index.js';
11
- export type { MigrateMyEntriesSummary } from './rpc/index.js';
12
- export type { ExecuteParams } from './rpc/index.js';
13
- export { SseClient, WsClient } from './events/index.js';
14
- export type { SseEventData, WsEventData, AppVersionChangedEvent, GroupMembershipEventData, GroupMigrationEventData, MigrationStartedData, MigrationProgressData, CascadeProgressData, MigrationCompletedData, } from './events/index.js';
15
- export { EphemeralClient, jsonCodec } from './ephemeral/index.js';
16
- export type { Codec, EphemeralEntry } from './ephemeral/index.js';
17
- export * from './cloud/index.js';
18
- export * from './relay/index.js';
19
- export { signWarrant, intentHash } from './warrant/index.js';
20
- export { generateAccountRoot, accountRootFromPhrase, accountRootFromSecret, signAccountLink, signAccountLogin, } from './account/index.js';
21
- export type { AccountRoot, RecoverableAccountRoot, AccountLinkInput, AccountLoginInput, } from './account/index.js';
22
- export { signDeviceCert, mintDeviceId, deviceCertPayload, accountForRoot, } from './device-cert/index.js';
23
- export type { DeviceCertInput } from './device-cert/index.js';
24
- export { signMemberJoinOp, encodeSignedInvitation, SIGNED_NAMESPACE_OP_SCHEMA_VERSION, } from './namespace-op/index.js';
25
- export type { SignMemberJoinInput } from './namespace-op/index.js';
26
- export type { WarrantInput } from './warrant/index.js';
27
- export { signLoginStatement } from './login/index.js';
28
- export type { Audience, LoginStatementInput } from './login/index.js';
29
- export { login, generateSessionKey } from './login/index.js';
30
- export type { LoginConfig, DelegatedSession, SessionKeyPair, } from './login/index.js';
31
- export * from './capabilities.js';
32
- export { DEFAULT_LOCAL_NODE_PORTS, localNodeUrl, nodeEndpoint, probeNodeHealth, discoverLocalNodes, } from './nodeDiscovery.js';
33
- export type { DiscoverLocalNodesOptions } from './nodeDiscovery.js';
1
+ export { MeroJs, createMeroJs } from "./mero-js.js";
2
+ export type { MeroJsConfig, TokenData } from "./mero-js.js";
3
+ export * from "./http-client/index.js";
4
+ export * from "./auth-api/index.js";
5
+ export * from "./admin-api/index.js";
6
+ export { parseAuthCallback, buildAuthLoginUrl } from "./auth/index.js";
7
+ export type { AuthCallbackResult, AuthLoginOptions } from "./auth/index.js";
8
+ export { MemoryTokenStore, LocalStorageTokenStore, } from "./token-store/index.js";
9
+ export type { TokenStore } from "./token-store/index.js";
10
+ export { RpcClient, RpcError } from "./rpc/index.js";
11
+ export type { MigrateMyEntriesSummary } from "./rpc/index.js";
12
+ export type { ExecuteParams } from "./rpc/index.js";
13
+ export { SseClient, WsClient } from "./events/index.js";
14
+ export type { SseEventData, WsEventData, AppVersionChangedEvent, GroupMembershipEventData, GroupMigrationEventData, MigrationStartedData, MigrationProgressData, CascadeProgressData, MigrationCompletedData, } from "./events/index.js";
15
+ export { EphemeralClient, jsonCodec } from "./ephemeral/index.js";
16
+ export type { Codec, EphemeralEntry } from "./ephemeral/index.js";
17
+ export * from "./cloud/index.js";
18
+ export * from "./relay/index.js";
19
+ export { signWarrant, intentHash } from "./warrant/index.js";
20
+ export { generateAccountRoot, accountRootFromPhrase, accountRootFromSecret, signAccountLink, signAccountLogin, } from "./account/index.js";
21
+ export type { AccountRoot, RecoverableAccountRoot, AccountLinkInput, AccountLoginInput, } from "./account/index.js";
22
+ export { signDeviceCert, mintDeviceId, deviceCertPayload, accountForRoot, } from "./device-cert/index.js";
23
+ export type { DeviceCertInput } from "./device-cert/index.js";
24
+ export { signMemberJoinOp, encodeSignedInvitation, SIGNED_NAMESPACE_OP_SCHEMA_VERSION, } from "./namespace-op/index.js";
25
+ export type { SignMemberJoinInput } from "./namespace-op/index.js";
26
+ export type { WarrantInput } from "./warrant/index.js";
27
+ export { requestBodyHash, signRequest } from "./request/index.js";
28
+ export type { RequestSigInput } from "./request/index.js";
29
+ export { signLoginStatement } from "./login/index.js";
30
+ export type { Audience, LoginStatementInput } from "./login/index.js";
31
+ export { login, generateSessionKey } from "./login/index.js";
32
+ export type { LoginConfig, DelegatedSession, SessionKeyPair, } from "./login/index.js";
33
+ export * from "./capabilities.js";
34
+ export { DEFAULT_LOCAL_NODE_PORTS, localNodeUrl, nodeEndpoint, probeNodeHealth, discoverLocalNodes, } from "./nodeDiscovery.js";
35
+ export type { DiscoverLocalNodesOptions } from "./nodeDiscovery.js";
package/dist/index.js CHANGED
@@ -1,37 +1,38 @@
1
1
  // Mero.js - Pure JavaScript SDK for Calimero
2
2
  // This will contain the pure JavaScript SDK without React dependencies
3
3
  // Main SDK class
4
- export { MeroJs, createMeroJs } from './mero-js.js';
4
+ export { MeroJs, createMeroJs } from "./mero-js.js";
5
5
  // HTTP client module (Web Standards based)
6
- export * from './http-client/index.js';
6
+ export * from "./http-client/index.js";
7
7
  // Auth API client
8
- export * from './auth-api/index.js';
8
+ export * from "./auth-api/index.js";
9
9
  // Admin API client
10
- export * from './admin-api/index.js';
10
+ export * from "./admin-api/index.js";
11
11
  // Auth utilities
12
- export { parseAuthCallback, buildAuthLoginUrl } from './auth/index.js';
12
+ export { parseAuthCallback, buildAuthLoginUrl } from "./auth/index.js";
13
13
  // Token store
14
- export { MemoryTokenStore, LocalStorageTokenStore } from './token-store/index.js';
14
+ export { MemoryTokenStore, LocalStorageTokenStore, } from "./token-store/index.js";
15
15
  // RPC client
16
- export { RpcClient, RpcError } from './rpc/index.js';
16
+ export { RpcClient, RpcError } from "./rpc/index.js";
17
17
  // Events (SSE / WebSocket)
18
- export { SseClient, WsClient } from './events/index.js';
18
+ export { SseClient, WsClient } from "./events/index.js";
19
19
  // Ephemeral presence (cursors / typing / online)
20
- export { EphemeralClient, jsonCodec } from './ephemeral/index.js';
20
+ export { EphemeralClient, jsonCodec } from "./ephemeral/index.js";
21
21
  // Cloud client — namespaces, relays, HA, and the cloud sign-in path
22
- export * from './cloud/index.js';
22
+ export * from "./cloud/index.js";
23
23
  // Relay client — write through delegated execution, holding only a signing key
24
- export * from './relay/index.js';
24
+ export * from "./relay/index.js";
25
25
  // Warrant signing — mint the author's consent for a relay to run one intent
26
- export { signWarrant, intentHash } from './warrant/index.js';
26
+ export { signWarrant, intentHash } from "./warrant/index.js";
27
27
  // Account roots — mint one with a recovery phrase, or prove you hold one
28
- export { generateAccountRoot, accountRootFromPhrase, accountRootFromSecret, signAccountLink, signAccountLogin, } from './account/index.js';
29
- export { signDeviceCert, mintDeviceId, deviceCertPayload, accountForRoot, } from './device-cert/index.js';
30
- export { signMemberJoinOp, encodeSignedInvitation, SIGNED_NAMESPACE_OP_SCHEMA_VERSION, } from './namespace-op/index.js';
28
+ export { generateAccountRoot, accountRootFromPhrase, accountRootFromSecret, signAccountLink, signAccountLogin, } from "./account/index.js";
29
+ export { signDeviceCert, mintDeviceId, deviceCertPayload, accountForRoot, } from "./device-cert/index.js";
30
+ export { signMemberJoinOp, encodeSignedInvitation, SIGNED_NAMESPACE_OP_SCHEMA_VERSION, } from "./namespace-op/index.js";
31
31
  // Login-statement signing — the device's half of a password-free session
32
- export { signLoginStatement } from './login/index.js';
33
- export { login, generateSessionKey } from './login/index.js';
32
+ export { requestBodyHash, signRequest } from "./request/index.js";
33
+ export { signLoginStatement } from "./login/index.js";
34
+ export { login, generateSessionKey } from "./login/index.js";
34
35
  // Member capability bitmask constants & helpers
35
- export * from './capabilities.js';
36
+ export * from "./capabilities.js";
36
37
  // Utilities
37
- export { DEFAULT_LOCAL_NODE_PORTS, localNodeUrl, nodeEndpoint, probeNodeHealth, discoverLocalNodes, } from './nodeDiscovery.js';
38
+ export { DEFAULT_LOCAL_NODE_PORTS, localNodeUrl, nodeEndpoint, probeNodeHealth, discoverLocalNodes, } from "./nodeDiscovery.js";
package/dist/index.mjs CHANGED
@@ -6442,8 +6442,47 @@ async function signMemberJoinOp(input) {
6442
6442
  return hex(concat(signable, signature, unendorsed));
6443
6443
  }
6444
6444
 
6445
+ // src/request/request-sig.ts
6446
+ var SIGN_DOMAIN2 = new TextEncoder().encode("calimero.auth.request.v1");
6447
+ var BODY_DOMAIN = new TextEncoder().encode("calimero.auth.request.body.v1");
6448
+ function borshString2(value) {
6449
+ const bytes = new TextEncoder().encode(value);
6450
+ return concat(u32le(bytes.length), bytes);
6451
+ }
6452
+ async function requestBodyHash(body = new Uint8Array(0)) {
6453
+ const bytes = typeof body === "string" ? new TextEncoder().encode(body) : body;
6454
+ return domainHash(BODY_DOMAIN, [bytes]);
6455
+ }
6456
+ async function signRequest(input) {
6457
+ const key = await importSigningKey(input.signerSecret);
6458
+ const bodyHash = await requestBodyHash(input.body);
6459
+ const issuedAt = u64le(input.issuedAt);
6460
+ const expiresAt = u64le(input.expiresAt);
6461
+ const encoder = new TextEncoder();
6462
+ const preimage = await domainHash(SIGN_DOMAIN2, [
6463
+ encoder.encode(input.method),
6464
+ encoder.encode(input.path),
6465
+ bodyHash,
6466
+ issuedAt,
6467
+ expiresAt
6468
+ ]);
6469
+ const signature = new Uint8Array(
6470
+ await crypto.subtle.sign({ name: "Ed25519" }, key, preimage)
6471
+ );
6472
+ return hex(
6473
+ concat(
6474
+ borshString2(input.method),
6475
+ borshString2(input.path),
6476
+ bodyHash,
6477
+ issuedAt,
6478
+ expiresAt,
6479
+ signature
6480
+ )
6481
+ );
6482
+ }
6483
+
6445
6484
  // src/login/login.ts
6446
- var SIGN_DOMAIN2 = new TextEncoder().encode("calimero.auth.login.v1");
6485
+ var SIGN_DOMAIN3 = new TextEncoder().encode("calimero.auth.login.v1");
6447
6486
  var AUDIENCE_TAG = {
6448
6487
  webOrigin: 0,
6449
6488
  codeSigningId: 1,
@@ -6482,7 +6521,7 @@ async function signLoginStatement(input) {
6482
6521
  const deviceKey = await derivePublicKey(input.deviceSecret);
6483
6522
  const issuedAt = u64le(input.issuedAt);
6484
6523
  const expiresAt = u64le(input.expiresAt);
6485
- const preimage = await domainHash(SIGN_DOMAIN2, [
6524
+ const preimage = await domainHash(SIGN_DOMAIN3, [
6486
6525
  node,
6487
6526
  audienceSigningBytes(input.audience),
6488
6527
  challenge,
@@ -6718,12 +6757,14 @@ export {
6718
6757
  nodeEndpoint,
6719
6758
  parseAuthCallback,
6720
6759
  probeNodeHealth,
6760
+ requestBodyHash,
6721
6761
  routingProofHeaders,
6722
6762
  signAccountLink,
6723
6763
  signAccountLogin,
6724
6764
  signDeviceCert,
6725
6765
  signLoginStatement,
6726
6766
  signMemberJoinOp,
6767
+ signRequest,
6727
6768
  signRoutingChallenge,
6728
6769
  signWarrant,
6729
6770
  withCap,