eoas 3.1.2-beta4 → 3.1.2

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.
@@ -249,7 +249,7 @@ async function requestUploadUrls({ body, requestUploadUrl, auth, runtimeVersion,
249
249
  }
250
250
  if (!response.ok) {
251
251
  const text = await response.text();
252
- throw new Error(`Failed to request upload URL: ${text}`);
252
+ throw new Error(`Failed to request upload URL: ${text}${(0, auth_1.missingEooTokenHint)(response.status)}`);
253
253
  }
254
254
  const json = await response.json();
255
255
  // Joi's sanitized value, not the raw payload: it is the object the schema
@@ -4,6 +4,7 @@ export interface Credentials {
4
4
  sessionSecret?: string;
5
5
  }
6
6
  export declare function detectServerImplementation(): ServerImplementation;
7
+ export declare function missingEooTokenHint(status: number): string;
7
8
  export declare function retrieveCredentials(): Credentials;
8
9
  export declare function validateCredentials(credentials: Credentials): boolean;
9
10
  export declare function retrieveExpoCredentials(): Credentials;
package/dist/lib/auth.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAuthHeaders = exports.retrieveExpoCredentials = exports.validateCredentials = exports.retrieveCredentials = exports.detectServerImplementation = void 0;
3
+ exports.getAuthHeaders = exports.retrieveExpoCredentials = exports.validateCredentials = exports.retrieveCredentials = exports.missingEooTokenHint = exports.detectServerImplementation = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const os_1 = require("os");
6
6
  const path_1 = tslib_1.__importDefault(require("path"));
@@ -8,6 +8,15 @@ function detectServerImplementation() {
8
8
  return process.env.EOO_TOKEN ? 'eoo' : 'expo';
9
9
  }
10
10
  exports.detectServerImplementation = detectServerImplementation;
11
+ // A 401 in expo mode may mean the server only accepts its own dashboard
12
+ // tokens; the CLI cannot know the server's mode, so it can only hint.
13
+ function missingEooTokenHint(status) {
14
+ if (status !== 401 || detectServerImplementation() !== 'expo') {
15
+ return '';
16
+ }
17
+ return '\nHint: servers running with a database control plane (DB_URL set) issue their own CLI tokens and do not accept EXPO_TOKEN — generate a token in the dashboard and set EOO_TOKEN.';
18
+ }
19
+ exports.missingEooTokenHint = missingEooTokenHint;
11
20
  function retrieveCredentials() {
12
21
  const serverImplementation = detectServerImplementation();
13
22
  if (serverImplementation === 'eoo') {
@@ -31,7 +31,12 @@ async function fetchUpdates({ baseUrl, appId, branch, runtimeVersion, credential
31
31
  if (!response.ok) {
32
32
  throw new Error(`Failed to fetch updates: ${await response.text()}`);
33
33
  }
34
- return (await response.json());
34
+ const body = (await response.json());
35
+ // Servers older than v3.1.2 return a bare array instead of a page.
36
+ if (Array.isArray(body)) {
37
+ return { items: body, nextCursor: null };
38
+ }
39
+ return body;
35
40
  }
36
41
  exports.fetchUpdates = fetchUpdates;
37
42
  // Publish groups only exist in control-plane mode. A 404 marks group mode as
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eoas",
3
- "version": "3.1.2-beta4",
3
+ "version": "3.1.2",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "build": "tsc --project tsconfig.json",