Skip to content

Commit

Permalink
fix: disallow usage of global buffer (#601)
Browse files Browse the repository at this point in the history
  • Loading branch information
TimoGlastra authored Jan 20, 2022
1 parent e547fb1 commit 87ecd8c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,23 @@ module.exports = {
],
},
overrides: [
{
files: ['packages/core/**'],
rules: {
'no-restricted-globals': [
'error',
{
name: 'Buffer',
message: 'Global buffer is not supported on all platforms. Import buffer from `src/utils/buffer`',
},
{
name: 'AbortController',
message:
"Global AbortController is not supported on all platforms. Use `import { AbortController } from 'abort-controller'`",
},
],
},
},
{
files: ['jest.config.ts', '.eslintrc.js'],
env: {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/utils/__tests__/HashlinkEncoder.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { HashlinkEncoder } from '../HashlinkEncoder'
import { Buffer } from '../buffer'

const validData = {
data: Buffer.from('Hello World!'),
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/utils/__tests__/MultibaseEncoder.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { BufferEncoder } from '../BufferEncoder'
import { MultiBaseEncoder } from '../MultiBaseEncoder'
import { Buffer } from '../buffer'

const validData = Buffer.from('Hello World!')
const validMultiBase = 'zKWfinQuRQ3ekD1danFHqvKRg9koFp8vpokUeREEgjSyHwweeKDFaxVHi'
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/utils/__tests__/MultihashEncoder.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { BufferEncoder } from '../BufferEncoder'
import { MultiHashEncoder } from '../MultiHashEncoder'
import { Buffer } from '../buffer'

const validData = Buffer.from('Hello World!')
const validMultiHash = new Uint8Array([18, 12, 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33])
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/utils/did.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/

import { BufferEncoder } from './BufferEncoder'
import { Buffer } from './buffer'

export const FULL_VERKEY_REGEX = /^[1-9A-HJ-NP-Za-km-z]{43,44}$/
export const ABBREVIATED_VERKEY_REGEX = /^~[1-9A-HJ-NP-Za-km-z]{21,22}$/
Expand Down

0 comments on commit 87ecd8c

Please sign in to comment.