apps 0.0.1-beta.2 → 0.0.1-beta.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/framework-reference.json +1 -1
- package/js/{chunk-RN2MXB4R.js → chunk-2VPJHFOU.js} +2 -2
- package/js/{chunk-MYYEW3RA.js → chunk-3M2MEDNL.js} +17 -4
- package/js/{chunk-J7O55ZV7.js → chunk-6VRYO2BG.js} +14 -4
- package/js/{chunk-JN55AYQH.js → chunk-DHUDODG5.js} +1 -1
- package/js/{chunk-HDTGZWP2.js → chunk-EQB7JMAL.js} +2 -2
- package/js/{chunk-OHRT55C4.js → chunk-G7ZIRKMK.js} +0 -3
- package/js/chunk-NQ3OMCA5.js +39 -0
- package/js/{chunk-4LPG6RCH.js → chunk-T2LAZCAD.js} +4 -24
- package/js/client.js +1 -1
- package/js/contracts.js +3 -1
- package/js/effect.js +3 -3
- package/js/graphql.js +3 -3
- package/js/host.js +3 -3
- package/js/index.js +2 -2
- package/js/mcp/effect.js +5 -5
- package/js/mcp/stdio.js +4 -4
- package/js/mcp.js +5 -5
- package/js/ui/auth/contracts.js +7 -8
- package/js/ui/auth.js +13 -11
- package/js/ui/contracts.js +1 -1
- package/js/ui/serving.js +3 -2
- package/package.json +1 -1
- package/runtime.json +1 -1
- package/types/apps/src/contracts/host.d.ts +4 -2
- package/types/apps/src/contracts/protocol-version.d.ts +1 -1
- package/types/apps/src/contracts/protocols/2.d.ts +668 -0
- package/types/apps/src/contracts/ui-auth.d.ts +6 -14
- package/types/apps/src/implementation/ui-auth.d.ts +11 -5
- package/types/apps/src/ui-auth.d.ts +2 -2
- package/js/chunk-TE4KO4HI.js +0 -47
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
/** Browser authentication protocol. Identity and session storage belong to the host. */
|
|
2
2
|
import { Schema } from "effect";
|
|
3
|
-
import { HttpApi, HttpApiEndpoint, HttpApiGroup } from "effect/unstable/httpapi";
|
|
4
|
-
import { UiFailed, UiForbidden, UiUnauthorized } from "./ui.js";
|
|
5
3
|
/** Opaque correlation ID; possession alone does not authorize an app session. */
|
|
6
4
|
export declare const AppSignInId: Schema.brand<Schema.String, "AppSignInId">;
|
|
7
5
|
export type AppSignInId = typeof AppSignInId.Type;
|
|
@@ -10,19 +8,13 @@ export declare const AppSignInCode: Schema.RedactedFromValue<Schema.String>;
|
|
|
10
8
|
/** A path on the current app origin, including its query and fragment; never a redirect to another host or host-owned route. */
|
|
11
9
|
export declare const AppReturnPath: Schema.brand<Schema.String, "AppReturnPath">;
|
|
12
10
|
export type AppReturnPath = typeof AppReturnPath.Type;
|
|
13
|
-
/**
|
|
11
|
+
/** Callback query on the app origin. The code is single-use and works only with its attempt's cookie. */
|
|
14
12
|
export declare const AppSignInCallback: Schema.Struct<{
|
|
15
13
|
readonly request: Schema.brand<Schema.String, "AppSignInId">;
|
|
16
14
|
readonly code: Schema.RedactedFromValue<Schema.String>;
|
|
17
15
|
}>;
|
|
18
|
-
/** Host-owned
|
|
19
|
-
export declare const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}>>, Schema.toCodecJson<typeof UiForbidden | typeof UiFailed>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"complete", "POST", "/_executor/auth/complete", never, never, Schema.toCodecJson<Schema.Struct<{
|
|
24
|
-
readonly request: Schema.brand<Schema.String, "AppSignInId">;
|
|
25
|
-
readonly code: Schema.RedactedFromValue<Schema.String>;
|
|
26
|
-
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
27
|
-
readonly returnTo: Schema.brand<Schema.String, "AppReturnPath">;
|
|
28
|
-
}>>, Schema.toCodecJson<typeof UiUnauthorized | typeof UiForbidden | typeof UiFailed>, never, never>, false>>;
|
|
16
|
+
/** Host-owned callback path on every app origin. */
|
|
17
|
+
export declare const appSignInCallbackPath = "/_executor/auth/callback";
|
|
18
|
+
/** Why the product could not authorize an attempt; the dashboard explains it without retrying. */
|
|
19
|
+
export declare const AppSignInFailure: Schema.Literals<readonly ["ended", "forbidden", "unavailable"]>;
|
|
20
|
+
export type AppSignInFailure = typeof AppSignInFailure.Type;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** Host responses around app sign-in. They carry no script and never contain product credentials. */
|
|
2
2
|
import { HttpServerResponse } from "effect/unstable/http";
|
|
3
|
+
import { type AppSignInId } from "../contracts/ui-auth.js";
|
|
3
4
|
/** Private app responses must not leak authentication URLs through caches or referrers. */
|
|
4
5
|
export declare const appPrivateHeaders: {
|
|
5
6
|
"cache-control": string;
|
|
@@ -7,7 +8,12 @@ export declare const appPrivateHeaders: {
|
|
|
7
8
|
"x-content-type-options": string;
|
|
8
9
|
"content-security-policy": string;
|
|
9
10
|
};
|
|
10
|
-
/**
|
|
11
|
-
export declare const
|
|
12
|
-
/**
|
|
13
|
-
|
|
11
|
+
/** Every sign-in hop is a server redirect, so the browser paints nothing until the app itself. */
|
|
12
|
+
export declare const appRedirect: (url: string) => HttpServerResponse.HttpServerResponse;
|
|
13
|
+
/**
|
|
14
|
+
* The callback URL carries the code in its query. It exists only as a redirect `Location`, never as
|
|
15
|
+
* a rendered document, and redeeming it also requires the attempt's HttpOnly cookie.
|
|
16
|
+
*/
|
|
17
|
+
export declare const appSignInCallback: (origin: string, request: AppSignInId, code: string) => string;
|
|
18
|
+
/** A failed callback explains itself without script; reopening the app URL starts a new attempt. */
|
|
19
|
+
export declare const appSignInFailed: () => HttpServerResponse.HttpServerResponse;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/** Host-only app authentication protocol
|
|
1
|
+
/** Host-only app authentication protocol; products supply identity and session lifecycle. */
|
|
2
2
|
export * from "./contracts/ui-auth.js";
|
|
3
|
-
export { appPrivateHeaders,
|
|
3
|
+
export { appPrivateHeaders, appRedirect, appSignInCallback, appSignInFailed, } from "./implementation/ui-auth.js";
|
package/js/chunk-TE4KO4HI.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
HttpServerResponse_exports
|
|
3
|
-
} from "./chunk-QKHR7BMF.js";
|
|
4
|
-
|
|
5
|
-
// src/implementation/ui-auth.ts
|
|
6
|
-
var appPrivateHeaders = {
|
|
7
|
-
"cache-control": "no-store",
|
|
8
|
-
"referrer-policy": "no-referrer",
|
|
9
|
-
"x-content-type-options": "nosniff",
|
|
10
|
-
"content-security-policy": "frame-ancestors 'none'"
|
|
11
|
-
};
|
|
12
|
-
var appSignInPage = () => HttpServerResponse_exports.text(
|
|
13
|
-
`<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Opening app</title></head><body><p>Opening app\u2026</p><a href="/" hidden>Try again</a><script src="/_executor/auth/browser.js"></script></body></html>`,
|
|
14
|
-
{
|
|
15
|
-
contentType: "text/html",
|
|
16
|
-
headers: {
|
|
17
|
-
...appPrivateHeaders,
|
|
18
|
-
"content-security-policy": "default-src 'none'; script-src 'self'; connect-src 'self'; frame-ancestors 'none'; base-uri 'none'"
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
);
|
|
22
|
-
var appSignInScript = () => HttpServerResponse_exports.text(
|
|
23
|
-
`
|
|
24
|
-
const callback = location.pathname === "/_executor/auth/callback";
|
|
25
|
-
const parameters = new URLSearchParams(location.hash.slice(1));
|
|
26
|
-
const body = callback
|
|
27
|
-
? {request: parameters.get("request"), code: parameters.get("code")}
|
|
28
|
-
: {returnTo: location.pathname + location.search + location.hash};
|
|
29
|
-
if (callback) history.replaceState(null, "", location.pathname);
|
|
30
|
-
fetch(callback ? "/_executor/auth/complete" : "/_executor/auth/start", {
|
|
31
|
-
method: "POST", headers: {"content-type":"application/json"}, body: JSON.stringify(body)
|
|
32
|
-
}).then(async response => {
|
|
33
|
-
if (!response.ok) throw new Error();
|
|
34
|
-
const result = await response.json();
|
|
35
|
-
location.replace(callback ? result.returnTo : result.url);
|
|
36
|
-
}).catch(() => {
|
|
37
|
-
document.querySelector("p").textContent = "Could not sign in to this app. Try opening it again.";
|
|
38
|
-
document.querySelector("a").hidden = false;
|
|
39
|
-
});`,
|
|
40
|
-
{ contentType: "text/javascript", headers: appPrivateHeaders }
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
export {
|
|
44
|
-
appPrivateHeaders,
|
|
45
|
-
appSignInPage,
|
|
46
|
-
appSignInScript
|
|
47
|
-
};
|