diff --git a/js/signal_protocol_store.js b/js/signal_protocol_store.js index 59881be20a00..2d1a2b5baf52 100644 --- a/js/signal_protocol_store.js +++ b/js/signal_protocol_store.js @@ -3,6 +3,7 @@ */ ;(function() { 'use strict'; + var TIMESTAMP_THRESHOLD = 5 * 1000; // 5 seconds var StaticByteBufferProto = new dcodeIO.ByteBuffer().__proto__; var StaticArrayBufferProto = new ArrayBuffer().__proto__; @@ -343,6 +344,16 @@ }); }); }, + isBlockingApprovalRequired: function(identityKey) { + return (!identityKey.get('firstUse') + && storage.get('safety-numbers-approval', true) + && !identityKey.get('blockingApproval')); + }, + isNonBlockingApprovalRequired: function(identityKey) { + return (!identityKey.get('firstUse') + && Date.now() - identityKey.get('timestamp') < TIMESTAMP_THRESHOLD + && !identityKey.get('nonblockingApproval')); + }, removeIdentityKey: function(number) { return new Promise(function(resolve, reject) { var identityKey = new IdentityKey({id: number});