Skip to content

Commit

Permalink
fix: polyfill crypto
Browse files Browse the repository at this point in the history
  • Loading branch information
Looskie committed Oct 3, 2023
1 parent 3074182 commit 85000d4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"dependencies": {
"@onehop/json-methods": "^1.2.0",
"cross-fetch": "^3.1.5",
"uncrypto": "^0.1.3",
"zod": "^3.21.4"
}
}
4 changes: 4 additions & 0 deletions src/util/crypto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import * as cryptoPonyfill from 'uncrypto';

export const HAS_NATIVE_CRYPTO = typeof globalThis.crypto !== 'undefined';
export const crypto = HAS_NATIVE_CRYPTO ? globalThis.crypto : cryptoPonyfill;
2 changes: 2 additions & 0 deletions src/util/webhooks.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {crypto} from './crypto';

export const POSSIBLE_EVENTS = {
Channels: [
{
Expand Down
8 changes: 8 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ __metadata:
typedoc-plugin-markdown: 3.14.0
typedoc-plugin-missing-exports: 1.0.0
typescript: ^5.0.2
uncrypto: ^0.1.3
zod: ^3.21.4
languageName: unknown
linkType: soft
Expand Down Expand Up @@ -3955,6 +3956,13 @@ __metadata:
languageName: node
linkType: hard

"uncrypto@npm:^0.1.3":
version: 0.1.3
resolution: "uncrypto@npm:0.1.3"
checksum: 07160e08806dd6cea16bb96c3fd54cd70fc801e02fc3c6f86980144d15c9ebbd1c55587f7280a207b3af6cd34901c0d0b77ada5a02c2f7081a033a05acf409e2
languageName: node
linkType: hard

"unique-filename@npm:^2.0.0":
version: 2.0.1
resolution: "unique-filename@npm:2.0.1"
Expand Down

0 comments on commit 85000d4

Please sign in to comment.