@shivaedev/identity 0.27.0 → 0.28.0
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 +8 -0
- package/README.md +41 -42
- package/dist/accountPreferences.d.ts +14 -14
- package/dist/accountPreferences.d.ts.map +1 -1
- package/dist/server/account-clock/boundary.d.ts +3 -0
- package/dist/server/account-clock/boundary.d.ts.map +1 -0
- package/dist/server/account-clock/boundary.js +7 -0
- package/dist/server/account-clock/boundary.js.map +1 -0
- 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 +4 -3
- package/dist/server/account-clock/dayRange.js.map +1 -1
- package/dist/server/account-clock/initialize.d.ts +2 -2
- package/dist/server/account-clock/initialize.d.ts.map +1 -1
- package/dist/server/account-clock/initialize.js +3 -10
- 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 +6 -3
- package/dist/server/account-clock/logicalDay.js.map +1 -1
- package/dist/server/{AccountClock.d.ts → account-clock/service.d.ts} +1 -1
- package/dist/server/account-clock/service.d.ts.map +1 -0
- package/dist/server/account-clock/service.js +14 -0
- package/dist/server/account-clock/service.js.map +1 -0
- package/dist/server/account-preferences/{initialize.d.ts → Rows.d.ts} +7 -6
- package/dist/server/account-preferences/Rows.d.ts.map +1 -0
- package/dist/server/account-preferences/{initialize.js → Rows.js} +7 -2
- package/dist/server/account-preferences/Rows.js.map +1 -0
- package/dist/server/account-preferences/capture.d.ts +2 -3
- package/dist/server/account-preferences/capture.d.ts.map +1 -1
- package/dist/server/account-preferences/capture.js +5 -5
- package/dist/server/account-preferences/capture.js.map +1 -1
- package/dist/server/account-preferences/get.d.ts +2 -3
- package/dist/server/account-preferences/get.d.ts.map +1 -1
- package/dist/server/account-preferences/get.js +5 -5
- package/dist/server/account-preferences/get.js.map +1 -1
- package/dist/server/{AccountPreferencesStore.d.ts → account-preferences/service.d.ts} +6 -6
- package/dist/server/account-preferences/service.d.ts.map +1 -0
- package/dist/server/account-preferences/service.js +13 -0
- package/dist/server/account-preferences/service.js.map +1 -0
- package/dist/server/account-preferences/set.d.ts +2 -3
- package/dist/server/account-preferences/set.d.ts.map +1 -1
- package/dist/server/account-preferences/set.js +7 -7
- package/dist/server/account-preferences/set.js.map +1 -1
- package/dist/server/account-preferences/store.d.ts +3 -0
- package/dist/server/account-preferences/store.d.ts.map +1 -0
- package/dist/server/account-preferences/store.js +5 -0
- package/dist/server/account-preferences/store.js.map +1 -0
- package/dist/server/accountPreferencesHandlers.js +1 -1
- package/dist/server/accountPreferencesHandlers.js.map +1 -1
- package/dist/server/{currentSessionContext.d.ts → adapters/currentSessionContext.d.ts} +1 -1
- package/dist/server/adapters/currentSessionContext.d.ts.map +1 -0
- package/dist/server/{currentSessionContext.js → adapters/currentSessionContext.js} +1 -1
- package/dist/server/adapters/currentSessionContext.js.map +1 -0
- package/dist/server/adapters/permissionRoute.d.ts +7 -0
- package/dist/server/adapters/permissionRoute.d.ts.map +1 -0
- package/dist/server/adapters/permissionRoute.js +26 -0
- package/dist/server/adapters/permissionRoute.js.map +1 -0
- package/dist/server/adapters/socketMonitor.d.ts +3 -0
- package/dist/server/adapters/socketMonitor.d.ts.map +1 -0
- package/dist/server/adapters/socketMonitor.js +11 -0
- package/dist/server/adapters/socketMonitor.js.map +1 -0
- package/dist/server/better-auth/adapters/accountPreferenceOptions.js +1 -1
- package/dist/server/better-auth/adapters/accountPreferenceOptions.js.map +1 -1
- package/dist/server/better-auth/{accountRoleSeed.d.ts → adapters/accountRoleSeed.d.ts} +3 -3
- package/dist/server/better-auth/adapters/accountRoleSeed.d.ts.map +1 -0
- package/dist/server/better-auth/{accountRoleSeed.js → adapters/accountRoleSeed.js} +2 -2
- package/dist/server/better-auth/adapters/accountRoleSeed.js.map +1 -0
- package/dist/server/better-auth/adapters/mount.d.ts +1 -1
- package/dist/server/better-auth/adapters/mount.d.ts.map +1 -1
- package/dist/server/better-auth/adapters/mount.js +2 -2
- package/dist/server/better-auth/adapters/mount.js.map +1 -1
- package/dist/server/better-auth/adapters/roleSeedOptions.d.ts +1 -1
- package/dist/server/better-auth/adapters/roleSeedOptions.d.ts.map +1 -1
- package/dist/server/{permissions.d.ts → permissionLayer.d.ts} +2 -4
- package/dist/server/permissionLayer.d.ts.map +1 -0
- package/dist/server/{permissions.js → permissionLayer.js} +1 -19
- package/dist/server/permissionLayer.js.map +1 -0
- package/dist/server/revalidateStream.js +1 -1
- package/dist/server/revalidateStream.js.map +1 -1
- package/dist/server/socketSession.d.ts.map +1 -1
- package/dist/server/socketSession.js +3 -8
- package/dist/server/socketSession.js.map +1 -1
- package/package.json +10 -10
- package/src/server/account-clock/boundary.ts +13 -0
- package/src/server/account-clock/dayRange.ts +4 -3
- package/src/server/account-clock/initialize.ts +3 -12
- package/src/server/account-clock/logicalDay.ts +6 -3
- package/src/server/{AccountClock.ts → account-clock/service.ts} +5 -5
- package/src/server/account-preferences/{initialize.ts → Rows.ts} +7 -3
- package/src/server/account-preferences/capture.ts +5 -6
- package/src/server/account-preferences/get.ts +9 -10
- package/src/server/account-preferences/service.ts +13 -0
- package/src/server/account-preferences/set.ts +7 -8
- package/src/server/account-preferences/store.ts +5 -0
- package/src/server/accountPreferencesHandlers.ts +1 -1
- package/src/server/{currentSessionContext.ts → adapters/currentSessionContext.ts} +2 -2
- package/src/server/adapters/permissionRoute.ts +43 -0
- package/src/server/adapters/socketMonitor.ts +19 -0
- package/src/server/better-auth/adapters/accountPreferenceOptions.ts +1 -1
- package/src/server/better-auth/{accountRoleSeed.ts → adapters/accountRoleSeed.ts} +2 -2
- package/src/server/better-auth/adapters/mount.ts +3 -3
- package/src/server/better-auth/adapters/roleSeedOptions.ts +1 -1
- package/src/server/{permissions.ts → permissionLayer.ts} +0 -30
- package/src/server/revalidateStream.ts +1 -1
- package/src/server/socketSession.ts +3 -16
- package/dist/server/AccountClock.d.ts.map +0 -1
- package/dist/server/AccountClock.js +0 -14
- package/dist/server/AccountClock.js.map +0 -1
- package/dist/server/AccountPreferencesStore.d.ts.map +0 -1
- package/dist/server/AccountPreferencesStore.js +0 -13
- package/dist/server/AccountPreferencesStore.js.map +0 -1
- package/dist/server/account-preferences/initialize.d.ts.map +0 -1
- package/dist/server/account-preferences/initialize.js.map +0 -1
- package/dist/server/better-auth/accountRoleSeed.d.ts.map +0 -1
- package/dist/server/better-auth/accountRoleSeed.js.map +0 -1
- package/dist/server/currentSessionContext.d.ts.map +0 -1
- package/dist/server/currentSessionContext.js.map +0 -1
- package/dist/server/permissions.d.ts.map +0 -1
- package/dist/server/permissions.js.map +0 -1
- package/src/server/AccountPreferencesStore.ts +0 -13
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DateTime, Effect } from "effect";
|
|
2
|
+
|
|
3
|
+
export const boundary = Effect.fn("AccountClock.boundary")((day: string, timezone: string, minutes: number) =>
|
|
4
|
+
Effect.sync(() =>
|
|
5
|
+
DateTime.toUtc(
|
|
6
|
+
DateTime.makeZonedUnsafe(`${day}T00:00:00.000Z`, {
|
|
7
|
+
adjustForTimeZone: true,
|
|
8
|
+
disambiguation: "compatible",
|
|
9
|
+
timeZone: timezone,
|
|
10
|
+
}).pipe(DateTime.setParts({ hour: Math.floor(minutes / 60), minute: minutes % 60 })),
|
|
11
|
+
),
|
|
12
|
+
),
|
|
13
|
+
);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { DateTime, Effect, Schema } from "effect";
|
|
2
|
+
import { boundary } from "./boundary.ts";
|
|
2
3
|
import type { initialize } from "./initialize.ts";
|
|
3
4
|
import { LogicalDay } from "./settings.ts";
|
|
4
5
|
|
|
5
|
-
export function dayRange({
|
|
6
|
+
export function dayRange({ minutes, timezone }: Effect.Success<typeof initialize>) {
|
|
6
7
|
const decodeDay = Schema.decodeUnknownEffect(LogicalDay);
|
|
7
|
-
return Effect.
|
|
8
|
+
return Effect.fn("AccountClock.dayRange")(function* (day: string) {
|
|
8
9
|
yield* decodeDay(day);
|
|
9
10
|
const next = DateTime.makeUnsafe(day).pipe(DateTime.add({ days: 1 }), DateTime.formatIsoDateUtc);
|
|
10
|
-
return { end: boundary(next), start: boundary(day) };
|
|
11
|
+
return { end: yield* boundary(next, timezone, minutes), start: yield* boundary(day, timezone, minutes) };
|
|
11
12
|
});
|
|
12
13
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AccountPreferencesStore } from "#server/
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import { AccountPreferencesStore } from "#server/account-preferences/service.ts";
|
|
3
3
|
import { Subject } from "#subject.ts";
|
|
4
4
|
import { AccountDayStart, DayStart } from "./settings.ts";
|
|
5
5
|
|
|
@@ -7,14 +7,5 @@ export const initialize = Effect.gen(function* () {
|
|
|
7
7
|
const { id } = yield* Subject;
|
|
8
8
|
const { timezone } = yield* (yield* AccountPreferencesStore).get(id);
|
|
9
9
|
const minutes = yield* Schema.decodeUnknownEffect(DayStart)(yield* AccountDayStart);
|
|
10
|
-
|
|
11
|
-
return DateTime.toUtc(
|
|
12
|
-
DateTime.makeZonedUnsafe(`${day}T00:00:00.000Z`, {
|
|
13
|
-
adjustForTimeZone: true,
|
|
14
|
-
disambiguation: "compatible",
|
|
15
|
-
timeZone: timezone,
|
|
16
|
-
}).pipe(DateTime.setParts({ hour: Math.floor(minutes / 60), minute: minutes % 60 })),
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
return { boundary, timezone };
|
|
10
|
+
return { minutes, timezone };
|
|
20
11
|
});
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { DateTime, Effect } from "effect";
|
|
2
|
+
import { boundary } from "./boundary.ts";
|
|
2
3
|
import type { initialize } from "./initialize.ts";
|
|
3
4
|
|
|
4
|
-
export function logicalDay({
|
|
5
|
-
return Effect.
|
|
5
|
+
export function logicalDay({ minutes, timezone }: Effect.Success<typeof initialize>) {
|
|
6
|
+
return Effect.fn("AccountClock.logicalDay")(function* (instant?: DateTime.Utc) {
|
|
6
7
|
const now = instant ?? (yield* DateTime.now);
|
|
7
8
|
const local = DateTime.setZoneNamedUnsafe(now, timezone);
|
|
8
9
|
const day = DateTime.formatIsoDate(local);
|
|
9
|
-
return DateTime.isLessThan(now, boundary(day
|
|
10
|
+
return DateTime.isLessThan(now, yield* boundary(day, timezone, minutes))
|
|
11
|
+
? DateTime.makeUnsafe(day).pipe(DateTime.subtract({ days: 1 }), DateTime.formatIsoDateUtc)
|
|
12
|
+
: day;
|
|
10
13
|
});
|
|
11
14
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { defineService } from "@shivaedev/service/defineService.ts";
|
|
2
|
-
import { AccountPreferencesStore } from "#server/
|
|
3
|
-
import { dayRange } from "#server/account-clock/dayRange.ts";
|
|
4
|
-
import { initialize } from "#server/account-clock/initialize.ts";
|
|
5
|
-
import { logicalDay } from "#server/account-clock/logicalDay.ts";
|
|
6
|
-
import { AccountDayStart } from "#server/account-clock/settings.ts";
|
|
2
|
+
import { AccountPreferencesStore } from "#server/account-preferences/service.ts";
|
|
7
3
|
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,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Schema } from "effect";
|
|
2
2
|
import { Model } from "effect/schema";
|
|
3
|
+
import { defineRepository } from "@shivaedev/sql/defineRepository.ts";
|
|
3
4
|
import { makeRepository } from "@shivaedev/sql/repository.ts";
|
|
4
5
|
import { AccountPreferenceValues } from "#accountPreferences.ts";
|
|
5
6
|
|
|
@@ -8,11 +9,14 @@ class StoredPreferences extends Model.Class<StoredPreferences>("AccountPreferenc
|
|
|
8
9
|
...AccountPreferenceValues.fields,
|
|
9
10
|
}) {}
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
const initialize = makeRepository(StoredPreferences, {
|
|
12
13
|
conflictColumns: ["id"],
|
|
13
14
|
idColumn: "id",
|
|
14
15
|
spanPrefix: "AccountPreferences",
|
|
15
16
|
tableName: "identity_account_preferences",
|
|
16
17
|
});
|
|
17
18
|
|
|
18
|
-
export
|
|
19
|
+
export const AccountPreferenceRows = defineRepository({
|
|
20
|
+
id: "@shivaedev/identity/AccountPreferenceRows",
|
|
21
|
+
initialize,
|
|
22
|
+
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import type { AccountPreferenceValues } from "#accountPreferences.ts";
|
|
3
3
|
import { providerFailure } from "#server/providerFailure.ts";
|
|
4
|
-
import
|
|
4
|
+
import { AccountPreferenceRows } from "./Rows.ts";
|
|
5
5
|
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
6
|
+
export const capture = Effect.fn("AccountPreferencesStore.capture")(function* (id: string, values: typeof AccountPreferenceValues.Type) {
|
|
7
|
+
const repository = yield* AccountPreferenceRows;
|
|
8
|
+
return yield* repository.insertOrIgnore({ id, ...values }).pipe(Effect.asVoid, Effect.catch(providerFailure));
|
|
9
|
+
});
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import { providerFailure } from "#server/providerFailure.ts";
|
|
3
|
-
import
|
|
3
|
+
import { AccountPreferenceRows } from "./Rows.ts";
|
|
4
4
|
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
5
|
+
export const get = Effect.fn("AccountPreferencesStore.get")(function* (id: string) {
|
|
6
|
+
const repository = yield* AccountPreferenceRows;
|
|
7
|
+
return yield* repository.findById(id).pipe(
|
|
8
|
+
Effect.map(({ locale, timezone, units }) => ({ locale, timezone, units })),
|
|
9
|
+
Effect.catchTag("NoSuchElementError", () => Effect.succeed({ locale: "en", timezone: "UTC", units: "metric" as const })),
|
|
10
|
+
Effect.catch(providerFailure),
|
|
11
|
+
);
|
|
12
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { defineService } from "@shivaedev/service/defineService.ts";
|
|
3
|
+
import { capture } from "./capture.ts";
|
|
4
|
+
import { get } from "./get.ts";
|
|
5
|
+
import { AccountPreferenceRows } from "./Rows.ts";
|
|
6
|
+
import { set } from "./set.ts";
|
|
7
|
+
|
|
8
|
+
export const AccountPreferencesStore = defineService({
|
|
9
|
+
id: "@shivaedev/identity/AccountPreferencesStore",
|
|
10
|
+
initialize: Effect.void,
|
|
11
|
+
methods: () => ({ capture, get, set }),
|
|
12
|
+
requires: [AccountPreferenceRows],
|
|
13
|
+
});
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import type { AccountPreferenceValues } from "#accountPreferences.ts";
|
|
3
3
|
import { providerFailure } from "#server/providerFailure.ts";
|
|
4
|
-
import
|
|
4
|
+
import { AccountPreferenceRows } from "./Rows.ts";
|
|
5
5
|
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
6
|
+
export const set = Effect.fn("AccountPreferencesStore.set")(function* (id: string, values: typeof AccountPreferenceValues.Type) {
|
|
7
|
+
const repository = yield* AccountPreferenceRows;
|
|
8
|
+
return yield* repository
|
|
9
|
+
.upsert({ id, ...values }, { updateColumns: ["locale", "timezone", "units"] })
|
|
10
|
+
.pipe(Effect.asVoid, Effect.catch(providerFailure));
|
|
11
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import { AccountPreferences } from "#accountPreferences.ts";
|
|
3
|
-
import { AccountPreferencesStore } from "#server/
|
|
3
|
+
import { AccountPreferencesStore } from "#server/account-preferences/service.ts";
|
|
4
4
|
import { Subject } from "#subject.ts";
|
|
5
5
|
|
|
6
6
|
export const accountPreferencesHandlers = AccountPreferences.application.toLayer({
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Context, Effect, Option, Schema } from "effect";
|
|
2
2
|
import { type AuthUnavailable, type Forbidden, Unauthorized } from "@shivaedev/errors/taxonomy.ts";
|
|
3
3
|
import { SessionUser, SessionUserSchema, SessionUserWithProviderAccounts } from "#identity.ts";
|
|
4
|
-
import { providerAccountsUser } from "
|
|
5
|
-
import type { SessionShape } from "
|
|
4
|
+
import { providerAccountsUser } from "#server/providerAccountsUser.ts";
|
|
5
|
+
import type { SessionShape } from "#server/session.ts";
|
|
6
6
|
|
|
7
7
|
export const currentSessionContext = Effect.fnUntraced(function* <TSession extends SessionShape, R, E = AuthUnavailable | Forbidden>(
|
|
8
8
|
id: string,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { HttpServerRequest, HttpServerResponse } from "effect/http";
|
|
3
|
+
import * as HttpStatus from "effect/http/HttpStatus";
|
|
4
|
+
import type { Permission } from "@shivaedev/access/permission.ts";
|
|
5
|
+
import { requirePermission } from "@shivaedev/access/requirePermission.ts";
|
|
6
|
+
import type { AuthUnavailable, Forbidden, Unauthorized } from "@shivaedev/errors/taxonomy.ts";
|
|
7
|
+
import { type Identity, SessionUser } from "#identity.ts";
|
|
8
|
+
import type { SessionPolicy } from "#server/SessionPolicy.ts";
|
|
9
|
+
import { withSessionUser } from "#server/session.ts";
|
|
10
|
+
|
|
11
|
+
function rejection(error: Unauthorized | Forbidden | AuthUnavailable) {
|
|
12
|
+
return HttpServerResponse.empty({
|
|
13
|
+
headers: { "cache-control": "private, no-store" },
|
|
14
|
+
status: {
|
|
15
|
+
AuthUnavailable: HttpStatus.fromLiteral("ServiceUnavailable"),
|
|
16
|
+
Forbidden: HttpStatus.fromLiteral("Forbidden"),
|
|
17
|
+
Unauthorized: HttpStatus.fromLiteral("Unauthorized"),
|
|
18
|
+
}[error._tag],
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function permissionRoute(permission: Permission) {
|
|
23
|
+
return <E, R>(
|
|
24
|
+
handler: Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>,
|
|
25
|
+
): Effect.Effect<
|
|
26
|
+
HttpServerResponse.HttpServerResponse,
|
|
27
|
+
E,
|
|
28
|
+
HttpServerRequest.HttpServerRequest | SessionPolicy | Exclude<R, Identity | SessionUser>
|
|
29
|
+
> =>
|
|
30
|
+
Effect.gen(function* () {
|
|
31
|
+
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
32
|
+
return yield* Effect.andThen(
|
|
33
|
+
Effect.flatMap(SessionUser, (user) => requirePermission(user, permission)),
|
|
34
|
+
Effect.context<Identity | SessionUser>(),
|
|
35
|
+
).pipe(
|
|
36
|
+
withSessionUser(request.headers, request.url),
|
|
37
|
+
Effect.matchEffect({
|
|
38
|
+
onFailure: (error) => Effect.succeed(rejection(error)),
|
|
39
|
+
onSuccess: (context) => Effect.provideContext(handler, context),
|
|
40
|
+
}),
|
|
41
|
+
);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Deferred, Effect } from "effect";
|
|
2
|
+
|
|
3
|
+
export function socketMonitor(checks: Set<Effect.Effect<void>>) {
|
|
4
|
+
return <E, R>(check: Effect.Effect<void, E, R>) =>
|
|
5
|
+
Effect.gen(function* () {
|
|
6
|
+
const context = yield* Effect.context<R>();
|
|
7
|
+
const ended = yield* Deferred.make<never, E>();
|
|
8
|
+
const run = check.pipe(
|
|
9
|
+
Effect.provideContext(context),
|
|
10
|
+
Effect.catchCause((cause) => Deferred.failCause(ended, cause)),
|
|
11
|
+
Effect.asVoid,
|
|
12
|
+
);
|
|
13
|
+
yield* Effect.acquireRelease(
|
|
14
|
+
Effect.sync(() => checks.add(run)),
|
|
15
|
+
() => Effect.sync(() => checks.delete(run)),
|
|
16
|
+
);
|
|
17
|
+
return yield* Deferred.await(ended);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -2,7 +2,7 @@ import type { BetterAuthOptions, BetterAuthPlugin } from "better-auth";
|
|
|
2
2
|
import { createAuthMiddleware } from "better-auth/api";
|
|
3
3
|
import { Effect, Option, Schema } from "effect";
|
|
4
4
|
import { AccountPreferenceValues } from "#accountPreferences.ts";
|
|
5
|
-
import { AccountPreferencesStore } from "#server/
|
|
5
|
+
import { AccountPreferencesStore } from "#server/account-preferences/service.ts";
|
|
6
6
|
|
|
7
7
|
export const accountPreferenceOptions = Effect.fnUntraced(function* <TOptions extends BetterAuthOptions>(options: TOptions) {
|
|
8
8
|
const store = yield* AccountPreferencesStore;
|
|
@@ -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 {
|
|
7
|
-
import {
|
|
6
|
+
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>;
|
|
@@ -2,8 +2,8 @@ import type { BetterAuthOptions } from "better-auth";
|
|
|
2
2
|
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
|
-
import {
|
|
6
|
-
import type { AccountRoleSeed } from "#server/better-auth/accountRoleSeed.ts";
|
|
5
|
+
import { accountPreferencesStore } from "#server/account-preferences/store.ts";
|
|
6
|
+
import type { AccountRoleSeed } from "#server/better-auth/adapters/accountRoleSeed.ts";
|
|
7
7
|
import { type BearerSessionsOptions, withBearerSessions } from "#server/better-auth/adapters/bearerSessions.ts";
|
|
8
8
|
import { closeRoleEndpoints } from "#server/better-auth/adapters/closeRoleEndpoints.ts";
|
|
9
9
|
import { effectHookOptions } from "#server/better-auth/adapters/effectHookOptions.ts";
|
|
@@ -62,7 +62,7 @@ const mountAuth = Effect.fn("Identity.mountAuth")(function* <const TOptions exte
|
|
|
62
62
|
const gate = yield* signInGate(policy);
|
|
63
63
|
const runtime = yield* hookRuntime<R>();
|
|
64
64
|
const preferences =
|
|
65
|
-
mount.accountPreferences === true ? yield* accountPreferenceOptions(options).pipe(Effect.provide(
|
|
65
|
+
mount.accountPreferences === true ? yield* accountPreferenceOptions(options).pipe(Effect.provide(accountPreferencesStore)) : options;
|
|
66
66
|
const reset = passwordResetOptions(preferences, mount.onPasswordReset, runtime);
|
|
67
67
|
const hooked = effectHookOptions(yield* emailOptions(reset, mount.emails, runtime), mount.databaseHooks, runtime);
|
|
68
68
|
const configured = mount.roles === undefined ? hooked : storedRoleOptions(closeRoleEndpoints(hooked), mount);
|
|
@@ -3,7 +3,7 @@ import { APIError } from "better-auth/api";
|
|
|
3
3
|
import { Effect, Exit } from "effect";
|
|
4
4
|
import { redact } from "@shivaedev/errors/redact.ts";
|
|
5
5
|
import { authRefusals } from "#authRefusal.ts";
|
|
6
|
-
import type { AccountRoleSeed } from "#server/better-auth/accountRoleSeed.ts";
|
|
6
|
+
import type { AccountRoleSeed } from "#server/better-auth/adapters/accountRoleSeed.ts";
|
|
7
7
|
|
|
8
8
|
export function roleSeedOptions<E>(options: BetterAuthOptions, seed: AccountRoleSeed<E> | undefined): BetterAuthOptions {
|
|
9
9
|
if (seed === undefined) {
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { type Context, Effect, Layer, Option } from "effect";
|
|
2
|
-
import { type HttpServerRequest, HttpServerResponse } from "effect/http";
|
|
3
|
-
import * as HttpStatus from "effect/http/HttpStatus";
|
|
4
2
|
import type { RpcMiddleware } from "effect/rpc";
|
|
5
3
|
import type { Permission } from "@shivaedev/access/permission.ts";
|
|
6
4
|
import { forbidden } from "@shivaedev/access/refusal.ts";
|
|
7
5
|
import { requirePermission } from "@shivaedev/access/requirePermission.ts";
|
|
8
|
-
import type { AuthUnavailable, Forbidden, Unauthorized } from "@shivaedev/errors/taxonomy.ts";
|
|
9
6
|
import { Identity, SessionUser } from "#identity.ts";
|
|
10
7
|
import type { IdentityFailures } from "#middleware.ts";
|
|
11
8
|
import { hasPermission } from "#permission.ts";
|
|
@@ -42,30 +39,3 @@ export function permissionLayer<TMiddleware>(
|
|
|
42
39
|
}),
|
|
43
40
|
);
|
|
44
41
|
}
|
|
45
|
-
function rejection(error: Unauthorized | Forbidden | AuthUnavailable) {
|
|
46
|
-
return HttpServerResponse.empty({
|
|
47
|
-
headers: { "cache-control": "private, no-store" },
|
|
48
|
-
status: {
|
|
49
|
-
AuthUnavailable: HttpStatus.fromLiteral("ServiceUnavailable"),
|
|
50
|
-
Forbidden: HttpStatus.fromLiteral("Forbidden"),
|
|
51
|
-
Unauthorized: HttpStatus.fromLiteral("Unauthorized"),
|
|
52
|
-
}[error._tag],
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function permissionRoute(permission: Permission) {
|
|
57
|
-
return <E, R>(handler: (request: HttpServerRequest.HttpServerRequest) => Effect.Effect<HttpServerResponse.HttpServerResponse, E, R>) =>
|
|
58
|
-
(
|
|
59
|
-
request: HttpServerRequest.HttpServerRequest,
|
|
60
|
-
): Effect.Effect<HttpServerResponse.HttpServerResponse, E, SessionPolicy | Exclude<R, Identity | SessionUser>> =>
|
|
61
|
-
Effect.andThen(
|
|
62
|
-
Effect.flatMap(SessionUser, (user) => requirePermission(user, permission)),
|
|
63
|
-
Effect.context<Identity | SessionUser>(),
|
|
64
|
-
).pipe(
|
|
65
|
-
withSessionUser(request.headers, request.url),
|
|
66
|
-
Effect.matchEffect({
|
|
67
|
-
onFailure: (error) => Effect.succeed(rejection(error)),
|
|
68
|
-
onSuccess: (context) => Effect.provideContext(handler(request), context),
|
|
69
|
-
}),
|
|
70
|
-
);
|
|
71
|
-
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
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
|
-
import { currentSessionContext } from "
|
|
4
|
+
import { currentSessionContext } from "#server/adapters/currentSessionContext.ts";
|
|
5
5
|
import { SessionPolicy } from "./SessionPolicy.ts";
|
|
6
6
|
import type { SessionShape } from "./session.ts";
|
|
7
7
|
import { revalidateSession } from "./socketSession.ts";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Context,
|
|
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 { socketMonitor } from "#server/adapters/socketMonitor.ts";
|
|
4
5
|
import type { SessionShape } from "./session.ts";
|
|
5
6
|
|
|
6
7
|
export type SessionSnapshot = SessionShape & { readonly user: { readonly permissions?: readonly Permission[] } };
|
|
@@ -32,21 +33,7 @@ export const makeSocketSession = Effect.fnUntraced(function* (interval: Duration
|
|
|
32
33
|
}
|
|
33
34
|
return yield* batch;
|
|
34
35
|
}),
|
|
35
|
-
monitor:
|
|
36
|
-
Effect.gen(function* () {
|
|
37
|
-
const context = yield* Effect.context<R>();
|
|
38
|
-
const ended = yield* Deferred.make<never, E>();
|
|
39
|
-
const run = check.pipe(
|
|
40
|
-
Effect.provideContext(context),
|
|
41
|
-
Effect.catchCause((cause) => Deferred.failCause(ended, cause)),
|
|
42
|
-
Effect.asVoid,
|
|
43
|
-
);
|
|
44
|
-
yield* Effect.acquireRelease(
|
|
45
|
-
Effect.sync(() => checks.add(run)),
|
|
46
|
-
() => Effect.sync(() => checks.delete(run)),
|
|
47
|
-
);
|
|
48
|
-
return yield* Deferred.await(ended);
|
|
49
|
-
}),
|
|
36
|
+
monitor: socketMonitor(checks),
|
|
50
37
|
});
|
|
51
38
|
});
|
|
52
39
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AccountClock.d.ts","sourceRoot":"","sources":["../../src/server/AccountClock.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,eAAO,MAAM,YAAY;;;;;;;;CAKvB,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { defineService } from "@shivaedev/service/defineService.ts";
|
|
2
|
-
import { AccountPreferencesStore } from "#server/AccountPreferencesStore.ts";
|
|
3
|
-
import { dayRange } from "#server/account-clock/dayRange.ts";
|
|
4
|
-
import { initialize } from "#server/account-clock/initialize.ts";
|
|
5
|
-
import { logicalDay } from "#server/account-clock/logicalDay.ts";
|
|
6
|
-
import { AccountDayStart } from "#server/account-clock/settings.ts";
|
|
7
|
-
import { Subject } from "#subject.ts";
|
|
8
|
-
export const AccountClock = defineService({
|
|
9
|
-
id: "@shivaedev/identity/AccountClock",
|
|
10
|
-
initialize,
|
|
11
|
-
methods: (state) => ({ dayRange: dayRange(state), logicalDay: logicalDay(state) }),
|
|
12
|
-
requires: [AccountPreferencesStore, Subject, AccountDayStart],
|
|
13
|
-
});
|
|
14
|
-
//# sourceMappingURL=AccountClock.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AccountClock.js","sourceRoot":"","sources":["../../src/server/AccountClock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC;IACzC,EAAE,EAAE,kCAAkC;IACtC,UAAU;IACV,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;IAClF,QAAQ,EAAE,CAAC,uBAAuB,EAAE,OAAO,EAAE,eAAe,CAAC;CAC7D,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AccountPreferencesStore.d.ts","sourceRoot":"","sources":["../../src/server/AccountPreferencesStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAOvC,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;CAKlC,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { SqlClient } from "effect/sql";
|
|
2
|
-
import { defineService } from "@shivaedev/service/defineService.ts";
|
|
3
|
-
import { capture } from "#server/account-preferences/capture.ts";
|
|
4
|
-
import { get } from "#server/account-preferences/get.ts";
|
|
5
|
-
import { initialize } from "#server/account-preferences/initialize.ts";
|
|
6
|
-
import { set } from "#server/account-preferences/set.ts";
|
|
7
|
-
export const AccountPreferencesStore = defineService({
|
|
8
|
-
id: "@shivaedev/identity/AccountPreferencesStore",
|
|
9
|
-
initialize,
|
|
10
|
-
methods: (state) => ({ capture: capture(state), get: get(state), set: set(state) }),
|
|
11
|
-
requires: [SqlClient.SqlClient],
|
|
12
|
-
});
|
|
13
|
-
//# sourceMappingURL=AccountPreferencesStore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AccountPreferencesStore.js","sourceRoot":"","sources":["../../src/server/AccountPreferencesStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAC;AACjE,OAAO,EAAE,GAAG,EAAE,MAAM,oCAAoC,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,2CAA2C,CAAC;AACvE,OAAO,EAAE,GAAG,EAAE,MAAM,oCAAoC,CAAC;AAEzD,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAAC;IACpD,EAAE,EAAE,6CAA6C;IACjD,UAAU;IACV,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;IACnF,QAAQ,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC;CAC/B,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.d.ts","sourceRoot":"","sources":["../../../src/server/account-preferences/initialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAK7C,cAAM,iBAAkB,SAAQ,sBAG9B;CAAG;AAEL,eAAO,MAAM,UAAU;;;;idAKrB,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,UAAU,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"initialize.js","sourceRoot":"","sources":["../../../src/server/account-preferences/initialize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,MAAM,iBAAkB,SAAQ,KAAK,CAAC,KAAK,CAAoB,oBAAoB,CAAC,CAAC;IACpF,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,GAAG,uBAAuB,CAAC,MAAM;CACjC,CAAC;CAAG;AAEL,MAAM,CAAC,MAAM,UAAU,GAAG,cAAc,CAAC,iBAAiB,EAAE;IAC3D,eAAe,EAAE,CAAC,IAAI,CAAC;IACvB,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,oBAAoB;IAChC,SAAS,EAAE,8BAA8B;CACzC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"accountRoleSeed.d.ts","sourceRoot":"","sources":["../../../src/server/better-auth/accountRoleSeed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACrD,OAAO,EAAE,SAAS,EAAa,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO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,CAAC;YACnD,CAAC;QACF,CAAC;IACF,CAAC,CAAC,CAAC;IACH,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;IACf,OAAO,EAAE,QAAQ,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;AAC7F,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"currentSessionContext.d.ts","sourceRoot":"","sources":["../../src/server/currentSessionContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACzD,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,SAAS,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAGnG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,eAAO,MAAM,qBAAqB,GAAgC,QAAQ,SAAS,YAAY,EAAE,CAAC,EAAE,CAAC,+JAgBnG,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"currentSessionContext.js","sourceRoot":"","sources":["../../src/server/currentSessionContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,EAAwC,YAAY,EAAE,MAAM,+BAA+B,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,+BAA+B,EAAE,MAAM,cAAc,CAAC;AAC/F,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGjE,MAAM,CAAC,MAAM,qBAAqB,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAC/D,EAAU,EACV,MAAoD;IAEpD,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,MAA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Ac,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;KACxE,CAAC,CACF,CAAC;AACL,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { SqlClient } from "effect/sql";
|
|
2
|
-
import { defineService } from "@shivaedev/service/defineService.ts";
|
|
3
|
-
import { capture } from "#server/account-preferences/capture.ts";
|
|
4
|
-
import { get } from "#server/account-preferences/get.ts";
|
|
5
|
-
import { initialize } from "#server/account-preferences/initialize.ts";
|
|
6
|
-
import { set } from "#server/account-preferences/set.ts";
|
|
7
|
-
|
|
8
|
-
export const AccountPreferencesStore = defineService({
|
|
9
|
-
id: "@shivaedev/identity/AccountPreferencesStore",
|
|
10
|
-
initialize,
|
|
11
|
-
methods: (state) => ({ capture: capture(state), get: get(state), set: set(state) }),
|
|
12
|
-
requires: [SqlClient.SqlClient],
|
|
13
|
-
});
|