arnacon-webrtc-service 0.1.13 → 0.1.14
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
|
@@ -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:
|
|
179
|
+
sessionId: childSessionId,
|
|
164
180
|
sdp: sourceOffer.sdp,
|
|
165
181
|
candidates: Array.isArray(sourceOffer.candidates) ? sourceOffer.candidates : [],
|
|
166
182
|
callNonce: sourceOffer.callNonce || null,
|