@langitdeveloper/baileys 2.0.6 → 2.0.7
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/lib/Signal/libsignal.js +15 -0
- package/package.json +1 -1
package/lib/Signal/libsignal.js
CHANGED
|
@@ -105,6 +105,21 @@ function makeLibSignalRepository(auth) {
|
|
|
105
105
|
const cipher = new libsignal.SessionBuilder(storage, jidToSignalProtocolAddress(jid));
|
|
106
106
|
await cipher.initOutgoing(session);
|
|
107
107
|
},
|
|
108
|
+
async validateSession(jid) {
|
|
109
|
+
try {
|
|
110
|
+
const addr = jidToSignalProtocolAddress(jid);
|
|
111
|
+
const session = await storage.loadSession(addr.toString());
|
|
112
|
+
if (!session) {
|
|
113
|
+
return { exists: false, reason: 'no session' };
|
|
114
|
+
}
|
|
115
|
+
if (!session.haveOpenSession()) {
|
|
116
|
+
return { exists: false, reason: 'no open session' };
|
|
117
|
+
}
|
|
118
|
+
return { exists: true };
|
|
119
|
+
} catch (error) {
|
|
120
|
+
return { exists: false, reason: 'validation error' };
|
|
121
|
+
}
|
|
122
|
+
},
|
|
108
123
|
jidToSignalProtocolAddress(jid) {
|
|
109
124
|
return jidToSignalProtocolAddress(jid).toString();
|
|
110
125
|
}
|