@eloxiv/client 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +6 -2
- package/dist/Account.d.ts +131 -0
- package/dist/Account.d.ts.map +1 -0
- package/dist/Account.js +169 -0
- package/dist/Account.js.map +1 -0
- package/dist/Agent.d.ts +496 -0
- package/dist/Agent.d.ts.map +1 -0
- package/dist/Agent.js +228 -0
- package/dist/Agent.js.map +1 -0
- package/dist/AgentSync.d.ts +990 -0
- package/dist/AgentSync.d.ts.map +1 -0
- package/dist/AgentSync.js +46 -0
- package/dist/AgentSync.js.map +1 -0
- package/dist/AppState.d.ts +127 -0
- package/dist/AppState.d.ts.map +1 -0
- package/dist/AppState.js +145 -0
- package/dist/AppState.js.map +1 -0
- package/dist/AppStateSync.d.ts +193 -0
- package/dist/AppStateSync.d.ts.map +1 -0
- package/dist/AppStateSync.js +23 -0
- package/dist/AppStateSync.js.map +1 -0
- package/dist/Auth.d.ts +95 -0
- package/dist/Auth.d.ts.map +1 -0
- package/dist/Auth.js +139 -0
- package/dist/Auth.js.map +1 -0
- package/dist/Avatars.d.ts +53 -0
- package/dist/Avatars.d.ts.map +1 -0
- package/dist/Avatars.js +121 -0
- package/dist/Avatars.js.map +1 -0
- package/dist/BrowserAnalytics.d.ts +56 -0
- package/dist/BrowserAnalytics.d.ts.map +1 -0
- package/dist/BrowserAnalytics.js +94 -0
- package/dist/BrowserAnalytics.js.map +1 -0
- package/dist/Chat.d.ts +712 -0
- package/dist/Chat.d.ts.map +1 -0
- package/dist/Chat.js +883 -0
- package/dist/Chat.js.map +1 -0
- package/dist/ChatIntegrity.d.ts +63 -0
- package/dist/ChatIntegrity.d.ts.map +1 -0
- package/dist/ChatIntegrity.js +89 -0
- package/dist/ChatIntegrity.js.map +1 -0
- package/dist/ChatSends.d.ts +103 -0
- package/dist/ChatSends.d.ts.map +1 -0
- package/dist/ChatSends.js +157 -0
- package/dist/ChatSends.js.map +1 -0
- package/dist/Client.d.ts +113 -0
- package/dist/Client.d.ts.map +1 -0
- package/dist/Client.js +189 -0
- package/dist/Client.js.map +1 -0
- package/dist/Collab.d.ts +138 -0
- package/dist/Collab.d.ts.map +1 -0
- package/dist/Collab.js +454 -0
- package/dist/Collab.js.map +1 -0
- package/dist/CollabTools.d.ts +129 -0
- package/dist/CollabTools.d.ts.map +1 -0
- package/dist/CollabTools.js +277 -0
- package/dist/CollabTools.js.map +1 -0
- package/dist/Connections.d.ts +288 -0
- package/dist/Connections.d.ts.map +1 -0
- package/dist/Connections.js +316 -0
- package/dist/Connections.js.map +1 -0
- package/dist/Consent.d.ts +338 -0
- package/dist/Consent.d.ts.map +1 -0
- package/dist/Consent.js +142 -0
- package/dist/Consent.js.map +1 -0
- package/dist/Desktop.d.ts +61 -0
- package/dist/Desktop.d.ts.map +1 -0
- package/dist/Desktop.js +101 -0
- package/dist/Desktop.js.map +1 -0
- package/dist/Directory.d.ts +36 -0
- package/dist/Directory.d.ts.map +1 -0
- package/dist/Directory.js +42 -0
- package/dist/Directory.js.map +1 -0
- package/dist/ErrorReporter.d.ts +48 -0
- package/dist/ErrorReporter.d.ts.map +1 -0
- package/dist/ErrorReporter.js +70 -0
- package/dist/ErrorReporter.js.map +1 -0
- package/dist/ExpoSqlite.d.ts +7 -0
- package/dist/ExpoSqlite.d.ts.map +1 -0
- package/dist/ExpoSqlite.js +7 -0
- package/dist/ExpoSqlite.js.map +1 -0
- package/dist/FileSync.d.ts +265 -0
- package/dist/FileSync.d.ts.map +1 -0
- package/dist/FileSync.js +29 -0
- package/dist/FileSync.js.map +1 -0
- package/dist/FileTables.gen.d.ts +109 -0
- package/dist/FileTables.gen.d.ts.map +1 -0
- package/dist/FileTables.gen.js +23 -0
- package/dist/FileTables.gen.js.map +1 -0
- package/dist/Foldkit.d.ts +487 -0
- package/dist/Foldkit.d.ts.map +1 -0
- package/dist/Foldkit.js +617 -0
- package/dist/Foldkit.js.map +1 -0
- package/dist/History.d.ts +133 -0
- package/dist/History.d.ts.map +1 -0
- package/dist/History.js +210 -0
- package/dist/History.js.map +1 -0
- package/dist/InboxSync.d.ts +428 -0
- package/dist/InboxSync.d.ts.map +1 -0
- package/dist/InboxSync.js +37 -0
- package/dist/InboxSync.js.map +1 -0
- package/dist/KernelTables.gen.d.ts +1522 -0
- package/dist/KernelTables.gen.d.ts.map +1 -0
- package/dist/KernelTables.gen.js +307 -0
- package/dist/KernelTables.gen.js.map +1 -0
- package/dist/Make.d.ts +75 -0
- package/dist/Make.d.ts.map +1 -0
- package/dist/Make.js +70 -0
- package/dist/Make.js.map +1 -0
- package/dist/Models.d.ts +88 -0
- package/dist/Models.d.ts.map +1 -0
- package/dist/Models.js +80 -0
- package/dist/Models.js.map +1 -0
- package/dist/Optimistic.d.ts +120 -0
- package/dist/Optimistic.d.ts.map +1 -0
- package/dist/Optimistic.js +231 -0
- package/dist/Optimistic.js.map +1 -0
- package/dist/PlatformSync.d.ts +273 -0
- package/dist/PlatformSync.d.ts.map +1 -0
- package/dist/PlatformSync.js +92 -0
- package/dist/PlatformSync.js.map +1 -0
- package/dist/Poll.d.ts +113 -0
- package/dist/Poll.d.ts.map +1 -0
- package/dist/Poll.js +179 -0
- package/dist/Poll.js.map +1 -0
- package/dist/Preferences.d.ts +18 -0
- package/dist/Preferences.d.ts.map +1 -0
- package/dist/Preferences.js +22 -0
- package/dist/Preferences.js.map +1 -0
- package/dist/Proposals.d.ts +29 -0
- package/dist/Proposals.d.ts.map +1 -0
- package/dist/Proposals.js +41 -0
- package/dist/Proposals.js.map +1 -0
- package/dist/React.d.ts +17 -0
- package/dist/React.d.ts.map +1 -0
- package/dist/React.js +17 -0
- package/dist/React.js.map +1 -0
- package/dist/Reader.d.ts +35 -0
- package/dist/Reader.d.ts.map +1 -0
- package/dist/Reader.js +136 -0
- package/dist/Reader.js.map +1 -0
- package/dist/Resources.d.ts +98 -0
- package/dist/Resources.d.ts.map +1 -0
- package/dist/Resources.js +161 -0
- package/dist/Resources.js.map +1 -0
- package/dist/Rows.d.ts +4 -0
- package/dist/Rows.d.ts.map +1 -0
- package/dist/Rows.js +16 -0
- package/dist/Rows.js.map +1 -0
- package/dist/Runtime.d.ts +254 -0
- package/dist/Runtime.d.ts.map +1 -0
- package/dist/Runtime.js +1249 -0
- package/dist/Runtime.js.map +1 -0
- package/dist/RuntimeRuns.d.ts +74 -0
- package/dist/RuntimeRuns.d.ts.map +1 -0
- package/dist/RuntimeRuns.js +118 -0
- package/dist/RuntimeRuns.js.map +1 -0
- package/dist/ServicesSync.d.ts +286 -0
- package/dist/ServicesSync.d.ts.map +1 -0
- package/dist/ServicesSync.js +40 -0
- package/dist/ServicesSync.js.map +1 -0
- package/dist/Session.d.ts +226 -0
- package/dist/Session.d.ts.map +1 -0
- package/dist/Session.js +763 -0
- package/dist/Session.js.map +1 -0
- package/dist/ShareGrant.d.ts +47 -0
- package/dist/ShareGrant.d.ts.map +1 -0
- package/dist/ShareGrant.js +20 -0
- package/dist/ShareGrant.js.map +1 -0
- package/dist/Sharing.d.ts +203 -0
- package/dist/Sharing.d.ts.map +1 -0
- package/dist/Sharing.js +520 -0
- package/dist/Sharing.js.map +1 -0
- package/dist/Skew.d.ts +52 -0
- package/dist/Skew.d.ts.map +1 -0
- package/dist/Skew.js +77 -0
- package/dist/Skew.js.map +1 -0
- package/dist/SpacesSync.d.ts +247 -0
- package/dist/SpacesSync.d.ts.map +1 -0
- package/dist/SpacesSync.js +30 -0
- package/dist/SpacesSync.js.map +1 -0
- package/dist/Storage.d.ts +51 -0
- package/dist/Storage.d.ts.map +1 -0
- package/dist/Storage.js +107 -0
- package/dist/Storage.js.map +1 -0
- package/dist/Sync.d.ts +48 -0
- package/dist/Sync.d.ts.map +1 -0
- package/dist/Sync.js +48 -0
- package/dist/Sync.js.map +1 -0
- package/dist/SyncTables.d.ts +13 -0
- package/dist/SyncTables.d.ts.map +1 -0
- package/dist/SyncTables.js +13 -0
- package/dist/SyncTables.js.map +1 -0
- package/dist/Tab.d.ts +36 -0
- package/dist/Tab.d.ts.map +1 -0
- package/dist/Tab.js +44 -0
- package/dist/Tab.js.map +1 -0
- package/dist/Transport.d.ts +139 -0
- package/dist/Transport.d.ts.map +1 -0
- package/dist/Transport.js +232 -0
- package/dist/Transport.js.map +1 -0
- package/dist/Upload.d.ts +41 -0
- package/dist/Upload.d.ts.map +1 -0
- package/dist/Upload.js +93 -0
- package/dist/Upload.js.map +1 -0
- package/dist/WebMcp.d.ts +78 -0
- package/dist/WebMcp.d.ts.map +1 -0
- package/dist/WebMcp.js +204 -0
- package/dist/WebMcp.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/package.json +97 -3
- package/src/Account.ts +249 -0
- package/src/Agent.ts +387 -0
- package/src/AgentSync.ts +59 -0
- package/src/AppState.ts +222 -0
- package/src/AppStateSync.ts +26 -0
- package/src/Auth.ts +225 -0
- package/src/Avatars.ts +144 -0
- package/src/BrowserAnalytics.ts +133 -0
- package/src/Chat.ts +1150 -0
- package/src/ChatIntegrity.ts +130 -0
- package/src/ChatSends.ts +209 -0
- package/src/Client.ts +319 -0
- package/src/Collab.ts +524 -0
- package/src/CollabTools.ts +381 -0
- package/src/Connections.ts +517 -0
- package/src/Consent.ts +176 -0
- package/src/Desktop.ts +139 -0
- package/src/Directory.ts +71 -0
- package/src/ErrorReporter.ts +112 -0
- package/src/ExpoSqlite.ts +6 -0
- package/src/FileSync.ts +34 -0
- package/src/FileTables.gen.ts +23 -0
- package/src/Foldkit.ts +960 -0
- package/src/History.ts +337 -0
- package/src/InboxSync.ts +47 -0
- package/src/KernelTables.gen.ts +329 -0
- package/src/Make.ts +120 -0
- package/src/Models.ts +134 -0
- package/src/Optimistic.ts +364 -0
- package/src/PlatformSync.ts +156 -0
- package/src/Poll.ts +227 -0
- package/src/Preferences.ts +42 -0
- package/src/Proposals.ts +57 -0
- package/src/React.ts +26 -0
- package/src/Reader.ts +180 -0
- package/src/Resources.ts +257 -0
- package/src/Rows.ts +16 -0
- package/src/Runtime.ts +1409 -0
- package/src/RuntimeRuns.ts +180 -0
- package/src/ServicesSync.ts +58 -0
- package/src/Session.ts +814 -0
- package/src/ShareGrant.ts +20 -0
- package/src/Sharing.ts +696 -0
- package/src/Skew.ts +97 -0
- package/src/SpacesSync.ts +61 -0
- package/src/Storage.ts +167 -0
- package/src/Sync.ts +125 -0
- package/src/SyncTables.ts +12 -0
- package/src/Tab.ts +59 -0
- package/src/Transport.ts +321 -0
- package/src/Upload.ts +125 -0
- package/src/WebMcp.ts +279 -0
- package/src/index.ts +26 -0
- package/src/web-globals.d.ts +103 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consent before and after sign-in, headless (the Privacy contract's visitor routes): a visitor's region (their time
|
|
3
|
+
* zone, or a country an edge stated), their category choices (kept by the kernel on their visit, which an HttpOnly
|
|
4
|
+
* cookie names, so a banner shows the same choices on every page), the touch that brought them (recorded only with
|
|
5
|
+
* their marketing consent), the scripts an app loads per category (loaded once granted, unloaded once refused), and
|
|
6
|
+
* the visit claimed at sign-in so the choices become the person's. The cookie banner itself is the app's.
|
|
7
|
+
*
|
|
8
|
+
* In a browser on another origin than the kernel, the kernel must trust the app's origin (`ELOXIV_TRUSTED_ORIGINS`)
|
|
9
|
+
* for its cookie to travel; `fetch` can be replaced (a server-side render, a test).
|
|
10
|
+
*/
|
|
11
|
+
import type { ConsentCategory, RegionHint, VisitRequest, VisitState, VisitTouch } from "@eloxiv/contracts";
|
|
12
|
+
/** A script an app loads only with consent for its category (analytics, a chat widget, an ad pixel). */
|
|
13
|
+
export interface ConsentScript {
|
|
14
|
+
readonly category: Exclude<ConsentCategory, "necessary">;
|
|
15
|
+
/** Load it (insert the tag, start the SDK); called once each time consent is granted. */
|
|
16
|
+
readonly load: () => void | Promise<void>;
|
|
17
|
+
/** Stop it and remove what it set; called once each time consent is withdrawn after it loaded. */
|
|
18
|
+
readonly unload?: (() => void | Promise<void>) | undefined;
|
|
19
|
+
}
|
|
20
|
+
export interface ConsentControllerOptions {
|
|
21
|
+
/** The kernel's base URL. */
|
|
22
|
+
readonly baseUrl: string;
|
|
23
|
+
/** Where the visitor is (default: their time zone). */
|
|
24
|
+
readonly region?: RegionHint | undefined;
|
|
25
|
+
/** Replace `fetch` (it must send and keep the visit cookie: `credentials: "include"` in a browser). */
|
|
26
|
+
readonly fetch?: typeof fetch | undefined;
|
|
27
|
+
}
|
|
28
|
+
/** The touch a page's address and referrer describe: UTM parameters, ad-click ids present, the path, the referrer. */
|
|
29
|
+
export declare const touchFromLocation: (href: string, referrer?: string) => VisitTouch;
|
|
30
|
+
/** A refused visitor request: the HTTP status and the kernel's error. */
|
|
31
|
+
export declare class ConsentRequestError extends Error {
|
|
32
|
+
readonly status: number;
|
|
33
|
+
readonly error: {
|
|
34
|
+
readonly _tag: string;
|
|
35
|
+
readonly message?: string;
|
|
36
|
+
};
|
|
37
|
+
constructor(status: number, error: {
|
|
38
|
+
readonly _tag: string;
|
|
39
|
+
readonly message?: string;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
export declare const consentController: (options: ConsentControllerOptions) => {
|
|
43
|
+
/** The visitor's consent and attribution, as the kernel holds them (scripts follow it). */
|
|
44
|
+
load: () => Promise<{
|
|
45
|
+
readonly consent: {
|
|
46
|
+
readonly userId: string;
|
|
47
|
+
readonly region: string | null;
|
|
48
|
+
readonly mode: "opt-in" | "opt-out";
|
|
49
|
+
readonly categories: {
|
|
50
|
+
readonly necessary: {
|
|
51
|
+
readonly granted: boolean;
|
|
52
|
+
readonly source: "choice" | "necessary" | "region";
|
|
53
|
+
readonly decidedAt: number | null;
|
|
54
|
+
};
|
|
55
|
+
readonly functional: {
|
|
56
|
+
readonly granted: boolean;
|
|
57
|
+
readonly source: "choice" | "necessary" | "region";
|
|
58
|
+
readonly decidedAt: number | null;
|
|
59
|
+
};
|
|
60
|
+
readonly analytics: {
|
|
61
|
+
readonly granted: boolean;
|
|
62
|
+
readonly source: "choice" | "necessary" | "region";
|
|
63
|
+
readonly decidedAt: number | null;
|
|
64
|
+
};
|
|
65
|
+
readonly marketing: {
|
|
66
|
+
readonly granted: boolean;
|
|
67
|
+
readonly source: "choice" | "necessary" | "region";
|
|
68
|
+
readonly decidedAt: number | null;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
readonly attribution: {
|
|
73
|
+
readonly first: {
|
|
74
|
+
readonly channel: "campaign" | "direct" | "paid" | "referral";
|
|
75
|
+
readonly source: string | null;
|
|
76
|
+
readonly medium: string | null;
|
|
77
|
+
readonly campaign: string | null;
|
|
78
|
+
readonly term: string | null;
|
|
79
|
+
readonly content: string | null;
|
|
80
|
+
readonly referrerHost: string | null;
|
|
81
|
+
readonly landingPath: string | null;
|
|
82
|
+
readonly clickIds: readonly string[];
|
|
83
|
+
readonly at: string;
|
|
84
|
+
};
|
|
85
|
+
readonly last: {
|
|
86
|
+
readonly channel: "campaign" | "direct" | "paid" | "referral";
|
|
87
|
+
readonly source: string | null;
|
|
88
|
+
readonly medium: string | null;
|
|
89
|
+
readonly campaign: string | null;
|
|
90
|
+
readonly term: string | null;
|
|
91
|
+
readonly content: string | null;
|
|
92
|
+
readonly referrerHost: string | null;
|
|
93
|
+
readonly landingPath: string | null;
|
|
94
|
+
readonly clickIds: readonly string[];
|
|
95
|
+
readonly at: string;
|
|
96
|
+
};
|
|
97
|
+
} | null;
|
|
98
|
+
readonly claim: string | null;
|
|
99
|
+
}>;
|
|
100
|
+
/** Record choices (a banner's answer): categories left out keep their choice, or their region's default. */
|
|
101
|
+
choose: (choices: NonNullable<VisitRequest["choices"]>) => Promise<{
|
|
102
|
+
readonly consent: {
|
|
103
|
+
readonly userId: string;
|
|
104
|
+
readonly region: string | null;
|
|
105
|
+
readonly mode: "opt-in" | "opt-out";
|
|
106
|
+
readonly categories: {
|
|
107
|
+
readonly necessary: {
|
|
108
|
+
readonly granted: boolean;
|
|
109
|
+
readonly source: "choice" | "necessary" | "region";
|
|
110
|
+
readonly decidedAt: number | null;
|
|
111
|
+
};
|
|
112
|
+
readonly functional: {
|
|
113
|
+
readonly granted: boolean;
|
|
114
|
+
readonly source: "choice" | "necessary" | "region";
|
|
115
|
+
readonly decidedAt: number | null;
|
|
116
|
+
};
|
|
117
|
+
readonly analytics: {
|
|
118
|
+
readonly granted: boolean;
|
|
119
|
+
readonly source: "choice" | "necessary" | "region";
|
|
120
|
+
readonly decidedAt: number | null;
|
|
121
|
+
};
|
|
122
|
+
readonly marketing: {
|
|
123
|
+
readonly granted: boolean;
|
|
124
|
+
readonly source: "choice" | "necessary" | "region";
|
|
125
|
+
readonly decidedAt: number | null;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
readonly attribution: {
|
|
130
|
+
readonly first: {
|
|
131
|
+
readonly channel: "campaign" | "direct" | "paid" | "referral";
|
|
132
|
+
readonly source: string | null;
|
|
133
|
+
readonly medium: string | null;
|
|
134
|
+
readonly campaign: string | null;
|
|
135
|
+
readonly term: string | null;
|
|
136
|
+
readonly content: string | null;
|
|
137
|
+
readonly referrerHost: string | null;
|
|
138
|
+
readonly landingPath: string | null;
|
|
139
|
+
readonly clickIds: readonly string[];
|
|
140
|
+
readonly at: string;
|
|
141
|
+
};
|
|
142
|
+
readonly last: {
|
|
143
|
+
readonly channel: "campaign" | "direct" | "paid" | "referral";
|
|
144
|
+
readonly source: string | null;
|
|
145
|
+
readonly medium: string | null;
|
|
146
|
+
readonly campaign: string | null;
|
|
147
|
+
readonly term: string | null;
|
|
148
|
+
readonly content: string | null;
|
|
149
|
+
readonly referrerHost: string | null;
|
|
150
|
+
readonly landingPath: string | null;
|
|
151
|
+
readonly clickIds: readonly string[];
|
|
152
|
+
readonly at: string;
|
|
153
|
+
};
|
|
154
|
+
} | null;
|
|
155
|
+
readonly claim: string | null;
|
|
156
|
+
}>;
|
|
157
|
+
/** Record the touch that brought the visitor (kept only with their marketing consent). */
|
|
158
|
+
touch: (touch: VisitTouch) => Promise<{
|
|
159
|
+
readonly consent: {
|
|
160
|
+
readonly userId: string;
|
|
161
|
+
readonly region: string | null;
|
|
162
|
+
readonly mode: "opt-in" | "opt-out";
|
|
163
|
+
readonly categories: {
|
|
164
|
+
readonly necessary: {
|
|
165
|
+
readonly granted: boolean;
|
|
166
|
+
readonly source: "choice" | "necessary" | "region";
|
|
167
|
+
readonly decidedAt: number | null;
|
|
168
|
+
};
|
|
169
|
+
readonly functional: {
|
|
170
|
+
readonly granted: boolean;
|
|
171
|
+
readonly source: "choice" | "necessary" | "region";
|
|
172
|
+
readonly decidedAt: number | null;
|
|
173
|
+
};
|
|
174
|
+
readonly analytics: {
|
|
175
|
+
readonly granted: boolean;
|
|
176
|
+
readonly source: "choice" | "necessary" | "region";
|
|
177
|
+
readonly decidedAt: number | null;
|
|
178
|
+
};
|
|
179
|
+
readonly marketing: {
|
|
180
|
+
readonly granted: boolean;
|
|
181
|
+
readonly source: "choice" | "necessary" | "region";
|
|
182
|
+
readonly decidedAt: number | null;
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
readonly attribution: {
|
|
187
|
+
readonly first: {
|
|
188
|
+
readonly channel: "campaign" | "direct" | "paid" | "referral";
|
|
189
|
+
readonly source: string | null;
|
|
190
|
+
readonly medium: string | null;
|
|
191
|
+
readonly campaign: string | null;
|
|
192
|
+
readonly term: string | null;
|
|
193
|
+
readonly content: string | null;
|
|
194
|
+
readonly referrerHost: string | null;
|
|
195
|
+
readonly landingPath: string | null;
|
|
196
|
+
readonly clickIds: readonly string[];
|
|
197
|
+
readonly at: string;
|
|
198
|
+
};
|
|
199
|
+
readonly last: {
|
|
200
|
+
readonly channel: "campaign" | "direct" | "paid" | "referral";
|
|
201
|
+
readonly source: string | null;
|
|
202
|
+
readonly medium: string | null;
|
|
203
|
+
readonly campaign: string | null;
|
|
204
|
+
readonly term: string | null;
|
|
205
|
+
readonly content: string | null;
|
|
206
|
+
readonly referrerHost: string | null;
|
|
207
|
+
readonly landingPath: string | null;
|
|
208
|
+
readonly clickIds: readonly string[];
|
|
209
|
+
readonly at: string;
|
|
210
|
+
};
|
|
211
|
+
} | null;
|
|
212
|
+
readonly claim: string | null;
|
|
213
|
+
}>;
|
|
214
|
+
/** The last state seen, if any. */
|
|
215
|
+
readonly state: VisitState | undefined;
|
|
216
|
+
/** Is the category granted in the last state seen? (`necessary` always is; anything else is not before `load`.) */
|
|
217
|
+
granted: (category: ConsentCategory) => boolean;
|
|
218
|
+
/** A script loaded while its category is granted and unloaded when it is withdrawn. */
|
|
219
|
+
register: (script: ConsentScript) => Promise<undefined> | Promise<{
|
|
220
|
+
readonly consent: {
|
|
221
|
+
readonly userId: string;
|
|
222
|
+
readonly region: string | null;
|
|
223
|
+
readonly mode: "opt-in" | "opt-out";
|
|
224
|
+
readonly categories: {
|
|
225
|
+
readonly necessary: {
|
|
226
|
+
readonly granted: boolean;
|
|
227
|
+
readonly source: "choice" | "necessary" | "region";
|
|
228
|
+
readonly decidedAt: number | null;
|
|
229
|
+
};
|
|
230
|
+
readonly functional: {
|
|
231
|
+
readonly granted: boolean;
|
|
232
|
+
readonly source: "choice" | "necessary" | "region";
|
|
233
|
+
readonly decidedAt: number | null;
|
|
234
|
+
};
|
|
235
|
+
readonly analytics: {
|
|
236
|
+
readonly granted: boolean;
|
|
237
|
+
readonly source: "choice" | "necessary" | "region";
|
|
238
|
+
readonly decidedAt: number | null;
|
|
239
|
+
};
|
|
240
|
+
readonly marketing: {
|
|
241
|
+
readonly granted: boolean;
|
|
242
|
+
readonly source: "choice" | "necessary" | "region";
|
|
243
|
+
readonly decidedAt: number | null;
|
|
244
|
+
};
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
readonly attribution: {
|
|
248
|
+
readonly first: {
|
|
249
|
+
readonly channel: "campaign" | "direct" | "paid" | "referral";
|
|
250
|
+
readonly source: string | null;
|
|
251
|
+
readonly medium: string | null;
|
|
252
|
+
readonly campaign: string | null;
|
|
253
|
+
readonly term: string | null;
|
|
254
|
+
readonly content: string | null;
|
|
255
|
+
readonly referrerHost: string | null;
|
|
256
|
+
readonly landingPath: string | null;
|
|
257
|
+
readonly clickIds: readonly string[];
|
|
258
|
+
readonly at: string;
|
|
259
|
+
};
|
|
260
|
+
readonly last: {
|
|
261
|
+
readonly channel: "campaign" | "direct" | "paid" | "referral";
|
|
262
|
+
readonly source: string | null;
|
|
263
|
+
readonly medium: string | null;
|
|
264
|
+
readonly campaign: string | null;
|
|
265
|
+
readonly term: string | null;
|
|
266
|
+
readonly content: string | null;
|
|
267
|
+
readonly referrerHost: string | null;
|
|
268
|
+
readonly landingPath: string | null;
|
|
269
|
+
readonly clickIds: readonly string[];
|
|
270
|
+
readonly at: string;
|
|
271
|
+
};
|
|
272
|
+
} | null;
|
|
273
|
+
readonly claim: string | null;
|
|
274
|
+
}>;
|
|
275
|
+
/** Every state from now on (a consent mode adapter, a banner). Returns the unsubscribe. */
|
|
276
|
+
subscribe: (listener: (state: VisitState) => void) => () => undefined;
|
|
277
|
+
/** Once signed in: the visit becomes the person's, its choices theirs where they made none (after `load`). */
|
|
278
|
+
claim: (token: string) => Promise<{
|
|
279
|
+
readonly carried: readonly ("analytics" | "functional" | "marketing" | "necessary")[];
|
|
280
|
+
readonly consent: {
|
|
281
|
+
readonly userId: string;
|
|
282
|
+
readonly region: string | null;
|
|
283
|
+
readonly mode: "opt-in" | "opt-out";
|
|
284
|
+
readonly categories: {
|
|
285
|
+
readonly necessary: {
|
|
286
|
+
readonly granted: boolean;
|
|
287
|
+
readonly source: "choice" | "necessary" | "region";
|
|
288
|
+
readonly decidedAt: number | null;
|
|
289
|
+
};
|
|
290
|
+
readonly functional: {
|
|
291
|
+
readonly granted: boolean;
|
|
292
|
+
readonly source: "choice" | "necessary" | "region";
|
|
293
|
+
readonly decidedAt: number | null;
|
|
294
|
+
};
|
|
295
|
+
readonly analytics: {
|
|
296
|
+
readonly granted: boolean;
|
|
297
|
+
readonly source: "choice" | "necessary" | "region";
|
|
298
|
+
readonly decidedAt: number | null;
|
|
299
|
+
};
|
|
300
|
+
readonly marketing: {
|
|
301
|
+
readonly granted: boolean;
|
|
302
|
+
readonly source: "choice" | "necessary" | "region";
|
|
303
|
+
readonly decidedAt: number | null;
|
|
304
|
+
};
|
|
305
|
+
};
|
|
306
|
+
};
|
|
307
|
+
readonly attribution: {
|
|
308
|
+
readonly first: {
|
|
309
|
+
readonly channel: "campaign" | "direct" | "paid" | "referral";
|
|
310
|
+
readonly source: string | null;
|
|
311
|
+
readonly medium: string | null;
|
|
312
|
+
readonly campaign: string | null;
|
|
313
|
+
readonly term: string | null;
|
|
314
|
+
readonly content: string | null;
|
|
315
|
+
readonly referrerHost: string | null;
|
|
316
|
+
readonly landingPath: string | null;
|
|
317
|
+
readonly clickIds: readonly string[];
|
|
318
|
+
readonly at: string;
|
|
319
|
+
};
|
|
320
|
+
readonly last: {
|
|
321
|
+
readonly channel: "campaign" | "direct" | "paid" | "referral";
|
|
322
|
+
readonly source: string | null;
|
|
323
|
+
readonly medium: string | null;
|
|
324
|
+
readonly campaign: string | null;
|
|
325
|
+
readonly term: string | null;
|
|
326
|
+
readonly content: string | null;
|
|
327
|
+
readonly referrerHost: string | null;
|
|
328
|
+
readonly landingPath: string | null;
|
|
329
|
+
readonly clickIds: readonly string[];
|
|
330
|
+
readonly at: string;
|
|
331
|
+
};
|
|
332
|
+
} | null;
|
|
333
|
+
}>;
|
|
334
|
+
/** Wait for script loads and unloads in progress. */
|
|
335
|
+
settled: () => Promise<void>;
|
|
336
|
+
};
|
|
337
|
+
export type ConsentController = ReturnType<typeof consentController>;
|
|
338
|
+
//# sourceMappingURL=Consent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Consent.d.ts","sourceRoot":"","sources":["../src/Consent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;A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I;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACJ,4GAA4G;IAC5G,MAAM,YAAY,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACtD,0FAA0F;IAC1F,KAAK,UAAU,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IACzB,mCAAmC;aAC/B,KAAK,EAAI,UAAU,GAAG,SAAS;IAGnC,mHAAmH;IACnH,OAAO,aAAa,eAAe;IAEnC,uFAAuF;IACvF,QAAQ,WAAW,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAIhC,2FAA2F;IAC3F,SAAS,aAAa,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI;IAIjD,8GAA8G;IAC9G,KAAK,UAAgB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAS3B,qDAAqD;IACrD,OAAO;CAEV,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAA"}
|
package/dist/Consent.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { CLICK_IDS, VISIT_PATHS } from "@eloxiv/contracts";
|
|
2
|
+
/** The touch a page's address and referrer describe: UTM parameters, ad-click ids present, the path, the referrer. */
|
|
3
|
+
export const touchFromLocation = (href, referrer) => {
|
|
4
|
+
const query = href.includes("?") ? href.slice(href.indexOf("?") + 1).split("#")[0] : "";
|
|
5
|
+
const params = new Map();
|
|
6
|
+
for (const pair of query.split("&")) {
|
|
7
|
+
if (pair === "")
|
|
8
|
+
continue;
|
|
9
|
+
const at = pair.indexOf("=");
|
|
10
|
+
const key = decodeURIComponent((at < 0 ? pair : pair.slice(0, at)).replaceAll("+", " "));
|
|
11
|
+
params.set(key, at < 0 ? "" : decodeURIComponent(pair.slice(at + 1).replaceAll("+", " ")));
|
|
12
|
+
}
|
|
13
|
+
const utm = (name) => {
|
|
14
|
+
const value = params.get(`utm_${name}`)?.slice(0, 200);
|
|
15
|
+
return value === undefined || value === "" ? {} : { [name]: value };
|
|
16
|
+
};
|
|
17
|
+
const afterOrigin = href.replace(/^[a-z][a-z0-9+.-]*:\/\/[^/]*/iu, "");
|
|
18
|
+
const path = (afterOrigin === "" ? "/" : afterOrigin).split(/[?#]/u)[0].slice(0, 500);
|
|
19
|
+
const clickIds = CLICK_IDS.filter((id) => params.has(id));
|
|
20
|
+
return {
|
|
21
|
+
...utm("source"),
|
|
22
|
+
...utm("medium"),
|
|
23
|
+
...utm("campaign"),
|
|
24
|
+
...utm("term"),
|
|
25
|
+
...utm("content"),
|
|
26
|
+
...(referrer === undefined || referrer === "" ? {} : { referrer: referrer.slice(0, 2_000) }),
|
|
27
|
+
landingPath: path,
|
|
28
|
+
...(clickIds.length === 0 ? {} : { clickIds }),
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
const timeZone = () => {
|
|
32
|
+
try {
|
|
33
|
+
const zone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
34
|
+
return typeof zone === "string" && zone !== "" ? { timeZone: zone } : {};
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
/** A refused visitor request: the HTTP status and the kernel's error. */
|
|
41
|
+
export class ConsentRequestError extends Error {
|
|
42
|
+
status;
|
|
43
|
+
error;
|
|
44
|
+
constructor(status, error) {
|
|
45
|
+
super(error.message ?? error._tag);
|
|
46
|
+
this.status = status;
|
|
47
|
+
this.error = error;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export const consentController = (options) => {
|
|
51
|
+
const base = options.baseUrl.replace(/\/+$/u, "");
|
|
52
|
+
const send = options.fetch ?? fetch;
|
|
53
|
+
const region = options.region ?? timeZone();
|
|
54
|
+
const scripts = [];
|
|
55
|
+
const listeners = new Set();
|
|
56
|
+
let current;
|
|
57
|
+
// Once the visit is claimed: the person's consent in the organisation, which every later state follows.
|
|
58
|
+
let account;
|
|
59
|
+
// Script loads and unloads run one at a time, in the order states arrive.
|
|
60
|
+
let applying = Promise.resolve();
|
|
61
|
+
const apply = (received) => {
|
|
62
|
+
const state = account === undefined ? received : { ...received, consent: account };
|
|
63
|
+
current = state;
|
|
64
|
+
applying = applying.then(async () => {
|
|
65
|
+
for (const entry of scripts) {
|
|
66
|
+
const granted = state.consent.categories[entry.script.category].granted;
|
|
67
|
+
// A script that fails to load or unload is the app's to report; the others still follow the state.
|
|
68
|
+
try {
|
|
69
|
+
if (granted && !entry.loaded) {
|
|
70
|
+
entry.loaded = true;
|
|
71
|
+
await entry.script.load();
|
|
72
|
+
}
|
|
73
|
+
else if (!granted && entry.loaded) {
|
|
74
|
+
entry.loaded = false;
|
|
75
|
+
await entry.script.unload?.();
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
// (ignored: see above)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return undefined;
|
|
83
|
+
});
|
|
84
|
+
for (const listener of listeners)
|
|
85
|
+
listener(state);
|
|
86
|
+
return applying.then(() => state);
|
|
87
|
+
};
|
|
88
|
+
const request = async (method, path, body, token) => {
|
|
89
|
+
const headers = { "content-type": "application/json" };
|
|
90
|
+
if (token !== undefined)
|
|
91
|
+
headers["authorization"] = `Bearer ${token}`;
|
|
92
|
+
const response = await send(`${base}${path}`, {
|
|
93
|
+
method,
|
|
94
|
+
headers,
|
|
95
|
+
credentials: "include",
|
|
96
|
+
...(body === undefined ? {} : { body: JSON.stringify(body) }),
|
|
97
|
+
});
|
|
98
|
+
const parsed = (await response.json().catch(() => ({})));
|
|
99
|
+
if (!response.ok)
|
|
100
|
+
throw new ConsentRequestError(response.status, { _tag: parsed._tag ?? `HTTP ${response.status}`, ...parsed });
|
|
101
|
+
return parsed;
|
|
102
|
+
};
|
|
103
|
+
const post = (body) => request("POST", VISIT_PATHS.visit, { region, ...body }).then(apply);
|
|
104
|
+
return {
|
|
105
|
+
/** The visitor's consent and attribution, as the kernel holds them (scripts follow it). */
|
|
106
|
+
load: () => request("GET", VISIT_PATHS.visit).then(apply),
|
|
107
|
+
/** Record choices (a banner's answer): categories left out keep their choice, or their region's default. */
|
|
108
|
+
choose: (choices) => post({ choices }),
|
|
109
|
+
/** Record the touch that brought the visitor (kept only with their marketing consent). */
|
|
110
|
+
touch: (touch) => post({ touch }),
|
|
111
|
+
/** The last state seen, if any. */
|
|
112
|
+
get state() {
|
|
113
|
+
return current;
|
|
114
|
+
},
|
|
115
|
+
/** Is the category granted in the last state seen? (`necessary` always is; anything else is not before `load`.) */
|
|
116
|
+
granted: (category) => category === "necessary" || current?.consent.categories[category].granted === true,
|
|
117
|
+
/** A script loaded while its category is granted and unloaded when it is withdrawn. */
|
|
118
|
+
register: (script) => {
|
|
119
|
+
scripts.push({ script, loaded: false });
|
|
120
|
+
return current === undefined ? Promise.resolve(undefined) : apply(current);
|
|
121
|
+
},
|
|
122
|
+
/** Every state from now on (a consent mode adapter, a banner). Returns the unsubscribe. */
|
|
123
|
+
subscribe: (listener) => {
|
|
124
|
+
listeners.add(listener);
|
|
125
|
+
return () => void listeners.delete(listener);
|
|
126
|
+
},
|
|
127
|
+
/** Once signed in: the visit becomes the person's, its choices theirs where they made none (after `load`). */
|
|
128
|
+
claim: async (token) => {
|
|
129
|
+
const claim = current?.claim ?? (await request("GET", VISIT_PATHS.visit).then(apply)).claim;
|
|
130
|
+
if (claim === null)
|
|
131
|
+
throw new ConsentRequestError(400, { _tag: "InvalidInput", message: "No visit to claim" });
|
|
132
|
+
const claimed = await request("POST", VISIT_PATHS.claim, { claim }, token);
|
|
133
|
+
// From here on the person's own consent decides: a category they refused unloads its scripts.
|
|
134
|
+
account = claimed.consent;
|
|
135
|
+
await apply({ claim, consent: claimed.consent, attribution: claimed.attribution });
|
|
136
|
+
return claimed;
|
|
137
|
+
},
|
|
138
|
+
/** Wait for script loads and unloads in progress. */
|
|
139
|
+
settled: () => applying,
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
//# sourceMappingURL=Consent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Consent.js","sourceRoot":"","sources":["../src/Consent.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAoB1D,sHAAsH;AACtH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAE,QAAiB,EAAc,EAAE;IAC/E,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,EAAE,CAAA;IACxF,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAA;IACxC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACpC,IAAI,IAAI,KAAK,EAAE;YAAE,SAAQ;QACzB,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QAC5B,MAAM,GAAG,GAAG,kBAAkB,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;QACxF,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAA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B,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,mBAAmB,EAAE,CAAC,CAAA;YAC9G,MAAM,OAAO,GAAG,MAAM,OAAO,CAAe,MAAM,EAAE,WAAW,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,CAAA;YACxF,8FAA8F;YAC9F,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;YACzB,MAAM,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAA;YAClF,OAAO,OAAO,CAAA;QAChB,CAAC;QACD,qDAAqD;QACrD,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ;KACxB,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Desktop sign-in, headless (the kernel's `DesktopSignIn.ts`): a desktop or native app gets a session of its own
|
|
3
|
+
* through the system browser, never by copying the browser's cookie. The app keeps a PKCE verifier; the browser,
|
|
4
|
+
* signed in, approves its challenge and is sent to the app's redirect with a one-time code; the app redeems the code
|
|
5
|
+
* with its verifier. Only the instance holding the verifier can redeem it, once, within a minute, while the session
|
|
6
|
+
* that approved it lasts.
|
|
7
|
+
*
|
|
8
|
+
* const login = await beginDesktopSignIn({ redirectUri: "http://127.0.0.1:43123/done" })
|
|
9
|
+
* open(`${signInPage}?${login.query}`) // the app's web sign-in page, which calls approveDesktopSignIn
|
|
10
|
+
* const { code, state } = await receive() // the loopback server (or deep link) the browser lands on
|
|
11
|
+
* const session = await completeDesktopSignIn(baseUrl, login, { code, state })
|
|
12
|
+
*
|
|
13
|
+
* `desktopSignIn(controller, ...)` runs the whole journey into the shared session controller (the desktop identity
|
|
14
|
+
* bootstrap).
|
|
15
|
+
*/
|
|
16
|
+
import { type Session } from "./Auth.ts";
|
|
17
|
+
import type { SessionController } from "./Session.ts";
|
|
18
|
+
/** What the app keeps between opening the browser and receiving its code. */
|
|
19
|
+
export interface DesktopSignIn {
|
|
20
|
+
readonly verifier: string;
|
|
21
|
+
readonly challenge: string;
|
|
22
|
+
readonly state: string;
|
|
23
|
+
readonly redirectUri: string;
|
|
24
|
+
/** The query to append to the app's sign-in page: `challenge`, `redirect_uri`, `state`. */
|
|
25
|
+
readonly query: string;
|
|
26
|
+
}
|
|
27
|
+
/** Start a desktop sign-in: a fresh verifier (kept by the app), its S256 challenge and a state. */
|
|
28
|
+
export declare const beginDesktopSignIn: (input: {
|
|
29
|
+
readonly redirectUri: string;
|
|
30
|
+
}) => Promise<DesktopSignIn>;
|
|
31
|
+
/**
|
|
32
|
+
* The browser's step, on the app's own web sign-in page, signed in (`token`, or the session cookie when omitted):
|
|
33
|
+
* approve the desktop's challenge. Answers where to send the browser next (the app's redirect, with the code).
|
|
34
|
+
*/
|
|
35
|
+
export declare const approveDesktopSignIn: (baseUrl: string, token: string | undefined, input: {
|
|
36
|
+
readonly challenge: string;
|
|
37
|
+
readonly redirectUri: string;
|
|
38
|
+
readonly state: string;
|
|
39
|
+
}) => Promise<{
|
|
40
|
+
readonly redirect: string;
|
|
41
|
+
}>;
|
|
42
|
+
/** The app's step: redeem the code its redirect received, with its verifier. Refuses a state it did not send. */
|
|
43
|
+
export declare const completeDesktopSignIn: (baseUrl: string, login: DesktopSignIn, received: {
|
|
44
|
+
readonly code: string;
|
|
45
|
+
readonly state: string;
|
|
46
|
+
}) => Promise<Session>;
|
|
47
|
+
/**
|
|
48
|
+
* The desktop identity bootstrap: the whole sign-in journey into the shared session controller. `open` shows the
|
|
49
|
+
* app's web sign-in page (with the query); `receive` resolves with what the redirect received.
|
|
50
|
+
*/
|
|
51
|
+
export declare const desktopSignIn: (controller: SessionController, input: {
|
|
52
|
+
readonly baseUrl: string;
|
|
53
|
+
readonly redirectUri: string;
|
|
54
|
+
readonly signInPage: string;
|
|
55
|
+
readonly open: (url: string) => Promise<void>;
|
|
56
|
+
readonly receive: () => Promise<{
|
|
57
|
+
readonly code: string;
|
|
58
|
+
readonly state: string;
|
|
59
|
+
}>;
|
|
60
|
+
}) => Promise<void>;
|
|
61
|
+
//# sourceMappingURL=Desktop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Desktop.d.ts","sourceRoot":"","sources":["../src/Desktop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAuB,KAAK,OAAO,EAAE,MAAM,WAAW,CAAA;AAC7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAErD,6EAA6E;AAC7E,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,2FAA2F;IAC3F,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACvB;AA4BD,mGAAmG;AACnG,eAAO,MAAM,kBAAkB,UAAiB;IAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;CAAE,KAAG,OAAO,CAAC,aAAa,CAcvG,CAAA;AA0BD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,YACtB,MAAM,SACR,MAAM,GAAG,SAAS,SAClB;IAAE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,KAC1F,OAAO,CAAC;IAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CACsD,CAAA;AAE9F,iHAAiH;AACjH,eAAO,MAAM,qBAAqB,YACvB,MAAM,SACR,aAAa,YACV;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,KAC1D,OAAO,CAAC,OAAO,CAQjB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,eACZ,iBAAiB,SACtB;IACL,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7C,QAAQ,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CACnF,KACA,OAAO,CAAC,IAAI,CAId,CAAA"}
|
package/dist/Desktop.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Desktop sign-in, headless (the kernel's `DesktopSignIn.ts`): a desktop or native app gets a session of its own
|
|
3
|
+
* through the system browser, never by copying the browser's cookie. The app keeps a PKCE verifier; the browser,
|
|
4
|
+
* signed in, approves its challenge and is sent to the app's redirect with a one-time code; the app redeems the code
|
|
5
|
+
* with its verifier. Only the instance holding the verifier can redeem it, once, within a minute, while the session
|
|
6
|
+
* that approved it lasts.
|
|
7
|
+
*
|
|
8
|
+
* const login = await beginDesktopSignIn({ redirectUri: "http://127.0.0.1:43123/done" })
|
|
9
|
+
* open(`${signInPage}?${login.query}`) // the app's web sign-in page, which calls approveDesktopSignIn
|
|
10
|
+
* const { code, state } = await receive() // the loopback server (or deep link) the browser lands on
|
|
11
|
+
* const session = await completeDesktopSignIn(baseUrl, login, { code, state })
|
|
12
|
+
*
|
|
13
|
+
* `desktopSignIn(controller, ...)` runs the whole journey into the shared session controller (the desktop identity
|
|
14
|
+
* bootstrap).
|
|
15
|
+
*/
|
|
16
|
+
import { AuthError, originOf } from "./Auth.js";
|
|
17
|
+
/**
|
|
18
|
+
* The web globals this file needs, read from `globalThis`: a runtime without one (React Native without its polyfills)
|
|
19
|
+
* has no such global at all, and naming it would throw a ReferenceError instead of this file's own error; React
|
|
20
|
+
* Native's typecheck declares none of them either.
|
|
21
|
+
*/
|
|
22
|
+
const web = globalThis;
|
|
23
|
+
const base64url = (bytes) => {
|
|
24
|
+
if (web.btoa === undefined)
|
|
25
|
+
throw new AuthError("This runtime has no btoa", 0);
|
|
26
|
+
let binary = "";
|
|
27
|
+
for (const byte of bytes)
|
|
28
|
+
binary += String.fromCharCode(byte);
|
|
29
|
+
return web.btoa(binary).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/u, "");
|
|
30
|
+
};
|
|
31
|
+
const random = (length) => {
|
|
32
|
+
if (web.crypto === undefined)
|
|
33
|
+
throw new AuthError("This runtime has no Web Crypto", 0);
|
|
34
|
+
return base64url(web.crypto.getRandomValues(new Uint8Array(length)));
|
|
35
|
+
};
|
|
36
|
+
/** Start a desktop sign-in: a fresh verifier (kept by the app), its S256 challenge and a state. */
|
|
37
|
+
export const beginDesktopSignIn = async (input) => {
|
|
38
|
+
const subtle = web.crypto?.subtle;
|
|
39
|
+
if (subtle === undefined || web.TextEncoder === undefined) {
|
|
40
|
+
throw new AuthError("This runtime has no Web Crypto digest", 0);
|
|
41
|
+
}
|
|
42
|
+
const verifier = random(32);
|
|
43
|
+
const challenge = base64url(new Uint8Array(await subtle.digest("SHA-256", new web.TextEncoder().encode(verifier))));
|
|
44
|
+
const state = random(16);
|
|
45
|
+
const query = [
|
|
46
|
+
`challenge=${encodeURIComponent(challenge)}`,
|
|
47
|
+
`redirect_uri=${encodeURIComponent(input.redirectUri)}`,
|
|
48
|
+
`state=${encodeURIComponent(state)}`,
|
|
49
|
+
].join("&");
|
|
50
|
+
return { verifier, challenge, state, redirectUri: input.redirectUri, query };
|
|
51
|
+
};
|
|
52
|
+
const post = async (baseUrl, path, body, token) => {
|
|
53
|
+
const response = await fetch(`${baseUrl}${path}`, {
|
|
54
|
+
method: "POST",
|
|
55
|
+
headers: {
|
|
56
|
+
"content-type": "application/json",
|
|
57
|
+
origin: originOf(baseUrl),
|
|
58
|
+
...(token === undefined ? {} : { authorization: `Bearer ${token}` }),
|
|
59
|
+
},
|
|
60
|
+
body: JSON.stringify(body),
|
|
61
|
+
});
|
|
62
|
+
const text = await response.text();
|
|
63
|
+
let json;
|
|
64
|
+
try {
|
|
65
|
+
json = text.length === 0 ? {} : JSON.parse(text);
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
json = undefined;
|
|
69
|
+
}
|
|
70
|
+
if (!response.ok) {
|
|
71
|
+
const message = json?.message;
|
|
72
|
+
throw new AuthError(`${path} failed: ${typeof message === "string" ? message : text}`, response.status);
|
|
73
|
+
}
|
|
74
|
+
return json;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* The browser's step, on the app's own web sign-in page, signed in (`token`, or the session cookie when omitted):
|
|
78
|
+
* approve the desktop's challenge. Answers where to send the browser next (the app's redirect, with the code).
|
|
79
|
+
*/
|
|
80
|
+
export const approveDesktopSignIn = async (baseUrl, token, input) => (await post(baseUrl, "/api/desktop/approve", input, token));
|
|
81
|
+
/** The app's step: redeem the code its redirect received, with its verifier. Refuses a state it did not send. */
|
|
82
|
+
export const completeDesktopSignIn = async (baseUrl, login, received) => {
|
|
83
|
+
if (received.state !== login.state)
|
|
84
|
+
throw new AuthError("The sign-in returned a state this app did not send", 400);
|
|
85
|
+
const answer = (await post(baseUrl, "/api/desktop/token", {
|
|
86
|
+
code: received.code,
|
|
87
|
+
verifier: login.verifier,
|
|
88
|
+
redirectUri: login.redirectUri,
|
|
89
|
+
}));
|
|
90
|
+
return { token: answer.token, user: answer.user };
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* The desktop identity bootstrap: the whole sign-in journey into the shared session controller. `open` shows the
|
|
94
|
+
* app's web sign-in page (with the query); `receive` resolves with what the redirect received.
|
|
95
|
+
*/
|
|
96
|
+
export const desktopSignIn = async (controller, input) => {
|
|
97
|
+
const login = await beginDesktopSignIn({ redirectUri: input.redirectUri });
|
|
98
|
+
await input.open(`${input.signInPage}${input.signInPage.includes("?") ? "&" : "?"}${login.query}`);
|
|
99
|
+
await controller.adopt(await completeDesktopSignIn(input.baseUrl, login, await input.receive()));
|
|
100
|
+
};
|
|
101
|
+
//# sourceMappingURL=Desktop.js.map
|