From 38dc28c073b0f0f1271069e75ddb65381b1152de Mon Sep 17 00:00:00 2001 From: vnugent Date: Sun, 31 Dec 2023 23:25:33 -0500 Subject: change tiny-uuid to nanoid --- extension/package-lock.json | 34 +++++++++++++++++++++++----------- extension/package.json | 2 +- extension/src/messaging/index.ts | 6 +++--- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/extension/package-lock.json b/extension/package-lock.json index a27a610..2fca58a 100644 --- a/extension/package-lock.json +++ b/extension/package-lock.json @@ -25,10 +25,10 @@ "base32-encode": "^2.0.0", "jose": "^5.0.x", "lodash-es": "^4.17.21", + "nanoid": "^5.0.4", "pinia": "^2.1.7", "sass": "^1.56.1", "serialize-error": "^11.0.0", - "tiny-uid": "^1.1.1", "universal-cookie": "^6.1.x", "vite-plugin-web-extension": "^3.0.2", "vue": "^3.2.47", @@ -6047,9 +6047,9 @@ "optional": true }, "node_modules/nanoid": { - "version": "3.3.7", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", - "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-5.0.4.tgz", + "integrity": "sha512-vAjmBf13gsmhXSgBrtIclinISzFFy22WwCYoyilZlsrRXNIHSwgFQ1bEdjRwMT3aoadeIF6HMuDRlOxzfXV8ig==", "funding": [ { "type": "github", @@ -6057,10 +6057,10 @@ } ], "bin": { - "nanoid": "bin/nanoid.cjs" + "nanoid": "bin/nanoid.js" }, "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + "node": "^18 || >=20" } }, "node_modules/natural-compare": { @@ -6786,6 +6786,23 @@ "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", "dev": true }, + "node_modules/postcss/node_modules/nanoid": { + "version": "3.3.7", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", + "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -7958,11 +7975,6 @@ "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", "integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==" }, - "node_modules/tiny-uid": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/tiny-uid/-/tiny-uid-1.1.2.tgz", - "integrity": "sha512-0beRFXR+fv4C40ND2PqgNjq6iyB1dKXciKJjslLw0kPYCcR82aNd2b+Tt2yy06LimIlvtoehgvrm/fUZCutSfg==" - }, "node_modules/tmp": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz", diff --git a/extension/package.json b/extension/package.json index 84b4e8a..7cd368e 100644 --- a/extension/package.json +++ b/extension/package.json @@ -55,7 +55,7 @@ "pinia": "^2.1.7", "sass": "^1.56.1", "serialize-error": "^11.0.0", - "tiny-uid": "^1.1.1", + "nanoid": "^5.0.4", "universal-cookie": "^6.1.x", "vite-plugin-web-extension": "^3.0.2", "vue": "^3.2.47", diff --git a/extension/src/messaging/index.ts b/extension/src/messaging/index.ts index dfc5aee..ae84c36 100644 --- a/extension/src/messaging/index.ts +++ b/extension/src/messaging/index.ts @@ -1,4 +1,4 @@ -import uuid from 'tiny-uid' +import { nanoid } from 'nanoid' import { isEqual } from 'lodash' import { Runtime, runtime } from 'webextension-polyfill' import { serializeError, isErrorLike, type ErrorObject, deserializeError } from 'serialize-error' @@ -49,7 +49,7 @@ interface RxChannelState{ onDisconnected(): void } -export const createMessageChannel = (localContext: ChannelContext): MessageChannel => { +export const createMessageChannel = (localContext: ChannelContext, randomIdSize = 32): MessageChannel => { const createRxChannel = (): RxChannelState => { @@ -150,7 +150,7 @@ export const createMessageChannel = (localContext: ChannelContext): MessageChann sendMessage: (port: Runtime.Port) => { return (name: string, message: JsonObject): Promise => { //unique transaction id for message, used to match in response map - const transactionId = uuid(32) + const transactionId = nanoid(randomIdSize) //Create itnernal request wrapper const request: InternalChannelMessage = { -- cgit