@shivaedev/identity 0.30.0 → 0.30.2
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 +19 -0
- package/dist/accountPreferences.d.ts +13 -13
- package/dist/client/AuthFailure.d.ts +1 -1
- package/dist/client/AuthFailure.d.ts.map +1 -1
- package/dist/client/AuthFailure.js +1 -1
- package/dist/client/AuthFailure.js.map +1 -1
- package/dist/client/adapters/authQuery.d.ts +1 -1
- package/dist/client/adapters/authQuery.d.ts.map +1 -1
- package/dist/client/adapters/authSession.d.ts +1 -1
- package/dist/client/adapters/authSession.d.ts.map +1 -1
- package/dist/client/adapters/authSession.js.map +1 -1
- package/dist/client/adapters/changeEmail.d.ts +1 -1
- package/dist/client/adapters/changeEmail.d.ts.map +1 -1
- package/dist/client/adapters/changeEmail.js +1 -1
- package/dist/client/adapters/changeEmail.js.map +1 -1
- package/dist/middleware.d.ts +1 -1
- package/dist/middleware.d.ts.map +1 -1
- package/dist/permission.d.ts +1 -1
- package/dist/permission.d.ts.map +1 -1
- package/dist/permission.js +1 -1
- package/dist/permission.js.map +1 -1
- package/dist/server/SessionPolicy.d.ts +2 -2
- package/dist/server/SessionPolicy.d.ts.map +1 -1
- package/dist/server/account-clock/dayRange.d.ts +1 -1
- package/dist/server/account-clock/dayRange.d.ts.map +1 -1
- package/dist/server/account-clock/dayRange.js +2 -2
- package/dist/server/account-clock/dayRange.js.map +1 -1
- package/dist/server/account-clock/initialize.d.ts.map +1 -1
- package/dist/server/account-clock/initialize.js +1 -1
- package/dist/server/account-clock/initialize.js.map +1 -1
- package/dist/server/account-clock/logicalDay.d.ts +1 -1
- package/dist/server/account-clock/logicalDay.d.ts.map +1 -1
- package/dist/server/account-clock/logicalDay.js +1 -1
- package/dist/server/account-clock/logicalDay.js.map +1 -1
- package/dist/server/account-clock/service.d.ts.map +1 -1
- package/dist/server/account-clock/service.js +4 -4
- package/dist/server/account-clock/service.js.map +1 -1
- package/dist/server/account-preferences/capture.js +1 -1
- package/dist/server/account-preferences/capture.js.map +1 -1
- package/dist/server/account-preferences/get.js +1 -1
- package/dist/server/account-preferences/get.js.map +1 -1
- package/dist/server/account-preferences/service.js +4 -4
- package/dist/server/account-preferences/service.js.map +1 -1
- package/dist/server/account-preferences/set.js +1 -1
- package/dist/server/account-preferences/set.js.map +1 -1
- package/dist/server/account-preferences/store.js +2 -2
- package/dist/server/account-preferences/store.js.map +1 -1
- package/dist/server/adapters/betterAuthSessions.d.ts.map +1 -1
- package/dist/server/adapters/betterAuthSessions.js +1 -1
- package/dist/server/adapters/betterAuthSessions.js.map +1 -1
- package/dist/server/adapters/trustedOrigins.d.ts.map +1 -1
- package/dist/server/adapters/trustedOrigins.js +1 -1
- package/dist/server/adapters/trustedOrigins.js.map +1 -1
- package/dist/server/better-auth/PasswordReset.d.ts +1 -1
- package/dist/server/better-auth/PasswordReset.d.ts.map +1 -1
- package/dist/server/better-auth/adapters/accountRoleSeed.d.ts +1 -1
- package/dist/server/better-auth/adapters/accountRoleSeed.d.ts.map +1 -1
- package/dist/server/better-auth/adapters/accountRoleSeed.js +1 -1
- package/dist/server/better-auth/adapters/accountRoleSeed.js.map +1 -1
- package/dist/server/better-auth/adapters/acquire.js +1 -1
- package/dist/server/better-auth/adapters/acquire.js.map +1 -1
- package/dist/server/better-auth/adapters/database.js +1 -1
- package/dist/server/better-auth/adapters/database.js.map +1 -1
- package/dist/server/better-auth/adapters/defineSeed.d.ts +2 -2
- package/dist/server/better-auth/adapters/defineSeed.d.ts.map +1 -1
- package/dist/server/better-auth/adapters/defineSeed.js +4 -4
- package/dist/server/better-auth/adapters/defineSeed.js.map +1 -1
- package/dist/server/better-auth/adapters/effectHookOptions.d.ts +1 -1
- package/dist/server/better-auth/adapters/effectHookOptions.d.ts.map +1 -1
- package/dist/server/better-auth/adapters/emailOptions.d.ts +1 -1
- package/dist/server/better-auth/adapters/emailOptions.d.ts.map +1 -1
- package/dist/server/better-auth/adapters/mount.d.ts.map +1 -1
- package/dist/server/better-auth/adapters/mount.js +3 -3
- package/dist/server/better-auth/adapters/mount.js.map +1 -1
- package/dist/server/better-auth/adapters/passwordResetOptions.d.ts +1 -1
- package/dist/server/better-auth/adapters/passwordResetOptions.d.ts.map +1 -1
- package/dist/server/better-auth/adapters/userDirectory.d.ts +1 -1
- package/dist/server/better-auth/adapters/userDirectory.d.ts.map +1 -1
- package/dist/server/better-auth/adapters/userDirectory.js.map +1 -1
- package/dist/server/better-auth/admittedSessions.d.ts +1 -1
- package/dist/server/better-auth/admittedSessions.d.ts.map +1 -1
- package/dist/server/better-auth/admittedSessions.js +1 -1
- package/dist/server/better-auth/admittedSessions.js.map +1 -1
- package/dist/server/better-auth/emails.d.ts +1 -1
- package/dist/server/better-auth/emails.d.ts.map +1 -1
- package/dist/server/better-auth/seedUsers.d.ts.map +1 -1
- package/dist/server/better-auth/seedUsers.js +1 -1
- package/dist/server/better-auth/seedUsers.js.map +1 -1
- package/dist/server/better-auth/sessionsHandlers.js +1 -1
- package/dist/server/better-auth/sessionsHandlers.js.map +1 -1
- package/dist/server/localOwner.js +1 -1
- package/dist/server/localOwner.js.map +1 -1
- package/dist/server/lookupSession.d.ts +3 -3
- package/dist/server/lookupSession.d.ts.map +1 -1
- package/dist/server/lookupSession.js +3 -3
- package/dist/server/lookupSession.js.map +1 -1
- package/dist/server/machineTokens.js +1 -1
- package/dist/server/machineTokens.js.map +1 -1
- package/dist/server/permissionLayer.d.ts +1 -1
- package/dist/server/permissionLayer.d.ts.map +1 -1
- package/dist/server/permissionLayer.js +4 -4
- package/dist/server/permissionLayer.js.map +1 -1
- package/dist/server/recheckSession.d.ts +1 -1
- package/dist/server/recheckSession.d.ts.map +1 -1
- package/dist/server/recheckSession.js +3 -3
- package/dist/server/recheckSession.js.map +1 -1
- package/dist/server/revalidateStream.d.ts +2 -2
- package/dist/server/revalidateStream.d.ts.map +1 -1
- package/dist/server/revalidateStream.js +2 -2
- package/dist/server/revalidateStream.js.map +1 -1
- package/dist/server/session.d.ts.map +1 -1
- package/dist/server/session.js +3 -3
- package/dist/server/session.js.map +1 -1
- package/dist/server/socketSession.d.ts +1 -1
- package/dist/server/socketSession.d.ts.map +1 -1
- package/package.json +20 -19
- package/src/client/AuthFailure.ts +1 -1
- package/src/client/adapters/authQuery.ts +1 -1
- package/src/client/adapters/authSession.ts +1 -1
- package/src/client/adapters/changeEmail.ts +1 -1
- package/src/middleware.ts +1 -1
- package/src/permission.ts +2 -2
- package/src/server/SessionPolicy.ts +2 -2
- package/src/server/account-clock/dayRange.ts +3 -3
- package/src/server/account-clock/initialize.ts +1 -1
- package/src/server/account-clock/logicalDay.ts +2 -2
- package/src/server/account-clock/service.ts +4 -4
- package/src/server/account-preferences/capture.ts +1 -1
- package/src/server/account-preferences/get.ts +1 -1
- package/src/server/account-preferences/service.ts +4 -4
- package/src/server/account-preferences/set.ts +1 -1
- package/src/server/account-preferences/store.ts +2 -2
- package/src/server/adapters/betterAuthSessions.ts +1 -1
- package/src/server/adapters/trustedOrigins.ts +1 -1
- package/src/server/better-auth/PasswordReset.ts +1 -1
- package/src/server/better-auth/adapters/accountRoleSeed.ts +1 -1
- package/src/server/better-auth/adapters/acquire.ts +1 -1
- package/src/server/better-auth/adapters/database.ts +1 -1
- package/src/server/better-auth/adapters/defineSeed.ts +5 -5
- package/src/server/better-auth/adapters/effectHookOptions.ts +1 -1
- package/src/server/better-auth/adapters/emailOptions.ts +1 -1
- package/src/server/better-auth/adapters/mount.ts +3 -3
- package/src/server/better-auth/adapters/passwordResetOptions.ts +1 -1
- package/src/server/better-auth/adapters/userDirectory.ts +1 -1
- package/src/server/better-auth/admittedSessions.ts +1 -1
- package/src/server/better-auth/emails.ts +1 -1
- package/src/server/better-auth/seedUsers.ts +1 -1
- package/src/server/better-auth/sessionsHandlers.ts +1 -1
- package/src/server/localOwner.ts +2 -2
- package/src/server/lookupSession.ts +4 -4
- package/src/server/machineTokens.ts +1 -1
- package/src/server/permissionLayer.ts +4 -4
- package/src/server/recheckSession.ts +3 -3
- package/src/server/revalidateStream.ts +3 -3
- package/src/server/session.ts +3 -3
- package/src/server/socketSession.ts +1 -1
package/dist/server/session.js
CHANGED
|
@@ -3,11 +3,11 @@ import { CurrentViewer } from "@shivaedev/contract/readPolicy.ts";
|
|
|
3
3
|
import { Unauthorized } from "@shivaedev/errors/taxonomy.ts";
|
|
4
4
|
import { Identity, OptionalIdentity, SessionUser, SessionUserSchema, SessionUserWithProviderAccounts, } from "#identity.ts";
|
|
5
5
|
import { Authenticated, AuthenticatedUser, AuthenticatedUserWithProviderAccounts, MaybeAuthenticated } from "#middleware.ts";
|
|
6
|
+
import { lookupSession, sessionRequest } from "#server/lookupSession.ts";
|
|
6
7
|
import { providerAccountsUser } from "#server/providerAccountsUser.ts";
|
|
8
|
+
import { recheckSession } from "#server/recheckSession.ts";
|
|
9
|
+
import { revalidateStream } from "#server/revalidateStream.ts";
|
|
7
10
|
import { SessionPolicy } from "#server/SessionPolicy.ts";
|
|
8
|
-
import { lookupSession, sessionRequest } from "./lookupSession.js";
|
|
9
|
-
import { recheckSession } from "./recheckSession.js";
|
|
10
|
-
import { revalidateStream } from "./revalidateStream.js";
|
|
11
11
|
export const resolveSession = Effect.fn("Identity.resolveSession")(function* (headers, rpc) {
|
|
12
12
|
const request = yield* sessionRequest(headers, rpc);
|
|
13
13
|
return yield* lookupSession(request.headers);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/server/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEvD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAwB,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACnF,OAAO,EACN,QAAQ,EACR,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EAEjB,+BAA+B,GAE/B,M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,GAAG,EAAE,EAAE,EAAE,cAAc,CAAC,OAAO,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC,EAC5D,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,EAAE,EAAE,EAAE,CAAC,EACvC,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EACzD,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,IAAI,CAAC,EACxC,MAAM,CAAC,cAAc,CAAC,+BAA+B,EAAE,EAAE,GAAG,IAAI,EAAE,gBAAgB,EAAE,CAAC,EACrF,MAAM,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CACnC,CAAC;IACH,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,CACvD,CACD,CAAC;AACH,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context, type Duration, Effect, Option, type Scope } from "effect";
|
|
2
2
|
import type { Permission } from "@shivaedev/access/permission.ts";
|
|
3
3
|
import type { AuthUnavailable, Forbidden } from "@shivaedev/errors/taxonomy.ts";
|
|
4
|
-
import type { SessionShape } from "
|
|
4
|
+
import type { SessionShape } from "#server/session.ts";
|
|
5
5
|
export type SessionSnapshot = SessionShape & {
|
|
6
6
|
readonly user: {
|
|
7
7
|
readonly permissions?: readonly Permission[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"socketSession.d.ts","sourceRoot":"","sources":["../../src/server/socketSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,M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AAC,KAAK,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC;sBAwBtG,CAAC;AAEH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,KAAK,8BAQjG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shivaedev/identity",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.2",
|
|
4
4
|
"description": "Request identity, sessions, transport trust and permission enforcement for Effect RPC servers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"effect"
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"@shivaedev/source": "./src/*.ts",
|
|
24
24
|
"types": "./dist/*.d.ts",
|
|
25
25
|
"default": "./dist/*.js"
|
|
26
|
-
}
|
|
26
|
+
},
|
|
27
|
+
"#manifest": "./package.json"
|
|
27
28
|
},
|
|
28
29
|
"exports": {
|
|
29
30
|
"./*.ts": {
|
|
@@ -45,34 +46,34 @@
|
|
|
45
46
|
"README.md"
|
|
46
47
|
],
|
|
47
48
|
"dependencies": {
|
|
48
|
-
"@shivaedev/access": "0.6.
|
|
49
|
-
"@shivaedev/changes": "0.11.
|
|
50
|
-
"@shivaedev/contract": "0.43.
|
|
51
|
-
"@shivaedev/errors": "0.10.
|
|
52
|
-
"@shivaedev/rate-limit": "0.6.
|
|
53
|
-
"@shivaedev/service": "0.8.
|
|
54
|
-
"@shivaedev/sql": "0.
|
|
49
|
+
"@shivaedev/access": "0.6.1",
|
|
50
|
+
"@shivaedev/changes": "0.11.1",
|
|
51
|
+
"@shivaedev/contract": "0.43.1",
|
|
52
|
+
"@shivaedev/errors": "0.10.1",
|
|
53
|
+
"@shivaedev/rate-limit": "0.6.5",
|
|
54
|
+
"@shivaedev/service": "0.8.1",
|
|
55
|
+
"@shivaedev/sql": "0.46.1"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
58
|
"@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.
|
|
62
|
-
"@shivaedev/server": "0.
|
|
63
|
-
"@shivaedev/test-kits": "0.10.
|
|
64
|
-
"@shivaedev/test-sql": "0.24.
|
|
65
|
-
"@shivaedev/test-story": "0.45.
|
|
59
|
+
"@effect/platform-node": "4.1.1",
|
|
60
|
+
"@effect/sql-pg": "4.1.1",
|
|
61
|
+
"@shivaedev/admin": "0.23.3",
|
|
62
|
+
"@shivaedev/quality": "0.70.1",
|
|
63
|
+
"@shivaedev/server": "0.32.1",
|
|
64
|
+
"@shivaedev/test-kits": "0.10.2",
|
|
65
|
+
"@shivaedev/test-sql": "0.24.5",
|
|
66
|
+
"@shivaedev/test-story": "0.45.2",
|
|
66
67
|
"@types/node": "24.19.2",
|
|
67
68
|
"better-auth": "1.7.14",
|
|
68
|
-
"effect": "4.1.
|
|
69
|
+
"effect": "4.1.1",
|
|
69
70
|
"typescript": "7.0.2",
|
|
70
71
|
"vitest": "5.0.5"
|
|
71
72
|
},
|
|
72
73
|
"peerDependencies": {
|
|
73
74
|
"@better-auth/oauth-provider": "1.7.14",
|
|
74
75
|
"better-auth": "1.7.14",
|
|
75
|
-
"effect": "4.1.
|
|
76
|
+
"effect": "4.1.1"
|
|
76
77
|
},
|
|
77
78
|
"peerDependenciesMeta": {
|
|
78
79
|
"@better-auth/oauth-provider": {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Cause, Schema } from "effect";
|
|
2
|
-
import { AuthFailureCode } from "
|
|
2
|
+
import { AuthFailureCode } from "#client/AuthFailureCode.ts";
|
|
3
3
|
|
|
4
4
|
export type AuthFailureWithCodes<TCode extends string> = Pick<AuthFailure, "_tag" | "cause"> &
|
|
5
5
|
Cause.YieldableError & { readonly code: AuthFailureCode | TCode };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import { AuthUnavailable } from "@shivaedev/errors/taxonomy.ts";
|
|
3
|
-
import type { AuthActionResult } from "
|
|
3
|
+
import type { AuthActionResult } from "#client/adapters/authCall.ts";
|
|
4
4
|
|
|
5
5
|
export function authQuery<TInput, A, E extends object = never>(
|
|
6
6
|
run: (input: TInput, signal: AbortSignal) => Promise<AuthActionResult<A, E>>,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
2
|
import { AuthUnavailable } from "@shivaedev/errors/taxonomy.ts";
|
|
3
|
+
import type { AuthActionResult } from "#client/adapters/authCall.ts";
|
|
3
4
|
import { PermissionSession } from "#PermissionSession.ts";
|
|
4
|
-
import type { AuthActionResult } from "./authCall.ts";
|
|
5
5
|
|
|
6
6
|
export type SessionWithPermissions<A> = A extends null ? null : A & PermissionSession;
|
|
7
7
|
|
package/src/middleware.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Schema } from "effect";
|
|
|
2
2
|
import { RpcMiddleware } from "effect/rpc";
|
|
3
3
|
import { MissingReadPolicy, QueryReadDenied } from "@shivaedev/contract/readPolicyErrors.ts";
|
|
4
4
|
import { AuthUnavailable, Forbidden, Unauthorized } from "@shivaedev/errors/taxonomy.ts";
|
|
5
|
-
import type { Identity, OptionalIdentity, RequestId, SessionUser, SessionUserWithProviderAccounts } from "
|
|
5
|
+
import type { Identity, OptionalIdentity, RequestId, SessionUser, SessionUserWithProviderAccounts } from "#identity.ts";
|
|
6
6
|
export const IdentityFailures = Schema.Union([Unauthorized, AuthUnavailable, Forbidden, MissingReadPolicy, QueryReadDenied]);
|
|
7
7
|
export type IdentityFailures = typeof IdentityFailures.Type;
|
|
8
8
|
|
package/src/permission.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RpcMiddleware } from "effect/rpc";
|
|
2
2
|
import { hasPermission as evaluateGrant, type Permission } from "@shivaedev/access/permission.ts";
|
|
3
|
-
import type { Identity, SessionUser, SessionUserValue } from "
|
|
4
|
-
import { IdentityFailures } from "
|
|
3
|
+
import type { Identity, SessionUser, SessionUserValue } from "#identity.ts";
|
|
4
|
+
import { IdentityFailures } from "#middleware.ts";
|
|
5
5
|
|
|
6
6
|
export function permissionMiddleware<TSelf>() {
|
|
7
7
|
return <const TName extends string>(name: TName, permission: Permission) =>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context, type Duration } from "effect";
|
|
2
2
|
import type { RoleSet } from "@shivaedev/access/roleSet.ts";
|
|
3
|
-
import type { OriginPolicy } from "
|
|
4
|
-
import type { SessionProvider, SessionShape } from "
|
|
3
|
+
import type { OriginPolicy } from "#server/origin.ts";
|
|
4
|
+
import type { SessionProvider, SessionShape } from "#server/session.ts";
|
|
5
5
|
|
|
6
6
|
export class SessionPolicy extends Context.Service<
|
|
7
7
|
SessionPolicy,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DateTime, Effect, Schema } from "effect";
|
|
2
|
-
import { boundary } from "
|
|
3
|
-
import type { initialize } from "
|
|
4
|
-
import { LogicalDay } from "
|
|
2
|
+
import { boundary } from "#server/account-clock/boundary.ts";
|
|
3
|
+
import type { initialize } from "#server/account-clock/initialize.ts";
|
|
4
|
+
import { LogicalDay } from "#server/account-clock/settings.ts";
|
|
5
5
|
|
|
6
6
|
export function dayRange({ minutes, timezone }: Effect.Success<typeof initialize>) {
|
|
7
7
|
const decodeDay = Schema.decodeUnknownEffect(LogicalDay);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
|
+
import { AccountDayStart, DayStart } from "#server/account-clock/settings.ts";
|
|
2
3
|
import { AccountPreferencesStore } from "#server/account-preferences/service.ts";
|
|
3
4
|
import { Subject } from "#subject.ts";
|
|
4
|
-
import { AccountDayStart, DayStart } from "./settings.ts";
|
|
5
5
|
|
|
6
6
|
export const initialize = Effect.gen(function* () {
|
|
7
7
|
const { id } = yield* Subject;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DateTime, Effect } from "effect";
|
|
2
|
-
import { boundary } from "
|
|
3
|
-
import type { initialize } from "
|
|
2
|
+
import { boundary } from "#server/account-clock/boundary.ts";
|
|
3
|
+
import type { initialize } from "#server/account-clock/initialize.ts";
|
|
4
4
|
|
|
5
5
|
export function logicalDay({ minutes, timezone }: Effect.Success<typeof initialize>) {
|
|
6
6
|
return Effect.fn("AccountClock.logicalDay")(function* (instant?: DateTime.Utc) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { defineService } from "@shivaedev/service/defineService.ts";
|
|
2
|
+
import { dayRange } from "#server/account-clock/dayRange.ts";
|
|
3
|
+
import { initialize } from "#server/account-clock/initialize.ts";
|
|
4
|
+
import { logicalDay } from "#server/account-clock/logicalDay.ts";
|
|
5
|
+
import { AccountDayStart } from "#server/account-clock/settings.ts";
|
|
2
6
|
import { AccountPreferencesStore } from "#server/account-preferences/service.ts";
|
|
3
7
|
import { Subject } from "#subject.ts";
|
|
4
|
-
import { dayRange } from "./dayRange.ts";
|
|
5
|
-
import { initialize } from "./initialize.ts";
|
|
6
|
-
import { logicalDay } from "./logicalDay.ts";
|
|
7
|
-
import { AccountDayStart } from "./settings.ts";
|
|
8
8
|
|
|
9
9
|
export const AccountClock = defineService({
|
|
10
10
|
id: "@shivaedev/identity/AccountClock",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import type { AccountPreferenceValues } from "#accountPreferences.ts";
|
|
3
|
+
import { AccountPreferenceRows } from "#server/account-preferences/Rows.ts";
|
|
3
4
|
import { providerFailure } from "#server/providerFailure.ts";
|
|
4
|
-
import { AccountPreferenceRows } from "./Rows.ts";
|
|
5
5
|
|
|
6
6
|
export const capture = Effect.fn("AccountPreferencesStore.capture")(function* (id: string, values: typeof AccountPreferenceValues.Type) {
|
|
7
7
|
const repository = yield* AccountPreferenceRows;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
+
import { AccountPreferenceRows } from "#server/account-preferences/Rows.ts";
|
|
2
3
|
import { providerFailure } from "#server/providerFailure.ts";
|
|
3
|
-
import { AccountPreferenceRows } from "./Rows.ts";
|
|
4
4
|
|
|
5
5
|
export const get = Effect.fn("AccountPreferencesStore.get")(function* (id: string) {
|
|
6
6
|
const repository = yield* AccountPreferenceRows;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import { defineService } from "@shivaedev/service/defineService.ts";
|
|
3
|
-
import { capture } from "
|
|
4
|
-
import { get } from "
|
|
5
|
-
import { AccountPreferenceRows } from "
|
|
6
|
-
import { set } from "
|
|
3
|
+
import { capture } from "#server/account-preferences/capture.ts";
|
|
4
|
+
import { get } from "#server/account-preferences/get.ts";
|
|
5
|
+
import { AccountPreferenceRows } from "#server/account-preferences/Rows.ts";
|
|
6
|
+
import { set } from "#server/account-preferences/set.ts";
|
|
7
7
|
|
|
8
8
|
export const AccountPreferencesStore = defineService({
|
|
9
9
|
id: "@shivaedev/identity/AccountPreferencesStore",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import type { AccountPreferenceValues } from "#accountPreferences.ts";
|
|
3
|
+
import { AccountPreferenceRows } from "#server/account-preferences/Rows.ts";
|
|
3
4
|
import { providerFailure } from "#server/providerFailure.ts";
|
|
4
|
-
import { AccountPreferenceRows } from "./Rows.ts";
|
|
5
5
|
|
|
6
6
|
export const set = Effect.fn("AccountPreferencesStore.set")(function* (id: string, values: typeof AccountPreferenceValues.Type) {
|
|
7
7
|
const repository = yield* AccountPreferenceRows;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Layer } from "effect";
|
|
2
|
-
import { AccountPreferenceRows } from "
|
|
3
|
-
import { AccountPreferencesStore } from "
|
|
2
|
+
import { AccountPreferenceRows } from "#server/account-preferences/Rows.ts";
|
|
3
|
+
import { AccountPreferencesStore } from "#server/account-preferences/service.ts";
|
|
4
4
|
|
|
5
5
|
export const accountPreferencesStore = AccountPreferencesStore.layer.pipe(Layer.provide(AccountPreferenceRows.layer));
|
|
@@ -3,9 +3,9 @@ import type { Headers } from "effect/http";
|
|
|
3
3
|
import * as HttpStatus from "effect/http/HttpStatus";
|
|
4
4
|
import { type AuthUnavailable, Unauthorized } from "@shivaedev/errors/taxonomy.ts";
|
|
5
5
|
import type { ProviderAccountValue } from "#identity.ts";
|
|
6
|
+
import { authCall } from "#server/adapters/authCall.ts";
|
|
6
7
|
import { providerFailure } from "#server/providerFailure.ts";
|
|
7
8
|
import type { SessionProvider, SessionShape } from "#server/session.ts";
|
|
8
|
-
import { authCall } from "./authCall.ts";
|
|
9
9
|
|
|
10
10
|
const ExpiringSession = Schema.Struct({ session: Schema.Struct({ expiresAt: Schema.Date }) });
|
|
11
11
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Option } from "effect";
|
|
2
|
+
import { localTransport } from "#server/adapters/local.ts";
|
|
2
3
|
import type { OriginPolicy, OriginRequest, TrustedOriginsOptions } from "#server/origin.ts";
|
|
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);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BetterAuthOptions } from "better-auth";
|
|
2
2
|
import type { Effect } from "effect";
|
|
3
|
-
import type { BetterAuthHookError } from "
|
|
3
|
+
import type { BetterAuthHookError } from "#server/better-auth/databaseHooks.ts";
|
|
4
4
|
|
|
5
5
|
type NativePasswordReset = NonNullable<NonNullable<BetterAuthOptions["emailAndPassword"]>["onPasswordReset"]>;
|
|
6
6
|
|
|
@@ -3,8 +3,8 @@ import { SqlClient, SqlSchema } from "effect/sql";
|
|
|
3
3
|
import type { AccessPolicy } from "@shivaedev/access/roleSet.ts";
|
|
4
4
|
import { AuthUnavailable } from "@shivaedev/errors/taxonomy.ts";
|
|
5
5
|
import type { ProviderAccountValue } from "#identity.ts";
|
|
6
|
+
import { type AuthTableOptions, tables } from "#server/better-auth/adapters/tables.ts";
|
|
6
7
|
import { assignRole } from "#server/better-auth/assignRole.ts";
|
|
7
|
-
import { type AuthTableOptions, tables } from "./tables.ts";
|
|
8
8
|
|
|
9
9
|
export interface AccountRoleSeed<E> {
|
|
10
10
|
readonly onSignIn: (userId: string) => Effect.Effect<void, E>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type BetterAuthOptions, betterAuth } from "better-auth";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
|
+
import { profileStorage } from "#server/better-auth/adapters/profileStorage.ts";
|
|
3
4
|
import { providerFailure } from "#server/providerFailure.ts";
|
|
4
|
-
import { profileStorage } from "./profileStorage.ts";
|
|
5
5
|
|
|
6
6
|
export const acquireAuth = Effect.fnUntraced(function* <TOptions extends BetterAuthOptions>(options: TOptions) {
|
|
7
7
|
const auth = betterAuth({
|
|
@@ -3,7 +3,7 @@ import { APIError } from "better-auth/api";
|
|
|
3
3
|
import { Cause, Effect, Exit, Option, Schema, Scope } from "effect";
|
|
4
4
|
import { SqlClient } from "effect/sql";
|
|
5
5
|
import { authCallSignal } from "#server/adapters/authCall.ts";
|
|
6
|
-
import { betterAuthTransaction } from "
|
|
6
|
+
import { betterAuthTransaction } from "#server/better-auth/adapters/transaction.ts";
|
|
7
7
|
|
|
8
8
|
type PostgresPool = Extract<NonNullable<BetterAuthOptions["database"]>, { connect: unknown }>;
|
|
9
9
|
type PoolClient = Awaited<ReturnType<PostgresPool["connect"]>>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Config, Effect } from "effect";
|
|
2
2
|
import { memoryStore } from "@shivaedev/rate-limit/memoryStore.ts";
|
|
3
3
|
import { postgresLayer } from "@shivaedev/sql/postgresLayer.ts";
|
|
4
|
+
import { assertSeedDatabase } from "#server/better-auth/adapters/assertSeedDatabase.ts";
|
|
5
|
+
import { betterAuthDatabase } from "#server/better-auth/adapters/database.ts";
|
|
6
|
+
import { betterAuthMount } from "#server/better-auth/adapters/mount.ts";
|
|
7
|
+
import type { SeedOptions } from "#server/better-auth/adapters/SeedOptions.ts";
|
|
8
|
+
import { betterAuthUserProvisioning } from "#server/better-auth/adapters/userProvisioning.ts";
|
|
4
9
|
import { seedUsers } from "#server/better-auth/seedUsers.ts";
|
|
5
|
-
import { assertSeedDatabase } from "./assertSeedDatabase.ts";
|
|
6
|
-
import { betterAuthDatabase } from "./database.ts";
|
|
7
|
-
import { betterAuthMount } from "./mount.ts";
|
|
8
|
-
import type { SeedOptions } from "./SeedOptions.ts";
|
|
9
|
-
import { betterAuthUserProvisioning } from "./userProvisioning.ts";
|
|
10
10
|
|
|
11
11
|
export function defineSeed<TRole extends string, E, R>(options: SeedOptions<TRole, E, R>) {
|
|
12
12
|
return Effect.gen(function* () {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BetterAuthOptions, GenericEndpointContext } from "better-auth";
|
|
2
2
|
import type { Effect } from "effect";
|
|
3
|
+
import type { hookRuntime } from "#server/better-auth/adapters/hookRuntime.ts";
|
|
3
4
|
import type { BetterAuthDatabaseHooks, BetterAuthHookError } from "#server/better-auth/databaseHooks.ts";
|
|
4
|
-
import type { hookRuntime } from "./hookRuntime.ts";
|
|
5
5
|
|
|
6
6
|
type SessionCreate = NonNullable<NonNullable<NonNullable<BetterAuthOptions["databaseHooks"]>["session"]>["create"]>;
|
|
7
7
|
type HookResult = Awaited<ReturnType<NonNullable<SessionCreate["before"]>>>;
|
|
@@ -3,8 +3,8 @@ import { Effect, Redacted, Schema } from "effect";
|
|
|
3
3
|
import { postgresStore } from "@shivaedev/rate-limit/adapters/postgresStore.ts";
|
|
4
4
|
import { rateLimit } from "@shivaedev/rate-limit/rateLimit.ts";
|
|
5
5
|
import { Store } from "@shivaedev/rate-limit/Store.ts";
|
|
6
|
+
import type { hookRuntime } from "#server/better-auth/adapters/hookRuntime.ts";
|
|
6
7
|
import type { AuthEmail, BetterAuthEmails } from "#server/better-auth/emails.ts";
|
|
7
|
-
import type { hookRuntime } from "./hookRuntime.ts";
|
|
8
8
|
|
|
9
9
|
type Outgoing = { [TKind in AuthEmail["_tag"]]: Omit<Extract<AuthEmail, { readonly _tag: TKind }>, "url"> }[AuthEmail["_tag"]];
|
|
10
10
|
|
|
@@ -3,7 +3,9 @@ import { Effect, Layer, type Scope } from "effect";
|
|
|
3
3
|
import type { RoleSet } from "@shivaedev/access/roleSet.ts";
|
|
4
4
|
import type { Store } from "@shivaedev/rate-limit/Store.ts";
|
|
5
5
|
import { accountPreferencesStore } from "#server/account-preferences/store.ts";
|
|
6
|
+
import { accountPreferenceOptions } from "#server/better-auth/adapters/accountPreferenceOptions.ts";
|
|
6
7
|
import type { AccountRoleSeed } from "#server/better-auth/adapters/accountRoleSeed.ts";
|
|
8
|
+
import { acquireAuth } from "#server/better-auth/adapters/acquire.ts";
|
|
7
9
|
import { type BearerSessionsOptions, withBearerSessions } from "#server/better-auth/adapters/bearerSessions.ts";
|
|
8
10
|
import { closeRoleEndpoints } from "#server/better-auth/adapters/closeRoleEndpoints.ts";
|
|
9
11
|
import { effectHookOptions } from "#server/better-auth/adapters/effectHookOptions.ts";
|
|
@@ -16,6 +18,7 @@ import { passwordResetOptions } from "#server/better-auth/adapters/passwordReset
|
|
|
16
18
|
import { providerOnlyOptions } from "#server/better-auth/adapters/providerOnlyOptions.ts";
|
|
17
19
|
import { rateLimitStorage } from "#server/better-auth/adapters/rateLimitStorage.ts";
|
|
18
20
|
import { roleSeedOptions } from "#server/better-auth/adapters/roleSeedOptions.ts";
|
|
21
|
+
import { authRouteHandler } from "#server/better-auth/adapters/routeHandler.ts";
|
|
19
22
|
import { signInPolicyOptions } from "#server/better-auth/adapters/signInPolicyOptions.ts";
|
|
20
23
|
import { type StoredRoleOptions, storedRoleOptions } from "#server/better-auth/adapters/storedRoleOptions.ts";
|
|
21
24
|
import { admittedSessions } from "#server/better-auth/admittedSessions.ts";
|
|
@@ -27,9 +30,6 @@ import { revokeUnadmitted } from "#server/better-auth/revokeUnadmitted.ts";
|
|
|
27
30
|
import { fromStorage, type PolicyStorage, type SignInPolicy, signInGate } from "#server/better-auth/signInGate.ts";
|
|
28
31
|
import { UndeclaredDefaultRole } from "#server/better-auth/UndeclaredDefaultRole.ts";
|
|
29
32
|
import { providerFailure } from "#server/providerFailure.ts";
|
|
30
|
-
import { accountPreferenceOptions } from "./accountPreferenceOptions.ts";
|
|
31
|
-
import { acquireAuth } from "./acquire.ts";
|
|
32
|
-
import { authRouteHandler } from "./routeHandler.ts";
|
|
33
33
|
|
|
34
34
|
export type BetterAuthMountOptions<E = never, R = never> = {
|
|
35
35
|
readonly accountPreferences?: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BetterAuthOptions } from "better-auth";
|
|
2
2
|
import type { Effect } from "effect";
|
|
3
|
+
import type { hookRuntime } from "#server/better-auth/adapters/hookRuntime.ts";
|
|
3
4
|
import type { BetterAuthPasswordReset } from "#server/better-auth/PasswordReset.ts";
|
|
4
|
-
import type { hookRuntime } from "./hookRuntime.ts";
|
|
5
5
|
|
|
6
6
|
export function passwordResetOptions<TOptions extends BetterAuthOptions, R>(
|
|
7
7
|
options: TOptions,
|
|
@@ -3,10 +3,10 @@ import * as Reactivity from "effect/reactivity/Reactivity";
|
|
|
3
3
|
import { SqlClient } from "effect/sql";
|
|
4
4
|
import type { AccessPolicy } from "@shivaedev/access/roleSet.ts";
|
|
5
5
|
import { AuthUnavailable } from "@shivaedev/errors/taxonomy.ts";
|
|
6
|
+
import type { AuthTableOptions } from "#server/better-auth/adapters/tables.ts";
|
|
6
7
|
import { assignRole } from "#server/better-auth/assignRole.ts";
|
|
7
8
|
import { userDirectoryReads } from "#server/better-auth/userDirectoryReads.ts";
|
|
8
9
|
import { UserDirectory } from "#server/UserDirectory.ts";
|
|
9
|
-
import type { AuthTableOptions } from "./tables.ts";
|
|
10
10
|
|
|
11
11
|
export function betterAuthUserDirectory<TRole extends string>(
|
|
12
12
|
access: Pick<AccessPolicy<TRole>, "Role" | "hasPermission">,
|
|
@@ -7,9 +7,9 @@ import {
|
|
|
7
7
|
type SessionWithProviderAccounts,
|
|
8
8
|
} from "#server/adapters/betterAuthSessions.ts";
|
|
9
9
|
import { type BearerSessionsOptions, sessionHeaders } from "#server/better-auth/adapters/bearerSessions.ts";
|
|
10
|
+
import { fromStorage, type PolicyStorage, type SignInGate } from "#server/better-auth/signInGate.ts";
|
|
10
11
|
import { providerFailure } from "#server/providerFailure.ts";
|
|
11
12
|
import type { SessionProvider, SessionShape } from "#server/session.ts";
|
|
12
|
-
import { fromStorage, type PolicyStorage, type SignInGate } from "./signInGate.ts";
|
|
13
13
|
|
|
14
14
|
interface SessionStorage extends PolicyStorage {
|
|
15
15
|
readonly authCookies: { readonly sessionToken: { readonly name: string } };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Duration, Effect, Redacted } from "effect";
|
|
2
|
-
import type { BetterAuthHookError } from "
|
|
2
|
+
import type { BetterAuthHookError } from "#server/better-auth/databaseHooks.ts";
|
|
3
3
|
|
|
4
4
|
interface Message {
|
|
5
5
|
readonly url: Redacted.Redacted<string>;
|
|
@@ -2,8 +2,8 @@ import { Effect, Option } from "effect";
|
|
|
2
2
|
import { CurrentViewer } from "@shivaedev/contract/readPolicy.ts";
|
|
3
3
|
import { Identity, SessionUser } from "#identity.ts";
|
|
4
4
|
import type { SeedOptions } from "#server/better-auth/adapters/SeedOptions.ts";
|
|
5
|
+
import { assignRole } from "#server/better-auth/assignRole.ts";
|
|
5
6
|
import { UserProvisioning } from "#server/UserProvisioning.ts";
|
|
6
|
-
import { assignRole } from "./assignRole.ts";
|
|
7
7
|
|
|
8
8
|
export const seedUsers = Effect.fn("Identity.seedUsers")(function* <TRole extends string, E, R>(options: SeedOptions<TRole, E, R>) {
|
|
9
9
|
const provisioning = yield* UserProvisioning;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { listSessions, revokeSession } from "#server/better-auth/sessionAdministration.ts";
|
|
1
2
|
import { Sessions } from "#sessions.ts";
|
|
2
|
-
import { listSessions, revokeSession } from "./sessionAdministration.ts";
|
|
3
3
|
|
|
4
4
|
export const sessionsHandlers = Sessions.application.toLayer({
|
|
5
5
|
"identity.sessions.list": listSessions,
|
package/src/server/localOwner.ts
CHANGED
|
@@ -4,8 +4,8 @@ import * as Hex from "effect/encoding/Hex";
|
|
|
4
4
|
import type { RoleSet } from "@shivaedev/access/roleSet.ts";
|
|
5
5
|
import type { SessionUserValue } from "#identity.ts";
|
|
6
6
|
import { localTransport } from "#server/adapters/local.ts";
|
|
7
|
-
import { machineTokens } from "
|
|
8
|
-
import type { SessionPolicy } from "
|
|
7
|
+
import { machineTokens } from "#server/machineTokens.ts";
|
|
8
|
+
import type { SessionPolicy } from "#server/SessionPolicy.ts";
|
|
9
9
|
|
|
10
10
|
export const localOwner = Effect.fn("Identity.localOwner")(function* (options: {
|
|
11
11
|
readonly owner: Pick<SessionUserValue, "id" | "name" | "email"> & { readonly role: string };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Effect, Option } from "effect";
|
|
2
2
|
import type { Headers } from "effect/http";
|
|
3
3
|
import { Forbidden } from "@shivaedev/errors/taxonomy.ts";
|
|
4
|
-
import { transportOriginRequest } from "
|
|
5
|
-
import { resolveRole } from "
|
|
6
|
-
import { SessionPolicy } from "
|
|
7
|
-
import type { SessionShape } from "
|
|
4
|
+
import { transportOriginRequest } from "#server/origin.ts";
|
|
5
|
+
import { resolveRole } from "#server/resolveRole.ts";
|
|
6
|
+
import { SessionPolicy } from "#server/SessionPolicy.ts";
|
|
7
|
+
import type { SessionShape } from "#server/session.ts";
|
|
8
8
|
|
|
9
9
|
export const sessionRequest = Effect.fnUntraced(function* (headers: Headers.Headers, rpc: string) {
|
|
10
10
|
const policy = yield* SessionPolicy;
|
|
@@ -5,7 +5,7 @@ import { Model } from "effect/schema";
|
|
|
5
5
|
import type { RoleSet } from "@shivaedev/access/roleSet.ts";
|
|
6
6
|
import { makeRepository } from "@shivaedev/sql/repository.ts";
|
|
7
7
|
import type { SessionUserValue } from "#identity.ts";
|
|
8
|
-
import { providerFailure } from "
|
|
8
|
+
import { providerFailure } from "#server/providerFailure.ts";
|
|
9
9
|
|
|
10
10
|
class MachineToken extends Model.Class<MachineToken>("IdentityMachineToken")({
|
|
11
11
|
id: Schema.String,
|
|
@@ -6,10 +6,10 @@ import { requirePermission } from "@shivaedev/access/requirePermission.ts";
|
|
|
6
6
|
import { Identity, SessionUser } from "#identity.ts";
|
|
7
7
|
import type { IdentityFailures } from "#middleware.ts";
|
|
8
8
|
import { hasPermission } from "#permission.ts";
|
|
9
|
-
import { recheckSession } from "
|
|
10
|
-
import { revalidateStream } from "
|
|
11
|
-
import { SessionPolicy } from "
|
|
12
|
-
import { withSessionUser } from "
|
|
9
|
+
import { recheckSession } from "#server/recheckSession.ts";
|
|
10
|
+
import { revalidateStream } from "#server/revalidateStream.ts";
|
|
11
|
+
import { SessionPolicy } from "#server/SessionPolicy.ts";
|
|
12
|
+
import { withSessionUser } from "#server/session.ts";
|
|
13
13
|
|
|
14
14
|
export function permissionLayer<TMiddleware>(
|
|
15
15
|
middleware: Context.Key<TMiddleware, RpcMiddleware.RpcMiddleware<Identity | SessionUser, IdentityFailures, never>> & {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Effect, Option } from "effect";
|
|
2
2
|
import type { Headers } from "effect/http";
|
|
3
|
-
import { sessionAccess, sessionRequest } from "
|
|
4
|
-
import { SessionPolicy } from "
|
|
5
|
-
import { SocketSession } from "
|
|
3
|
+
import { sessionAccess, sessionRequest } from "#server/lookupSession.ts";
|
|
4
|
+
import { SessionPolicy } from "#server/SessionPolicy.ts";
|
|
5
|
+
import { SocketSession } from "#server/socketSession.ts";
|
|
6
6
|
|
|
7
7
|
export const recheckSession = Effect.fnUntraced(function* (headers: Headers.Headers, rpc: string) {
|
|
8
8
|
const policy = yield* SessionPolicy;
|
|
@@ -2,9 +2,9 @@ import { Effect, type Option } from "effect";
|
|
|
2
2
|
import { type Rpc, RpcSchema } from "effect/rpc";
|
|
3
3
|
import type { AuthUnavailable, Forbidden } from "@shivaedev/errors/taxonomy.ts";
|
|
4
4
|
import { currentSessionContext } from "#server/adapters/currentSessionContext.ts";
|
|
5
|
-
import { SessionPolicy } from "
|
|
6
|
-
import type { SessionShape } from "
|
|
7
|
-
import { revalidateSession } from "
|
|
5
|
+
import { SessionPolicy } from "#server/SessionPolicy.ts";
|
|
6
|
+
import type { SessionShape } from "#server/session.ts";
|
|
7
|
+
import { revalidateSession } from "#server/socketSession.ts";
|
|
8
8
|
|
|
9
9
|
export function revalidateStream<TSession extends SessionShape, TLookupRequirements, TLookupError = AuthUnavailable | Forbidden>(
|
|
10
10
|
rpc: Rpc.AnyWithProps,
|
package/src/server/session.ts
CHANGED
|
@@ -12,11 +12,11 @@ import {
|
|
|
12
12
|
type SessionUserWithProviderAccountsValue,
|
|
13
13
|
} from "#identity.ts";
|
|
14
14
|
import { Authenticated, AuthenticatedUser, AuthenticatedUserWithProviderAccounts, MaybeAuthenticated } from "#middleware.ts";
|
|
15
|
+
import { lookupSession, sessionRequest } from "#server/lookupSession.ts";
|
|
15
16
|
import { providerAccountsUser } from "#server/providerAccountsUser.ts";
|
|
17
|
+
import { recheckSession } from "#server/recheckSession.ts";
|
|
18
|
+
import { revalidateStream } from "#server/revalidateStream.ts";
|
|
16
19
|
import { SessionPolicy } from "#server/SessionPolicy.ts";
|
|
17
|
-
import { lookupSession, sessionRequest } from "./lookupSession.ts";
|
|
18
|
-
import { recheckSession } from "./recheckSession.ts";
|
|
19
|
-
import { revalidateStream } from "./revalidateStream.ts";
|
|
20
20
|
export interface SessionShape {
|
|
21
21
|
readonly user: {
|
|
22
22
|
readonly id: string;
|