mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
Update electron to 11.1.1 (#642)
This commit is contained in:
parent
c09ba7051f
commit
5d953fd2fc
2
jslib
2
jslib
@ -1 +1 @@
|
||||
Subproject commit 9ddec9baf8b6e7de58c00744eb371dc68e1b6383
|
||||
Subproject commit d1c46e6bdc9332bcf47acbd235c3a6278e086d8a
|
2422
package-lock.json
generated
2422
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
12
package.json
12
package.json
@ -262,10 +262,10 @@
|
||||
"cross-env": "^5.2.0",
|
||||
"css-loader": "^1.0.0",
|
||||
"del": "^3.0.0",
|
||||
"electron": "6.1.7",
|
||||
"electron-builder": "22.8.1",
|
||||
"electron-notarize": "^0.2.1",
|
||||
"electron-rebuild": "^1.9.0",
|
||||
"electron": "11.1.1",
|
||||
"electron-builder": "22.9.1",
|
||||
"electron-notarize": "^1.0.0",
|
||||
"electron-rebuild": "^2.3.4",
|
||||
"electron-reload": "^1.5.0",
|
||||
"file-loader": "^2.0.0",
|
||||
"font-awesome": "4.7.0",
|
||||
@ -310,8 +310,8 @@
|
||||
"core-js": "2.6.2",
|
||||
"desktop-idle": "1.1.2",
|
||||
"duo_web_sdk": "git+https://github.com/duosecurity/duo_web_sdk.git",
|
||||
"electron-log": "2.2.17",
|
||||
"electron-store": "1.3.0",
|
||||
"electron-log": "4.3.0",
|
||||
"electron-store": "6.0.1",
|
||||
"electron-updater": "4.3.5",
|
||||
"forcefocus": "^1.1.0",
|
||||
"keytar": "4.13.0",
|
||||
|
@ -37,12 +37,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
<p class="text-center lead no-margin">
|
||||
<span *ngIf="canMakeMacAppStorePayments">
|
||||
{{'premiumPrice' | i18n : appStoreFormattedPrice}}
|
||||
</span>
|
||||
<span *ngIf="!canMakeMacAppStorePayments">
|
||||
{{'premiumPrice' | i18n : (price | currency:'$')}}
|
||||
</span>
|
||||
{{'premiumPrice' | i18n : (price | currency:'$')}}
|
||||
</p>
|
||||
</div>
|
||||
<div *ngIf="isPremium">
|
||||
@ -57,15 +52,11 @@
|
||||
<b>{{'premiumManage' | i18n}}</b>
|
||||
</button>
|
||||
<button #purchaseBtn type="button" class="primary" appBlurClick (click)="purchase()" *ngIf="!isPremium"
|
||||
[disabled]="purchaseBtn.loading" [appApiAction]="purchasePromise">
|
||||
[disabled]="purchaseBtn.loading">
|
||||
<b>{{'premiumPurchase' | i18n}}</b>
|
||||
</button>
|
||||
<button type="button" data-dismiss="modal">{{'close' | i18n}}</button>
|
||||
<div class="right" *ngIf="!isPremium">
|
||||
<button #restoreBtn type="button" appBlurClick (click)="restore()" *ngIf="canRestorePurchase"
|
||||
[disabled]="restoreBtn.loading" [appApiAction]="restorePromise">
|
||||
{{'restore' | i18n}}
|
||||
</button>
|
||||
<button #refreshBtn type="button" appBlurClick (click)="refresh()" [disabled]="refreshBtn.loading"
|
||||
appA11yTitle="{{'premiumRefresh' | i18n}}" [appApiAction]="refreshPromise">
|
||||
<i class="fa fa-refresh fa-lg fa-fw" [hidden]="refreshBtn.loading" aria-hidden="true"></i>
|
||||
|
@ -1,6 +1,3 @@
|
||||
import { remote } from 'electron';
|
||||
import * as fs from 'fs';
|
||||
|
||||
import {
|
||||
Component,
|
||||
NgZone,
|
||||
@ -15,202 +12,15 @@ import { TokenService } from 'jslib/abstractions/token.service';
|
||||
|
||||
import { PremiumComponent as BasePremiumComponent } from 'jslib/angular/components/premium.component';
|
||||
|
||||
import { PaymentMethodType } from 'jslib/enums/paymentMethodType';
|
||||
|
||||
import { IapCheckRequest } from 'jslib/models/request/iapCheckRequest';
|
||||
|
||||
import { Utils } from 'jslib/misc/utils';
|
||||
|
||||
const AppStorePremiumPlan = 'premium_annually';
|
||||
|
||||
@Component({
|
||||
selector: 'app-premium',
|
||||
templateUrl: 'premium.component.html',
|
||||
})
|
||||
export class PremiumComponent extends BasePremiumComponent {
|
||||
purchasePromise: Promise<any>;
|
||||
restorePromise: Promise<any>;
|
||||
canMakeMacAppStorePayments = false;
|
||||
appStoreFormattedPrice = '$14.99';
|
||||
canRestorePurchase = false;
|
||||
|
||||
private makingPremiumAfterPurchase = false;
|
||||
|
||||
constructor(i18nService: I18nService, platformUtilsService: PlatformUtilsService,
|
||||
tokenService: TokenService, apiService: ApiService,
|
||||
private ngZone: NgZone, private messagingService: MessagingService,
|
||||
private syncService: SyncService) {
|
||||
super(i18nService, platformUtilsService, tokenService, apiService);
|
||||
}
|
||||
|
||||
async ngOnInit() {
|
||||
await super.ngOnInit();
|
||||
const isMacAppStore = this.platformUtilsService.isMacAppStore();
|
||||
if (isMacAppStore) {
|
||||
this.canMakeMacAppStorePayments = remote.inAppPurchase.canMakePayments();
|
||||
}
|
||||
if (this.isPremium || !isMacAppStore || !this.canMakeMacAppStorePayments) {
|
||||
return;
|
||||
}
|
||||
const pricePromise = new Promise((resolve) => {
|
||||
remote.inAppPurchase.getProducts([AppStorePremiumPlan], (products) => {
|
||||
this.ngZone.run(() => {
|
||||
if (products == null || !Array.isArray(products) || products.length === 0) {
|
||||
return;
|
||||
}
|
||||
this.appStoreFormattedPrice = products[0].formattedPrice;
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
this.setCanRestorePurchase();
|
||||
remote.inAppPurchase.on('transactions-updated', (event, transactions) => {
|
||||
this.ngZone.run(async () => {
|
||||
if (transactions == null || !Array.isArray(transactions)) {
|
||||
return;
|
||||
}
|
||||
// Check each transaction.
|
||||
transactions.forEach(async (transaction) => {
|
||||
const payment = transaction.payment;
|
||||
switch (transaction.transactionState) {
|
||||
case 'purchasing':
|
||||
// tslint:disable-next-line
|
||||
console.log(`Purchasing ${payment.productIdentifier}...`);
|
||||
break;
|
||||
case 'purchased':
|
||||
// tslint:disable-next-line
|
||||
console.log(`${payment.productIdentifier} purchased.`);
|
||||
if (this.makingPremiumAfterPurchase || payment.productIdentifier !== AppStorePremiumPlan) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.makingPremiumAfterPurchase = true;
|
||||
await this.makePremium(false);
|
||||
} catch { }
|
||||
this.makingPremiumAfterPurchase = false;
|
||||
// Finish the transaction.
|
||||
remote.inAppPurchase.finishTransactionByDate(transaction.transactionDate);
|
||||
break;
|
||||
case 'failed':
|
||||
// tslint:disable-next-line
|
||||
console.log(`Failed to purchase ${payment.productIdentifier}. ` +
|
||||
`${transaction.errorCode} = ${transaction.errorMessage}`);
|
||||
if (transaction.errorCode !== 2) {
|
||||
this.platformUtilsService.showToast('error', null, transaction.errorMessage);
|
||||
}
|
||||
// Finish the transaction.
|
||||
remote.inAppPurchase.finishTransactionByDate(transaction.transactionDate);
|
||||
break;
|
||||
case 'restored':
|
||||
// tslint:disable-next-line
|
||||
console.log(`The purchase of ${payment.productIdentifier} has been restored.`);
|
||||
break;
|
||||
case 'deferred':
|
||||
// tslint:disable-next-line
|
||||
console.log(`The purchase of ${payment.productIdentifier} has been deferred.`);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async purchase() {
|
||||
if (this.isPremium || !this.canMakeMacAppStorePayments) {
|
||||
await super.purchase();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const request = new IapCheckRequest();
|
||||
request.paymentMethodType = PaymentMethodType.AppleInApp;
|
||||
this.purchasePromise = this.apiService.postIapCheck(request);
|
||||
await this.purchasePromise;
|
||||
remote.inAppPurchase.purchaseProduct(AppStorePremiumPlan, 1, (isValid) => {
|
||||
if (!isValid) {
|
||||
// TODO?
|
||||
}
|
||||
});
|
||||
} catch { }
|
||||
}
|
||||
|
||||
async restore() {
|
||||
if (this.isPremium || !this.canMakeMacAppStorePayments) {
|
||||
return;
|
||||
}
|
||||
let makePremium = false;
|
||||
try {
|
||||
const request = new IapCheckRequest();
|
||||
request.paymentMethodType = PaymentMethodType.AppleInApp;
|
||||
this.restorePromise = this.apiService.postIapCheck(request);
|
||||
await this.restorePromise;
|
||||
makePremium = true;
|
||||
} catch { }
|
||||
if (makePremium) {
|
||||
await this.makePremium(true);
|
||||
}
|
||||
}
|
||||
|
||||
async manage() {
|
||||
if (!this.canMakeMacAppStorePayments || this.getReceiptUrl() == null) {
|
||||
await super.manage();
|
||||
return;
|
||||
}
|
||||
const confirmed = await this.platformUtilsService.showDialog(this.i18nService.t('premiumManageAlertAppStore'),
|
||||
this.i18nService.t('premiumManage'), this.i18nService.t('yes'), this.i18nService.t('cancel'));
|
||||
if (confirmed) {
|
||||
this.platformUtilsService.launchUri('itms-apps://apps.apple.com/account/subscriptions');
|
||||
}
|
||||
}
|
||||
|
||||
private async makePremium(restore: boolean) {
|
||||
const receiptUrl = this.getReceiptUrl();
|
||||
const receiptBuffer = fs.readFileSync(receiptUrl);
|
||||
const receiptB64 = Utils.fromBufferToB64(receiptBuffer);
|
||||
const fd = new FormData();
|
||||
fd.append('paymentMethodType', '6');
|
||||
fd.append('paymentToken', receiptB64);
|
||||
fd.append('additionalStorageGb', '0');
|
||||
try {
|
||||
const p = this.apiService.postPremium(fd).then((paymentResponse) => {
|
||||
if (paymentResponse.success) {
|
||||
return this.finalizePremium();
|
||||
}
|
||||
});
|
||||
if (restore) {
|
||||
this.restorePromise = p;
|
||||
await this.restorePromise;
|
||||
} else {
|
||||
this.purchasePromise = p;
|
||||
await this.purchasePromise;
|
||||
}
|
||||
} catch { }
|
||||
}
|
||||
|
||||
private async finalizePremium() {
|
||||
await this.apiService.refreshIdentityToken();
|
||||
await this.syncService.fullSync(true);
|
||||
this.platformUtilsService.showToast('success', null, this.i18nService.t('premiumUpdated'));
|
||||
this.messagingService.send('purchasedPremium');
|
||||
this.isPremium = this.tokenService.getPremium();
|
||||
this.setCanRestorePurchase();
|
||||
}
|
||||
|
||||
private setCanRestorePurchase() {
|
||||
if (!this.isPremium && this.canMakeMacAppStorePayments) {
|
||||
const receiptUrl = this.getReceiptUrl();
|
||||
this.canRestorePurchase = receiptUrl != null;
|
||||
} else {
|
||||
this.canRestorePurchase = false;
|
||||
}
|
||||
}
|
||||
|
||||
private getReceiptUrl(): string {
|
||||
const receiptUrl = remote.inAppPurchase.getReceiptURL();
|
||||
if (receiptUrl != null) {
|
||||
return fs.existsSync(receiptUrl) ? receiptUrl : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ export function initFactory(): Function {
|
||||
let theme = await storageService.get<string>(ConstantsService.themeKey);
|
||||
if (theme == null) {
|
||||
theme = platformUtilsService.getDevice() === DeviceType.MacOsDesktop &&
|
||||
remote.systemPreferences.isDarkMode() ? 'dark' : 'light';
|
||||
remote.nativeTheme.shouldUseDarkColors ? 'dark' : 'light';
|
||||
}
|
||||
htmlEl.classList.add('theme_' + theme);
|
||||
stateService.save(ConstantsService.disableFaviconKey,
|
||||
|
@ -15,8 +15,8 @@
|
||||
"@nodert-win10-rs4/windows.security.credentials.ui": "^0.4.4",
|
||||
"big-integer": "1.6.36",
|
||||
"desktop-idle": "1.1.2",
|
||||
"electron-log": "2.2.17",
|
||||
"electron-store": "1.3.0",
|
||||
"electron-log": "4.3.0",
|
||||
"electron-store": "6.0.1",
|
||||
"electron-updater": "4.3.5",
|
||||
"forcefocus": "^1.1.0",
|
||||
"keytar": "4.13.0",
|
||||
|
Loading…
Reference in New Issue
Block a user