@runlot/access 0.1.0-rc.73 → 0.1.0-rc.75
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/dist/index.d.ts +8 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -12
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
export type AccessMode = "public" | "org" | "password" | "bypass";
|
|
2
2
|
export type OrgRole = "admin" | "member" | "viewer";
|
|
3
3
|
export interface Identity {
|
|
4
|
-
/** front
|
|
4
|
+
/** The mode the front decided. When it is `public`, the rest is empty. */
|
|
5
5
|
mode: AccessMode;
|
|
6
|
-
/**
|
|
6
|
+
/** The user id. In `password` mode it is `pw:…`, in `bypass` it is
|
|
7
|
+
* `bypass`. */
|
|
7
8
|
subject: string | null;
|
|
8
9
|
email: string | null;
|
|
9
10
|
orgRole: OrgRole | null;
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* The identity of the request. When the headers are absent entirely (running
|
|
14
|
+
* outside the front — local `wrangler dev` and the like) it reads as `public`:
|
|
15
|
+
* the front **always** attaches Mode, so its absence means "there was no
|
|
16
|
+
* decision", and that is the same as open.
|
|
15
17
|
*/
|
|
16
18
|
export declare function identity(request: Request): Identity;
|
|
17
|
-
/**
|
|
19
|
+
/** Is there a login — somebody who is neither `public` nor `bypass`. */
|
|
18
20
|
export declare function isSignedIn(who: Identity): boolean;
|
|
19
21
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,KAAK,GAAG,UAAU,GAAG,QAAQ,CAAC;AAClE,MAAM,MAAM,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEpD,MAAM,WAAW,QAAQ;IACvB,0EAA0E;IAC1E,IAAI,EAAE,UAAU,CAAC;IACjB;oBACgB;IAChB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CACzB;AAKD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,QAAQ,CAYnD;AAED,wEAAwE;AACxE,wBAAgB,UAAU,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAEjD"}
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
// `identity(request)` —
|
|
1
|
+
// `identity(request)` — reads the identity the front attached
|
|
2
|
+
// (docs/access.md §4.2).
|
|
2
3
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
4
|
+
// Reading it from the request rather than from `env.auth` is a constraint, not
|
|
5
|
+
// a taste: `env` is a bundle fixed for the lifetime of the worker, and the
|
|
6
|
+
// identity is a different value on every request. Reading it from the request
|
|
7
|
+
// means the problem of an implicit store (AsyncLocalStorage) being cut at a
|
|
8
|
+
// streaming or waitUntil boundary does not exist at all.
|
|
7
9
|
//
|
|
8
|
-
//
|
|
9
|
-
// (proto/front-headers.md).
|
|
10
|
-
//
|
|
10
|
+
// The headers cannot be forged, because the front attaches them after erasing
|
|
11
|
+
// every inbound `Runlot-*` (proto/front-headers.md). This function **trusts**
|
|
12
|
+
// that — there is no deployment where a worker is opened directly without
|
|
13
|
+
// passing through the front.
|
|
11
14
|
const MODES = new Set(["public", "org", "password", "bypass"]);
|
|
12
15
|
const ROLES = new Set(["admin", "member", "viewer"]);
|
|
13
16
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
+
* The identity of the request. When the headers are absent entirely (running
|
|
18
|
+
* outside the front — local `wrangler dev` and the like) it reads as `public`:
|
|
19
|
+
* the front **always** attaches Mode, so its absence means "there was no
|
|
20
|
+
* decision", and that is the same as open.
|
|
17
21
|
*/
|
|
18
22
|
export function identity(request) {
|
|
19
23
|
const h = request.headers;
|
|
@@ -29,7 +33,7 @@ export function identity(request) {
|
|
|
29
33
|
orgRole: rawRole !== null && ROLES.has(rawRole) ? rawRole : null,
|
|
30
34
|
};
|
|
31
35
|
}
|
|
32
|
-
/**
|
|
36
|
+
/** Is there a login — somebody who is neither `public` nor `bypass`. */
|
|
33
37
|
export function isSignedIn(who) {
|
|
34
38
|
return who.mode === "org";
|
|
35
39
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,yBAAyB;AACzB,EAAE;AACF,+EAA+E;AAC/E,2EAA2E;AAC3E,8EAA8E;AAC9E,4EAA4E;AAC5E,yDAAyD;AACzD,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAC9E,0EAA0E;AAC1E,6BAA6B;AAe7B,MAAM,KAAK,GAAwB,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;AACpF,MAAM,KAAK,GAAwB,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE1E;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,OAAgB;IACvC,MAAM,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAC1B,MAAM,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,oBAAoB,CAAC,IAAI,QAAQ,CAAC;IACxD,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAe,CAAC;IACrE,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAClF,MAAM,OAAO,GAAG,CAAC,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IAChD,OAAO;QACL,IAAI;QACJ,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,uBAAuB,CAAC;QACvC,KAAK,EAAE,CAAC,CAAC,GAAG,CAAC,qBAAqB,CAAC;QACnC,OAAO,EAAE,OAAO,KAAK,IAAI,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAE,OAAmB,CAAC,CAAC,CAAC,IAAI;KAC9E,CAAC;AACJ,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,UAAU,CAAC,GAAa;IACtC,OAAO,GAAG,CAAC,IAAI,KAAK,KAAK,CAAC;AAC5B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@runlot/access",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.75",
|
|
4
4
|
"description": "Reads the access identity (Runlot-Access-* headers) that Runlot attaches to a request",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"@types/node": "^22.10.2",
|
|
27
27
|
"esbuild": "^0.24.2",
|
|
28
28
|
"typescript": "^5.7.2",
|
|
29
|
-
"@runlot/config": "0.1.0-rc.
|
|
29
|
+
"@runlot/config": "0.1.0-rc.75"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"test": "node build.mjs",
|