Skip to content

Commit

Permalink
Remove test dependency crypto
Browse files Browse the repository at this point in the history
  • Loading branch information
DogLooksGood committed Dec 19, 2023
1 parent c122357 commit 15f738b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ Race Protocol: A multi-chain infrastructure for asymmetric competitive games

# Master(Unreleased)

## Enhancements
- SDK: Remove dependency `crypto` to support NodeJS runtime

## Features
- CLI: Update `publish` command. Now it receives the path to the WASM bundle instead of the Arweave URL to solana metadata.
- Add optional `createProfileIfNeeded` to join options.
Expand Down
1 change: 0 additions & 1 deletion js/sdk-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,5 @@
"ts-chacha20": "^1.2.0"
},
"testDependencies": {
"crypto": "1.0.1"
}
}
8 changes: 7 additions & 1 deletion js/sdk-core/src/encryptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import { IStorage } from './storage';

const ENCRYPTOR_VERSION = '1.0';

let subtle: SubtleCrypto = crypto.subtle;
let subtle: SubtleCrypto;
if (typeof window === 'undefined') {
const crypto = require('node:crypto')
subtle = crypto.subtle
} else {
subtle = window.crypto.subtle
}

export const aesContentIv = Uint8Array.of(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

Expand Down

0 comments on commit 15f738b

Please sign in to comment.