@kottera/tera-web 0.1.0-rc.2 → 0.1.0-rc.4
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/README.md +3 -2
- package/dist/client.d.ts +59 -5
- package/dist/client.js +203 -16
- package/dist/feed/connection.d.ts +2 -0
- package/dist/feed/connection.js +2 -2
- package/dist/generated/kit.d.ts +61 -6
- package/dist/generated/kit.js +24 -4
- package/dist/generated/shares.d.ts +196 -0
- package/dist/generated/shares.js +17 -0
- package/dist/generated/workorder-events.d.ts +1 -1
- package/dist/generated/workorder.d.ts +91 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +3 -1
- package/dist/routes.d.ts +15 -0
- package/dist/routes.js +28 -0
- package/dist/stepup.d.ts +87 -0
- package/dist/stepup.js +66 -0
- package/package.json +1 -1
package/dist/stepup.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/** The request header that carries a confirmed step-up's id to the plugin's route. */
|
|
2
|
+
export const STEP_UP_HEADER = "Tera-Step-Up";
|
|
3
|
+
/** The code of a refusal that needs the person's confirmation. */
|
|
4
|
+
export const STEP_UP_REQUIRED = "step_up_required";
|
|
5
|
+
/**
|
|
6
|
+
* The query parameter the navigation fallback adds to its `return_to`, naming
|
|
7
|
+
* the step-up the person went to confirm, so the page that loads again
|
|
8
|
+
* resumes it rather than beginning another.
|
|
9
|
+
*/
|
|
10
|
+
export const STEP_UP_RESUME_PARAM = "tera_step_up";
|
|
11
|
+
/** How often the step-up's state is read while the person confirms it, by default. */
|
|
12
|
+
export const STEP_UP_POLL_MS = 1000;
|
|
13
|
+
/** A step-up the person did not confirm: the request it was for was not sent again. */
|
|
14
|
+
export class StepUpError extends Error {
|
|
15
|
+
/** The step-up's id. */
|
|
16
|
+
stepUpId;
|
|
17
|
+
/** How it ended. */
|
|
18
|
+
end;
|
|
19
|
+
constructor(stepUpId, end, message) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = "StepUpError";
|
|
22
|
+
this.stepUpId = stepUpId;
|
|
23
|
+
this.end = end;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The step-up a refusal needs confirmed, when it is one this client can have
|
|
28
|
+
* confirmed: code `step_up_required` with a page to open. A refusal naming an
|
|
29
|
+
* ended step-up carries no page, and is not one.
|
|
30
|
+
*/
|
|
31
|
+
export function stepUpChallengeOf(code, stepUp) {
|
|
32
|
+
if (code !== STEP_UP_REQUIRED || typeof stepUp !== "object" || stepUp === null)
|
|
33
|
+
return null;
|
|
34
|
+
const c = stepUp;
|
|
35
|
+
if (typeof c.id !== "string" || c.id === "" || typeof c.url !== "string" || c.url === "")
|
|
36
|
+
return null;
|
|
37
|
+
return c;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The step-up page's URL with `return_to` set to `returnTo`, itself carrying
|
|
41
|
+
* {@link STEP_UP_RESUME_PARAM}. tera follows it back only when it is on the
|
|
42
|
+
* plugin's own origin.
|
|
43
|
+
*/
|
|
44
|
+
export function stepUpPageURL(pageURL, stepUpId, returnTo) {
|
|
45
|
+
const back = new URL(returnTo);
|
|
46
|
+
back.searchParams.set(STEP_UP_RESUME_PARAM, stepUpId);
|
|
47
|
+
const page = new URL(pageURL);
|
|
48
|
+
page.searchParams.set("return_to", back.toString());
|
|
49
|
+
return page.toString();
|
|
50
|
+
}
|
|
51
|
+
/** The step-up id a page loaded through the navigation fallback carries back, or null. */
|
|
52
|
+
export function resumedStepUp(pageURL) {
|
|
53
|
+
try {
|
|
54
|
+
const id = new URL(pageURL).searchParams.get(STEP_UP_RESUME_PARAM);
|
|
55
|
+
return id === null || id === "" ? null : id;
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export function defaultOpenWindow(url) {
|
|
62
|
+
return globalThis.open?.(url, "_blank") ?? null;
|
|
63
|
+
}
|
|
64
|
+
export function defaultSleep(ms) {
|
|
65
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
66
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kottera/tera-web",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.4",
|
|
4
4
|
"description": "The browser half of a UI over tera: a framework-free client for the /tera/v1/ routes a plugin's webui kit serves (ADR-162 D4).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|