@passlock/client 0.9.22 → 0.9.24
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/README.md +10 -5
- package/README.template.md +130 -0
- package/dist/authentication/authenticate.d.ts +16 -16
- package/dist/authentication/authenticate.fixture.d.ts +21 -7
- package/dist/authentication/authenticate.fixture.js +7 -5
- package/dist/authentication/authenticate.fixture.js.map +1 -1
- package/dist/authentication/authenticate.js +19 -8
- package/dist/authentication/authenticate.js.map +1 -1
- package/dist/capabilities/capabilities.d.ts +9 -5
- package/dist/capabilities/capabilities.js +11 -2
- package/dist/capabilities/capabilities.js.map +1 -1
- package/dist/connection/connection.d.ts +11 -7
- package/dist/connection/connection.fixture.d.ts +2 -2
- package/dist/connection/connection.fixture.js +2 -1
- package/dist/connection/connection.fixture.js.map +1 -1
- package/dist/connection/connection.js +12 -3
- package/dist/connection/connection.js.map +1 -1
- package/dist/effect.d.ts +23 -46
- package/dist/effect.js +55 -51
- package/dist/effect.js.map +1 -1
- package/dist/email/email.d.ts +42 -12
- package/dist/email/email.fixture.d.ts +19 -5
- package/dist/email/email.fixture.js +5 -4
- package/dist/email/email.fixture.js.map +1 -1
- package/dist/email/email.js +44 -8
- package/dist/email/email.js.map +1 -1
- package/dist/event/event.d.ts +4 -2
- package/dist/event/event.js +4 -1
- package/dist/event/event.js.map +1 -1
- package/dist/index.d.ts +105 -27
- package/dist/index.js +101 -50
- package/dist/index.js.map +1 -1
- package/dist/logging/eventLogger.d.ts +13 -1
- package/dist/logging/eventLogger.js +14 -1
- package/dist/logging/eventLogger.js.map +1 -1
- package/dist/registration/register.d.ts +19 -22
- package/dist/registration/register.fixture.d.ts +20 -6
- package/dist/registration/register.fixture.js +14 -7
- package/dist/registration/register.fixture.js.map +1 -1
- package/dist/registration/register.js +18 -9
- package/dist/registration/register.js.map +1 -1
- package/dist/rpc/authentication.d.ts +1 -2
- package/dist/rpc/authentication.js +2 -1
- package/dist/rpc/authentication.js.map +1 -1
- package/dist/rpc/client.d.ts +5 -2
- package/dist/rpc/client.js +12 -3
- package/dist/rpc/client.js.map +1 -1
- package/dist/rpc/config.d.ts +0 -1
- package/dist/rpc/connection.d.ts +1 -2
- package/dist/rpc/connection.js +2 -1
- package/dist/rpc/connection.js.map +1 -1
- package/dist/rpc/registration.d.ts +1 -2
- package/dist/rpc/registration.js +2 -1
- package/dist/rpc/registration.js.map +1 -1
- package/dist/rpc/social.d.ts +1 -2
- package/dist/rpc/social.js +2 -1
- package/dist/rpc/social.js.map +1 -1
- package/dist/rpc/user.d.ts +1 -2
- package/dist/rpc/user.js +2 -1
- package/dist/rpc/user.js.map +1 -1
- package/dist/social/social.d.ts +17 -24
- package/dist/social/social.fixture.d.ts +22 -10
- package/dist/social/social.fixture.js +8 -14
- package/dist/social/social.fixture.js.map +1 -1
- package/dist/social/social.js +15 -11
- package/dist/social/social.js.map +1 -1
- package/dist/storage/storage.d.ts +41 -13
- package/dist/storage/storage.fixture.d.ts +2 -2
- package/dist/storage/storage.fixture.js +2 -2
- package/dist/storage/storage.fixture.js.map +1 -1
- package/dist/storage/storage.js +52 -15
- package/dist/storage/storage.js.map +1 -1
- package/dist/test/fixtures.d.ts +2 -3
- package/dist/test/fixtures.js +20 -5
- package/dist/test/fixtures.js.map +1 -1
- package/dist/user/user.d.ts +9 -6
- package/dist/user/user.fixture.d.ts +2 -2
- package/dist/user/user.fixture.js +9 -5
- package/dist/user/user.fixture.js.map +1 -1
- package/dist/user/user.js +12 -3
- package/dist/user/user.js.map +1 -1
- package/dist/version.d.ts +1 -2
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +38 -30
- package/src/authentication/authenticate.fixture.ts +10 -7
- package/src/authentication/authenticate.test.ts +61 -18
- package/src/authentication/authenticate.ts +37 -33
- package/src/capabilities/capabilities.ts +11 -9
- package/src/connection/connection.fixture.ts +4 -1
- package/src/connection/connection.test.ts +4 -3
- package/src/connection/connection.ts +10 -8
- package/src/effect.ts +129 -134
- package/src/email/email.fixture.ts +7 -4
- package/src/email/email.test.ts +6 -5
- package/src/email/email.ts +27 -17
- package/src/event/event.node.test.ts +1 -0
- package/src/event/event.test.ts +1 -0
- package/src/event/event.ts +2 -1
- package/src/index.ts +235 -173
- package/src/logging/eventLogger.test.ts +2 -1
- package/src/logging/eventLogger.ts +3 -3
- package/src/registration/register.fixture.ts +16 -8
- package/src/registration/register.test.ts +16 -10
- package/src/registration/register.ts +37 -35
- package/src/rpc/authentication.ts +43 -0
- package/src/rpc/client.ts +174 -0
- package/src/rpc/config.ts +18 -0
- package/src/rpc/connection.ts +30 -0
- package/src/rpc/registration.ts +41 -0
- package/src/rpc/social.ts +45 -0
- package/src/rpc/user.ts +57 -0
- package/src/social/social.fixture.ts +12 -18
- package/src/social/social.test.ts +16 -30
- package/src/social/social.ts +22 -47
- package/src/storage/storage.fixture.ts +4 -4
- package/src/storage/storage.test.ts +29 -19
- package/src/storage/storage.ts +37 -36
- package/src/test/fixtures.ts +23 -6
- package/src/user/user.fixture.ts +19 -7
- package/src/user/user.test.ts +3 -5
- package/src/user/user.ts +16 -10
- package/src/version.ts +1 -0
- package/dist/authentication/authenticate.d.ts.map +0 -1
- package/dist/authentication/authenticate.fixture.d.ts.map +0 -1
- package/dist/capabilities/capabilities.d.ts.map +0 -1
- package/dist/config.d.ts +0 -18
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -20
- package/dist/config.js.map +0 -1
- package/dist/connection/connection.d.ts.map +0 -1
- package/dist/connection/connection.fixture.d.ts.map +0 -1
- package/dist/effect.d.ts.map +0 -1
- package/dist/email/email.d.ts.map +0 -1
- package/dist/email/email.fixture.d.ts.map +0 -1
- package/dist/event/event.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/logging/eventLogger.d.ts.map +0 -1
- package/dist/registration/register.d.ts.map +0 -1
- package/dist/registration/register.fixture.d.ts.map +0 -1
- package/dist/rpc/authentication.d.ts.map +0 -1
- package/dist/rpc/client.d.ts.map +0 -1
- package/dist/rpc/config.d.ts.map +0 -1
- package/dist/rpc/connection.d.ts.map +0 -1
- package/dist/rpc/registration.d.ts.map +0 -1
- package/dist/rpc/social.d.ts.map +0 -1
- package/dist/rpc/user.d.ts.map +0 -1
- package/dist/social/social.d.ts.map +0 -1
- package/dist/social/social.fixture.d.ts.map +0 -1
- package/dist/storage/storage.d.ts.map +0 -1
- package/dist/storage/storage.fixture.d.ts.map +0 -1
- package/dist/test/fixtures.d.ts.map +0 -1
- package/dist/user/user.d.ts.map +0 -1
- package/dist/user/user.fixture.d.ts.map +0 -1
- package/dist/version.d.ts.map +0 -1
- package/src/config.ts +0 -42
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
The pnpm script build:readme replaces tokens
|
|
3
|
+
in README.template.md and outputs to README.md
|
|
4
|
+
-->
|
|
1
5
|
<div align="center">
|
|
2
|
-
<a href="https://github.com/passlock-dev/
|
|
6
|
+
<a href="https://github.com/passlock-dev/passlock">
|
|
3
7
|
<img src="https://github.com/passlock-dev/passkeys-frontend/assets/208345/53ee00d3-8e6c-49ea-b43c-3f901450c73b" alt="Passlock logo" width="80" height="80">
|
|
4
8
|
</a>
|
|
5
9
|
</div>
|
|
@@ -12,12 +16,13 @@
|
|
|
12
16
|
<img align="center" width=550 height=50 src="https://raw.githubusercontent.com/passlock-dev/ts-clients/master/README_assets/repo-banner.svg" />
|
|
13
17
|
</picture>
|
|
14
18
|
<p align="center">
|
|
15
|
-
Typescript library for next generation authentication.
|
|
19
|
+
Typescript library for next generation authentication. <br/>
|
|
20
|
+
Passkeys, Apple login, Google one-tap and more..
|
|
16
21
|
<br />
|
|
17
22
|
<a href="https://passlock.dev"><strong>Project website »</strong></a>
|
|
18
23
|
<br />
|
|
19
|
-
<a href="https://github.com/passlock-dev/
|
|
20
|
-
·
|
|
24
|
+
<a href="https://github.com/passlock-dev/passlock">GitHub</a>
|
|
25
|
+
·
|
|
21
26
|
<a href="https://d1rl0ue18b0151.cloudfront.net">Demo</a>
|
|
22
27
|
·
|
|
23
28
|
<a href="https://docs.passlock.dev">Documentation</a>
|
|
@@ -67,7 +72,7 @@ const clientId = '...'
|
|
|
67
72
|
|
|
68
73
|
const passlock = new Passlock({ tenancyId, clientId })
|
|
69
74
|
|
|
70
|
-
// to register a new passkey, call registerPasskey(). We're using placeholders for
|
|
75
|
+
// to register a new passkey, call registerPasskey(). We're using placeholders for
|
|
71
76
|
// the user data. You should grab this from an HTML form, React store, Redux etc.
|
|
72
77
|
const [email, givenName, familyName] = ["jdoe@gmail.com", "John", "Doe"]
|
|
73
78
|
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
The pnpm script build:readme replaces tokens
|
|
3
|
+
in README.template.md and outputs to README.md
|
|
4
|
+
-->
|
|
5
|
+
<div align="center">
|
|
6
|
+
<a href="#{GITHUB_REPO}#">
|
|
7
|
+
<img src="#{PASSLOCK_LOGO}#" alt="Passlock logo" width="80" height="80">
|
|
8
|
+
</a>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<h1 align="center">Passkeys, Social Login & More</h1>
|
|
12
|
+
|
|
13
|
+
<div align="center">
|
|
14
|
+
<picture align="center">
|
|
15
|
+
<source srcset="https://raw.githubusercontent.com/passlock-dev/ts-clients/master/README_assets/repo-banner.dark.svg" media="(prefers-color-scheme: dark)" />
|
|
16
|
+
<img align="center" width=550 height=50 src="https://raw.githubusercontent.com/passlock-dev/ts-clients/master/README_assets/repo-banner.svg" />
|
|
17
|
+
</picture>
|
|
18
|
+
<p align="center">
|
|
19
|
+
Typescript library for next generation authentication. <br/>
|
|
20
|
+
Passkeys, Apple login, Google one-tap and more..
|
|
21
|
+
<br />
|
|
22
|
+
<a href="#{PASSLOCK_SITE}#"><strong>Project website »</strong></a>
|
|
23
|
+
<br />
|
|
24
|
+
<a href="#{GITHUB_REPO}#">GitHub</a>
|
|
25
|
+
·
|
|
26
|
+
<a href="#{PRELINE_DEMO_SITE}#">Demo</a>
|
|
27
|
+
·
|
|
28
|
+
<a href="#{DOCS}#">Documentation</a>
|
|
29
|
+
·
|
|
30
|
+
<a href="#{TUTORIAL}#">Tutorial</a>
|
|
31
|
+
</p>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<br />
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
Passkeys and the WebAuthn API are quite complex. I've taken an opinionated approach to simplify things for you. Following the 80/20 principle, I've tried to focus on the features most valuable to developers and users.
|
|
39
|
+
|
|
40
|
+
1. **🔐 Primary or secondary authentication** - 2FA or a complete replacement for passwords
|
|
41
|
+
|
|
42
|
+
2. **🚀 Social login** - Supporting Apple & Google. GitHub coming soon..
|
|
43
|
+
|
|
44
|
+
3. **☝🏻 Biometrics** - Frictionless facial or fingerprint recognition for your webapps
|
|
45
|
+
|
|
46
|
+
4. **🖥️ Management console** - Suspend users, disable or revoke passkeys and more..
|
|
47
|
+
|
|
48
|
+
5. **🕵️ Audit trail** - View a full audit trail for each user
|
|
49
|
+
|
|
50
|
+
6. **🖥️ Dev console** - Something not working? check the web console for details
|
|
51
|
+
|
|
52
|
+
7. **👌 Headless components** - You have 100% control over the UI
|
|
53
|
+
|
|
54
|
+
## Screenshots
|
|
55
|
+
|
|
56
|
+

|
|
57
|
+
<p align="center">Demo app using this library for passkey and social login</p>
|
|
58
|
+
|
|
59
|
+

|
|
60
|
+
<p align="center">Viewing a user's authentication activity on their profile page</p>
|
|
61
|
+
|
|
62
|
+
## Usage
|
|
63
|
+
|
|
64
|
+
### Register a passkey
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
import { Passlock, PasslockError } from '@passlock/client'
|
|
68
|
+
|
|
69
|
+
// you can find these details in the settings area of your Passlock console
|
|
70
|
+
const tenancyId = '...'
|
|
71
|
+
const clientId = '...'
|
|
72
|
+
|
|
73
|
+
const passlock = new Passlock({ tenancyId, clientId })
|
|
74
|
+
|
|
75
|
+
// to register a new passkey, call registerPasskey(). We're using placeholders for
|
|
76
|
+
// the user data. You should grab this from an HTML form, React store, Redux etc.
|
|
77
|
+
const [email, givenName, familyName] = ["jdoe@gmail.com", "John", "Doe"]
|
|
78
|
+
|
|
79
|
+
// Passlock doesn't throw but instead returns a union: result | error
|
|
80
|
+
const result = await passlock.registerPasskey({ email, givenName, familyName })
|
|
81
|
+
|
|
82
|
+
// ensure we're error free
|
|
83
|
+
if (!PasslockError.isError(result)) {
|
|
84
|
+
// send the token to your backend (json/fetch or hidden form field etc)
|
|
85
|
+
console.log('Token: %s', result.token)
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Authenticate using a passkey
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
import { Passlock, PasslockError } from '@passlock/client'
|
|
93
|
+
|
|
94
|
+
const tenancyId = '...'
|
|
95
|
+
const clientId = '...'
|
|
96
|
+
|
|
97
|
+
const passlock = new Passlock({ tenancyId, clientId })
|
|
98
|
+
const result = await passlock.authenticatePasskey()
|
|
99
|
+
|
|
100
|
+
if (!PasslockError.isError(result)) {
|
|
101
|
+
// send the token to your backend for verification
|
|
102
|
+
console.log('Token: %s', result.token)
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Backend verification
|
|
107
|
+
|
|
108
|
+
Verify the token and obtain the passkey registration or authentication details. You can make a simple GET request to `https://api.passlock.dev/{tenancyId}/token/{token}` or use the [@passlock/node][node] library:
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
import { Passlock } from '@passlock/node'
|
|
112
|
+
|
|
113
|
+
// API Keys can be found in your passlock console
|
|
114
|
+
const passlock = new Passlock({ tenancyId, apiKey })
|
|
115
|
+
|
|
116
|
+
// token comes from your frontend
|
|
117
|
+
const principal = await passlock.fetchPrincipal({ token })
|
|
118
|
+
|
|
119
|
+
// get the user id
|
|
120
|
+
console.log(principal.user.id)
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## More information
|
|
124
|
+
|
|
125
|
+
Please see the [tutorial][tutorial] and [documentation][docs]
|
|
126
|
+
|
|
127
|
+
[contact]: https://passlock.dev/contact
|
|
128
|
+
[tutorial]: https://docs.passlock.dev/docs/tutorial/introduction
|
|
129
|
+
[docs]: https://docs.passlock.dev
|
|
130
|
+
[node]: https://www.npmjs.com/package/@passlock/node
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { InternalBrowserError, type NotSupported } from '@passlock/shared/dist/error/error.js';
|
|
2
|
-
import type { OptionsErrors, VerificationErrors } from '@passlock/shared/dist/rpc/authentication.js';
|
|
3
|
-
import { AuthenticationClient } from '@passlock/shared/dist/rpc/authentication.js';
|
|
4
|
-
import type { AuthenticationCredential, UserVerification } from '@passlock/shared/dist/schema/passkey.js';
|
|
5
|
-
import { Principal } from '@passlock/shared/dist/schema/principal.js';
|
|
6
1
|
import { Context, Effect as E, Layer } from 'effect';
|
|
2
|
+
import { InternalBrowserError, type NotSupported } from '@passlock/shared/dist/error/error.js';
|
|
3
|
+
import { type OptionsErrors, type OptionsReq, type VerificationErrors } from '@passlock/shared/dist/rpc/authentication.js';
|
|
4
|
+
import type { AuthenticationCredential } from '@passlock/shared/dist/schema/passkey.js';
|
|
5
|
+
import type { Principal } from '@passlock/shared/dist/schema/principal.js';
|
|
7
6
|
import { Capabilities } from '../capabilities/capabilities.js';
|
|
7
|
+
import { AuthenticationClient } from '../rpc/authentication.js';
|
|
8
8
|
import { StorageService } from '../storage/storage.js';
|
|
9
|
-
export type AuthenticationRequest =
|
|
10
|
-
email?: string;
|
|
11
|
-
userVerification?: UserVerification;
|
|
12
|
-
};
|
|
9
|
+
export type AuthenticationRequest = OptionsReq;
|
|
13
10
|
export type AuthenticationErrors = NotSupported | OptionsErrors | VerificationErrors;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
declare const GetCredential_base: Context.TagClass<GetCredential, "@services/GetCredential", {
|
|
12
|
+
getCredential: (request: CredentialRequestOptions) => E.Effect<AuthenticationCredential, InternalBrowserError>;
|
|
13
|
+
}>;
|
|
14
|
+
export declare class GetCredential extends GetCredential_base {
|
|
15
|
+
}
|
|
16
|
+
declare const AuthenticationService_base: Context.TagClass<AuthenticationService, "@services/AuthenticationService", {
|
|
17
17
|
authenticatePasskey: (request: AuthenticationRequest) => E.Effect<Principal, AuthenticationErrors>;
|
|
18
|
-
}
|
|
19
|
-
export declare
|
|
18
|
+
}>;
|
|
19
|
+
export declare class AuthenticationService extends AuthenticationService_base {
|
|
20
|
+
}
|
|
20
21
|
type Dependencies = GetCredential | Capabilities | StorageService | AuthenticationClient;
|
|
21
22
|
export declare const authenticatePasskey: (request: AuthenticationRequest) => E.Effect<Principal, AuthenticationErrors, Dependencies>;
|
|
22
|
-
export declare const AuthenticateServiceLive: Layer.Layer<AuthenticationService, never, Capabilities |
|
|
23
|
+
export declare const AuthenticateServiceLive: Layer.Layer<AuthenticationService, never, Capabilities | AuthenticationClient | StorageService | GetCredential>;
|
|
23
24
|
export {};
|
|
24
|
-
//# sourceMappingURL=authenticate.d.ts.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Layer as L } from 'effect';
|
|
2
|
+
import { OptionsRes, VerificationReq, VerificationRes } from '@passlock/shared/dist/rpc/authentication.js';
|
|
2
3
|
import { IsExistingUserRes, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js';
|
|
3
4
|
import type { AuthenticationCredential } from '@passlock/shared/dist/schema/passkey.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
5
|
+
import { AuthenticationClient } from '../rpc/authentication.js';
|
|
6
|
+
import { type AuthenticationRequest, GetCredential } from './authenticate.js';
|
|
6
7
|
export declare const session = "session";
|
|
7
8
|
export declare const token = "token";
|
|
8
9
|
export declare const code = "code";
|
|
@@ -18,21 +19,34 @@ export declare const rpcVerifyEmailRes: VerifyEmailRes;
|
|
|
18
19
|
export declare const getCredentialTest: L.Layer<GetCredential, never, never>;
|
|
19
20
|
export declare const rpcClientTest: L.Layer<AuthenticationClient, never, never>;
|
|
20
21
|
export declare const principal: {
|
|
22
|
+
readonly email?: string;
|
|
23
|
+
readonly givenName?: string;
|
|
24
|
+
readonly familyName?: string;
|
|
25
|
+
readonly emailVerified?: boolean;
|
|
26
|
+
readonly iss: string;
|
|
27
|
+
readonly aud: string;
|
|
28
|
+
readonly sub: string;
|
|
29
|
+
readonly iat: Date;
|
|
30
|
+
readonly nbf: Date;
|
|
31
|
+
readonly exp: Date;
|
|
32
|
+
readonly jti: string;
|
|
21
33
|
readonly token: string;
|
|
22
|
-
readonly
|
|
23
|
-
|
|
34
|
+
readonly userVerified: boolean;
|
|
35
|
+
readonly authType: "email" | "apple" | "google" | "passkey";
|
|
36
|
+
readonly authId: string;
|
|
37
|
+
readonly user?: {
|
|
24
38
|
readonly id: string;
|
|
39
|
+
readonly email: string;
|
|
25
40
|
readonly givenName: string;
|
|
26
41
|
readonly familyName: string;
|
|
27
42
|
readonly emailVerified: boolean;
|
|
28
43
|
};
|
|
29
44
|
readonly authStatement: {
|
|
30
|
-
readonly authType: "email" | "passkey" | "apple" | "google";
|
|
31
45
|
readonly userVerified: boolean;
|
|
46
|
+
readonly authType: "email" | "apple" | "google" | "passkey";
|
|
32
47
|
readonly authTimestamp: Date;
|
|
33
48
|
};
|
|
34
49
|
readonly expireAt: Date;
|
|
35
50
|
};
|
|
36
51
|
export declare const capabilitiesTest: L.Layer<import("../capabilities/capabilities.js").Capabilities, never, never>;
|
|
37
52
|
export declare const storageServiceTest: L.Layer<import("../storage/storage.js").StorageService, never, never>;
|
|
38
|
-
//# sourceMappingURL=authenticate.fixture.d.ts.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Effect as E, Layer as L, Option as O } from 'effect';
|
|
2
|
+
import { OptionsRes, VerificationReq, VerificationRes, } from '@passlock/shared/dist/rpc/authentication.js';
|
|
2
3
|
import { IsExistingUserRes, VerifyEmailRes } from '@passlock/shared/dist/rpc/user.js';
|
|
3
|
-
import { Effect as E, Layer as L } from 'effect';
|
|
4
4
|
import * as Fixtures from '../test/fixtures.js';
|
|
5
|
+
import { AuthenticationClient } from '../rpc/authentication.js';
|
|
5
6
|
import { GetCredential } from './authenticate.js';
|
|
6
7
|
export const session = 'session';
|
|
7
8
|
export const token = 'token';
|
|
@@ -9,7 +10,8 @@ export const code = 'code';
|
|
|
9
10
|
export const authType = 'passkey';
|
|
10
11
|
export const expireAt = Date.now() + 10000;
|
|
11
12
|
export const request = {
|
|
12
|
-
userVerification: 'preferred',
|
|
13
|
+
userVerification: O.some('preferred'),
|
|
14
|
+
email: O.none(),
|
|
13
15
|
};
|
|
14
16
|
export const rpcOptionsRes = new OptionsRes({
|
|
15
17
|
session,
|
|
@@ -35,9 +37,9 @@ export const credential = {
|
|
|
35
37
|
};
|
|
36
38
|
export const rpcVerificationReq = new VerificationReq({ session, credential });
|
|
37
39
|
export const rpcVerificationRes = new VerificationRes({ principal: Fixtures.principal });
|
|
38
|
-
export const rpcIsExistingUserRes = new IsExistingUserRes({ existingUser: true });
|
|
40
|
+
export const rpcIsExistingUserRes = new IsExistingUserRes({ existingUser: true, detail: O.none() });
|
|
39
41
|
export const rpcVerifyEmailRes = new VerifyEmailRes({ principal: Fixtures.principal });
|
|
40
|
-
export const getCredentialTest = L.succeed(GetCredential, GetCredential.of(() => E.succeed(credential)));
|
|
42
|
+
export const getCredentialTest = L.succeed(GetCredential, GetCredential.of({ getCredential: () => E.succeed(credential) }));
|
|
41
43
|
export const rpcClientTest = L.succeed(AuthenticationClient, AuthenticationClient.of({
|
|
42
44
|
getAuthenticationOptions: () => E.succeed(rpcOptionsRes),
|
|
43
45
|
verifyAuthenticationCredential: () => E.succeed(rpcVerificationRes),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticate.fixture.js","sourceRoot":"","sources":["../../src/authentication/authenticate.fixture.ts"],"names":[],"mappings":"AAAA,OA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Q,CAAC,gBAAgB,CAAA;AACzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC,kBAAkB,CAAA"}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Passkey authentication effects
|
|
3
|
+
*/
|
|
1
4
|
import { parseRequestOptionsFromJSON, } from '@github/webauthn-json/browser-ponyfill';
|
|
2
|
-
import { InternalBrowserError, } from '@passlock/shared/dist/error/error.js';
|
|
3
|
-
import { AuthenticationClient, OptionsReq, VerificationReq } from '@passlock/shared/dist/rpc/authentication.js';
|
|
4
|
-
import { Principal } from '@passlock/shared/dist/schema/principal.js';
|
|
5
5
|
import { Context, Effect as E, Layer, flow, pipe } from 'effect';
|
|
6
|
+
import { InternalBrowserError } from '@passlock/shared/dist/error/error.js';
|
|
7
|
+
import { VerificationReq, } from '@passlock/shared/dist/rpc/authentication.js';
|
|
6
8
|
import { Capabilities } from '../capabilities/capabilities.js';
|
|
9
|
+
import { AuthenticationClient } from '../rpc/authentication.js';
|
|
7
10
|
import { StorageService } from '../storage/storage.js';
|
|
8
|
-
|
|
9
|
-
export
|
|
11
|
+
/* Dependencies */
|
|
12
|
+
export class GetCredential extends Context.Tag('@services/GetCredential')() {
|
|
13
|
+
}
|
|
14
|
+
/* Service */
|
|
15
|
+
export class AuthenticationService extends Context.Tag('@services/AuthenticationService')() {
|
|
16
|
+
}
|
|
17
|
+
/* Utilities */
|
|
10
18
|
const fetchOptions = (request) => {
|
|
11
19
|
return E.gen(function* (_) {
|
|
12
20
|
yield* _(E.logDebug('Making request'));
|
|
@@ -37,10 +45,10 @@ export const authenticatePasskey = (request) => {
|
|
|
37
45
|
const capabilities = yield* _(Capabilities);
|
|
38
46
|
yield* _(capabilities.passkeySupport);
|
|
39
47
|
yield* _(E.logInfo('Fetching authentication options from Passlock'));
|
|
40
|
-
const { options, session } = yield* _(fetchOptions(
|
|
48
|
+
const { options, session } = yield* _(fetchOptions(request));
|
|
41
49
|
yield* _(E.logInfo('Looking up credential'));
|
|
42
|
-
const
|
|
43
|
-
const credential = yield* _(
|
|
50
|
+
const { getCredential } = yield* _(GetCredential);
|
|
51
|
+
const credential = yield* _(getCredential(options));
|
|
44
52
|
yield* _(E.logInfo('Verifying credential with Passlock'));
|
|
45
53
|
const principal = yield* _(verifyCredential(new VerificationReq({ credential, session })));
|
|
46
54
|
const storageService = yield* _(StorageService);
|
|
@@ -53,10 +61,13 @@ export const authenticatePasskey = (request) => {
|
|
|
53
61
|
});
|
|
54
62
|
return E.catchTag(effect, 'InternalBrowserError', e => E.die(e));
|
|
55
63
|
};
|
|
64
|
+
/* Live */
|
|
65
|
+
/* v8 ignore start */
|
|
56
66
|
export const AuthenticateServiceLive = Layer.effect(AuthenticationService, E.gen(function* (_) {
|
|
57
67
|
const context = yield* _(E.context());
|
|
58
68
|
return AuthenticationService.of({
|
|
59
69
|
authenticatePasskey: flow(authenticatePasskey, E.provide(context)),
|
|
60
70
|
});
|
|
61
71
|
}));
|
|
72
|
+
/* v8 ignore stop */
|
|
62
73
|
//# sourceMappingURL=authenticate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticate.js","sourceRoot":"","sources":["../../src/authentication/authenticate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"authenticate.js","sourceRoot":"","sources":["../../src/authentication/authenticate.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAEL,2BAA2B,GAC5B,MAAM,wCAAwC,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAEhE,OAAO,EAAE,oBAAoB,EAAqB,MAAM,sCAAsC,CAAA;AAC9F,OAAO,EAIL,eAAe,GAChB,MAAM,6CAA6C,CAAA;AAIpD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MA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,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;IAChB,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CACtB,CAAC,CAAC,OAAO,EAAwE,CAClF,CAAA;IAED,OAAO,qBAAqB,CAAC,EAAE,CAAC;QAC9B,mBAAmB,EAAE,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;KACnE,CAAC,CAAA;AACJ,CAAC,CAAC,CACH,CAAA;AACD,oBAAoB"}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Test if the browser supports passkeys, conditional UI etc
|
|
3
|
+
*/
|
|
2
4
|
import { Context, Effect as E, Layer } from 'effect';
|
|
3
|
-
|
|
5
|
+
import { NotSupported } from '@passlock/shared/dist/error/error.js';
|
|
6
|
+
declare const Capabilities_base: Context.TagClass<Capabilities, "@services/Capabilities", {
|
|
4
7
|
passkeySupport: E.Effect<void, NotSupported>;
|
|
5
8
|
isPasskeySupport: E.Effect<boolean>;
|
|
6
9
|
autofillSupport: E.Effect<void, NotSupported>;
|
|
7
10
|
isAutofillSupport: E.Effect<boolean>;
|
|
8
|
-
}
|
|
9
|
-
export declare
|
|
11
|
+
}>;
|
|
12
|
+
export declare class Capabilities extends Capabilities_base {
|
|
13
|
+
}
|
|
10
14
|
export declare const passkeySupport: E.Effect<void, NotSupported, never>;
|
|
11
15
|
export declare const isPasskeySupport: E.Effect<boolean, never, never>;
|
|
12
16
|
export declare const autofillSupport: E.Effect<void, NotSupported, never>;
|
|
13
17
|
export declare const isAutofillSupport: E.Effect<boolean, never, never>;
|
|
14
18
|
export declare const capabilitiesLive: Layer.Layer<Capabilities, never, never>;
|
|
15
|
-
|
|
19
|
+
export {};
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Test if the browser supports passkeys, conditional UI etc
|
|
3
|
+
*/
|
|
2
4
|
import { Context, Effect as E, Layer, identity, pipe } from 'effect';
|
|
3
|
-
|
|
5
|
+
import { NotSupported } from '@passlock/shared/dist/error/error.js';
|
|
6
|
+
/* Service */
|
|
7
|
+
export class Capabilities extends Context.Tag('@services/Capabilities')() {
|
|
8
|
+
}
|
|
9
|
+
/* Effects */
|
|
4
10
|
const hasWebAuthn = E.suspend(() => typeof window.PublicKeyCredential === 'function'
|
|
5
11
|
? E.void
|
|
6
12
|
: new NotSupported({ message: 'WebAuthn API is not supported on this device' }));
|
|
@@ -19,10 +25,13 @@ export const isAutofillSupport = pipe(autofillSupport, E.match({
|
|
|
19
25
|
onFailure: () => false,
|
|
20
26
|
onSuccess: () => true,
|
|
21
27
|
}));
|
|
28
|
+
/* Live */
|
|
29
|
+
/* v8 ignore start */
|
|
22
30
|
export const capabilitiesLive = Layer.succeed(Capabilities, {
|
|
23
31
|
passkeySupport,
|
|
24
32
|
isPasskeySupport,
|
|
25
33
|
autofillSupport,
|
|
26
34
|
isAutofillSupport,
|
|
27
35
|
});
|
|
36
|
+
/* v8 ignore stop */
|
|
28
37
|
//# sourceMappingURL=capabilities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../../src/capabilities/capabilities.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../../src/capabilities/capabilities.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAEpE,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAA;AAEnE,aAAa;AAEb,MAAM,OAAO,YAAa,SAAQ,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,EAQpE;CAAG;AAEN,aAAa;AAEb,MAAM,WAAW,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CACjC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CACtB,CAAC,CACH,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAA;AAEhF,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CACnC,eAAe,EACf,CAAC,CAAC,KAAK,CAAC;IACN,SAAS,EAAE,GAAG,EAAE,CAAC,KAAK;IACtB,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI;CACtB,CAAC,CACH,CAAA;AAED,UAAU;AAEV,qBAAqB;AACrB,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE;IAC1D,cAAc;IACd,gBAAgB;IAChB,eAAe;IACf,iBAAiB;CAClB,CAAC,CAAA;AACF,oBAAoB"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Hits the rpc endpoint to warm up a lambda
|
|
3
|
+
*/
|
|
4
4
|
import { Context, Effect as E, Layer } from 'effect';
|
|
5
|
-
|
|
5
|
+
import { Dispatcher } from '../rpc/client.js';
|
|
6
|
+
import type { RpcConfig } from '../rpc/config.js';
|
|
7
|
+
import { ConnectionClient } from '../rpc/connection.js';
|
|
8
|
+
declare const ConnectionService_base: Context.TagClass<ConnectionService, "@services/ConnectionService", {
|
|
6
9
|
preConnect: () => E.Effect<void>;
|
|
7
|
-
}
|
|
8
|
-
export declare
|
|
10
|
+
}>;
|
|
11
|
+
export declare class ConnectionService extends ConnectionService_base {
|
|
12
|
+
}
|
|
9
13
|
export declare const preConnect: () => E.Effect<void, never, Dispatcher | ConnectionClient>;
|
|
10
14
|
export declare const ConnectionServiceLive: Layer.Layer<ConnectionService, never, RpcConfig | Dispatcher | ConnectionClient>;
|
|
11
|
-
|
|
15
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ConnectionClient, ConnectRes } from '@passlock/shared/dist/rpc/connection.js';
|
|
2
1
|
import { Layer as L } from 'effect';
|
|
2
|
+
import { ConnectRes } from '@passlock/shared/dist/rpc/connection.js';
|
|
3
|
+
import { ConnectionClient } from '../rpc/connection.js';
|
|
3
4
|
export declare const preConnectRes: ConnectRes;
|
|
4
5
|
export declare const rpcClientTest: L.Layer<ConnectionClient, never, never>;
|
|
5
6
|
export declare const rpcConfig: {
|
|
@@ -7,4 +8,3 @@ export declare const rpcConfig: {
|
|
|
7
8
|
tenancyId: string;
|
|
8
9
|
clientId: string;
|
|
9
10
|
};
|
|
10
|
-
//# sourceMappingURL=connection.fixture.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ConnectionClient, ConnectRes } from '@passlock/shared/dist/rpc/connection.js';
|
|
2
1
|
import { Effect as E, Layer as L } from 'effect';
|
|
2
|
+
import { ConnectRes } from '@passlock/shared/dist/rpc/connection.js';
|
|
3
|
+
import { ConnectionClient } from '../rpc/connection.js';
|
|
3
4
|
export const preConnectRes = new ConnectRes({ warmed: true });
|
|
4
5
|
export const rpcClientTest = L.succeed(ConnectionClient, ConnectionClient.of({
|
|
5
6
|
preConnect: () => E.succeed(preConnectRes),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.fixture.js","sourceRoot":"","sources":["../../src/connection/connection.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"connection.fixture.js","sourceRoot":"","sources":["../../src/connection/connection.fixture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,MAAM,QAAQ,CAAA;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAA;AAEpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAEvD,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,UAAU,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;AAE7D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,OAAO,CACpC,gBAAgB,EAChB,gBAAgB,CAAC,EAAE,CAAC;IAClB,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC;CAC3C,CAAC,CACH,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,QAAQ,EAAE,qBAAqB;IAC/B,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,UAAU;CACrB,CAAA"}
|
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Hits the rpc endpoint to warm up a lambda
|
|
3
|
+
*/
|
|
3
4
|
import { Context, Effect as E, Layer, flow, pipe } from 'effect';
|
|
4
|
-
|
|
5
|
+
import { Dispatcher } from '../rpc/client.js';
|
|
6
|
+
import { ConnectionClient } from '../rpc/connection.js';
|
|
7
|
+
/* Service */
|
|
8
|
+
export class ConnectionService extends Context.Tag('@services/ConnectionService')() {
|
|
9
|
+
}
|
|
10
|
+
/* Effects */
|
|
5
11
|
const hitPrincipal = pipe(E.logInfo('Pre-connecting to Principal endpoint'), E.zipRight(Dispatcher), E.flatMap(dispatcher => dispatcher.get('/token/token?warm=true')), E.asVoid, E.catchAll(() => E.void));
|
|
6
12
|
const hitRpc = pipe(E.logInfo('Pre-connecting to RPC endpoint'), E.zipRight(ConnectionClient), E.flatMap(rpcClient => rpcClient.preConnect()), E.asVoid);
|
|
7
13
|
export const preConnect = () => pipe(E.all([hitPrincipal, hitRpc], { concurrency: 2 }), E.asVoid);
|
|
14
|
+
/* Live */
|
|
15
|
+
/* v8 ignore start */
|
|
8
16
|
export const ConnectionServiceLive = Layer.effect(ConnectionService, E.gen(function* (_) {
|
|
9
17
|
const context = yield* _(E.context());
|
|
10
18
|
return ConnectionService.of({
|
|
11
19
|
preConnect: flow(preConnect, E.provide(context)),
|
|
12
20
|
});
|
|
13
21
|
}));
|
|
22
|
+
/* v8 ignore stop */
|
|
14
23
|
//# sourceMappingURL=connection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/connection/connection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/connection/connection.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAEvD,aAAa;AAEb,MAAM,OAAO,iBAAkB,SAAQ,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,EAK9E;CAAG;AAEN,aAAa;AAEb,MAAM,YAAY,GAAG,IAAI,CACvB,CAAC,CAAC,OAAO,CAAC,sCAAsC,CAAC,EACjD,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,EACtB,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC,EACjE,CAAC,CAAC,MAAM,EACR,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CACzB,CAAA;AAED,MAAM,MAAM,GAAG,IAAI,CACjB,CAAC,CAAC,OAAO,CAAC,gCAAgC,CAAC,EAC3C,CAAC,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAC5B,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC,EAC9C,CAAC,CAAC,MAAM,CACT,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,MAAM,CAAC,EAAE,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAA;AAEjG,UAAU;AAEV,qBAAqB;AACrB,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC,MAAM,CAC/C,iBAAiB,EACjB,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;IAChB,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,EAA6C,CAAC,CAAA;IAEhF,OAAO,iBAAiB,CAAC,EAAE,CAAC;QAC1B,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;KACjD,CAAC,CAAA;AACJ,CAAC,CAAC,CACH,CAAA;AACD,oBAAoB"}
|
package/dist/effect.d.ts
CHANGED
|
@@ -1,49 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { Principal } from '@passlock/shared/dist/schema/principal.js';
|
|
3
|
-
import { Context, Effect as E, Layer as L } from 'effect';
|
|
1
|
+
import { Effect as E, Layer as L } from 'effect';
|
|
4
2
|
import type { NoSuchElementException } from 'effect/Cause';
|
|
5
|
-
import {
|
|
3
|
+
import { type BadRequest } from '@passlock/shared/dist/error/error.js';
|
|
4
|
+
import type { Principal } from '@passlock/shared/dist/schema/principal.js';
|
|
5
|
+
import { type AuthenticationErrors, type AuthenticationRequest, AuthenticationService } from './authentication/authenticate.js';
|
|
6
|
+
import { Capabilities } from './capabilities/capabilities.js';
|
|
6
7
|
import { ConnectionService } from './connection/connection.js';
|
|
7
|
-
import { EmailService, type VerifyRequest } from './email/email.js';
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
export declare const allRequirements: L.Layer<
|
|
14
|
-
declare const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
export declare
|
|
20
|
-
|
|
21
|
-
export declare const
|
|
22
|
-
export declare const isRegistered: (email: Email) => E.Effect<boolean, BadRequest, Config>;
|
|
23
|
-
export type RegistrationErrors = NotSupported | BadRequest | Duplicate | Unauthorized | Forbidden;
|
|
24
|
-
export declare const registerPasskey: (request: RegistrationRequest) => E.Effect<Principal, RegistrationErrors, Config>;
|
|
25
|
-
export type AuthenticationErrors = NotSupported | BadRequest | NotFound | Disabled | Unauthorized | Forbidden;
|
|
26
|
-
export declare const authenticatePasskey: (request: AuthenticationRequest) => E.Effect<Principal, AuthenticationErrors, Config>;
|
|
27
|
-
export type VerifyEmailErrors = NotSupported | BadRequest | NotFound | Disabled | Unauthorized | Forbidden;
|
|
28
|
-
export declare const verifyEmailCode: (request: VerifyRequest) => E.Effect<Principal, VerifyEmailErrors, Config>;
|
|
29
|
-
export declare const verifyEmailLink: () => E.Effect<Principal, VerifyEmailErrors, Config>;
|
|
8
|
+
import { EmailService, type VerifyEmailErrors, type VerifyRequest } from './email/email.js';
|
|
9
|
+
import { type RegistrationErrors, type RegistrationRequest, RegistrationService } from './registration/register.js';
|
|
10
|
+
import type { RpcConfig } from './rpc/config.js';
|
|
11
|
+
import { type AuthenticateOidcReq, type AuthenticationErrors as OidcAuthenticationErrors, type RegistrationErrors as OidcRegistrationErrors, type RegisterOidcReq, SocialService } from './social/social.js';
|
|
12
|
+
import { type AuthType, BrowserStorage, StorageService, type StoredToken } from './storage/storage.js';
|
|
13
|
+
import { type Email, type ResendEmail, type ResendEmailErrors, UserService } from './user/user.js';
|
|
14
|
+
export declare const allRequirements: L.Layer<Capabilities | StorageService | AuthenticationService | ConnectionService | EmailService | UserService | RegistrationService | SocialService, never, RpcConfig | BrowserStorage>;
|
|
15
|
+
export declare const preConnect: () => E.Effect<void, never, RpcConfig>;
|
|
16
|
+
export declare const isPasskeySupport: E.Effect<boolean>;
|
|
17
|
+
export declare const isExistingUser: (request: Email) => E.Effect<boolean, BadRequest, RpcConfig>;
|
|
18
|
+
export declare const registerPasskey: (request: RegistrationRequest) => E.Effect<Principal, RegistrationErrors, RpcConfig>;
|
|
19
|
+
export declare const authenticatePasskey: (request: AuthenticationRequest) => E.Effect<Principal, AuthenticationErrors, RpcConfig>;
|
|
20
|
+
export declare const verifyEmailCode: (request: VerifyRequest) => E.Effect<Principal, VerifyEmailErrors, RpcConfig>;
|
|
21
|
+
export declare const verifyEmailLink: E.Effect<Principal, VerifyEmailErrors, RpcConfig>;
|
|
22
|
+
export declare const resendVerificationEmail: (request: ResendEmail) => E.Effect<void, ResendEmailErrors, RpcConfig>;
|
|
30
23
|
export declare const getSessionToken: (authType: AuthType) => E.Effect<StoredToken, NoSuchElementException>;
|
|
31
|
-
export declare const clearExpiredTokens:
|
|
32
|
-
export declare const
|
|
33
|
-
|
|
34
|
-
readonly user: {
|
|
35
|
-
readonly email: string;
|
|
36
|
-
readonly id: string;
|
|
37
|
-
readonly givenName: string;
|
|
38
|
-
readonly familyName: string;
|
|
39
|
-
readonly emailVerified: boolean;
|
|
40
|
-
};
|
|
41
|
-
readonly authStatement: {
|
|
42
|
-
readonly authType: "email" | "passkey" | "apple" | "google";
|
|
43
|
-
readonly userVerified: boolean;
|
|
44
|
-
readonly authTimestamp: Date;
|
|
45
|
-
};
|
|
46
|
-
readonly expireAt: Date;
|
|
47
|
-
}, import("./social/social.js").RegistrationErrors, RpcConfig>;
|
|
48
|
-
export {};
|
|
49
|
-
//# sourceMappingURL=effect.d.ts.map
|
|
24
|
+
export declare const clearExpiredTokens: E.Effect<void>;
|
|
25
|
+
export declare const registerOidc: (request: RegisterOidcReq) => E.Effect<Principal, OidcRegistrationErrors, RpcConfig>;
|
|
26
|
+
export declare const authenticateOidc: (request: AuthenticateOidcReq) => E.Effect<Principal, OidcAuthenticationErrors, RpcConfig>;
|