Skip to content

Commit 3459aff

Browse files
committed
chore: bot comment
1 parent 9ce11d7 commit 3459aff

4 files changed

Lines changed: 10 additions & 4 deletions

File tree

packages/sdk/electron/__tests__/ElectronIPC.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ it('derives namespace from credential alone', () => {
66
});
77

88
it('derives namespace from credential with custom namespace', () => {
9-
expect(deriveNamespace('mob-abc-123', 'my-namespace')).toBe('my-namespace:mob-abc-123');
9+
expect(deriveNamespace('mob-abc-123', 'my-namespace')).toBe('my-namespace_mob-abc-123');
1010
});
1111

1212
it('produces different namespaces with and without custom namespace', () => {

packages/sdk/electron/contract-tests/entity/src/ClientEntity.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// eslint-disable-next-line import/no-extraneous-dependencies
22
import { app } from 'electron';
3+
import { createHash } from 'node:crypto';
34
import fs from 'node:fs';
45
import path from 'node:path';
56

@@ -262,7 +263,8 @@ export async function createEntity(options: CreateInstanceParams, clientNamespac
262263
logger.info(`Creating client with configuration: ${JSON.stringify(options.configuration)}`);
263264

264265
const derivedNs = deriveNamespace(clientSideId, clientNamespace);
265-
const storagePath = path.join(app.getPath('userData'), `ldcache-${derivedNs}`);
266+
const storageNs = createHash('sha256').update(derivedNs).digest('base64url');
267+
const storagePath = path.join(app.getPath('userData'), `ldcache-${storageNs}`);
266268

267269
const timeoutMs =
268270
options.configuration.startWaitTimeMs !== null &&

packages/sdk/electron/src/deriveNamespace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
* preserving backward compatibility for single-client apps.
66
*/
77
export function deriveNamespace(credential: string, customNamespace?: string): string {
8-
return customNamespace ? `${customNamespace}:${credential}` : credential;
8+
return customNamespace ? `${customNamespace}_${credential}` : credential;
99
}

packages/sdk/electron/src/platform/ElectronPlatform.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ export default class ElectronPlatform implements platform.Platform {
2222
requests: platform.Requests;
2323

2424
constructor(logger: LDLogger, derivedNamespace: string, options: ElectronOptions) {
25-
this.storage = new ElectronStorage(derivedNamespace, logger);
25+
const storageNs = this.crypto
26+
.createHash('sha256')
27+
.update(derivedNamespace)
28+
.digest?.('base64url');
29+
this.storage = new ElectronStorage(storageNs!, logger);
2630
this.requests = new ElectronRequests(
2731
options.tlsParams,
2832
options.proxyOptions,

0 commit comments

Comments
 (0)