Merge branch 'master' into orangesurf/2024-07-19

This commit is contained in:
orangesurf
2024-07-23 20:48:03 +09:00
committed by GitHub
4 changed files with 86 additions and 77 deletions

View File

@@ -1,7 +1,7 @@
import { Component, OnInit, OnDestroy, Output, EventEmitter, Input, ChangeDetectorRef, SimpleChanges, HostListener } from '@angular/core';
import { Subscription, tap, of, catchError, Observable, switchMap } from 'rxjs';
import { ServicesApiServices } from '../../services/services-api.service';
import { nextRoundNumber } from '../../shared/common.utils';
import { nextRoundNumber, insecureRandomUUID } from '../../shared/common.utils';
import { StateService } from '../../services/state.service';
import { AudioService } from '../../services/audio.service';
import { ETA, EtaService } from '../../services/eta.service';
@@ -130,7 +130,7 @@ export class AccelerateCheckout implements OnInit, OnDestroy {
private authService: AuthServiceMempool,
private enterpriseService: EnterpriseService,
) {
this.accelerationUUID = window.crypto.randomUUID();
this.accelerationUUID = insecureRandomUUID();
}
ngOnInit() {

View File

@@ -3,7 +3,7 @@ import { FormBuilder, FormGroup } from '@angular/forms';
import { DomSanitizer, SafeUrl } from '@angular/platform-browser';
import { ActivatedRoute } from '@angular/router';
import { Subscription, of, timer } from 'rxjs';
import { retry, switchMap, tap } from 'rxjs/operators';
import { filter, repeat, retry, switchMap, take, tap } from 'rxjs/operators';
import { ServicesApiServices } from '../../services/services-api.service';
@Component({
@@ -73,11 +73,11 @@ export class BitcoinInvoiceComponent implements OnInit, OnChanges, OnDestroy {
this.paymentStatus = 4;
}
this.paymentStatusSubscription = this.apiService.getPaymentStatus$(this.invoice.btcpayInvoiceId).pipe(
retry({ delay: () => timer(2000)})
).subscribe((response) => {
if (response.status === 204 || response.status === 404) {
return;
}
retry({ delay: () => timer(2000)}),
repeat({delay: 2000}),
filter((response) => response.status !== 204 && response.status !== 404),
take(1),
).subscribe(() => {
this.paymentStatus = 3;
this.completed.emit();
});

View File

@@ -181,4 +181,17 @@ export function uncompressDeltaChange(delta: MempoolBlockDeltaCompressed): Mempo
acc: !!tx[3],
}))
};
}
}
export function insecureRandomUUID(): string {
const hexDigits = '0123456789abcdef';
const uuidLengths = [8, 4, 4, 4, 12];
let uuid = '';
for (const length of uuidLengths) {
for (let i = 0; i < length; i++) {
uuid += hexDigits[Math.floor(Math.random() * 16)];
}
uuid += '-';
}
return uuid.slice(0, -1);
}