From 73413db0e9ea7a4548f6239f1f4ba3a1ecb020ed Mon Sep 17 00:00:00 2001 From: Nuriddin Yuldashev Date: Tue, 23 Apr 2024 13:23:46 +0500 Subject: [PATCH] fix: crypto does not work in http domain (specs) --- libs/dialog/src/lib/dialog.component.ts | 4 ++-- libs/dialog/src/lib/dialog.utils.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libs/dialog/src/lib/dialog.component.ts b/libs/dialog/src/lib/dialog.component.ts index c733e08..8a8bcc9 100644 --- a/libs/dialog/src/lib/dialog.component.ts +++ b/libs/dialog/src/lib/dialog.component.ts @@ -14,7 +14,7 @@ import { filter, map, takeUntil } from 'rxjs/operators'; import { InternalDialogRef } from './dialog-ref'; import { DialogService } from './dialog.service'; -import { coerceCssPixelValue } from './dialog.utils'; +import { coerceCssPixelValue, generateUUID } from './dialog.utils'; import { DialogDraggableDirective, DragOffset } from './draggable.directive'; import { NODES_TO_INSERT } from './providers'; @@ -105,7 +105,7 @@ export class DialogComponent implements OnInit, OnDestroy { } if (!this.config.id) { - const id = `dialog-${crypto.randomUUID()}`; + const id = `dialog-${generateUUID()}`; this.config.id = id; this.dialogRef.updateConfig({ id }); if (isDevMode()) { diff --git a/libs/dialog/src/lib/dialog.utils.ts b/libs/dialog/src/lib/dialog.utils.ts index 139effc..efb4056 100644 --- a/libs/dialog/src/lib/dialog.utils.ts +++ b/libs/dialog/src/lib/dialog.utils.ts @@ -13,3 +13,11 @@ export function coerceCssPixelValue(value: any): string { return isString(value) ? value : `${value}px`; } + +export function generateUUID() { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { + const r = (Math.random() * 16) | 0, + v = c == 'x' ? r : (r & 0x3) | 0x8; + return v.toString(16); + }); +}