@tangle-network/agent-integrations 0.26.0 → 0.28.0
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/dist/bin/tangle-catalog-runtime.js +6 -2
- package/dist/bin/tangle-catalog-runtime.js.map +1 -1
- package/dist/catalog.d.ts +5 -1
- package/dist/catalog.js +6 -2
- package/dist/chunk-ATYHZXLL.js +457 -0
- package/dist/chunk-ATYHZXLL.js.map +1 -0
- package/dist/chunk-H4XYLS7T.js +75 -0
- package/dist/chunk-H4XYLS7T.js.map +1 -0
- package/dist/{chunk-GA4VTE3U.js → chunk-JU25UDN2.js} +5 -58
- package/dist/chunk-JU25UDN2.js.map +1 -0
- package/dist/chunk-P24T3MLM.js +106 -0
- package/dist/chunk-P24T3MLM.js.map +1 -0
- package/dist/chunk-SVQ4PHDZ.js +129 -0
- package/dist/chunk-SVQ4PHDZ.js.map +1 -0
- package/dist/{chunk-ALCIWTIR.js → chunk-UWRYFPJW.js} +41 -83
- package/dist/chunk-UWRYFPJW.js.map +1 -0
- package/dist/connect/index.d.ts +112 -0
- package/dist/connect/index.js +14 -0
- package/dist/connect/index.js.map +1 -0
- package/dist/connectors/adapters/index.d.ts +593 -1
- package/dist/connectors/adapters/index.js +15 -1
- package/dist/connectors/index.d.ts +2 -1
- package/dist/connectors/index.js +19 -5
- package/dist/errors-Bg3_rxnQ.d.ts +32 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +47 -9
- package/dist/middleware/index.d.ts +137 -0
- package/dist/middleware/index.js +14 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/registry.d.ts +29 -33
- package/dist/registry.js +6 -2
- package/dist/router-BncoovUh.d.ts +149 -0
- package/dist/runtime.d.ts +5 -1
- package/dist/runtime.js +6 -2
- package/dist/specs.d.ts +5 -1
- package/dist/stripe/index.d.ts +812 -0
- package/dist/stripe/index.js +866 -0
- package/dist/stripe/index.js.map +1 -0
- package/dist/tangle-catalog-runtime.d.ts +5 -1
- package/dist/tangle-catalog-runtime.js +6 -2
- package/dist/tangle-id-CTU4kGId.d.ts +553 -0
- package/dist/webhooks/index.d.ts +3 -148
- package/package.json +16 -1
- package/dist/chunk-ALCIWTIR.js.map +0 -1
- package/dist/chunk-GA4VTE3U.js.map +0 -1
- package/dist/index-D4D4CEKX.d.ts +0 -976
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { T as TangleIdentityOptions, a as TangleUserSummary } from '../tangle-id-CTU4kGId.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @stable Cross-product connect flow.
|
|
5
|
+
*
|
|
6
|
+
* A product app (legal, tax, gtm, creative, agent-builder, sandbox, …) that
|
|
7
|
+
* is already part of the Tangle trusted-app registry on id.tangle.tools
|
|
8
|
+
* routes its users through this flow to obtain an `sk-tan-*` API key bound
|
|
9
|
+
* to the calling user. The shape mirrors the platform's `/cross-site/*`
|
|
10
|
+
* routes one-for-one so consumers can swap a bespoke fetch loop for these
|
|
11
|
+
* helpers without changing the wire protocol.
|
|
12
|
+
*
|
|
13
|
+
* Three stages:
|
|
14
|
+
*
|
|
15
|
+
* 1. start({ appId, returnUrl, state }) → { authorizeUrl }
|
|
16
|
+
* The product redirects the user to `authorizeUrl`. id.tangle.tools
|
|
17
|
+
* checks the session cookie; if absent it punts to the login page
|
|
18
|
+
* with a callback back to /cross-site/authorize.
|
|
19
|
+
*
|
|
20
|
+
* 2. callback({ code, app, state }) → { apiKey, user, workspaceId }
|
|
21
|
+
* id.tangle.tools redirects back to the product's `returnUrl` with
|
|
22
|
+
* `?code=…&app=…&state=…`. The product calls `finish()` with the
|
|
23
|
+
* code; the helper POSTs /cross-site/exchange and returns the minted
|
|
24
|
+
* key + identity. `state` is verified by the caller against its own
|
|
25
|
+
* session (we never see it twice; CSRF is the caller's responsibility
|
|
26
|
+
* per the platform contract — see `cross-site.ts` line 148).
|
|
27
|
+
*
|
|
28
|
+
* 3. revoke({ apiKey }) → void
|
|
29
|
+
* Revoke the credential. Wraps `tangleIdentity().revokeSession`.
|
|
30
|
+
*
|
|
31
|
+
* Storage: this module is stateless. Persistence of the minted key (per
|
|
32
|
+
* user, per workspace) is the caller's job — it goes in whatever
|
|
33
|
+
* encrypted-credentials store the product already runs (sandbox uses Redis,
|
|
34
|
+
* gtm uses Postgres, blueprints uses CF KV). The recipe is identical to
|
|
35
|
+
* sandbox/api/src/lib/platform-client.ts — caller supplies a store, this
|
|
36
|
+
* module hands back the raw key once and never persists it.
|
|
37
|
+
*
|
|
38
|
+
* Why not invent a new wire protocol: tcloud + sandbox already speak this
|
|
39
|
+
* one against the live platform deployment. Diverging breaks the boundary
|
|
40
|
+
* we maintain at the directive level ("DO NOT invent the wire protocol —
|
|
41
|
+
* use what tcloud already does"). Every byte on the wire here matches a
|
|
42
|
+
* test in `products/platform/api/tests/cross-site.test.ts`.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
interface ConnectFlowOptions extends TangleIdentityOptions {
|
|
46
|
+
/** Base URL of id.tangle.tools (defaults to {@link DEFAULT_TANGLE_PLATFORM_URL}). */
|
|
47
|
+
baseUrl?: string;
|
|
48
|
+
}
|
|
49
|
+
interface StartConnectInput {
|
|
50
|
+
/** Trusted app id (registered on id.tangle.tools — `evals`, `sandbox`,
|
|
51
|
+
* `agent-builder`, `tax-agent`, `legal-agent`, …). */
|
|
52
|
+
appId: string;
|
|
53
|
+
/** Caller-generated CSRF nonce. The caller stashes it in its own
|
|
54
|
+
* session/cookie store; on the callback it MUST be compared against
|
|
55
|
+
* the `state` returned in the redirect. */
|
|
56
|
+
state: string;
|
|
57
|
+
/** Optional exact-match override of the registered callback URI. When
|
|
58
|
+
* omitted, the platform falls back to the app's first registered
|
|
59
|
+
* redirectUri. When provided, MUST equal one of the registered entries
|
|
60
|
+
* (origin + pathname) — otherwise the platform refuses the flow. */
|
|
61
|
+
redirectUri?: string;
|
|
62
|
+
}
|
|
63
|
+
interface StartConnectOutput {
|
|
64
|
+
/** The URL to redirect the user's browser to. */
|
|
65
|
+
authorizeUrl: string;
|
|
66
|
+
}
|
|
67
|
+
interface FinishConnectInput {
|
|
68
|
+
/** Auth code returned by id.tangle.tools on the callback redirect. */
|
|
69
|
+
code: string;
|
|
70
|
+
/** Same `appId` passed to `start()`. */
|
|
71
|
+
appId: string;
|
|
72
|
+
}
|
|
73
|
+
interface FinishConnectOutput {
|
|
74
|
+
/** Newly-minted `sk-tan-*` API key bound to the calling user. Returned
|
|
75
|
+
* ONCE — caller is responsible for stashing it in the product's
|
|
76
|
+
* encrypted credentials store. */
|
|
77
|
+
apiKey: string;
|
|
78
|
+
/** Identity hydrated from the exchange response. */
|
|
79
|
+
user: TangleUserSummary;
|
|
80
|
+
/** Initial balance the platform returns alongside the key. */
|
|
81
|
+
balance: number;
|
|
82
|
+
}
|
|
83
|
+
/** Initiate a cross-product connect flow. Returns the URL the product
|
|
84
|
+
* app should redirect the user's browser to. */
|
|
85
|
+
declare function startConnectFlow(opts: ConnectFlowOptions, input: StartConnectInput): StartConnectOutput;
|
|
86
|
+
/** Finish a cross-product connect flow. Calls /cross-site/exchange and
|
|
87
|
+
* returns the minted API key + hydrated user identity. */
|
|
88
|
+
declare function finishConnectFlow(opts: ConnectFlowOptions, input: FinishConnectInput): Promise<FinishConnectOutput>;
|
|
89
|
+
/** Revoke a minted API key. Idempotent — re-revoking a stale key is a no-op. */
|
|
90
|
+
declare function revokeConnectFlow(opts: ConnectFlowOptions, input: {
|
|
91
|
+
apiKey: string;
|
|
92
|
+
}): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Convenience: build a tiny session manager keyed by `state` for products
|
|
95
|
+
* that don't already have a CSRF store. NOT recommended for production —
|
|
96
|
+
* use your existing session cookie / signed-state mechanism. Exposed for
|
|
97
|
+
* tests and for quick prototyping. In-memory; not shared across workers.
|
|
98
|
+
*/
|
|
99
|
+
declare class InMemoryConnectStateStore {
|
|
100
|
+
private readonly entries;
|
|
101
|
+
put(state: string, value: {
|
|
102
|
+
appId: string;
|
|
103
|
+
ttlMs?: number;
|
|
104
|
+
}): void;
|
|
105
|
+
consume(state: string): {
|
|
106
|
+
appId: string;
|
|
107
|
+
} | undefined;
|
|
108
|
+
/** Test-only — drop pending state between unit-test runs. */
|
|
109
|
+
clear(): void;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export { type ConnectFlowOptions, type FinishConnectInput, type FinishConnectOutput, InMemoryConnectStateStore, type StartConnectInput, type StartConnectOutput, finishConnectFlow, revokeConnectFlow, startConnectFlow };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InMemoryConnectStateStore,
|
|
3
|
+
finishConnectFlow,
|
|
4
|
+
revokeConnectFlow,
|
|
5
|
+
startConnectFlow
|
|
6
|
+
} from "../chunk-P24T3MLM.js";
|
|
7
|
+
import "../chunk-ATYHZXLL.js";
|
|
8
|
+
export {
|
|
9
|
+
InMemoryConnectStateStore,
|
|
10
|
+
finishConnectFlow,
|
|
11
|
+
revokeConnectFlow,
|
|
12
|
+
startConnectFlow
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|