@tangle-network/agent-integrations 0.49.0 → 0.51.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.
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-P4FFI752.js.map
@@ -0,0 +1,109 @@
1
+ import {
2
+ CONNECTOR_ADAPTER_FACTORIES,
3
+ adapters_exports
4
+ } from "./chunk-XEJKVCXB.js";
5
+
6
+ // src/connectors/bundled-manifests.ts
7
+ var MANIFEST_PROBE_PREFIX = "tangle-adapter-metadata-";
8
+ function isConnectorAdapter(value) {
9
+ if (!value || typeof value !== "object") return false;
10
+ const manifest = value.manifest;
11
+ if (!manifest || typeof manifest !== "object") return false;
12
+ return typeof manifest.kind === "string";
13
+ }
14
+ function manifestFromFactory(definition) {
15
+ const probeOptions = Object.fromEntries(
16
+ Object.keys(definition.envMap).map((name) => [name, `${MANIFEST_PROBE_PREFIX}${name}`])
17
+ );
18
+ try {
19
+ return definition.factory(probeOptions).manifest;
20
+ } catch {
21
+ return void 0;
22
+ }
23
+ }
24
+ var cachedManifests;
25
+ var cachedByKind;
26
+ function buildRegistry() {
27
+ const byKind = /* @__PURE__ */ new Map();
28
+ for (const value of Object.values(adapters_exports)) {
29
+ if (isConnectorAdapter(value)) byKind.set(value.manifest.kind, value.manifest);
30
+ }
31
+ for (const definition of CONNECTOR_ADAPTER_FACTORIES) {
32
+ if (byKind.has(definition.kind)) continue;
33
+ const manifest = manifestFromFactory(definition);
34
+ if (manifest) byKind.set(manifest.kind, manifest);
35
+ }
36
+ return byKind;
37
+ }
38
+ function registry() {
39
+ if (!cachedByKind) cachedByKind = buildRegistry();
40
+ return cachedByKind;
41
+ }
42
+ function listBundledAdapterManifests() {
43
+ if (!cachedManifests) {
44
+ cachedManifests = [...registry().values()].sort((a, b) => a.kind.localeCompare(b.kind));
45
+ }
46
+ return cachedManifests;
47
+ }
48
+ function getBundledAdapterManifest(kind) {
49
+ return registry().get(kind);
50
+ }
51
+ function hasBundledAdapter(kind) {
52
+ return registry().has(kind);
53
+ }
54
+ function listBundledAdapterKinds() {
55
+ return listBundledAdapterManifests().map((manifest) => manifest.kind);
56
+ }
57
+ function bundledAuthMode(manifest) {
58
+ const auth = manifest.auth;
59
+ const effective = auth.kind === "one_of" ? auth.options.find((option) => option.kind === auth.preferred) ?? auth.options[0] : auth;
60
+ switch (effective.kind) {
61
+ case "oauth2":
62
+ return effective.grantType === "client_credentials" ? "oauth2_client_credentials" : "oauth2";
63
+ case "api-key":
64
+ return "api_key";
65
+ case "hmac":
66
+ return "hmac";
67
+ case "none":
68
+ return "none";
69
+ default:
70
+ return void 0;
71
+ }
72
+ }
73
+ function bundledApiKeyHint(manifest) {
74
+ const auth = manifest.auth;
75
+ const candidates = auth.kind === "one_of" ? auth.options : [auth];
76
+ for (const candidate of candidates) {
77
+ if (candidate.kind === "api-key") return candidate.hint;
78
+ }
79
+ return void 0;
80
+ }
81
+ function bundledOAuth2Auth(manifest) {
82
+ const auth = manifest.auth;
83
+ const candidates = auth.kind === "one_of" ? auth.options.filter((option) => option.kind === auth.preferred) : [auth];
84
+ for (const candidate of candidates) {
85
+ if (candidate.kind !== "oauth2") continue;
86
+ if (candidate.grantType === "client_credentials") continue;
87
+ if (!candidate.authorizationUrl) continue;
88
+ return {
89
+ authorizationUrl: candidate.authorizationUrl,
90
+ tokenUrl: candidate.tokenUrl,
91
+ scopes: candidate.scopes,
92
+ clientIdEnv: candidate.clientIdEnv,
93
+ clientSecretEnv: candidate.clientSecretEnv,
94
+ extraAuthParams: candidate.extraAuthParams
95
+ };
96
+ }
97
+ return void 0;
98
+ }
99
+
100
+ export {
101
+ listBundledAdapterManifests,
102
+ getBundledAdapterManifest,
103
+ hasBundledAdapter,
104
+ listBundledAdapterKinds,
105
+ bundledAuthMode,
106
+ bundledApiKeyHint,
107
+ bundledOAuth2Auth
108
+ };
109
+ //# sourceMappingURL=chunk-PUXYDSXI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/connectors/bundled-manifests.ts"],"sourcesContent":["import {\n CONNECTOR_ADAPTER_FACTORIES,\n type ConnectorAdapterFactoryDefinition,\n} from './adapters/factories.js'\nimport * as bundledAdapters from './adapters/index.js'\nimport type { ConnectorAdapter, ConnectorManifest } from './types.js'\n\n/**\n * The bundled adapter registry — the single source of truth for \"which\n * connectors does this package actually implement, and how do they really\n * authenticate\".\n *\n * This exists because the answer was previously maintained by hand in two\n * places that drifted apart: `specs/registry.ts` carried an 18-name\n * `EXECUTABLE_KINDS` set while the package shipped 530 adapters, and the\n * platform kept its own private `collectBundledAdapters()` copy. A catalog\n * that describes connectors must derive from the connectors, never restate\n * them — restating is what let QuickBooks and Xero advertise a\n * `https://example.invalid/...` authorization URL behind a live Connect\n * button.\n *\n * Manifests are static data. Factory-style adapters need client credentials\n * to *execute*, but their manifest (auth endpoints, scopes, capability list)\n * is fixed at definition time, so we instantiate them with clearly-marked\n * placeholder options purely to read that static shape. The placeholders are\n * never used to make a request — {@link listBundledAdapterManifests} returns\n * manifests, not adapters.\n */\n\n/** Placeholder marker for factory options resolved only to read a manifest. */\nconst MANIFEST_PROBE_PREFIX = 'tangle-adapter-metadata-'\n\nfunction isConnectorAdapter(value: unknown): value is ConnectorAdapter {\n if (!value || typeof value !== 'object') return false\n const manifest = (value as { manifest?: unknown }).manifest\n if (!manifest || typeof manifest !== 'object') return false\n return typeof (manifest as { kind?: unknown }).kind === 'string'\n}\n\nfunction manifestFromFactory(\n definition: ConnectorAdapterFactoryDefinition,\n): ConnectorManifest | undefined {\n const probeOptions = Object.fromEntries(\n Object.keys(definition.envMap).map((name) => [name, `${MANIFEST_PROBE_PREFIX}${name}`]),\n )\n try {\n return definition.factory(probeOptions).manifest\n } catch {\n // A factory that cannot be constructed from placeholder options cannot\n // contribute a manifest. Skipping is correct: it means the adapter is not\n // describable without real credentials, so the catalog must not claim it.\n return undefined\n }\n}\n\nlet cachedManifests: ConnectorManifest[] | undefined\nlet cachedByKind: Map<string, ConnectorManifest> | undefined\n\nfunction buildRegistry(): Map<string, ConnectorManifest> {\n const byKind = new Map<string, ConnectorManifest>()\n for (const value of Object.values(bundledAdapters)) {\n if (isConnectorAdapter(value)) byKind.set(value.manifest.kind, value.manifest)\n }\n for (const definition of CONNECTOR_ADAPTER_FACTORIES) {\n if (byKind.has(definition.kind)) continue\n const manifest = manifestFromFactory(definition)\n if (manifest) byKind.set(manifest.kind, manifest)\n }\n return byKind\n}\n\nfunction registry(): Map<string, ConnectorManifest> {\n if (!cachedByKind) cachedByKind = buildRegistry()\n return cachedByKind\n}\n\n/** Every connector manifest this package bundles, sorted by kind. */\nexport function listBundledAdapterManifests(): ConnectorManifest[] {\n if (!cachedManifests) {\n cachedManifests = [...registry().values()].sort((a, b) => a.kind.localeCompare(b.kind))\n }\n return cachedManifests\n}\n\n/** The bundled manifest for `kind`, or undefined when nothing implements it. */\nexport function getBundledAdapterManifest(kind: string): ConnectorManifest | undefined {\n return registry().get(kind)\n}\n\n/** Whether this package ships a real, executable adapter for `kind`. */\nexport function hasBundledAdapter(kind: string): boolean {\n return registry().has(kind)\n}\n\n/** Kinds this package implements. */\nexport function listBundledAdapterKinds(): string[] {\n return listBundledAdapterManifests().map((manifest) => manifest.kind)\n}\n\n/**\n * How a bundled connector really authenticates.\n *\n * `oauth2_client_credentials` is called out separately because it IS a\n * connectable mode but has no user-facing authorize step — a caller that\n * treats \"oauth2 without an authorizationUrl\" as broken would wrongly condemn\n * these machine-to-machine providers.\n */\nexport type BundledAuthMode =\n | 'oauth2'\n | 'oauth2_client_credentials'\n | 'api_key'\n | 'hmac'\n | 'none'\n\n/** The auth mode a connect flow would actually drive for this manifest,\n * resolving `one_of` through its declared `preferred` mode. */\nexport function bundledAuthMode(manifest: ConnectorManifest): BundledAuthMode | undefined {\n const auth = manifest.auth\n const effective =\n auth.kind === 'one_of'\n ? (auth.options.find((option) => option.kind === auth.preferred) ?? auth.options[0])\n : auth\n switch (effective.kind) {\n case 'oauth2':\n return effective.grantType === 'client_credentials' ? 'oauth2_client_credentials' : 'oauth2'\n case 'api-key':\n return 'api_key'\n case 'hmac':\n return 'hmac'\n case 'none':\n return 'none'\n default:\n return undefined\n }\n}\n\n/** The setup hint an api-key connector shows when collecting its credential. */\nexport function bundledApiKeyHint(manifest: ConnectorManifest): string | undefined {\n const auth = manifest.auth\n const candidates = auth.kind === 'one_of' ? auth.options : [auth]\n for (const candidate of candidates) {\n if (candidate.kind === 'api-key') return candidate.hint\n }\n return undefined\n}\n\n/** The authorization-code OAuth2 branch of a manifest's auth spec, if it has\n * one. `one_of` manifests are resolved through their `preferred` mode, which\n * is the mode a connect flow would actually drive. Returns undefined for\n * api-key/hmac/none connectors and for `client_credentials` OAuth (which has\n * no user-facing authorize step). */\nexport function bundledOAuth2Auth(manifest: ConnectorManifest):\n | {\n authorizationUrl: string\n tokenUrl: string\n scopes: string[]\n clientIdEnv: string\n clientSecretEnv: string\n extraAuthParams?: Record<string, string>\n }\n | undefined {\n const auth = manifest.auth\n const candidates =\n auth.kind === 'one_of'\n ? auth.options.filter((option) => option.kind === auth.preferred)\n : [auth]\n for (const candidate of candidates) {\n if (candidate.kind !== 'oauth2') continue\n if (candidate.grantType === 'client_credentials') continue\n if (!candidate.authorizationUrl) continue\n return {\n authorizationUrl: candidate.authorizationUrl,\n tokenUrl: candidate.tokenUrl,\n scopes: candidate.scopes,\n clientIdEnv: candidate.clientIdEnv,\n clientSecretEnv: candidate.clientSecretEnv,\n extraAuthParams: candidate.extraAuthParams,\n }\n }\n return undefined\n}\n"],"mappings":";;;;;;AA8BA,IAAM,wBAAwB;AAE9B,SAAS,mBAAmB,OAA2C;AACrE,MAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,QAAM,WAAY,MAAiC;AACnD,MAAI,CAAC,YAAY,OAAO,aAAa,SAAU,QAAO;AACtD,SAAO,OAAQ,SAAgC,SAAS;AAC1D;AAEA,SAAS,oBACP,YAC+B;AAC/B,QAAM,eAAe,OAAO;AA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