Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fcb8a13a authored by Akhil's avatar Akhil 🙂
Browse files

feat: add compatibility warning if no crypto support

parent a14dfc22
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ class AccountController extends Controller {
			$setupPasswordsE2ee = true;
			$csp->allowEvalWasm();
		}
		$this->initialState->provideInitialState('setupPasswordsE2ee', $setupPasswordsE2ee);
		$this->initialState->provideInitialState('shouldSetupPasswordsE2ee', $setupPasswordsE2ee);

		if ($captchaProvider === self::HCAPTCHA_PROVIDER) {
			foreach (self::HCAPTCHA_DOMAINS as $domain) {
+39 −3
Original line number Diff line number Diff line
@@ -2,7 +2,10 @@
	<div>
		<section id="main" class="register-page">
			<div id="registration">
				<RegistrationForm v-if="showRegistrationForm" v-model="formData" @form-submitted="submitRegistrationForm" />
				<RegistrationForm v-if="showRegistrationForm"
					v-model="formData"
					:disabled="!cryptoSupported"
					@form-submitted="submitRegistrationForm" />
				<CaptchaForm v-if="showCaptchaForm && captchaProvider === 'image'"
					v-model="formData"
					@form-submitted="submitCaptchaForm" />
@@ -64,6 +67,9 @@ export default {
			showCaptchaForm: false,
			showRecoveryEmailForm: false,
			showSuccessSection: false,
			shouldSetupPasswordsE2ee: loadState(APPLICATION_NAME, 'shouldSetupPasswordsE2ee'),
			cryptoSupported: true,
			cryptoSupportChecked: false,
			language: loadState(APPLICATION_NAME, 'lang'),
			processingCreation: false,
		}
@@ -75,8 +81,39 @@ export default {

		// Set formData.email directly to recoveryEmail
		this.formData.email = recoveryEmail || ''
		this.checkCryptoSupport()
	},
	methods: {
		async checkCryptoSupport() {
			if (!this.shouldSetupPasswordsE2ee) {
				this.cryptoSupportChecked = true
				return
			}

			try {
				const hasWebCrypto = typeof window.crypto !== 'undefined'
					&& typeof window.crypto.subtle === 'object'
				const hasTextEncoder = typeof window.TextEncoder !== 'undefined'
				const hasWebAssembly = typeof window.WebAssembly !== 'undefined'
					&& typeof window.WebAssembly.instantiate === 'function'

				if (!hasWebCrypto || !hasTextEncoder || !hasWebAssembly) {
					throw new Error('Required cryptography APIs are unavailable')
				}

				this.cryptoSupported = true
			} catch (error) {
				this.cryptoSupported = false
				const cryptoSupportError = t(this.appName, 'Your browser does not support the cryptography required to create an account. Please use a modern browser.')
				this.showRegistrationForm = false
				this.showCaptchaForm = false
				this.showRecoveryEmailForm = false
				this.showSuccessSection = false
				this.showMessage(cryptoSupportError, 'error')
			} finally {
				this.cryptoSupportChecked = true
			}
		},
		submitRegistrationForm(data) {
			if (data.isFormValid) {
				this.showRegistrationForm = false
@@ -109,8 +146,7 @@ export default {
				const url = generateUrl(`/apps/${this.appName}/accounts/create`)
				this.processingCreation = true
				await Axios.post(url, data)
			    const setupPasswordsE2ee = loadState(APPLICATION_NAME, 'setupPasswordsE2ee')
				if (setupPasswordsE2ee) {
				if (this.shouldSetupPasswordsE2ee) {
					await this.setupPasswordsE2ee()
				}

+3 −0
Original line number Diff line number Diff line
(function() {
	const OriginalXhr = window.XMLHttpRequest

	/**
	 *
	 */
	function PatchedXhr() {
		const xhr = new OriginalXhr()

+24 −6
Original line number Diff line number Diff line
<template>
	<div id="registrationForm">
		<div class="grid">
			<select v-model="formData.selectedLanguage" class="padding-0 lang-select" @change="onLanguageChange">
			<select v-model="formData.selectedLanguage"
				class="padding-0 lang-select"
				:disabled="disabled"
				@change="onLanguageChange">
				<option v-for="language in languages" :key="language.code" :value="language.code">
					{{ t(appName,language.name) }}
				</option>
@@ -22,6 +25,7 @@
							name="displayname"
							type="text"
							class="form-input"
							:disabled="disabled"
							:placeholder="t(appName,'Your name as shown to others')"
							@input="validateForm(['displayname'])">
						<p v-if="validation.isDisplaynameEmpty" class="validation-warning">
@@ -45,6 +49,7 @@
								class="form-input"
								:placeholder="t(appName,'Username')"
								type="text"
								:disabled="disabled"
								@input="validateForm(['username'])">
							<div id="username-domain-div" class="pad-left-5">
								@{{ domain }}
@@ -75,6 +80,7 @@
								:badge="false"
								type="password"
								name="password"
								:disabled="disabled"
								:default-class="form - input"
								:placeholder="t(appName,'Password')"
								@input="validateForm(['password'])" />
@@ -83,6 +89,7 @@
								type="password"
								name="repassword"
								class="form-input"
								:disabled="disabled"
								:placeholder="t(appName,'Confirm')"
								@input="validateForm(['repassword'])">
						</div>
@@ -112,7 +119,8 @@
							<input id="action-tns"
								v-model="formData.accepttns"
								type="checkbox"
								class="checkbox action-checkbox__checkbox focusable">
								class="checkbox action-checkbox__checkbox focusable"
								:disabled="disabled">
							<label for="action-tns" class="action-checkbox__label" v-html="t(appName,'I have read and accept the <a href=\'https://murena.io/apps/terms_of_service/en/termsandconditions\' target=\'_blank\'>Terms of Service</a>.')" />
						</span>

@@ -130,7 +138,8 @@
							<input id="action-newsletter_eos"
								v-model="formData.newsletterEos"
								type="checkbox"
								class="checkbox action-checkbox__checkbox focusable">
								class="checkbox action-checkbox__checkbox focusable"
								:disabled="disabled">
							<label for="action-newsletter_eos" class="action-checkbox__label">{{ t(appName,'I want to receive news about /e/OS.') }}</label>
						</span>
					</div>
@@ -144,7 +153,8 @@
							<input id="action-newsletter_product"
								v-model="formData.newsletterProduct"
								type="checkbox"
								class="checkbox action-checkbox__checkbox focusable">
								class="checkbox action-checkbox__checkbox focusable"
								:disabled="disabled">
							<label for="action-newsletter_product" class="action-checkbox__label">{{ t(appName,'I want to receive news about Murena products and promotions.') }}</label>
						</span>
					</div>
@@ -158,7 +168,8 @@
							<input id="action-newsletter_b2b"
								v-model="formData.newsletterB2B"
								type="checkbox"
								class="checkbox action-checkbox__checkbox focusable">
								class="checkbox action-checkbox__checkbox focusable"
								:disabled="disabled">
							<label for="action-newsletter_b2b" class="action-checkbox__label">{{ t(appName,'I want to stay informed about Murena for business offers.') }}</label>
						</span>
					</div>
@@ -169,7 +180,7 @@
				<button :wide="true"
					class="btn-primary"
					type="primary"
					:disabled="processing">
					:disabled="processing || disabled">
					<template v-if="!processing">
						{{ t(appName,'Create My Account') }}
					</template>
@@ -195,6 +206,10 @@ export default {
	},
	props: {
		value: Object,
		disabled: {
			type: Boolean,
			default: false,
		},
	},
	data() {
		return {
@@ -323,6 +338,9 @@ export default {
			}
		},
		async submitRegistrationForm() {
			if (this.disabled) {
				return
			}
			this.processing = true
			this.validateForm(['displayname', 'username', 'password', 'repassword', 'termsandservices'])
			await this.validateFields()