@revenexx/integrations-node-sdk 0.11.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/chunk-NJJ7FHGD.js +39 -0
- package/dist/chunk-NJJ7FHGD.js.map +1 -0
- package/dist/cli.cjs +124 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.js +72 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +351 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +467 -0
- package/dist/index.d.ts +467 -0
- package/dist/index.js +287 -0
- package/dist/index.js.map +1 -0
- package/package.json +33 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// src/extract.ts
|
|
2
|
+
function extractManifest(node) {
|
|
3
|
+
return node.description;
|
|
4
|
+
}
|
|
5
|
+
function extractManifests(nodes) {
|
|
6
|
+
return nodes.map(extractManifest);
|
|
7
|
+
}
|
|
8
|
+
function extractCredentialManifest(credential) {
|
|
9
|
+
return credential.description;
|
|
10
|
+
}
|
|
11
|
+
function extractCredentialManifests(credentials) {
|
|
12
|
+
return credentials.map(extractCredentialManifest);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// src/manifest.ts
|
|
16
|
+
var MANIFEST_VERSION = "v0-draft";
|
|
17
|
+
function buildManifest(nodes, credentials = [], templates = []) {
|
|
18
|
+
const manifest = {
|
|
19
|
+
manifestVersion: MANIFEST_VERSION,
|
|
20
|
+
nodes: extractManifests(nodes)
|
|
21
|
+
};
|
|
22
|
+
if (credentials.length > 0) {
|
|
23
|
+
manifest.credentials = extractCredentialManifests(credentials);
|
|
24
|
+
}
|
|
25
|
+
if (templates.length > 0) {
|
|
26
|
+
manifest.templates = templates;
|
|
27
|
+
}
|
|
28
|
+
return manifest;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
extractManifest,
|
|
33
|
+
extractManifests,
|
|
34
|
+
extractCredentialManifest,
|
|
35
|
+
extractCredentialManifests,
|
|
36
|
+
MANIFEST_VERSION,
|
|
37
|
+
buildManifest
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=chunk-NJJ7FHGD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/extract.ts","../src/manifest.ts"],"sourcesContent":["import type { ICredential, ICredentialDescription, INode, INodeDescription } from './types.js';\n\nexport function extractManifest(node: INode): INodeDescription {\n return node.description;\n}\n\nexport function extractManifests(nodes: INode[]): INodeDescription[] {\n return nodes.map(extractManifest);\n}\n\nexport function extractCredentialManifest(credential: ICredential): ICredentialDescription {\n return credential.description;\n}\n\nexport function extractCredentialManifests(credentials: ICredential[]): ICredentialDescription[] {\n return credentials.map(extractCredentialManifest);\n}\n","import { extractCredentialManifests, extractManifests } from './extract.js';\nimport type {\n ICredential,\n ICredentialDescription,\n INode,\n INodeDescription,\n ITemplateDescription,\n} from './types.js';\n\n/**\n * Envelope version expected by the integrations server-side\n * `TarballInspector`. Earlier (pre-registry) builds emitted a bare array\n * without any `manifestVersion` field; `v0-draft` is currently the only\n * accepted value (see `SchemaServiceProvider::DOMAIN_NODE` in the\n * integrations service). Keeping it versioned lets the registry evolve the\n * shape without breaking older publishers.\n */\nexport const MANIFEST_VERSION = 'v0-draft';\n\nexport interface NodeManifest {\n manifestVersion: typeof MANIFEST_VERSION;\n nodes: INodeDescription[];\n /**\n * Credential types this package publishes. Optional and additive: packages\n * that ship no credentials omit it (older publishers never set it).\n */\n credentials?: ICredentialDescription[];\n /**\n * Workflow templates this package publishes. Optional and additive: packages\n * that ship no templates omit it. Templates are plain data (no executable\n * code), so they are carried verbatim from the package's `TEMPLATES` export.\n */\n templates?: ITemplateDescription[];\n}\n\n/**\n * Builds the manifest envelope from a package's `NODES` (and optional\n * `CREDENTIALS` / `TEMPLATES`) exports. The result is what gets written to\n * `dist/manifest.json` and uploaded to the registry inside the tarball.\n */\nexport function buildManifest(\n nodes: INode[],\n credentials: ICredential[] = [],\n templates: ITemplateDescription[] = [],\n): NodeManifest {\n const manifest: NodeManifest = {\n manifestVersion: MANIFEST_VERSION,\n nodes: extractManifests(nodes),\n };\n if (credentials.length > 0) {\n manifest.credentials = extractCredentialManifests(credentials);\n }\n if (templates.length > 0) {\n manifest.templates = templates;\n }\n return manifest;\n}\n"],"mappings":";AAEO,SAAS,gBAAgB,MAA+B;AAC7D,SAAO,KAAK;AACd;AAEO,SAAS,iBAAiB,OAAoC;AACnE,SAAO,MAAM,IAAI,eAAe;AAClC;AAEO,SAAS,0BAA0B,YAAiD;AACzF,SAAO,WAAW;AACpB;AAEO,SAAS,2BAA2B,aAAsD;AAC/F,SAAO,YAAY,IAAI,yBAAyB;AAClD;;;ACCO,IAAM,mBAAmB;AAuBzB,SAAS,cACd,OACA,cAA6B,CAAC,GAC9B,YAAoC,CAAC,GACvB;AACd,QAAM,WAAyB;AAAA,IAC7B,iBAAiB;AAAA,IACjB,OAAO,iBAAiB,KAAK;AAAA,EAC/B;AACA,MAAI,YAAY,SAAS,GAAG;AAC1B,aAAS,cAAc,2BAA2B,WAAW;AAAA,EAC/D;AACA,MAAI,UAAU,SAAS,GAAG;AACxB,aAAS,YAAY;AAAA,EACvB;AACA,SAAO;AACT;","names":[]}
|
package/dist/cli.cjs
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
18
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
19
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
20
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
21
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
22
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
23
|
+
mod
|
|
24
|
+
));
|
|
25
|
+
|
|
26
|
+
// src/cli.ts
|
|
27
|
+
var fs = __toESM(require("fs"), 1);
|
|
28
|
+
var import_node_path = require("path");
|
|
29
|
+
var import_node_url = require("url");
|
|
30
|
+
|
|
31
|
+
// src/extract.ts
|
|
32
|
+
function extractManifest(node) {
|
|
33
|
+
return node.description;
|
|
34
|
+
}
|
|
35
|
+
function extractManifests(nodes) {
|
|
36
|
+
return nodes.map(extractManifest);
|
|
37
|
+
}
|
|
38
|
+
function extractCredentialManifest(credential) {
|
|
39
|
+
return credential.description;
|
|
40
|
+
}
|
|
41
|
+
function extractCredentialManifests(credentials) {
|
|
42
|
+
return credentials.map(extractCredentialManifest);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// src/manifest.ts
|
|
46
|
+
var MANIFEST_VERSION = "v0-draft";
|
|
47
|
+
function buildManifest(nodes, credentials = [], templates = []) {
|
|
48
|
+
const manifest = {
|
|
49
|
+
manifestVersion: MANIFEST_VERSION,
|
|
50
|
+
nodes: extractManifests(nodes)
|
|
51
|
+
};
|
|
52
|
+
if (credentials.length > 0) {
|
|
53
|
+
manifest.credentials = extractCredentialManifests(credentials);
|
|
54
|
+
}
|
|
55
|
+
if (templates.length > 0) {
|
|
56
|
+
manifest.templates = templates;
|
|
57
|
+
}
|
|
58
|
+
return manifest;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// src/cli.ts
|
|
62
|
+
var projectRoot = process.cwd();
|
|
63
|
+
function fail(message) {
|
|
64
|
+
console.error(`Error: ${message}`);
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
async function runManifest() {
|
|
68
|
+
const distEntry = (0, import_node_path.resolve)(projectRoot, "dist", "index.js");
|
|
69
|
+
if (!fs.existsSync(distEntry)) {
|
|
70
|
+
fail("dist/index.js is missing. Run the build (tsup) before `rvnxx-nodes manifest`.");
|
|
71
|
+
}
|
|
72
|
+
const mod = await import((0, import_node_url.pathToFileURL)(distEntry).href);
|
|
73
|
+
if (!Array.isArray(mod.NODES)) {
|
|
74
|
+
fail("dist/index.js does not export a `NODES` array. Export `NODES: INode[]` from your package entry.");
|
|
75
|
+
}
|
|
76
|
+
if (mod.CREDENTIALS !== void 0 && !Array.isArray(mod.CREDENTIALS)) {
|
|
77
|
+
fail("dist/index.js exports `CREDENTIALS` but it is not an array. Export `CREDENTIALS: ICredential[]`.");
|
|
78
|
+
}
|
|
79
|
+
if (mod.TEMPLATES !== void 0 && !Array.isArray(mod.TEMPLATES)) {
|
|
80
|
+
fail("dist/index.js exports `TEMPLATES` but it is not an array. Export `TEMPLATES: ITemplateDescription[]`.");
|
|
81
|
+
}
|
|
82
|
+
const credentials = mod.CREDENTIALS ?? [];
|
|
83
|
+
const templates = mod.TEMPLATES ?? [];
|
|
84
|
+
const manifest = buildManifest(mod.NODES, credentials, templates);
|
|
85
|
+
const outDir = (0, import_node_path.resolve)(projectRoot, "dist");
|
|
86
|
+
const outFile = (0, import_node_path.resolve)(outDir, "manifest.json");
|
|
87
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
88
|
+
fs.writeFileSync(outFile, JSON.stringify(manifest, null, 2), "utf-8");
|
|
89
|
+
const credentialCount = manifest.credentials?.length ?? 0;
|
|
90
|
+
const templateCount = manifest.templates?.length ?? 0;
|
|
91
|
+
console.log(
|
|
92
|
+
`\u2713 dist/manifest.json \u2014 ${manifest.nodes.length} node(s), ${credentialCount} credential(s), ${templateCount} template(s)`
|
|
93
|
+
);
|
|
94
|
+
for (const m of manifest.nodes) {
|
|
95
|
+
console.log(` node ${m.slug}@${m.version}`);
|
|
96
|
+
}
|
|
97
|
+
for (const c of manifest.credentials ?? []) {
|
|
98
|
+
console.log(` credential ${c.slug}@${c.version} (${c.authKind})`);
|
|
99
|
+
}
|
|
100
|
+
for (const t of manifest.templates ?? []) {
|
|
101
|
+
console.log(` template ${t.slug}@${t.version} (${t.level})`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async function main() {
|
|
105
|
+
const command = process.argv[2];
|
|
106
|
+
switch (command) {
|
|
107
|
+
case "manifest":
|
|
108
|
+
await runManifest();
|
|
109
|
+
break;
|
|
110
|
+
case "publish":
|
|
111
|
+
console.error(
|
|
112
|
+
"The `publish` command has been removed. Node packages are no longer published from the repos themselves \u2014 registration happens through the Revenexx Console/Cockpit. For local development, use `integrations/scripts/register-nodes-core.sh`, which packs and uploads the tarball to the admin API."
|
|
113
|
+
);
|
|
114
|
+
process.exit(1);
|
|
115
|
+
default:
|
|
116
|
+
console.error("Usage: rvnxx-nodes <manifest>");
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
main().catch((err) => {
|
|
121
|
+
console.error(err);
|
|
122
|
+
process.exit(1);
|
|
123
|
+
});
|
|
124
|
+
//# sourceMappingURL=cli.cjs.map
|
package/dist/cli.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../src/extract.ts","../src/manifest.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * `rvnxx-nodes` — shared tooling for Revenexx node packages.\n *\n * Subcommands:\n * rvnxx-nodes manifest Read the package's built `NODES` export and write\n * `dist/manifest.json`. Run after `tsup`.\n *\n * Everything operates on the current working directory (`process.cwd()`),\n * so the same binary works from any node package that depends on the SDK.\n *\n * Node packages are NOT published from the repos themselves — registration\n * happens through the Revenexx Console/Cockpit (and, for local development,\n * via `integrations/scripts/update-dev.sh`, which uploads the packed tarball\n * to the admin API). Hence there is no `publish` subcommand here.\n */\n\nimport * as fs from 'node:fs';\nimport { resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { buildManifest } from './manifest.js';\nimport type { ICredential, INode, ITemplateDescription } from './types.js';\n\nconst projectRoot = process.cwd();\n\nfunction fail(message: string): never {\n console.error(`Error: ${message}`);\n process.exit(1);\n}\n\n// --------------------------------------------------------------- manifest\n\nasync function runManifest(): Promise<void> {\n const distEntry = resolve(projectRoot, 'dist', 'index.js');\n if (!fs.existsSync(distEntry)) {\n fail('dist/index.js is missing. Run the build (tsup) before `rvnxx-nodes manifest`.');\n }\n\n const mod = (await import(pathToFileURL(distEntry).href)) as {\n NODES?: unknown;\n CREDENTIALS?: unknown;\n TEMPLATES?: unknown;\n };\n if (!Array.isArray(mod.NODES)) {\n fail('dist/index.js does not export a `NODES` array. Export `NODES: INode[]` from your package entry.');\n }\n if (mod.CREDENTIALS !== undefined && !Array.isArray(mod.CREDENTIALS)) {\n fail('dist/index.js exports `CREDENTIALS` but it is not an array. Export `CREDENTIALS: ICredential[]`.');\n }\n if (mod.TEMPLATES !== undefined && !Array.isArray(mod.TEMPLATES)) {\n fail('dist/index.js exports `TEMPLATES` but it is not an array. Export `TEMPLATES: ITemplateDescription[]`.');\n }\n\n const credentials = (mod.CREDENTIALS as ICredential[] | undefined) ?? [];\n const templates = (mod.TEMPLATES as ITemplateDescription[] | undefined) ?? [];\n const manifest = buildManifest(mod.NODES as INode[], credentials, templates);\n\n const outDir = resolve(projectRoot, 'dist');\n const outFile = resolve(outDir, 'manifest.json');\n fs.mkdirSync(outDir, { recursive: true });\n fs.writeFileSync(outFile, JSON.stringify(manifest, null, 2), 'utf-8');\n\n const credentialCount = manifest.credentials?.length ?? 0;\n const templateCount = manifest.templates?.length ?? 0;\n console.log(\n `✓ dist/manifest.json — ${manifest.nodes.length} node(s), ${credentialCount} credential(s), ${templateCount} template(s)`,\n );\n for (const m of manifest.nodes) {\n console.log(` node ${m.slug}@${m.version}`);\n }\n for (const c of manifest.credentials ?? []) {\n console.log(` credential ${c.slug}@${c.version} (${c.authKind})`);\n }\n for (const t of manifest.templates ?? []) {\n console.log(` template ${t.slug}@${t.version} (${t.level})`);\n }\n}\n\n// ------------------------------------------------------------------- main\n\nasync function main(): Promise<void> {\n const command = process.argv[2];\n switch (command) {\n case 'manifest':\n await runManifest();\n break;\n case 'publish':\n console.error(\n 'The `publish` command has been removed. Node packages are no longer ' +\n 'published from the repos themselves — registration happens through the ' +\n 'Revenexx Console/Cockpit. For local development, use ' +\n '`integrations/scripts/register-nodes-core.sh`, which packs and uploads ' +\n 'the tarball to the admin API.',\n );\n process.exit(1);\n default:\n console.error('Usage: rvnxx-nodes <manifest>');\n process.exit(1);\n }\n}\n\nmain().catch((err) => {\n console.error(err);\n process.exit(1);\n});\n","import type { ICredential, ICredentialDescription, INode, INodeDescription } from './types.js';\n\nexport function extractManifest(node: INode): INodeDescription {\n return node.description;\n}\n\nexport function extractManifests(nodes: INode[]): INodeDescription[] {\n return nodes.map(extractManifest);\n}\n\nexport function extractCredentialManifest(credential: ICredential): ICredentialDescription {\n return credential.description;\n}\n\nexport function extractCredentialManifests(credentials: ICredential[]): ICredentialDescription[] {\n return credentials.map(extractCredentialManifest);\n}\n","import { extractCredentialManifests, extractManifests } from './extract.js';\nimport type {\n ICredential,\n ICredentialDescription,\n INode,\n INodeDescription,\n ITemplateDescription,\n} from './types.js';\n\n/**\n * Envelope version expected by the integrations server-side\n * `TarballInspector`. Earlier (pre-registry) builds emitted a bare array\n * without any `manifestVersion` field; `v0-draft` is currently the only\n * accepted value (see `SchemaServiceProvider::DOMAIN_NODE` in the\n * integrations service). Keeping it versioned lets the registry evolve the\n * shape without breaking older publishers.\n */\nexport const MANIFEST_VERSION = 'v0-draft';\n\nexport interface NodeManifest {\n manifestVersion: typeof MANIFEST_VERSION;\n nodes: INodeDescription[];\n /**\n * Credential types this package publishes. Optional and additive: packages\n * that ship no credentials omit it (older publishers never set it).\n */\n credentials?: ICredentialDescription[];\n /**\n * Workflow templates this package publishes. Optional and additive: packages\n * that ship no templates omit it. Templates are plain data (no executable\n * code), so they are carried verbatim from the package's `TEMPLATES` export.\n */\n templates?: ITemplateDescription[];\n}\n\n/**\n * Builds the manifest envelope from a package's `NODES` (and optional\n * `CREDENTIALS` / `TEMPLATES`) exports. The result is what gets written to\n * `dist/manifest.json` and uploaded to the registry inside the tarball.\n */\nexport function buildManifest(\n nodes: INode[],\n credentials: ICredential[] = [],\n templates: ITemplateDescription[] = [],\n): NodeManifest {\n const manifest: NodeManifest = {\n manifestVersion: MANIFEST_VERSION,\n nodes: extractManifests(nodes),\n };\n if (credentials.length > 0) {\n manifest.credentials = extractCredentialManifests(credentials);\n }\n if (templates.length > 0) {\n manifest.templates = templates;\n }\n return manifest;\n}\n"],"mappings":"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","names":[]}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
buildManifest
|
|
4
|
+
} from "./chunk-NJJ7FHGD.js";
|
|
5
|
+
|
|
6
|
+
// src/cli.ts
|
|
7
|
+
import * as fs from "fs";
|
|
8
|
+
import { resolve } from "path";
|
|
9
|
+
import { pathToFileURL } from "url";
|
|
10
|
+
var projectRoot = process.cwd();
|
|
11
|
+
function fail(message) {
|
|
12
|
+
console.error(`Error: ${message}`);
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
async function runManifest() {
|
|
16
|
+
const distEntry = resolve(projectRoot, "dist", "index.js");
|
|
17
|
+
if (!fs.existsSync(distEntry)) {
|
|
18
|
+
fail("dist/index.js is missing. Run the build (tsup) before `rvnxx-nodes manifest`.");
|
|
19
|
+
}
|
|
20
|
+
const mod = await import(pathToFileURL(distEntry).href);
|
|
21
|
+
if (!Array.isArray(mod.NODES)) {
|
|
22
|
+
fail("dist/index.js does not export a `NODES` array. Export `NODES: INode[]` from your package entry.");
|
|
23
|
+
}
|
|
24
|
+
if (mod.CREDENTIALS !== void 0 && !Array.isArray(mod.CREDENTIALS)) {
|
|
25
|
+
fail("dist/index.js exports `CREDENTIALS` but it is not an array. Export `CREDENTIALS: ICredential[]`.");
|
|
26
|
+
}
|
|
27
|
+
if (mod.TEMPLATES !== void 0 && !Array.isArray(mod.TEMPLATES)) {
|
|
28
|
+
fail("dist/index.js exports `TEMPLATES` but it is not an array. Export `TEMPLATES: ITemplateDescription[]`.");
|
|
29
|
+
}
|
|
30
|
+
const credentials = mod.CREDENTIALS ?? [];
|
|
31
|
+
const templates = mod.TEMPLATES ?? [];
|
|
32
|
+
const manifest = buildManifest(mod.NODES, credentials, templates);
|
|
33
|
+
const outDir = resolve(projectRoot, "dist");
|
|
34
|
+
const outFile = resolve(outDir, "manifest.json");
|
|
35
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
36
|
+
fs.writeFileSync(outFile, JSON.stringify(manifest, null, 2), "utf-8");
|
|
37
|
+
const credentialCount = manifest.credentials?.length ?? 0;
|
|
38
|
+
const templateCount = manifest.templates?.length ?? 0;
|
|
39
|
+
console.log(
|
|
40
|
+
`\u2713 dist/manifest.json \u2014 ${manifest.nodes.length} node(s), ${credentialCount} credential(s), ${templateCount} template(s)`
|
|
41
|
+
);
|
|
42
|
+
for (const m of manifest.nodes) {
|
|
43
|
+
console.log(` node ${m.slug}@${m.version}`);
|
|
44
|
+
}
|
|
45
|
+
for (const c of manifest.credentials ?? []) {
|
|
46
|
+
console.log(` credential ${c.slug}@${c.version} (${c.authKind})`);
|
|
47
|
+
}
|
|
48
|
+
for (const t of manifest.templates ?? []) {
|
|
49
|
+
console.log(` template ${t.slug}@${t.version} (${t.level})`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async function main() {
|
|
53
|
+
const command = process.argv[2];
|
|
54
|
+
switch (command) {
|
|
55
|
+
case "manifest":
|
|
56
|
+
await runManifest();
|
|
57
|
+
break;
|
|
58
|
+
case "publish":
|
|
59
|
+
console.error(
|
|
60
|
+
"The `publish` command has been removed. Node packages are no longer published from the repos themselves \u2014 registration happens through the Revenexx Console/Cockpit. For local development, use `integrations/scripts/register-nodes-core.sh`, which packs and uploads the tarball to the admin API."
|
|
61
|
+
);
|
|
62
|
+
process.exit(1);
|
|
63
|
+
default:
|
|
64
|
+
console.error("Usage: rvnxx-nodes <manifest>");
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
main().catch((err) => {
|
|
69
|
+
console.error(err);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
});
|
|
72
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n/**\n * `rvnxx-nodes` — shared tooling for Revenexx node packages.\n *\n * Subcommands:\n * rvnxx-nodes manifest Read the package's built `NODES` export and write\n * `dist/manifest.json`. Run after `tsup`.\n *\n * Everything operates on the current working directory (`process.cwd()`),\n * so the same binary works from any node package that depends on the SDK.\n *\n * Node packages are NOT published from the repos themselves — registration\n * happens through the Revenexx Console/Cockpit (and, for local development,\n * via `integrations/scripts/update-dev.sh`, which uploads the packed tarball\n * to the admin API). Hence there is no `publish` subcommand here.\n */\n\nimport * as fs from 'node:fs';\nimport { resolve } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport { buildManifest } from './manifest.js';\nimport type { ICredential, INode, ITemplateDescription } from './types.js';\n\nconst projectRoot = process.cwd();\n\nfunction fail(message: string): never {\n console.error(`Error: ${message}`);\n process.exit(1);\n}\n\n// --------------------------------------------------------------- manifest\n\nasync function runManifest(): Promise<void> {\n const distEntry = resolve(projectRoot, 'dist', 'index.js');\n if (!fs.existsSync(distEntry)) {\n fail('dist/index.js is missing. Run the build (tsup) before `rvnxx-nodes manifest`.');\n }\n\n const mod = (await import(pathToFileURL(distEntry).href)) as {\n NODES?: unknown;\n CREDENTIALS?: unknown;\n TEMPLATES?: unknown;\n };\n if (!Array.isArray(mod.NODES)) {\n fail('dist/index.js does not export a `NODES` array. Export `NODES: INode[]` from your package entry.');\n }\n if (mod.CREDENTIALS !== undefined && !Array.isArray(mod.CREDENTIALS)) {\n fail('dist/index.js exports `CREDENTIALS` but it is not an array. Export `CREDENTIALS: ICredential[]`.');\n }\n if (mod.TEMPLATES !== undefined && !Array.isArray(mod.TEMPLATES)) {\n fail('dist/index.js exports `TEMPLATES` but it is not an array. Export `TEMPLATES: ITemplateDescription[]`.');\n }\n\n const credentials = (mod.CREDENTIALS as ICredential[] | undefined) ?? [];\n const templates = (mod.TEMPLATES as ITemplateDescription[] | undefined) ?? [];\n const manifest = buildManifest(mod.NODES as INode[], credentials, templates);\n\n const outDir = resolve(projectRoot, 'dist');\n const outFile = resolve(outDir, 'manifest.json');\n fs.mkdirSync(outDir, { recursive: true });\n fs.writeFileSync(outFile, JSON.stringify(manifest, null, 2), 'utf-8');\n\n const credentialCount = manifest.credentials?.length ?? 0;\n const templateCount = manifest.templates?.length ?? 0;\n console.log(\n `✓ dist/manifest.json — ${manifest.nodes.length} node(s), ${credentialCount} credential(s), ${templateCount} template(s)`,\n );\n for (const m of manifest.nodes) {\n console.log(` node ${m.slug}@${m.version}`);\n }\n for (const c of manifest.credentials ?? []) {\n console.log(` credential ${c.slug}@${c.version} (${c.authKind})`);\n }\n for (const t of manifest.templates ?? []) {\n console.log(` template ${t.slug}@${t.version} (${t.level})`);\n }\n}\n\n// ------------------------------------------------------------------- main\n\nasync function main(): Promise<void> {\n const command = process.argv[2];\n switch (command) {\n case 'manifest':\n await runManifest();\n break;\n case 'publish':\n console.error(\n 'The `publish` command has been removed. Node packages are no longer ' +\n 'published from the repos themselves — registration happens through the ' +\n 'Revenexx Console/Cockpit. For local development, use ' +\n '`integrations/scripts/register-nodes-core.sh`, which packs and uploads ' +\n 'the tarball to the admin API.',\n );\n process.exit(1);\n default:\n console.error('Usage: rvnxx-nodes <manifest>');\n process.exit(1);\n }\n}\n\nmain().catch((err) => {\n console.error(err);\n process.exit(1);\n});\n"],"mappings":";;;;;;AAiBA,YAAY,QAAQ;AACpB,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAI9B,IAAM,cAAc,QAAQ,IAAI;AAEhC,SAAS,KAAK,SAAwB;AACpC,UAAQ,MAAM,UAAU,OAAO,EAAE;AACjC,UAAQ,KAAK,CAAC;AAChB;AAIA,eAAe,cAA6B;AAC1C,QAAM,YAAY,QAAQ,aAAa,QAAQ,UAAU;AACzD,MAAI,CAAI,cAAW,SAAS,GAAG;AAC7B,SAAK,+EAA+E;AAAA,EACtF;AAEA,QAAM,MAAO,MAAM,OAAO,cAAc,SAAS,EAAE;AAKnD,MAAI,CAAC,MAAM,QAAQ,IAAI,KAAK,GAAG;AAC7B,SAAK,iGAAiG;AAAA,EACxG;AACA,MAAI,IAAI,gBAAgB,UAAa,CAAC,MAAM,QAAQ,IAAI,WAAW,GAAG;AACpE,SAAK,kGAAkG;AAAA,EACzG;AACA,MAAI,IAAI,cAAc,UAAa,CAAC,MAAM,QAAQ,IAAI,SAAS,GAAG;AAChE,SAAK,uGAAuG;AAAA,EAC9G;AAEA,QAAM,cAAe,IAAI,eAA6C,CAAC;AACvE,QAAM,YAAa,IAAI,aAAoD,CAAC;AAC5E,QAAM,WAAW,cAAc,IAAI,OAAkB,aAAa,SAAS;AAE3E,QAAM,SAAS,QAAQ,aAAa,MAAM;AAC1C,QAAM,UAAU,QAAQ,QAAQ,eAAe;AAC/C,EAAG,aAAU,QAAQ,EAAE,WAAW,KAAK,CAAC;AACxC,EAAG,iBAAc,SAAS,KAAK,UAAU,UAAU,MAAM,CAAC,GAAG,OAAO;AAEpE,QAAM,kBAAkB,SAAS,aAAa,UAAU;AACxD,QAAM,gBAAgB,SAAS,WAAW,UAAU;AACpD,UAAQ;AAAA,IACN,oCAA0B,SAAS,MAAM,MAAM,aAAa,eAAe,mBAAmB,aAAa;AAAA,EAC7G;AACA,aAAW,KAAK,SAAS,OAAO;AAC9B,YAAQ,IAAI,gBAAgB,EAAE,IAAI,IAAI,EAAE,OAAO,EAAE;AAAA,EACnD;AACA,aAAW,KAAK,SAAS,eAAe,CAAC,GAAG;AAC1C,YAAQ,IAAI,gBAAgB,EAAE,IAAI,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,GAAG;AAAA,EACnE;AACA,aAAW,KAAK,SAAS,aAAa,CAAC,GAAG;AACxC,YAAQ,IAAI,gBAAgB,EAAE,IAAI,IAAI,EAAE,OAAO,KAAK,EAAE,KAAK,GAAG;AAAA,EAChE;AACF;AAIA,eAAe,OAAsB;AACnC,QAAM,UAAU,QAAQ,KAAK,CAAC;AAC9B,UAAQ,SAAS;AAAA,IACf,KAAK;AACH,YAAM,YAAY;AAClB;AAAA,IACF,KAAK;AACH,cAAQ;AAAA,QACN;AAAA,MAKF;AACA,cAAQ,KAAK,CAAC;AAAA,IAChB;AACE,cAAQ,MAAM,+BAA+B;AAC7C,cAAQ,KAAK,CAAC;AAAA,EAClB;AACF;AAEA,KAAK,EAAE,MAAM,CAAC,QAAQ;AACpB,UAAQ,MAAM,GAAG;AACjB,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
ApiKeyCredential: () => ApiKeyCredential,
|
|
24
|
+
BaseCredential: () => BaseCredential,
|
|
25
|
+
BasicAuthCredential: () => BasicAuthCredential,
|
|
26
|
+
MANIFEST_VERSION: () => MANIFEST_VERSION,
|
|
27
|
+
NodeError: () => NodeError,
|
|
28
|
+
OAuth2AuthCodeCredential: () => OAuth2AuthCodeCredential,
|
|
29
|
+
OAuth2ClientCredentialsCredential: () => OAuth2ClientCredentialsCredential,
|
|
30
|
+
SimpleValueCredential: () => SimpleValueCredential,
|
|
31
|
+
buildManifest: () => buildManifest,
|
|
32
|
+
extractCredentialManifest: () => extractCredentialManifest,
|
|
33
|
+
extractCredentialManifests: () => extractCredentialManifests,
|
|
34
|
+
extractManifest: () => extractManifest,
|
|
35
|
+
extractManifests: () => extractManifests,
|
|
36
|
+
isNodeWithIteration: () => isNodeWithIteration,
|
|
37
|
+
isOAuthAuthorizeCredential: () => isOAuthAuthorizeCredential,
|
|
38
|
+
normalizeCredentialType: () => normalizeCredentialType,
|
|
39
|
+
normalizeLocalized: () => normalizeLocalized
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(index_exports);
|
|
42
|
+
|
|
43
|
+
// src/types.ts
|
|
44
|
+
function isNodeWithIteration(node) {
|
|
45
|
+
return typeof node.extractItems === "function";
|
|
46
|
+
}
|
|
47
|
+
function isOAuthAuthorizeCredential(credential) {
|
|
48
|
+
const candidate = credential;
|
|
49
|
+
return typeof candidate.buildAuthorizeUrl === "function" && typeof candidate.exchangeCode === "function";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// src/localized.ts
|
|
53
|
+
function normalizeLocalized(value, fallbackLang = "en") {
|
|
54
|
+
if (typeof value === "string") {
|
|
55
|
+
const trimmed = value.trim();
|
|
56
|
+
return trimmed === "" ? void 0 : trimmed;
|
|
57
|
+
}
|
|
58
|
+
if (value && typeof value === "object") {
|
|
59
|
+
const preferred = value[fallbackLang];
|
|
60
|
+
if (typeof preferred === "string" && preferred.trim() !== "") {
|
|
61
|
+
return preferred.trim();
|
|
62
|
+
}
|
|
63
|
+
for (const candidate of Object.values(value)) {
|
|
64
|
+
if (typeof candidate === "string" && candidate.trim() !== "") {
|
|
65
|
+
return candidate.trim();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return void 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// src/credentialType.ts
|
|
73
|
+
function normalizeCredentialType(value) {
|
|
74
|
+
const raw = value === void 0 ? [] : Array.isArray(value) ? value : [value];
|
|
75
|
+
const seen = /* @__PURE__ */ new Set();
|
|
76
|
+
for (const entry of raw) {
|
|
77
|
+
const trimmed = typeof entry === "string" ? entry.trim() : "";
|
|
78
|
+
if (trimmed !== "") {
|
|
79
|
+
seen.add(trimmed);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return [...seen];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// src/extract.ts
|
|
86
|
+
function extractManifest(node) {
|
|
87
|
+
return node.description;
|
|
88
|
+
}
|
|
89
|
+
function extractManifests(nodes) {
|
|
90
|
+
return nodes.map(extractManifest);
|
|
91
|
+
}
|
|
92
|
+
function extractCredentialManifest(credential) {
|
|
93
|
+
return credential.description;
|
|
94
|
+
}
|
|
95
|
+
function extractCredentialManifests(credentials) {
|
|
96
|
+
return credentials.map(extractCredentialManifest);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// src/manifest.ts
|
|
100
|
+
var MANIFEST_VERSION = "v0-draft";
|
|
101
|
+
function buildManifest(nodes, credentials = [], templates = []) {
|
|
102
|
+
const manifest = {
|
|
103
|
+
manifestVersion: MANIFEST_VERSION,
|
|
104
|
+
nodes: extractManifests(nodes)
|
|
105
|
+
};
|
|
106
|
+
if (credentials.length > 0) {
|
|
107
|
+
manifest.credentials = extractCredentialManifests(credentials);
|
|
108
|
+
}
|
|
109
|
+
if (templates.length > 0) {
|
|
110
|
+
manifest.templates = templates;
|
|
111
|
+
}
|
|
112
|
+
return manifest;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// src/credentials.ts
|
|
116
|
+
var import_node_crypto = require("crypto");
|
|
117
|
+
function readString(source, key) {
|
|
118
|
+
const value = source[key];
|
|
119
|
+
return typeof value === "string" ? value : void 0;
|
|
120
|
+
}
|
|
121
|
+
function requireString(source, key, what) {
|
|
122
|
+
const value = readString(source, key);
|
|
123
|
+
if (value === void 0 || value === "") {
|
|
124
|
+
throw new Error(`${what}: missing required value "${key}"`);
|
|
125
|
+
}
|
|
126
|
+
return value;
|
|
127
|
+
}
|
|
128
|
+
function expiryFromExpiresIn(expiresIn) {
|
|
129
|
+
const seconds = typeof expiresIn === "number" ? expiresIn : Number(expiresIn);
|
|
130
|
+
if (!Number.isFinite(seconds) || seconds <= 0) {
|
|
131
|
+
return void 0;
|
|
132
|
+
}
|
|
133
|
+
return new Date(Date.now() + seconds * 1e3).toISOString();
|
|
134
|
+
}
|
|
135
|
+
var BaseCredential = class {
|
|
136
|
+
async test(_ctx, config) {
|
|
137
|
+
for (const field of this.description.fields) {
|
|
138
|
+
if (field.required && (config[field.key] === void 0 || config[field.key] === "")) {
|
|
139
|
+
return { ok: false, message: `Missing required field "${field.key}"` };
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return { ok: true };
|
|
143
|
+
}
|
|
144
|
+
/** POST `application/x-www-form-urlencoded` and parse a JSON token response. */
|
|
145
|
+
async postForm(ctx, url, form, headers = {}) {
|
|
146
|
+
const body = new URLSearchParams();
|
|
147
|
+
for (const [key, value] of Object.entries(form)) {
|
|
148
|
+
if (value !== void 0) {
|
|
149
|
+
body.set(key, value);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
const res = await fetch(url, {
|
|
153
|
+
method: "POST",
|
|
154
|
+
signal: ctx.signal,
|
|
155
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded", Accept: "application/json", ...headers },
|
|
156
|
+
body
|
|
157
|
+
});
|
|
158
|
+
const text = await res.text();
|
|
159
|
+
if (!res.ok) {
|
|
160
|
+
throw new Error(`token endpoint ${url} -> ${res.status}${formatOAuthError(text)}`);
|
|
161
|
+
}
|
|
162
|
+
try {
|
|
163
|
+
return JSON.parse(text);
|
|
164
|
+
} catch {
|
|
165
|
+
throw new Error(`token endpoint ${url} returned non-JSON body`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
function formatOAuthError(body) {
|
|
170
|
+
try {
|
|
171
|
+
const parsed = JSON.parse(body);
|
|
172
|
+
const error = typeof parsed.error === "string" ? parsed.error : void 0;
|
|
173
|
+
if (!error) {
|
|
174
|
+
return "";
|
|
175
|
+
}
|
|
176
|
+
const description = typeof parsed.error_description === "string" ? parsed.error_description : void 0;
|
|
177
|
+
return `: ${error}${description ? ` (${description})` : ""}`;
|
|
178
|
+
} catch {
|
|
179
|
+
return "";
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
var SimpleValueCredential = class extends BaseCredential {
|
|
183
|
+
async resolve(_ctx, config, _durableCreds) {
|
|
184
|
+
return { credentials: { ...config } };
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
var ApiKeyCredential = class extends BaseCredential {
|
|
188
|
+
apiKeyField() {
|
|
189
|
+
return "apiKey";
|
|
190
|
+
}
|
|
191
|
+
credentialShape(apiKey) {
|
|
192
|
+
return { apiKey };
|
|
193
|
+
}
|
|
194
|
+
async resolve(_ctx, config, _durableCreds) {
|
|
195
|
+
const apiKey = requireString(config, this.apiKeyField(), this.description.slug);
|
|
196
|
+
return { credentials: this.credentialShape(apiKey) };
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
var BasicAuthCredential = class extends BaseCredential {
|
|
200
|
+
usernameField() {
|
|
201
|
+
return "username";
|
|
202
|
+
}
|
|
203
|
+
passwordField() {
|
|
204
|
+
return "password";
|
|
205
|
+
}
|
|
206
|
+
async resolve(_ctx, config, _durableCreds) {
|
|
207
|
+
const username = requireString(config, this.usernameField(), this.description.slug);
|
|
208
|
+
const password = requireString(config, this.passwordField(), this.description.slug);
|
|
209
|
+
return { credentials: { username, password } };
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
var OAuth2ClientCredentialsCredential = class extends BaseCredential {
|
|
213
|
+
scope(_config) {
|
|
214
|
+
return void 0;
|
|
215
|
+
}
|
|
216
|
+
/** Map the raw token response to the node-facing credentials. */
|
|
217
|
+
credentialShape(token) {
|
|
218
|
+
return { accessToken: token.access_token, tokenType: token.token_type ?? "Bearer" };
|
|
219
|
+
}
|
|
220
|
+
async resolve(ctx, config, _durableCreds) {
|
|
221
|
+
const token = await this.postForm(ctx, this.tokenUrl(config), {
|
|
222
|
+
grant_type: "client_credentials",
|
|
223
|
+
client_id: this.clientId(config),
|
|
224
|
+
client_secret: this.clientSecret(config),
|
|
225
|
+
scope: this.scope(config)
|
|
226
|
+
});
|
|
227
|
+
if (!token.access_token) {
|
|
228
|
+
throw new Error(`${this.description.slug}: token endpoint returned no access_token`);
|
|
229
|
+
}
|
|
230
|
+
return { credentials: this.credentialShape(token), expiresAt: expiryFromExpiresIn(token.expires_in) };
|
|
231
|
+
}
|
|
232
|
+
async test(ctx, config) {
|
|
233
|
+
try {
|
|
234
|
+
await this.resolve(ctx, config, null);
|
|
235
|
+
return { ok: true };
|
|
236
|
+
} catch (err) {
|
|
237
|
+
return { ok: false, message: err instanceof Error ? err.message : String(err) };
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
var OAuth2AuthCodeCredential = class extends BaseCredential {
|
|
242
|
+
scope(_config) {
|
|
243
|
+
return void 0;
|
|
244
|
+
}
|
|
245
|
+
usePkce() {
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
credentialShape(token) {
|
|
249
|
+
return { accessToken: token.access_token, tokenType: token.token_type ?? "Bearer" };
|
|
250
|
+
}
|
|
251
|
+
async buildAuthorizeUrl(_ctx, config, params) {
|
|
252
|
+
const url = new URL(this.authorizeUrl(config));
|
|
253
|
+
url.searchParams.set("response_type", "code");
|
|
254
|
+
url.searchParams.set("client_id", this.clientId(config));
|
|
255
|
+
url.searchParams.set("redirect_uri", params.redirectUri);
|
|
256
|
+
url.searchParams.set("state", params.state);
|
|
257
|
+
const scope = this.scope(config);
|
|
258
|
+
if (scope) {
|
|
259
|
+
url.searchParams.set("scope", scope);
|
|
260
|
+
}
|
|
261
|
+
let codeVerifier;
|
|
262
|
+
if (this.usePkce()) {
|
|
263
|
+
codeVerifier = base64Url((0, import_node_crypto.randomBytes)(32));
|
|
264
|
+
const challenge = base64Url((0, import_node_crypto.createHash)("sha256").update(codeVerifier).digest());
|
|
265
|
+
url.searchParams.set("code_challenge", challenge);
|
|
266
|
+
url.searchParams.set("code_challenge_method", "S256");
|
|
267
|
+
}
|
|
268
|
+
return { authorizeUrl: url.toString(), codeVerifier };
|
|
269
|
+
}
|
|
270
|
+
async exchangeCode(ctx, config, params) {
|
|
271
|
+
const token = await this.postForm(ctx, this.tokenUrl(config), {
|
|
272
|
+
grant_type: "authorization_code",
|
|
273
|
+
code: params.code,
|
|
274
|
+
redirect_uri: params.redirectUri,
|
|
275
|
+
client_id: this.clientId(config),
|
|
276
|
+
client_secret: this.clientSecret(config),
|
|
277
|
+
code_verifier: params.codeVerifier
|
|
278
|
+
});
|
|
279
|
+
if (!token.refresh_token) {
|
|
280
|
+
throw new Error(`${this.description.slug}: authorization_code exchange returned no refresh_token`);
|
|
281
|
+
}
|
|
282
|
+
return { durableCreds: { refreshToken: token.refresh_token } };
|
|
283
|
+
}
|
|
284
|
+
async resolve(ctx, config, durableCreds) {
|
|
285
|
+
const refreshToken = durableCreds ? readString(durableCreds, "refreshToken") : void 0;
|
|
286
|
+
if (!refreshToken) {
|
|
287
|
+
throw new Error(`${this.description.slug}: not authorized \u2014 no refresh_token (needs_reauth)`);
|
|
288
|
+
}
|
|
289
|
+
const token = await this.postForm(ctx, this.tokenUrl(config), {
|
|
290
|
+
grant_type: "refresh_token",
|
|
291
|
+
refresh_token: refreshToken,
|
|
292
|
+
client_id: this.clientId(config),
|
|
293
|
+
client_secret: this.clientSecret(config),
|
|
294
|
+
scope: this.scope(config)
|
|
295
|
+
});
|
|
296
|
+
if (!token.access_token) {
|
|
297
|
+
throw new Error(`${this.description.slug}: refresh returned no access_token`);
|
|
298
|
+
}
|
|
299
|
+
if (token.refresh_token && token.refresh_token !== refreshToken && ctx.persistDurableCreds) {
|
|
300
|
+
await ctx.persistDurableCreds({ refreshToken: token.refresh_token });
|
|
301
|
+
}
|
|
302
|
+
return { credentials: this.credentialShape(token), expiresAt: expiryFromExpiresIn(token.expires_in) };
|
|
303
|
+
}
|
|
304
|
+
async test(_ctx, config) {
|
|
305
|
+
try {
|
|
306
|
+
new URL(this.authorizeUrl(config));
|
|
307
|
+
new URL(this.tokenUrl(config));
|
|
308
|
+
this.clientId(config);
|
|
309
|
+
this.clientSecret(config);
|
|
310
|
+
return { ok: true, message: "Configuration valid \u2014 complete the OAuth consent to finish setup." };
|
|
311
|
+
} catch (err) {
|
|
312
|
+
return { ok: false, message: err instanceof Error ? err.message : String(err) };
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
function base64Url(buf) {
|
|
317
|
+
return buf.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// src/errors.ts
|
|
321
|
+
var NodeError = class extends Error {
|
|
322
|
+
code;
|
|
323
|
+
meta;
|
|
324
|
+
constructor(code, message, meta) {
|
|
325
|
+
super(message);
|
|
326
|
+
this.name = "NodeError";
|
|
327
|
+
this.code = code;
|
|
328
|
+
this.meta = meta;
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
332
|
+
0 && (module.exports = {
|
|
333
|
+
ApiKeyCredential,
|
|
334
|
+
BaseCredential,
|
|
335
|
+
BasicAuthCredential,
|
|
336
|
+
MANIFEST_VERSION,
|
|
337
|
+
NodeError,
|
|
338
|
+
OAuth2AuthCodeCredential,
|
|
339
|
+
OAuth2ClientCredentialsCredential,
|
|
340
|
+
SimpleValueCredential,
|
|
341
|
+
buildManifest,
|
|
342
|
+
extractCredentialManifest,
|
|
343
|
+
extractCredentialManifests,
|
|
344
|
+
extractManifest,
|
|
345
|
+
extractManifests,
|
|
346
|
+
isNodeWithIteration,
|
|
347
|
+
isOAuthAuthorizeCredential,
|
|
348
|
+
normalizeCredentialType,
|
|
349
|
+
normalizeLocalized
|
|
350
|
+
});
|
|
351
|
+
//# sourceMappingURL=index.cjs.map
|