Fix the EvenHub login form sizing and missing cancel button

This commit is contained in:
James Babcock committed 2026-09-25 01:56:52 -07:00
1 parent 90d60cee10
commit 09a59b9821
8 files changed
+269 -96

No files matched your search

+2 -1
View File
@@ -12,11 +12,12 @@
* Depth effects for the window switcher, top bar, and modals
* Glanceboard has configurable distance
### Other Features
### Other Features and Bugfixes
* Add tokens and faceclaw-input script, which allows using a CLI utility as an input device for the glasses
* Navigate app: Add map-without-destination mode
* Nightscout app: Glanceboard widget still shows out-of-bounds values when out of space
* EvenHub: Fix login form being stuck open without a cancel button
### iOS port:
+16 -8
View File
@@ -181,12 +181,18 @@ export class EvenHubApiClient {
path: string,
options: { query?: Record<string, string | number>; body?: Record<string, unknown> } = {},
): Promise<unknown> {
let token = await this.ensureLogin();
const token = await this.ensureLogin();
const response = await this.request(method, path, { ...options, token, commonVersion: 3 });
if (response.httpStatus === 401) {
invalidateEvenHubToken();
try {
return unwrap(response.envelope, response.httpStatus, path);
} catch (error) {
// A rejected session fails every later request too, so drop the token
// (unless a fresh sign-in replaced it while this request was in flight).
if (error instanceof EvenHubAuthenticationError && getEvenHubToken() === token) {
invalidateEvenHubToken();
}
throw error;
}
return unwrap(response.envelope, response.httpStatus, path);
}
private ensureLogin(): Promise<string> {
@@ -350,15 +356,17 @@ async function fetchWithTimeout(url: string, init: RequestInit, timeoutMs = REQU
}
function unwrap(envelope: ApiEnvelope, httpStatus: number, path: string): unknown {
if (httpStatus === 401) {
throw new EvenHubAuthenticationError("Even rejected the login session.");
const message = typeof envelope.msg === "string" ? envelope.msg.trim() : "";
// An expired session can come back as HTTP 401, or as HTTP 200 with code
// 401 in the envelope ("Your login is expired").
if (httpStatus === 401 || Number(envelope.code) === 401) {
throw new EvenHubAuthenticationError(message || "Even rejected the login session.");
}
if (httpStatus < 200 || httpStatus >= 300) {
throw new Error(`EvenHub request failed (HTTP ${httpStatus}, ${path}).`);
}
if (envelope.code !== 0) {
const detail = typeof envelope.msg === "string" && envelope.msg ? `: ${envelope.msg}` : "";
throw new Error(`EvenHub API error ${envelope.code ?? "unknown"}${detail}`);
throw new Error(`EvenHub API error ${envelope.code ?? "unknown"}${message ? `: ${message}` : ""}`);
}
return envelope.data;
}
+5
View File
@@ -26,6 +26,8 @@ export type EvenHubStoreDetailOptions = {
appendLog: (message: string) => void;
/** A package was installed, updated, or reinstalled from this page. */
onInstalled?: (app: InstalledEvenHubApp) => void;
/** Offered every failure first; returns true if it was a rejected session (and was dealt with). */
onAuthError?: (ctx: LayerContext, error: unknown) => boolean;
};
/** Storefront metadata and the Install/Launch action for one public app. */
@@ -170,6 +172,7 @@ export class EvenHubStoreDetailLayer implements Layer {
await this.install(ctx);
} catch (error) {
if (this.options.onAuthError?.(ctx, error)) return;
this.status = cleanError(error);
this.options.appendLog(`evenhub store: ${this.status}`);
} finally { this.working = false; ctx.actions.requestRender(); }
@@ -203,6 +206,7 @@ export class EvenHubStoreDetailLayer implements Layer {
ctx.actions.requestRender();
await this.options.launchApp(installedEvenHubAppId(result.packageId));
} catch (error) {
if (this.options.onAuthError?.(ctx, error)) return;
this.status = cleanError(error);
this.options.appendLog(`evenhub store: ${this.status}`);
} finally {
@@ -226,6 +230,7 @@ export class EvenHubStoreDetailLayer implements Layer {
return undefined;
})
.catch((error) => {
if (this.options.onAuthError?.(ctx, error)) return;
this.options.appendLog(`evenhub store: app details unavailable: ${cleanError(error)}`);
})
.finally(() => ctx.actions.requestRender());
+36 -32
View File
@@ -10,7 +10,7 @@ import { ConfigSettingString } from "../../ui/dashboard-settings";
import { evenHubApi, EvenHubAuthenticationError, isEvenHubStoreConfigured, type EvenHubStoreApp, type EvenHubStorePage } from "./even-api";
import { clearEvenHubLoginForm, clearEvenHubSession, clearTransientEvenHubSession, evenHubLoginEmailSetting, evenHubLoginPasswordSetting, evenHubRememberMeSetting, resetEvenHubLoginForm } from "./credentials";
import { getInstalledEvenHubApps, uninstallEvenHubPackage, type InstalledEvenHubApp } from "./installed-apps";
import { EvenHubStoreDetailLayer } from "./store-detail-layer";
import { EvenHubStoreDetailLayer, type EvenHubStoreDetailOptions } from "./store-detail-layer";
import { cleanError, installStoreApp } from "./store-install";
import { checkForEvenHubUpdates, describeUpdate, type EvenHubAppUpdate } from "./updates";
import { lineStep } from "../../ui/metrics";
@@ -150,13 +150,11 @@ export class EvenHubStoreLayer implements Layer {
this.started = true;
// Do NOT open the phone credential editor here. This runs on the first
// paint, which includes the restore of a still-open EvenHub at app
// startup -- so an unfinished sign-in re-opened the form on every launch,
// and the form has no way out: it has no Cancel control, its onCancel is
// dropped before it reaches the controller, and Back leaves the app
// rather than closing it. The login pane already says "Enter your Even
// account email and password in the phone app" and already opens the
// editor on click (handleInput), so the editor is still one tap away for
// someone who actually wants it.
// startup -- so an unfinished sign-in re-opened the form on every
// launch, unasked. The login pane already says "Enter your Even account
// email and password in the phone app" and already opens the editor on
// click (handleInput), so the editor is still one tap away for someone
// who actually wants it.
if (!this.showingLogin) {
void this.ensureTabLoaded(ctx, this.activeTab);
}
@@ -348,13 +346,7 @@ export class EvenHubStoreLayer implements Layer {
}
case "app":
if (this.updatingAll) return;
ctx.stack.push(
new EvenHubStoreDetailLayer(row.app, {
launchApp: this.options.launchApp,
appendLog: this.options.appendLog,
onInstalled: (installed) => this.onInstalled(installed),
}),
);
ctx.stack.push(new EvenHubStoreDetailLayer(row.app, this.detailOptions()));
return;
}
}
@@ -372,13 +364,7 @@ export class EvenHubStoreLayer implements Layer {
}
this.pendingPackage = null;
stack.clearToBase();
stack.push(
new EvenHubStoreDetailLayer(placeholderStoreApp(installed), {
launchApp: this.options.launchApp,
appendLog: this.options.appendLog,
onInstalled: (result) => this.onInstalled(result),
}),
);
stack.push(new EvenHubStoreDetailLayer(placeholderStoreApp(installed), this.detailOptions()));
}
/** Dictated text becomes a search (the shell's "Type Into App" / voice input). */
@@ -595,6 +581,8 @@ export class EvenHubStoreLayer implements Layer {
failures.push(`${row.app.name} (declined)`);
}
} catch (error) {
// An expired session fails every remaining update the same way.
if (this.handleAuthError(ctx, error)) return;
const message = cleanError(error);
this.options.appendLog(`evenhub store: update of ${row.app.packageId} failed: ${message}`);
failures.push(row.app.name);
@@ -629,15 +617,33 @@ export class EvenHubStoreLayer implements Layer {
// ---- login and phone editors --------------------------------------------
/** Route a rejected session back to the login form; true if it was one. */
/**
* Drop back to the logged-out pane when Even rejects the session (an
* expired login); true if the error was one. Anything open above the list
* (an app page, a permission dialog) needed the session too, so it goes.
* The phone form is not opened: this can happen on the first load of a
* store window restored at startup (see paint), and the pane's click
* opens it.
*/
private handleAuthError(ctx: LayerContext, error: unknown): boolean {
if (!(error instanceof EvenHubAuthenticationError)) return false;
const message = cleanError(error);
this.options.appendLog(`evenhub store login failed: ${message}`);
this.enterLogin(ctx, `Login failed: ${message}`);
this.options.appendLog(`evenhub store: session rejected: ${message}`);
if (this.closed) return true;
ctx.stack.clearToBase();
this.enterLogin(ctx, `Signed out: ${message}`, false);
return true;
}
private detailOptions(): EvenHubStoreDetailOptions {
return {
launchApp: this.options.launchApp,
appendLog: this.options.appendLog,
onInstalled: (installed) => this.onInstalled(installed),
onAuthError: (ctx, error) => this.handleAuthError(ctx, error),
};
}
private enterLogin(
ctx: LayerContext,
status = "Sign in to browse public apps.",
@@ -691,13 +697,11 @@ export class EvenHubStoreLayer implements Layer {
const email = evenHubLoginEmailSetting.get();
const password = evenHubLoginPasswordSetting.get();
if (!email.trim() || !password) {
// The phone editor has no Cancel control, so submitting an untouched form
// with the keyboard's Done key is the only way someone can back out of
// it. Reopening the editor there makes that a loop with no exit, so a
// wholly empty submission is treated as a cancel and leaves the editor
// closed -- the login pane still says how to get back in, and a click
// reopens the editor. A half-filled form is a real mistake, so that
// still reopens with the message.
// A wholly empty submission (the keyboard's Done key on an untouched
// form) is treated as a cancel and leaves the editor closed -- the login
// pane still says how to get back in, and a click reopens the editor.
// A half-filled form is a real mistake, so that still reopens with the
// message.
const cancelled = !email.trim() && !password;
this.enterLogin(
ctx,
+32
View File
@@ -213,6 +213,13 @@ class DashboardController {
*/
private activeTextEditorOnCancel: (() => void) | null = null;
private activeTextEditorToggle: TextSettingsEditToggle | null = null;
/**
* The active settings' values (and the toggle's) when the edit began. The
* phone fields write through on every keystroke, so this is what the
* editor's Cancel button puts back.
*/
private activeTextSettingOriginalValues: string[] = [];
private activeTextEditorToggleOriginalValue = false;
private evenNotificationActive = false;
private evenAppConflictMessage = "";
private firmwareWarningMessage = "";
@@ -1897,9 +1904,11 @@ class DashboardController {
onCancel?: () => void,
): void {
this.activeTextSettings = Array.from(settings.slice(0, 2));
this.activeTextSettingOriginalValues = this.activeTextSettings.map((setting) => setting.get());
this.activeTextEditorTitle = title;
this.activeTextEditorOnFinish = onFinish ?? null;
this.activeTextEditorToggle = toggle ?? null;
this.activeTextEditorToggleOriginalValue = toggle?.setting.get() ?? false;
this.activeTextEditorOnCancel = onCancel ?? null;
this.emit();
}
@@ -2021,6 +2030,7 @@ class DashboardController {
// finishTextSettingEdit clears this first, so a completed edit never fires it.
const onCancel = this.activeTextEditorOnCancel;
this.activeTextSettings = [];
this.activeTextSettingOriginalValues = [];
this.activeTextEditorTitle = "";
this.activeTextEditorOnFinish = null;
this.activeTextEditorToggle = null;
@@ -2056,6 +2066,28 @@ class DashboardController {
onFinish?.();
}
/**
* The phone editor's Cancel button: put back the values the edit started
* with, end the edit as a cancel (the caller's onCancel fires), and
* navigate the Settings app's glasses editor out of the edit page.
*/
cancelActiveTextSettingEdit(): void {
if (!this.activeTextSettings.length) return;
this.activeTextSettings.forEach((setting, index) => {
const original = this.activeTextSettingOriginalValues[index] ?? "";
if (setting.get() !== original) setting.set(original);
});
const toggle = this.activeTextEditorToggle;
if (toggle && toggle.setting.get() !== this.activeTextEditorToggleOriginalValue) {
toggle.setting.set(this.activeTextEditorToggleOriginalValue);
}
const closesGlassesEditor = this.activeTextSettings.length === 1;
this.endTextSettingEdit();
if (closesGlassesEditor && this.textEditorHost?.closeTextEditor()) {
this.textEditorHost.requestRender();
}
}
private updateTextSetting(setting: ConfigSettingString, value: string): void {
if (setting.get() !== value) {
setting.set(value);
+70 -44
View File
@@ -106,50 +106,76 @@
<!-- Keyboard-input mode: anchored to the bottom of the (keyboard-
shrunk) page, so it sits in the space below the mirror and only
overlaps the mirror when the open keyboard leaves too little
room. The tabbed controls are collapsed while it is up. -->
<StackLayout
class="system-name-modal"
visibility="{{ textSettingEditorVisibility }}"
horizontalAlignment="stretch"
verticalAlignment="bottom">
<Label text="{{ activeTextEditorTitle }}" class="h2" />
<!-- Per-field labels only matter with two fields; a single-field
edit's field title is the same string as the editor title. -->
<Label text="{{ activeTextSettingTitle }}" visibility="{{ secondaryTextSettingVisibility }}" />
<TextField
id="settingsTextField"
text="{{ activeTextSettingValue }}"
textChange="{{ onTextSettingTextChange }}"
returnPress="{{ onPrimaryTextSettingReturnPress }}"
autocorrect="false"
autocapitalizationType="none"
keyboardType="{{ activeTextSettingKeyboardType }}"
secure="{{ activeTextSettingSecure }}"
returnKeyType="{{ primaryTextSettingReturnKeyType }}" />
<StackLayout visibility="{{ secondaryTextSettingVisibility }}">
<Label text="{{ secondaryTextSettingTitle }}" />
<TextField
id="secondarySettingsTextField"
text="{{ secondaryTextSettingValue }}"
textChange="{{ onSecondaryTextSettingTextChange }}"
returnPress="{{ onSecondaryTextSettingReturnPress }}"
autocorrect="false"
autocapitalizationType="none"
keyboardType="{{ secondaryTextSettingKeyboardType }}"
secure="{{ secondaryTextSettingSecure }}"
returnKeyType="done" />
</StackLayout>
<GridLayout
columns="*,auto"
visibility="{{ activeTextEditorToggleVisibility }}"
class="m-t-8">
<Label col="0" text="{{ activeTextEditorToggleLabel }}" verticalAlignment="center" />
<Switch
col="1"
checked="{{ activeTextEditorToggleValue }}"
checkedChange="{{ onTextSettingToggleChange }}" />
</GridLayout>
</StackLayout>
room. The tabbed controls are collapsed while it is up.
NativeScript has no maxHeight, so the transparent outer grid's
fixed height is the cap: it shrinks to the page when the keyboard
leaves less room than that, and the bottom-aligned modal inside
sizes to its content within it. Past the cap the fields scroll
and the buttons stay put.
Any GridLayout in here needs an explicit rows="auto": the implicit
single star row stretches to fill all the height offered (Stack-
and DockLayout offer it AT_MOST the remaining height), which is
what made the form balloon with the keyboard minimized. -->
<GridLayout
height="440"
verticalAlignment="bottom"
isPassThroughParentEnabled="true"
visibility="{{ textSettingEditorVisibility }}">
<DockLayout
class="system-name-modal"
stretchLastChild="true"
horizontalAlignment="stretch"
verticalAlignment="bottom">
<Label dock="top" text="{{ activeTextEditorTitle }}" class="h2" />
<GridLayout dock="bottom" columns="*,*" rows="auto" class="m-t-8">
<Button col="0" text="Cancel" tap="{{ onTextSettingCancelTap }}" />
<Button col="1" text="Submit" tap="{{ onTextSettingSubmitTap }}" class="-primary" />
</GridLayout>
<ScrollView>
<StackLayout>
<!-- Per-field labels only matter with two fields; a single-field
edit's field title is the same string as the editor title. -->
<Label text="{{ activeTextSettingTitle }}" visibility="{{ secondaryTextSettingVisibility }}" />
<TextField
id="settingsTextField"
text="{{ activeTextSettingValue }}"
textChange="{{ onTextSettingTextChange }}"
returnPress="{{ onPrimaryTextSettingReturnPress }}"
autocorrect="false"
autocapitalizationType="none"
keyboardType="{{ activeTextSettingKeyboardType }}"
secure="{{ activeTextSettingSecure }}"
returnKeyType="{{ primaryTextSettingReturnKeyType }}" />
<StackLayout visibility="{{ secondaryTextSettingVisibility }}">
<Label text="{{ secondaryTextSettingTitle }}" />
<TextField
id="secondarySettingsTextField"
text="{{ secondaryTextSettingValue }}"
textChange="{{ onSecondaryTextSettingTextChange }}"
returnPress="{{ onSecondaryTextSettingReturnPress }}"
autocorrect="false"
autocapitalizationType="none"
keyboardType="{{ secondaryTextSettingKeyboardType }}"
secure="{{ secondaryTextSettingSecure }}"
returnKeyType="done" />
</StackLayout>
<GridLayout
columns="*,auto"
rows="auto"
visibility="{{ activeTextEditorToggleVisibility }}"
class="m-t-8">
<Label col="0" text="{{ activeTextEditorToggleLabel }}" verticalAlignment="center" />
<Switch
col="1"
checked="{{ activeTextEditorToggleValue }}"
checkedChange="{{ onTextSettingToggleChange }}" />
</GridLayout>
</StackLayout>
</ScrollView>
</DockLayout>
</GridLayout>
<!-- Keyboard-input panel (the keyboard button beside the mic button):
the phone's end of the keyboard dialog on the glasses
(ui/shell/keyboard-input.ts). Same placement and collapsing rules
+21
View File
@@ -8,6 +8,7 @@ import {
Screen,
SwipeDirection,
type GestureEventData,
type TextField,
type SwipeGestureEventData,
type TouchGestureEventData,
type View,
@@ -988,6 +989,26 @@ export class MainViewModel extends RemoteControlsViewModel {
dashboardController.finishActiveTextSettingEdit();
}
/** The editor's Submit button: the same as the done key on the last field. */
onTextSettingSubmitTap(args: { object?: View }): void {
// Commit both fields' actual text, in case a final keystroke's textChange
// hadn't landed yet (as the return-press handlers do).
const page = args?.object?.page;
const primaryText = page?.getViewById<TextField>("settingsTextField")?.text;
if (typeof primaryText === "string") {
dashboardController.setActiveTextSettingValue(primaryText, this.activeTextSettingId ?? undefined);
}
const secondaryText = page?.getViewById<TextField>("secondarySettingsTextField")?.text;
if (this.hasSecondaryTextSetting && typeof secondaryText === "string") {
dashboardController.setActiveTextSettingValue(secondaryText, this.secondaryTextSettingId ?? undefined);
}
dashboardController.finishActiveTextSettingEdit();
}
onTextSettingCancelTap(): void {
dashboardController.cancelActiveTextSettingEdit();
}
onTextSettingToggleChange(args: { value?: boolean; object?: { checked?: boolean } }): void {
dashboardController.setActiveTextEditorToggleValue(
args.object?.checked ?? args.value ?? false,
+87 -11
View File
@@ -15,14 +15,23 @@ const setting = (initial = '') => {
return { get: () => value, set: (next) => { value = next; } };
};
/** Load the store layer with a signed-out account and no stored credentials. */
const loadStoreLayer = () => {
class AuthError extends Error {}
/**
* Load the store layer, by default with a signed-out account and no stored
* credentials. `api` overrides evenHubApi methods; text the layer paints is
* collected in `drawn`, and the options each app page is opened with in
* `detailOptions`.
*/
const loadStoreLayer = ({ configured = false, api = {} } = {}) => {
const email = setting('');
const password = setting('');
const font = { lineHeight: 10 };
const drawn = [];
const detailOptions = [];
const font = { lineHeight: 10, measureText: (text) => text.length * 6 };
const load = loader({}, {
'../../graphics/ui-fonts': { getDefaultSmallFont: () => font },
'../../graphics/image': { GrayImage: class { drawText() {} } },
'../../graphics/image': { GrayImage: class { drawText(_f, _x, _y, text) { drawn.push(text); } fillRect() {} } },
'../../graphics/textwrap': { truncateText: (_f, text) => text, wrapText: (_f, text) => [text] },
'../../util/numeric-util': { clamp: (v, lo, hi) => Math.min(hi, Math.max(lo, v)) },
'../../ui/gestures': { GESTURE_CLICK: 'click' },
@@ -35,9 +44,9 @@ const loadStoreLayer = () => {
get() { return this.value; } set(next) { this.value = next; } },
},
'./even-api': {
evenHubApi: { signIn: async () => {} },
EvenHubAuthenticationError: class extends Error {},
isEvenHubStoreConfigured: () => false,
evenHubApi: { signIn: async () => {}, ...api },
EvenHubAuthenticationError: AuthError,
isEvenHubStoreConfigured: () => configured,
},
'./credentials': {
evenHubLoginEmailSetting: email,
@@ -48,20 +57,28 @@ const loadStoreLayer = () => {
clearEvenHubSession() {}, clearTransientEvenHubSession() {},
},
'./installed-apps': { getInstalledEvenHubApps: () => [], uninstallEvenHubPackage: async () => {} },
'./store-detail-layer': { EvenHubStoreDetailLayer: class {} },
'./store-install': { cleanError: (error) => String(error), installStoreApp: async () => {} },
'./store-detail-layer': { EvenHubStoreDetailLayer: class { constructor(_app, options) { detailOptions.push(options); } } },
'./store-install': { cleanError: (error) => String(error?.message ?? error), installStoreApp: async () => {} },
'./updates': { checkForEvenHubUpdates: async () => [], describeUpdate: () => '' },
});
const { EvenHubStoreLayer } = load('app/apps/evenhub/store-layer.ts');
return { EvenHubStoreLayer, email, password };
return { EvenHubStoreLayer, email, password, drawn, detailOptions };
};
/** A LayerContext that records every editor the layer asks the phone to open. */
const makeCtx = () => {
const opened = [];
const stack = {
cleared: 0,
pushed: [],
getBaseSize: () => ({ width: 576, height: 136 }),
isFocused: () => true,
clearToBase() { stack.cleared++; stack.pushed.length = 0; },
push(layer) { stack.pushed.push(layer); },
};
return {
opened,
stack: { getBaseSize: () => ({ width: 576, height: 136 }) },
stack,
actions: {
requestRender() {},
endTextSettingEdit() {},
@@ -125,3 +142,62 @@ test('cancelling the sign-in form leaves it reopenable', () => {
layer.handleInput({ type: 'click' }, ctx);
assert.equal(ctx.opened.length, 2, 'a dropped onCancel latches the guard and no later open is allowed');
});
test('an expired session drops the store back to the logged-out pane', async () => {
const { EvenHubStoreLayer, drawn } = loadStoreLayer({
configured: true,
api: { listApps: async () => { throw new AuthError('Your login is expired'); } },
});
const layer = new EvenHubStoreLayer({ launchApp: async () => {}, appendLog: () => {} });
const ctx = makeCtx();
layer.paint(ctx);
await settle();
assert.equal(layer.buildMenuItems().length, 0, 'the signed-in menu (Refresh, Log Out) is gone');
assert.equal(ctx.stack.cleared, 1, 'pages above the list needed the session too');
assert.deepEqual(ctx.opened, [], 'this can happen on a startup restore, so the form must not pop up by itself');
drawn.length = 0;
layer.paint(ctx);
assert.ok(drawn.includes('Signed out: Your login is expired'), `painted: ${JSON.stringify(drawn)}`);
layer.handleInput({ type: 'click' }, ctx);
assert.equal(ctx.opened.length, 1, 'a click on the pane opens the sign-in form');
});
test('an expired session on an app page drops the store back to the logged-out pane', () => {
const { EvenHubStoreLayer, detailOptions } = loadStoreLayer({
configured: true,
api: { listApps: () => new Promise(() => {}) },
});
const layer = new EvenHubStoreLayer({ launchApp: async () => {}, appendLog: () => {} });
const ctx = makeCtx();
layer.paint(ctx);
layer.showInstalledPackage(ctx.stack, { packageId: 'com.example.app', name: 'Example' });
assert.equal(ctx.stack.pushed.length, 1);
const { onAuthError } = detailOptions[0];
assert.equal(onAuthError(ctx, new Error('network down')), false, 'other failures stay on the page');
assert.ok(layer.buildMenuItems().length > 0);
assert.equal(onAuthError(ctx, new AuthError('Your login is expired')), true);
assert.equal(ctx.stack.pushed.length, 0, 'the app page is closed');
assert.equal(layer.buildMenuItems().length, 0);
});
test('an API envelope with code 401 is a rejected session and forgets the token', async () => {
let token = 'stale-token';
let invalidated = 0;
const api = loader({ setTimeout, clearTimeout }, {
'./even-platform': { getPhoneOpenUdid: () => 'fixture-terminal', hmacSha256Base64: () => 'fixture-signature' },
'./credentials': {
getEvenHubToken: () => token, hasEvenHubCredentials: () => !!token,
saveEvenHubSession() {}, invalidateEvenHubToken() { invalidated++; token = ''; },
},
'../../util/http': {
fetchWithUserAgent: async () => ({ status: 200, json: async () => ({ code: 401, msg: 'Your login is expired' }) }),
},
})('app/apps/evenhub/even-api.ts');
await assert.rejects(api.evenHubApi.listApps(), (error) => {
assert.ok(error instanceof api.EvenHubAuthenticationError, `got ${error}`);
assert.equal(error.message, 'Your login is expired');
return true;
});
assert.equal(invalidated, 1);
assert.equal(api.isEvenHubStoreConfigured(), false);
});