@effect-auth/core 0.1.0-alpha.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/LICENSE +21 -0
- package/README.md +113 -0
- package/dist/AuditLog.d.ts +71 -0
- package/dist/AuditLog.d.ts.map +1 -0
- package/dist/AuditLog.js +9 -0
- package/dist/AuditLog.js.map +1 -0
- package/dist/AuthFlow.d.ts +63 -0
- package/dist/AuthFlow.d.ts.map +1 -0
- package/dist/AuthFlow.js +10 -0
- package/dist/AuthFlow.js.map +1 -0
- package/dist/Challenge.d.ts +64 -0
- package/dist/Challenge.d.ts.map +1 -0
- package/dist/Challenge.js +10 -0
- package/dist/Challenge.js.map +1 -0
- package/dist/Crypto.d.ts +35 -0
- package/dist/Crypto.d.ts.map +1 -0
- package/dist/Crypto.js +6 -0
- package/dist/Crypto.js.map +1 -0
- package/dist/Identifiers.d.ts +59 -0
- package/dist/Identifiers.d.ts.map +1 -0
- package/dist/Identifiers.js +40 -0
- package/dist/Identifiers.js.map +1 -0
- package/dist/Policy.d.ts +39 -0
- package/dist/Policy.d.ts.map +1 -0
- package/dist/Policy.js +50 -0
- package/dist/Policy.js.map +1 -0
- package/dist/Privacy.d.ts +24 -0
- package/dist/Privacy.d.ts.map +1 -0
- package/dist/Privacy.js +12 -0
- package/dist/Privacy.js.map +1 -0
- package/dist/Sessions.d.ts +121 -0
- package/dist/Sessions.d.ts.map +1 -0
- package/dist/Sessions.js +20 -0
- package/dist/Sessions.js.map +1 -0
- package/dist/Testing.d.ts +3 -0
- package/dist/Testing.d.ts.map +1 -0
- package/dist/Testing.js +6 -0
- package/dist/Testing.js.map +1 -0
- package/dist/WaitUntil.d.ts +18 -0
- package/dist/WaitUntil.d.ts.map +1 -0
- package/dist/WaitUntil.js +9 -0
- package/dist/WaitUntil.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/package.json +75 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Effect Auth contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# @effect-auth/core
|
|
2
|
+
|
|
3
|
+
Composable Effect-first authentication primitives.
|
|
4
|
+
|
|
5
|
+
The current alpha surface is intentionally small: service contracts and small helpers that can be wired with application-owned layers.
|
|
6
|
+
|
|
7
|
+
## Policy
|
|
8
|
+
|
|
9
|
+
`Policy` is an `Effect` used for authorization. Success means access is allowed. `AuthzError` means access is denied. Other failures stay operational errors.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { Effect } from "effect"
|
|
13
|
+
import * as Policy from "@effect-auth/core/Policy"
|
|
14
|
+
|
|
15
|
+
const canEditProject = Policy.deny("missing-permission")
|
|
16
|
+
|
|
17
|
+
const updateProject = Effect.succeed({ updated: true }).pipe(
|
|
18
|
+
Policy.require(canEditProject)
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
const decision = Policy.check(canEditProject)
|
|
22
|
+
const detailed = Policy.checkDetailed(canEditProject)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Use `Policy.check` when callers should branch on allowed/denied and let operational errors fail. Use `Policy.checkDetailed` when callers need a value for allowed, denied, or failed.
|
|
26
|
+
|
|
27
|
+
Policies compose with `all`, `any`, and `not`:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
declare const isProjectOwner: Policy.Policy
|
|
31
|
+
declare const hasUpdateGrant: Policy.Policy
|
|
32
|
+
declare const isSuspended: Policy.Policy
|
|
33
|
+
|
|
34
|
+
const canEditProject = Policy.any(
|
|
35
|
+
isProjectOwner,
|
|
36
|
+
hasUpdateGrant
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
const canEditAndNotSuspended = Policy.all(
|
|
40
|
+
canEditProject,
|
|
41
|
+
Policy.not(isSuspended, "account-disabled")
|
|
42
|
+
)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## AuthFlow
|
|
46
|
+
|
|
47
|
+
Login methods should verify a factor, then hand the result to `AuthFlow`. `AuthFlow` decides whether to issue a session, require MFA, require verification, or deny the attempt.
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { Effect } from "effect"
|
|
51
|
+
import { AuthFlow } from "@effect-auth/core/AuthFlow"
|
|
52
|
+
import type { UserId } from "@effect-auth/core/Identifiers"
|
|
53
|
+
|
|
54
|
+
export const completePassword = (userId: UserId) =>
|
|
55
|
+
Effect.gen(function* () {
|
|
56
|
+
const authFlow = yield* AuthFlow
|
|
57
|
+
|
|
58
|
+
return yield* authFlow.completePrimaryFactor({
|
|
59
|
+
userId,
|
|
60
|
+
method: "password",
|
|
61
|
+
amr: ["pwd"],
|
|
62
|
+
aal: "aal1"
|
|
63
|
+
})
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Sessions
|
|
68
|
+
|
|
69
|
+
`Sessions` is the server-side session authority. Transports such as cookies are separate services so browser, API, and custom transports can share the same session strategy.
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import { Effect } from "effect"
|
|
73
|
+
import type { UserId } from "@effect-auth/core/Identifiers"
|
|
74
|
+
import { SessionCookie, Sessions } from "@effect-auth/core/Sessions"
|
|
75
|
+
|
|
76
|
+
export const createBrowserSession = (userId: UserId) =>
|
|
77
|
+
Effect.gen(function* () {
|
|
78
|
+
const sessions = yield* Sessions
|
|
79
|
+
const sessionCookie = yield* SessionCookie
|
|
80
|
+
|
|
81
|
+
const issued = yield* sessions.create({
|
|
82
|
+
userId,
|
|
83
|
+
method: "password",
|
|
84
|
+
amr: ["pwd"],
|
|
85
|
+
aal: "aal1"
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
const cookie = yield* sessionCookie.commit(issued)
|
|
89
|
+
|
|
90
|
+
return { issued, cookie }
|
|
91
|
+
})
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Challenge
|
|
95
|
+
|
|
96
|
+
`Challenge` is the shared primitive for short-lived proofs: email OTP, magic link, passkey challenges, OAuth state, reset password, and MFA.
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
import { Duration, Effect, Redacted } from "effect"
|
|
100
|
+
import { Challenge } from "@effect-auth/core/Challenge"
|
|
101
|
+
|
|
102
|
+
export const issueEmailOtp = (email: string, code: string) =>
|
|
103
|
+
Effect.gen(function* () {
|
|
104
|
+
const challenge = yield* Challenge
|
|
105
|
+
|
|
106
|
+
return yield* challenge.issue({
|
|
107
|
+
type: "email-otp",
|
|
108
|
+
subject: email,
|
|
109
|
+
ttl: Duration.minutes(10),
|
|
110
|
+
secret: Redacted.make(code)
|
|
111
|
+
})
|
|
112
|
+
})
|
|
113
|
+
```
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Context, Effect, Layer } from "effect";
|
|
2
|
+
import type { AuditEventId, EmailHash, IpHash, PolicyId, SessionId, UnixMillis, UserAgentHash, UserId } from "./Identifiers.js";
|
|
3
|
+
declare const AuditLogError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
4
|
+
readonly _tag: "AuditLogError";
|
|
5
|
+
} & Readonly<A>;
|
|
6
|
+
export declare class AuditLogError extends AuditLogError_base<{
|
|
7
|
+
readonly message: string;
|
|
8
|
+
readonly cause?: unknown;
|
|
9
|
+
}> {
|
|
10
|
+
}
|
|
11
|
+
export type AuditActor = {
|
|
12
|
+
readonly type: "anonymous";
|
|
13
|
+
} | {
|
|
14
|
+
readonly type: "user";
|
|
15
|
+
readonly userId: UserId;
|
|
16
|
+
readonly sessionId?: SessionId;
|
|
17
|
+
};
|
|
18
|
+
export type AuditSubject = {
|
|
19
|
+
readonly type: "anonymous";
|
|
20
|
+
} | {
|
|
21
|
+
readonly type: "email";
|
|
22
|
+
readonly emailHash: EmailHash;
|
|
23
|
+
} | {
|
|
24
|
+
readonly type: "user";
|
|
25
|
+
readonly userId: UserId;
|
|
26
|
+
};
|
|
27
|
+
export interface AuditRequest {
|
|
28
|
+
readonly ipHash?: IpHash;
|
|
29
|
+
readonly userAgentHash?: UserAgentHash;
|
|
30
|
+
}
|
|
31
|
+
export type AuthAuditEvent = {
|
|
32
|
+
readonly type: "auth.login.succeeded";
|
|
33
|
+
readonly id?: AuditEventId;
|
|
34
|
+
readonly actor: AuditActor;
|
|
35
|
+
readonly method: string;
|
|
36
|
+
readonly request?: AuditRequest;
|
|
37
|
+
readonly occurredAt: UnixMillis;
|
|
38
|
+
} | {
|
|
39
|
+
readonly type: "auth.login.failed";
|
|
40
|
+
readonly id?: AuditEventId;
|
|
41
|
+
readonly subject: AuditSubject;
|
|
42
|
+
readonly method: string;
|
|
43
|
+
readonly reason: string;
|
|
44
|
+
readonly request?: AuditRequest;
|
|
45
|
+
readonly occurredAt: UnixMillis;
|
|
46
|
+
} | {
|
|
47
|
+
readonly type: "auth.session.revoked";
|
|
48
|
+
readonly id?: AuditEventId;
|
|
49
|
+
readonly actor: AuditActor;
|
|
50
|
+
readonly sessionId: SessionId;
|
|
51
|
+
readonly reason: string;
|
|
52
|
+
readonly request?: AuditRequest;
|
|
53
|
+
readonly occurredAt: UnixMillis;
|
|
54
|
+
} | {
|
|
55
|
+
readonly type: "auth.policy.denied";
|
|
56
|
+
readonly id?: AuditEventId;
|
|
57
|
+
readonly actor: AuditActor;
|
|
58
|
+
readonly policyId: PolicyId;
|
|
59
|
+
readonly reason: string;
|
|
60
|
+
readonly request?: AuditRequest;
|
|
61
|
+
readonly occurredAt: UnixMillis;
|
|
62
|
+
};
|
|
63
|
+
export interface AuditLogService {
|
|
64
|
+
readonly emit: (event: AuthAuditEvent) => Effect.Effect<void, AuditLogError>;
|
|
65
|
+
}
|
|
66
|
+
declare const AuditLog_base: Context.ServiceClass<AuditLog, "auth/AuditLog", AuditLogService>;
|
|
67
|
+
export declare class AuditLog extends AuditLog_base {
|
|
68
|
+
}
|
|
69
|
+
export declare const AuditLogNoopLive: Layer.Layer<AuditLog, never, never>;
|
|
70
|
+
export {};
|
|
71
|
+
//# sourceMappingURL=AuditLog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuditLog.d.ts","sourceRoot":"","sources":["../src/AuditLog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAQ,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAErD,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE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|
|
|
1
|
+
import { Context, Data, Effect, Layer } from "effect";
|
|
2
|
+
export class AuditLogError extends Data.TaggedError("AuditLogError") {
|
|
3
|
+
}
|
|
4
|
+
export class AuditLog extends Context.Service()("auth/AuditLog") {
|
|
5
|
+
}
|
|
6
|
+
export const AuditLogNoopLive = Layer.succeed(AuditLog)({
|
|
7
|
+
emit: () => Effect.void
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=AuditLog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuditLog.js","sourceRoot":"","sources":["../src/AuditLog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAIrD,MAAM,OAAO,aAAc,SAAQ,IAAI,CAAC,WAAW,CAAC,eAAe,CAGjE;CAAG;AAyDL,MAAM,OAAO,QAAS,SAAQ,OAAO,CAAC,OAAO,EAA6B,CAAC,eAAe,CAAC;CAAG;AAE9F,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtD,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI;CACxB,CAAC,CAAA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Context, Effect } from "effect";
|
|
2
|
+
import type { AuthFlowId, UserId } from "./Identifiers.js";
|
|
3
|
+
import type { AuthAssuranceLevel, AuthMethodReference, IssuedSession } from "./Sessions.js";
|
|
4
|
+
export type AuthMethod = "password" | "email-otp" | "magic-link" | "passkey" | "oauth" | "totp" | "backup-code" | (string & {});
|
|
5
|
+
export type AuthDenyReason = "invalid-credentials" | "account-disabled" | "rate-limited" | "policy-denied" | "requires-explicit-linking" | (string & {});
|
|
6
|
+
export interface MfaFactor {
|
|
7
|
+
readonly type: "totp" | "backup-code" | "passkey" | (string & {});
|
|
8
|
+
}
|
|
9
|
+
export interface PrimaryFactorResult {
|
|
10
|
+
readonly userId: UserId;
|
|
11
|
+
readonly method: AuthMethod;
|
|
12
|
+
readonly amr: ReadonlyArray<AuthMethodReference>;
|
|
13
|
+
readonly aal: AuthAssuranceLevel;
|
|
14
|
+
}
|
|
15
|
+
export interface MfaCompleteInput {
|
|
16
|
+
readonly flowId: AuthFlowId;
|
|
17
|
+
readonly method: AuthMethod;
|
|
18
|
+
readonly amr: ReadonlyArray<AuthMethodReference>;
|
|
19
|
+
readonly aal: AuthAssuranceLevel;
|
|
20
|
+
}
|
|
21
|
+
export interface AuthFlowCompleteInput {
|
|
22
|
+
readonly userId: UserId;
|
|
23
|
+
readonly method: AuthMethod;
|
|
24
|
+
readonly amr: ReadonlyArray<AuthMethodReference>;
|
|
25
|
+
readonly aal: AuthAssuranceLevel;
|
|
26
|
+
}
|
|
27
|
+
export type AuthResult = {
|
|
28
|
+
readonly type: "authenticated";
|
|
29
|
+
readonly session: IssuedSession;
|
|
30
|
+
} | {
|
|
31
|
+
readonly type: "requires-mfa";
|
|
32
|
+
readonly flowId: AuthFlowId;
|
|
33
|
+
readonly factors: ReadonlyArray<MfaFactor>;
|
|
34
|
+
} | {
|
|
35
|
+
readonly type: "requires-email-verification";
|
|
36
|
+
readonly flowId: AuthFlowId;
|
|
37
|
+
} | {
|
|
38
|
+
readonly type: "requires-passkey-enrollment";
|
|
39
|
+
readonly flowId: AuthFlowId;
|
|
40
|
+
} | {
|
|
41
|
+
readonly type: "denied";
|
|
42
|
+
readonly reason: AuthDenyReason;
|
|
43
|
+
};
|
|
44
|
+
declare const AuthFlowError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
45
|
+
readonly _tag: "AuthFlowError";
|
|
46
|
+
} & Readonly<A>;
|
|
47
|
+
export declare class AuthFlowError extends AuthFlowError_base<{
|
|
48
|
+
readonly message: string;
|
|
49
|
+
readonly cause?: unknown;
|
|
50
|
+
}> {
|
|
51
|
+
}
|
|
52
|
+
export interface AuthFlowService {
|
|
53
|
+
readonly startPrimaryFactor: (input: PrimaryFactorResult) => Effect.Effect<AuthResult, AuthFlowError>;
|
|
54
|
+
readonly completePrimaryFactor: (input: PrimaryFactorResult) => Effect.Effect<AuthResult, AuthFlowError>;
|
|
55
|
+
readonly completeMfa: (input: MfaCompleteInput) => Effect.Effect<AuthResult, AuthFlowError>;
|
|
56
|
+
readonly complete: (input: AuthFlowCompleteInput) => Effect.Effect<AuthResult, AuthFlowError>;
|
|
57
|
+
}
|
|
58
|
+
declare const AuthFlow_base: Context.ServiceClass<AuthFlow, "auth/AuthFlow", AuthFlowService>;
|
|
59
|
+
export declare class AuthFlow extends AuthFlow_base {
|
|
60
|
+
}
|
|
61
|
+
export declare const denied: (reason: AuthDenyReason) => AuthResult;
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=AuthFlow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthFlow.d.ts","sourceRoot":"","sources":["../src/AuthFlow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAQ,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE3F,MAAM,MAAM,UAAU,GAClB,UAAU,GACV,WAAW,GACX,YAAY,GACZ,SAAS,GACT,OAAO,GACP,MAAM,GACN,aAAa,GACb,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEjB,MAAM,MAAM,cAAc,GACtB,qBAAqB,GACrB,kBAAkB,GAClB,cAAc,GACd,eAAe,GACf,2BAA2B,GAC3B,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEjB,MAAM,WAAW,SAAS;IACxB,QAAQ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AQ,CAAC,MAAM,EAAE,UAAU,CAAA;CAAE,GAC7E;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;CAAE,CAAA;;;;AAEhE,qBAAa,aAAc,SAAQ,mBAAkC;IACnE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CACzB,CAAC;CAAG;AAEL,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,kBAAkB,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,CAAA;IACrG,QAAQ,CAAC,qBAAqB,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,CAAA;IACxG,QAAQ,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,CAAA;IAC3F,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,CAAA;CAC9F;;AAED,qBAAa,QAAS,SAAQ,aAA6D;CAAG;AAE9F,eAAO,MAAM,MAAM,GAAI,QAAQ,cAAc,KAAG,UAG9C,CAAA"}
|
package/dist/AuthFlow.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Context, Data, Effect } from "effect";
|
|
2
|
+
export class AuthFlowError extends Data.TaggedError("AuthFlowError") {
|
|
3
|
+
}
|
|
4
|
+
export class AuthFlow extends Context.Service()("auth/AuthFlow") {
|
|
5
|
+
}
|
|
6
|
+
export const denied = (reason) => ({
|
|
7
|
+
type: "denied",
|
|
8
|
+
reason
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=AuthFlow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthFlow.js","sourceRoot":"","sources":["../src/AuthFlow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAuD9C,MAAM,OAAO,aAAc,SAAQ,IAAI,CAAC,WAAW,CAAC,eAAe,CAGjE;CAAG;AASL,MAAM,OAAO,QAAS,SAAQ,OAAO,CAAC,OAAO,EAA6B,CAAC,eAAe,CAAC;CAAG;AAE9F,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,MAAsB,EAAc,EAAE,CAAC,CAAC;IAC7D,IAAI,EAAE,QAAQ;IACd,MAAM;CACP,CAAC,CAAA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Context, Effect, Redacted } from "effect";
|
|
2
|
+
import type * as Duration from "effect/Duration";
|
|
3
|
+
import type { ChallengeId, UnixMillis } from "./Identifiers.js";
|
|
4
|
+
export type ChallengeType = "email-otp" | "magic-link" | "passkey-authentication" | "reset-password" | "email-verification" | "oauth-state" | "mfa" | (string & {});
|
|
5
|
+
export interface ChallengeIssueInput {
|
|
6
|
+
readonly type: ChallengeType;
|
|
7
|
+
readonly subject: string;
|
|
8
|
+
readonly ttl: Duration.Duration;
|
|
9
|
+
readonly secret?: Redacted.Redacted<string>;
|
|
10
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
11
|
+
}
|
|
12
|
+
export interface IssuedChallenge {
|
|
13
|
+
readonly id: ChallengeId;
|
|
14
|
+
readonly type: ChallengeType;
|
|
15
|
+
readonly subject: string;
|
|
16
|
+
readonly secret?: Redacted.Redacted<string>;
|
|
17
|
+
readonly expiresAt: UnixMillis;
|
|
18
|
+
}
|
|
19
|
+
export interface ChallengeVerifyInput {
|
|
20
|
+
readonly challengeId: ChallengeId;
|
|
21
|
+
readonly type: ChallengeType;
|
|
22
|
+
readonly secret?: Redacted.Redacted<string>;
|
|
23
|
+
}
|
|
24
|
+
export interface VerifiedChallenge {
|
|
25
|
+
readonly id: ChallengeId;
|
|
26
|
+
readonly type: ChallengeType;
|
|
27
|
+
readonly subject: string;
|
|
28
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
29
|
+
}
|
|
30
|
+
declare const ChallengeIssueError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
31
|
+
readonly _tag: "ChallengeIssueError";
|
|
32
|
+
} & Readonly<A>;
|
|
33
|
+
export declare class ChallengeIssueError extends ChallengeIssueError_base<{
|
|
34
|
+
readonly message: string;
|
|
35
|
+
readonly cause?: unknown;
|
|
36
|
+
}> {
|
|
37
|
+
}
|
|
38
|
+
declare const ChallengeVerifyError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
39
|
+
readonly _tag: "ChallengeVerifyError";
|
|
40
|
+
} & Readonly<A>;
|
|
41
|
+
export declare class ChallengeVerifyError extends ChallengeVerifyError_base<{
|
|
42
|
+
readonly message: string;
|
|
43
|
+
readonly cause?: unknown;
|
|
44
|
+
}> {
|
|
45
|
+
}
|
|
46
|
+
declare const ChallengeConsumeError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
47
|
+
readonly _tag: "ChallengeConsumeError";
|
|
48
|
+
} & Readonly<A>;
|
|
49
|
+
export declare class ChallengeConsumeError extends ChallengeConsumeError_base<{
|
|
50
|
+
readonly message: string;
|
|
51
|
+
readonly cause?: unknown;
|
|
52
|
+
}> {
|
|
53
|
+
}
|
|
54
|
+
export type ChallengeError = ChallengeIssueError | ChallengeVerifyError | ChallengeConsumeError;
|
|
55
|
+
export interface ChallengeService {
|
|
56
|
+
readonly issue: (input: ChallengeIssueInput) => Effect.Effect<IssuedChallenge, ChallengeIssueError>;
|
|
57
|
+
readonly verify: (input: ChallengeVerifyInput) => Effect.Effect<VerifiedChallenge, ChallengeVerifyError>;
|
|
58
|
+
readonly consume: (id: ChallengeId) => Effect.Effect<void, ChallengeConsumeError>;
|
|
59
|
+
}
|
|
60
|
+
declare const Challenge_base: Context.ServiceClass<Challenge, "auth/Challenge", ChallengeService>;
|
|
61
|
+
export declare class Challenge extends Challenge_base {
|
|
62
|
+
}
|
|
63
|
+
export {};
|
|
64
|
+
//# sourceMappingURL=Challenge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Challenge.d.ts","sourceRoot":"","sources":["../src/Challenge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAQ,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AACxD,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE/D,MAAM,MAAM,aAAa,GACrB,WAAW,GACX,YAAY,GACZ,wBAAwB,GACxB,gBAAgB,GAChB,oBAAoB,GACpB,aAAa,GACb,KAAK,GACL,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEjB,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAA;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,QAAQ,CAAA;IAC/B,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;IAC3C,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;CACtD;A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AAG,mBAAmB,GAAG,oBAAoB,GAAG,qBAAqB,CAAA;AAE/F,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,mBAAmB,CAAC,CAAA;IACnG,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,MAAM,CAAC,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,CAAA;IACxG,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,WAAW,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAA;CAClF;;AAED,qBAAa,SAAU,SAAQ,cAAgE;CAAG"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Context, Data, Effect, Redacted } from "effect";
|
|
2
|
+
export class ChallengeIssueError extends Data.TaggedError("ChallengeIssueError") {
|
|
3
|
+
}
|
|
4
|
+
export class ChallengeVerifyError extends Data.TaggedError("ChallengeVerifyError") {
|
|
5
|
+
}
|
|
6
|
+
export class ChallengeConsumeError extends Data.TaggedError("ChallengeConsumeError") {
|
|
7
|
+
}
|
|
8
|
+
export class Challenge extends Context.Service()("auth/Challenge") {
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=Challenge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Challenge.js","sourceRoot":"","sources":["../src/Challenge.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AA4CxD,MAAM,OAAO,mBAAoB,SAAQ,IAAI,CAAC,WAAW,CAAC,qBAAqB,CAG7E;CAAG;AAEL,MAAM,OAAO,oBAAqB,SAAQ,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAG/E;CAAG;AAEL,MAAM,OAAO,qBAAsB,SAAQ,IAAI,CAAC,WAAW,CAAC,uBAAuB,CAGjF;CAAG;AAUL,MAAM,OAAO,SAAU,SAAQ,OAAO,CAAC,OAAO,EAA+B,CAAC,gBAAgB,CAAC;CAAG"}
|
package/dist/Crypto.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Context, Effect, Redacted } from "effect";
|
|
2
|
+
export type CryptoOperation = "random-bytes" | "random-token" | "digest" | "hmac-sha256" | "timing-safe-equal";
|
|
3
|
+
declare const CryptoError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
4
|
+
readonly _tag: "CryptoError";
|
|
5
|
+
} & Readonly<A>;
|
|
6
|
+
export declare class CryptoError extends CryptoError_base<{
|
|
7
|
+
readonly operation: CryptoOperation;
|
|
8
|
+
readonly message: string;
|
|
9
|
+
readonly cause?: unknown;
|
|
10
|
+
}> {
|
|
11
|
+
}
|
|
12
|
+
export type CryptoKey = Redacted.Redacted<string> | Uint8Array;
|
|
13
|
+
export interface HmacSha256Input {
|
|
14
|
+
readonly key: CryptoKey;
|
|
15
|
+
readonly data: string | Uint8Array;
|
|
16
|
+
}
|
|
17
|
+
export interface DigestInput {
|
|
18
|
+
readonly data: string | Uint8Array;
|
|
19
|
+
}
|
|
20
|
+
export interface TimingSafeEqualInput {
|
|
21
|
+
readonly left: Uint8Array;
|
|
22
|
+
readonly right: Uint8Array;
|
|
23
|
+
}
|
|
24
|
+
export interface CryptoService {
|
|
25
|
+
readonly randomBytes: (byteLength: number) => Effect.Effect<Uint8Array, CryptoError>;
|
|
26
|
+
readonly randomToken: (byteLength?: number) => Effect.Effect<string, CryptoError>;
|
|
27
|
+
readonly digestSha256: (input: DigestInput) => Effect.Effect<string, CryptoError>;
|
|
28
|
+
readonly hmacSha256: (input: HmacSha256Input) => Effect.Effect<string, CryptoError>;
|
|
29
|
+
readonly timingSafeEqual: (input: TimingSafeEqualInput) => Effect.Effect<boolean, CryptoError>;
|
|
30
|
+
}
|
|
31
|
+
declare const Crypto_base: Context.ServiceClass<Crypto, "auth/Crypto", CryptoService>;
|
|
32
|
+
export declare class Crypto extends Crypto_base {
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=Crypto.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Crypto.d.ts","sourceRoot":"","sources":["../src/Crypto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAQ,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAExD,MAAM,MAAM,eAAe,GACvB,cAAc,GACd,cAAc,GACd,QAAQ,GACR,aAAa,GACb,mBAAmB,CAAA;;;;AAEvB,qBAAa,WAAY,SAAQ,iBAAgC;IAC/D,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAA;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CACzB,CAAC;CAAG;AAEL,MAAM,MAAM,SAAS,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,UAAU,CAAA;AAE9D,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAA;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAA;CACnC;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAA;CACnC;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;CAC3B;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,WAAW,CAAC,CAAA;IACpF,QAAQ,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;IACjF,QAAQ,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;IACjF,QAAQ,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;IACnF,QAAQ,CAAC,eAAe,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;CAC/F;;AAED,qBAAa,MAAO,SAAQ,WAAuD;CAAG"}
|
package/dist/Crypto.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Crypto.js","sourceRoot":"","sources":["../src/Crypto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AASxD,MAAM,OAAO,WAAY,SAAQ,IAAI,CAAC,WAAW,CAAC,aAAa,CAI7D;CAAG;AA0BL,MAAM,OAAO,MAAO,SAAQ,OAAO,CAAC,OAAO,EAAyB,CAAC,aAAa,CAAC;CAAG"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Brand, Schema } from "effect";
|
|
2
|
+
export type UserId = Brand.Branded<string, "auth/UserId">;
|
|
3
|
+
export declare const UserId: Brand.Constructor<UserId>;
|
|
4
|
+
export declare const UserIdSchema: Schema.brand<Schema.String, "auth/UserId">;
|
|
5
|
+
export type IdentityId = Brand.Branded<string, "auth/IdentityId">;
|
|
6
|
+
export declare const IdentityId: Brand.Constructor<IdentityId>;
|
|
7
|
+
export declare const IdentityIdSchema: Schema.brand<Schema.String, "auth/IdentityId">;
|
|
8
|
+
export type CredentialId = Brand.Branded<string, "auth/CredentialId">;
|
|
9
|
+
export declare const CredentialId: Brand.Constructor<CredentialId>;
|
|
10
|
+
export declare const CredentialIdSchema: Schema.brand<Schema.String, "auth/CredentialId">;
|
|
11
|
+
export type SessionId = Brand.Branded<string, "auth/SessionId">;
|
|
12
|
+
export declare const SessionId: Brand.Constructor<SessionId>;
|
|
13
|
+
export declare const SessionIdSchema: Schema.brand<Schema.String, "auth/SessionId">;
|
|
14
|
+
export type SessionToken = Brand.Branded<string, "auth/SessionToken">;
|
|
15
|
+
export declare const SessionToken: Brand.Constructor<SessionToken>;
|
|
16
|
+
export declare const SessionTokenSchema: Schema.brand<Schema.String, "auth/SessionToken">;
|
|
17
|
+
export type ChallengeId = Brand.Branded<string, "auth/ChallengeId">;
|
|
18
|
+
export declare const ChallengeId: Brand.Constructor<ChallengeId>;
|
|
19
|
+
export declare const ChallengeIdSchema: Schema.brand<Schema.String, "auth/ChallengeId">;
|
|
20
|
+
export type AuthFlowId = Brand.Branded<string, "auth/AuthFlowId">;
|
|
21
|
+
export declare const AuthFlowId: Brand.Constructor<AuthFlowId>;
|
|
22
|
+
export declare const AuthFlowIdSchema: Schema.brand<Schema.String, "auth/AuthFlowId">;
|
|
23
|
+
export type OAuthProviderId = Brand.Branded<string, "auth/OAuthProviderId">;
|
|
24
|
+
export declare const OAuthProviderId: Brand.Constructor<OAuthProviderId>;
|
|
25
|
+
export declare const OAuthProviderIdSchema: Schema.brand<Schema.String, "auth/OAuthProviderId">;
|
|
26
|
+
export type OAuthAccountId = Brand.Branded<string, "auth/OAuthAccountId">;
|
|
27
|
+
export declare const OAuthAccountId: Brand.Constructor<OAuthAccountId>;
|
|
28
|
+
export declare const OAuthAccountIdSchema: Schema.brand<Schema.String, "auth/OAuthAccountId">;
|
|
29
|
+
export type PermissionId = Brand.Branded<string, "auth/PermissionId">;
|
|
30
|
+
export declare const PermissionId: Brand.Constructor<PermissionId>;
|
|
31
|
+
export declare const PermissionIdSchema: Schema.brand<Schema.String, "auth/PermissionId">;
|
|
32
|
+
export type PolicyId = Brand.Branded<string, "auth/PolicyId">;
|
|
33
|
+
export declare const PolicyId: Brand.Constructor<PolicyId>;
|
|
34
|
+
export declare const PolicyIdSchema: Schema.brand<Schema.String, "auth/PolicyId">;
|
|
35
|
+
export type RoleId = Brand.Branded<string, "auth/RoleId">;
|
|
36
|
+
export declare const RoleId: Brand.Constructor<RoleId>;
|
|
37
|
+
export declare const RoleIdSchema: Schema.brand<Schema.String, "auth/RoleId">;
|
|
38
|
+
export type AuditEventId = Brand.Branded<string, "auth/AuditEventId">;
|
|
39
|
+
export declare const AuditEventId: Brand.Constructor<AuditEventId>;
|
|
40
|
+
export declare const AuditEventIdSchema: Schema.brand<Schema.String, "auth/AuditEventId">;
|
|
41
|
+
export type Email = Brand.Branded<string, "auth/Email">;
|
|
42
|
+
export declare const Email: Brand.Constructor<Email>;
|
|
43
|
+
export declare const EmailSchema: Schema.brand<Schema.String, "auth/Email">;
|
|
44
|
+
export type EmailHash = Brand.Branded<string, "auth/EmailHash">;
|
|
45
|
+
export declare const EmailHash: Brand.Constructor<EmailHash>;
|
|
46
|
+
export declare const EmailHashSchema: Schema.brand<Schema.String, "auth/EmailHash">;
|
|
47
|
+
export type IpAddress = Brand.Branded<string, "auth/IpAddress">;
|
|
48
|
+
export declare const IpAddress: Brand.Constructor<IpAddress>;
|
|
49
|
+
export declare const IpAddressSchema: Schema.brand<Schema.String, "auth/IpAddress">;
|
|
50
|
+
export type IpHash = Brand.Branded<string, "auth/IpHash">;
|
|
51
|
+
export declare const IpHash: Brand.Constructor<IpHash>;
|
|
52
|
+
export declare const IpHashSchema: Schema.brand<Schema.String, "auth/IpHash">;
|
|
53
|
+
export type UserAgentHash = Brand.Branded<string, "auth/UserAgentHash">;
|
|
54
|
+
export declare const UserAgentHash: Brand.Constructor<UserAgentHash>;
|
|
55
|
+
export declare const UserAgentHashSchema: Schema.brand<Schema.String, "auth/UserAgentHash">;
|
|
56
|
+
export type UnixMillis = Brand.Branded<number, "auth/UnixMillis">;
|
|
57
|
+
export declare const UnixMillis: Brand.Constructor<UnixMillis>;
|
|
58
|
+
export declare const UnixMillisSchema: Schema.brand<Schema.Number, "auth/UnixMillis">;
|
|
59
|
+
//# sourceMappingURL=Identifiers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Identifiers.d.ts","sourceRoot":"","sources":["../src/Identifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAEtC,MAAM,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;AACzD,eAAO,MAAM,MAAM,2BAA0B,CAAA;AAC7C,eAAO,MAAM,YAAY,4CAAkD,CAAA;AAE3E,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;AACjE,eAAO,MAAM,UAAU,+BAA8B,CAAA;AACrD,eAAO,MAAM,gBAAgB,gDAAsD,CAAA;AAEnF,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAA;AACrE,eAAO,MAAM,YAAY,iCAAgC,CAAA;AACzD,eAAO,MAAM,kBAAkB,kDAAwD,CAAA;AAEvF,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAA;AAC/D,eAAO,MAAM,SAAS,8BAA6B,CAAA;AACnD,eAAO,MAAM,eAAe,+CAAqD,CAAA;AAEjF,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAA;AACrE,eAAO,MAAM,YAAY,iCAAgC,CAAA;AACzD,eAAO,MAAM,kBAAkB,kDAAwD,CAAA;AAEvF,MAAM,MAA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4
|
+
export const IdentityId = Brand.nominal();
|
|
5
|
+
export const IdentityIdSchema = Schema.String.pipe(Schema.brand("auth/IdentityId"));
|
|
6
|
+
export const CredentialId = Brand.nominal();
|
|
7
|
+
export const CredentialIdSchema = Schema.String.pipe(Schema.brand("auth/CredentialId"));
|
|
8
|
+
export const SessionId = Brand.nominal();
|
|
9
|
+
export const SessionIdSchema = Schema.String.pipe(Schema.brand("auth/SessionId"));
|
|
10
|
+
export const SessionToken = Brand.nominal();
|
|
11
|
+
export const SessionTokenSchema = Schema.String.pipe(Schema.brand("auth/SessionToken"));
|
|
12
|
+
export const ChallengeId = Brand.nominal();
|
|
13
|
+
export const ChallengeIdSchema = Schema.String.pipe(Schema.brand("auth/ChallengeId"));
|
|
14
|
+
export const AuthFlowId = Brand.nominal();
|
|
15
|
+
export const AuthFlowIdSchema = Schema.String.pipe(Schema.brand("auth/AuthFlowId"));
|
|
16
|
+
export const OAuthProviderId = Brand.nominal();
|
|
17
|
+
export const OAuthProviderIdSchema = Schema.String.pipe(Schema.brand("auth/OAuthProviderId"));
|
|
18
|
+
export const OAuthAccountId = Brand.nominal();
|
|
19
|
+
export const OAuthAccountIdSchema = Schema.String.pipe(Schema.brand("auth/OAuthAccountId"));
|
|
20
|
+
export const PermissionId = Brand.nominal();
|
|
21
|
+
export const PermissionIdSchema = Schema.String.pipe(Schema.brand("auth/PermissionId"));
|
|
22
|
+
export const PolicyId = Brand.nominal();
|
|
23
|
+
export const PolicyIdSchema = Schema.String.pipe(Schema.brand("auth/PolicyId"));
|
|
24
|
+
export const RoleId = Brand.nominal();
|
|
25
|
+
export const RoleIdSchema = Schema.String.pipe(Schema.brand("auth/RoleId"));
|
|
26
|
+
export const AuditEventId = Brand.nominal();
|
|
27
|
+
export const AuditEventIdSchema = Schema.String.pipe(Schema.brand("auth/AuditEventId"));
|
|
28
|
+
export const Email = Brand.nominal();
|
|
29
|
+
export const EmailSchema = Schema.String.pipe(Schema.brand("auth/Email"));
|
|
30
|
+
export const EmailHash = Brand.nominal();
|
|
31
|
+
export const EmailHashSchema = Schema.String.pipe(Schema.brand("auth/EmailHash"));
|
|
32
|
+
export const IpAddress = Brand.nominal();
|
|
33
|
+
export const IpAddressSchema = Schema.String.pipe(Schema.brand("auth/IpAddress"));
|
|
34
|
+
export const IpHash = Brand.nominal();
|
|
35
|
+
export const IpHashSchema = Schema.String.pipe(Schema.brand("auth/IpHash"));
|
|
36
|
+
export const UserAgentHash = Brand.nominal();
|
|
37
|
+
export const UserAgentHashSchema = Schema.String.pipe(Schema.brand("auth/UserAgentHash"));
|
|
38
|
+
export const UnixMillis = Brand.nominal();
|
|
39
|
+
export const UnixMillisSchema = Schema.Number.pipe(Schema.brand("auth/UnixMillis"));
|
|
40
|
+
//# sourceMappingURL=Identifiers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Identifiers.js","sourceRoot":"","sources":["../src/Identifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAGtC,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,EAAU,CAAA;AAC7C,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAA;AAG3E,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,EAAc,CAAA;AACrD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAA;AAGnF,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,EAAgB,CAAA;AACzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,CAAA;AAGv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AAgB,CAAC,CAAC,CAAA;AAGjF,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,EAAU,CAAA;AAC7C,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAA;AAG3E,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,EAAiB,CAAA;AAC3D,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAA;AAGzF,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,EAAc,CAAA;AACrD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAA"}
|
package/dist/Policy.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import type { PolicyId } from "./Identifiers.js";
|
|
3
|
+
import type { CurrentActor } from "./Sessions.js";
|
|
4
|
+
export type AuthzDenyReason = "missing-permission" | "missing-role" | "missing-relation" | "missing-grant" | "not-owner" | "not-authenticated" | (string & {});
|
|
5
|
+
declare const AuthzError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
6
|
+
readonly _tag: "AuthzError";
|
|
7
|
+
} & Readonly<A>;
|
|
8
|
+
export declare class AuthzError extends AuthzError_base<{
|
|
9
|
+
readonly reason: AuthzDenyReason;
|
|
10
|
+
readonly policyId?: PolicyId;
|
|
11
|
+
readonly message?: string;
|
|
12
|
+
readonly cause?: unknown;
|
|
13
|
+
}> {
|
|
14
|
+
}
|
|
15
|
+
export type Policy<A = void, E = never, R = never> = Effect.Effect<A, AuthzError | E, CurrentActor | R>;
|
|
16
|
+
export type PolicyDecision = {
|
|
17
|
+
readonly type: "allowed";
|
|
18
|
+
} | {
|
|
19
|
+
readonly type: "denied";
|
|
20
|
+
readonly error: AuthzError;
|
|
21
|
+
};
|
|
22
|
+
export type PolicyCheckResult<E = never> = PolicyDecision | {
|
|
23
|
+
readonly type: "failed";
|
|
24
|
+
readonly error: E;
|
|
25
|
+
};
|
|
26
|
+
type NonAuthzError<E> = Exclude<E, AuthzError>;
|
|
27
|
+
type EffectError<T> = T extends Effect.Effect<unknown, infer E, unknown> ? E : never;
|
|
28
|
+
type EffectContext<T> = T extends Effect.Effect<unknown, unknown, infer R> ? R : never;
|
|
29
|
+
export declare const isAuthzError: (error: unknown) => error is AuthzError;
|
|
30
|
+
export declare const allow: Policy;
|
|
31
|
+
export declare const deny: (reason: AuthzDenyReason, policyId?: PolicyId) => Policy<never>;
|
|
32
|
+
export declare const all: <const Policies extends ReadonlyArray<Effect.Effect<unknown, unknown, unknown>>>(...policies: Policies) => Effect.Effect<void, EffectError<Policies[number]>, EffectContext<Policies[number]>>;
|
|
33
|
+
export declare const any: <const Policies extends ReadonlyArray<Effect.Effect<unknown, unknown, unknown>>>(...policies: Policies) => Effect.Effect<void, AuthzError | NonAuthzError<EffectError<Policies[number]>>, EffectContext<Policies[number]>>;
|
|
34
|
+
export declare const not: <A, E, R>(policy: Effect.Effect<A, E, R>, reason?: AuthzDenyReason) => Effect.Effect<void, AuthzError | NonAuthzError<E>, R>;
|
|
35
|
+
export declare const check: <A, E, R>(policy: Effect.Effect<A, E, R>) => Effect.Effect<PolicyDecision, NonAuthzError<E>, R>;
|
|
36
|
+
export declare const checkDetailed: <A, E, R>(policy: Effect.Effect<A, E, R>) => Effect.Effect<PolicyCheckResult<NonAuthzError<E>>, never, R>;
|
|
37
|
+
export declare const require: <A, E, R>(policy: Effect.Effect<A, E, R>) => <B, E2, R2>(effect: Effect.Effect<B, E2,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Error extends Data.TaggedError("AuthzError") {
|
|
3
|
+
}
|
|
4
|
+
export const isAuthzError = (error) => {
|
|
5
|
+
if (typeof error !== "object" || error === null) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
const record = error;
|
|
9
|
+
return record._tag === "AuthzError" && typeof record.reason === "string";
|
|
10
|
+
};
|
|
11
|
+
export const allow = Effect.void;
|
|
12
|
+
export const deny = (reason, policyId) => Effect.fail(new AuthzError({ reason, policyId }));
|
|
13
|
+
export const all = (...policies) => Effect.gen(function* () {
|
|
14
|
+
for (const policy of policies) {
|
|
15
|
+
yield* policy;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
export const any = (...policies) => {
|
|
19
|
+
const loop = (index, lastDeny) => {
|
|
20
|
+
const policy = policies[index];
|
|
21
|
+
if (policy === undefined) {
|
|
22
|
+
return Effect.fail(lastDeny ?? new AuthzError({ reason: "policy-not-satisfied" }));
|
|
23
|
+
}
|
|
24
|
+
return policy.pipe(Effect.matchEffect({
|
|
25
|
+
onSuccess: () => Effect.void,
|
|
26
|
+
onFailure: (error) => isAuthzError(error)
|
|
27
|
+
? loop(index + 1, error)
|
|
28
|
+
: Effect.fail(error)
|
|
29
|
+
}));
|
|
30
|
+
};
|
|
31
|
+
return loop(0, undefined);
|
|
32
|
+
};
|
|
33
|
+
export const not = (policy, reason = "policy-not-satisfied") => policy.pipe(Effect.matchEffect({
|
|
34
|
+
onSuccess: () => Effect.fail(new AuthzError({ reason })),
|
|
35
|
+
onFailure: (error) => (isAuthzError(error) ? Effect.void : Effect.fail(error))
|
|
36
|
+
}));
|
|
37
|
+
export const check = (policy) => policy.pipe(Effect.matchEffect({
|
|
38
|
+
onSuccess: () => Effect.succeed({ type: "allowed" }),
|
|
39
|
+
onFailure: (error) => isAuthzError(error)
|
|
40
|
+
? Effect.succeed({ type: "denied", error })
|
|
41
|
+
: Effect.fail(error)
|
|
42
|
+
}));
|
|
43
|
+
export const checkDetailed = (policy) => policy.pipe(Effect.match({
|
|
44
|
+
onSuccess: () => ({ type: "allowed" }),
|
|
45
|
+
onFailure: (error) => isAuthzError(error)
|
|
46
|
+
? ({ type: "denied", error })
|
|
47
|
+
: ({ type: "failed", error: error })
|
|
48
|
+
}));
|
|
49
|
+
export const require = (policy) => (effect) => Effect.flatMap(policy, () => effect);
|
|
50
|
+
//# sourceMappingURL=Policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Policy.js","sourceRoot":"","sources":["../src/Policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAcrC,MAAM,OAAO,UAAW,SAAQ,IAAI,CAAC,WAAW,CAAC,YAAY,CAK3D;CAAG;AAgBL,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAc,EAAuB,EAAE;IAClE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAA;IACd,CAAC;IAED,MAAM,MAAM,GAAG,KAAgC,CAAA;IAE/C,OAAO,MAAM,CAAC,IAAI,KAAK,YAAY,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAA;AAC1E,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,KAAK,GAAW,MAAM,CAAC,IAAI,CAAA;AAExC,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,MAAuB,EAAE,QAAmB,EAAiB,EAAE,CAClF,MAAM,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAA;AAEnD,MAAM,CAAC,MAAM,GAAG,GAAG,CACjB,GAAG,QAAkB,EACgE,EAAE,CACvF,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC9B,KAAK,CAAC,CAAC,MAAM,CAAA;IACf,CAAC;A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ress } from "./Identifiers.js";
|
|
4
|
+
export type PrivacyOperation = "email-hash" | "ip-hash" | "user-agent-hash";
|
|
5
|
+
declare const PrivacyError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
6
|
+
readonly _tag: "PrivacyError";
|
|
7
|
+
} & Readonly<A>;
|
|
8
|
+
export declare class PrivacyError extends PrivacyError_base<{
|
|
9
|
+
readonly operation: PrivacyOperation;
|
|
10
|
+
readonly message: string;
|
|
11
|
+
readonly cause?: unknown;
|
|
12
|
+
}> {
|
|
13
|
+
}
|
|
14
|
+
export interface PrivacyService {
|
|
15
|
+
readonly emailHash: (email: Email) => Effect.Effect<EmailHash, PrivacyError>;
|
|
16
|
+
readonly ipHash: (ip: IpAddress) => Effect.Effect<IpHash, PrivacyError>;
|
|
17
|
+
readonly userAgentHash: (userAgent: string) => Effect.Effect<UserAgentHash, PrivacyError>;
|
|
18
|
+
}
|
|
19
|
+
declare const Privacy_base: Context.ServiceClass<Privacy, "auth/Privacy", PrivacyService>;
|
|
20
|
+
export declare class Privacy extends Privacy_base {
|
|
21
|
+
}
|
|
22
|
+
export declare const PrivacyTestLive: Layer.Layer<Privacy, never, never>;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=Privacy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Privacy.d.ts","sourceRoot":"","sources":["../src/Privacy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAQ,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACnE,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAExD,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,SAAS,GAAG,iBAAiB,CAAA;;;;AAE3E,qBAAa,YAAa,SAAQ,kBAAiC;IACjE,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAA;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CACzB,CAAC;CAAG;AAEL,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,CAAA;IAC5E,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,SAAS,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IACvE,QAAQ,CAAC,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,YAAY,CAAC,CAAA;CAC1F;;AAED,qBAAa,OAAQ,SAAQ,YAA0D;CAAG;AAE1F,eAAO,MAAM,eAAe,oCAI1B,CAAA"}
|
package/dist/Privacy.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Context, Data, Effect, Layer } from "effect";
|
|
2
|
+
import { EmailHash, IpHash, UserAgentHash } from "./Identifiers.js";
|
|
3
|
+
export class PrivacyError extends Data.TaggedError("PrivacyError") {
|
|
4
|
+
}
|
|
5
|
+
export class Privacy extends Context.Service()("auth/Privacy") {
|
|
6
|
+
}
|
|
7
|
+
export const PrivacyTestLive = Layer.succeed(Privacy)({
|
|
8
|
+
emailHash: (email) => Effect.succeed(EmailHash(`test:email:${email}`)),
|
|
9
|
+
ipHash: (ip) => Effect.succeed(IpHash(`test:ip:${ip}`)),
|
|
10
|
+
userAgentHash: (userAgent) => Effect.succeed(UserAgentHash(`test:user-agent:${userAgent}`))
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=Privacy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Privacy.js","sourceRoot":"","sources":["../src/Privacy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAKnE,MAAM,OAAO,YAAa,SAAQ,IAAI,CAAC,WAAW,CAAC,cAAc,CAI/D;CAAG;AAQL,MAAM,OAAO,OAAQ,SAAQ,OAAO,CAAC,OAAO,EAA2B,CAAC,cAAc,CAAC;CAAG;AAE1F,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACpD,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,cAAc,KAAK,EAAE,CAAC,CAAC;IACtE,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACvD,aAAa,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,mBAAmB,SAAS,EAAE,CAAC,CAAC;CAC5F,CAAC,CAAA"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Context, Effect } from "effect";
|
|
2
|
+
import type * as Option from "effect/Option";
|
|
3
|
+
import type { SessionId, SessionToken, UnixMillis, UserId } from "./Identifiers.js";
|
|
4
|
+
export type AuthAssuranceLevel = "aal1" | "aal2" | "aal3";
|
|
5
|
+
export type AuthMethodReference = "pwd" | "otp" | "email" | "magic_link" | "passkey" | "oauth" | "totp" | "backup_code" | (string & {});
|
|
6
|
+
export interface SessionTtlPolicy {
|
|
7
|
+
readonly idleTtlMillis: number;
|
|
8
|
+
readonly absoluteTtlMillis: number;
|
|
9
|
+
readonly refreshAfterMillis: number;
|
|
10
|
+
}
|
|
11
|
+
export interface SessionCreateInput {
|
|
12
|
+
readonly userId: UserId;
|
|
13
|
+
readonly method: string;
|
|
14
|
+
readonly amr: ReadonlyArray<AuthMethodReference>;
|
|
15
|
+
readonly aal: AuthAssuranceLevel;
|
|
16
|
+
readonly now?: UnixMillis;
|
|
17
|
+
readonly ttl?: SessionTtlPolicy;
|
|
18
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
19
|
+
}
|
|
20
|
+
export interface IssuedSession {
|
|
21
|
+
readonly sessionId: SessionId;
|
|
22
|
+
readonly userId: UserId;
|
|
23
|
+
readonly token: SessionToken;
|
|
24
|
+
readonly authTime: UnixMillis;
|
|
25
|
+
readonly expiresAt: UnixMillis;
|
|
26
|
+
readonly aal: AuthAssuranceLevel;
|
|
27
|
+
readonly amr: ReadonlyArray<AuthMethodReference>;
|
|
28
|
+
}
|
|
29
|
+
export interface CurrentSessionShape {
|
|
30
|
+
readonly sessionId: SessionId;
|
|
31
|
+
readonly userId: UserId;
|
|
32
|
+
readonly authTime: UnixMillis;
|
|
33
|
+
readonly expiresAt: UnixMillis;
|
|
34
|
+
readonly aal: AuthAssuranceLevel;
|
|
35
|
+
readonly amr: ReadonlyArray<AuthMethodReference>;
|
|
36
|
+
}
|
|
37
|
+
export interface CurrentActorShape {
|
|
38
|
+
readonly userId: UserId;
|
|
39
|
+
readonly sessionId: SessionId;
|
|
40
|
+
}
|
|
41
|
+
export interface ValidatedSession {
|
|
42
|
+
readonly issued: IssuedSession;
|
|
43
|
+
readonly currentSession: CurrentSessionShape;
|
|
44
|
+
readonly actor: CurrentActorShape;
|
|
45
|
+
}
|
|
46
|
+
export interface SessionRotateInput {
|
|
47
|
+
readonly sessionId: SessionId;
|
|
48
|
+
readonly reason: string;
|
|
49
|
+
}
|
|
50
|
+
export interface SessionRevokeInput {
|
|
51
|
+
readonly sessionId: SessionId;
|
|
52
|
+
readonly reason: string;
|
|
53
|
+
}
|
|
54
|
+
declare const SessionCreateError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
55
|
+
readonly _tag: "SessionCreateError";
|
|
56
|
+
} & Readonly<A>;
|
|
57
|
+
export declare class SessionCreateError extends SessionCreateError_base<{
|
|
58
|
+
readonly message: string;
|
|
59
|
+
readonly cause?: unknown;
|
|
60
|
+
}> {
|
|
61
|
+
}
|
|
62
|
+
declare const SessionValidateError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
63
|
+
readonly _tag: "SessionValidateError";
|
|
64
|
+
} & Readonly<A>;
|
|
65
|
+
export declare class SessionValidateError extends SessionValidateError_base<{
|
|
66
|
+
readonly message: string;
|
|
67
|
+
readonly cause?: unknown;
|
|
68
|
+
}> {
|
|
69
|
+
}
|
|
70
|
+
declare const SessionRefreshError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
71
|
+
readonly _tag: "SessionRefreshError";
|
|
72
|
+
} & Readonly<A>;
|
|
73
|
+
export declare class SessionRefreshError extends SessionRefreshError_base<{
|
|
74
|
+
readonly message: string;
|
|
75
|
+
readonly cause?: unknown;
|
|
76
|
+
}> {
|
|
77
|
+
}
|
|
78
|
+
declare const SessionRotateError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
79
|
+
readonly _tag: "SessionRotateError";
|
|
80
|
+
} & Readonly<A>;
|
|
81
|
+
export declare class SessionRotateError extends SessionRotateError_base<{
|
|
82
|
+
readonly message: string;
|
|
83
|
+
readonly cause?: unknown;
|
|
84
|
+
}> {
|
|
85
|
+
}
|
|
86
|
+
declare const SessionRevokeError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
87
|
+
readonly _tag: "SessionRevokeError";
|
|
88
|
+
} & Readonly<A>;
|
|
89
|
+
export declare class SessionRevokeError extends SessionRevokeError_base<{
|
|
90
|
+
readonly message: string;
|
|
91
|
+
readonly cause?: unknown;
|
|
92
|
+
}> {
|
|
93
|
+
}
|
|
94
|
+
export type SessionError = SessionCreateError | SessionValidateError | SessionRefreshError | SessionRotateError | SessionRevokeError;
|
|
95
|
+
export interface SessionsService {
|
|
96
|
+
readonly create: (input: SessionCreateInput) => Effect.Effect<IssuedSession, SessionCreateError>;
|
|
97
|
+
readonly validate: (token: SessionToken) => Effect.Effect<ValidatedSession, SessionValidateError>;
|
|
98
|
+
readonly refresh: (token: SessionToken) => Effect.Effect<IssuedSession, SessionRefreshError>;
|
|
99
|
+
readonly rotate: (input: SessionRotateInput) => Effect.Effect<IssuedSession, SessionRotateError>;
|
|
100
|
+
readonly revoke: (input: SessionRevokeInput) => Effect.Effect<void, SessionRevokeError>;
|
|
101
|
+
readonly revokeAllForUser: (userId: UserId) => Effect.Effect<void, SessionRevokeError>;
|
|
102
|
+
}
|
|
103
|
+
declare const Sessions_base: Context.ServiceClass<Sessions, "auth/Sessions", SessionsService>;
|
|
104
|
+
export declare class Sessions extends Sessions_base {
|
|
105
|
+
}
|
|
106
|
+
export interface SessionCookieService {
|
|
107
|
+
readonly read: (request: Request) => Effect.Effect<Option.Option<SessionToken>, SessionValidateError>;
|
|
108
|
+
readonly commit: (issued: IssuedSession) => Effect.Effect<string, SessionCreateError>;
|
|
109
|
+
readonly clear: Effect.Effect<string, SessionRevokeError>;
|
|
110
|
+
}
|
|
111
|
+
declare const SessionCookie_base: Context.ServiceClass<SessionCookie, "auth/SessionCookie", SessionCookieService>;
|
|
112
|
+
export declare class SessionCookie extends SessionCookie_base {
|
|
113
|
+
}
|
|
114
|
+
declare const CurrentSession_base: Context.ServiceClass<CurrentSession, "auth/CurrentSession", CurrentSessionShape>;
|
|
115
|
+
export declare class CurrentSession extends CurrentSession_base {
|
|
116
|
+
}
|
|
117
|
+
declare const CurrentActor_base: Context.ServiceClass<CurrentActor, "auth/CurrentActor", CurrentActorShape>;
|
|
118
|
+
export declare class CurrentActor extends CurrentActor_base {
|
|
119
|
+
}
|
|
120
|
+
export {};
|
|
121
|
+
//# sourceMappingURL=Sessions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sessions.d.ts","sourceRoot":"","sources":["../src/Sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAQ,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC9C,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAE5C,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEnF,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;AAEzD,MAAM,MAAM,mBAAmB,GAC3B,KAAK,GACL,KAAK,GACL,OAAO,GACP,YAAY,GACZ,SAAS,GACT,OAAO,GACP,MAAM,GACN,aAAa,GACb,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEjB,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAA;IAClC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAA;CACpC;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,GAAG,EAAE,aAAa,CAAC,mBAAm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|
|
|
1
|
+
import { Context, Data, Effect } from "effect";
|
|
2
|
+
export class SessionCreateError extends Data.TaggedError("SessionCreateError") {
|
|
3
|
+
}
|
|
4
|
+
export class SessionValidateError extends Data.TaggedError("SessionValidateError") {
|
|
5
|
+
}
|
|
6
|
+
export class SessionRefreshError extends Data.TaggedError("SessionRefreshError") {
|
|
7
|
+
}
|
|
8
|
+
export class SessionRotateError extends Data.TaggedError("SessionRotateError") {
|
|
9
|
+
}
|
|
10
|
+
export class SessionRevokeError extends Data.TaggedError("SessionRevokeError") {
|
|
11
|
+
}
|
|
12
|
+
export class Sessions extends Context.Service()("auth/Sessions") {
|
|
13
|
+
}
|
|
14
|
+
export class SessionCookie extends Context.Service()("auth/SessionCookie") {
|
|
15
|
+
}
|
|
16
|
+
export class CurrentSession extends Context.Service()("auth/CurrentSession") {
|
|
17
|
+
}
|
|
18
|
+
export class CurrentActor extends Context.Service()("auth/CurrentActor") {
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=Sessions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Sessions.js","sourceRoot":"","sources":["../src/Sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AA0E9C,MAAM,OAAO,kBAAmB,SAAQ,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAG3E;CAAG;AAEL,MAAM,OAAO,oBAAqB,SAAQ,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAG/E;CAAG;AAEL,MAAM,OAAO,mBAAoB,SAAQ,IAAI,CAAC,WAAW,CAAC,qBAAqB,CAG7E;CAAG;AAEL,MAAM,OAAO,kBAAmB,SAAQ,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAG3E;CAAG;AAEL,MAAM,OAAO,kBAAmB,SAAQ,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAG3E;CAAG;AAkBL,MAAM,OAAO,QAAS,SAAQ,OAAO,CAAC,OAAO,EAA6B,CAAC,eAAe,CAAC;CAAG;AAQ9F,MAAM,OAAO,aAAc,SAAQ,OAAO,CAAC,OAAO,EAAuC,CAAC,oBAAoB,CAAC;CAAG;AAElH,MAAM,OAAO,cAAe,SAAQ,OAAO,CAAC,OAAO,EAAuC,CAAC,qBAAqB,CAAC;CAAG;AAEpH,MAAM,OAAO,YAAa,SAAQ,OAAO,CAAC,OAAO,EAAmC,CAAC,mBAAmB,CAAC;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Testing.d.ts","sourceRoot":"","sources":["../src/Testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAM9B,eAAO,MAAM,eAAe,mIAI3B,CAAA"}
|
package/dist/Testing.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Layer } from "effect";
|
|
2
|
+
import { AuditLogNoopLive } from "./AuditLog.js";
|
|
3
|
+
import { PrivacyTestLive } from "./Privacy.js";
|
|
4
|
+
import { WaitUntilNoopLive } from "./WaitUntil.js";
|
|
5
|
+
export const CoreTestingLive = Layer.mergeAll(AuditLogNoopLive, PrivacyTestLive, WaitUntilNoopLive);
|
|
6
|
+
//# sourceMappingURL=Testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Testing.js","sourceRoot":"","sources":["../src/Testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAE9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAElD,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC,QAAQ,CAC3C,gBAAgB,EAChB,eAAe,EACf,iBAAiB,CAClB,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Context, Effect, Layer } from "effect";
|
|
2
|
+
declare const WaitUntilError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
3
|
+
readonly _tag: "WaitUntilError";
|
|
4
|
+
} & Readonly<A>;
|
|
5
|
+
export declare class WaitUntilError extends WaitUntilError_base<{
|
|
6
|
+
readonly message: string;
|
|
7
|
+
readonly cause?: unknown;
|
|
8
|
+
}> {
|
|
9
|
+
}
|
|
10
|
+
export interface WaitUntilService {
|
|
11
|
+
readonly waitUntil: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<void, WaitUntilError, R>;
|
|
12
|
+
}
|
|
13
|
+
declare const WaitUntil_base: Context.ServiceClass<WaitUntil, "runtime/WaitUntil", WaitUntilService>;
|
|
14
|
+
export declare class WaitUntil extends WaitUntil_base {
|
|
15
|
+
}
|
|
16
|
+
export declare const WaitUntilNoopLive: Layer.Layer<WaitUntil, never, never>;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=WaitUntil.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WaitUntil.d.ts","sourceRoot":"","sources":["../src/WaitUntil.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAQ,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;;;;AAErD,qBAAa,cAAe,SAAQ,oBAAmC;IACrE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CACzB,CAAC;CAAG;AAEL,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,cAAc,EAAE,CAAC,CAAC,CAAA;CACxG;;AAED,qBAAa,SAAU,SAAQ,cAAmE;CAAG;AAErG,eAAO,MAAM,iBAAiB,sCAE5B,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Context, Data, Effect, Layer } from "effect";
|
|
2
|
+
export class WaitUntilError extends Data.TaggedError("WaitUntilError") {
|
|
3
|
+
}
|
|
4
|
+
export class WaitUntil extends Context.Service()("runtime/WaitUntil") {
|
|
5
|
+
}
|
|
6
|
+
export const WaitUntilNoopLive = Layer.succeed(WaitUntil)({
|
|
7
|
+
waitUntil: (_effect) => Effect.asVoid(Effect.context())
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=WaitUntil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WaitUntil.js","sourceRoot":"","sources":["../src/WaitUntil.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAA;AAErD,MAAM,OAAO,cAAe,SAAQ,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAGnE;CAAG;AAML,MAAM,OAAO,SAAU,SAAQ,OAAO,CAAC,OAAO,EAA+B,CAAC,mBAAmB,CAAC;CAAG;AAErG,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACxD,SAAS,EAAE,CAAU,OAA+B,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAK,CAAC;CAC5F,CAAC,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const packageName: "@effect-auth/core";
|
|
2
|
+
export * from "./AuditLog.js";
|
|
3
|
+
export * from "./AuthFlow.js";
|
|
4
|
+
export * from "./Challenge.js";
|
|
5
|
+
export * from "./Crypto.js";
|
|
6
|
+
export * from "./Identifiers.js";
|
|
7
|
+
export * from "./Policy.js";
|
|
8
|
+
export * from "./Privacy.js";
|
|
9
|
+
export * from "./Sessions.js";
|
|
10
|
+
export * from "./WaitUntil.js";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,EAAG,mBAA4B,CAAA;AAEvD,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const packageName = "@effect-auth/core";
|
|
2
|
+
export * from "./AuditLog.js";
|
|
3
|
+
export * from "./AuthFlow.js";
|
|
4
|
+
export * from "./Challenge.js";
|
|
5
|
+
export * from "./Crypto.js";
|
|
6
|
+
export * from "./Identifiers.js";
|
|
7
|
+
export * from "./Policy.js";
|
|
8
|
+
export * from "./Privacy.js";
|
|
9
|
+
export * from "./Sessions.js";
|
|
10
|
+
export * from "./WaitUntil.js";
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,mBAA4B,CAAA;AAEvD,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@effect-auth/core",
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
|
+
"description": "Composable Effect-first authentication primitives.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./AuditLog": {
|
|
17
|
+
"types": "./dist/AuditLog.d.ts",
|
|
18
|
+
"default": "./dist/AuditLog.js"
|
|
19
|
+
},
|
|
20
|
+
"./AuthFlow": {
|
|
21
|
+
"types": "./dist/AuthFlow.d.ts",
|
|
22
|
+
"default": "./dist/AuthFlow.js"
|
|
23
|
+
},
|
|
24
|
+
"./Challenge": {
|
|
25
|
+
"types": "./dist/Challenge.d.ts",
|
|
26
|
+
"default": "./dist/Challenge.js"
|
|
27
|
+
},
|
|
28
|
+
"./Crypto": {
|
|
29
|
+
"types": "./dist/Crypto.d.ts",
|
|
30
|
+
"default": "./dist/Crypto.js"
|
|
31
|
+
},
|
|
32
|
+
"./WaitUntil": {
|
|
33
|
+
"types": "./dist/WaitUntil.d.ts",
|
|
34
|
+
"default": "./dist/WaitUntil.js"
|
|
35
|
+
},
|
|
36
|
+
"./Identifiers": {
|
|
37
|
+
"types": "./dist/Identifiers.d.ts",
|
|
38
|
+
"default": "./dist/Identifiers.js"
|
|
39
|
+
},
|
|
40
|
+
"./Policy": {
|
|
41
|
+
"types": "./dist/Policy.d.ts",
|
|
42
|
+
"default": "./dist/Policy.js"
|
|
43
|
+
},
|
|
44
|
+
"./Privacy": {
|
|
45
|
+
"types": "./dist/Privacy.d.ts",
|
|
46
|
+
"default": "./dist/Privacy.js"
|
|
47
|
+
},
|
|
48
|
+
"./Sessions": {
|
|
49
|
+
"types": "./dist/Sessions.d.ts",
|
|
50
|
+
"default": "./dist/Sessions.js"
|
|
51
|
+
},
|
|
52
|
+
"./Testing": {
|
|
53
|
+
"types": "./dist/Testing.d.ts",
|
|
54
|
+
"default": "./dist/Testing.js"
|
|
55
|
+
},
|
|
56
|
+
"./package.json": {
|
|
57
|
+
"default": "./package.json"
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"files": [
|
|
61
|
+
"dist/**/*.d.ts",
|
|
62
|
+
"dist/**/*.d.ts.map",
|
|
63
|
+
"dist/**/*.js",
|
|
64
|
+
"dist/**/*.js.map"
|
|
65
|
+
],
|
|
66
|
+
"peerDependencies": {
|
|
67
|
+
"effect": "^4.0.0-beta.67"
|
|
68
|
+
},
|
|
69
|
+
"scripts": {
|
|
70
|
+
"build": "tsc -b",
|
|
71
|
+
"check": "tsc -b --pretty false && pnpm type-test",
|
|
72
|
+
"test": "pnpm build && node --test test/*.test.mjs",
|
|
73
|
+
"type-test": "tsc -p tsconfig.type-tests.json --pretty false"
|
|
74
|
+
}
|
|
75
|
+
}
|