@cxxi-lab/hubbyware-sdk 3.2.0 → 3.3.0
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.
- package/frame/index.ts +1 -1
- package/frame/sdk.ts +15 -0
- package/package.json +1 -1
- package/types/index.d.ts +65 -30
- package/version.json +1 -1
package/frame/index.ts
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
// the base stylesheet, extracted into runtime.css at build (the frame page links it)
|
|
4
4
|
import './runtime.css'
|
|
5
5
|
|
|
6
|
-
export { call, collection, nav, notifications, settings, useInit, usePath, type Doc } from './sdk'
|
|
6
|
+
export { call, collection, nav, notifications, oauth, settings, useInit, usePath, type Doc, type OAuthConnection } from './sdk'
|
|
7
7
|
export { defineHubby, start, type HubbyDefinition, type HubbyPageDefinition } from './hubby'
|
|
8
8
|
export { useBackHandler, useMediaQuery } from '@cxxi-lab/hubbyware-ui'
|
package/frame/sdk.ts
CHANGED
|
@@ -109,6 +109,21 @@ export const notifications = {
|
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
/** Announces the hubby's pages to its host (it builds the navigation). */
|
|
112
|
+
/** An account connected at a provider, as the hubby sees it (its grant covers what it declares: `ready`). */
|
|
113
|
+
export interface OAuthConnection { id: string, provider: string, email: string, name: string | null, ready: boolean, lastError: string | null }
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* The account's connections at a provider (Google, Microsoft), for what the hubby declares
|
|
117
|
+
* (hubby.json `oauth`; the account allowing it `app:oauth:<provider>`): through the host, as the hubby.
|
|
118
|
+
*/
|
|
119
|
+
export const oauth = {
|
|
120
|
+
connections: () => call<OAuthConnection[]>('oauth.connections'),
|
|
121
|
+
/** the consent opens in the browser; resolves once the account consented */
|
|
122
|
+
connect: (provider: string, options: { connection?: string } = {}) => call<OAuthConnection | null>('oauth.connect', provider, options),
|
|
123
|
+
/** an access token, for the hubby's scopes only */
|
|
124
|
+
accessToken: (connection: string) => call<{ accessToken: string, expiresAt: number }>('oauth.accessToken', connection),
|
|
125
|
+
}
|
|
126
|
+
|
|
112
127
|
export function register(pages: HubbyPage[], sections: Record<string, unknown>) {
|
|
113
128
|
post({ type: 'register', pages, sections })
|
|
114
129
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cxxi-lab/hubbyware-sdk",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "The contract of Hubbyware's hubbies: the SDK a hubby builds on (provided by the host app at run time), and the SDK of the hubbies running isolated in their frame. Formerly @cxxi-lab/hub-sdk.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @cxxi-lab/hubbyware-sdk 3.
|
|
1
|
+
// @cxxi-lab/hubbyware-sdk 3.3.0: generated by app/scripts/emit-sdk-types.mjs from app/src/sdk — do not edit.
|
|
2
2
|
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
3
3
|
import { ComponentType, HTMLInputTypeAttribute, MouseEventHandler, ReactNode, TdHTMLAttributes, ThHTMLAttributes } from 'react';
|
|
4
4
|
|
|
@@ -19,6 +19,19 @@ export type StreamEventHandler = (event: string, data: unknown) => void;
|
|
|
19
19
|
* JSON-decoded data. Comments, empty blocks and undecodable data are skipped.
|
|
20
20
|
*/
|
|
21
21
|
export declare function readEventStream(body: ReadableStream<Uint8Array>, onEvent: StreamEventHandler): Promise<void>;
|
|
22
|
+
/** A site's player scripts, served by the back (the web socle, Resources/<host>/). */
|
|
23
|
+
export interface PlayerScripts {
|
|
24
|
+
/** run on the video page (page mode) to isolate the player */
|
|
25
|
+
page: string | null;
|
|
26
|
+
/** run on a bare embed player (embed mode) */
|
|
27
|
+
embed: string | null;
|
|
28
|
+
pause: string | null;
|
|
29
|
+
}
|
|
30
|
+
export interface PlayerConfig {
|
|
31
|
+
/** the host whose scripts apply to the requested domain */
|
|
32
|
+
host: string;
|
|
33
|
+
scripts: PlayerScripts;
|
|
34
|
+
}
|
|
22
35
|
/**
|
|
23
36
|
* The platform contract: everything the shared UI needs from its host shell.
|
|
24
37
|
*
|
|
@@ -431,11 +444,6 @@ export interface Platform {
|
|
|
431
444
|
openSettings(target?: string): Promise<void>;
|
|
432
445
|
/** In the Settings window: a screen another window asked for. */
|
|
433
446
|
onSettingsGoto(cb: (target: string) => void): Unsubscribe;
|
|
434
|
-
/**
|
|
435
|
-
* Opens an OAuth consent page in an app window; resolves with the URL the provider redirected to
|
|
436
|
-
* (`redirectUri` + the code), caught before it loads, or null when the window was closed.
|
|
437
|
-
*/
|
|
438
|
-
authorizeOAuth(url: string, redirectUri: string): Promise<string | null>;
|
|
439
447
|
/** Opens a hubby's window (HubbyManifest.windows), registered beforehand. */
|
|
440
448
|
openHubbyWindow(hubbyId: string, windowId: string): Promise<void>;
|
|
441
449
|
/** The windows of the active hubbies: what the app menu offers (replaces the previous list). */
|
|
@@ -700,37 +708,49 @@ export interface PaginatedResponse<T> {
|
|
|
700
708
|
pages: number;
|
|
701
709
|
};
|
|
702
710
|
}
|
|
703
|
-
export declare function ensureIntegrationForUrl(rawUrl: string): Promise<void>;
|
|
704
711
|
/**
|
|
705
712
|
* Sync probe — true if the domain has already been checked (positive or
|
|
706
713
|
* negative). Lets call-sites skip the async await on hot paths.
|
|
707
714
|
*/
|
|
708
715
|
export declare function isIntegrationKnownSync(rawUrl: string): boolean;
|
|
709
|
-
/** A site's player scripts, served by the back (the web socle, Resources/<host>/). */
|
|
710
|
-
export interface PlayerScripts {
|
|
711
|
-
/** run on the video page (page mode) to isolate the player */
|
|
712
|
-
page: string | null;
|
|
713
|
-
/** run on a bare embed player (embed mode) */
|
|
714
|
-
embed: string | null;
|
|
715
|
-
pause: string | null;
|
|
716
|
-
}
|
|
717
|
-
export interface PlayerConfig {
|
|
718
|
-
/** the host whose scripts apply to the requested domain */
|
|
719
|
-
host: string;
|
|
720
|
-
scripts: PlayerScripts;
|
|
721
|
-
}
|
|
722
716
|
/**
|
|
723
|
-
* The
|
|
724
|
-
*
|
|
725
|
-
*
|
|
717
|
+
* The account's connections at a provider (Google, Microsoft), as a hubby uses them (server
|
|
718
|
+
* docs/plan-oauth.md): the hubby declares the provider scopes it needs (hubby.json `oauth`), the
|
|
719
|
+
* account allows it the provider (`app:oauth:<provider>`, its permissions), then it lists the
|
|
720
|
+
* connections, connects an account (the consent opens in the browser, the server takes the
|
|
721
|
+
* provider's answer) and gets access tokens narrowed to its scopes. Every call is the hubby's
|
|
722
|
+
* (its token): the SDK binds it (src/sdk/index.ts), the host too for an isolated one.
|
|
726
723
|
*/
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
724
|
+
/** An account connected at a provider, as the hubby sees it. */
|
|
725
|
+
export interface OAuthConnection {
|
|
726
|
+
id: string;
|
|
727
|
+
provider: string;
|
|
728
|
+
email: string;
|
|
729
|
+
name: string | null;
|
|
730
|
+
/** its grant covers what the hubby declares (else: connect it again, `connect(provider, { connection })`) */
|
|
731
|
+
ready: boolean;
|
|
732
|
+
lastError: string | null;
|
|
733
|
+
}
|
|
734
|
+
export interface OAuthAccessToken {
|
|
735
|
+
accessToken: string;
|
|
736
|
+
/** unix seconds */
|
|
737
|
+
expiresAt: number;
|
|
738
|
+
}
|
|
739
|
+
export interface OAuthApi {
|
|
740
|
+
/** The account's connections at the providers the hubby declares (and was allowed). */
|
|
741
|
+
connections(): Promise<OAuthConnection[]>;
|
|
742
|
+
/**
|
|
743
|
+
* Connects an account at a provider for what the hubby declares, or gives one connected
|
|
744
|
+
* (`connection`) what it lacks: the consent opens in the browser; resolves once the account
|
|
745
|
+
* consented (null: given up, `signal`).
|
|
746
|
+
*/
|
|
747
|
+
connect(provider: string, options?: {
|
|
748
|
+
connection?: string;
|
|
749
|
+
signal?: AbortSignal;
|
|
750
|
+
}): Promise<OAuthConnection | null>;
|
|
751
|
+
/** An access token of a connection, for the hubby's scopes (kept until shortly before it expires). */
|
|
752
|
+
accessToken(connection: string): Promise<OAuthAccessToken>;
|
|
753
|
+
}
|
|
734
754
|
export type ButtonColor = "primary" | "secondary" | "danger";
|
|
735
755
|
export interface ButtonProps {
|
|
736
756
|
label?: ReactNode;
|
|
@@ -1010,6 +1030,21 @@ export declare function api<T>(path: string, options?: RequestInit, retry?: bool
|
|
|
1010
1030
|
* body and carry the token — and resolves once the server closes it.
|
|
1011
1031
|
*/
|
|
1012
1032
|
export declare function apiStream(path: string, options: RequestInit, onEvent: StreamEventHandler, retry?: boolean): Promise<void>;
|
|
1033
|
+
/** Applies the website integration (cookies, CDN referer) of a URL's site before a webview or the native player loads it. */
|
|
1034
|
+
export declare function ensureIntegrationForUrl(rawUrl: string): Promise<void>;
|
|
1035
|
+
/**
|
|
1036
|
+
* The player config for a domain, null when the back has no scripts for the
|
|
1037
|
+
* site (it is then loaded as-is). A failed lookup resolves null too, and is
|
|
1038
|
+
* retried next time.
|
|
1039
|
+
*/
|
|
1040
|
+
export declare function getPlayerConfig(domain: string): Promise<PlayerConfig | null>;
|
|
1041
|
+
/** Makes sure the shell holds the back's current player blocklist before a player loads a site (once per session). */
|
|
1042
|
+
export declare function syncPlayerBlocklist(): Promise<void>;
|
|
1043
|
+
/**
|
|
1044
|
+
* The account's connections at a provider (Google, Microsoft), for what the hubby declares
|
|
1045
|
+
* (hubby.json `oauth`): list them, connect an account, get access tokens narrowed to its scopes.
|
|
1046
|
+
*/
|
|
1047
|
+
export declare const oauth: OAuthApi;
|
|
1013
1048
|
|
|
1014
1049
|
export {
|
|
1015
1050
|
FormData$1 as FormData,
|
package/version.json
CHANGED