@happy-technologies/connector-core

中文文档
0.3.0发布于 2026/07/11Apache-2.0TypeScriptES Module近 30 天下载 4459

Shared connector substrate for Happy Technologies products: manifest/descriptor schema, a generic registry, config validation, and an OAuth/credential substrate. Domain-agnostic; products supply their own connector contract, crypto, and storage.

原始使用文档
文档目录4 节
  1. Design boundary
  2. Wiring the OAuth substrate with Arctic
  3. Scripts
  4. Status

@happy-technologies/connector-core

The shared connector substrate for Happy Technologies products. It provides the parts of a connector platform that are identical across products, and nothing that is specific to one:

  • Manifest / descriptor schema (ConnectorDescriptor): the single source of truth for a connector's metadata, driving config validation, the catalog, and the registration form.
  • A generic ConnectorRegistry<T>: register connectors, look them up, list the catalog, validate config. Replaces closed enums and DB CHECK constraints.
  • Descriptor-driven config validation, including a guard that rejects credential-shaped keys on the non-secret config path.
  • An OAuth and credential substrate (OAuthSubstrate): the authorization-code flow, token refresh, and encrypted token storage, behind injected interfaces.
  • An optional document-connector contract (SourceConnector) for products that ingest documents.

Design boundary

This package owns metadata, registry mechanics, validation, and auth orchestration. It does not own:

  • Product domain logic (compiling to artifacts, reconciling to CIs).
  • Crypto. You inject a SecretCipher.
  • Storage. You inject a CredentialStore and optionally an OAuthStateStore.
  • A specific OAuth library. You inject per-provider OAuthClient instances.

This is the seam that lets the auth backend be swapped later (for example to a self-hosted Nango) without touching connector code.

Wiring the OAuth substrate with Arctic

Arctic (arcticjs.dev, MIT) provides typed OAuth 2.0 clients for Microsoft Entra ID, Google, Atlassian, GitHub, Slack, and more. Arctic's token object exposes methods (accessToken()), so wrap each client to the OAuthClient shape this package expects:

import * as arctic from "arctic";
import { OAuthSubstrate, type OAuthClient } from "@happy-technologies/connector-core";

function wrap(provider: {
  createAuthorizationURL: (state: string, codeVerifier: string, scopes: string[]) => URL;
  validateAuthorizationCode: (code: string, codeVerifier: string) => Promise<arctic.OAuth2Tokens>;
  refreshAccessToken: (refreshToken: string, scopes?: string[]) => Promise<arctic.OAuth2Tokens>;
}): OAuthClient {
  const toTokens = (t: arctic.OAuth2Tokens) => ({
    accessToken: t.accessToken(),
    refreshToken: t.hasRefreshToken() ? t.refreshToken() : undefined,
    accessTokenExpiresAt: t.accessTokenExpiresAt(),
  });
  return {
    createAuthorizationURL: (state, verifier, scopes) =>
      provider.createAuthorizationURL(state, verifier, scopes),
    validateAuthorizationCode: async (code, verifier) =>
      toTokens(await provider.validateAuthorizationCode(code, verifier)),
    refreshAccessToken: async (refreshToken, scopes) =>
      toTokens(await provider.refreshAccessToken(refreshToken, scopes)),
  };
}

const google = new arctic.Google(clientId, clientSecret, redirectUri);

const oauth = new OAuthSubstrate({
  clients: new Map([["google", wrap(google)]]),
  credentials: myCredentialStore, // backed by your DB + envelope crypto
  cipher: myEnvelopeCipher,        // encryptSecret / decryptSecret
});

// In a fetch path:
const cred = await oauth.resolve(sourceId);
const res = await fetch(url, { headers: cred.headers });

For client-credentials / app-only grants (Microsoft Graph app-only, ServiceNow service accounts), implement OAuthClient directly over a token endpoint, or use openid-client.

Scripts

  • bun test runs the unit suite.
  • bun run type-check runs tsc --noEmit.
  • bun run build emits dist/ with declarations.
  • bun run check:no-em-dash enforces the org content rule.

Status

v0.1: substrate core (descriptor, registry, validation, auth, document contract) with tests. Consumed first by Happy Knowledge; HappyCMDB's existing framework migrates onto the same manifest schema over time.

版本与发布记录

@happy-technologies/connector-core 共发布 3 个版本,首次发布于 2026/06/21;过去 12 个月发布了 3 个版本。

版本发布日期距今
0.3.0latest2026/07/114 个月前
0.2.02026/06/224 个月前
0.1.02026/06/214 个月前

关于 @happy-technologies/connector-core 的常见问题

@happy-technologies/connector-core 是什么?

Shared connector substrate for Happy Technologies products: manifest/descriptor schema, a generic registry, config validation, and an OAuth/credential substrate. Domain-agnostic; products supply their own connector contract, crypto, and storage.

如何安装 @happy-technologies/connector-core?

在项目目录运行 npm install @happy-technologies/connector-core,或使用 pnpm add / yarn add / bun add。

@happy-technologies/connector-core 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@happy-technologies/connector-core 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@happy-technologies/connector-core 可以商用吗?

@happy-technologies/connector-core 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@happy-technologies/connector-core 的下载量有多少?

根据 npm 官方下载统计,@happy-technologies/connector-core 在 2026/10/17 – 2026/11/15 这 30 天内被下载 4,459 次,日均约 149 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@happy-technologies/connector-core 还在维护吗?

最新版本 0.3.0 发布于 2026/07/11(4 个月前);至今共发布 3 个版本,其中过去 12 个月发布了 3 个;首次发布于 2026/06/21。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。