@superdurable/connector-alibaba 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Super Durable
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,3 +1,7 @@
1
- # Temporary Holding Version
1
+ # Alibaba Cloud TypeScript connector
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `@superdurable/connector-alibaba` provides the read-only `describeRegions` Dex Step. It signs Alibaba Cloud ECS OpenAPI requests with [ACS3-HMAC-SHA256](https://help.aliyun.com/en/sdk/product-overview/v3-request-structure-and-signature) and returns the region catalog.
4
+
5
+ Use the [runnable Flow and Worker](examples/regions/) with the static `alibaba` connection. In Dex Web Connections, create or select a RAM user at [Alibaba Cloud RAM](https://ram.console.aliyun.com) > Identities > Users > Authentication > AccessKey. Enter its AccessKey ID and one-time secret in the connection form. The secret is resolved for each request and never enters Flow state. The ECS endpoint, timeout, and response size limit have manifest defaults.
6
+
7
+ The checked-in conformance scenarios replay Go-recorded requests and outcomes, including exact signatures. The integration test exercises a real Dex Worker and Client with a local ECS provider that returns 503 before succeeding. Real Alibaba Cloud authorization and region discovery remain unverified without user-controlled RAM credentials.
@@ -0,0 +1,52 @@
1
+ {
2
+ "connectorId": "alibaba",
3
+ "releaseTag": "connectors/alibaba/go/v0.1.0",
4
+ "package": {
5
+ "ecosystem": "npm",
6
+ "name": "@superdurable/connector-alibaba",
7
+ "version": "0.1.0"
8
+ },
9
+ "factories": [
10
+ {
11
+ "name": "newDescribeRegionsStep",
12
+ "kind": "query",
13
+ "operationId": "describeRegions",
14
+ "inputType": "DescribeRegionsInput",
15
+ "description": "List ECS region IDs, local names, endpoints, and sale status.",
16
+ "fields": {
17
+ "stepType": "stepType",
18
+ "annotations": "annotations",
19
+ "connectionName": "connectionName",
20
+ "resultAttribute": "resultAttribute"
21
+ },
22
+ "branches": [
23
+ {
24
+ "id": "fetched",
25
+ "field": "fetched",
26
+ "optional": false
27
+ },
28
+ {
29
+ "id": "providerRejected",
30
+ "field": "providerRejected",
31
+ "optional": true
32
+ },
33
+ {
34
+ "id": "invalidResponse",
35
+ "field": "invalidResponse",
36
+ "optional": true
37
+ },
38
+ {
39
+ "id": "defect",
40
+ "field": "defect",
41
+ "optional": true
42
+ }
43
+ ],
44
+ "inputSchema": {
45
+ "additionalProperties": false,
46
+ "description": "DescribeRegionsInput has no business parameters; the connector lists available ECS regions.",
47
+ "properties": {},
48
+ "type": "object"
49
+ }
50
+ }
51
+ ]
52
+ }
@@ -0,0 +1,124 @@
1
+ // src/generated/models.ts
2
+ import { z } from "zod";
3
+ import { SecretString } from "@superdurable/connectors-sdk";
4
+ var ConfigSchema = z.object({
5
+ "baseUrl": z.string().optional(),
6
+ "timeoutMs": z.number().int().optional(),
7
+ "maxResponseBytes": z.number().int().optional()
8
+ });
9
+ var CredentialMaterialError = class extends TypeError {
10
+ constructor(message) {
11
+ super(message);
12
+ this.name = "CredentialMaterialError";
13
+ }
14
+ };
15
+ var sdkCredentialDecodingFailureMessages = /* @__PURE__ */ new Set([
16
+ "project credential decoding failed",
17
+ "shared project credential decoding failed",
18
+ "project credential decoding failed: this connector version does not support shared credentials"
19
+ ]);
20
+ function isCredentialMaterialError(error) {
21
+ return error instanceof CredentialMaterialError || error instanceof TypeError && sdkCredentialDecodingFailureMessages.has(error.message);
22
+ }
23
+ function decodeCredentials(value) {
24
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new CredentialMaterialError("credential fields are invalid");
25
+ const fields = value;
26
+ const allowed = /* @__PURE__ */ new Set(["access_key_id", "access_key_secret"]);
27
+ if (Object.keys(fields).some((key) => !allowed.has(key))) throw new CredentialMaterialError("stored credential does not match the connector credential fields");
28
+ if (fields["access_key_id"] != null && !(typeof fields["access_key_id"] === "string")) throw new CredentialMaterialError("credential access_key_id has an invalid type");
29
+ if (fields["access_key_secret"] != null && !(typeof fields["access_key_secret"] === "string")) throw new CredentialMaterialError("credential access_key_secret has an invalid type");
30
+ const credentials = {};
31
+ if (!fields["access_key_id"]) throw new CredentialMaterialError("credential access_key_id is required");
32
+ credentials.accessKeyId = new SecretString(fields["access_key_id"] ?? "");
33
+ if (!fields["access_key_secret"]) throw new CredentialMaterialError("credential access_key_secret is required");
34
+ credentials.accessKeySecret = new SecretString(fields["access_key_secret"] ?? "");
35
+ return credentials;
36
+ }
37
+ var DescribeRegionsInputSchema = z.strictObject({});
38
+ var ECSRegionSchema = z.strictObject({
39
+ "regionId": z.string(),
40
+ "localName": z.string(),
41
+ "endpoint": z.string(),
42
+ "status": z.string()
43
+ });
44
+ var DescribeRegionsOutputSchema = z.strictObject({
45
+ "regions": z.array(ECSRegionSchema).nullable()
46
+ });
47
+
48
+ // src/generated/definitions.ts
49
+ var ConnectorID = "alibaba";
50
+ var ProviderID = "alibaba";
51
+ var DescribeRegionsBranch = {
52
+ Fetched: "fetched",
53
+ ProviderRejected: "providerRejected",
54
+ InvalidResponse: "invalidResponse",
55
+ Defect: "defect"
56
+ };
57
+ var DescribeRegionsBranchFetched = DescribeRegionsBranch.Fetched;
58
+ var DescribeRegionsBranchProviderRejected = DescribeRegionsBranch.ProviderRejected;
59
+ var DescribeRegionsBranchInvalidResponse = DescribeRegionsBranch.InvalidResponse;
60
+ var DescribeRegionsBranchDefect = DescribeRegionsBranch.Defect;
61
+ var DescribeRegionsDefinition = {
62
+ operation: { connectorId: ConnectorID, operationId: "describeRegions" },
63
+ branches: [
64
+ { id: "fetched", description: "Alibaba Cloud returned its ECS regions." },
65
+ { id: "providerRejected", description: "Alibaba Cloud rejected the credentials or request.", optional: true },
66
+ { id: "invalidResponse", description: "Alibaba Cloud returned malformed or oversized data.", optional: true },
67
+ { id: "defect", description: "Local connection configuration is invalid.", optional: true }
68
+ ],
69
+ stepDefaults: { executeMethodTimeoutMs: 3e4, executeDurability: "async" }
70
+ };
71
+ var DescribeRegionsMetadata = { kind: "query", idempotency: "none", authorization: "required" };
72
+
73
+ // src/generated/connection.ts
74
+ import { ConnectionRefSchema } from "@superdurable/connectors-sdk";
75
+ var Connection = class {
76
+ /** Stable provider and connection name. */
77
+ reference;
78
+ /** Bound provider operations. */
79
+ operations;
80
+ /** Validate a reference and bind operations. */
81
+ constructor(reference, operations) {
82
+ this.reference = ConnectionRefSchema.parse(reference);
83
+ if (this.reference.provider !== ProviderID) throw new TypeError("connection provider differs from the manifest");
84
+ if (!operations) throw new TypeError("connector operations are required");
85
+ this.operations = operations;
86
+ }
87
+ };
88
+ function newConnection(client, reference) {
89
+ if (!client) throw new TypeError("connector client is required");
90
+ return new Connection(reference, client);
91
+ }
92
+ function newConnectionWithOperations(operations, reference) {
93
+ return new Connection(reference, operations);
94
+ }
95
+ function newProjectConnection(project, connectionName, createClient) {
96
+ if (!project) throw new TypeError("loaded project is required");
97
+ const reference = ConnectionRefSchema.parse({ provider: ProviderID, name: connectionName });
98
+ const selected = project.configuration.connections.find((entry) => entry.connectorId === ConnectorID && entry.connectionName === connectionName);
99
+ if (!selected || selected.provider !== ProviderID) throw new TypeError("project connection is not configured");
100
+ return newConnection(createClient(project, connectionName), reference);
101
+ }
102
+
103
+ export {
104
+ ConfigSchema,
105
+ CredentialMaterialError,
106
+ isCredentialMaterialError,
107
+ decodeCredentials,
108
+ DescribeRegionsInputSchema,
109
+ ECSRegionSchema,
110
+ DescribeRegionsOutputSchema,
111
+ ConnectorID,
112
+ ProviderID,
113
+ DescribeRegionsBranch,
114
+ DescribeRegionsBranchFetched,
115
+ DescribeRegionsBranchProviderRejected,
116
+ DescribeRegionsBranchInvalidResponse,
117
+ DescribeRegionsBranchDefect,
118
+ DescribeRegionsDefinition,
119
+ DescribeRegionsMetadata,
120
+ Connection,
121
+ newConnection,
122
+ newConnectionWithOperations,
123
+ newProjectConnection
124
+ };
@@ -0,0 +1,93 @@
1
+ import { SecretString, CredentialProvider, Query, ConnectionRef } from '@superdurable/connectors-sdk';
2
+ import { z } from 'zod';
3
+
4
+ /** Connector configuration; omitted fields use manifest defaults. */
5
+ interface Config {
6
+ /** HTTPS origin of the ECS public OpenAPI endpoint, without a path. Leave blank for the displayed China Hangzhou endpoint; override only for another official ECS public region endpoint or an approved proxy. */
7
+ baseUrl?: string;
8
+ /** Maximum time for one DescribeRegions call as a positive Go duration such as 5s or 1m. Leave blank for the displayed default; increase only for a slow approved proxy. Runtime value in milliseconds. */
9
+ timeoutMs?: number;
10
+ /** Maximum response size in bytes as a positive integer. Leave blank for the displayed default; raise only if a valid ECS regions response exceeds it. */
11
+ maxResponseBytes?: number;
12
+ }
13
+ /** Runtime schema for manifest configuration. */
14
+ declare const ConfigSchema: z.ZodObject<{
15
+ baseUrl: z.ZodOptional<z.ZodString>;
16
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
17
+ maxResponseBytes: z.ZodOptional<z.ZodNumber>;
18
+ }, z.core.$strip>;
19
+ /** Private connector credentials resolved by the host. */
20
+ interface Credentials {
21
+ /** AccessKey ID from https://ram.console.aliyun.com > Identities > Users > your RAM user > Authentication > AccessKey. Copy its exact ID; it appears only in the signed Authorization header. Treat it as a credential; blank prevents requests. */
22
+ accessKeyId: SecretString;
23
+ /** AccessKey secret from https://ram.console.aliyun.com > Identities > Users > your RAM user > Authentication > AccessKey. Copy it when creating the key; it is secret and used only to sign requests. Blank prevents requests. */
24
+ accessKeySecret: SecretString;
25
+ }
26
+ /** Stored credential material that fails the connector credential checks, so no retry can succeed. */
27
+ declare class CredentialMaterialError extends TypeError {
28
+ constructor(message: string);
29
+ }
30
+ /** Report malformed stored credential material, also behind the SDK provider's decoding TypeError. */
31
+ declare function isCredentialMaterialError(error: unknown): boolean;
32
+ /** Decode private credential fields for the connector. */
33
+ declare function decodeCredentials(value: unknown): Credentials;
34
+ /** Host-owned source of private connector credentials. */
35
+ type CredentialSource = CredentialProvider<Credentials>;
36
+ /** DescribeRegionsInput has no business parameters; the connector lists available ECS regions. */
37
+ interface DescribeRegionsInput {
38
+ }
39
+ /** ECSRegion is a region advertised by ECS. */
40
+ interface ECSRegion {
41
+ /** RegionID is the canonical ECS region ID. */
42
+ "regionId": string;
43
+ /** LocalName is the provider's localized region name. */
44
+ "localName": string;
45
+ /** Endpoint is the public ECS API host for the region. */
46
+ "endpoint": string;
47
+ /** Status is available or soldOut. */
48
+ "status": string;
49
+ }
50
+ /** DescribeRegionsOutput contains the single-page ECS region list. */
51
+ interface DescribeRegionsOutput {
52
+ /** Regions contains all returned ECS regions, including sold-out entries. */
53
+ "regions": Array<ECSRegion> | null;
54
+ }
55
+ /** Runtime validator for DescribeRegionsInput. */
56
+ declare const DescribeRegionsInputSchema: z.ZodObject<{}, z.core.$strict>;
57
+ /** Runtime validator for ECSRegion. */
58
+ declare const ECSRegionSchema: z.ZodObject<{
59
+ regionId: z.ZodString;
60
+ localName: z.ZodString;
61
+ endpoint: z.ZodString;
62
+ status: z.ZodString;
63
+ }, z.core.$strict>;
64
+ /** Runtime validator for DescribeRegionsOutput. */
65
+ declare const DescribeRegionsOutputSchema: z.ZodObject<{
66
+ regions: z.ZodNullable<z.ZodArray<z.ZodObject<{
67
+ regionId: z.ZodString;
68
+ localName: z.ZodString;
69
+ endpoint: z.ZodString;
70
+ status: z.ZodString;
71
+ }, z.core.$strict>>>;
72
+ }, z.core.$strict>;
73
+
74
+ /** Typed operations supplied by a client or mock. */
75
+ interface Operations {
76
+ /** Invoke describeRegions through this connection. */
77
+ describeRegions(): Query<DescribeRegionsInput, DescribeRegionsOutput>;
78
+ }
79
+ /** Named connector connection kept outside Flow state. */
80
+ declare class Connection<BoundOperations = Operations> {
81
+ /** Stable provider and connection name. */
82
+ readonly reference: ConnectionRef;
83
+ /** Bound provider operations. */
84
+ readonly operations: BoundOperations;
85
+ /** Validate a reference and bind operations. */
86
+ constructor(reference: ConnectionRef, operations: BoundOperations);
87
+ }
88
+ /** Bind a client to a named connection. */
89
+ declare function newConnection(client: Operations, reference: ConnectionRef): Connection;
90
+ /** Bind scripted operations to a named connection. */
91
+ declare function newConnectionWithOperations(operations: Operations, reference: ConnectionRef): Connection;
92
+
93
+ export { Connection as C, type DescribeRegionsInput as D, type ECSRegion as E, type Operations as O, type DescribeRegionsOutput as a, type Credentials as b, type Config as c, ConfigSchema as d, CredentialMaterialError as e, type CredentialSource as f, DescribeRegionsInputSchema as g, DescribeRegionsOutputSchema as h, ECSRegionSchema as i, decodeCredentials as j, isCredentialMaterialError as k, newConnectionWithOperations as l, newConnection as n };
@@ -0,0 +1,97 @@
1
+ import { D as DescribeRegionsInput, a as DescribeRegionsOutput, C as Connection, O as Operations, b as Credentials, c as Config } from './connection-DFvkFolN.js';
2
+ export { d as ConfigSchema, e as CredentialMaterialError, f as CredentialSource, g as DescribeRegionsInputSchema, h as DescribeRegionsOutputSchema, E as ECSRegion, i as ECSRegionSchema, j as decodeCredentials, k as isCredentialMaterialError, n as newConnection, l as newConnectionWithOperations } from './connection-DFvkFolN.js';
3
+ import { QueryDefinition, QueryStepConfig, Query, QueryResult, QueryStep, CredentialProvider, Call, QueryAttempt } from '@superdurable/connectors-sdk';
4
+ import { StepTarget } from '@superdurable/dex';
5
+ import { LoadedProject } from '@superdurable/connectors-sdk/projectconfig';
6
+ import { ProviderRequest, ProviderResponse } from '@superdurable/connectors-sdk/providerhttp';
7
+ import 'zod';
8
+
9
+ /** Stable connector identity. */
10
+ declare const ConnectorID = "alibaba";
11
+ /** Provider identity for named connections. */
12
+ declare const ProviderID = "alibaba";
13
+ /** Branch IDs for describeRegions. */
14
+ declare const DescribeRegionsBranch: {
15
+ readonly Fetched: "fetched";
16
+ readonly ProviderRejected: "providerRejected";
17
+ readonly InvalidResponse: "invalidResponse";
18
+ readonly Defect: "defect";
19
+ };
20
+ /** Alibaba Cloud returned its ECS regions. */
21
+ declare const DescribeRegionsBranchFetched: "fetched";
22
+ /** Alibaba Cloud rejected the credentials or request. */
23
+ declare const DescribeRegionsBranchProviderRejected: "providerRejected";
24
+ /** Alibaba Cloud returned malformed or oversized data. */
25
+ declare const DescribeRegionsBranchInvalidResponse: "invalidResponse";
26
+ /** Local connection configuration is invalid. */
27
+ declare const DescribeRegionsBranchDefect: "defect";
28
+ /** Manifest definition for describeRegions. */
29
+ declare const DescribeRegionsDefinition: QueryDefinition;
30
+ /** Manifest metadata for describeRegions. */
31
+ declare const DescribeRegionsMetadata: {
32
+ readonly kind: "query";
33
+ readonly idempotency: "none";
34
+ readonly authorization: "required";
35
+ };
36
+
37
+ /** Configuration for the describeRegions connector Step. */
38
+ interface DescribeRegionsStepConfig<StepInput, OperationInput = DescribeRegionsInput, OperationOutput = DescribeRegionsOutput> extends Omit<QueryStepConfig<StepInput, OperationInput, OperationOutput>, 'operation' | 'connection' | 'branches'> {
39
+ /** Named connection supplying this operation. */
40
+ connection: Connection<{
41
+ describeRegions(): Query<OperationInput, OperationOutput>;
42
+ }>;
43
+ /** Name matching the bound connection. */
44
+ connectionName: string;
45
+ /** Alibaba Cloud returned its ECS regions. */
46
+ fetched: StepTarget<QueryResult<OperationOutput>>;
47
+ /** Alibaba Cloud rejected the credentials or request. */
48
+ providerRejected?: StepTarget<QueryResult<OperationOutput>>;
49
+ /** Alibaba Cloud returned malformed or oversized data. */
50
+ invalidResponse?: StepTarget<QueryResult<OperationOutput>>;
51
+ /** Local connection configuration is invalid. */
52
+ defect?: StepTarget<QueryResult<OperationOutput>>;
53
+ }
54
+ /** Build the describeRegions Step from a named connection. */
55
+ declare function newDescribeRegionsStep<StepInput, OperationInput = DescribeRegionsInput, OperationOutput = DescribeRegionsOutput>(configuration: DescribeRegionsStepConfig<StepInput, OperationInput, OperationOutput>): QueryStep<StepInput, OperationInput, OperationOutput>;
56
+
57
+ /** Open one named Alibaba Cloud connection from Dex project configuration. */
58
+ declare function newProjectConnection(project: LoadedProject, connectionName: string): Connection<Operations>;
59
+
60
+ /** Send one ECS request through a caller-owned transport. */
61
+ type AlibabaRequestSender = (request: ProviderRequest) => Promise<ProviderResponse>;
62
+ /** Optional request dependencies for deterministic provider tests. */
63
+ interface AlibabaClientOptions {
64
+ /** Request sender; production uses the Connector SDK transport. */
65
+ send?: AlibabaRequestSender;
66
+ /** UTC request clock; production uses the current system time. */
67
+ clock?: () => Date;
68
+ /** Sixteen random nonce bytes; production uses cryptographic randomness. */
69
+ nonceSource?: () => Uint8Array;
70
+ }
71
+ /** Resolve Alibaba Cloud RAM credentials for each ECS query. */
72
+ declare class AlibabaClient {
73
+ readonly baseUrl: string;
74
+ readonly endpointHost: string;
75
+ readonly timeoutMs: number;
76
+ readonly maxResponseBytes: number;
77
+ readonly credentials: CredentialProvider<Credentials>;
78
+ readonly send: AlibabaRequestSender;
79
+ readonly clock: () => Date;
80
+ readonly nonceSource: () => Uint8Array;
81
+ /** Validate settings without contacting Alibaba Cloud. */
82
+ constructor(config: Config, credentials: CredentialProvider<Credentials>, options?: AlibabaClientOptions);
83
+ /** Bind the ECS region Query. */
84
+ describeRegions(): DescribeRegionsOperation;
85
+ }
86
+ /** List ECS regions without storing RAM credentials in Flow state. */
87
+ declare class DescribeRegionsOperation implements Query<DescribeRegionsInput, DescribeRegionsOutput> {
88
+ private readonly client;
89
+ /** Bind an authenticated Alibaba Cloud client. */
90
+ constructor(client: AlibabaClient);
91
+ /** Return the stable generated Query contract. */
92
+ definition(): QueryDefinition;
93
+ /** Sign, send, and classify one ECS DescribeRegions request. */
94
+ invoke(call: Call, input: DescribeRegionsInput): Promise<QueryAttempt<DescribeRegionsOutput>>;
95
+ }
96
+
97
+ export { AlibabaClient, type AlibabaClientOptions, type AlibabaRequestSender, Config, Connection, ConnectorID, Credentials, DescribeRegionsBranch, DescribeRegionsBranchDefect, DescribeRegionsBranchFetched, DescribeRegionsBranchInvalidResponse, DescribeRegionsBranchProviderRejected, DescribeRegionsDefinition, DescribeRegionsInput, DescribeRegionsMetadata, DescribeRegionsOperation, DescribeRegionsOutput, type DescribeRegionsStepConfig, ProviderID, newDescribeRegionsStep, newProjectConnection };
package/dist/index.js ADDED
@@ -0,0 +1,262 @@
1
+ import {
2
+ ConfigSchema,
3
+ Connection,
4
+ ConnectorID,
5
+ CredentialMaterialError,
6
+ DescribeRegionsBranch,
7
+ DescribeRegionsBranchDefect,
8
+ DescribeRegionsBranchFetched,
9
+ DescribeRegionsBranchInvalidResponse,
10
+ DescribeRegionsBranchProviderRejected,
11
+ DescribeRegionsDefinition,
12
+ DescribeRegionsInputSchema,
13
+ DescribeRegionsMetadata,
14
+ DescribeRegionsOutputSchema,
15
+ ECSRegionSchema,
16
+ ProviderID,
17
+ decodeCredentials,
18
+ isCredentialMaterialError,
19
+ newConnection,
20
+ newConnectionWithOperations,
21
+ newProjectConnection
22
+ } from "./chunk-OY7J2DIO.js";
23
+
24
+ // src/generated/steps.ts
25
+ import { goToBranch, newQueryStep } from "@superdurable/connectors-sdk";
26
+ function newDescribeRegionsStep(configuration) {
27
+ const { connection, connectionName, fetched, providerRejected, invalidResponse, defect, ...stepConfiguration } = configuration;
28
+ if (!connection || connection.reference.name !== connectionName) throw new TypeError("Step connection name differs from the bound connection");
29
+ return newQueryStep({ ...stepConfiguration, operation: connection.operations.describeRegions(), connection: connection.reference, branches: [
30
+ goToBranch("fetched", fetched),
31
+ ...providerRejected ? [goToBranch("providerRejected", providerRejected)] : [],
32
+ ...invalidResponse ? [goToBranch("invalidResponse", invalidResponse)] : [],
33
+ ...defect ? [goToBranch("defect", defect)] : []
34
+ ] });
35
+ }
36
+
37
+ // src/project.ts
38
+ import { SecretString as SecretString2 } from "@superdurable/connectors-sdk";
39
+ import { z } from "zod";
40
+
41
+ // src/client.ts
42
+ import { randomBytes } from "crypto";
43
+ import { SecretString, newQueryBranch, newQueryRetry } from "@superdurable/connectors-sdk";
44
+ import { BodyTooLargeError, parseRetryAfter, sendProviderRequest, validateBaseURL } from "@superdurable/connectors-sdk/providerhttp";
45
+
46
+ // src/signature.ts
47
+ import { createHash, createHmac } from "crypto";
48
+ var EmptyPayloadSHA256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
49
+ var SignedHeaderNames = "host;x-acs-action;x-acs-content-sha256;x-acs-date;x-acs-signature-nonce;x-acs-version";
50
+ function signACS3Request(secret, method, host, action, canonicalQuery, requestDate, nonce) {
51
+ const canonicalHeaders = `host:${host}
52
+ x-acs-action:${action}
53
+ x-acs-content-sha256:${EmptyPayloadSHA256}
54
+ x-acs-date:${requestDate}
55
+ x-acs-signature-nonce:${nonce}
56
+ x-acs-version:2014-05-26
57
+ `;
58
+ const canonicalRequest = `${method}
59
+ /
60
+ ${canonicalQuery}
61
+ ${canonicalHeaders}
62
+ ${SignedHeaderNames}
63
+ ${EmptyPayloadSHA256}`;
64
+ const digest = createHash("sha256").update(canonicalRequest, "utf8").digest("hex");
65
+ return createHmac("sha256", secret).update(`ACS3-HMAC-SHA256
66
+ ${digest}`, "utf8").digest("hex");
67
+ }
68
+
69
+ // src/client.ts
70
+ var emptyOutput = { regions: [] };
71
+ var AlibabaClient = class {
72
+ baseUrl;
73
+ endpointHost;
74
+ timeoutMs;
75
+ maxResponseBytes;
76
+ credentials;
77
+ send;
78
+ clock;
79
+ nonceSource;
80
+ /** Validate settings without contacting Alibaba Cloud. */
81
+ constructor(config, credentials, options = {}) {
82
+ if (!credentials) throw new TypeError("Alibaba Cloud credential source is required");
83
+ const baseUrl = validateBaseURL(config.baseUrl || "https://ecs.cn-hangzhou.aliyuncs.com");
84
+ const parsed = new URL(baseUrl);
85
+ if (parsed.pathname !== "/" || parsed.search || parsed.hash) throw new TypeError("Alibaba Cloud ECS base URL must be a host root");
86
+ this.baseUrl = baseUrl.replace(/\/$/, "");
87
+ this.endpointHost = parsed.host;
88
+ this.timeoutMs = config.timeoutMs || 1e4;
89
+ this.maxResponseBytes = config.maxResponseBytes || 1048576;
90
+ if (!Number.isSafeInteger(this.timeoutMs) || this.timeoutMs <= 0 || !Number.isSafeInteger(this.maxResponseBytes) || this.maxResponseBytes <= 0) throw new TypeError("Alibaba Cloud timeout and maxResponseBytes must be positive");
91
+ this.credentials = credentials;
92
+ this.send = options.send ?? sendProviderRequest;
93
+ this.clock = options.clock ?? (() => /* @__PURE__ */ new Date());
94
+ this.nonceSource = options.nonceSource ?? (() => randomBytes(16));
95
+ }
96
+ /** Bind the ECS region Query. */
97
+ describeRegions() {
98
+ return new DescribeRegionsOperation(this);
99
+ }
100
+ };
101
+ var DescribeRegionsOperation = class {
102
+ /** Bind an authenticated Alibaba Cloud client. */
103
+ constructor(client) {
104
+ this.client = client;
105
+ }
106
+ client;
107
+ /** Return the stable generated Query contract. */
108
+ definition() {
109
+ return DescribeRegionsDefinition;
110
+ }
111
+ /** Sign, send, and classify one ECS DescribeRegions request. */
112
+ async invoke(call, input) {
113
+ if (input === null || typeof input !== "object" || Array.isArray(input)) return branch("defect", "VALIDATION", "ECS request is invalid");
114
+ let credentials;
115
+ try {
116
+ credentials = await this.client.credentials.resolve(call, call.context.cancellationSignal);
117
+ } catch {
118
+ return branch("defect", "AUTHENTICATION", "connection credentials are unavailable or invalid");
119
+ }
120
+ const accessKeyId = credentials.accessKeyId instanceof SecretString ? credentials.accessKeyId.reveal() : "";
121
+ const accessKeySecret = credentials.accessKeySecret instanceof SecretString ? credentials.accessKeySecret.reveal() : "";
122
+ if (!isValidCredential(accessKeyId) || !isValidCredential(accessKeySecret)) return branch("defect", "AUTHENTICATION", "connection credentials are unavailable or invalid");
123
+ let nonce;
124
+ try {
125
+ const bytes = this.client.nonceSource();
126
+ if (bytes.length !== 16) throw new TypeError("nonce must contain sixteen bytes");
127
+ nonce = Buffer.from(bytes).toString("hex");
128
+ } catch {
129
+ return retry("AVAILABILITY", "request nonce unavailable");
130
+ }
131
+ const currentTime = this.client.clock();
132
+ if (Number.isNaN(currentTime.getTime())) return branch("defect", "VALIDATION", "ECS request date is invalid");
133
+ const requestDate = currentTime.toISOString().replace(/\.\d{3}Z$/, "Z");
134
+ const signature = signACS3Request(accessKeySecret, "GET", this.client.endpointHost, "DescribeRegions", "", requestDate, nonce);
135
+ const authorization = `ACS3-HMAC-SHA256 Credential=${accessKeyId},SignedHeaders=${SignedHeaderNames},Signature=${signature}`;
136
+ let response;
137
+ try {
138
+ response = await this.client.send({
139
+ url: `${this.client.baseUrl}/`,
140
+ method: "GET",
141
+ headers: {
142
+ "x-acs-action": "DescribeRegions",
143
+ "x-acs-content-sha256": EmptyPayloadSHA256,
144
+ "x-acs-date": requestDate,
145
+ "x-acs-signature-nonce": nonce,
146
+ "x-acs-version": "2014-05-26",
147
+ Authorization: authorization,
148
+ Accept: "application/json"
149
+ },
150
+ maxResponseBytes: this.client.maxResponseBytes,
151
+ timeoutMs: this.client.timeoutMs,
152
+ addressPolicy: this.client.baseUrl === "https://ecs.cn-hangzhou.aliyuncs.com" ? "publicHTTPS" : "privateNetworkHTTP",
153
+ signal: call.context.cancellationSignal
154
+ });
155
+ } catch (error) {
156
+ if (error instanceof BodyTooLargeError && error.status !== void 0) {
157
+ response = { status: error.status, headers: error.headers ?? {}, body: new Uint8Array() };
158
+ if (response.status !== 429 && response.status !== 408 && response.status < 500) return branch("invalidResponse", "RESPONSE_TOO_LARGE", "ECS response exceeded the configured limit");
159
+ } else return retry("AVAILABILITY", "ECS request failed");
160
+ }
161
+ const retryAfterHeader = response.headers["retry-after"];
162
+ const retryAfterMs = parseRetryAfter(Array.isArray(retryAfterHeader) ? retryAfterHeader[0] ?? "" : retryAfterHeader ?? "");
163
+ if (response.status === 429) return retry("RATE_LIMIT", "ECS rate limited the request", retryAfterMs);
164
+ if (response.status === 408 || response.status >= 500) return retry("AVAILABILITY", "ECS is temporarily unavailable", retryAfterMs);
165
+ let document;
166
+ try {
167
+ document = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(response.body));
168
+ } catch {
169
+ return branch("invalidResponse", "PROTOCOL", "ECS returned invalid JSON");
170
+ }
171
+ if (!isRecord(document) || document.Code !== void 0 && document.Code !== null && typeof document.Code !== "string") return branch("invalidResponse", "PROTOCOL", "ECS returned invalid JSON");
172
+ const code = typeof document.Code === "string" ? document.Code : "";
173
+ if (code.startsWith("Throttling")) return retry("RATE_LIMIT", "ECS rate limited the request", retryAfterMs);
174
+ if (code || response.status !== 200) return branch("providerRejected", "PROVIDER_REJECTION", "ECS rejected the regions request");
175
+ const regionsValue = document.Regions;
176
+ if (!isRecord(regionsValue) || !Array.isArray(regionsValue.Region)) return branch("invalidResponse", "PROTOCOL", "ECS omitted its regions list");
177
+ const regions = [];
178
+ for (const row of regionsValue.Region) {
179
+ if (!isRecord(row) || typeof row.RegionId !== "string" || !row.RegionId || typeof row.LocalName !== "string" || !row.LocalName || typeof row.RegionEndpoint !== "string" || !row.RegionEndpoint || row.Status !== "available" && row.Status !== "soldOut") {
180
+ return branch("invalidResponse", "PROTOCOL", "ECS returned an incomplete region");
181
+ }
182
+ regions.push({ regionId: row.RegionId, localName: row.LocalName, endpoint: row.RegionEndpoint, status: row.Status });
183
+ }
184
+ return newQueryBranch("fetched", { regions });
185
+ }
186
+ };
187
+ function isRecord(value) {
188
+ return typeof value === "object" && value !== null && !Array.isArray(value);
189
+ }
190
+ function isValidCredential(value) {
191
+ return /^[!-~]{1,512}$/.test(value);
192
+ }
193
+ function failure(kind, message) {
194
+ return { provider: "alibaba", operation: "describeRegions", kind, message };
195
+ }
196
+ function branch(id, kind, message) {
197
+ return newQueryBranch(id, emptyOutput, {}, failure(kind, message));
198
+ }
199
+ function retry(kind, message, delayMs = 0) {
200
+ return newQueryRetry(failure(kind, message), delayMs);
201
+ }
202
+
203
+ // src/project.ts
204
+ function newProjectConnection2(project, connectionName) {
205
+ return newProjectConnection(project, connectionName, (loadedProject, name) => {
206
+ const selected = loadedProject.configuration.connections.find((entry) => entry.connectorId === "alibaba" && entry.connectionName === name);
207
+ if (!selected) throw new TypeError("Alibaba Cloud project connection is not configured");
208
+ const fields = z.strictObject({ baseUrl: z.string().optional(), timeout: z.union([z.string(), z.number().int()]).optional(), maxResponseBytes: z.number().int().optional() }).parse(selected.configuration);
209
+ const timeoutMs = typeof fields.timeout === "number" ? Math.ceil(fields.timeout / 1e6) : fields.timeout ? parseDurationMilliseconds(fields.timeout) : void 0;
210
+ const config = {
211
+ ...fields.baseUrl !== void 0 ? { baseUrl: fields.baseUrl } : {},
212
+ ...timeoutMs !== void 0 ? { timeoutMs } : {},
213
+ ...fields.maxResponseBytes !== void 0 ? { maxResponseBytes: fields.maxResponseBytes } : {}
214
+ };
215
+ const credentials = {
216
+ async resolve(_call, signal) {
217
+ const privateFields = await loadedProject.resolveCredential("alibaba", name, signal);
218
+ if (typeof privateFields.access_key_id !== "string" || typeof privateFields.access_key_secret !== "string") throw new TypeError("Alibaba Cloud RAM credentials are unavailable");
219
+ return { accessKeyId: new SecretString2(privateFields.access_key_id), accessKeySecret: new SecretString2(privateFields.access_key_secret) };
220
+ }
221
+ };
222
+ return new AlibabaClient(config, credentials);
223
+ });
224
+ }
225
+ function parseDurationMilliseconds(value) {
226
+ let remaining = value;
227
+ let milliseconds = 0;
228
+ const units = { ns: 1e-6, us: 1e-3, "\xB5s": 1e-3, ms: 1, s: 1e3, m: 6e4, h: 36e5 };
229
+ while (remaining) {
230
+ const part = /^(\d+(?:\.\d+)?)(ns|us|µs|ms|s|m|h)/.exec(remaining);
231
+ if (!part) throw new TypeError("Alibaba Cloud timeout must be a positive Go duration");
232
+ milliseconds += Number(part[1]) * (units[part[2] ?? ""] ?? NaN);
233
+ remaining = remaining.slice(part[0].length);
234
+ }
235
+ if (!Number.isSafeInteger(milliseconds) || milliseconds <= 0) throw new TypeError("Alibaba Cloud timeout must resolve to positive whole milliseconds");
236
+ return milliseconds;
237
+ }
238
+ export {
239
+ AlibabaClient,
240
+ ConfigSchema,
241
+ Connection,
242
+ ConnectorID,
243
+ CredentialMaterialError,
244
+ DescribeRegionsBranch,
245
+ DescribeRegionsBranchDefect,
246
+ DescribeRegionsBranchFetched,
247
+ DescribeRegionsBranchInvalidResponse,
248
+ DescribeRegionsBranchProviderRejected,
249
+ DescribeRegionsDefinition,
250
+ DescribeRegionsInputSchema,
251
+ DescribeRegionsMetadata,
252
+ DescribeRegionsOperation,
253
+ DescribeRegionsOutputSchema,
254
+ ECSRegionSchema,
255
+ ProviderID,
256
+ decodeCredentials,
257
+ isCredentialMaterialError,
258
+ newConnection,
259
+ newConnectionWithOperations,
260
+ newDescribeRegionsStep,
261
+ newProjectConnection2 as newProjectConnection
262
+ };
package/dist/mock.d.ts ADDED
@@ -0,0 +1,35 @@
1
+ import { MockQuery, Case } from '@superdurable/connectors-sdk/connectormock';
2
+ import { Failure } from '@superdurable/connectors-sdk';
3
+ import { O as Operations, C as Connection, D as DescribeRegionsInput, a as DescribeRegionsOutput, E as ECSRegion } from './connection-DFvkFolN.js';
4
+ import 'zod';
5
+
6
+ /** Go zero value for DescribeRegionsInput in scripted cases. */
7
+ declare const emptyDescribeRegionsInput: DescribeRegionsInput;
8
+ /** Go zero value for ECSRegion in scripted cases. */
9
+ declare const emptyECSRegion: ECSRegion;
10
+ /** Go zero value for DescribeRegionsOutput in scripted cases. */
11
+ declare const emptyDescribeRegionsOutput: DescribeRegionsOutput;
12
+ /** Script the fetched branch. */
13
+ declare function describeRegionsFetched(value: DescribeRegionsOutput, failure?: Failure): Case<DescribeRegionsOutput>;
14
+ /** Script the providerRejected branch. */
15
+ declare function describeRegionsProviderRejected(value: DescribeRegionsOutput, failure?: Failure): Case<DescribeRegionsOutput>;
16
+ /** Script the invalidResponse branch. */
17
+ declare function describeRegionsInvalidResponse(value: DescribeRegionsOutput, failure?: Failure): Case<DescribeRegionsOutput>;
18
+ /** Script the defect branch. */
19
+ declare function describeRegionsDefect(value: DescribeRegionsOutput, failure?: Failure): Case<DescribeRegionsOutput>;
20
+ /** Script a safe retry of describeRegions. */
21
+ declare function describeRegionsRetry(failure: Failure, retryAfterMs?: number): Case<DescribeRegionsOutput>;
22
+ /** Manifest scenario sampleRegions for describeRegions. */
23
+ declare function describeRegionsSampleRegions(): Case<DescribeRegionsOutput>;
24
+ /** Default describeRegions scenario. */
25
+ declare function describeRegionsDefault(): Case<DescribeRegionsOutput>;
26
+ /** Scripted operations and manifest defaults for this connector. */
27
+ declare class GeneratedMock implements Operations {
28
+ #private;
29
+ constructor(connectionName: string);
30
+ connection(): Connection;
31
+ describeRegions(): MockQuery<DescribeRegionsInput, DescribeRegionsOutput>;
32
+ assertNoFailures(): void;
33
+ }
34
+
35
+ export { GeneratedMock, GeneratedMock as Mock, describeRegionsDefault, describeRegionsDefect, describeRegionsFetched, describeRegionsInvalidResponse, describeRegionsProviderRejected, describeRegionsRetry, describeRegionsSampleRegions, emptyDescribeRegionsInput, emptyDescribeRegionsOutput, emptyECSRegion };
package/dist/mock.js ADDED
@@ -0,0 +1,74 @@
1
+ import {
2
+ DescribeRegionsDefinition,
3
+ DescribeRegionsInputSchema,
4
+ DescribeRegionsOutputSchema,
5
+ ECSRegionSchema,
6
+ ProviderID,
7
+ newConnectionWithOperations
8
+ } from "./chunk-OY7J2DIO.js";
9
+
10
+ // src/generated/mock.ts
11
+ import { branchCase, retryCase, newQuery } from "@superdurable/connectors-sdk/connectormock";
12
+ var emptyDescribeRegionsInput = DescribeRegionsInputSchema.parse({});
13
+ var emptyECSRegion = ECSRegionSchema.parse({
14
+ "regionId": "",
15
+ "localName": "",
16
+ "endpoint": "",
17
+ "status": ""
18
+ });
19
+ var emptyDescribeRegionsOutput = DescribeRegionsOutputSchema.parse({
20
+ "regions": []
21
+ });
22
+ function describeRegionsFetched(value, failure) {
23
+ return branchCase("fetched", value, failure);
24
+ }
25
+ function describeRegionsProviderRejected(value, failure) {
26
+ return branchCase("providerRejected", value, failure);
27
+ }
28
+ function describeRegionsInvalidResponse(value, failure) {
29
+ return branchCase("invalidResponse", value, failure);
30
+ }
31
+ function describeRegionsDefect(value, failure) {
32
+ return branchCase("defect", value, failure);
33
+ }
34
+ function describeRegionsRetry(failure, retryAfterMs = 0) {
35
+ return retryCase(failure, retryAfterMs);
36
+ }
37
+ function describeRegionsSampleRegions() {
38
+ const value = DescribeRegionsOutputSchema.parse({ "regions": [{ "endpoint": "ecs.cn-hangzhou.aliyuncs.com", "localName": "\u534E\u4E1C1\uFF08\u676D\u5DDE\uFF09", "regionId": "cn-hangzhou", "status": "available" }] });
39
+ return branchCase("fetched", value);
40
+ }
41
+ function describeRegionsDefault() {
42
+ return describeRegionsSampleRegions();
43
+ }
44
+ var GeneratedMock = class {
45
+ #describeRegions;
46
+ #connection;
47
+ constructor(connectionName) {
48
+ this.#describeRegions = newQuery(DescribeRegionsDefinition).default(describeRegionsDefault());
49
+ this.#connection = newConnectionWithOperations(this, { provider: ProviderID, name: connectionName });
50
+ }
51
+ connection() {
52
+ return this.#connection;
53
+ }
54
+ describeRegions() {
55
+ return this.#describeRegions;
56
+ }
57
+ assertNoFailures() {
58
+ this.#describeRegions.assertNoFailures();
59
+ }
60
+ };
61
+ export {
62
+ GeneratedMock,
63
+ GeneratedMock as Mock,
64
+ describeRegionsDefault,
65
+ describeRegionsDefect,
66
+ describeRegionsFetched,
67
+ describeRegionsInvalidResponse,
68
+ describeRegionsProviderRejected,
69
+ describeRegionsRetry,
70
+ describeRegionsSampleRegions,
71
+ emptyDescribeRegionsInput,
72
+ emptyDescribeRegionsOutput,
73
+ emptyECSRegion
74
+ };
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
2
  "name": "@superdurable/connector-alibaba",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "description": "Alibaba Cloud ECS connector for Dex TypeScript applications",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/superdurable/dex-connectors-library.git",
9
+ "directory": "connectors/alibaba/typescript"
10
+ },
11
+ "type": "module",
12
+ "engines": {
13
+ "node": "^22.0.0 || ^24.0.0"
14
+ },
15
+ "module": "./dist/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js"
21
+ },
22
+ "./mock": {
23
+ "types": "./dist/mock.d.ts",
24
+ "import": "./dist/mock.js"
25
+ },
26
+ "./dex-connector.json": "./dex-connector.json"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "README.md",
31
+ "LICENSE",
32
+ "dex-connector.json"
33
+ ],
34
+ "scripts": {
35
+ "prepack": "npm run build",
36
+ "build": "tsup src/index.ts src/mock.ts --format esm --dts --clean",
37
+ "typecheck": "tsc --noEmit",
38
+ "lint": "eslint src test examples",
39
+ "test": "vitest run --exclude test/integration/**",
40
+ "test:integration": "vitest run test/integration/*.integration.test.ts",
41
+ "check": "npm run typecheck && npm run lint && npm test && npm run build",
42
+ "example:worker": "tsx examples/regions/worker.ts",
43
+ "example:start": "tsx examples/regions/start.ts"
44
+ },
45
+ "dependencies": {
46
+ "@superdurable/connectors-sdk": "0.11.0",
47
+ "@superdurable/dex": ">=1.28.0",
48
+ "zod": "^4.1.0"
49
+ },
50
+ "devDependencies": {
51
+ "@eslint/js": "^9.0.0",
52
+ "@types/node": "^22.0.0",
53
+ "eslint": "^9.0.0",
54
+ "tsup": "^8.0.0",
55
+ "tsx": "^4.23.15",
56
+ "typescript": "^5.9.0",
57
+ "typescript-eslint": "^8.0.0",
58
+ "vitest": "^3.0.0",
59
+ "yaml": "^2.9.1"
60
+ }
61
+ }