Skip to content

TypeScript: connectFromKey missing from src/index.d.ts (3.5.0) #70

Description

@perki

Summary

pryv@3.5.0 adds a module-level connectFromKey helper and Service#connectFromKey for the new key-based auth-flow handoff, but neither declaration is present in src/index.d.ts. TypeScript consumers calling the documented migration helper hit:

error TS2339: Property 'connectFromKey' does not exist on type 'typeof import("pryv")'.

Reproduction

import pryv from 'pryv'

// Documented 3.5.0 migration recipe
const connection = await pryv.connectFromKey(state.key, serviceInfoUrl)
// ^ TS2339

Service form:

const service = new pryv.Service(serviceInfoUrl)
await service.connectFromKey(key)
// ^ also TS2339 — Service interface in src/index.d.ts is missing the method

Evidence the function exists at runtime

  • src/index.js:30 — re-exports connectFromKey from the module
  • src/index.js:46-50 — definition: async function connectFromKey(key, serviceInfoUrl, serviceCustomizations) returning a Connection built via a transient Service
  • src/Service.js:540-552Service.prototype.connectFromKey(key)
  • test/Service.accessRequest.test.js:41+[CFKX] Service.connectFromKey test suite confirms the public-API intent

Suggested fix

Add to src/index.d.ts:

declare module 'pryv' {
  /**
   * Module-level convenience over `Service#connectFromKey`. Resolves the
   * service-info URL, instantiates a transient `Service`, and returns a
   * working `Connection` for the granted access.
   */
  export function connectFromKey(
    key: string,
    serviceInfoUrl?: string,
    serviceCustomizations?: unknown
  ): Promise<Connection>;

  interface Service {
    connectFromKey(key: string): Promise<Connection>;
  }
}

Until upstream lands the type, downstream consumers can augment locally. hds-lib (a downstream wrapper around pryv) has applied this workaround at https://github.com/healthdatasafe/hds-lib-js/blob/1.1.1/ts/patchedPryv.ts — referenced for context.

Impact

Affects every TypeScript consumer following the 3.5.0 AUTHORIZED-state migration recipe. Runtime behavior is fine; the symptom is purely a tsc --noEmit failure.

Environment

  • pryv@3.5.0 (installed via npm, latest as of 2026-06-02)
  • TypeScript 5.7+
  • Verified across three independent consumers (apps in our workspace)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions