-
Notifications
You must be signed in to change notification settings - Fork 180
Auth Adapter + #958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auth Adapter + #958
Changes from 11 commits
2f07dc8
5bf7bab
5de2e93
73188a9
313a3f8
add04d4
5280eef
1c779c8
724123d
1b78059
3cccb4d
d168c5d
2b758cd
41791f3
5a124a0
3f0f6f7
402507a
cfa5f39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,7 +47,7 @@ const optionalDefaults: Partial<Adapters> = { | |
| }, | ||
| }; | ||
|
|
||
| const REQUIRED_ADAPTERS = ['scanner', 'network', 'crypto', 'documents'] as const; | ||
| const REQUIRED_ADAPTERS = ['auth', 'scanner', 'network', 'crypto', 'documents'] as const; | ||
aaronmgdr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Creates a fully configured {@link SelfClient} instance. | ||
|
|
@@ -128,10 +128,31 @@ export function createSelfClient({ config, adapters }: { config: Config; adapter | |
| return adapters.analytics.trackEvent(event, payload); | ||
| } | ||
|
|
||
| /** | ||
| * Retrieves the private key via the auth adapter. | ||
| * With great power comes great responsibility | ||
| */ | ||
| async function getPrivateKey(): Promise<string> { | ||
| if (!adapters.auth) throw notImplemented('auth'); | ||
|
||
| return adapters.auth.getPrivateKey(); | ||
| } | ||
aaronmgdr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| async function hasPrivateKey(): Promise<boolean> { | ||
| if (!adapters.auth) throw notImplemented('auth'); | ||
| try { | ||
| const key = await adapters.auth.getPrivateKey(); | ||
| return !!key; | ||
| } catch { | ||
| return false; | ||
| } | ||
| } | ||
aaronmgdr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return { | ||
| scanDocument, | ||
| validateDocument, | ||
| trackEvent, | ||
| getPrivateKey, | ||
| hasPrivateKey, | ||
| checkRegistration, | ||
| registerDocument, | ||
| generateProof, | ||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.