Skip to content

Commit

Permalink
fix: change enc keys, increase cache for applications (#1143)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgithubprofile authored Nov 24, 2023
1 parent e35f31b commit 3886f1f
Show file tree
Hide file tree
Showing 31 changed files with 499 additions and 237 deletions.
106 changes: 53 additions & 53 deletions chat/matrix-element.11.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion chat/matrix-element.11.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion chat/matrix-element.11.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion chat/matrix-element.11.min.js.map

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions chat/matrix-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -123127,6 +123127,7 @@ class mtrx_MTRX {
_this4.store = _this4.client.store;
_this4.ready = true;
} catch (e) {
console.error(e);
_this4.error = e;
}
return true;
Expand Down Expand Up @@ -161199,7 +161200,7 @@ var PcryptoRoom = /*#__PURE__*/function () {
};
var lcachekey = "pcrypto8_" + chat.roomId + "_";
var ecachekey = "e_pcrypto8_";
var usershashVersion = 11;
var usershashVersion = 12;
var cache = {};
self.preparedUsers = function (time, v) {
if (!v || v <= 1) {
Expand Down Expand Up @@ -161591,6 +161592,7 @@ var PcryptoRoom = /*#__PURE__*/function () {
keyindex = sender;
}
if (!body[bodyindex]) {
console.log('body', body, bodyindex);
throw new Error("emptyforme");
}
return self.decrypt(keyindex, body[bodyindex], time, block, null, version).then(decrypted => {
Expand Down Expand Up @@ -161714,7 +161716,10 @@ var PcryptoRoom = /*#__PURE__*/function () {
bodyindex = me;
keyindex = sender;
}
if (!body[bodyindex]) throw new Error("emptyforme");
if (!body[bodyindex]) {
console.log('body', body, bodyindex, event);
throw new Error("emptyforme");
}
var decryptedKey = yield self.decrypt(keyindex, body[bodyindex], time, block, users, v);
return decryptedKey;
});
Expand Down Expand Up @@ -161748,7 +161753,8 @@ var PcryptoRoom = /*#__PURE__*/function () {
};
}();
var usershash = function () {
var users = self.preparedUsers();
var users = self.preparedUsers(undefined, self.version);
console.log("users", users);
var hash = _application_functions__WEBPACK_IMPORTED_MODULE_7__[/* default */ "a"].md5(_.filter(_.map(users, user => {
return user.id;
}), uid => {
Expand Down
2 changes: 1 addition & 1 deletion chat/matrix-element.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions chat/matrix-element.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion chat/matrix-element.min.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion components/notifications/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
#notifications .nwrapper .notification .caption {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
#notifications .nwrapper .notification .date {
font-size: 0.8em;
Expand Down
6 changes: 5 additions & 1 deletion components/notifications/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ var notifications = (function(){
e.fastMessageEvents(n, {
el : _p.el.find('.notification[notification="'+n.txid+'"]')
}, function(){
self.closeContainer()

if(!self.app.mobileview)
self.closeContainer()
})
}
})
Expand Down Expand Up @@ -242,6 +244,8 @@ var notifications = (function(){
el.error.addClass('hidden')
el.empty.removeClass('hidden')

console.log('self.app.platform.sdk.notifications', self.app.platform.sdk.notifications)

if (!self.app.platform.sdk.notifications.inited || self.app.platform.sdk.notifications.loading){
el.loader.removeClass('hidden')
}
Expand Down
1 change: 0 additions & 1 deletion components/notifications/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
.caption{
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}

.date{
Expand Down
46 changes: 23 additions & 23 deletions cordova/cordova-plugin-firebasex/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,20 @@
<framework src="src/android/build.gradle" custom="true" type="gradleReference" />

<!-- Default versions for Gradle dependencies -->
<preference name="ANDROID_PLAY_SERVICES_TAGMANAGER_VERSION" default="18.0.2" />
<preference name="ANDROID_PLAY_SERVICES_AUTH_VERSION" default="20.5.0" />
<preference name="ANDROID_FIREBASE_ANALYTICS_VERSION" default="21.2.2" />
<preference name="ANDROID_FIREBASE_MESSAGING_VERSION" default="23.1.2" />
<preference name="ANDROID_FIREBASE_CONFIG_VERSION" default="21.4.0" />
<preference name="ANDROID_FIREBASE_PERF_VERSION" default="20.3.2" />
<preference name="ANDROID_FIREBASE_AUTH_VERSION" default="22.0.0" />
<preference name="ANDROID_FIREBASE_INAPPMESSAGING_VERSION" default="20.3.2" />
<preference name="ANDROID_FIREBASE_FIRESTORE_VERSION" default="24.6.0" />
<preference name="ANDROID_FIREBASE_FUNCTIONS_VERSION" default="20.3.0" />
<preference name="ANDROID_PLAY_SERVICES_TAGMANAGER_VERSION" default="18.0.4" />
<preference name="ANDROID_PLAY_SERVICES_AUTH_VERSION" default="20.7.0" />
<preference name="ANDROID_FIREBASE_ANALYTICS_VERSION" default="21.5.0" />
<preference name="ANDROID_FIREBASE_MESSAGING_VERSION" default="23.3.1" />
<preference name="ANDROID_FIREBASE_CONFIG_VERSION" default="21.5.0" />
<preference name="ANDROID_FIREBASE_PERF_VERSION" default="20.5.0" />
<preference name="ANDROID_FIREBASE_AUTH_VERSION" default="22.2.0" />
<preference name="ANDROID_FIREBASE_INAPPMESSAGING_VERSION" default="20.4.0" />
<preference name="ANDROID_FIREBASE_FIRESTORE_VERSION" default="24.9.1" />
<preference name="ANDROID_FIREBASE_FUNCTIONS_VERSION" default="20.4.0" />
<preference name="ANDROID_FIREBASE_IID_VERSION" default="21.1.0" /> <!-- deprecated but required by firebase-messaging -->
<preference name="ANDROID_FIREBASE_INSTALLATIONS_VERSION" default="17.1.3" />
<preference name="ANDROID_FIREBASE_CRASHLYTICS_VERSION" default="18.3.7" />
<preference name="ANDROID_FIREBASE_CRASHLYTICS_NDK_VERSION" default="18.3.7" />
<preference name="ANDROID_FIREBASE_INSTALLATIONS_VERSION" default="17.2.0" />
<preference name="ANDROID_FIREBASE_CRASHLYTICS_VERSION" default="18.5.1" />
<preference name="ANDROID_FIREBASE_CRASHLYTICS_NDK_VERSION" default="18.5.1" />
<preference name="ANDROID_GSON_VERSION" default="2.9.0" />
<preference name="ANDROID_FIREBASE_PERF_GRADLE_PLUGIN_VERSION" default="1.4.2" />
<preference name="ANDROID_GRPC_OKHTTP" default="1.46.0" />
Expand Down Expand Up @@ -150,16 +150,16 @@
<source url="https://cdn.cocoapods.org/"/>
</config>
<pods use-frameworks="true">
<pod name="Firebase/Core" spec="10.10.0"/>
<pod name="Firebase/Auth" spec="10.10.0"/>
<pod name="Firebase/Messaging" spec="10.10.0"/>
<pod name="Firebase/Performance" spec="10.10.0"/>
<pod name="Firebase/RemoteConfig" spec="10.10.0"/>
<pod name="Firebase/InAppMessaging" spec="10.10.0"/>
<pod name="Firebase/Firestore" spec="10.10.0"/>
<pod name="Firebase/Crashlytics" spec="10.10.0"/>
<pod name="Firebase/Functions" spec="10.10.0"/>
<pod name="Firebase/Installations" spec="10.10.0"/>
<pod name="FirebaseCore" spec="10.17.0"/>
<pod name="FirebaseAuth" spec="10.17.0"/>
<pod name="FirebaseMessaging" spec="10.17.0"/>
<pod name="FirebasePerformance" spec="10.17.0"/>
<pod name="FirebaseRemoteConfig" spec="10.17.0"/>
<pod name="FirebaseInAppMessaging" spec="10.17.0-beta"/>
<pod name="FirebaseFirestore" spec="10.17.0"/>
<pod name="FirebaseCrashlytics" spec="10.17.0"/>
<pod name="FirebaseFunctions" spec="10.17.0"/>
<pod name="FirebaseInstallations" spec="10.17.0"/>
<pod name="GoogleSignIn" spec="6.2.4"/>
<pod name="GoogleTagManager" spec="7.4.3"/>
</pods>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = function(context) {
if(platforms.includes('ios') && pluginVariables.IOS_USE_PRECOMPILED_FIRESTORE_POD==='true'){
const pluginJSON=parsePluginXml();
const iosPlatform = pluginJSON.plugin.platform.find((platform) => platform._attributes.name === 'ios');
const firestorePod = iosPlatform.podspec.pods.pod.find((pod) => pod._attributes.name === 'Firebase/Firestore');
const firestorePod = iosPlatform.podspec.pods.pod.find((pod) => pod._attributes.name === 'FirebaseFirestore');
firestorePod._attributes.tag = firestorePod._attributes.spec;
firestorePod._attributes.git = 'https://github.com/invertase/firestore-ios-sdk-frameworks.git';
delete firestorePod._attributes.spec;
Expand Down
10 changes: 9 additions & 1 deletion cordova/cordova-plugin-firebasex/scripts/lib/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@ Utilities.setContext = function(context){
};

Utilities.parsePackageJson = function(){
return JSON.parse(fs.readFileSync(path.resolve('./package.json')));
try {
return JSON.parse(fs.readFileSync(path.resolve('./package.json')));
}
catch (error) {
if(error.code === "ENOENT") {
return {}
}
throw error;
}
};

Utilities.parseConfigXml = function(){
Expand Down
43 changes: 38 additions & 5 deletions cordova/cordova-plugin-firebasex/src/android/FirebasePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.google.firebase.auth.ActionCodeSettings;
import com.google.firebase.auth.EmailAuthCredential;
import com.google.firebase.auth.EmailAuthProvider;

import com.google.firebase.auth.FirebaseAuthMultiFactorException;
import com.google.firebase.auth.FirebaseUserMetadata;
import com.google.firebase.auth.MultiFactorAssertion;
Expand All @@ -41,7 +40,6 @@
import com.google.firebase.crashlytics.FirebaseCrashlytics;

import com.google.android.gms.auth.api.Auth;

import com.google.android.gms.common.api.ApiException;
import com.google.android.gms.common.api.CommonStatusCodes;
import com.google.android.gms.common.api.GoogleApiClient;
Expand Down Expand Up @@ -139,7 +137,9 @@ public class FirebasePlugin extends CordovaPlugin {
private FirebaseFunctions functions;
private Gson gson;
private FirebaseAuth.AuthStateListener authStateListener;
private FirebaseAuth.IdTokenListener idTokenListener;
private boolean authStateChangeListenerInitialized = false;
private String currentIdToken;
private static CordovaInterface cordovaInterface = null;
protected static Context applicationContext = null;
private static Activity cordovaActivity = null;
Expand Down Expand Up @@ -205,6 +205,9 @@ public void run() {
authStateListener = new AuthStateListener();
FirebaseAuth.getInstance().addAuthStateListener(authStateListener);

idTokenListener = new IdTokenListener();
FirebaseAuth.getInstance().addIdTokenListener(idTokenListener);

firestore = FirebaseFirestore.getInstance();
functions = FirebaseFunctions.getInstance();

Expand Down Expand Up @@ -1168,9 +1171,6 @@ public void run() {
// Sign out of Firebase
FirebaseAuth.getInstance().signOut();

// Try to sign out of Google


} catch (Exception e) {
handleExceptionWithContext(e, callbackContext);
}
Expand Down Expand Up @@ -3734,6 +3734,39 @@ public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
}
}

private static class IdTokenListener implements FirebaseAuth.IdTokenListener {
@Override
public void onIdTokenChanged(@NonNull FirebaseAuth firebaseAuth) {
try {
FirebaseUser user = firebaseAuth.getCurrentUser();
user.getIdToken(true).addOnSuccessListener(new OnSuccessListener<GetTokenResult>() {
@Override
public void onSuccess(GetTokenResult result) {
try {
String idToken = result.getToken();
if(idToken != null && idToken.equals(instance.currentIdToken)){
return;
}
instance.currentIdToken = idToken;
String providerId = result.getSignInProvider();
FirebasePlugin.instance.executeGlobalJavascript(JS_GLOBAL_NAMESPACE+"_onAuthIdTokenChange({\"idToken\":\""+idToken+"\",\"providerId\":\""+providerId+"\"})");
} catch (Exception e) {
FirebasePlugin.instance.executeGlobalJavascript(JS_GLOBAL_NAMESPACE+"_onAuthIdTokenChange()");
}
}

}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
FirebasePlugin.instance.executeGlobalJavascript(JS_GLOBAL_NAMESPACE+"_onAuthIdTokenChange()");
}
});
} catch (Exception e) {
FirebasePlugin.instance.executeGlobalJavascript(JS_GLOBAL_NAMESPACE+"_onAuthIdTokenChange()");
}
}
}

private Map<String, Object> jsonStringToMap(String jsonString) throws JSONException {
Type type = new TypeToken<Map<String, Object>>(){}.getType();
return gson.fromJson(jsonString, type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ private void sendMessage(RemoteMessage remoteMessage, Map<String, String> data,
bitmap = getCircleBitmap(bitmap);
}
else if(imageTypeBigPicture.equalsIgnoreCase(imageType)) {
notificationBuilder.setStyle(new NotificationCompat.BigPictureStyle().bigPicture(bitmap).bigLargeIcon(null));
notificationBuilder.setStyle(new NotificationCompat.BigPictureStyle().bigPicture(bitmap).bigLargeIcon((Bitmap) null));
}
notificationBuilder.setLargeIcon(bitmap);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ + (AppDelegate*) instance {
}

static NSDictionary* mutableUserInfo;

static FIRAuthStateDidChangeListenerHandle authStateChangeListener;
static bool authStateChangeListenerInitialized = false;

static FIRIDTokenDidChangeListenerHandle authIdTokenChangeListener;
static NSString* currentIdToken = @"";

static __weak id <UNUserNotificationCenterDelegate> _prevUserNotificationCenterDelegate = nil;

+ (void)load {
Expand Down Expand Up @@ -100,6 +105,35 @@ - (BOOL)application:(UIApplication *)application swizzledDidFinishLaunchingWithO
[FirebasePlugin.firebasePlugin handlePluginExceptionWithoutContext:exception];
}
}];

authIdTokenChangeListener = [[FIRAuth auth] addIDTokenDidChangeListener:^(FIRAuth * _Nonnull auth, FIRUser * _Nullable user) {
@try {
if(![FIRAuth auth].currentUser){
[FirebasePlugin.firebasePlugin executeGlobalJavascript:@"FirebasePlugin._onAuthIdTokenChange()"];
return;
}
FIRUser* user = [FIRAuth auth].currentUser;
[user getIDTokenWithCompletion:^(NSString * _Nullable token, NSError * _Nullable error) {
if(error == nil){


if([token isEqualToString:currentIdToken]) return;;
currentIdToken = token;
[user getIDTokenResultWithCompletion:^(FIRAuthTokenResult * _Nullable tokenResult, NSError * _Nullable error) {
if(error == nil){
[FirebasePlugin.firebasePlugin executeGlobalJavascript:[NSString stringWithFormat:@"FirebasePlugin._onAuthIdTokenChange({\"idToken\": \"%@\", \"providerId\": \"%@\"})", token, tokenResult.signInProvider]];
}else{
[FirebasePlugin.firebasePlugin executeGlobalJavascript:[NSString stringWithFormat:@"FirebasePlugin._onAuthIdTokenChange({\"idToken\": \"%@\"})", token]];
}
}];
}else{
[FirebasePlugin.firebasePlugin executeGlobalJavascript:@"FirebasePlugin._onAuthIdTokenChange()"];
}
}];
}@catch (NSException *exception) {
[FirebasePlugin.firebasePlugin executeGlobalJavascript:@"FirebasePlugin._onAuthIdTokenChange()"];
}
}];

self.applicationInBackground = @(YES);

Expand Down
3 changes: 3 additions & 0 deletions cordova/cordova-plugin-firebasex/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ export interface FirebasePlugin {
registerAuthStateChangeListener(
fn: (userSignedIn: boolean) => void,
): void
registerAuthIdTokenChangeListener(
fn: (result: undefined|{idToken: string, providerId: string}) => void,
): void
useAuthEmulator(
host: string,
port: number,
Expand Down
10 changes: 10 additions & 0 deletions cordova/cordova-plugin-firebasex/www/firebase.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var handleAuthErrorResult = function(errorCallback){
};

var onAuthStateChangeCallback = function(){};
var onAuthIdTokenChangeCallback = function(){};
var onInstallationIdChangeCallback = function(){};
var onApplicationDidBecomeActiveCallback = function(){};
var onApplicationDidEnterBackgroundCallback = function(){};
Expand All @@ -40,6 +41,10 @@ exports._onAuthStateChange = function(userSignedIn){
onAuthStateChangeCallback(userSignedIn);
};

exports._onAuthIdTokenChange = function(token){
onAuthIdTokenChangeCallback(token);
};

exports._onInstallationIdChangeCallback = function(installationId){
onInstallationIdChangeCallback(installationId);
};
Expand Down Expand Up @@ -434,6 +439,11 @@ exports.registerAuthStateChangeListener = function(fn){
onAuthStateChangeCallback = fn;
};

exports.registerAuthIdTokenChangeListener = function(fn){
if(typeof fn !== "function") throw "The specified argument must be a function";
onAuthIdTokenChangeCallback = fn;
};

exports.useAuthEmulator = function (host, port, success, error) {
exec(success, error, "FirebasePlugin", "useAuthEmulator", [host, port]);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var WEB_HOOK_FILE_PATH = path.join(
);
var WEB_HOOK_TPL_FILE_PATH = path.join(
"plugins",
"cordova-wtto00-universal-link",
"cordova-universal-links-plugin",
"ul_web_hooks",
"android_web_hook_tpl.html"
);
Expand Down
Loading

0 comments on commit 3886f1f

Please sign in to comment.