@tinkerlandai/indiana-sdk 0.8.4 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -1
- package/README.md +45 -37
- package/README.zh-CN.md +42 -13
- package/dist/{ai-usage-DUlre7JC.d.ts → ai-usage-DMNKvCiq.d.ts} +3 -3
- package/dist/{api-XDc4pRlN.d.ts → api--Zf0gxfj.d.ts} +128 -124
- package/dist/chunk-3PZ4Y6UD.js +17 -0
- package/dist/chunk-5O667MKA.js +1 -0
- package/dist/chunk-7DXL3LHT.js +1 -0
- package/dist/chunk-7IB7CZ5P.js +1 -0
- package/dist/chunk-CPLLMISZ.js +1 -0
- package/dist/chunk-DAWZULXZ.js +1 -0
- package/dist/chunk-G23YNWWI.js +1 -0
- package/dist/chunk-G56XGVMS.js +1 -0
- package/dist/chunk-IH4KBLNR.js +1 -0
- package/dist/chunk-JEFEBF2H.js +1 -0
- package/dist/chunk-L7LKE3MG.js +173 -0
- package/dist/chunk-NH2PTTNK.js +2 -0
- package/dist/chunk-NTP55JMK.js +1 -0
- package/dist/chunk-SX5MO56H.js +4 -0
- package/dist/chunk-UBRLGIZE.js +1 -0
- package/dist/chunk-YAU4DI52.js +1 -0
- package/dist/{configuration-sync-Ce3dShy7.d.ts → configuration-sync-E98CqVwh.d.ts} +6 -5
- package/dist/content-YAPEUX6I.js +1 -0
- package/dist/{errors-C8lRYZ0n.d.ts → errors-0TSUIbUi.d.ts} +12 -1
- package/dist/{funnel-local-client-CUGavICI.d.ts → funnel-local-client-BjPwXlQb.d.ts} +550 -260
- package/dist/funnel-runtime-host-OZA763NT.js +1 -0
- package/dist/index.d.ts +689 -223
- package/dist/index.js +1 -1
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.d.ts +3 -3
- package/dist/openrouter.js +1 -1
- package/dist/page.d.ts +6 -6
- package/dist/page.js +1 -1
- package/dist/paywall-EM7RGU56.js +1 -0
- package/dist/popup.d.ts +1 -1
- package/dist/popup.js +1 -1
- package/dist/react-native.d.ts +122 -99
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-A6VYE2QL.js +1 -0
- package/dist/server.d.ts +58 -58
- package/dist/server.js +1 -1
- package/dist/visual.d.ts +36 -1
- package/dist/visual.js +1 -2
- package/package.json +1 -1
- package/dist/chunk-3F2NQOR2.js +0 -1
- package/dist/chunk-663UOBHL.js +0 -1
- package/dist/chunk-BUDTHBFF.js +0 -173
- package/dist/chunk-EJTBSGLV.js +0 -10
- package/dist/chunk-EXCPE2XH.js +0 -1
- package/dist/chunk-F2GOIBDQ.js +0 -1
- package/dist/chunk-GRLMT5PR.js +0 -1
- package/dist/chunk-KQCTDXVD.js +0 -17
- package/dist/chunk-LMR2TM3X.js +0 -1
- package/dist/chunk-OBYJWIRB.js +0 -1
- package/dist/chunk-RRII2DMC.js +0 -1
- package/dist/chunk-RZBZ6LCT.js +0 -4
- package/dist/chunk-SOQO2RDZ.js +0 -1
- package/dist/chunk-SSHUBTT3.js +0 -1
- package/dist/chunk-VVV3JNS3.js +0 -1
- package/dist/content-2FCUY6XX.js +0 -1
- package/dist/funnel-runtime-host-ENRTSXPJ.js +0 -1
- package/dist/paywall-734GWAS4.js +0 -1
- package/dist/screen-renderer-DLXDQQKK.js +0 -1
- package/dist/src-CLEFCTAU.js +0 -1
- package/dist/{screen-BpAejkn0.d.ts → screen-BITZ11jn.d.ts} +18 -18
package/CHANGELOG.md
CHANGED
|
@@ -2,13 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
Release facts and artifact evidence: [SDK release ledger](../../docs/sdk-releases.md).
|
|
4
4
|
|
|
5
|
+
## 0.9.1 — 2026-10-29
|
|
6
|
+
|
|
7
|
+
- Return scoped Access/Refresh credential pairs from backend issuance and Guest session resumption. Replace backend renewal with client Refresh Token rotation; backend revocation invalidates both credentials.
|
|
8
|
+
- Automatically refresh in Web, React Native, Swift and Kotlin without resetting Customer state, analytics queues, Funnel Runs or Paywalls. Fence account changes and retain Refresh Tokens after lost responses.
|
|
9
|
+
- Go owns opaque-session lifecycle and authorization policy; PostgreSQL serializes rotation and revocation. Protocol 0.9 requires the matching runtime and SQL migrations and refuses older development protocols.
|
|
10
|
+
|
|
11
|
+
## 0.8.5 — 2026-10-27
|
|
12
|
+
|
|
13
|
+
- Add direct browser script loading through `/sdk.js`, sharing the npm browser APIs and page/visual experiment factories without requiring a bundler. Website deployment distributes this entry independently of npm publication.
|
|
14
|
+
- Keep IAM release markers attached through host updates, group render-signature queries, and recover bounded visual work without duplicate exposure events.
|
|
15
|
+
- Disable Funnel Back navigation until the current presentation is rendered, and include the SDK version in experiment-event requests.
|
|
16
|
+
- Synchronize the packaged Web, iOS and Android renderers while retaining HTTP protocol 0.8.
|
|
17
|
+
|
|
5
18
|
## 0.8.4 — 2026-10-26
|
|
6
19
|
|
|
7
20
|
- Add `prepareContent` and `preparePopup` to render authorized content before the opening click and reveal the same iframe on demand.
|
|
8
21
|
- Prepare bounded HTML DOM templates for supplied pages and Product variants; update variable text in place while preserving styles, images and unrelated content. Reuse inactive variants with empty variable slots.
|
|
9
22
|
- Prepare Local Funnel rule definitions once per pure segment and send advance signals without waiting for advisory prediction downloads. Late predictions remain fenced by Run position and identity.
|
|
10
23
|
- Synchronize the packaged Web, iOS and Android renderers. Retain HTTP protocol 0.8 and server authority over Funnel acceptance and commercial operations.
|
|
11
|
-
-
|
|
24
|
+
- Carry the committed Merchandise context through Feature evaluation, page experiments, Analytics events and Coupon applicability; refresh the generated native Paywall schema.
|
|
25
|
+
- Include the committed Android Push recovery proofs, visual target diagnostics and Paywall/Funnel focus restoration fixes.
|
|
12
26
|
|
|
13
27
|
## 0.8.3 — 2026-10-26
|
|
14
28
|
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @tinkerlandai/indiana-sdk
|
|
2
2
|
|
|
3
|
-
These examples
|
|
3
|
+
These examples target SDK 0.9.1 and protocol 0.9 at `https://api.tinker.cash`, using a Sandbox App and credentials issued by the production deployment. Sandbox still contains production data; do not reuse credentials from the separate test deployment. Confirm runtime readiness in [environment state](../../docs/development-status.md) before running them.
|
|
4
4
|
|
|
5
5
|
[简体中文](./README.zh-CN.md)
|
|
6
6
|
|
|
@@ -9,13 +9,42 @@ The Indiana business SDK groups its capabilities as **Identity, Commerce, Growth
|
|
|
9
9
|
**IAM source scanning, generation, validation and upload belong to the independent build package `@tinkerlandai/indiana-iam`.** This business SDK retains only the runtime release binding used by GB visual changes. See [SDK boundaries](../../docs/sdk-architecture.md) and the [IAM package](../iam/README.md).
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
npm install --save-exact @tinkerlandai/indiana-sdk@0.
|
|
12
|
+
npm install --save-exact @tinkerlandai/indiana-sdk@0.9.1
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
SDK 0.
|
|
15
|
+
SDK 0.9.1 requires HTTP protocol 0.9. Install a version that matches your runtime; publishing a package does not deploy the server. Publication and accepted environment scope are recorded in the [release ledger](../../docs/sdk-releases.md) and [development status](../../docs/development-status.md).
|
|
16
16
|
|
|
17
17
|
The data/session layer handles public JSON, integrity checks and authenticated operations. The presentation host composes that layer with the packaged screen renderer; the renderer receives supplied data and emits action intents. Client display entry points load presentation lazily. The `/server` entry has no screen presentation dependency and uses a scoped Server Key only on your backend. A local SDK guard never replaces runtime authorization or verified payment completion. Console preview supplies simulated data/session results to the same presentation host.
|
|
18
18
|
|
|
19
|
+
## Plain HTML / script installation
|
|
20
|
+
|
|
21
|
+
The classic-script entry reuses the npm browser implementation, with no bundler:
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<script src="https://tinker.cash/sdk.js"></script>
|
|
25
|
+
<script type="module">
|
|
26
|
+
const {
|
|
27
|
+
createIndiana,
|
|
28
|
+
createPaywallSession,
|
|
29
|
+
showPaywall,
|
|
30
|
+
createFunnelRunController,
|
|
31
|
+
showFunnelRun,
|
|
32
|
+
mountContent,
|
|
33
|
+
} = await Indiana.ready;
|
|
34
|
+
const client = createIndiana({
|
|
35
|
+
baseUrl: "https://api.tinker.cash",
|
|
36
|
+
scope: { projectId: "<APP_UUID>", environment: "sandbox" },
|
|
37
|
+
});
|
|
38
|
+
// Obtain the complete session pair from your authenticated backend.
|
|
39
|
+
// client.identify(session);
|
|
40
|
+
// await client.readHoldings();
|
|
41
|
+
// client.track("page_viewed", { page: location.pathname });
|
|
42
|
+
// await client.flush();
|
|
43
|
+
</script>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Production uses `https://tinker.cash/sdk.js` and its matching API/credentials. `Indiana.ready` provides every root browser export plus `createPageExperiments` and `createVisualExperiments`; replace npm imports below with destructuring those names. Loading activates no sessions, events or experiments. Server Keys remain on your backend; Funnel start/recovery and logout cleanup retain the existing contracts. Duplicate tags share readiness, failures reject the Promise and UI loads lazily. With `async`/`defer`, wait for the loader tag's load event before accessing `Indiana`. CSP must allow the script origin and API connections. Page experiments use the same script entry; explicitly create their clients and call `start()`. See [script distribution](../../docs/sdk-architecture.md#web-script-distribution) and [the complete integration example](https://tinker.cash/docs/javascript#script).
|
|
47
|
+
|
|
19
48
|
## React Native core
|
|
20
49
|
|
|
21
50
|
Use the independent `@tinkerlandai/indiana-react-native` package. The `@tinkerlandai/indiana-sdk/react-native` subpath shares the same implementation. Both support Customer Token identity, holdings, entitlement checks and usage reporting through your authenticated backend. It requires no DOM or native UI/store bridge. See [mobile SDK installation and examples](../../docs/mobile-sdk.md).
|
|
@@ -53,32 +82,9 @@ The canonical repository policy, including production/test domain roles, package
|
|
|
53
82
|
|
|
54
83
|
Omitting `baseUrl` selects `https://api.tinker.cash`. This applies to Customer/Server, Funnel, Feature, Paywall, page and visual clients. `createConfigurationSync` also defaults its optional `origin` to that address. Swift `IndianaConfiguration(scope: ...)` and Kotlin `IndianaConfiguration(scope = ...)` uses the same default and shared release version. Explicit `baseURL` / `baseUrl` still overrides it. Funnel and Paywall shells and renderers are packaged locally; their executable code is not downloaded from that API origin.
|
|
55
84
|
|
|
56
|
-
Both `beta` and `latest` versions published with this default use the production API address. Tags select package versions, not deployments.
|
|
57
|
-
|
|
58
|
-
For our own testing, always require a test-service address instead of relying on the production default:
|
|
59
|
-
|
|
60
|
-
Set `INDIANA_TEST_BASE_URL=https://api.dev.tinker.cash` and use the native Cloud SQL test App/Key. A production Key or a retained Supabase Key cannot authenticate against that test environment.
|
|
61
|
-
|
|
62
|
-
```ts
|
|
63
|
-
const testBaseUrl = process.env.INDIANA_TEST_BASE_URL;
|
|
64
|
-
if (!testBaseUrl) throw new Error("Set INDIANA_TEST_BASE_URL explicitly");
|
|
65
|
-
|
|
66
|
-
const scope = { projectId: testProjectId, environment: "sandbox" as const };
|
|
67
|
-
const server = createIndianaServer({
|
|
68
|
-
baseUrl: testBaseUrl,
|
|
69
|
-
apiKey: testServerKey,
|
|
70
|
-
scope,
|
|
71
|
-
});
|
|
72
|
-
const customer = createIndiana({ baseUrl: testBaseUrl, scope });
|
|
73
|
-
const configuration = createConfigurationSync({
|
|
74
|
-
origin: testBaseUrl,
|
|
75
|
-
scope: { ...scope, environmentId: testEnvironmentId },
|
|
76
|
-
});
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
Use the same explicit address for every client in a test run, including Funnel start/controllers and page/visual clients. Environment variables are read by the host, not automatically by the SDK. Sandbox/Live selects business scope inside the chosen service; it does not select a deployment or database. Never retry against another service automatically after an error or unknown command result.
|
|
85
|
+
Both `beta` and `latest` versions published with this default use the production API address. Tags select package versions, not deployments. The separate test API at `https://api.dev.tinker.cash` requires its own credentials and a client matching its deployed protocol; it is outside this production 0.9 rollout.
|
|
80
86
|
|
|
81
|
-
|
|
87
|
+
Use the same API origin for every client and configuration-sync instance in one integration. Sandbox/Live selects business scope inside that deployment, not a different service or database. Never retry against another service automatically after an error or unknown command result. Maintainer test runs require an explicit target and must not fall back to production; follow the [SDK testing guide](../../docs/sdk-selfserve.md#maintainer-api-origin-testing).
|
|
82
88
|
|
|
83
89
|
## Create a Customer Session from a trusted backend
|
|
84
90
|
|
|
@@ -97,7 +103,7 @@ const user = await requireSignedInUser(request);
|
|
|
97
103
|
const { customer } = await indiana.getOrCreateCustomer({
|
|
98
104
|
externalUserId: user.id,
|
|
99
105
|
});
|
|
100
|
-
const
|
|
106
|
+
const session = await indiana.createCustomerSession(customer.id);
|
|
101
107
|
```
|
|
102
108
|
|
|
103
109
|
Keep the Secret Key on your trusted backend. A Customer ID supplied by a browser is not proof of login. Give each Customer Token only to the corresponding authenticated user. App, Sandbox/Live environment, Customer identity, permissions, and allowed origins are checked independently. The SDK holds Customer credentials in memory; destroy the previous view and clear credentials when signing out or changing accounts.
|
|
@@ -109,13 +115,13 @@ const indiana = createIndiana({
|
|
|
109
115
|
baseUrl,
|
|
110
116
|
scope: { projectId, environment: "sandbox" },
|
|
111
117
|
});
|
|
112
|
-
indiana.identify(
|
|
118
|
+
indiana.identify(session);
|
|
113
119
|
const { holdings } = await indiana.readHoldings();
|
|
114
120
|
// On sign-out:
|
|
115
121
|
indiana.reset();
|
|
116
122
|
```
|
|
117
123
|
|
|
118
|
-
|
|
124
|
+
The SDK refreshes its Access/Refresh pair directly with GOP. Access lasts at most one hour, Refresh at most 24 hours per rotation, within the original 30-day session limit. Successful rotation preserves the Customer identity and pending work; a definitive refresh refusal or expired Refresh Token clears the credentials and requires a new verified login. Business requests do not extend expiry or automatically replay after refresh. Revocation and issuer expiry still apply. See [Customer credentials](../../docs/customer-credentials.md).
|
|
119
125
|
|
|
120
126
|
Customer updates are partial patches and do not use a Customer revision. When a Guest signs in to an existing Customer, the response reports `switched: true`. Resources and history keep their original owner; create a new Session/Funnel for the target Customer. Guest financial facts are not merged.
|
|
121
127
|
|
|
@@ -274,15 +280,15 @@ import {
|
|
|
274
280
|
createIndiana,
|
|
275
281
|
} from "@tinkerlandai/indiana-sdk";
|
|
276
282
|
|
|
277
|
-
//
|
|
278
|
-
const
|
|
283
|
+
// Use a Sandbox App and credentials issued by the production deployment.
|
|
284
|
+
const apiUrl = "https://api.tinker.cash";
|
|
279
285
|
const scope = { projectId, environment: "sandbox" as const, environmentId };
|
|
280
286
|
const configuration = createConfigurationSync({
|
|
281
|
-
origin:
|
|
287
|
+
origin: apiUrl,
|
|
282
288
|
scope,
|
|
283
289
|
});
|
|
284
290
|
const indiana = createIndiana({
|
|
285
|
-
baseUrl:
|
|
291
|
+
baseUrl: apiUrl,
|
|
286
292
|
scope: { projectId, environment: "sandbox" },
|
|
287
293
|
configuration,
|
|
288
294
|
});
|
|
@@ -374,8 +380,8 @@ export async function showBanner(
|
|
|
374
380
|
onContinue: (intent: ContentActionIntent) => Promise<void>,
|
|
375
381
|
) {
|
|
376
382
|
const indiana = createIndiana({
|
|
377
|
-
baseUrl: "https://api.
|
|
378
|
-
scope: { projectId: "<
|
|
383
|
+
baseUrl: "https://api.tinker.cash",
|
|
384
|
+
scope: { projectId: "<APP_UUID>", environment: "sandbox" },
|
|
379
385
|
});
|
|
380
386
|
indiana.identify(customerToken);
|
|
381
387
|
const { content } = await indiana.resolveContent({
|
|
@@ -419,3 +425,5 @@ openButton.addEventListener("click", () => popup.show(), {
|
|
|
419
425
|
```
|
|
420
426
|
|
|
421
427
|
Preparation waits for the first render without opening the dialog or running actions. `show()` reveals the same iframe and is idempotent; destroy and prepare a fresh handle for another presentation. Abort also cancels preparation while it is pending. This does not pre-authorize business operations or guarantee that images have decoded. For low-level ScreenDocument rendering, `/popup` provides `preparePopup(document, options)` with `ready`, `show()` and `destroy()`.
|
|
428
|
+
|
|
429
|
+
Customer sessions contain `customerId`, `sessionId`, `accessToken`, `refreshToken`, `expiresAt` and `refreshExpiresAt`. Return the pair only to the authenticated merchant user with `Cache-Control: no-store`, then call `indiana.identify(session)`. The SDK refreshes directly with GOP and keeps credentials in memory; account reset fences pending refresh. Your backend uses `revokeCustomerSessions({customerId, sessionId?})` for revocation. Share `indiana.session` through the `session` option of independent Paywall/Funnel clients to preserve one refresh lifecycle.
|
package/README.zh-CN.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[English](./README.md)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
本页示例面向 SDK 0.9.1 和协议 0.9,使用 `https://api.tinker.cash` 以及生产部署内签发的 Sandbox App/凭据。Sandbox 仍属于生产数据,不能复用独立测试部署的凭据。运行前核对[环境状态](../../docs/development-status.md),确认服务已就绪。
|
|
4
4
|
|
|
5
5
|
# @tinkerlandai/indiana-sdk
|
|
6
6
|
|
|
@@ -9,13 +9,42 @@
|
|
|
9
9
|
**IAM 的源码扫描、生成、校验和上传属于独立构建包 `@tinkerlandai/indiana-iam`。** 普通业务 SDK 只保留 GB visual 应用页面变更所需的运行时 release 绑定。完整定义见 [SDK 边界](../../docs/sdk-architecture.md) 与 [IAM 构建包](../iam/README.md)。
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
npm install --save-exact @tinkerlandai/indiana-sdk@0.
|
|
12
|
+
npm install --save-exact @tinkerlandai/indiana-sdk@0.9.1
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
SDK 0.
|
|
15
|
+
SDK 0.9.1 要求 HTTP 协议 0.9。安装版本须与运行服务匹配;发布包不会部署服务端。实际发布、标签与环境验收范围见 [SDK 发布总账](../../docs/sdk-releases.md) 和 [开发状态](../../docs/development-status.md)。
|
|
16
16
|
|
|
17
17
|
数据/会话层负责公开 JSON、完整性校验和鉴权操作;展示宿主将会话接口接入打包的屏幕渲染器,渲染器消费已提供的数据并返回动作意图。客户端按需加载展示;`/server` 入口使用商户后端的受限 Server Key,不加载屏幕展示。SDK 本地检查不替代运行时授权或付款核实。后台 Preview 为同一个展示宿主提供模拟会话和数据。
|
|
18
18
|
|
|
19
|
+
## 普通 HTML / script 接入
|
|
20
|
+
|
|
21
|
+
普通 script 标签复用 npm 浏览器实现,无需打包工具:
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<script src="https://tinker.cash/sdk.js"></script>
|
|
25
|
+
<script type="module">
|
|
26
|
+
const {
|
|
27
|
+
createIndiana,
|
|
28
|
+
createPaywallSession,
|
|
29
|
+
showPaywall,
|
|
30
|
+
createFunnelRunController,
|
|
31
|
+
showFunnelRun,
|
|
32
|
+
mountContent,
|
|
33
|
+
} = await Indiana.ready;
|
|
34
|
+
const client = createIndiana({
|
|
35
|
+
baseUrl: "https://api.tinker.cash",
|
|
36
|
+
scope: { projectId: "<APP_UUID>", environment: "sandbox" },
|
|
37
|
+
});
|
|
38
|
+
// 从验证登录后的自有后端获取完整 session 凭据对。
|
|
39
|
+
// client.identify(session);
|
|
40
|
+
// await client.readHoldings();
|
|
41
|
+
// client.track("page_viewed", { page: location.pathname });
|
|
42
|
+
// await client.flush();
|
|
43
|
+
</script>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
生产脚本为 `https://tinker.cash/sdk.js`,配套使用同环境 API 和凭据。`Indiana.ready` 返回根入口的全部浏览器导出,以及 `createPageExperiments` / `createVisualExperiments`;下文 npm import 可替换为从该 Promise 解构同名函数。加载不自动创建会话、发送事件或启动实验。Server Key 留在后端,Funnel 启动恢复与退出清理沿用现有流程。重复标签共用 ready,失败会拒绝 Promise,UI 按需加载。加载标签使用普通 script;添加 async/defer 时先等标签 load 事件,再访问 Indiana。CSP 需允许脚本来源和 API 连接。页面实验也使用该统一入口,显式创建客户端并调用 `start()`。详见 [script 分发](../../docs/sdk-architecture.md#web-script-distribution)和[完整接入示例](https://tinker.cash/docs/javascript#script)。
|
|
47
|
+
|
|
19
48
|
## React Native 核心入口
|
|
20
49
|
|
|
21
50
|
React Native 使用独立包 `@tinkerlandai/indiana-react-native`,原 `@tinkerlandai/indiana-sdk/react-native` 子入口共用同一实现。两者均支持 Customer Token 身份接入、权益读取和经业务后端转发的用量上报。此入口无需 DOM,不包含原生 UI 或内购桥接。参见[移动端 SDK 安装与示例](../../docs/mobile-sdk.md)。
|
|
@@ -65,11 +94,9 @@ JavaScript 与 TypeScript 共用本包,声明文件随包提供。内部 `@ind
|
|
|
65
94
|
|
|
66
95
|
包含此默认值的版本无论标记为 `beta` 或 `latest`,都使用生产 API 地址。标签选择包版本,不选择服务环境。两套 API 入口经 Vercel 转发到各自 Go Indianapolis,入口和业务就绪分别验收。
|
|
67
96
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
测试 API 地址为 `https://api.dev.tinker.cash`,测试主站/Admin 使用 `dev.tinker.cash`。测试应用配置 `INDIANA_TEST_BASE_URL=https://api.dev.tinker.cash`,使用测试环境自己的 App/Key,并核验权限与集成配置。默认地址保持生产 `https://api.tinker.cash`,由测试应用显式覆盖。
|
|
97
|
+
同一次接入中的所有客户端与配置同步实例使用同一个 API origin。`environment: "sandbox"` 只选择该部署内的业务环境,不选择另一套服务或数据库;错误或未知写入结果不能触发跨环境自动重试。
|
|
71
98
|
|
|
72
|
-
|
|
99
|
+
独立测试 API `https://api.dev.tinker.cash` 不在本次生产 0.9 升级范围内,必须使用与其已部署协议匹配的 SDK 和测试凭据。维护者测试必须显式指定目标,不能回落生产默认值,见[测试流程](../../docs/sdk-selfserve.md#maintainer-api-origin-testing)。
|
|
73
100
|
|
|
74
101
|
## 从可信后端创建 Customer Session
|
|
75
102
|
|
|
@@ -88,10 +115,10 @@ const user = await requireSignedInUser(request);
|
|
|
88
115
|
const { customer } = await indiana.getOrCreateCustomer({
|
|
89
116
|
externalUserId: user.id,
|
|
90
117
|
});
|
|
91
|
-
const
|
|
118
|
+
const session = await indiana.createCustomerSession(customer.id);
|
|
92
119
|
```
|
|
93
120
|
|
|
94
|
-
Secret Key 仅保存在可信后端。浏览器传入的 Customer ID
|
|
121
|
+
Secret Key 仅保存在可信后端。浏览器传入的 Customer ID 不能作为登录证明;将完整 Access/Refresh 凭据对交给对应的已登录用户。App、Sandbox/Live、Customer、权限和允许来源分别校验。SDK 在内存中持有客户凭据;退出或切换身份时销毁旧视图并清理凭据。
|
|
95
122
|
|
|
96
123
|
```ts
|
|
97
124
|
import { createIndiana } from "@tinkerlandai/indiana-sdk";
|
|
@@ -100,13 +127,13 @@ const indiana = createIndiana({
|
|
|
100
127
|
baseUrl,
|
|
101
128
|
scope: { projectId, environment: "sandbox" },
|
|
102
129
|
});
|
|
103
|
-
indiana.identify(
|
|
130
|
+
indiana.identify(session);
|
|
104
131
|
const { holdings } = await indiana.readHoldings();
|
|
105
132
|
// 退出账号时:
|
|
106
133
|
indiana.reset();
|
|
107
134
|
```
|
|
108
135
|
|
|
109
|
-
|
|
136
|
+
SDK 通过 Refresh Token 直接向 GOP 轮换凭据;Access 最长 1 小时,Refresh 每次轮换最长 24 小时,原会话最长 30 天。成功轮换保留当前 Customer 身份和待处理业务;刷新被明确拒绝或 Refresh Token 过期时清除凭据,需要重新验证登录。普通业务请求不延期,刷新不会自动重放业务写入。撤销和 Key 到期继续生效。见[Customer 凭据](../../docs/customer-credentials.md)。
|
|
110
137
|
|
|
111
138
|
Customer 使用原始业务字段;资料更新是部分 patch,没有 Customer revision。Guest 登录到已有 Customer 时返回 `switched: true`,资源和历史保留原归属,接入方应为目标 Customer 创建新 Session/Funnel;不合并旧 Guest 的财务事实。
|
|
112
139
|
|
|
@@ -279,8 +306,8 @@ export async function showBanner(
|
|
|
279
306
|
onContinue: (intent: ContentActionIntent) => Promise<void>,
|
|
280
307
|
) {
|
|
281
308
|
const indiana = createIndiana({
|
|
282
|
-
baseUrl: "https://api.
|
|
283
|
-
scope: { projectId: "<
|
|
309
|
+
baseUrl: "https://api.tinker.cash",
|
|
310
|
+
scope: { projectId: "<APP_UUID>", environment: "sandbox" },
|
|
284
311
|
});
|
|
285
312
|
indiana.identify(customerToken);
|
|
286
313
|
const { content } = await indiana.resolveContent({
|
|
@@ -307,3 +334,5 @@ export async function showBanner(
|
|
|
307
334
|
需要加快点击打开时,可提前为当前 Customer 读取内容,再调用根入口的 `prepareContent(container, options)`,参数与 `mountContent` 相同。它提前加载展示模块、校验文档并启动 iframe,等首次渲染后返回句柄;点击时同步调用 `handle.show()`,直接显示同一个 iframe。准备期间不打开弹窗、不抢焦点、不执行动作。句柄用于一次展示,重复 `show()` 不重复挂载;下一次展示需重新准备。
|
|
308
335
|
|
|
309
336
|
可传入 `signal: abortController.signal`,在卸载、退出或切换 Customer/App/环境时 `abortController.abort()`,连同仍在等待的准备一起取消并释放资源。预渲染不代替业务鉴权,也不保证图片已完成解码。直接持有已授权 ScreenDocument 的低层接入可使用 `/popup` 的 `preparePopup(document, options)`;句柄立即返回,提供 `ready`、`show()` 和 `destroy()`。
|
|
337
|
+
|
|
338
|
+
客户会话返回 `customerId`、`sessionId`、`accessToken`、`refreshToken`、`expiresAt`、`refreshExpiresAt`。后端只向当前已验证用户返回这组数据,并设置 `Cache-Control: no-store`;客户端调用 `indiana.identify(session)`。SDK 在内存中保管凭据,直接向 GOP 刷新,切换账号或 reset 后不接纳旧刷新响应。撤销由后端调用 `revokeCustomerSessions({customerId, sessionId?})`。独立 Paywall/Funnel 客户端可通过 `session: indiana.session` 共用刷新生命周期。
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LanguageModelV4Usage, LanguageModelV4Middleware } from '@ai-sdk/provider';
|
|
2
|
-
import { F as FoundationApi, A as ApiInput } from './api
|
|
2
|
+
import { F as FoundationApi, A as ApiInput } from './api--Zf0gxfj.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
declare const tokenCounts: z.ZodObject<{
|
|
@@ -104,7 +104,7 @@ declare function createAiPricing(options?: AiPricingOptions): {
|
|
|
104
104
|
accepted: boolean;
|
|
105
105
|
reason: "expired" | "unavailable" | "insufficient_balance" | "limit_exceeded" | "awaiting_topup" | "authorization_required" | "payment_blocked" | "cash_budget_exceeded" | null;
|
|
106
106
|
createdAt: string;
|
|
107
|
-
reservationStatus: "
|
|
107
|
+
reservationStatus: "expired" | "pending" | "confirmed" | "released" | null;
|
|
108
108
|
expiresAt: string | null;
|
|
109
109
|
allocations: ({
|
|
110
110
|
funding: "prepaid";
|
|
@@ -175,7 +175,7 @@ declare function createConfiguredAiPricing(client: Pick<FoundationApi, "readAiPr
|
|
|
175
175
|
accepted: boolean;
|
|
176
176
|
reason: "expired" | "unavailable" | "insufficient_balance" | "limit_exceeded" | "awaiting_topup" | "authorization_required" | "payment_blocked" | "cash_budget_exceeded" | null;
|
|
177
177
|
createdAt: string;
|
|
178
|
-
reservationStatus: "
|
|
178
|
+
reservationStatus: "expired" | "pending" | "confirmed" | "released" | null;
|
|
179
179
|
expiresAt: string | null;
|
|
180
180
|
allocations: ({
|
|
181
181
|
funding: "prepaid";
|