happy path working with stub companion app
This commit is contained in:
@@ -109,6 +109,33 @@ type Credential = {
|
||||
}
|
||||
```
|
||||
|
||||
### `locqr.abort()`
|
||||
|
||||
Cancels an in-flight run, any phase. A no-op if no run is active. Any
|
||||
pending `requestCredential()` Promise rejects through the normal
|
||||
`run_error` round-trip this triggers, not synchronously from calling this.
|
||||
|
||||
```js
|
||||
locqr.abort();
|
||||
```
|
||||
|
||||
### `locqr.reportSession(options)`
|
||||
|
||||
```ts
|
||||
locqr.reportSession({ active: boolean });
|
||||
```
|
||||
|
||||
Tells the extension whether this site currently considers the user to have
|
||||
an active session — purely advisory, shown as a badge/copy variant on the
|
||||
popup's `idle` screen (`extension/gui.md`). Never affects verification or
|
||||
any run's security checks; those are unconditional regardless of what a
|
||||
site reports here. Call it any time after `init()`, and again whenever the
|
||||
site's own session state changes (including its own logout flow, with
|
||||
`active: false`) — LOCQR has no session mechanism of its own and doesn't
|
||||
persist this across a page reload; the site's existing session handling
|
||||
(cookie, server-checked session, whatever it already has) is what this
|
||||
should be sourced from.
|
||||
|
||||
### `locqr.on(event, handler)` / `locqr.off(event, handler)`
|
||||
|
||||
Registers and removes handlers for extension-initiated events.
|
||||
|
||||
@@ -160,6 +160,29 @@ class Locqr {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels an in-flight run (any phase). A no-op if no run is active —
|
||||
* the extension itself decides what "no active run" means; the SDK
|
||||
* doesn't try to track run state to pre-empt this call locally.
|
||||
* Rejection of any pending requestCredential() promise happens through
|
||||
* the normal run_error round-trip above, not from calling this directly.
|
||||
*/
|
||||
abort(): void {
|
||||
this.port?.postMessage({ type: 'abort' });
|
||||
}
|
||||
|
||||
/**
|
||||
* Advisory only (types.ts's SessionStatusMessage on the extension
|
||||
* side): tells the extension whether this site currently considers the
|
||||
* user to have an active session, purely so the popup's idle screen
|
||||
* can reflect it. Never affects verification or the run's own security
|
||||
* checks — those are unconditional regardless of what a site reports
|
||||
* here.
|
||||
*/
|
||||
reportSession(options: { active: boolean }): void {
|
||||
this.port?.postMessage({ type: 'session_status', active: options.active });
|
||||
}
|
||||
|
||||
on<E extends LocqrEvent>(event: E, handler: EventHandler<E>): void {
|
||||
if (!this.handlers.has(event)) this.handlers.set(event, new Set());
|
||||
this.handlers.get(event)!.add(handler as EventHandler);
|
||||
|
||||
Reference in New Issue
Block a user