Back to Black Site
SOURCE / PINNED RELEASE

Made of little things.

Black Site

Release
666bc7c74ebd…
Author-recorded commit
05e95af79676…
License
LICENSE
Author’s source reference
nostr://npub12lm3rxsva8kfempyjkxupt09e02n3fezurkyadyqfejdc5e0r2kscqty6r/wss%3A%2F%2Fgit.napplet.soy%2F/n-d2225ddc391

Archive hash verified: 1544e072e245c4a8…. The source-to-build association is the author’s claim; it has not been independently rebuilt.

src/armory-host.ts
import { identity, outbox } from '@napplet/sdk';
import { appDataCollection, type AppDataHost } from '../docs/examples/app-data.js';
import { validateCustomization } from './customization.js';
import { validateArmory } from './armory.js';
import { runtimeHasDomain } from './domain-availability.js';

/** Sole policy adapter: observe the documented host hint; all identity/event calls use the SDK. */
async function openPlayerCollection<T>(collection: string, schema: string, validate: (value: unknown) => T) {
  if (!runtimeHasDomain('identity') || !runtimeHasDomain('outbox')) throw new Error('app-data-unavailable');
  const injected = (globalThis as unknown as { napplet?: AppDataHost }).napplet;
  if (!injected?.shell?.onReady) throw new Error('app-data-unavailable');
  const host: AppDataHost = {
    shell: injected.shell,
    identity: { getPublicKey: () => identity.getPublicKey() },
    outbox: {
      query: (filters, options) => outbox.query(filters as Parameters<typeof outbox.query>[0], options),
      publish: (template, options) => outbox.publish(template, options),
    },
  };
  return appDataCollection({ collection, schema, version: 1, validate, host });
}
export const openArmoryCollection = () => openPlayerCollection('player-armory', 'blacksite.armory', validateArmory);
export const openCustomizationCollection = () => openPlayerCollection('player-customization', 'blacksite.customization', validateCustomization);
export type ArmoryCollection = Awaited<ReturnType<typeof openArmoryCollection>>;