@embassys/ambassador 0.0.0 → 0.2.6

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.
Files changed (85) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +68 -2
  3. package/dist/agent-capabilities.d.ts +35 -0
  4. package/dist/agent-capabilities.js +221 -0
  5. package/dist/agent-capabilities.js.map +1 -0
  6. package/dist/ambassador-options.d.ts +9 -0
  7. package/dist/ambassador-options.js +31 -0
  8. package/dist/ambassador-options.js.map +1 -0
  9. package/dist/central-credential.d.ts +41 -0
  10. package/dist/central-credential.js +355 -0
  11. package/dist/central-credential.js.map +1 -0
  12. package/dist/central-enrollment.d.ts +31 -0
  13. package/dist/central-enrollment.js +278 -0
  14. package/dist/central-enrollment.js.map +1 -0
  15. package/dist/central-json.d.ts +8 -0
  16. package/dist/central-json.js +259 -0
  17. package/dist/central-json.js.map +1 -0
  18. package/dist/central-protected-transport.d.ts +21 -0
  19. package/dist/central-protected-transport.js +217 -0
  20. package/dist/central-protected-transport.js.map +1 -0
  21. package/dist/central-rest.d.ts +50 -0
  22. package/dist/central-rest.js +401 -0
  23. package/dist/central-rest.js.map +1 -0
  24. package/dist/cli.d.ts +26 -0
  25. package/dist/cli.js +131 -0
  26. package/dist/cli.js.map +1 -0
  27. package/dist/credential-store.d.ts +18 -0
  28. package/dist/credential-store.js +517 -0
  29. package/dist/credential-store.js.map +1 -0
  30. package/dist/delivery-profile.d.ts +43 -0
  31. package/dist/delivery-profile.js +253 -0
  32. package/dist/delivery-profile.js.map +1 -0
  33. package/dist/direct-delivery.d.ts +38 -0
  34. package/dist/direct-delivery.js +315 -0
  35. package/dist/direct-delivery.js.map +1 -0
  36. package/dist/dpop.d.ts +28 -0
  37. package/dist/dpop.js +119 -0
  38. package/dist/dpop.js.map +1 -0
  39. package/dist/errors.d.ts +5 -0
  40. package/dist/errors.js +11 -0
  41. package/dist/errors.js.map +1 -0
  42. package/dist/gateway-application.d.ts +32 -0
  43. package/dist/gateway-application.js +256 -0
  44. package/dist/gateway-application.js.map +1 -0
  45. package/dist/gateway-paths.d.ts +10 -0
  46. package/dist/gateway-paths.js +28 -0
  47. package/dist/gateway-paths.js.map +1 -0
  48. package/dist/guided-registration.d.ts +23 -0
  49. package/dist/guided-registration.js +117 -0
  50. package/dist/guided-registration.js.map +1 -0
  51. package/dist/identity.d.ts +20 -0
  52. package/dist/identity.js +54 -0
  53. package/dist/identity.js.map +1 -0
  54. package/dist/local-mcp.d.ts +28 -0
  55. package/dist/local-mcp.js +420 -0
  56. package/dist/local-mcp.js.map +1 -0
  57. package/dist/local-tool-result.d.ts +4 -0
  58. package/dist/local-tool-result.js +17 -0
  59. package/dist/local-tool-result.js.map +1 -0
  60. package/dist/mcp-contract.d.ts +10 -0
  61. package/dist/mcp-contract.js +63 -0
  62. package/dist/mcp-contract.js.map +1 -0
  63. package/dist/notification-journal.d.ts +24 -0
  64. package/dist/notification-journal.js +194 -0
  65. package/dist/notification-journal.js.map +1 -0
  66. package/dist/notification-relay.d.ts +31 -0
  67. package/dist/notification-relay.js +203 -0
  68. package/dist/notification-relay.js.map +1 -0
  69. package/dist/process-lock.d.ts +8 -0
  70. package/dist/process-lock.js +122 -0
  71. package/dist/process-lock.js.map +1 -0
  72. package/dist/sqlite-artifact.d.ts +7 -0
  73. package/dist/sqlite-artifact.js +121 -0
  74. package/dist/sqlite-artifact.js.map +1 -0
  75. package/dist/webhook-delivery.d.ts +23 -0
  76. package/dist/webhook-delivery.js +122 -0
  77. package/dist/webhook-delivery.js.map +1 -0
  78. package/docs/getting-started-claude.md +94 -0
  79. package/docs/getting-started-codex.md +103 -0
  80. package/docs/getting-started-gemini.md +87 -0
  81. package/docs/getting-started-hermes.md +84 -0
  82. package/docs/getting-started-openclaw.md +83 -0
  83. package/docs/live-qualification.md +174 -0
  84. package/package.json +48 -7
  85. package/index.js +0 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 a2adev contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,4 +1,70 @@
1
1
  # Embassys Ambassador
2
2
 
3
- This `0.0.0` package is an inert placeholder used to configure npm trusted
4
- publishing. Install a later release to use Embassys Ambassador.
3
+ Embassys Ambassador is a local bridge between an agent and the Embassys REST
4
+ service. It exposes authenticated MCP tools to the agent and delivers incoming
5
+ messages either to a webhook or directly to a local agent over ACP v1.
6
+
7
+ The accepted package and command are:
8
+
9
+ ```text
10
+ @embassys/ambassador
11
+ ambassador start --local-token-env=<environment-variable>
12
+ ```
13
+
14
+ Delivery is resolved through the MCP registration flow and a fixed capability
15
+ registry. OpenClaw, Hermes, Codex, Claude Code, and Gemini CLI support both
16
+ modes, so Ambassador asks their users to choose direct or webhook and presents
17
+ direct as the default. Codex uses the existing
18
+ `@agentclientprotocol/codex-acp` adapter, Claude Code uses
19
+ `@agentclientprotocol/claude-agent-acp`, and Gemini CLI uses native ACP. A known
20
+ direct-only profile would proceed without a delivery question. Unknown or
21
+ incomplete profiles are rejected; the model cannot select an agent, command,
22
+ or adapter. Webhook mode sends the complete message to a user-approved URL.
23
+ Direct mode starts a gateway-managed ACP agent session. There is no agent
24
+ selector or webhook URL on `start`.
25
+
26
+ The central integration uses the unversioned REST API at
27
+ `https://mcp.embassys.ai`. Verification binds the central token to an
28
+ Ambassador-owned P-256 key. Protected requests use Bearer authorization plus a
29
+ separate DPoP proof. Ambassador does not use the central MCP endpoint.
30
+
31
+ ## Implementation status
32
+
33
+ The REST and DPoP integration and deterministic Ambassador delivery cutover
34
+ are implemented. The live-central qualification with real Codex passed. The
35
+ user approved publication of `@embassys/ambassador@0.2.6` before the remaining
36
+ real-agent matrix is complete. That one-release exception is recorded in
37
+ [ADR 0015](docs/adr/0015-npm-distribution.md); the outstanding qualification
38
+ work remains visible in the [implementation plan](docs/implementation-plan.md).
39
+
40
+ ## Development
41
+
42
+ Use Node.js 24 and the pnpm version recorded in `package.json`.
43
+
44
+ ```text
45
+ pnpm install --frozen-lockfile
46
+ pnpm check
47
+ ```
48
+
49
+ CI uses a mock webhook receiver and mock ACP v1 agent for deterministic
50
+ delivery tests. Opt-in local qualification covers all five supported agents in
51
+ both delivery modes.
52
+
53
+ ## Documentation
54
+
55
+ - [Documentation map](docs/README.md)
56
+ - [Product and architecture](docs/product-vision-and-architecture.md)
57
+ - [Target protocol](docs/protocol.md)
58
+ - [Current work](docs/implementation-plan.md)
59
+ - [Architecture decisions](docs/adr/README.md)
60
+ - [Qualification strategy](docs/qualification.md)
61
+ - [Codex setup](docs/getting-started-codex.md)
62
+ - [Claude Code setup](docs/getting-started-claude.md)
63
+ - [Gemini CLI setup](docs/getting-started-gemini.md)
64
+ - [Hermes setup](docs/getting-started-hermes.md)
65
+ - [OpenClaw setup](docs/getting-started-openclaw.md)
66
+ - [Central service follow-ups](docs/central-follow-ups.md)
67
+
68
+ ## License
69
+
70
+ MIT
@@ -0,0 +1,35 @@
1
+ export type DeliveryMode = "direct" | "webhook";
2
+ export type McpConfigurationBehavior = "provider_config" | "session";
3
+ export interface AgentClientInfo {
4
+ readonly name: string;
5
+ readonly version: string;
6
+ }
7
+ export interface DirectAgentCapability {
8
+ readonly command: string;
9
+ readonly args: readonly string[];
10
+ readonly agentInfo: {
11
+ readonly name: string;
12
+ readonly versions: readonly string[];
13
+ };
14
+ readonly mcp: McpConfigurationBehavior;
15
+ readonly environment: readonly string[];
16
+ }
17
+ export interface AgentCapability {
18
+ readonly kind: string;
19
+ readonly displayName: string;
20
+ readonly enabled: boolean;
21
+ readonly aliases: readonly AgentClientInfo[];
22
+ readonly modes: readonly DeliveryMode[];
23
+ readonly direct?: DirectAgentCapability;
24
+ readonly qualificationCases: readonly string[];
25
+ }
26
+ export type AgentCapabilityResolution = {
27
+ readonly status: "matched";
28
+ readonly profile: AgentCapability;
29
+ } | {
30
+ readonly status: "unsupported";
31
+ };
32
+ export declare const PRODUCTION_AGENT_CAPABILITIES: readonly AgentCapability[];
33
+ export declare function isCompleteAgentCapability(value: AgentCapability): boolean;
34
+ export declare function resolveAgentCapability(clientInfo: AgentClientInfo | undefined, registry?: readonly AgentCapability[]): AgentCapabilityResolution;
35
+ export declare function capabilityForKind(kind: string, registry?: readonly AgentCapability[]): AgentCapability | undefined;
@@ -0,0 +1,221 @@
1
+ const BOUNDED_METADATA = /^[\x20-\x7e]{1,128}$/u;
2
+ const KIND = /^[a-z][a-z0-9-]{0,63}$/u;
3
+ const ENVIRONMENT_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/u;
4
+ export const PRODUCTION_AGENT_CAPABILITIES = [
5
+ {
6
+ kind: "openclaw",
7
+ displayName: "OpenClaw",
8
+ enabled: true,
9
+ aliases: [{ name: "openclaw-bundle-mcp", version: "0.0.0" }],
10
+ modes: ["direct", "webhook"],
11
+ direct: {
12
+ command: "openclaw",
13
+ args: ["acp"],
14
+ agentInfo: { name: "openclaw-acp", versions: ["2026.8.1"] },
15
+ mcp: "provider_config",
16
+ environment: [
17
+ "HOME",
18
+ "LANG",
19
+ "LC_ALL",
20
+ "NODE_EXTRA_CA_CERTS",
21
+ "PATH",
22
+ "SSL_CERT_DIR",
23
+ "SSL_CERT_FILE",
24
+ "TMPDIR",
25
+ "USERPROFILE",
26
+ "XDG_CONFIG_HOME",
27
+ "XDG_DATA_HOME",
28
+ "XDG_STATE_HOME",
29
+ ],
30
+ },
31
+ qualificationCases: ["openclaw-webhook", "openclaw-direct"],
32
+ },
33
+ {
34
+ kind: "hermes",
35
+ displayName: "Hermes",
36
+ enabled: true,
37
+ aliases: [{ name: "mcp", version: "0.1.0" }],
38
+ modes: ["direct", "webhook"],
39
+ direct: {
40
+ command: "hermes-acp",
41
+ args: [],
42
+ agentInfo: { name: "hermes-agent", versions: ["0.21.0"] },
43
+ mcp: "session",
44
+ environment: [
45
+ "HOME",
46
+ "LANG",
47
+ "LC_ALL",
48
+ "PATH",
49
+ "SSL_CERT_DIR",
50
+ "SSL_CERT_FILE",
51
+ "TMPDIR",
52
+ "USERPROFILE",
53
+ "XDG_CACHE_HOME",
54
+ "XDG_CONFIG_HOME",
55
+ "XDG_DATA_HOME",
56
+ "XDG_STATE_HOME",
57
+ ],
58
+ },
59
+ qualificationCases: ["hermes-webhook", "hermes-direct"],
60
+ },
61
+ {
62
+ kind: "codex",
63
+ displayName: "Codex",
64
+ enabled: true,
65
+ aliases: [
66
+ { name: "codex-mcp-client", version: "0.149.0" },
67
+ { name: "codex-mcp-client", version: "0.152.1" },
68
+ ],
69
+ modes: ["direct", "webhook"],
70
+ direct: {
71
+ command: "codex-acp",
72
+ args: [],
73
+ agentInfo: { name: "@agentclientprotocol/codex-acp", versions: ["1.8.0"] },
74
+ mcp: "session",
75
+ environment: [
76
+ "CODEX_API_KEY",
77
+ "HOME",
78
+ "LANG",
79
+ "LC_ALL",
80
+ "NODE_EXTRA_CA_CERTS",
81
+ "OPENAI_API_KEY",
82
+ "PATH",
83
+ "SSL_CERT_DIR",
84
+ "SSL_CERT_FILE",
85
+ "TMPDIR",
86
+ "USERPROFILE",
87
+ "XDG_CONFIG_HOME",
88
+ "XDG_DATA_HOME",
89
+ "XDG_RUNTIME_DIR",
90
+ "XDG_STATE_HOME",
91
+ ],
92
+ },
93
+ qualificationCases: ["codex-webhook", "codex-direct"],
94
+ },
95
+ {
96
+ kind: "claude",
97
+ displayName: "Claude Code",
98
+ enabled: true,
99
+ aliases: [
100
+ { name: "claude-code", version: "2.1.257" },
101
+ { name: "claude-code", version: "2.1.258" },
102
+ ],
103
+ modes: ["direct", "webhook"],
104
+ direct: {
105
+ command: "claude-agent-acp",
106
+ args: [],
107
+ agentInfo: { name: "@agentclientprotocol/claude-agent-acp", versions: ["0.73.0"] },
108
+ mcp: "session",
109
+ environment: [
110
+ "ANTHROPIC_API_KEY",
111
+ "ANTHROPIC_AUTH_TOKEN",
112
+ "CLAUDE_CODE_OAUTH_TOKEN",
113
+ "HOME",
114
+ "LANG",
115
+ "LC_ALL",
116
+ "NODE_EXTRA_CA_CERTS",
117
+ "PATH",
118
+ "SSL_CERT_DIR",
119
+ "SSL_CERT_FILE",
120
+ "TMPDIR",
121
+ "USERPROFILE",
122
+ "XDG_CONFIG_HOME",
123
+ "XDG_DATA_HOME",
124
+ "XDG_STATE_HOME",
125
+ ],
126
+ },
127
+ qualificationCases: ["claude-webhook", "claude-direct"],
128
+ },
129
+ {
130
+ kind: "gemini",
131
+ displayName: "Gemini CLI",
132
+ enabled: true,
133
+ aliases: [{ name: "gemini-cli-mcp-client", version: "0.58.0" }],
134
+ modes: ["direct", "webhook"],
135
+ direct: {
136
+ command: "gemini",
137
+ args: ["--acp"],
138
+ agentInfo: { name: "gemini-cli", versions: ["0.58.0"] },
139
+ mcp: "session",
140
+ environment: [
141
+ "GEMINI_API_KEY",
142
+ "GOOGLE_API_KEY",
143
+ "GOOGLE_CLOUD_LOCATION",
144
+ "GOOGLE_CLOUD_PROJECT",
145
+ "GOOGLE_GENAI_USE_VERTEXAI",
146
+ "HOME",
147
+ "LANG",
148
+ "LC_ALL",
149
+ "NODE_EXTRA_CA_CERTS",
150
+ "PATH",
151
+ "SSL_CERT_DIR",
152
+ "SSL_CERT_FILE",
153
+ "TMPDIR",
154
+ "USERPROFILE",
155
+ "XDG_CONFIG_HOME",
156
+ "XDG_DATA_HOME",
157
+ "XDG_STATE_HOME",
158
+ ],
159
+ },
160
+ qualificationCases: ["gemini-webhook", "gemini-direct"],
161
+ },
162
+ ];
163
+ function unique(values) {
164
+ return new Set(values).size === values.length;
165
+ }
166
+ function completeDirect(value) {
167
+ return (value !== undefined &&
168
+ BOUNDED_METADATA.test(value.command) &&
169
+ value.args.length <= 16 &&
170
+ value.args.every((argument) => BOUNDED_METADATA.test(argument)) &&
171
+ BOUNDED_METADATA.test(value.agentInfo.name) &&
172
+ value.agentInfo.versions.length > 0 &&
173
+ value.agentInfo.versions.length <= 16 &&
174
+ value.agentInfo.versions.every((version) => BOUNDED_METADATA.test(version)) &&
175
+ unique(value.agentInfo.versions) &&
176
+ (value.mcp === "provider_config" || value.mcp === "session") &&
177
+ value.environment.length <= 32 &&
178
+ value.environment.every((name) => ENVIRONMENT_NAME.test(name)) &&
179
+ unique(value.environment));
180
+ }
181
+ export function isCompleteAgentCapability(value) {
182
+ if (!KIND.test(value.kind) ||
183
+ !BOUNDED_METADATA.test(value.displayName) ||
184
+ value.aliases.length === 0 ||
185
+ value.aliases.length > 16 ||
186
+ value.modes.length === 0 ||
187
+ value.modes.length > 2 ||
188
+ !unique(value.modes) ||
189
+ value.qualificationCases.length === 0 ||
190
+ value.qualificationCases.length > 16 ||
191
+ !value.qualificationCases.every((item) => BOUNDED_METADATA.test(item)) ||
192
+ !unique(value.qualificationCases)) {
193
+ return false;
194
+ }
195
+ const aliases = value.aliases.map(({ name, version }) => `${name}\u0000${version}`);
196
+ if (!unique(aliases) ||
197
+ !value.aliases.every(({ name, version }) => BOUNDED_METADATA.test(name) && BOUNDED_METADATA.test(version))) {
198
+ return false;
199
+ }
200
+ if (value.modes.some((mode) => mode !== "direct" && mode !== "webhook"))
201
+ return false;
202
+ return value.modes.includes("direct") ? completeDirect(value.direct) : value.direct === undefined;
203
+ }
204
+ function boundedClientInfo(value) {
205
+ return (value !== undefined && BOUNDED_METADATA.test(value.name) && BOUNDED_METADATA.test(value.version));
206
+ }
207
+ export function resolveAgentCapability(clientInfo, registry = PRODUCTION_AGENT_CAPABILITIES) {
208
+ if (!boundedClientInfo(clientInfo))
209
+ return { status: "unsupported" };
210
+ const matches = registry.filter((profile) => profile.enabled &&
211
+ isCompleteAgentCapability(profile) &&
212
+ profile.aliases.some((alias) => alias.name === clientInfo.name && alias.version === clientInfo.version));
213
+ return matches.length === 1 && matches[0] !== undefined
214
+ ? { status: "matched", profile: matches[0] }
215
+ : { status: "unsupported" };
216
+ }
217
+ export function capabilityForKind(kind, registry = PRODUCTION_AGENT_CAPABILITIES) {
218
+ const matches = registry.filter((profile) => profile.kind === kind && profile.enabled && isCompleteAgentCapability(profile));
219
+ return matches.length === 1 ? matches[0] : undefined;
220
+ }
221
+ //# sourceMappingURL=agent-capabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-capabilities.js","sourceRoot":"","sources":["../src/agent-capabilities.ts"],"names":[],"mappings":"AAiCA,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AACjD,MAAM,IAAI,GAAG,yBAAyB,CAAC;AACvC,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AAErD,MAAM,CAAC,MAAM,6BAA6B,GAA+B;IACvE;QACE,IAAI,EAAE,UAAU;QAChB,WAAW,EAAE,UAAU;QACvB,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;QAC5D,KAAK,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC;QAC5B,MAAM,EAAE;YACN,OAAO,EAAE,UAAU;YACnB,IAAI,EAAE,CAAC,KAAK,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E,aAAa,EAAE,CAAC;IACrE,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAC7B,CAAC,OAAO,EAAE,EAAE,CACV,OAAO,CAAC,OAAO;QACf,yBAAyB,CAAC,OAAO,CAAC;QAClC,OAAO,CAAC,OAAO,CAAC,IAAI,CAClB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,UAAU,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,KAAK,UAAU,CAAC,OAAO,CAClF,CACJ,CAAC;IACF,OAAO,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,SAAS;QACrD,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE;QAC5C,CAAC,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,IAAY,EACZ,QAAQ,GAA+B,6BAA6B;IAEpE,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAC7B,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,IAAI,IAAI,OAAO,CAAC,OAAO,IAAI,yBAAyB,CAAC,OAAO,CAAC,CAC5F,CAAC;IACF,OAAO,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare class AmbassadorOptionsError extends Error {
2
+ readonly exitCode: 2 | 4;
3
+ constructor(exitCode: 2 | 4);
4
+ }
5
+ export interface AmbassadorStartOptions {
6
+ readonly localTokenEnv: string;
7
+ }
8
+ export declare function parseAmbassadorStartOptions(args: readonly string[]): AmbassadorStartOptions;
9
+ export declare function resolveLocalToken(environment: NodeJS.ProcessEnv, variableName: string): string;
@@ -0,0 +1,31 @@
1
+ export class AmbassadorOptionsError extends Error {
2
+ exitCode;
3
+ constructor(exitCode) {
4
+ super(exitCode === 2 ? "Invalid command or arguments" : "Invalid local token");
5
+ this.name = "AmbassadorOptionsError";
6
+ this.exitCode = exitCode;
7
+ }
8
+ }
9
+ const ENVIRONMENT_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/u;
10
+ const GENERATED_LOCAL_TOKEN = /^[0-9a-f]{48}$/u;
11
+ const OPTION_PREFIX = "--local-token-env=";
12
+ export function parseAmbassadorStartOptions(args) {
13
+ if (args.length !== 2 || args[0] !== "start")
14
+ throw new AmbassadorOptionsError(2);
15
+ const option = args[1];
16
+ if (option === undefined || !option.startsWith(OPTION_PREFIX)) {
17
+ throw new AmbassadorOptionsError(2);
18
+ }
19
+ const localTokenEnv = option.slice(OPTION_PREFIX.length);
20
+ if (!ENVIRONMENT_NAME.test(localTokenEnv))
21
+ throw new AmbassadorOptionsError(2);
22
+ return { localTokenEnv };
23
+ }
24
+ export function resolveLocalToken(environment, variableName) {
25
+ const value = environment[variableName];
26
+ if (value === undefined || !GENERATED_LOCAL_TOKEN.test(value)) {
27
+ throw new AmbassadorOptionsError(4);
28
+ }
29
+ return value;
30
+ }
31
+ //# sourceMappingURL=ambassador-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ambassador-options.js","sourceRoot":"","sources":["../src/ambassador-options.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IACtC,QAAQ,CAAQ;IAEzB,YAAY,QAAe;QACzB,KAAK,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,8BAA8B,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC;QAC/E,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAMD,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AACrD,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AAChD,MAAM,aAAa,GAAG,oBAAoB,CAAC;AAE3C,MAAM,UAAU,2BAA2B,CAAC,IAAuB;IACjE,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,OAAO;QAAE,MAAM,IAAI,sBAAsB,CAAC,CAAC,CAAC,CAAC;IAClF,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACvB,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;QAC9D,MAAM,IAAI,sBAAsB,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;IACD,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACzD,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,aAAa,CAAC;QAAE,MAAM,IAAI,sBAAsB,CAAC,CAAC,CAAC,CAAC;IAC/E,OAAO,EAAE,aAAa,EAAE,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,WAA8B,EAAE,YAAoB;IACpF,MAAM,KAAK,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC;IACxC,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9D,MAAM,IAAI,sBAAsB,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { type KeyObject } from "node:crypto";
2
+ export interface CentralPublicJwk {
3
+ readonly kty: "EC";
4
+ readonly crv: "P-256";
5
+ readonly x: string;
6
+ readonly y: string;
7
+ }
8
+ export interface CentralCredentialRecord {
9
+ readonly credential_format: 1;
10
+ readonly access_token: string;
11
+ readonly dpop_private_key_pkcs8: string;
12
+ }
13
+ export interface CentralTokenClaims {
14
+ readonly subject: string;
15
+ readonly email: string;
16
+ readonly issuedAt: number;
17
+ readonly expiresAt: number;
18
+ readonly keyThumbprint: string;
19
+ }
20
+ export interface LoadedCentralCredential {
21
+ readonly record: CentralCredentialRecord;
22
+ readonly serialized: string;
23
+ readonly privateKey: KeyObject;
24
+ readonly publicJwk: CentralPublicJwk;
25
+ readonly keyThumbprint: string;
26
+ readonly token: CentralTokenClaims;
27
+ }
28
+ export interface CentralKeyMaterial {
29
+ readonly privateKey: KeyObject;
30
+ readonly privateKeyPkcs8: string;
31
+ readonly publicJwk: CentralPublicJwk;
32
+ readonly thumbprint: string;
33
+ }
34
+ export declare class CentralCredentialError extends Error {
35
+ constructor();
36
+ }
37
+ export declare function exactCentralPublicJwk(value: unknown): CentralPublicJwk;
38
+ export declare function centralJwkThumbprint(jwk: CentralPublicJwk): string;
39
+ export declare function serializeCentralCredential(record: CentralCredentialRecord): string;
40
+ export declare function parseCentralCredential(value: string | CentralCredentialRecord | unknown, nowSeconds?: () => number): LoadedCentralCredential;
41
+ export declare function createCentralCredentialRecord(accessToken: string, key: CentralKeyMaterial): CentralCredentialRecord;