Documentation
    Preparing search index...

    Function createResourceService

    • Create a NAP-RESOURCE reference service.

      Implements the NAP-RESOURCE request/response protocol: resource.info, resource.bytes, resource.bytesMany, resource.cancel, and their result/error envelopes.

      The runtime resolver is validated at construction. Runtime implementers may additionally install the origin-grant adapter; Kehto provides and enforces the hook contract without selecting the grants or requiring that policy.

      Returns a ServiceHandler (no publishValues-style surface — resource has no shell-initiated push beyond the response/error path).

      Parameters

      Returns ServiceHandler

      ServiceHandler to register via runtime.registerService('resource', handler)

      import { createResourceService } from '@kehto/services';

      const svc = createResourceService({
      fetch: (url, init) => runtimeResources.resolve(url, init),
      isOriginGranted: (origin, grants) => grants.includes(origin),
      getConnectGrants: (dTag, hash) => myOriginGrantStore.getOrigins(dTag, hash),
      resolveIdentity: (windowId) => sessionRegistry.getEntryByWindowId(windowId) ?? null,
      });
      runtime.registerService('resource', svc);