openclaw-app 1.0.3 → 1.0.4

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/index.ts CHANGED
@@ -663,10 +663,6 @@ async function handleRelayMessage(ctx: any, accountId: string, state: RelayState
663
663
  ctx.log?.warn?.(`[${CHANNEL_ID}] [${accountId}] [E2E] peer_joined missing sessionKey, ignoring`);
664
664
  return;
665
665
  }
666
- if (!state.relayToken) {
667
- ctx.log?.error?.(`[${CHANNEL_ID}] [${accountId}] [E2E] Relay token missing, cannot authenticate handshake`);
668
- return;
669
- }
670
666
  // Always restart E2E when peer_joined arrives — the app may have
671
667
  // reconnected with a fresh _e2eReadyCompleter and is waiting for a
672
668
  // new handshake even if we still hold an old session state.
@@ -678,23 +674,26 @@ async function handleRelayMessage(ctx: any, accountId: string, state: RelayState
678
674
  const sessionE2E = makeE2EState();
679
675
  state.e2eSessions.set(sessionKey, sessionE2E);
680
676
  const pubkey = await e2eInit(sessionE2E);
681
- const ts = Date.now();
682
- const mac = await buildHandshakeMac(
683
- state.relayToken,
684
- "plugin",
685
- sessionKey,
686
- pubkey,
687
- ts,
688
- HANDSHAKE_AUTH_VERSION
689
- );
690
- const handshakeWithSession = JSON.stringify({
677
+ const handshakePayload: Record<string, unknown> = {
691
678
  type: "handshake",
692
- v: HANDSHAKE_AUTH_VERSION,
693
679
  sessionKey,
694
680
  pubkey,
695
- ts,
696
- mac,
697
- });
681
+ };
682
+ if (state.relayToken) {
683
+ const ts = Date.now();
684
+ const mac = await buildHandshakeMac(
685
+ state.relayToken,
686
+ "plugin",
687
+ sessionKey,
688
+ pubkey,
689
+ ts,
690
+ HANDSHAKE_AUTH_VERSION
691
+ );
692
+ handshakePayload.v = HANDSHAKE_AUTH_VERSION;
693
+ handshakePayload.ts = ts;
694
+ handshakePayload.mac = mac;
695
+ }
696
+ const handshakeWithSession = JSON.stringify(handshakePayload);
698
697
  if (state.ws?.readyState === WebSocket.OPEN) {
699
698
  state.ws.send(handshakeWithSession);
700
699
  }
@@ -708,34 +707,36 @@ async function handleRelayMessage(ctx: any, accountId: string, state: RelayState
708
707
  const peerMac = msg.mac as string | undefined;
709
708
  const version = (msg.v as string | undefined) ?? HANDSHAKE_AUTH_VERSION;
710
709
  const peerTs = parseHandshakeTs(msg.ts);
711
- if (!sessionKey || !peerPubKey || !peerMac || peerTs == null) {
712
- ctx.log?.warn?.(`[${CHANNEL_ID}] [${accountId}] [E2E] Handshake missing auth fields`);
713
- return;
714
- }
715
- if (version !== HANDSHAKE_AUTH_VERSION) {
716
- ctx.log?.warn?.(`[${CHANNEL_ID}] [${accountId}] [E2E] Unsupported handshake version: ${version}`);
710
+ if (!sessionKey || !peerPubKey) {
711
+ ctx.log?.warn?.(`[${CHANNEL_ID}] [${accountId}] [E2E] Handshake missing sessionKey or pubkey`);
717
712
  return;
718
713
  }
719
- if (!isHandshakeTsFresh(peerTs)) {
720
- ctx.log?.warn?.(`[${CHANNEL_ID}] [${accountId}] [E2E] Handshake timestamp out of window, dropping`);
721
- return;
722
- }
723
- if (!state.relayToken) {
724
- ctx.log?.error?.(`[${CHANNEL_ID}] [${accountId}] [E2E] Relay token missing, cannot verify handshake`);
725
- return;
726
- }
727
- const verified = await verifyHandshakeMac(
728
- state.relayToken,
729
- "app",
730
- sessionKey,
731
- peerPubKey,
732
- peerTs,
733
- peerMac,
734
- version
735
- );
736
- if (!verified) {
737
- ctx.log?.warn?.(`[${CHANNEL_ID}] [${accountId}] [E2E] Handshake MAC verification failed, dropping`);
738
- return;
714
+ if (state.relayToken) {
715
+ if (!peerMac || peerTs == null) {
716
+ ctx.log?.warn?.(`[${CHANNEL_ID}] [${accountId}] [E2E] Handshake missing auth fields`);
717
+ return;
718
+ }
719
+ if (version !== HANDSHAKE_AUTH_VERSION) {
720
+ ctx.log?.warn?.(`[${CHANNEL_ID}] [${accountId}] [E2E] Unsupported handshake version: ${version}`);
721
+ return;
722
+ }
723
+ if (!isHandshakeTsFresh(peerTs)) {
724
+ ctx.log?.warn?.(`[${CHANNEL_ID}] [${accountId}] [E2E] Handshake timestamp out of window, dropping`);
725
+ return;
726
+ }
727
+ const verified = await verifyHandshakeMac(
728
+ state.relayToken,
729
+ "app",
730
+ sessionKey,
731
+ peerPubKey,
732
+ peerTs,
733
+ peerMac,
734
+ version
735
+ );
736
+ if (!verified) {
737
+ ctx.log?.warn?.(`[${CHANNEL_ID}] [${accountId}] [E2E] Handshake MAC verification failed, dropping`);
738
+ return;
739
+ }
739
740
  }
740
741
  let sessionE2E = state.e2eSessions.get(sessionKey);
741
742
  if (!sessionE2E) {
@@ -744,23 +745,26 @@ async function handleRelayMessage(ctx: any, accountId: string, state: RelayState
744
745
  sessionE2E = makeE2EState();
745
746
  state.e2eSessions.set(sessionKey, sessionE2E);
746
747
  const pubkey = await e2eInit(sessionE2E);
747
- const ts = Date.now();
748
- const mac = await buildHandshakeMac(
749
- state.relayToken,
750
- "plugin",
751
- sessionKey,
752
- pubkey,
753
- ts,
754
- HANDSHAKE_AUTH_VERSION
755
- );
756
- const handshakeWithSession = JSON.stringify({
748
+ const handshakePayload: Record<string, unknown> = {
757
749
  type: "handshake",
758
- v: HANDSHAKE_AUTH_VERSION,
759
750
  sessionKey,
760
751
  pubkey,
761
- ts,
762
- mac,
763
- });
752
+ };
753
+ if (state.relayToken) {
754
+ const ts = Date.now();
755
+ const mac = await buildHandshakeMac(
756
+ state.relayToken,
757
+ "plugin",
758
+ sessionKey,
759
+ pubkey,
760
+ ts,
761
+ HANDSHAKE_AUTH_VERSION
762
+ );
763
+ handshakePayload.v = HANDSHAKE_AUTH_VERSION;
764
+ handshakePayload.ts = ts;
765
+ handshakePayload.mac = mac;
766
+ }
767
+ const handshakeWithSession = JSON.stringify(handshakePayload);
764
768
  if (state.ws?.readyState === WebSocket.OPEN) {
765
769
  state.ws.send(handshakeWithSession);
766
770
  ctx.log?.info?.(`[${CHANNEL_ID}] [${accountId}] [E2E] Session ${sessionKey} — sent handshake (reactive, no prior peer_joined)`);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "openclaw-app",
3
3
  "name": "OpenClaw App",
4
- "version": "1.0.3",
4
+ "version": "1.0.4",
5
5
  "description": "Mobile app channel for OpenClaw — chat via the OpenClaw Mobile app through a Cloudflare Worker relay.",
6
6
  "channels": [
7
7
  "openclaw-app"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-app",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "OpenClaw Mobile channel plugin — relay bridge for the OpenClaw Mobile app",
5
5
  "main": "index.ts",
6
6
  "type": "module",