@shivaedev/identity 0.29.2 → 0.30.1
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/CHANGELOG.md +13 -0
- package/README.md +18 -3
- package/dist/accountPreferences.d.ts +33 -48
- package/dist/accountPreferences.d.ts.map +1 -1
- package/dist/server/adapters/local.d.ts +1 -1
- package/dist/server/adapters/local.d.ts.map +1 -1
- package/dist/server/adapters/local.js +13 -12
- package/dist/server/adapters/local.js.map +1 -1
- package/dist/server/adapters/trustedOrigins.d.ts.map +1 -1
- package/dist/server/adapters/trustedOrigins.js +2 -2
- package/dist/server/adapters/trustedOrigins.js.map +1 -1
- package/dist/server/origin.d.ts +4 -1
- package/dist/server/origin.d.ts.map +1 -1
- package/dist/server/origin.js.map +1 -1
- package/dist/sessions.d.ts +10 -25
- package/dist/sessions.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/server/adapters/local.ts +13 -12
- package/src/server/adapters/trustedOrigins.ts +10 -7
- package/src/server/origin.ts +4 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.30.1 - 2026-11-07
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- Update `@shivaedev/rate-limit` from 0.6.3 to 0.6.4.
|
|
8
|
+
- Update `@shivaedev/sql` from 0.45.0 to 0.46.0.
|
|
9
|
+
|
|
10
|
+
## 0.30.0 - 2026-11-06
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Carry the exact trusted-origin allow-list with the session origin policy and admit declared sibling origins through the HTTP RPC transport guard.
|
|
15
|
+
|
|
3
16
|
## 0.29.2 - 2026-11-06
|
|
4
17
|
|
|
5
18
|
### Changed
|
package/README.md
CHANGED
|
@@ -130,10 +130,25 @@ export const sessions = Layer.succeed(SessionPolicy, {
|
|
|
130
130
|
});
|
|
131
131
|
```
|
|
132
132
|
|
|
133
|
-
`trustedOrigins({ allow, missing })` accepts an exact allowlist and supports `missing: "reject"` or `"allow"`; a custom `OriginPolicy` can decide from the RPC name or transport headers. A denied policy fails with `Forbidden` before provider lookup.
|
|
133
|
+
`trustedOrigins({ allow, missing })` accepts an exact allowlist and supports `missing: "reject"` or `"allow"`; a custom `OriginPolicy` can decide from the RPC name or transport headers. A denied policy fails with `Forbidden` before provider lookup. On `appHost`, that same `allow` list admits sibling browser origins through the HTTP RPC guard and credentialed CORS on RPC and mounted auth routes. Responses reflect the exact Origin with `Access-Control-Allow-Credentials: true`; undeclared origins get no credentialed CORS. Wildcards and patterns are not expanded. A custom policy without a `trustedOrigins` list does not enable credentialed CORS.
|
|
134
134
|
|
|
135
135
|
To also accept the transport guard's same-origin requests, pass `sameOrigin: { trustedProxy }`, with the same proxy IP addresses or CIDR ranges as the host. This admits direct loopback HTTP and the forwarded HTTP or HTTPS authority only from a matching transport peer. Session resolution supplies that peer from the HTTP request, including the WebSocket upgrade; RPC message headers cannot supply it. Missing Origins still follow `missing`. Leave `sameOrigin` absent when an explicit public-origin allowlist should be the only authority.
|
|
136
136
|
|
|
137
|
+
For a separate frontend, declare its origin in identity's `trustedOrigins` policy, then pass the session Layer to `appHost`:
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
const browserOrigins = ["https://app.example.com", "https://www.example.com"];
|
|
141
|
+
const sessions = Layer.succeed(SessionPolicy, {
|
|
142
|
+
...mounted.sessions,
|
|
143
|
+
origin: trustedOrigins({ allow: browserOrigins, missing: "allow", sameOrigin: {} }),
|
|
144
|
+
});
|
|
145
|
+
const host = appHost({ group, handlers, routes: mounted.routes, sessions });
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Identity owns the browser origin declaration; there is no separate host CORS allow-list. When mounting Better Auth, reuse `browserOrigins` for its `trustedOrigins` option so provider CSRF checks use the same origins. Browser fetch calls must set `credentials: "include"`. Origins listed in the host's `nativeOrigins` continue to use bearer sessions with cookies removed and credentials off, even if identity lists them too.
|
|
149
|
+
|
|
150
|
+
CORS does not change cookie attributes. HTTPS sibling subdomains on the same registrable domain are usually same-site and can keep the existing SameSite setting. A frontend on another registrable domain is cross-site: the app must configure Better Auth's `advanced.defaultCookieAttributes` with `{ sameSite: "none", secure: true }` and serve the API over HTTPS for its cookie to accompany cross-site requests. Browser third-party-cookie restrictions still apply.
|
|
151
|
+
|
|
137
152
|
The application's `auth` owns its storage and session configuration. A null lookup becomes a missing session. When the lookup returns Better Auth’s `session.expiresAt` as a `Date`, identity also rejects the session at or after that instant using Effect’s current clock. A thrown or rejected lookup is logged in redacted form and fails with the generic `AuthUnavailable` message. It remains a failure even on an RPC with optional authentication.
|
|
138
153
|
|
|
139
154
|
### Local owners and machine callers
|
|
@@ -422,9 +437,9 @@ A native client signs in through `/api/auth/sign-in/email` with `credentials: "o
|
|
|
422
437
|
|
|
423
438
|
Native sign-out revokes the stored session. Signing in again while sending the current bearer replaces it and revokes the old session after successful sign-in. Streams keep their original request headers, so the old session ends with `Unauthorized` on the next revalidation; it never adopts the replacement. Keep cookie caching disabled for database-backed revocation and choose `streamRevalidationInterval` for the required delivery window.
|
|
424
439
|
|
|
425
|
-
`appHost`'s `nativeOrigins` option admits those exact origins through the RPC transport guard and the auth routes. Wildcards, patterns and URLs with paths are rejected at startup. Keep the list aligned with `bearerSessions.origins`, Better Auth's `trustedOrigins` and the RPC session origin policy
|
|
440
|
+
`appHost`'s `nativeOrigins` option admits those exact origins through the RPC transport guard and the auth routes. Wildcards, patterns and URLs with paths are rejected at startup. Keep the list aligned with `bearerSessions.origins`, Better Auth's `trustedOrigins` and the RPC session origin policy. Use `nativeOrigins` for bundled clients so their transport remains credential-free; other declared origins follow the sibling browser policy above.
|
|
426
441
|
|
|
427
|
-
The host answers native preflights with POST for RPC, GET and POST for auth, and only `Authorization` and `Content-Type` headers. Native responses echo the allowed origin exactly with `Vary: Origin`; auth responses expose `set-auth-token`.
|
|
442
|
+
The host answers native preflights with POST for RPC, GET and POST for auth, and only `Authorization` and `Content-Type` headers. Native responses echo the allowed origin exactly with `Vary: Origin`; auth responses expose `set-auth-token`. Native responses never enable CORS credentials. It strips cookies from admitted native requests before auth or RPC session resolution, so only the signed bearer session can authenticate them. This prevents native access from opening a cookie CSRF path, even if a caller sends a cookie. Resource authorization remains app-owned.
|
|
428
443
|
|
|
429
444
|
Use the WebView's own fetch with `credentials: "omit"` for incremental NDJSON change streams and abort its request to release server work. A buffering native HTTP bridge cannot deliver that streaming behavior. The host still validates trusted proxy peers and forwarded authority, enforces NDJSON and body limits, uses only transport credentials, redacts diagnostics and authorizes sessions. Native HTTP callers without an Origin can exercise bearer RPC with an origin policy that explicitly permits missing Origins.
|
|
430
445
|
|
|
@@ -13,7 +13,7 @@ export declare const AccountPreferences: import("@shivaedev/contract/contract.ts
|
|
|
13
13
|
readonly units: Schema.Literals<readonly ["metric", "imperial"]>;
|
|
14
14
|
}>, {
|
|
15
15
|
readonly AuthUnavailable: typeof AuthUnavailable;
|
|
16
|
-
}, never
|
|
16
|
+
}, never>>], readonly [NoInfer<import("@shivaedev/contract/operation.ts").Command<"capture", Schema.Struct<{
|
|
17
17
|
readonly locale: Schema.NonEmptyString;
|
|
18
18
|
readonly timezone: Schema.String;
|
|
19
19
|
readonly units: Schema.Literals<readonly ["metric", "imperial"]>;
|
|
@@ -25,54 +25,15 @@ export declare const AccountPreferences: import("@shivaedev/contract/contract.ts
|
|
|
25
25
|
readonly units: Schema.Literals<readonly ["metric", "imperial"]>;
|
|
26
26
|
}>, Schema.Void, {
|
|
27
27
|
readonly AuthUnavailable: typeof AuthUnavailable;
|
|
28
|
-
}>>], import("effect/rpc/Rpc").Rpc<"identity.accountPreferences
|
|
29
|
-
readonly locale: Schema.NonEmptyString;
|
|
30
|
-
readonly timezone: Schema.String;
|
|
31
|
-
readonly units: Schema.Literals<readonly ["metric", "imperial"]>;
|
|
32
|
-
}>, Schema.Void, Schema.Union<readonly (typeof AuthUnavailable)[]>, import("effect/rpc/RpcMiddleware").ServiceClass<import("@shivaedev/contract/subjectMiddleware.ts").SubjectMiddleware<{
|
|
33
|
-
error: Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>;
|
|
34
|
-
middleware: Effect.Effect<import("#subject.ts").SubjectMiddleware<never, never>, never, import("#subject.ts").SubjectResolver>;
|
|
35
|
-
}>, `@shivaedev/contract/Subject/${string}`, import("./identity.ts").Identity | import("./identity.ts").SessionUser | import("#subject.ts").Subject, Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, never, never, false> & {
|
|
36
|
-
"@shivaedev/contract/SubjectDeclaration": {
|
|
37
|
-
error: Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>;
|
|
38
|
-
middleware: Effect.Effect<import("#subject.ts").SubjectMiddleware<never, never>, never, import("#subject.ts").SubjectResolver>;
|
|
39
|
-
};
|
|
40
|
-
}, never> | import("effect/rpc/Rpc").Rpc<"identity.accountPreferences.set", Schema.Struct<{
|
|
41
|
-
readonly locale: Schema.NonEmptyString;
|
|
42
|
-
readonly timezone: Schema.String;
|
|
43
|
-
readonly units: Schema.Literals<readonly ["metric", "imperial"]>;
|
|
44
|
-
}>, Schema.Void, Schema.Union<readonly (typeof AuthUnavailable)[]>, import("effect/rpc/RpcMiddleware").ServiceClass<import("@shivaedev/contract/subjectMiddleware.ts").SubjectMiddleware<{
|
|
45
|
-
error: Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>;
|
|
46
|
-
middleware: Effect.Effect<import("#subject.ts").SubjectMiddleware<never, never>, never, import("#subject.ts").SubjectResolver>;
|
|
47
|
-
}>, `@shivaedev/contract/Subject/${string}`, import("./identity.ts").Identity | import("./identity.ts").SessionUser | import("#subject.ts").Subject, Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, never, never, false> & {
|
|
48
|
-
"@shivaedev/contract/SubjectDeclaration": {
|
|
49
|
-
error: Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>;
|
|
50
|
-
middleware: Effect.Effect<import("#subject.ts").SubjectMiddleware<never, never>, never, import("#subject.ts").SubjectResolver>;
|
|
51
|
-
};
|
|
52
|
-
}, never> | import("effect/rpc/Rpc").Rpc<"identity.accountPreferences.$changes", Schema.Struct<{
|
|
28
|
+
}>>], import("effect/rpc/Rpc").Rpc<"identity.accountPreferences.$changes", Schema.Struct<{
|
|
53
29
|
queries: Schema.$Array<Schema.Union<readonly Schema.Struct<{
|
|
54
30
|
query: Schema.Literal<"get">;
|
|
55
31
|
payload: Schema.Void;
|
|
56
32
|
}>[]>>;
|
|
57
|
-
}>, import("effect/rpc/RpcSchema").Stream<Schema.Union<readonly [
|
|
58
|
-
readonly _tag: Schema.Literal<"
|
|
59
|
-
readonly
|
|
60
|
-
|
|
61
|
-
readonly collection: Schema.String;
|
|
62
|
-
readonly field: Schema.String;
|
|
63
|
-
readonly value: Schema.Union<readonly [Schema.String, Schema.Number]>;
|
|
64
|
-
}>, Schema.Struct<{
|
|
65
|
-
readonly _tag: Schema.Literal<"List">;
|
|
66
|
-
readonly collection: Schema.String;
|
|
67
|
-
}>, Schema.Struct<{
|
|
68
|
-
readonly _tag: Schema.Literal<"Item">;
|
|
69
|
-
readonly collection: Schema.String;
|
|
70
|
-
readonly id: Schema.Union<readonly [Schema.String, Schema.Number]>;
|
|
71
|
-
}>]>>;
|
|
72
|
-
readonly queryIndexes: Schema.optional<Schema.$Array<Schema.Number>>;
|
|
73
|
-
}>, Schema.Struct<{
|
|
74
|
-
readonly _tag: Schema.Literal<"Resync">;
|
|
75
|
-
}>]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, ...Schema.Struct<{
|
|
33
|
+
}>, import("effect/rpc/RpcSchema").Stream<Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, ...(Schema.Struct<{
|
|
34
|
+
readonly _tag: Schema.Literal<"Unchanged">;
|
|
35
|
+
readonly queryIndex: Schema.Number;
|
|
36
|
+
}> | Schema.Struct<{
|
|
76
37
|
_tag: Schema.Literal<"Result">;
|
|
77
38
|
query: Schema.Literal<"get">;
|
|
78
39
|
queryIndex: Schema.Number;
|
|
@@ -81,7 +42,7 @@ export declare const AccountPreferences: import("@shivaedev/contract/contract.ts
|
|
|
81
42
|
readonly timezone: Schema.String;
|
|
82
43
|
readonly units: Schema.Literals<readonly ["metric", "imperial"]>;
|
|
83
44
|
}>;
|
|
84
|
-
}>[]]>, Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired, ...Schema.Union<readonly (typeof AuthUnavailable)[]>[]]>>, Schema.Never, (import("effect/Context").Reference<<A, E, R>(effect: Effect.Effect<A, E, R>, request: {
|
|
45
|
+
}>)[]]>, Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired, ...Schema.Union<readonly (typeof AuthUnavailable)[]>[]]>>, Schema.Never, (import("effect/Context").Reference<<A, E, R>(effect: Effect.Effect<A, E, R>, request: {
|
|
85
46
|
readonly rpc: import("effect/rpc/Rpc").Any;
|
|
86
47
|
readonly payload: unknown;
|
|
87
48
|
}) => Effect.Effect<A, E | import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy | import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied | import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired | import("effect/Types").unhandled, R>> & {
|
|
@@ -97,7 +58,19 @@ export declare const AccountPreferences: import("@shivaedev/contract/contract.ts
|
|
|
97
58
|
error: Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>;
|
|
98
59
|
middleware: Effect.Effect<import("#subject.ts").SubjectMiddleware<never, never>, never, import("#subject.ts").SubjectResolver>;
|
|
99
60
|
};
|
|
100
|
-
}), never> | import("effect/rpc/Rpc").Rpc<"identity.accountPreferences.
|
|
61
|
+
}), never> | import("effect/rpc/Rpc").Rpc<"identity.accountPreferences.capture", Schema.Struct<{
|
|
62
|
+
readonly locale: Schema.NonEmptyString;
|
|
63
|
+
readonly timezone: Schema.String;
|
|
64
|
+
readonly units: Schema.Literals<readonly ["metric", "imperial"]>;
|
|
65
|
+
}>, Schema.Void, Schema.Union<readonly (typeof AuthUnavailable)[]>, import("effect/rpc/RpcMiddleware").ServiceClass<import("@shivaedev/contract/subjectMiddleware.ts").SubjectMiddleware<{
|
|
66
|
+
error: Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>;
|
|
67
|
+
middleware: Effect.Effect<import("#subject.ts").SubjectMiddleware<never, never>, never, import("#subject.ts").SubjectResolver>;
|
|
68
|
+
}>, `@shivaedev/contract/Subject/${string}`, import("./identity.ts").Identity | import("./identity.ts").SessionUser | import("#subject.ts").Subject, Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, never, never, false> & {
|
|
69
|
+
"@shivaedev/contract/SubjectDeclaration": {
|
|
70
|
+
error: Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>;
|
|
71
|
+
middleware: Effect.Effect<import("#subject.ts").SubjectMiddleware<never, never>, never, import("#subject.ts").SubjectResolver>;
|
|
72
|
+
};
|
|
73
|
+
}, never> | import("effect/rpc/Rpc").Rpc<"identity.accountPreferences.get", Schema.Void, Schema.Struct<{
|
|
101
74
|
readonly locale: Schema.NonEmptyString;
|
|
102
75
|
readonly timezone: Schema.String;
|
|
103
76
|
readonly units: Schema.Literals<readonly ["metric", "imperial"]>;
|
|
@@ -117,5 +90,17 @@ export declare const AccountPreferences: import("@shivaedev/contract/contract.ts
|
|
|
117
90
|
error: Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>;
|
|
118
91
|
middleware: Effect.Effect<import("#subject.ts").SubjectMiddleware<never, never>, never, import("#subject.ts").SubjectResolver>;
|
|
119
92
|
};
|
|
120
|
-
}), never
|
|
93
|
+
}), never> | import("effect/rpc/Rpc").Rpc<"identity.accountPreferences.set", Schema.Struct<{
|
|
94
|
+
readonly locale: Schema.NonEmptyString;
|
|
95
|
+
readonly timezone: Schema.String;
|
|
96
|
+
readonly units: Schema.Literals<readonly ["metric", "imperial"]>;
|
|
97
|
+
}>, Schema.Void, Schema.Union<readonly (typeof AuthUnavailable)[]>, import("effect/rpc/RpcMiddleware").ServiceClass<import("@shivaedev/contract/subjectMiddleware.ts").SubjectMiddleware<{
|
|
98
|
+
error: Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>;
|
|
99
|
+
middleware: Effect.Effect<import("#subject.ts").SubjectMiddleware<never, never>, never, import("#subject.ts").SubjectResolver>;
|
|
100
|
+
}>, `@shivaedev/contract/Subject/${string}`, import("./identity.ts").Identity | import("./identity.ts").SessionUser | import("#subject.ts").Subject, Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>, never, never, false> & {
|
|
101
|
+
"@shivaedev/contract/SubjectDeclaration": {
|
|
102
|
+
error: Schema.Union<readonly [typeof import("@shivaedev/errors/taxonomy.ts").Unauthorized, typeof AuthUnavailable, typeof import("@shivaedev/errors/taxonomy.ts").Forbidden, typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied]>;
|
|
103
|
+
middleware: Effect.Effect<import("#subject.ts").SubjectMiddleware<never, never>, never, import("#subject.ts").SubjectResolver>;
|
|
104
|
+
};
|
|
105
|
+
}, never>, readonly [], undefined>;
|
|
121
106
|
//# sourceMappingURL=accountPreferences.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountPreferences.d.ts","sourceRoot":"","sources":["../src/accountPreferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAI1D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhE,eAAO,MAAM,eAAe,eAE3B,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;EAIlC,CAAC;AAEH,eAAO,MAAM,qBAAqB,8GAA2D,CAAC;AAE9F,eAAO,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"accountPreferences.d.ts","sourceRoot":"","sources":["../src/accountPreferences.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAC;AAI1D,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhE,eAAO,MAAM,eAAe,eAE3B,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;EAIlC,CAAC;AAEH,eAAO,MAAM,qBAAqB,8GAA2D,CAAC;AAE9F,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAsB7B,CAAC"}
|
|
@@ -6,6 +6,6 @@ export declare function sameOrigin(request: Pick<TransportRequest, "headers">):
|
|
|
6
6
|
export declare const loopbackOnly: <E, R>(handler: Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>) => Effect.Effect<HttpServerResponse.HttpServerResponse, E, R | HttpServerRequest.HttpServerRequest>;
|
|
7
7
|
export declare function trustedProxyPeer(trustedProxy?: string): (address: string) => boolean;
|
|
8
8
|
export declare function localTransport(trustedProxy?: string, nativeOrigins?: readonly string[]): (request: TransportRequest) => boolean;
|
|
9
|
-
export declare
|
|
9
|
+
export declare const localRpcGuard: <E, R>(effect: Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>, trustedProxy?: string | undefined, nativeOrigins?: readonly string[] | undefined) => Effect.Effect<HttpServerResponse.HttpServerResponse, E, R | HttpServerRequest.HttpServerRequest | RpcSerialization.RpcSerialization>;
|
|
10
10
|
export {};
|
|
11
11
|
//# sourceMappingURL=local.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAoB,MAAM,aAAa,CAAC;AAEtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"local.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAoB,MAAM,aAAa,CAAC;AAEtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAI9C,KAAK,gBAAgB,GAAG,IAAI,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,SAAS,GAAG,eAAe,CAAC,CAAC;AAoB/F,wBAAgB,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,SAAS,CAAC,GAAG,OAAO,CAW9E;AACD,eAAO,MAAM,YAAY,GAAgC,CAAC,EAAE,CAAC,0KAK3D,CAAC;AACH,wBAAgB,gBAAgB,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAGpF;AAkBD,wBAAgB,cAAc,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,aAAa,GAAE,SAAS,MAAM,EAAO,aAEzE,gBAAgB,KAAG,OAAO,CAK3C;AACD,eAAO,MAAM,aAAa,GAAgC,CAAC,EAAE,CAAC,+RAe5D,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { HttpServerRequest, HttpServerResponse, HttpTraceContext } from "effect/
|
|
|
3
3
|
import * as HttpStatus from "effect/http/HttpStatus";
|
|
4
4
|
import { RpcSerialization } from "effect/rpc";
|
|
5
5
|
import { proxyAddresses, proxyMatches } from "#server/adapters/trustedProxy.ts";
|
|
6
|
+
import { SessionPolicy } from "#server/SessionPolicy.ts";
|
|
6
7
|
function loopbackAddress(address) {
|
|
7
8
|
const unmapped = unmapAddress(address);
|
|
8
9
|
return unmapped === "::1" || (/^127(?:\.\d{1,3}){3}$/u.test(unmapped) && unmapped.split(".").every((part) => Number(part) <= 255));
|
|
@@ -69,18 +70,18 @@ export function localTransport(trustedProxy, nativeOrigins = []) {
|
|
|
69
70
|
return (local && (native || sameOrigin(request))) || proxyOrigin(request, isTrustedProxy, native);
|
|
70
71
|
};
|
|
71
72
|
}
|
|
72
|
-
export
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
73
|
+
export const localRpcGuard = Effect.fnUntraced(function* (effect, trustedProxy, nativeOrigins = []) {
|
|
74
|
+
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
75
|
+
const policy = yield* Effect.serviceOption(SessionPolicy);
|
|
76
|
+
const origins = Option.getOrUndefined(policy)?.origin.trustedOrigins ?? [];
|
|
77
|
+
const allowed = localTransport(trustedProxy, [...nativeOrigins, ...origins]);
|
|
78
|
+
const serialization = yield* RpcSerialization.RpcSerialization;
|
|
79
|
+
const contentType = request.headers["content-type"]?.split(";")[0]?.trim().toLowerCase();
|
|
80
|
+
const legacyNdjson = serialization.contentType === RpcSerialization.ndjson.contentType && contentType === "application/ndjson";
|
|
81
|
+
return allowed(request) && (contentType === serialization.contentType || legacyNdjson)
|
|
82
|
+
? yield* continueHttpTrace(effect)
|
|
83
|
+
: HttpServerResponse.text("Local same-origin requests only", { status: HttpStatus.fromLiteral("Forbidden") });
|
|
84
|
+
});
|
|
84
85
|
const continueHttpTrace = Effect.fnUntraced(function* (effect) {
|
|
85
86
|
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
86
87
|
const incoming = HttpTraceContext.w3c(request.headers);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../../src/server/adapters/local.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../../src/server/adapters/local.ts"],"names":[],"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,IAAI,CAAC,WAAW,KAAK,aAAa,CAAC,WAAW,IAAI,YAAY,CAAC;QACrF,CAAC,CAAC,KAAK,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC;QAClC,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,iCAAiC,EAAE,EAAE,MAAM,EAAE,UAAU,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;AAChH,CAAC,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAW,MAA8B;IAC7F,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,iBAAiB,CAAC,iBAAiB,CAAC;IAC3D,MAAM,QAAQ,GAAG,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACvD,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC;IACtB,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtG,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trustedOrigins.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/trustedOrigins.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"trustedOrigins.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/trustedOrigins.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAiB,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAG5F,wBAAgB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,YAAY,CAW3E"}
|
|
@@ -2,9 +2,9 @@ import { Option } from "effect";
|
|
|
2
2
|
import { localTransport } from "./local.js";
|
|
3
3
|
export function trustedOrigins(options) {
|
|
4
4
|
const sameOrigin = options.sameOrigin === undefined ? undefined : localTransport(options.sameOrigin.trustedProxy);
|
|
5
|
-
return (request) => Option.match(request.origin, {
|
|
5
|
+
return Object.assign((request) => Option.match(request.origin, {
|
|
6
6
|
onNone: () => options.missing === "allow",
|
|
7
7
|
onSome: (value) => options.allow.includes(value) || sameOrigin?.({ headers: request.headers, remoteAddress: request.remoteAddress ?? Option.none() }) === true,
|
|
8
|
-
});
|
|
8
|
+
}), { trustedOrigins: options.allow });
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=trustedOrigins.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trustedOrigins.js","sourceRoot":"","sources":["../../../src/server/adapters/trustedOrigins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,UAAU,cAAc,CAAC,OAA8B;IAC5D,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAClH,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"trustedOrigins.js","sourceRoot":"","sources":["../../../src/server/adapters/trustedOrigins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,MAAM,UAAU,cAAc,CAAC,OAA8B;IAC5D,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAClH,OAAO,MAAM,CAAC,MAAM,CACnB,CAAC,OAAsB,EAAE,EAAE,CAC1B,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE;QAC5B,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,KAAK,OAAO;QACzC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CACjB,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,CAAC,aAAa,IAAI,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI;KAC5I,CAAC,EACH,EAAE,cAAc,EAAE,OAAO,CAAC,KAAK,EAAE,CACjC,CAAC;AACH,CAAC"}
|
package/dist/server/origin.d.ts
CHANGED
|
@@ -6,7 +6,10 @@ export interface OriginRequest {
|
|
|
6
6
|
readonly remoteAddress?: Option.Option<string>;
|
|
7
7
|
readonly rpc: string;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
9
|
+
export interface OriginPolicy {
|
|
10
|
+
readonly trustedOrigins?: readonly string[];
|
|
11
|
+
(request: OriginRequest): boolean;
|
|
12
|
+
}
|
|
10
13
|
export interface TrustedOriginsOptions {
|
|
11
14
|
readonly allow: readonly string[];
|
|
12
15
|
readonly missing: "allow" | "reject";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"origin.d.ts","sourceRoot":"","sources":["../../src/server/origin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,OAAO,EAAqB,MAAM,aAAa,CAAC;AAEzD,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,OAAO,EAA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MAAM,CAAiB,GAAG,aAAa,CAOxI;AAED,eAAO,MAAM,sBAAsB,uFAQjC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"origin.js","sourceRoot":"","sources":["../../src/server/origin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"origin.js","sourceRoot":"","sources":["../../src/server/origin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAgB/D,MAAM,UAAU,aAAa,CAAC,OAAwB,EAAE,GAAW,EAAE,aAAa,GAA0B,MAAM,CAAC,IAAI,EAAE;IACxH,OAAO;QACN,OAAO;QACP,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC;QACtC,aAAa;QACb,GAAG;KACH,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAC,EAAE,CAAC,iCAAiC,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAwB,EAAE,GAAW;IAClI,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACnD,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC;IACjF,OAAO,aAAa,CACnB,SAAS,EACT,GAAG,EACH,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,CACvD,CAAC;AACH,CAAC,CAAC,CAAC"}
|
package/dist/sessions.d.ts
CHANGED
|
@@ -65,7 +65,7 @@ export declare const Sessions: import("@shivaedev/contract/contract.ts").Contrac
|
|
|
65
65
|
}>, {
|
|
66
66
|
readonly AuthUnavailable: typeof AuthUnavailable;
|
|
67
67
|
readonly Forbidden: typeof Forbidden;
|
|
68
|
-
}, never
|
|
68
|
+
}, never>>], readonly [NoInfer<import("@shivaedev/contract/operation.ts").Command<"revoke", Schema.Struct<{
|
|
69
69
|
id: Schema.String;
|
|
70
70
|
}>, Schema.Void, {
|
|
71
71
|
readonly AuthUnavailable: typeof AuthUnavailable;
|
|
@@ -82,25 +82,10 @@ export declare const Sessions: import("@shivaedev/contract/contract.ts").Contrac
|
|
|
82
82
|
readonly limit: Schema.Number;
|
|
83
83
|
}>;
|
|
84
84
|
}>[]>>;
|
|
85
|
-
}>, import("effect/rpc/RpcSchema").Stream<Schema.Union<readonly [
|
|
86
|
-
readonly _tag: Schema.Literal<"
|
|
87
|
-
readonly
|
|
88
|
-
|
|
89
|
-
readonly collection: Schema.String;
|
|
90
|
-
readonly field: Schema.String;
|
|
91
|
-
readonly value: Schema.Union<readonly [Schema.String, Schema.Number]>;
|
|
92
|
-
}>, Schema.Struct<{
|
|
93
|
-
readonly _tag: Schema.Literal<"List">;
|
|
94
|
-
readonly collection: Schema.String;
|
|
95
|
-
}>, Schema.Struct<{
|
|
96
|
-
readonly _tag: Schema.Literal<"Item">;
|
|
97
|
-
readonly collection: Schema.String;
|
|
98
|
-
readonly id: Schema.Union<readonly [Schema.String, Schema.Number]>;
|
|
99
|
-
}>]>>;
|
|
100
|
-
readonly queryIndexes: Schema.optional<Schema.$Array<Schema.Number>>;
|
|
101
|
-
}>, Schema.Struct<{
|
|
102
|
-
readonly _tag: Schema.Literal<"Resync">;
|
|
103
|
-
}>]>, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, ...Schema.Struct<{
|
|
85
|
+
}>, import("effect/rpc/RpcSchema").Stream<Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, ...(Schema.Struct<{
|
|
86
|
+
readonly _tag: Schema.Literal<"Unchanged">;
|
|
87
|
+
readonly queryIndex: Schema.Number;
|
|
88
|
+
}> | Schema.Struct<{
|
|
104
89
|
_tag: Schema.Literal<"Result">;
|
|
105
90
|
query: Schema.Literal<"list">;
|
|
106
91
|
queryIndex: Schema.Number;
|
|
@@ -121,7 +106,7 @@ export declare const Sessions: import("@shivaedev/contract/contract.ts").Contrac
|
|
|
121
106
|
}>;
|
|
122
107
|
}>>;
|
|
123
108
|
}>;
|
|
124
|
-
}>[]]>, Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired, ...Schema.Union<readonly (typeof Forbidden | typeof AuthUnavailable)[]>[]]>>, Schema.Never, typeof SessionsPermission | (import("effect/Context").Reference<<A, E, R>(effect: Effect.Effect<A, E, R>, request: {
|
|
109
|
+
}>)[]]>, Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired, ...Schema.Union<readonly (typeof Forbidden | typeof AuthUnavailable)[]>[]]>>, Schema.Never, typeof SessionsPermission | (import("effect/Context").Reference<<A, E, R>(effect: Effect.Effect<A, E, R>, request: {
|
|
125
110
|
readonly rpc: import("effect/rpc/Rpc").Any;
|
|
126
111
|
readonly payload: unknown;
|
|
127
112
|
}) => Effect.Effect<A, E | import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy | import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied | import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired | import("effect/Types").unhandled, R>> & {
|
|
@@ -129,7 +114,9 @@ export declare const Sessions: import("@shivaedev/contract/contract.ts").Contrac
|
|
|
129
114
|
"~ClientError": never;
|
|
130
115
|
error: Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired]>;
|
|
131
116
|
requiredForClient: false;
|
|
132
|
-
}), never> | import("effect/rpc/Rpc").Rpc<"identity.sessions.
|
|
117
|
+
}), never> | import("effect/rpc/Rpc").Rpc<"identity.sessions.revoke", Schema.Struct<{
|
|
118
|
+
id: Schema.String;
|
|
119
|
+
}>, Schema.Void, Schema.Union<readonly (typeof NotFound | typeof Forbidden | typeof AuthUnavailable)[]>, typeof SessionsPermission, never> | import("effect/rpc/Rpc").Rpc<"identity.sessions.list", Schema.Struct<{
|
|
133
120
|
readonly cursor: Schema.optionalKey<Schema.Struct<{
|
|
134
121
|
readonly id: Schema.String;
|
|
135
122
|
readonly lastActivityAt: Schema.DateTimeUtcFromString;
|
|
@@ -159,7 +146,5 @@ export declare const Sessions: import("@shivaedev/contract/contract.ts").Contrac
|
|
|
159
146
|
"~ClientError": never;
|
|
160
147
|
error: Schema.Union<readonly [typeof import("@shivaedev/contract/readPolicyErrors.ts").MissingReadPolicy, typeof import("@shivaedev/contract/readPolicyErrors.ts").QueryReadDenied, typeof import("@shivaedev/contract/WebSocketRequired.ts").WebSocketRequired]>;
|
|
161
148
|
requiredForClient: false;
|
|
162
|
-
}), never
|
|
163
|
-
id: Schema.String;
|
|
164
|
-
}>, Schema.Void, Schema.Union<readonly (typeof NotFound | typeof Forbidden | typeof AuthUnavailable)[]>, typeof SessionsPermission, never>, readonly [], undefined>;
|
|
149
|
+
}), never>, readonly [], undefined>;
|
|
165
150
|
//# sourceMappingURL=sessions.d.ts.map
|
package/dist/sessions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../src/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIxC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAI5D,eAAO,MAAM,eAAe;;;;;;;;;;EAM1B,CAAC;AAEH,eAAO,MAAM,aAAa;;;EAAqF,CAAC;AAChH,eAAO,MAAM,gBAAgB;;;;;;EAG3B,CAAC;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;EAA2G,CAAC;AAEpI,eAAO,MAAM,QAAQ
|
|
1
|
+
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../src/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIxC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAI5D,eAAO,MAAM,eAAe;;;;;;;;;;EAM1B,CAAC;AAEH,eAAO,MAAM,aAAa;;;EAAqF,CAAC;AAChH,eAAO,MAAM,gBAAgB;;;;;;EAG3B,CAAC;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;EAA2G,CAAC;AAEpI,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mCAiBY,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shivaedev/identity",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.30.1",
|
|
4
4
|
"description": "Request identity, sessions, transport trust and permission enforcement for Effect RPC servers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"effect"
|
|
@@ -47,32 +47,32 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@shivaedev/access": "0.6.0",
|
|
49
49
|
"@shivaedev/changes": "0.11.0",
|
|
50
|
-
"@shivaedev/contract": "0.
|
|
50
|
+
"@shivaedev/contract": "0.43.0",
|
|
51
51
|
"@shivaedev/errors": "0.10.0",
|
|
52
|
-
"@shivaedev/rate-limit": "0.6.
|
|
52
|
+
"@shivaedev/rate-limit": "0.6.4",
|
|
53
53
|
"@shivaedev/service": "0.8.0",
|
|
54
|
-
"@shivaedev/sql": "0.
|
|
54
|
+
"@shivaedev/sql": "0.46.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@better-auth/oauth-provider": "1.7.14",
|
|
58
|
-
"@effect/platform-node": "4.1.
|
|
59
|
-
"@effect/sql-pg": "4.1.
|
|
60
|
-
"@shivaedev/admin": "0.23.
|
|
61
|
-
"@shivaedev/quality": "0.69.
|
|
62
|
-
"@shivaedev/server": "0.
|
|
63
|
-
"@shivaedev/test-kits": "0.
|
|
64
|
-
"@shivaedev/test-sql": "0.24.
|
|
65
|
-
"@shivaedev/test-story": "0.
|
|
58
|
+
"@effect/platform-node": "4.1.1",
|
|
59
|
+
"@effect/sql-pg": "4.1.1",
|
|
60
|
+
"@shivaedev/admin": "0.23.2",
|
|
61
|
+
"@shivaedev/quality": "0.69.4",
|
|
62
|
+
"@shivaedev/server": "0.31.1",
|
|
63
|
+
"@shivaedev/test-kits": "0.10.1",
|
|
64
|
+
"@shivaedev/test-sql": "0.24.4",
|
|
65
|
+
"@shivaedev/test-story": "0.45.1",
|
|
66
66
|
"@types/node": "24.19.2",
|
|
67
67
|
"better-auth": "1.7.14",
|
|
68
|
-
"effect": "4.1.
|
|
68
|
+
"effect": "4.1.1",
|
|
69
69
|
"typescript": "7.0.2",
|
|
70
70
|
"vitest": "5.0.5"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"@better-auth/oauth-provider": "1.7.14",
|
|
74
74
|
"better-auth": "1.7.14",
|
|
75
|
-
"effect": "4.1.
|
|
75
|
+
"effect": "4.1.1"
|
|
76
76
|
},
|
|
77
77
|
"peerDependenciesMeta": {
|
|
78
78
|
"@better-auth/oauth-provider": {
|
|
@@ -3,6 +3,7 @@ import { HttpServerRequest, HttpServerResponse, HttpTraceContext } from "effect/
|
|
|
3
3
|
import * as HttpStatus from "effect/http/HttpStatus";
|
|
4
4
|
import { RpcSerialization } from "effect/rpc";
|
|
5
5
|
import { proxyAddresses, proxyMatches } from "#server/adapters/trustedProxy.ts";
|
|
6
|
+
import { SessionPolicy } from "#server/SessionPolicy.ts";
|
|
6
7
|
|
|
7
8
|
type TransportRequest = Pick<HttpServerRequest.HttpServerRequest, "headers" | "remoteAddress">;
|
|
8
9
|
|
|
@@ -71,22 +72,22 @@ export function localTransport(trustedProxy?: string, nativeOrigins: readonly st
|
|
|
71
72
|
return (local && (native || sameOrigin(request))) || proxyOrigin(request, isTrustedProxy, native);
|
|
72
73
|
};
|
|
73
74
|
}
|
|
74
|
-
export function
|
|
75
|
+
export const localRpcGuard = Effect.fnUntraced(function* <E, R>(
|
|
75
76
|
effect: Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>,
|
|
76
77
|
trustedProxy?: string,
|
|
77
78
|
nativeOrigins: readonly string[] = [],
|
|
78
79
|
) {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
80
|
+
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
81
|
+
const policy = yield* Effect.serviceOption(SessionPolicy);
|
|
82
|
+
const origins = Option.getOrUndefined(policy)?.origin.trustedOrigins ?? [];
|
|
83
|
+
const allowed = localTransport(trustedProxy, [...nativeOrigins, ...origins]);
|
|
84
|
+
const serialization = yield* RpcSerialization.RpcSerialization;
|
|
85
|
+
const contentType = request.headers["content-type"]?.split(";")[0]?.trim().toLowerCase();
|
|
86
|
+
const legacyNdjson = serialization.contentType === RpcSerialization.ndjson.contentType && contentType === "application/ndjson";
|
|
87
|
+
return allowed(request) && (contentType === serialization.contentType || legacyNdjson)
|
|
88
|
+
? yield* continueHttpTrace(effect)
|
|
89
|
+
: HttpServerResponse.text("Local same-origin requests only", { status: HttpStatus.fromLiteral("Forbidden") });
|
|
90
|
+
});
|
|
90
91
|
|
|
91
92
|
const continueHttpTrace = Effect.fnUntraced(function* <A, E, R>(effect: Effect.Effect<A, E, R>) {
|
|
92
93
|
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { Option } from "effect";
|
|
2
|
-
import type { OriginPolicy, TrustedOriginsOptions } from "#server/origin.ts";
|
|
2
|
+
import type { OriginPolicy, OriginRequest, TrustedOriginsOptions } from "#server/origin.ts";
|
|
3
3
|
import { localTransport } from "./local.ts";
|
|
4
4
|
|
|
5
5
|
export function trustedOrigins(options: TrustedOriginsOptions): OriginPolicy {
|
|
6
6
|
const sameOrigin = options.sameOrigin === undefined ? undefined : localTransport(options.sameOrigin.trustedProxy);
|
|
7
|
-
return (
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
return Object.assign(
|
|
8
|
+
(request: OriginRequest) =>
|
|
9
|
+
Option.match(request.origin, {
|
|
10
|
+
onNone: () => options.missing === "allow",
|
|
11
|
+
onSome: (value) =>
|
|
12
|
+
options.allow.includes(value) || sameOrigin?.({ headers: request.headers, remoteAddress: request.remoteAddress ?? Option.none() }) === true,
|
|
13
|
+
}),
|
|
14
|
+
{ trustedOrigins: options.allow },
|
|
15
|
+
);
|
|
13
16
|
}
|
package/src/server/origin.ts
CHANGED
|
@@ -7,7 +7,10 @@ export interface OriginRequest {
|
|
|
7
7
|
readonly remoteAddress?: Option.Option<string>;
|
|
8
8
|
readonly rpc: string;
|
|
9
9
|
}
|
|
10
|
-
export
|
|
10
|
+
export interface OriginPolicy {
|
|
11
|
+
readonly trustedOrigins?: readonly string[];
|
|
12
|
+
(request: OriginRequest): boolean;
|
|
13
|
+
}
|
|
11
14
|
export interface TrustedOriginsOptions {
|
|
12
15
|
readonly allow: readonly string[];
|
|
13
16
|
readonly missing: "allow" | "reject";
|