@devicecloud.dev/dcd 5.11.0-beta.8 → 5.11.0-beta.9

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.
@@ -242,11 +242,7 @@ export const cloudCommand = defineCommand({
242
242
  const ciContext = detectCiContext();
243
243
  let compatibilityData;
244
244
  try {
245
- compatibilityData = await fetchCompatibilityData(apiUrl, auth, {
246
- cliVersion,
247
- ciProvider: ciContext.provider,
248
- ciWrapperVersion: ciContext.wrapperVersion,
249
- });
245
+ compatibilityData = await fetchCompatibilityData(apiUrl, auth);
250
246
  if (debug) {
251
247
  out('[DEBUG] Successfully fetched compatibility data from API');
252
248
  }
@@ -6,8 +6,7 @@ import { outputFlags } from '../config/flags/output.flags.js';
6
6
  import { uploadBinary, verifyAppZip } from '../methods.js';
7
7
  import { telemetry } from '../services/telemetry.service.js';
8
8
  import { resolveAuth } from '../utils/auth.js';
9
- import { detectCiContext } from '../utils/ci.js';
10
- import { CliError, getCliVersion, logger } from '../utils/cli.js';
9
+ import { CliError, logger } from '../utils/cli.js';
11
10
  import { fetchCompatibilityData } from '../utils/compatibility.js';
12
11
  import { resolveApiUrl } from '../utils/config-store.js';
13
12
  import { checkKekForEncryption, resolveEncryption } from '../utils/envelope.js';
@@ -56,12 +55,7 @@ export const uploadCommand = defineCommand({
56
55
  // failed fetch leaves the default off rather than failing the upload.
57
56
  let serverDefault;
58
57
  try {
59
- const ciContext = detectCiContext();
60
- const compatibilityData = await fetchCompatibilityData(apiUrl, auth, {
61
- cliVersion: getCliVersion(),
62
- ciProvider: ciContext.provider,
63
- ciWrapperVersion: ciContext.wrapperVersion,
64
- });
58
+ const compatibilityData = await fetchCompatibilityData(apiUrl, auth);
65
59
  serverDefault = compatibilityData.encryption?.defaultOn;
66
60
  }
67
61
  catch (error) {
@@ -1,7 +1,6 @@
1
1
  import { rm } from 'node:fs/promises';
2
2
  import { uploadBinary, verifyAppZip } from '../methods.js';
3
- import { detectCiContext } from './ci.js';
4
- import { CliError, getCliVersion } from './cli.js';
3
+ import { CliError } from './cli.js';
5
4
  import { fetchCompatibilityData } from './compatibility.js';
6
5
  import { checkKekForEncryption, resolveEncryption } from './envelope.js';
7
6
  import { extractTarGz, findAppBundle } from './expo.js';
@@ -31,12 +30,7 @@ export async function uploadLocalApp(opts) {
31
30
  // rather than failing the upload.
32
31
  let serverDefault;
33
32
  try {
34
- const ci = detectCiContext();
35
- const compatibility = await fetchCompatibilityData(apiUrl, auth, {
36
- cliVersion: getCliVersion(),
37
- ciProvider: ci.provider,
38
- ciWrapperVersion: ci.wrapperVersion,
39
- });
33
+ const compatibility = await fetchCompatibilityData(apiUrl, auth);
40
34
  serverDefault = compatibility.encryption?.defaultOn;
41
35
  }
42
36
  catch {
@@ -2,6 +2,7 @@
2
2
  * Resolves which credential a command should use and returns the fetch headers
3
3
  * to send. Precedence: --api-key flag > DEVICE_CLOUD_API_KEY env > stored
4
4
  * Supabase session (refreshed if near expiry). Throws CliError if none found.
5
+ * The headers also carry the CLI's own identity (see clientHeaders).
5
6
  *
6
7
  * The refresh path writes the rotated tokens back to disk atomically. Callers
7
8
  * resolve once per invocation, not per request — except where a process can
@@ -11,7 +12,8 @@
11
12
  import { closeSync, openSync, rmSync, statSync } from 'node:fs';
12
13
  import { CliAuthGateway, SessionRefreshError, } from '../gateways/cli-auth-gateway.js';
13
14
  import { telemetry } from '../services/telemetry.service.js';
14
- import { CliError } from './cli.js';
15
+ import { detectCiContext } from './ci.js';
16
+ import { CliError, getCliVersion } from './cli.js';
15
17
  import { getConfigPath, readConfig, writeConfig, } from './config-store.js';
16
18
  const REFRESH_SKEW_SECONDS = 60;
17
19
  // Refresh lock tuning: a refresh is a single HTTP round-trip, so anything
@@ -31,13 +33,30 @@ export function apiKeyOverride(apiKeyFlag) {
31
33
  return 'DEVICE_CLOUD_API_KEY';
32
34
  return undefined;
33
35
  }
36
+ /**
37
+ * Who is calling, sent with every request next to the credential: the API
38
+ * targets notices by it and records it on each upload and binary.
39
+ * The CI headers are sent only when a DCD wrapper forwarded them or the
40
+ * provider could be inferred.
41
+ */
42
+ function clientHeaders() {
43
+ const headers = {
44
+ 'x-dcd-cli-version': getCliVersion(),
45
+ };
46
+ const ci = detectCiContext();
47
+ if (ci.provider)
48
+ headers['x-dcd-ci-provider'] = ci.provider;
49
+ if (ci.wrapperVersion)
50
+ headers['x-dcd-ci-wrapper-version'] = ci.wrapperVersion;
51
+ return headers;
52
+ }
34
53
  export async function resolveAuth(opts) {
35
54
  if (!opts.sessionOnly) {
36
55
  const flag = opts.apiKeyFlag?.trim();
37
56
  if (flag) {
38
57
  const auth = {
39
58
  mode: 'apiKey',
40
- headers: { 'x-app-api-key': flag },
59
+ headers: { ...clientHeaders(), 'x-app-api-key': flag },
41
60
  };
42
61
  telemetry.configure({ auth });
43
62
  return auth;
@@ -46,7 +65,7 @@ export async function resolveAuth(opts) {
46
65
  if (env) {
47
66
  const auth = {
48
67
  mode: 'apiKey',
49
- headers: { 'x-app-api-key': env },
68
+ headers: { ...clientHeaders(), 'x-app-api-key': env },
50
69
  };
51
70
  telemetry.configure({ auth });
52
71
  return auth;
@@ -75,6 +94,7 @@ export async function resolveAuth(opts) {
75
94
  orgId: config.current_org_id,
76
95
  userEmail: session.user_email,
77
96
  headers: {
97
+ ...clientHeaders(),
78
98
  authorization: `Bearer ${session.access_token}`,
79
99
  'x-dcd-org': config.current_org_id,
80
100
  },
@@ -19,11 +19,9 @@ export interface CompatibilityData {
19
19
  defaultOn: boolean;
20
20
  };
21
21
  }
22
- /** Identity the CLI forwards so the API can target notices by version / CI. */
23
- export interface ClientContext {
24
- cliVersion?: string;
25
- ciProvider?: string | null;
26
- ciWrapperVersion?: string | null;
27
- }
28
- export declare function fetchCompatibilityData(apiUrl: string, auth: AuthContext, clientContext?: ClientContext): Promise<CompatibilityData>;
22
+ /**
23
+ * The CLI / CI identity the API version-filters and targets notices by rides
24
+ * on `auth.headers`, like on every other request (see resolveAuth).
25
+ */
26
+ export declare function fetchCompatibilityData(apiUrl: string, auth: AuthContext): Promise<CompatibilityData>;
29
27
  export declare function clearCompatibilityCache(): void;
@@ -1,25 +1,17 @@
1
1
  let cachedCompatibilityData = null;
2
- export async function fetchCompatibilityData(apiUrl, auth, clientContext) {
2
+ /**
3
+ * The CLI / CI identity the API version-filters and targets notices by rides
4
+ * on `auth.headers`, like on every other request (see resolveAuth).
5
+ */
6
+ export async function fetchCompatibilityData(apiUrl, auth) {
3
7
  if (cachedCompatibilityData) {
4
8
  return cachedCompatibilityData;
5
9
  }
6
- // Forward CLI / CI identity so the API can version-filter and target notices.
7
- const noticeHeaders = {};
8
- if (clientContext?.cliVersion) {
9
- noticeHeaders['x-dcd-cli-version'] = clientContext.cliVersion;
10
- }
11
- if (clientContext?.ciProvider) {
12
- noticeHeaders['x-dcd-ci-provider'] = clientContext.ciProvider;
13
- }
14
- if (clientContext?.ciWrapperVersion) {
15
- noticeHeaders['x-dcd-ci-wrapper-version'] = clientContext.ciWrapperVersion;
16
- }
17
10
  try {
18
11
  const response = await fetch(`${apiUrl}/results/compatibility/data`, {
19
12
  headers: {
20
13
  'Content-Type': 'application/json',
21
14
  ...auth.headers,
22
- ...noticeHeaders,
23
15
  },
24
16
  method: 'GET',
25
17
  });
@@ -5,8 +5,7 @@ import { DeviceGateway } from '../gateways/device-gateway.js';
5
5
  import { compressFilesFromRelativePath } from '../methods.js';
6
6
  import { resolveIncludedPaths } from '../services/execution-plan.service.js';
7
7
  import { isWorkspaceConfigFile, loadWorkspaceConfig, processDependencies, readTestYamlFileAsJson, } from '../services/execution-plan.utils.js';
8
- import { detectCiContext } from './ci.js';
9
- import { CliError, getCliVersion } from './cli.js';
8
+ import { CliError } from './cli.js';
10
9
  import { fetchCompatibilityData } from './compatibility.js';
11
10
  import { checkKekForEncryption, encryptFlowBuffer, resolveEncryption, resolveKekPublicKey, } from './envelope.js';
12
11
  /** The API's limit on a bundle (dcd plan 2.5b). */
@@ -127,12 +126,7 @@ export async function uploadFlowBundle(opts) {
127
126
  const zip = await compressFilesFromRelativePath(dir, files, '');
128
127
  let serverDefault;
129
128
  try {
130
- const ci = detectCiContext();
131
- const compatibility = await fetchCompatibilityData(apiUrl, auth, {
132
- cliVersion: getCliVersion(),
133
- ciProvider: ci.provider,
134
- ciWrapperVersion: ci.wrapperVersion,
135
- });
129
+ const compatibility = await fetchCompatibilityData(apiUrl, auth);
136
130
  serverDefault = compatibility.encryption?.defaultOn;
137
131
  }
138
132
  catch {
package/package.json CHANGED
@@ -68,7 +68,7 @@
68
68
  "test:unit": "node scripts/test-runner.mjs --unit",
69
69
  "typecheck": "tsc --noEmit -p tsconfig.test.json"
70
70
  },
71
- "version": "5.11.0-beta.8",
71
+ "version": "5.11.0-beta.9",
72
72
  "bugs": {
73
73
  "url": "https://discord.gg/gm3mJwcNw8"
74
74
  },