Skip to content

Commit 8071f28

Browse files
committed
Remove Store.putRemoteIdentity
This function isn't strictly necessary as the application can add the identity to their store when first seeing it in isRemoteIdentityTrusted
1 parent 3fb04f7 commit 8071f28

File tree

8 files changed

+33
-79
lines changed

8 files changed

+33
-79
lines changed

README.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -146,22 +146,6 @@ Name|Type|Description
146146
`remoteIdentity`|Identity|The identity of the remote entity.
147147
`identityPublicKey`|ArrayBuffer|The purported remote identity's public key.
148148

149-
#### putRemoteIdentity
150-
151-
```
152-
putRemoteIdentity(remoteIdentity, identityPublicKey) → {Void}
153-
```
154-
155-
Store a public key to be associated with the remote identity. This is called when a session is successfully established
156-
and gives the application an opportunity to register trust in the identity.
157-
158-
##### Parameters
159-
160-
Name|Type|Description
161-
:---|:---|:----------
162-
`remoteIdentity`|Identity|The identity of the remote entity.
163-
`identityPublicKey`|ArrayBuffer|The remote identity's public key.
164-
165149
#### hasSession
166150

167151
```

dist/axolotl.js

Lines changed: 30 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,9 +1685,9 @@
16851685
if (!isTrusted) {
16861686
throw new UntrustedIdentityException();
16871687
}
1688-
$ctx.state = 49;
1688+
$ctx.state = 45;
16891689
break;
1690-
case 49:
1690+
case 45:
16911691
$ctx.state = retrievedPreKeyBundle.signedPreKey ? 5 : 10;
16921692
break;
16931693
case 5:
@@ -1708,9 +1708,9 @@
17081708
throw new InvalidKeyException('Both signed and unsigned pre keys are absent');
17091709
}
17101710
supportsV3 = !!retrievedPreKeyBundle.signedPreKey;
1711-
$ctx.state = 51;
1711+
$ctx.state = 47;
17121712
break;
1713-
case 51:
1713+
case 47:
17141714
$ctx.state = 13;
17151715
return crypto.generateKeyPair();
17161716
case 13:
@@ -1719,9 +1719,9 @@
17191719
break;
17201720
case 15:
17211721
theirSignedPreKey = supportsV3 ? retrievedPreKeyBundle.signedPreKey : retrievedPreKeyBundle.preKey;
1722-
$ctx.state = 53;
1722+
$ctx.state = 49;
17231723
break;
1724-
case 53:
1724+
case 49:
17251725
$__14 = store.getLocalIdentityKeyPair;
17261726
$__15 = $__14.call(store);
17271727
$ctx.state = 21;
@@ -1766,9 +1766,9 @@
17661766
signedPreKeyId: retrievedPreKeyBundle.signedPreKeyId,
17671767
baseKey: ourBaseKeyPair.public
17681768
};
1769-
$ctx.state = 55;
1769+
$ctx.state = 51;
17701770
break;
1771-
case 55:
1771+
case 51:
17721772
$ctx.state = 29;
17731773
return store.getLocalRegistrationId();
17741774
case 29:
@@ -1780,35 +1780,28 @@
17801780
return store.putSession(toIdentity, serialisedState);
17811781
});
17821782
sessionStateList.addSessionState(sessionState);
1783-
$ctx.state = 57;
1783+
$ctx.state = 53;
17841784
break;
1785-
case 57:
1785+
case 53:
17861786
$ctx.state = 33;
17871787
return sessionStateList.save();
17881788
case 33:
17891789
$ctx.maybeThrow();
17901790
$ctx.state = 35;
17911791
break;
17921792
case 35:
1793-
$ctx.state = 37;
1794-
return store.putRemoteIdentity(toIdentity, retrievedPreKeyBundle.identityKey);
1795-
case 37:
1796-
$ctx.maybeThrow();
1797-
$ctx.state = 39;
1798-
break;
1799-
case 39:
18001793
$__21 = self.getSessionForIdentity;
18011794
$__22 = $__21.call(self, toIdentity);
1802-
$ctx.state = 45;
1803-
break;
1804-
case 45:
18051795
$ctx.state = 41;
1806-
return $__22;
1796+
break;
18071797
case 41:
1798+
$ctx.state = 37;
1799+
return $__22;
1800+
case 37:
18081801
$__23 = $ctx.sent;
1809-
$ctx.state = 43;
1802+
$ctx.state = 39;
18101803
break;
1811-
case 43:
1804+
case 39:
18121805
$ctx.returnValue = $__23;
18131806
$ctx.state = -2;
18141807
break;
@@ -1828,9 +1821,9 @@
18281821
throw new UnsupportedProtocolVersionException('Protocol version ' + preKeyWhisperMessage.version.current + ' is not supported');
18291822
}
18301823
message = preKeyWhisperMessage.message;
1831-
$ctx.state = 63;
1824+
$ctx.state = 59;
18321825
break;
1833-
case 63:
1826+
case 59:
18341827
$ctx.state = 2;
18351828
return store.isRemoteIdentityTrusted(fromIdentity, message.identityKey);
18361829
case 2:
@@ -1841,9 +1834,9 @@
18411834
if (!isTrusted) {
18421835
throw new UntrustedIdentityException();
18431836
}
1844-
$ctx.state = 65;
1837+
$ctx.state = 61;
18451838
break;
1846-
case 65:
1839+
case 61:
18471840
$ctx.state = self.hasSessionForIdentity(fromIdentity) ? 5 : 14;
18481841
break;
18491842
case 5:
@@ -1926,9 +1919,9 @@
19261919
break;
19271920
case 37:
19281921
sessionState.theirBaseKey = message.baseKey;
1929-
$ctx.state = 67;
1922+
$ctx.state = 63;
19301923
break;
1931-
case 67:
1924+
case 63:
19321925
$__33 = getSessionStateListForIdentity(fromIdentity);
19331926
$ctx.state = 43;
19341927
break;
@@ -1946,35 +1939,28 @@
19461939
break;
19471940
case 45:
19481941
sessionStateList.addSessionState(sessionState);
1949-
$ctx.state = 69;
1942+
$ctx.state = 65;
19501943
break;
1951-
case 69:
1944+
case 65:
19521945
$ctx.state = 47;
19531946
return sessionStateList.save();
19541947
case 47:
19551948
$ctx.maybeThrow();
19561949
$ctx.state = 49;
19571950
break;
19581951
case 49:
1959-
$ctx.state = 51;
1960-
return store.putRemoteIdentity(fromIdentity, message.identityKey);
1961-
case 51:
1962-
$ctx.maybeThrow();
1963-
$ctx.state = 53;
1964-
break;
1965-
case 53:
19661952
$__36 = self.getSessionForIdentity;
19671953
$__37 = $__36.call(self, fromIdentity);
1968-
$ctx.state = 59;
1969-
break;
1970-
case 59:
19711954
$ctx.state = 55;
1972-
return $__37;
1955+
break;
19731956
case 55:
1957+
$ctx.state = 51;
1958+
return $__37;
1959+
case 51:
19741960
$__38 = $ctx.sent;
1975-
$ctx.state = 57;
1961+
$ctx.state = 53;
19761962
break;
1977-
case 57:
1963+
case 53:
19781964
$ctx.returnValue = $__38;
19791965
$ctx.state = -2;
19801966
break;
@@ -2338,7 +2324,6 @@
23382324
'getLocalPreKeyPair',
23392325
'getRemotePreKeyBundle',
23402326
'isRemoteIdentityTrusted',
2341-
'putRemoteIdentity',
23422327
'hasSession',
23432328
'getSession',
23442329
'putSession'

src/Axolotl.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ import co from "co";
6565
* @property {function} getLocalPreKeyPair
6666
* @property {function} getRemotePreKeyBundle
6767
* @property {function} isRemoteIdentityTrusted
68-
* @property {function} putRemoteIdentity
6968
* @property {function} hasSession
7069
* @property {function} getSession
7170
* @property {function} putSession

src/SessionFactory.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ function SessionFactory(crypto, store) {
7676
});
7777
sessionStateList.addSessionState(sessionState);
7878
yield sessionStateList.save();
79-
yield store.putRemoteIdentity(toIdentity, retrievedPreKeyBundle.identityKey);
8079
return yield self.getSessionForIdentity(toIdentity);
8180
});
8281

@@ -125,7 +124,6 @@ function SessionFactory(crypto, store) {
125124
var { sessionStateList } = yield getSessionStateListForIdentity(fromIdentity);
126125
sessionStateList.addSessionState(sessionState);
127126
yield sessionStateList.save();
128-
yield store.putRemoteIdentity(fromIdentity, message.identityKey);
129127
return yield self.getSessionForIdentity(fromIdentity);
130128
});
131129

src/Store.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ var methodNames = [
2424
"getLocalPreKeyPair",
2525
"getRemotePreKeyBundle",
2626
"isRemoteIdentityTrusted",
27-
"putRemoteIdentity",
2827
"hasSession",
2928
"getSession",
3029
"putSession"

test/integration/browser-amd.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@
5555
hasSession: stub,
5656
getSession: stub,
5757
putSession: stub,
58-
isRemoteIdentityTrusted: stub,
59-
putRemoteIdentity: stub
58+
isRemoteIdentityTrusted: stub
6059
});
6160
});
6261
});

test/integration/node.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ describe("integration", function() {
2828
hasSession: stub,
2929
getSession: stub,
3030
putSession: stub,
31-
isRemoteIdentityTrusted: stub,
32-
putRemoteIdentity: stub
31+
isRemoteIdentityTrusted: stub
3332
});
3433
});
3534
});

test/unit/Axolotl.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ var createStore = () => {
3434
putSession: sinon.spy((identity, session) => {
3535
sessions[identity] = session;
3636
}),
37-
isRemoteIdentityTrusted: sinon.stub(),
38-
putRemoteIdentity: sinon.stub()
37+
isRemoteIdentityTrusted: sinon.stub()
3938
};
4039
};
4140

@@ -500,13 +499,5 @@ describe("Axolotl", () => {
500499
var message = yield createEncryptedMessage(aliceAxolotl, bobIdentity);
501500
return assert.isRejected(decryptMessage(bobAxolotl, aliceIdentity, message), UntrustedIdentityException);
502501
}));
503-
it("stores identity in store", co.wrap(function*() {
504-
yield assertSessionsCanCommunicateTwoWay();
505-
506-
assert.ok(aliceStore.putRemoteIdentity.calledOnce);
507-
assert.ok(bobStore.putRemoteIdentity.calledOnce);
508-
assert.ok(aliceStore.putRemoteIdentity.calledWith(bobIdentity, bobIdentityKeyPair.public));
509-
assert.ok(bobStore.putRemoteIdentity.calledWith(aliceIdentity, aliceIdentityKeyPair.public));
510-
}));
511502
});
512503
});

0 commit comments

Comments
 (0)