Skip to content

Commit

Permalink
chore: remove nanoid dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
nytamin committed May 13, 2024
1 parent 22bea72 commit 8daf95e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
1 change: 0 additions & 1 deletion apps/package-manager/packages/generic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"data-store": "^4.0.3",
"deep-extend": "^0.6.0",
"fast-clone": "^1.5.13",
"nanoid": "^3.3.4",
"underscore": "^1.12.0"
},
"devDependencies": {
Expand Down
14 changes: 11 additions & 3 deletions apps/package-manager/packages/generic/src/credentials.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { CoreCredentials, PeripheralDeviceId, protectString } from '@sofie-automation/server-core-integration'
import { nanoid } from 'nanoid'

// eslint-disable-next-line @typescript-eslint/no-var-requires
const DataStore = require('data-store')
Expand All @@ -14,11 +13,20 @@ export function getCredentials(name: string): CoreCredentials {
let credentials: CoreCredentials = store.get('CoreCredentials')
if (!credentials) {
credentials = {
deviceId: protectString<PeripheralDeviceId>(nanoid()),
deviceToken: nanoid(),
deviceId: protectString<PeripheralDeviceId>(randomString()),
deviceToken: randomString(),
}
store.set('CoreCredentials', credentials)
}

return credentials
}

function randomString(length = 20): string {
const chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
let result = ''
for (let i = length; i > 0; --i) {
result += chars[Math.floor(Math.random() * chars.length)]
}
return result
}
10 changes: 0 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1655,7 +1655,6 @@ __metadata:
deep-extend: "npm:^0.6.0"
fast-clone: "npm:^1.5.13"
jest: "npm:*"
nanoid: "npm:^3.3.4"
rimraf: "npm:^5.0.5"
underscore: "npm:^1.12.0"
peerDependencies:
Expand Down Expand Up @@ -8775,15 +8774,6 @@ __metadata:
languageName: node
linkType: hard

"nanoid@npm:^3.3.4":
version: 3.3.7
resolution: "nanoid@npm:3.3.7"
bin:
nanoid: bin/nanoid.cjs
checksum: 10/ac1eb60f615b272bccb0e2b9cd933720dad30bf9708424f691b8113826bb91aca7e9d14ef5d9415a6ba15c266b37817256f58d8ce980c82b0ba3185352565679
languageName: node
linkType: hard

"nanotimer@npm:^0.3.15":
version: 0.3.15
resolution: "nanotimer@npm:0.3.15"
Expand Down

0 comments on commit 8daf95e

Please sign in to comment.