arnacon-webrtc-service 0.1.13 → 0.1.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arnacon-webrtc-service",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "Arnacon WebRTC core runtime and service modules",
5
5
  "main": "./webRTCservice/core.js",
6
6
  "type": "commonjs",
@@ -59,6 +59,17 @@ function createBridgeApi({
59
59
  }
60
60
  }
61
61
 
62
+ function getCallerNumberLabel(identity) {
63
+ if (!identity || typeof identity !== "string") return "";
64
+ const trimmed = identity.trim();
65
+ if (!trimmed) return "";
66
+ const atPos = trimmed.indexOf("@");
67
+ if (atPos > 0) return trimmed.slice(0, atPos);
68
+ const dotPos = trimmed.indexOf(".");
69
+ if (dotPos > 0) return trimmed.slice(0, dotPos);
70
+ return trimmed;
71
+ }
72
+
62
73
  async function notifyAndBridge(callerSessionId, destination) {
63
74
  const callerSession = sessions.get(callerSessionId);
64
75
  if (!callerSession) throw new Error("Caller session not found");
@@ -107,6 +118,7 @@ function createBridgeApi({
107
118
 
108
119
  const groupId = newRingGroupId();
109
120
  const callerEns = callerSession.callerEns;
121
+ const callerNumberLabel = getCallerNumberLabel(callerEns);
110
122
  const timeoutMs = 60000;
111
123
  const group = {
112
124
  groupId,
@@ -142,25 +154,29 @@ function createBridgeApi({
142
154
 
143
155
  ringGroups.set(groupId, group);
144
156
 
157
+ let legIndex = 0;
145
158
  for (const destination of targets) {
146
159
  const calleeWallet = destination.wallet;
147
160
  const calleeEns = destination.ensName || calleeWallet;
148
161
  if (!calleeWallet) continue;
162
+ legIndex += 1;
163
+ const childSessionId = `${groupId}-leg${legIndex}`;
149
164
  const walletKey = calleeWallet.toLowerCase();
150
165
  group.pendingWallets.add(walletKey);
151
166
  addPendingEntry(walletKey, {
152
167
  kind: "multi",
153
168
  groupId,
154
169
  callerSessionId,
170
+ childSessionId,
155
171
  walletKey,
156
172
  ensName: calleeEns,
157
173
  });
158
174
 
159
175
  const callPayload = JSON.stringify({
160
176
  type: "offer",
161
- from: callerEns,
177
+ from: callerNumberLabel || callerEns,
162
178
  to: calleeEns,
163
- sessionId: callerSessionId,
179
+ sessionId: childSessionId,
164
180
  sdp: sourceOffer.sdp,
165
181
  candidates: Array.isArray(sourceOffer.candidates) ? sourceOffer.candidates : [],
166
182
  callNonce: sourceOffer.callNonce || null,
@@ -62,8 +62,8 @@ function createOfferFlow({
62
62
 
63
63
  if (type === "answer") {
64
64
  const session = sessions.get(sessionId);
65
- if (session && typeof onVerifiedNotifyAnswer === "function") {
66
- const result = await onVerifiedNotifyAnswer(sessionId, offer, session);
65
+ if (typeof onVerifiedNotifyAnswer === "function") {
66
+ const result = await onVerifiedNotifyAnswer(sessionId, offer, session || null);
67
67
  if (result && result.handled) {
68
68
  return result;
69
69
  }
@@ -877,6 +877,7 @@ async function onVerifiedNotifyAnswer(sessionId, offer, session) {
877
877
  if (!winner || !winner.handled) return null;
878
878
  if (!winner.won) {
879
879
  return {
880
+ handled: true,
880
881
  ok: true,
881
882
  ignored: true,
882
883
  reason: "multiring-loser",
@@ -886,6 +887,7 @@ async function onVerifiedNotifyAnswer(sessionId, offer, session) {
886
887
  }
887
888
  console.log(`[${sessionId}] Multi-ring winner selected on verified answer`);
888
889
  return {
890
+ handled: true,
889
891
  ok: true,
890
892
  accepted: true,
891
893
  reason: "multiring-winner",