@superdurable/connector-cloopen 0.1.0 → 0.1.1

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.
@@ -4,7 +4,7 @@
4
4
  "package": {
5
5
  "ecosystem": "npm",
6
6
  "name": "@superdurable/connector-cloopen",
7
- "version": "0.1.0"
7
+ "version": "0.1.1"
8
8
  },
9
9
  "factories": [
10
10
  {
@@ -18,7 +18,7 @@ declare const ConfigSchema: z.ZodObject<{
18
18
  }, z.core.$strip>;
19
19
  /** Private connector credentials resolved by the host. */
20
20
  interface Credentials {
21
- /** Main-account ACCOUNT SID from https://console.yuntongxun.com > management console > account information. Copy the exact 32-character alphanumeric ID; it is placed in the API path and signed header. Blank prevents requests. */
21
+ /** Secret main-account ACCOUNT SID from https://console.yuntongxun.com > management console > account information. Copy the exact 32-character alphanumeric ID; it is placed in the API path and signed header. Blank prevents requests. */
22
22
  accountSid: SecretString;
23
23
  /** Main-account AUTH TOKEN from https://console.yuntongxun.com > management console > account information. Copy the exact 32-character secret; it is used only to create the request signature. Blank prevents requests. */
24
24
  authToken: SecretString;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { G as GetBalanceInput, a as GetBalanceOutput, C as Connection, b as Config, c as Credentials, O as Operations } from './connection-DSueiu_K.js';
2
- export { d as ConfigSchema, e as CredentialMaterialError, f as CredentialSource, g as GetBalanceInputSchema, h as GetBalanceOutputSchema, i as decodeCredentials, j as isCredentialMaterialError, n as newConnection, k as newConnectionWithOperations } from './connection-DSueiu_K.js';
1
+ import { G as GetBalanceInput, a as GetBalanceOutput, C as Connection, b as Config, c as Credentials, O as Operations } from './connection-utPMl6ey.js';
2
+ export { d as ConfigSchema, e as CredentialMaterialError, f as CredentialSource, g as GetBalanceInputSchema, h as GetBalanceOutputSchema, i as decodeCredentials, j as isCredentialMaterialError, n as newConnection, k as newConnectionWithOperations } from './connection-utPMl6ey.js';
3
3
  import { QueryDefinition, QueryStepConfig, Query, QueryResult, QueryStep, CredentialProvider, Call, QueryAttempt, Failure } from '@superdurable/connectors-sdk';
4
4
  import { StepTarget } from '@superdurable/dex';
5
5
  import { LoadedProject } from '@superdurable/connectors-sdk/projectconfig';
package/dist/index.js CHANGED
@@ -122,23 +122,27 @@ var GetBalanceOperation = class {
122
122
  if (response.status !== 200) return terminal("providerRejected", httpFailureKind(response.status), "Cloopen rejected the account lookup");
123
123
  let wire;
124
124
  try {
125
- wire = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(response.body));
125
+ wire = JSON.parse(new TextDecoder().decode(response.body), (_name, value) => isRecord(value) ? Object.fromEntries(Object.entries(value).map(([name, field]) => [name.toLowerCase(), field])) : value);
126
126
  } catch {
127
127
  return terminal("invalidResponse", "PROTOCOL", "Cloopen returned an invalid account response");
128
128
  }
129
- if (!wire || typeof wire !== "object" || Array.isArray(wire)) return terminal("invalidResponse", "PROTOCOL", "Cloopen returned an invalid account response");
130
- const fields = wire;
131
- const statusCode = fields.statusCode;
129
+ if (!isRecord(wire)) return terminal("invalidResponse", "PROTOCOL", "Cloopen returned an invalid account response");
130
+ const statusCode = wire.statuscode;
131
+ const account = wire.account;
132
+ if (account != null && !isRecord(account)) return terminal("invalidResponse", "PROTOCOL", "Cloopen returned an invalid account response");
133
+ const balance = account?.balance;
134
+ if (balance != null && typeof balance !== "string") return terminal("invalidResponse", "PROTOCOL", "Cloopen returned an invalid balance");
132
135
  if (typeof statusCode !== "string" || !statusCode) return terminal("invalidResponse", "PROTOCOL", "Cloopen returned an invalid account response");
133
136
  if (statusCode === "111111") return newQueryRetry(failure("RATE_LIMIT", "Cloopen concurrency limit reached"));
134
137
  if (statusCode.startsWith("1110")) return newQueryRetry(failure("AVAILABILITY", "Cloopen reported an internal failure"));
135
138
  if (statusCode !== "000000") return terminal("providerRejected", "PROVIDER_REJECTION", "Cloopen rejected the account lookup");
136
- if (!fields.Account || typeof fields.Account !== "object" || Array.isArray(fields.Account)) return terminal("invalidResponse", "PROTOCOL", "Cloopen returned an invalid balance");
137
- const balance = fields.Account.balance;
138
139
  if (typeof balance !== "string" || balance.length > 64 || !/^(0|[1-9][0-9]*)(\.[0-9]+)?$/.test(balance)) return terminal("invalidResponse", "PROTOCOL", "Cloopen returned an invalid balance");
139
140
  return newQueryBranch("fetched", { balance });
140
141
  }
141
142
  };
143
+ function isRecord(value) {
144
+ return typeof value === "object" && value !== null && !Array.isArray(value);
145
+ }
142
146
  function validAccountSid(value) {
143
147
  return /^[A-Za-z0-9]{32}$/.test(value);
144
148
  }
package/dist/mock.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { MockQuery, Case } from '@superdurable/connectors-sdk/connectormock';
2
2
  import { Failure } from '@superdurable/connectors-sdk';
3
- import { O as Operations, C as Connection, G as GetBalanceInput, a as GetBalanceOutput } from './connection-DSueiu_K.js';
3
+ import { O as Operations, C as Connection, G as GetBalanceInput, a as GetBalanceOutput } from './connection-utPMl6ey.js';
4
4
  import 'zod';
5
5
 
6
6
  /** Go zero value for GetBalanceInput in scripted cases. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdurable/connector-cloopen",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "license": "MIT",
5
5
  "description": "Cloopen main-account balance connector for Dex TypeScript applications",
6
6
  "repository": {