app

Local-first trade for farms and co-ops
git clone https://radroots.dev/git/app.git
Log | Files | Refs | README | LICENSE

private-store.test.ts (1443B)


      1 import { expect, it } from 'vitest';
      2 import { createIdentitySession } from '../../src/lib/runtime/identity-session.ts';
      3 import { createPrivateSession } from '../../src/lib/runtime/private-session.ts';
      4 import {
      5   getPrivateStore,
      6   privateStoreEnvelope,
      7   closePrivateStore
      8 } from '../../src/lib/messaging/private-store.ts';
      9 import {
     10   getPrivateCacheScope,
     11   privateCacheWire,
     12   privateCacheSnapshot,
     13   closePrivateCacheScope
     14 } from '../../src/lib/nostr/private-cache-scope.ts';
     15 
     16 it('SSR private store and cache acquisition has no browser or extension effect', async () => {
     17   expect(getPrivateStore({} as never)).toBeUndefined();
     18   expect(
     19     getPrivateCacheScope({} as never, 'projection_ownership')
     20   ).toBeUndefined();
     21   expect(
     22     await createPrivateSession(
     23       createIdentitySession(),
     24       'reviewed_private_session'
     25     )
     26   ).toBeUndefined();
     27 });
     28 it('forged private store and generic cache handles provide no read or disposal authority', () => {
     29   expect(() => privateStoreEnvelope({} as never, '0'.repeat(64))).toThrow(
     30     'private_store_invalid'
     31   );
     32   expect(() => privateCacheWire({} as never, '0'.repeat(64))).toThrow(
     33     'private_cache_invalid'
     34   );
     35   expect(() => privateCacheSnapshot({} as never)).toThrow(
     36     'private_cache_invalid'
     37   );
     38   expect(() => closePrivateStore({} as never)).toThrow('private_store_invalid');
     39   expect(() => closePrivateCacheScope({} as never)).toThrow(
     40     'private_cache_invalid'
     41   );
     42 });