@contractspec/lib.contracts-integrations 2.0.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/README.md +3 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +3676 -0
- package/dist/integrations/binding.d.ts +14 -0
- package/dist/integrations/binding.js +1 -0
- package/dist/integrations/connection.d.ts +47 -0
- package/dist/integrations/connection.js +1 -0
- package/dist/integrations/docs/integrations.docblock.d.ts +2 -0
- package/dist/integrations/docs/integrations.docblock.js +110 -0
- package/dist/integrations/health.d.ts +17 -0
- package/dist/integrations/health.js +73 -0
- package/dist/integrations/health.test.d.ts +1 -0
- package/dist/integrations/index.d.ts +11 -0
- package/dist/integrations/index.js +3264 -0
- package/dist/integrations/integrations.capability.d.ts +1 -0
- package/dist/integrations/integrations.capability.js +18 -0
- package/dist/integrations/integrations.feature.d.ts +5 -0
- package/dist/integrations/integrations.feature.js +33 -0
- package/dist/integrations/meeting-recorder/contracts/index.d.ts +7 -0
- package/dist/integrations/meeting-recorder/contracts/index.js +474 -0
- package/dist/integrations/meeting-recorder/contracts/meetings.d.ts +451 -0
- package/dist/integrations/meeting-recorder/contracts/meetings.js +219 -0
- package/dist/integrations/meeting-recorder/contracts/transcripts.d.ts +166 -0
- package/dist/integrations/meeting-recorder/contracts/transcripts.js +287 -0
- package/dist/integrations/meeting-recorder/contracts/webhooks.d.ts +85 -0
- package/dist/integrations/meeting-recorder/contracts/webhooks.js +172 -0
- package/dist/integrations/meeting-recorder/meeting-recorder.capability.d.ts +1 -0
- package/dist/integrations/meeting-recorder/meeting-recorder.capability.js +18 -0
- package/dist/integrations/meeting-recorder/meeting-recorder.feature.d.ts +5 -0
- package/dist/integrations/meeting-recorder/meeting-recorder.feature.js +33 -0
- package/dist/integrations/meeting-recorder/models.d.ts +402 -0
- package/dist/integrations/meeting-recorder/models.js +122 -0
- package/dist/integrations/meeting-recorder/telemetry.d.ts +13 -0
- package/dist/integrations/meeting-recorder/telemetry.js +54 -0
- package/dist/integrations/openbanking/contracts/accounts.d.ts +282 -0
- package/dist/integrations/openbanking/contracts/accounts.js +328 -0
- package/dist/integrations/openbanking/contracts/balances.d.ts +158 -0
- package/dist/integrations/openbanking/contracts/balances.js +292 -0
- package/dist/integrations/openbanking/contracts/index.d.ts +7 -0
- package/dist/integrations/openbanking/contracts/index.js +644 -0
- package/dist/integrations/openbanking/contracts/transactions.d.ts +206 -0
- package/dist/integrations/openbanking/contracts/transactions.js +298 -0
- package/dist/integrations/openbanking/guards.d.ts +8 -0
- package/dist/integrations/openbanking/guards.js +42 -0
- package/dist/integrations/openbanking/guards.test.d.ts +1 -0
- package/dist/integrations/openbanking/models.d.ts +223 -0
- package/dist/integrations/openbanking/models.js +110 -0
- package/dist/integrations/openbanking/openbanking.capability.d.ts +1 -0
- package/dist/integrations/openbanking/openbanking.capability.js +18 -0
- package/dist/integrations/openbanking/openbanking.feature.d.ts +5 -0
- package/dist/integrations/openbanking/openbanking.feature.js +35 -0
- package/dist/integrations/openbanking/telemetry.d.ts +12 -0
- package/dist/integrations/openbanking/telemetry.js +51 -0
- package/dist/integrations/operations.d.ts +430 -0
- package/dist/integrations/operations.js +297 -0
- package/dist/integrations/operations.test.d.ts +1 -0
- package/dist/integrations/providers/analytics-reader.d.ts +103 -0
- package/dist/integrations/providers/analytics-reader.js +1 -0
- package/dist/integrations/providers/analytics-writer.d.ts +6 -0
- package/dist/integrations/providers/analytics-writer.js +1 -0
- package/dist/integrations/providers/analytics.d.ts +47 -0
- package/dist/integrations/providers/analytics.js +1 -0
- package/dist/integrations/providers/calendar.d.ts +75 -0
- package/dist/integrations/providers/calendar.js +1 -0
- package/dist/integrations/providers/database.d.ts +12 -0
- package/dist/integrations/providers/database.js +1 -0
- package/dist/integrations/providers/elevenlabs.d.ts +3 -0
- package/dist/integrations/providers/elevenlabs.js +86 -0
- package/dist/integrations/providers/email.d.ts +83 -0
- package/dist/integrations/providers/email.js +1 -0
- package/dist/integrations/providers/embedding.d.ts +21 -0
- package/dist/integrations/providers/embedding.js +1 -0
- package/dist/integrations/providers/fal.d.ts +3 -0
- package/dist/integrations/providers/fal.js +112 -0
- package/dist/integrations/providers/fathom.d.ts +3 -0
- package/dist/integrations/providers/fathom.js +126 -0
- package/dist/integrations/providers/fireflies.d.ts +3 -0
- package/dist/integrations/providers/fireflies.js +106 -0
- package/dist/integrations/providers/gcs-storage.d.ts +3 -0
- package/dist/integrations/providers/gcs-storage.js +97 -0
- package/dist/integrations/providers/gmail.d.ts +3 -0
- package/dist/integrations/providers/gmail.js +109 -0
- package/dist/integrations/providers/google-calendar.d.ts +3 -0
- package/dist/integrations/providers/google-calendar.js +92 -0
- package/dist/integrations/providers/gradium.d.ts +3 -0
- package/dist/integrations/providers/gradium.js +110 -0
- package/dist/integrations/providers/granola.d.ts +3 -0
- package/dist/integrations/providers/granola.js +107 -0
- package/dist/integrations/providers/index.d.ts +38 -0
- package/dist/integrations/providers/index.js +2094 -0
- package/dist/integrations/providers/jira.d.ts +3 -0
- package/dist/integrations/providers/jira.js +108 -0
- package/dist/integrations/providers/linear.d.ts +3 -0
- package/dist/integrations/providers/linear.js +107 -0
- package/dist/integrations/providers/llm.d.ts +79 -0
- package/dist/integrations/providers/llm.js +1 -0
- package/dist/integrations/providers/meeting-recorder.d.ts +129 -0
- package/dist/integrations/providers/meeting-recorder.js +1 -0
- package/dist/integrations/providers/mistral.d.ts +3 -0
- package/dist/integrations/providers/mistral.js +94 -0
- package/dist/integrations/providers/notion.d.ts +3 -0
- package/dist/integrations/providers/notion.js +113 -0
- package/dist/integrations/providers/openbanking.d.ts +125 -0
- package/dist/integrations/providers/openbanking.js +1 -0
- package/dist/integrations/providers/payments.d.ts +106 -0
- package/dist/integrations/providers/payments.js +1 -0
- package/dist/integrations/providers/posthog-llm-telemetry.d.ts +51 -0
- package/dist/integrations/providers/posthog-llm-telemetry.js +176 -0
- package/dist/integrations/providers/posthog.d.ts +3 -0
- package/dist/integrations/providers/posthog.js +106 -0
- package/dist/integrations/providers/postmark.d.ts +3 -0
- package/dist/integrations/providers/postmark.js +98 -0
- package/dist/integrations/providers/powens.d.ts +3 -0
- package/dist/integrations/providers/powens.js +124 -0
- package/dist/integrations/providers/project-management.d.ts +32 -0
- package/dist/integrations/providers/project-management.js +1 -0
- package/dist/integrations/providers/providers.test.d.ts +1 -0
- package/dist/integrations/providers/qdrant.d.ts +3 -0
- package/dist/integrations/providers/qdrant.js +101 -0
- package/dist/integrations/providers/registry.d.ts +6 -0
- package/dist/integrations/providers/registry.js +1878 -0
- package/dist/integrations/providers/sms.d.ts +31 -0
- package/dist/integrations/providers/sms.js +1 -0
- package/dist/integrations/providers/storage.d.ts +57 -0
- package/dist/integrations/providers/storage.js +1 -0
- package/dist/integrations/providers/stripe.d.ts +3 -0
- package/dist/integrations/providers/stripe.js +105 -0
- package/dist/integrations/providers/supabase-postgres.d.ts +3 -0
- package/dist/integrations/providers/supabase-postgres.js +87 -0
- package/dist/integrations/providers/supabase-vector.d.ts +3 -0
- package/dist/integrations/providers/supabase-vector.js +107 -0
- package/dist/integrations/providers/tldv.d.ts +3 -0
- package/dist/integrations/providers/tldv.js +106 -0
- package/dist/integrations/providers/twilio-sms.d.ts +3 -0
- package/dist/integrations/providers/twilio-sms.js +91 -0
- package/dist/integrations/providers/vector-store.d.ts +39 -0
- package/dist/integrations/providers/vector-store.js +1 -0
- package/dist/integrations/providers/voice.d.ts +31 -0
- package/dist/integrations/providers/voice.js +1 -0
- package/dist/integrations/runtime.d.ts +95 -0
- package/dist/integrations/runtime.js +209 -0
- package/dist/integrations/runtime.test.d.ts +1 -0
- package/dist/integrations/secrets/aws-secret-manager.d.ts +28 -0
- package/dist/integrations/secrets/aws-secret-manager.js +346 -0
- package/dist/integrations/secrets/env-secret-provider.d.ts +28 -0
- package/dist/integrations/secrets/env-secret-provider.js +159 -0
- package/dist/integrations/secrets/gcp-secret-manager.d.ts +29 -0
- package/dist/integrations/secrets/gcp-secret-manager.js +347 -0
- package/dist/integrations/secrets/index.d.ts +6 -0
- package/dist/integrations/secrets/index.js +1129 -0
- package/dist/integrations/secrets/manager.d.ts +44 -0
- package/dist/integrations/secrets/manager.js +183 -0
- package/dist/integrations/secrets/provider.d.ts +49 -0
- package/dist/integrations/secrets/provider.js +74 -0
- package/dist/integrations/secrets/provider.test.d.ts +1 -0
- package/dist/integrations/secrets/scaleway-secret-manager.d.ts +35 -0
- package/dist/integrations/secrets/scaleway-secret-manager.js +375 -0
- package/dist/integrations/secrets-types.d.ts +14 -0
- package/dist/integrations/secrets-types.js +1 -0
- package/dist/integrations/spec.d.ts +72 -0
- package/dist/integrations/spec.js +22 -0
- package/dist/integrations/spec.test.d.ts +1 -0
- package/dist/node/index.js +3675 -0
- package/dist/node/integrations/binding.js +0 -0
- package/dist/node/integrations/connection.js +0 -0
- package/dist/node/integrations/docs/integrations.docblock.js +109 -0
- package/dist/node/integrations/health.js +72 -0
- package/dist/node/integrations/index.js +3263 -0
- package/dist/node/integrations/integrations.capability.js +17 -0
- package/dist/node/integrations/integrations.feature.js +32 -0
- package/dist/node/integrations/meeting-recorder/contracts/index.js +473 -0
- package/dist/node/integrations/meeting-recorder/contracts/meetings.js +218 -0
- package/dist/node/integrations/meeting-recorder/contracts/transcripts.js +286 -0
- package/dist/node/integrations/meeting-recorder/contracts/webhooks.js +171 -0
- package/dist/node/integrations/meeting-recorder/meeting-recorder.capability.js +17 -0
- package/dist/node/integrations/meeting-recorder/meeting-recorder.feature.js +32 -0
- package/dist/node/integrations/meeting-recorder/models.js +121 -0
- package/dist/node/integrations/meeting-recorder/telemetry.js +53 -0
- package/dist/node/integrations/openbanking/contracts/accounts.js +327 -0
- package/dist/node/integrations/openbanking/contracts/balances.js +291 -0
- package/dist/node/integrations/openbanking/contracts/index.js +643 -0
- package/dist/node/integrations/openbanking/contracts/transactions.js +297 -0
- package/dist/node/integrations/openbanking/guards.js +41 -0
- package/dist/node/integrations/openbanking/models.js +109 -0
- package/dist/node/integrations/openbanking/openbanking.capability.js +17 -0
- package/dist/node/integrations/openbanking/openbanking.feature.js +34 -0
- package/dist/node/integrations/openbanking/telemetry.js +50 -0
- package/dist/node/integrations/operations.js +296 -0
- package/dist/node/integrations/providers/analytics-reader.js +0 -0
- package/dist/node/integrations/providers/analytics-writer.js +0 -0
- package/dist/node/integrations/providers/analytics.js +0 -0
- package/dist/node/integrations/providers/calendar.js +0 -0
- package/dist/node/integrations/providers/database.js +0 -0
- package/dist/node/integrations/providers/elevenlabs.js +85 -0
- package/dist/node/integrations/providers/email.js +0 -0
- package/dist/node/integrations/providers/embedding.js +0 -0
- package/dist/node/integrations/providers/fal.js +111 -0
- package/dist/node/integrations/providers/fathom.js +125 -0
- package/dist/node/integrations/providers/fireflies.js +105 -0
- package/dist/node/integrations/providers/gcs-storage.js +96 -0
- package/dist/node/integrations/providers/gmail.js +108 -0
- package/dist/node/integrations/providers/google-calendar.js +91 -0
- package/dist/node/integrations/providers/gradium.js +109 -0
- package/dist/node/integrations/providers/granola.js +106 -0
- package/dist/node/integrations/providers/index.js +2093 -0
- package/dist/node/integrations/providers/jira.js +107 -0
- package/dist/node/integrations/providers/linear.js +106 -0
- package/dist/node/integrations/providers/llm.js +0 -0
- package/dist/node/integrations/providers/meeting-recorder.js +0 -0
- package/dist/node/integrations/providers/mistral.js +93 -0
- package/dist/node/integrations/providers/notion.js +112 -0
- package/dist/node/integrations/providers/openbanking.js +0 -0
- package/dist/node/integrations/providers/payments.js +0 -0
- package/dist/node/integrations/providers/posthog-llm-telemetry.js +175 -0
- package/dist/node/integrations/providers/posthog.js +105 -0
- package/dist/node/integrations/providers/postmark.js +97 -0
- package/dist/node/integrations/providers/powens.js +123 -0
- package/dist/node/integrations/providers/project-management.js +0 -0
- package/dist/node/integrations/providers/qdrant.js +100 -0
- package/dist/node/integrations/providers/registry.js +1877 -0
- package/dist/node/integrations/providers/sms.js +0 -0
- package/dist/node/integrations/providers/storage.js +0 -0
- package/dist/node/integrations/providers/stripe.js +104 -0
- package/dist/node/integrations/providers/supabase-postgres.js +86 -0
- package/dist/node/integrations/providers/supabase-vector.js +106 -0
- package/dist/node/integrations/providers/tldv.js +105 -0
- package/dist/node/integrations/providers/twilio-sms.js +90 -0
- package/dist/node/integrations/providers/vector-store.js +0 -0
- package/dist/node/integrations/providers/voice.js +0 -0
- package/dist/node/integrations/runtime.js +208 -0
- package/dist/node/integrations/secrets/aws-secret-manager.js +345 -0
- package/dist/node/integrations/secrets/env-secret-provider.js +158 -0
- package/dist/node/integrations/secrets/gcp-secret-manager.js +346 -0
- package/dist/node/integrations/secrets/index.js +1128 -0
- package/dist/node/integrations/secrets/manager.js +182 -0
- package/dist/node/integrations/secrets/provider.js +73 -0
- package/dist/node/integrations/secrets/scaleway-secret-manager.js +374 -0
- package/dist/node/integrations/secrets-types.js +0 -0
- package/dist/node/integrations/spec.js +21 -0
- package/package.json +1029 -0
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/integrations/secrets/provider.ts
|
|
3
|
+
import { Buffer } from "buffer";
|
|
4
|
+
|
|
5
|
+
class SecretProviderError extends Error {
|
|
6
|
+
provider;
|
|
7
|
+
reference;
|
|
8
|
+
code;
|
|
9
|
+
cause;
|
|
10
|
+
constructor(params) {
|
|
11
|
+
super(params.message);
|
|
12
|
+
this.name = "SecretProviderError";
|
|
13
|
+
this.provider = params.provider;
|
|
14
|
+
this.reference = params.reference;
|
|
15
|
+
this.code = params.code ?? "UNKNOWN";
|
|
16
|
+
this.cause = params.cause;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function parseSecretUri(reference) {
|
|
20
|
+
if (!reference) {
|
|
21
|
+
throw new SecretProviderError({
|
|
22
|
+
message: "Secret reference cannot be empty",
|
|
23
|
+
provider: "unknown",
|
|
24
|
+
reference,
|
|
25
|
+
code: "INVALID"
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
const [scheme, rest] = reference.split("://");
|
|
29
|
+
if (!scheme || !rest) {
|
|
30
|
+
throw new SecretProviderError({
|
|
31
|
+
message: `Invalid secret reference: ${reference}`,
|
|
32
|
+
provider: "unknown",
|
|
33
|
+
reference,
|
|
34
|
+
code: "INVALID"
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const queryIndex = rest.indexOf("?");
|
|
38
|
+
if (queryIndex === -1) {
|
|
39
|
+
return {
|
|
40
|
+
provider: scheme,
|
|
41
|
+
path: rest
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const path = rest.slice(0, queryIndex);
|
|
45
|
+
const query = rest.slice(queryIndex + 1);
|
|
46
|
+
const extras = Object.fromEntries(query.split("&").filter(Boolean).map((pair) => {
|
|
47
|
+
const [keyRaw, valueRaw] = pair.split("=");
|
|
48
|
+
const key = keyRaw ?? "";
|
|
49
|
+
const value = valueRaw ?? "";
|
|
50
|
+
return [decodeURIComponent(key), decodeURIComponent(value)];
|
|
51
|
+
}));
|
|
52
|
+
return {
|
|
53
|
+
provider: scheme,
|
|
54
|
+
path,
|
|
55
|
+
extras
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function normalizeSecretPayload(payload) {
|
|
59
|
+
if (payload.data instanceof Uint8Array) {
|
|
60
|
+
return payload.data;
|
|
61
|
+
}
|
|
62
|
+
if (payload.encoding === "base64") {
|
|
63
|
+
return Buffer.from(payload.data, "base64");
|
|
64
|
+
}
|
|
65
|
+
if (payload.encoding === "binary") {
|
|
66
|
+
return Buffer.from(payload.data, "binary");
|
|
67
|
+
}
|
|
68
|
+
return Buffer.from(payload.data, "utf-8");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// src/integrations/secrets/scaleway-secret-manager.ts
|
|
72
|
+
import { Buffer as Buffer2 } from "buffer";
|
|
73
|
+
var UUID_V4_LIKE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
74
|
+
|
|
75
|
+
class ScalewaySecretManagerProvider {
|
|
76
|
+
id = "scaleway-secret-manager";
|
|
77
|
+
token;
|
|
78
|
+
defaultRegion;
|
|
79
|
+
defaultProjectId;
|
|
80
|
+
baseUrl;
|
|
81
|
+
fetchFn;
|
|
82
|
+
constructor(options = {}) {
|
|
83
|
+
this.token = options.token ?? process.env.SCW_SECRET_KEY ?? process.env.SCALEWAY_SECRET_KEY ?? "";
|
|
84
|
+
this.defaultRegion = options.defaultRegion ?? process.env.SCW_DEFAULT_REGION ?? process.env.SCW_REGION;
|
|
85
|
+
this.defaultProjectId = options.defaultProjectId ?? process.env.SCW_DEFAULT_PROJECT_ID ?? process.env.SCW_PROJECT_ID;
|
|
86
|
+
this.baseUrl = options.baseUrl ?? "https://api.scaleway.com";
|
|
87
|
+
this.fetchFn = options.fetch ?? fetch;
|
|
88
|
+
}
|
|
89
|
+
canHandle(reference) {
|
|
90
|
+
try {
|
|
91
|
+
const parsed = parseSecretUri(reference);
|
|
92
|
+
return parsed.provider === "scw" && (parsed.path === "secret-manager" || parsed.path.startsWith("secret-manager/"));
|
|
93
|
+
} catch {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async getSecret(reference, options) {
|
|
98
|
+
const location = this.parseReference(reference);
|
|
99
|
+
if (!this.token) {
|
|
100
|
+
throw new SecretProviderError({
|
|
101
|
+
message: "Scaleway secret manager token is missing (set SCW_SECRET_KEY / SCALEWAY_SECRET_KEY).",
|
|
102
|
+
provider: this.id,
|
|
103
|
+
reference,
|
|
104
|
+
code: "FORBIDDEN"
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
if (!UUID_V4_LIKE.test(location.secretIdOrName)) {
|
|
108
|
+
throw new SecretProviderError({
|
|
109
|
+
message: "Scaleway getSecret requires a secretId (uuid) reference, not a secret name.",
|
|
110
|
+
provider: this.id,
|
|
111
|
+
reference,
|
|
112
|
+
code: "INVALID"
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
const revision = options?.version ?? location.revision ?? "latest";
|
|
116
|
+
const url = `${this.baseUrl}/secret-manager/v1beta1/regions/${encodeURIComponent(location.region)}/secrets/${encodeURIComponent(location.secretIdOrName)}/versions/${encodeURIComponent(revision)}/access`;
|
|
117
|
+
const response = await this.fetchFn(url, {
|
|
118
|
+
method: "GET",
|
|
119
|
+
headers: {
|
|
120
|
+
"X-Auth-Token": this.token
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
if (!response.ok) {
|
|
124
|
+
throw await toScalewayError({
|
|
125
|
+
response,
|
|
126
|
+
provider: this.id,
|
|
127
|
+
reference,
|
|
128
|
+
operation: "getSecret"
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const payload = await response.json();
|
|
132
|
+
const dataB64 = extractScalewayData(payload);
|
|
133
|
+
return {
|
|
134
|
+
data: Buffer2.from(dataB64, "base64"),
|
|
135
|
+
version: revision,
|
|
136
|
+
metadata: {
|
|
137
|
+
region: location.region,
|
|
138
|
+
secretId: location.secretIdOrName
|
|
139
|
+
},
|
|
140
|
+
retrievedAt: new Date
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
async setSecret(reference, payload) {
|
|
144
|
+
const location = this.parseReference(reference);
|
|
145
|
+
if (!this.token) {
|
|
146
|
+
throw new SecretProviderError({
|
|
147
|
+
message: "Scaleway secret manager token is missing (set SCW_SECRET_KEY / SCALEWAY_SECRET_KEY).",
|
|
148
|
+
provider: this.id,
|
|
149
|
+
reference,
|
|
150
|
+
code: "FORBIDDEN"
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
const bytes = normalizeSecretPayload(payload);
|
|
154
|
+
const encoded = Buffer2.from(bytes).toString("base64");
|
|
155
|
+
const secretId = UUID_V4_LIKE.test(location.secretIdOrName) ? location.secretIdOrName : await this.createSecret({
|
|
156
|
+
region: location.region,
|
|
157
|
+
name: location.secretIdOrName,
|
|
158
|
+
reference
|
|
159
|
+
});
|
|
160
|
+
const version = await this.createSecretVersion({
|
|
161
|
+
region: location.region,
|
|
162
|
+
secretId,
|
|
163
|
+
dataB64: encoded,
|
|
164
|
+
reference
|
|
165
|
+
});
|
|
166
|
+
return {
|
|
167
|
+
reference: this.buildReference(location.region, secretId, {
|
|
168
|
+
version
|
|
169
|
+
}),
|
|
170
|
+
version
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
async rotateSecret(reference, payload) {
|
|
174
|
+
return this.setSecret(reference, payload);
|
|
175
|
+
}
|
|
176
|
+
async deleteSecret(reference) {
|
|
177
|
+
const location = this.parseReference(reference);
|
|
178
|
+
if (!this.token) {
|
|
179
|
+
throw new SecretProviderError({
|
|
180
|
+
message: "Scaleway secret manager token is missing (set SCW_SECRET_KEY / SCALEWAY_SECRET_KEY).",
|
|
181
|
+
provider: this.id,
|
|
182
|
+
reference,
|
|
183
|
+
code: "FORBIDDEN"
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
if (!UUID_V4_LIKE.test(location.secretIdOrName)) {
|
|
187
|
+
throw new SecretProviderError({
|
|
188
|
+
message: "Scaleway deleteSecret requires a secretId (uuid) reference, not a secret name.",
|
|
189
|
+
provider: this.id,
|
|
190
|
+
reference,
|
|
191
|
+
code: "INVALID"
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
const url = `${this.baseUrl}/secret-manager/v1beta1/regions/${encodeURIComponent(location.region)}/secrets/${encodeURIComponent(location.secretIdOrName)}`;
|
|
195
|
+
const response = await this.fetchFn(url, {
|
|
196
|
+
method: "DELETE",
|
|
197
|
+
headers: {
|
|
198
|
+
"X-Auth-Token": this.token
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
if (!response.ok) {
|
|
202
|
+
throw await toScalewayError({
|
|
203
|
+
response,
|
|
204
|
+
provider: this.id,
|
|
205
|
+
reference,
|
|
206
|
+
operation: "deleteSecret"
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
parseReference(reference) {
|
|
211
|
+
const parsed = parseSecretUri(reference);
|
|
212
|
+
if (parsed.provider !== "scw") {
|
|
213
|
+
throw new SecretProviderError({
|
|
214
|
+
message: `Unsupported secret provider: ${parsed.provider}`,
|
|
215
|
+
provider: this.id,
|
|
216
|
+
reference,
|
|
217
|
+
code: "INVALID"
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
const segments = parsed.path.split("/").filter(Boolean);
|
|
221
|
+
if (segments.length < 2 || segments[0] !== "secret-manager") {
|
|
222
|
+
throw new SecretProviderError({
|
|
223
|
+
message: "Expected secret reference format scw://secret-manager/{region}/{secretIdOrName}[?version=...]",
|
|
224
|
+
provider: this.id,
|
|
225
|
+
reference,
|
|
226
|
+
code: "INVALID"
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
const region = segments[1] ?? this.defaultRegion;
|
|
230
|
+
if (!region) {
|
|
231
|
+
throw new SecretProviderError({
|
|
232
|
+
message: "Scaleway region must be provided either in reference (scw://secret-manager/{region}/...) or via SCW_DEFAULT_REGION/SCW_REGION.",
|
|
233
|
+
provider: this.id,
|
|
234
|
+
reference,
|
|
235
|
+
code: "INVALID"
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
const secretIdOrName = segments.slice(2).join("/");
|
|
239
|
+
if (!secretIdOrName) {
|
|
240
|
+
throw new SecretProviderError({
|
|
241
|
+
message: `Unable to resolve secret id/name from reference "${parsed.path}"`,
|
|
242
|
+
provider: this.id,
|
|
243
|
+
reference,
|
|
244
|
+
code: "INVALID"
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
region,
|
|
249
|
+
secretIdOrName,
|
|
250
|
+
revision: parsed.extras?.version
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
async createSecret(params) {
|
|
254
|
+
const projectId = this.defaultProjectId;
|
|
255
|
+
if (!projectId) {
|
|
256
|
+
throw new SecretProviderError({
|
|
257
|
+
message: "Scaleway project id is required to create secrets by name (set SCW_DEFAULT_PROJECT_ID/SCW_PROJECT_ID).",
|
|
258
|
+
provider: this.id,
|
|
259
|
+
reference: params.reference,
|
|
260
|
+
code: "INVALID"
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
const url = `${this.baseUrl}/secret-manager/v1beta1/regions/${encodeURIComponent(params.region)}/secrets`;
|
|
264
|
+
const response = await this.fetchFn(url, {
|
|
265
|
+
method: "POST",
|
|
266
|
+
headers: {
|
|
267
|
+
"Content-Type": "application/json",
|
|
268
|
+
"X-Auth-Token": this.token
|
|
269
|
+
},
|
|
270
|
+
body: JSON.stringify({
|
|
271
|
+
name: params.name,
|
|
272
|
+
project_id: projectId
|
|
273
|
+
})
|
|
274
|
+
});
|
|
275
|
+
if (!response.ok) {
|
|
276
|
+
throw await toScalewayError({
|
|
277
|
+
response,
|
|
278
|
+
provider: this.id,
|
|
279
|
+
reference: params.reference,
|
|
280
|
+
operation: "createSecret"
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
const payload = await response.json();
|
|
284
|
+
const secretId = extractScalewaySecretId(payload);
|
|
285
|
+
return secretId;
|
|
286
|
+
}
|
|
287
|
+
async createSecretVersion(params) {
|
|
288
|
+
const url = `${this.baseUrl}/secret-manager/v1beta1/regions/${encodeURIComponent(params.region)}/secrets/${encodeURIComponent(params.secretId)}/versions`;
|
|
289
|
+
const response = await this.fetchFn(url, {
|
|
290
|
+
method: "POST",
|
|
291
|
+
headers: {
|
|
292
|
+
"Content-Type": "application/json",
|
|
293
|
+
"X-Auth-Token": this.token
|
|
294
|
+
},
|
|
295
|
+
body: JSON.stringify({
|
|
296
|
+
data: params.dataB64
|
|
297
|
+
})
|
|
298
|
+
});
|
|
299
|
+
if (!response.ok) {
|
|
300
|
+
throw await toScalewayError({
|
|
301
|
+
response,
|
|
302
|
+
provider: this.id,
|
|
303
|
+
reference: params.reference,
|
|
304
|
+
operation: "createSecretVersion"
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
const payload = await response.json();
|
|
308
|
+
return extractScalewayRevision(payload) ?? "latest";
|
|
309
|
+
}
|
|
310
|
+
buildReference(region, secretId, extras) {
|
|
311
|
+
const base = `scw://secret-manager/${region}/${secretId}`;
|
|
312
|
+
const query = extras ? Object.entries(extras).filter(([, value]) => Boolean(value)).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join("&") : "";
|
|
313
|
+
return query ? `${base}?${query}` : base;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
function extractScalewayData(payload) {
|
|
317
|
+
if (!payload || typeof payload !== "object") {
|
|
318
|
+
throw new Error("Invalid scaleway secret payload");
|
|
319
|
+
}
|
|
320
|
+
const record = payload;
|
|
321
|
+
if (typeof record.data === "string" && record.data) {
|
|
322
|
+
return record.data;
|
|
323
|
+
}
|
|
324
|
+
throw new Error("Scaleway secret payload is missing data");
|
|
325
|
+
}
|
|
326
|
+
function extractScalewaySecretId(payload) {
|
|
327
|
+
if (!payload || typeof payload !== "object") {
|
|
328
|
+
throw new Error("Invalid scaleway createSecret payload");
|
|
329
|
+
}
|
|
330
|
+
const record = payload;
|
|
331
|
+
if (typeof record.id === "string" && record.id) {
|
|
332
|
+
return record.id;
|
|
333
|
+
}
|
|
334
|
+
throw new Error("Scaleway createSecret response is missing id");
|
|
335
|
+
}
|
|
336
|
+
function extractScalewayRevision(payload) {
|
|
337
|
+
if (!payload || typeof payload !== "object") {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
const record = payload;
|
|
341
|
+
if (typeof record.revision === "number") {
|
|
342
|
+
return String(record.revision);
|
|
343
|
+
}
|
|
344
|
+
if (typeof record.revision === "string" && record.revision) {
|
|
345
|
+
return record.revision;
|
|
346
|
+
}
|
|
347
|
+
if (typeof record.id === "string" && record.id) {
|
|
348
|
+
return record.id;
|
|
349
|
+
}
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
async function toScalewayError(params) {
|
|
353
|
+
const { response, provider, reference, operation } = params;
|
|
354
|
+
const code = response.status === 404 ? "NOT_FOUND" : response.status === 401 || response.status === 403 ? "FORBIDDEN" : response.status >= 400 && response.status < 500 ? "INVALID" : "UNKNOWN";
|
|
355
|
+
const bodyText = await safeReadBody(response);
|
|
356
|
+
const message = bodyText ? `Scaleway Secret Manager ${operation} failed (${response.status}): ${bodyText}` : `Scaleway Secret Manager ${operation} failed (${response.status})`;
|
|
357
|
+
return new SecretProviderError({
|
|
358
|
+
message,
|
|
359
|
+
provider,
|
|
360
|
+
reference,
|
|
361
|
+
code
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
async function safeReadBody(response) {
|
|
365
|
+
try {
|
|
366
|
+
const text = await response.text();
|
|
367
|
+
const trimmed = text.trim();
|
|
368
|
+
return trimmed.length ? trimmed : undefined;
|
|
369
|
+
} catch {
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
export {
|
|
374
|
+
ScalewaySecretManagerProvider
|
|
375
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Secret Provider types for integrations
|
|
3
|
+
* These are core type definitions that don't require runtime dependencies.
|
|
4
|
+
*/
|
|
5
|
+
export interface SecretValue {
|
|
6
|
+
data: Uint8Array;
|
|
7
|
+
version?: string;
|
|
8
|
+
metadata?: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
export interface SecretProvider {
|
|
11
|
+
id: string;
|
|
12
|
+
canHandle(reference: string): boolean;
|
|
13
|
+
getSecret(reference: string): Promise<SecretValue>;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// @bun
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { OwnerShipMeta } from '@contractspec/lib.contracts-spec/ownership';
|
|
2
|
+
import type { CapabilityRef, CapabilityRequirement } from '@contractspec/lib.contracts-spec/capabilities';
|
|
3
|
+
import { SpecContractRegistry } from '@contractspec/lib.contracts-spec/registry';
|
|
4
|
+
export type IntegrationCategory = 'payments' | 'email' | 'calendar' | 'sms' | 'ai-llm' | 'ai-voice' | 'analytics' | 'speech-to-text' | 'vector-db' | 'storage' | 'accounting' | 'crm' | 'helpdesk' | 'project-management' | 'open-banking' | 'meeting-recorder' | 'database' | 'custom';
|
|
5
|
+
export type IntegrationOwnershipMode = 'managed' | 'byok';
|
|
6
|
+
export interface IntegrationMeta extends OwnerShipMeta {
|
|
7
|
+
category: IntegrationCategory;
|
|
8
|
+
}
|
|
9
|
+
export interface IntegrationCapabilityMapping {
|
|
10
|
+
/** Which CapabilitySpec this integration provides. */
|
|
11
|
+
provides: CapabilityRef[];
|
|
12
|
+
/** Optional: which capabilities it requires (e.g., storage for caching). */
|
|
13
|
+
requires?: CapabilityRequirement[];
|
|
14
|
+
}
|
|
15
|
+
export interface IntegrationConfigSchema {
|
|
16
|
+
/** JSON Schema or SchemaModel defining required config fields. */
|
|
17
|
+
schema: unknown;
|
|
18
|
+
/** Example configuration (for docs/UI). */
|
|
19
|
+
example?: Record<string, unknown>;
|
|
20
|
+
}
|
|
21
|
+
export interface IntegrationSecretSchema {
|
|
22
|
+
/** JSON Schema or SchemaModel describing secret fields. */
|
|
23
|
+
schema: unknown;
|
|
24
|
+
/** Redacted example for documentation/UI. */
|
|
25
|
+
example?: Record<string, string>;
|
|
26
|
+
}
|
|
27
|
+
export interface IntegrationByokSetup {
|
|
28
|
+
/** Human-readable instructions for tenants configuring BYOK accounts. */
|
|
29
|
+
setupInstructions?: string;
|
|
30
|
+
/** Required scopes/permissions for BYOK accounts. */
|
|
31
|
+
requiredScopes?: string[];
|
|
32
|
+
}
|
|
33
|
+
export interface IntegrationHealthCheck {
|
|
34
|
+
/** Endpoint or method to validate connection health. */
|
|
35
|
+
method?: 'ping' | 'list' | 'custom';
|
|
36
|
+
/** Timeout in ms for health check. */
|
|
37
|
+
timeoutMs?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface IntegrationSpec {
|
|
40
|
+
meta: IntegrationMeta;
|
|
41
|
+
/** Supported ownership modes for this provider. */
|
|
42
|
+
supportedModes: IntegrationOwnershipMode[];
|
|
43
|
+
/** Which capabilities this integration provides/requires. */
|
|
44
|
+
capabilities: IntegrationCapabilityMapping;
|
|
45
|
+
/** Configuration schema (API keys, endpoints, etc.). */
|
|
46
|
+
configSchema: IntegrationConfigSchema;
|
|
47
|
+
/** Secret schema (API/key material stored via secretRef). */
|
|
48
|
+
secretSchema: IntegrationSecretSchema;
|
|
49
|
+
/** Optional health check configuration. */
|
|
50
|
+
healthCheck?: IntegrationHealthCheck;
|
|
51
|
+
/** Documentation URL. */
|
|
52
|
+
docsUrl?: string;
|
|
53
|
+
/** Rate limits or usage constraints. */
|
|
54
|
+
constraints?: {
|
|
55
|
+
rateLimit?: {
|
|
56
|
+
rpm?: number;
|
|
57
|
+
rph?: number;
|
|
58
|
+
};
|
|
59
|
+
quotas?: Record<string, number>;
|
|
60
|
+
};
|
|
61
|
+
/** Provider-specific metadata for BYOK setup flows. */
|
|
62
|
+
byokSetup?: IntegrationByokSetup;
|
|
63
|
+
}
|
|
64
|
+
export declare class IntegrationSpecRegistry extends SpecContractRegistry<'integration', IntegrationSpec> {
|
|
65
|
+
constructor(items?: IntegrationSpec[]);
|
|
66
|
+
getByCategory(category: IntegrationCategory): IntegrationSpec[];
|
|
67
|
+
}
|
|
68
|
+
export declare function makeIntegrationSpecKey(meta: IntegrationMeta): string;
|
|
69
|
+
/**
|
|
70
|
+
* Helper to define an Integration.
|
|
71
|
+
*/
|
|
72
|
+
export declare const defineIntegration: (spec: IntegrationSpec) => IntegrationSpec;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/integrations/spec.ts
|
|
3
|
+
import { SpecContractRegistry } from "@contractspec/lib.contracts-spec/registry";
|
|
4
|
+
var integrationKey = (meta) => `${meta.key}.v${meta.version}`;
|
|
5
|
+
|
|
6
|
+
class IntegrationSpecRegistry extends SpecContractRegistry {
|
|
7
|
+
constructor(items) {
|
|
8
|
+
super("integration", items);
|
|
9
|
+
}
|
|
10
|
+
getByCategory(category) {
|
|
11
|
+
return this.list().filter((spec) => spec.meta.category === category);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function makeIntegrationSpecKey(meta) {
|
|
15
|
+
return integrationKey(meta);
|
|
16
|
+
}
|
|
17
|
+
var defineIntegration = (spec) => spec;
|
|
18
|
+
export {
|
|
19
|
+
makeIntegrationSpecKey,
|
|
20
|
+
defineIntegration,
|
|
21
|
+
IntegrationSpecRegistry
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|