2021-02-24 22:53:57 +00:00
|
|
|
// Copyright (C) 2021 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
<template>
|
2021-08-30 15:15:43 +01:00
|
|
|
<div class="encrypt-container">
|
|
|
|
<EncryptIcon />
|
|
|
|
<h1 class="encrypt-container__title">Encrypt your data</h1>
|
|
|
|
<p class="encrypt-container__info">
|
|
|
|
The encryption passphrase is used to encrypt and access the data that you upload to Storj DCS. We strongly
|
|
|
|
encourage you to use a mnemonic phrase, which is automatically generated one on the client-side for you.
|
|
|
|
<span v-if="isOnboardingTour">
|
|
|
|
Alternatively, you can skip this step and enter a passphrase later into the Uplink CLI during setup.
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
<div class="encrypt-container__header">
|
|
|
|
<p class="encrypt-container__header__rec">RECOMMENDED</p>
|
|
|
|
<div class="encrypt-container__header__row">
|
|
|
|
<p class="encrypt-container__header__row__gen" :class="{ active: isGenerate }" @click="setToGenerate">Generate Phrase</p>
|
|
|
|
<div class="encrypt-container__header__row__right">
|
|
|
|
<p class="encrypt-container__header__row__right__enter" :class="{ active: !isGenerate }" @click="setToEnter">Enter Your Own Passphrase</p>
|
2021-09-03 14:13:59 +01:00
|
|
|
<VInfo class="encrypt-container__header__row__right__info-button">
|
|
|
|
<template #icon>
|
|
|
|
<InfoIcon class="encrypt-container__header__row__right__info-button__image" />
|
|
|
|
</template>
|
|
|
|
<template #message>
|
|
|
|
<p class="encrypt-container__header__row__right__info-button__message">
|
|
|
|
We strongly encourage you to use a mnemonic phrase, which is automatically generated one
|
|
|
|
on the client-side for you. Alternatively, you can enter your own passphrase.
|
|
|
|
</p>
|
|
|
|
</template>
|
2021-08-30 15:15:43 +01:00
|
|
|
</VInfo>
|
|
|
|
</div>
|
2021-02-24 22:53:57 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-08-30 15:15:43 +01:00
|
|
|
<div v-if="isGenerate" class="encrypt-container__generate">
|
|
|
|
<p class="encrypt-container__generate__value">{{ passphrase }}</p>
|
|
|
|
<VButton
|
|
|
|
class="encrypt-container__generate__button"
|
|
|
|
label="Copy"
|
|
|
|
width="66px"
|
|
|
|
height="30px"
|
|
|
|
is-blue-white="true"
|
|
|
|
:on-press="onCopyClick"
|
|
|
|
/>
|
2021-04-14 16:38:58 +01:00
|
|
|
</div>
|
2021-08-30 15:15:43 +01:00
|
|
|
<div v-else class="encrypt-container__enter">
|
|
|
|
<HeaderlessInput
|
|
|
|
placeholder="Enter a passphrase here..."
|
|
|
|
:error="enterError"
|
|
|
|
@setData="setPassphrase"
|
|
|
|
/>
|
2021-02-24 22:53:57 +00:00
|
|
|
</div>
|
2021-08-30 15:15:43 +01:00
|
|
|
<div class="encrypt-container__save">
|
|
|
|
<h2 class="encrypt-container__save__title">Save your encryption passphrase</h2>
|
|
|
|
<p class="encrypt-container__save__msg">
|
|
|
|
Please note that Storj does not know or store your encryption passphrase. If you lose it, you will
|
|
|
|
not be able to recover your files.
|
2021-04-14 16:38:58 +01:00
|
|
|
</p>
|
2021-08-30 15:15:43 +01:00
|
|
|
<p class="encrypt-container__save__download" @click="onDownloadClick">Download as a text file</p>
|
|
|
|
</div>
|
|
|
|
<div class="encrypt-container__buttons">
|
|
|
|
<VButton
|
|
|
|
v-if="isOnboardingTour"
|
|
|
|
class="encrypt-container__buttons__back"
|
|
|
|
label="< Back"
|
|
|
|
height="64px"
|
|
|
|
border-radius="62px"
|
|
|
|
:on-press="onBackClick"
|
|
|
|
is-grey-blue="true"
|
|
|
|
:is-disabled="isLoading"
|
|
|
|
/>
|
|
|
|
<VButton
|
|
|
|
v-if="isOnboardingTour"
|
|
|
|
class="encrypt-container__buttons__skip"
|
|
|
|
label="Skip for now"
|
|
|
|
height="64px"
|
|
|
|
border-radius="62px"
|
|
|
|
:on-press="onSkipClick"
|
|
|
|
is-grey-blue="true"
|
|
|
|
:is-disabled="isLoading"
|
|
|
|
/>
|
|
|
|
<VButton
|
|
|
|
label="Next >"
|
|
|
|
height="64px"
|
|
|
|
border-radius="62px"
|
|
|
|
:on-press="onNextButtonClick"
|
|
|
|
:is-disabled="isLoading"
|
|
|
|
/>
|
2021-04-14 16:38:58 +01:00
|
|
|
</div>
|
2021-02-24 22:53:57 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { Component, Prop, Vue } from 'vue-property-decorator';
|
2021-08-30 15:15:43 +01:00
|
|
|
import * as bip39 from "bip39";
|
2021-02-24 22:53:57 +00:00
|
|
|
|
2021-08-30 15:15:43 +01:00
|
|
|
import { RouteConfig } from "@/router";
|
|
|
|
import { LocalData, UserIDPassSalt } from "@/utils/localData";
|
|
|
|
import { Download } from "@/utils/download";
|
2021-02-24 22:53:57 +00:00
|
|
|
|
2021-08-30 15:15:43 +01:00
|
|
|
import VButton from '@/components/common/VButton.vue';
|
|
|
|
import VInfo from "@/components/common/VInfo.vue";
|
|
|
|
import HeaderlessInput from "@/components/common/HeaderlessInput.vue";
|
2021-02-24 22:53:57 +00:00
|
|
|
|
2021-08-30 15:15:43 +01:00
|
|
|
import EncryptIcon from "@/../static/images/objects/encrypt.svg";
|
|
|
|
import InfoIcon from "@/../static/images/common/greyInfo.svg";
|
2021-04-12 17:58:36 +01:00
|
|
|
|
2021-08-31 14:49:45 +01:00
|
|
|
// @vue/component
|
2021-02-24 22:53:57 +00:00
|
|
|
@Component({
|
|
|
|
components: {
|
2021-08-30 15:15:43 +01:00
|
|
|
EncryptIcon,
|
|
|
|
InfoIcon,
|
|
|
|
VInfo,
|
2021-02-24 22:53:57 +00:00
|
|
|
VButton,
|
2021-08-30 15:15:43 +01:00
|
|
|
HeaderlessInput,
|
2021-02-24 22:53:57 +00:00
|
|
|
},
|
|
|
|
})
|
|
|
|
export default class GeneratePassphrase extends Vue {
|
|
|
|
@Prop({ default: () => null })
|
2021-08-30 15:15:43 +01:00
|
|
|
public readonly onNextClick: () => unknown;
|
|
|
|
@Prop({ default: () => null })
|
|
|
|
public readonly onBackClick: () => unknown;
|
|
|
|
@Prop({ default: () => null })
|
|
|
|
public readonly onSkipClick: () => unknown;
|
2021-02-24 22:53:57 +00:00
|
|
|
@Prop({ default: () => null })
|
|
|
|
public readonly setParentPassphrase: (passphrase: string) => void;
|
|
|
|
@Prop({ default: false })
|
|
|
|
public readonly isLoading: boolean;
|
2021-04-14 16:38:58 +01:00
|
|
|
|
2021-08-30 15:15:43 +01:00
|
|
|
public isGenerate = true;
|
|
|
|
public enterError = '';
|
2021-08-02 19:17:49 +01:00
|
|
|
public passphrase = '';
|
2021-02-24 22:53:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Lifecycle hook after initial render.
|
2021-08-30 15:15:43 +01:00
|
|
|
* Chooses correct state and generates mnemonic.
|
2021-02-24 22:53:57 +00:00
|
|
|
*/
|
|
|
|
public mounted(): void {
|
2021-08-30 15:15:43 +01:00
|
|
|
const idPassSalt: UserIDPassSalt | null = LocalData.getUserIDPassSalt();
|
|
|
|
if (idPassSalt && idPassSalt.userId === this.$store.getters.user.id) {
|
|
|
|
this.isGenerate = false;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-02-24 22:53:57 +00:00
|
|
|
this.passphrase = bip39.generateMnemonic();
|
|
|
|
this.setParentPassphrase(this.passphrase);
|
|
|
|
}
|
|
|
|
|
2021-08-30 15:15:43 +01:00
|
|
|
/**
|
|
|
|
* Holds on copy button click logic.
|
|
|
|
* Copies passphrase to clipboard.
|
|
|
|
*/
|
|
|
|
public onCopyClick(): void {
|
|
|
|
this.$copyText(this.passphrase);
|
|
|
|
this.$notify.success('Passphrase was copied successfully');
|
|
|
|
}
|
2021-02-24 22:53:57 +00:00
|
|
|
|
2021-08-30 15:15:43 +01:00
|
|
|
/**
|
|
|
|
* Holds on download button click logic.
|
|
|
|
* Downloads encryption passphrase as a txt file.
|
|
|
|
*/
|
|
|
|
public onDownloadClick(): void {
|
|
|
|
if (!this.passphrase) {
|
|
|
|
this.enterError = 'Can\'t be empty!';
|
2021-02-24 22:53:57 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-08-30 15:15:43 +01:00
|
|
|
const fileName = 'StorjEncryptionPassphrase.txt';
|
2021-04-12 17:58:36 +01:00
|
|
|
|
2021-08-30 15:15:43 +01:00
|
|
|
Download.file(this.passphrase, fileName);
|
2021-02-24 22:53:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-08-30 15:15:43 +01:00
|
|
|
* Sets passphrase from child component.
|
2021-02-24 22:53:57 +00:00
|
|
|
*/
|
2021-08-30 15:15:43 +01:00
|
|
|
public setPassphrase(passphrase: string): void {
|
|
|
|
if (this.enterError) this.enterError = '';
|
2021-02-24 22:53:57 +00:00
|
|
|
|
2021-08-30 15:15:43 +01:00
|
|
|
this.passphrase = passphrase;
|
2021-02-24 22:53:57 +00:00
|
|
|
this.setParentPassphrase(this.passphrase);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-08-30 15:15:43 +01:00
|
|
|
* Sets view state to enter passphrase.
|
2021-02-24 22:53:57 +00:00
|
|
|
*/
|
2021-08-30 15:15:43 +01:00
|
|
|
public setToEnter(): void {
|
2021-02-24 22:53:57 +00:00
|
|
|
this.passphrase = '';
|
2021-08-30 15:15:43 +01:00
|
|
|
this.isGenerate = false;
|
2021-02-24 22:53:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-08-30 15:15:43 +01:00
|
|
|
* Sets view state to generate passphrase.
|
2021-02-24 22:53:57 +00:00
|
|
|
*/
|
2021-08-30 15:15:43 +01:00
|
|
|
public setToGenerate(): void {
|
|
|
|
if (this.enterError) this.enterError = '';
|
|
|
|
|
|
|
|
this.passphrase = bip39.generateMnemonic();
|
|
|
|
this.isGenerate = true;
|
2021-02-24 22:53:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-08-30 15:15:43 +01:00
|
|
|
* Holds on next button click logic.
|
2021-02-24 22:53:57 +00:00
|
|
|
*/
|
2021-08-30 15:15:43 +01:00
|
|
|
public async onNextButtonClick(): Promise<void> {
|
|
|
|
if (!this.passphrase) {
|
|
|
|
this.enterError = 'Can\'t be empty!';
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
await this.onNextClick();
|
2021-02-24 22:53:57 +00:00
|
|
|
}
|
2021-04-14 16:38:58 +01:00
|
|
|
|
|
|
|
/**
|
2021-08-30 15:15:43 +01:00
|
|
|
* Indicates if current route is onboarding tour.
|
2021-04-14 16:38:58 +01:00
|
|
|
*/
|
2021-08-30 15:15:43 +01:00
|
|
|
public get isOnboardingTour(): boolean {
|
|
|
|
return this.$route.path.includes(RouteConfig.OnboardingTour.path);
|
2021-04-14 16:38:58 +01:00
|
|
|
}
|
2021-02-24 22:53:57 +00:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2021-08-30 15:15:43 +01:00
|
|
|
.encrypt-container {
|
2021-02-24 22:53:57 +00:00
|
|
|
font-family: 'font_regular', sans-serif;
|
2021-08-30 15:15:43 +01:00
|
|
|
padding: 60px;
|
|
|
|
max-width: 500px;
|
|
|
|
background: #fcfcfc;
|
|
|
|
box-shadow: 0 0 32px rgba(0, 0, 0, 0.04);
|
|
|
|
border-radius: 20px;
|
|
|
|
margin: 30px auto 0 auto;
|
2021-02-24 22:53:57 +00:00
|
|
|
|
|
|
|
&__title {
|
|
|
|
font-family: 'font_bold', sans-serif;
|
2021-08-30 15:15:43 +01:00
|
|
|
font-size: 36px;
|
|
|
|
line-height: 56px;
|
|
|
|
letter-spacing: 1px;
|
|
|
|
color: #14142b;
|
|
|
|
margin: 35px 0 10px 0;
|
2021-02-24 22:53:57 +00:00
|
|
|
}
|
|
|
|
|
2021-08-30 15:15:43 +01:00
|
|
|
&__info {
|
|
|
|
font-size: 16px;
|
|
|
|
line-height: 32px;
|
|
|
|
letter-spacing: 0.75px;
|
|
|
|
color: #1b2533;
|
|
|
|
margin-bottom: 20px;
|
|
|
|
}
|
|
|
|
|
|
|
|
&__header {
|
|
|
|
|
|
|
|
&__rec {
|
|
|
|
font-size: 12px;
|
|
|
|
line-height: 15px;
|
|
|
|
color: #1b2533;
|
|
|
|
opacity: 0.4;
|
|
|
|
margin-bottom: 15px;
|
|
|
|
}
|
2021-02-24 22:53:57 +00:00
|
|
|
|
2021-08-30 15:15:43 +01:00
|
|
|
&__row {
|
2021-02-24 22:53:57 +00:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
2021-08-30 15:15:43 +01:00
|
|
|
justify-content: space-between;
|
2021-02-24 22:53:57 +00:00
|
|
|
|
2021-08-30 15:15:43 +01:00
|
|
|
&__gen {
|
2021-02-24 22:53:57 +00:00
|
|
|
font-family: 'font_bold', sans-serif;
|
|
|
|
font-size: 16px;
|
|
|
|
line-height: 19px;
|
2021-08-30 15:15:43 +01:00
|
|
|
color: #a9b5c1;
|
|
|
|
padding-bottom: 10px;
|
|
|
|
border-bottom: 5px solid #fff;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
&__right {
|
|
|
|
display: flex;
|
|
|
|
align-items: flex-start;
|
|
|
|
|
|
|
|
&__enter {
|
|
|
|
font-family: 'font_bold', sans-serif;
|
|
|
|
font-size: 16px;
|
|
|
|
line-height: 19px;
|
|
|
|
color: #a9b5c1;
|
|
|
|
cursor: pointer;
|
|
|
|
margin-right: 10px;
|
|
|
|
padding-bottom: 10px;
|
|
|
|
border-bottom: 5px solid #fff;
|
|
|
|
}
|
|
|
|
|
|
|
|
&__info-button {
|
|
|
|
|
|
|
|
&__image {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
2021-09-03 14:13:59 +01:00
|
|
|
|
|
|
|
&__message {
|
|
|
|
color: #586c86;
|
|
|
|
font-size: 16px;
|
|
|
|
line-height: 21px;
|
|
|
|
}
|
2021-08-30 15:15:43 +01:00
|
|
|
}
|
2021-02-24 22:53:57 +00:00
|
|
|
}
|
|
|
|
}
|
2021-08-30 15:15:43 +01:00
|
|
|
}
|
2021-02-24 22:53:57 +00:00
|
|
|
|
2021-08-30 15:15:43 +01:00
|
|
|
&__generate {
|
|
|
|
margin-top: 25px;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
padding: 25px;
|
|
|
|
background: #eff0f7;
|
|
|
|
border-radius: 10px;
|
|
|
|
|
|
|
|
&__value {
|
2021-04-14 16:38:58 +01:00
|
|
|
font-size: 16px;
|
2021-08-30 15:15:43 +01:00
|
|
|
line-height: 28px;
|
|
|
|
color: #384b65;
|
|
|
|
}
|
|
|
|
|
|
|
|
&__button {
|
|
|
|
margin-left: 32px;
|
|
|
|
min-width: 66px;
|
2021-04-14 16:38:58 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-30 15:15:43 +01:00
|
|
|
&__enter {
|
|
|
|
margin-top: 25px;
|
|
|
|
}
|
|
|
|
|
|
|
|
&__save {
|
2021-04-14 16:38:58 +01:00
|
|
|
border: 1px solid #e6e9ef;
|
2021-08-30 15:15:43 +01:00
|
|
|
border-radius: 10px;
|
|
|
|
padding: 25px;
|
|
|
|
margin-top: 35px;
|
2021-04-14 16:38:58 +01:00
|
|
|
|
|
|
|
&__title {
|
|
|
|
font-family: 'font_bold', sans-serif;
|
|
|
|
font-size: 16px;
|
|
|
|
line-height: 19px;
|
|
|
|
color: #1b2533;
|
2021-08-30 15:15:43 +01:00
|
|
|
margin-bottom: 10px;
|
2021-04-14 16:38:58 +01:00
|
|
|
}
|
|
|
|
|
2021-08-30 15:15:43 +01:00
|
|
|
&__msg {
|
2021-04-14 16:38:58 +01:00
|
|
|
font-size: 14px;
|
2021-08-30 15:15:43 +01:00
|
|
|
line-height: 20px;
|
2021-04-14 16:38:58 +01:00
|
|
|
color: #1b2533;
|
2021-08-30 15:15:43 +01:00
|
|
|
margin-bottom: 10px;
|
2021-02-24 22:53:57 +00:00
|
|
|
}
|
|
|
|
|
2021-08-30 15:15:43 +01:00
|
|
|
&__download {
|
2021-02-24 22:53:57 +00:00
|
|
|
font-family: 'font_bold', sans-serif;
|
|
|
|
font-size: 16px;
|
2021-08-30 15:15:43 +01:00
|
|
|
line-height: 19px;
|
|
|
|
color: #0068dc;
|
|
|
|
cursor: pointer;
|
2021-02-24 22:53:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-30 15:15:43 +01:00
|
|
|
&__buttons {
|
2021-02-24 22:53:57 +00:00
|
|
|
width: 100%;
|
|
|
|
display: flex;
|
2021-08-30 15:15:43 +01:00
|
|
|
align-items: center;
|
|
|
|
margin-top: 30px;
|
2021-02-24 22:53:57 +00:00
|
|
|
|
2021-08-30 15:15:43 +01:00
|
|
|
&__back,
|
|
|
|
&__skip {
|
|
|
|
margin-right: 24px;
|
2021-02-24 22:53:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.active {
|
2021-08-30 15:15:43 +01:00
|
|
|
color: #0149ff;
|
|
|
|
border-color: #0149ff;
|
2021-02-24 22:53:57 +00:00
|
|
|
}
|
|
|
|
|
2021-08-30 15:15:43 +01:00
|
|
|
::v-deep .info__box__message {
|
|
|
|
min-width: 440px;
|
2021-02-24 22:53:57 +00:00
|
|
|
}
|
|
|
|
</style>
|