diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d0331041..cded89c8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,10 +15,11 @@ on: jobs: from-template: - uses: Unleash/.github/.github/workflows/npm-release.yml@v1.2.0 + uses: Unleash/.github/.github/workflows/npm-release.yml@v2.0.0 with: version: ${{ github.event.inputs.version }} tag: ${{ github.event.inputs.tag }} secrets: - GH_ACCESS_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} NPM_ACCESS_TOKEN: ${{ secrets.NPM_TOKEN }} + UNLEASH_BOT_APP_ID: ${{ secrets.UNLEASH_BOT_APP_ID }} + UNLEASH_BOT_PRIVATE_KEY: ${{ secrets.UNLEASH_BOT_PRIVATE_KEY }} diff --git a/package.json b/package.json index b1582b94..0a3fafd4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "unleash-client", - "version": "6.4.0", + "version": "6.4.1", "description": "Unleash Client for Node", "license": "Apache-2.0", "main": "./lib/index.js", diff --git a/src/details.json b/src/details.json index e00d0215..351c181f 100644 --- a/src/details.json +++ b/src/details.json @@ -1 +1 @@ -{"name":"unleash-client-node","version":"6.4.0","sdkVersion":"unleash-client-node:6.4.0"} \ No newline at end of file +{"name":"unleash-client-node","version":"6.4.1","sdkVersion":"unleash-client-node:6.4.1"} \ No newline at end of file diff --git a/src/unleash.ts b/src/unleash.ts index 588a06a8..c970a04f 100644 --- a/src/unleash.ts +++ b/src/unleash.ts @@ -22,7 +22,7 @@ import { resolveUrl } from './url-utils'; // @ts-expect-error import { EventSource } from 'launchdarkly-eventsource'; import { buildHeaders } from './request'; -import { randomUUID } from 'crypto'; +import { uuidv4 } from './uuidv4'; export { Strategy, UnleashEvents, UnleashConfig }; const BACKUP_PATH: string = tmpdir(); @@ -108,7 +108,7 @@ export class Unleash extends EventEmitter { const unleashInstanceId = generateInstanceId(instanceId); - const unleashConnectionId = randomUUID(); + const unleashConnectionId = uuidv4(); this.staticContext = { appName, environment }; diff --git a/src/uuidv4.ts b/src/uuidv4.ts new file mode 100644 index 00000000..27c9927d --- /dev/null +++ b/src/uuidv4.ts @@ -0,0 +1,14 @@ +/** + * This function generates a UUID using Math.random(). + * The distribution of unique values is not guaranteed to be as robust + * as with a crypto module but works across all platforms (Node, React Native, browser JS). + * + * We use it for connection id generation which is not critical for security. + */ +export const uuidv4 = (): string => { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { + const r = (Math.random() * 16) | 0; + const v = c === 'x' ? r : (r & 0x3) | 0x8; + return v.toString(16); + }); +};