Skip to content

Commit

Permalink
Add Polyfill for crypto.randomUUID
Browse files Browse the repository at this point in the history
  • Loading branch information
caioricciuti committed Jun 13, 2024
1 parent 5a60047 commit 5b95e0b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/providers/ClickHouseContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@ import { createClient } from "@clickhouse/client-web";
import { toast } from "sonner";
import { analyticsQueries } from "@/helpers/instanceAnalyticsQueries";

// Polyfill for crypto.randomUUID if not available
if (typeof crypto.randomUUID !== "function") {
crypto.randomUUID = function () {
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) =>
(
c ^
(crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))
).toString(16)
);
};
}

const ClickHouseContext = createContext();

const ClickHouseProvider = ({ children }) => {
Expand Down

0 comments on commit 5b95e0b

Please sign in to comment.