@fiskil/link

中文文档
1.0.0发布于 2026/11/13SEE LICENSE IN LICENSE.mdTypeScriptES Module零依赖近 30 天下载 2.4万

Minimal TypeScript SDK for creating Fiskil auth sessions (redirect or iframe).

原始使用文档
文档目录9 节
  1. Fiskil Link SDK ( @fiskil/link )
  2. Installation
  3. Quick start (ESM/TypeScript)
  4. API Reference
  5. link(sessionId, options?)
  6. Result
  7. Migrating to 1.0.0
  8. Error Handling
  9. UMD / CDN Usage

Tests npm version

The Fiskil Link SDK (@fiskil/link) makes it easy to embed a Fiskil Auth Session inside your web application. An Auth Session is how end-users connect their bank or financial institution to share Consumer Data Right (CDR) data through the Fiskil platform.

This SDK handles the complete consent process and returns the outcome of the data sharing process - and you only need to provide a Fiskil auth_session_id to initiate and handle the result in your app. Once the user approves CDR sharing, your backend can listen for Fiskil webhooks and then begin fetching CDR data through Fiskil’s Banking or Energy APIs.

Installation

Install the package with your preferred package manager:

npm i @fiskil/link
# or
pnpm add @fiskil/link

Quick start (ESM/TypeScript)

Note that to use this SDK, you’ll need a Fiskil team account. If you don't have an account, you can get in touch for a quick demo. If you’re new to Fiskil platform, start with the Quick Start Guide.

Before launching the consent flow, your backend must create an Auth Session through the Fiskil API. Pass the resulting auth_session_id into the SDK to start the flow in your application.

import { link, type LinkError } from '@fiskil/link';

// Start the consent flow
const flow = link('auth_session_id');

try {
  const result = await flow;
  console.log(result.consents);
} catch (err) {
  const linkError = err as LinkError;
  console.log('Link Error code:', linkError.code);
} 

// to cancel the consent flow programmatically
// flow.close();

API Reference

link(sessionId, options?)

Creates and mounts the consent UI element. Returns a LinkFlow object, which is both:

  • a Promise that resolves with the flow result, and
  • a controller with .close() to cancel the flow programmatically.
OptionTypeDescription
timeoutMsnumberMaximum time for the consent flow, in milliseconds. Defaults to 600000 (10 minutes).

Result

The LinkFlow resolves with the success payload:

type LinkResult = {
  redirectURL?: string;
  consents: string[];
};
  • Resolved result includes redirectURL (if configured) and consents, an array of consent IDs that can be used to fetch user data from the Fiskil platform.
  • On failure, the promise rejects with a LinkError (see Error Handling).

Completion messages must contain one or more non-blank string IDs. Invalid consents are ignored without falling back to consentID; the SDK waits for a valid result or timeout.

Migrating to 1.0.0

Breaking change: replace result.consentID with result.consents, an array of consent IDs, and handle each ID. redirectURL remains optional.

Legacy completion messages are still supported: the SDK converts consentID to consents: [consentID].

The SDK adds its package version to the iframe URL as sdkVersion. No configuration is required.

Error Handling

The promise rejects with a LinkError if any error encountered during consent flow.

interface LinkError extends Error {
  name: 'LinkError';
  code: LinkErrorCode;
  details?: unknown;
}
Error CodeDescription
LINK_NOT_FOUNDContainer element not found in DOM
LINK_TIMEOUTFlow exceeded timeout duration specified in options
LINK_USER_CANCELLEDUser cancelled or flow was closed programmatically
LINK_ORIGIN_MISMATCHMessage received from unexpected origin
LINK_INTERNAL_ERRORUnrecognized error encountered during the consent flow. Unknown error types are preserved in details.error_type
LINK_INVALID_SESSIONThe specified auth session is invalid
AUTH_SESSION_INVALIDAuth session is invalid
AUTH_SESSION_CANCELLEDAuth session was cancelled
CONSENT_UPSTREAM_PROCESSING_ERRORUpstream processing error during consent flow
CONSENT_ENDUSER_DENIEDUser denied consent during consent flow
CONSENT_OTP_FAILUREOTP verification failed during consent flow
CONSENT_ENDUSER_INELIGIBLEUser is ineligible for data sharing
CONSENT_TIMEOUTConsent process timed out

Note: For LINK_INVALID_SESSION, the iframe remains mounted. You can close it programmatically with .close(). For AUTH_SESSION_INVALID, the iframe is removed when the promise rejects.

UMD / CDN Usage

<script src="https://cdn.jsdelivr.net/npm/@fiskil/[email protected]/dist/fiskil-link.umd.js"></script>
<script>
  const flow = FiskilLink.link('session_123');
  flow.then((res) => console.log('done', res)).catch(console.error);
  // flow.close();
</script>

版本与发布记录

@fiskil/link 共发布 11 个版本,首次发布于 2025/09/05;过去 12 个月发布了 3 个版本。

版本发布日期距今
1.0.0latest2026/11/131 天前
0.1.102026/06/164 个月前
0.1.92026/01/0610 个月前
0.1.8-beta2025/09/181.2 年前
0.1.6-beta2025/09/121.2 年前
0.1.5-beta2025/09/051.2 年前

关于 @fiskil/link 的常见问题

@fiskil/link 是什么?

Minimal TypeScript SDK for creating Fiskil auth sessions (redirect or iframe).

如何安装 @fiskil/link?

在项目目录运行 npm install @fiskil/link,或使用 pnpm add / yarn add / bun add。

@fiskil/link 支持 TypeScript 吗?

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

@fiskil/link 支持 ESM 还是 CommonJS?

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

@fiskil/link 可以商用吗?

@fiskil/link 使用 SEE LICENSE IN LICENSE.md 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@fiskil/link 的下载量有多少?

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

@fiskil/link 还在维护吗?

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