-
Notifications
You must be signed in to change notification settings - Fork 0
Add Directory support #6
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b9eafae
Build Directory.fromURLs
rvlb 2800664
Add flow to create an SHCReader with a directory
rvlb 82b354e
Rename IssuerInterface -> Issuer
rvlb 1a92c52
Add error handling flows at Directory.fromURLs
rvlb 33c75f0
Add Directory tests
rvlb ab5a73b
Improve tests
rvlb 1ad9463
Merge branch 'main' into directories-shc
rvlb 7fc30b7
Update minimal node version to 20
rvlb 8fdb5da
Implement Directory.fromJSON
rvlb 38f2c3f
Update typing validations
rvlb 484898c
Fix directory error handling
rvlb 32fa0f9
Add error message checks in directory tests
rvlb a79b775
Ensure 100% coverage at directory.ts
rvlb 50acb7a
Add docs
rvlb 5e7c85e
Update fromURLs to use fromJSON
rvlb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,7 +86,7 @@ | |
| "url": "https://github.com/vintasoftware/kill-the-clipboard/issues" | ||
| }, | ||
| "engines": { | ||
| "node": ">=18.0.0" | ||
| "node": ">=20.0.0" | ||
| }, | ||
| "packageManager": "[email protected]", | ||
| "dependencies": { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import type { DirectoryJSON, Issuer } from './types' | ||
|
|
||
| export class Directory { | ||
| constructor(private issuerInfo: Issuer[]) {} | ||
|
|
||
| getIssuerInfo(): Issuer[] { | ||
| return this.issuerInfo | ||
| } | ||
|
|
||
| static fromJSON(dirJson: DirectoryJSON): Directory { | ||
| const data: Issuer[] = dirJson.issuerInfo.map(({ issuer: { iss }, keys, crls }) => { | ||
| return { iss, keys, crls } as Issuer | ||
| }) | ||
| return new Directory(data) | ||
| } | ||
|
|
||
| static async fromURLs(issUrls: string[]): Promise<Directory> { | ||
rvlb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const issuersInfo: Issuer[] = [] | ||
|
|
||
| try { | ||
| for (const issUrl of issUrls) { | ||
| const issuer: Issuer = { | ||
| iss: issUrl, | ||
| keys: [], | ||
| crls: [], | ||
| } | ||
|
|
||
| const crls = [] | ||
| const jwksUrl = `${issUrl}/.well-known/jwks.json` | ||
| const jwksResponse = await fetch(jwksUrl) | ||
| if (!jwksResponse.ok) { | ||
| const errorData = await jwksResponse.json().catch(() => ({ error: 'Unknown error' })) | ||
rvlb marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| throw new Error(errorData.error || `Failed to fetch jwks at ${jwksUrl}`) | ||
| } | ||
|
|
||
| const { keys: issKeys } = await jwksResponse.json() | ||
| for (const key of issKeys) { | ||
| const crlUrl = `${issUrl}/.well-known/crl/${key.kid}.json` | ||
| const crlResponse = await fetch(crlUrl) | ||
| if (!crlResponse.ok) { | ||
| console.debug( | ||
| `Failed to fetch crl at ${crlUrl} with status ${crlResponse.status}, skipping.` | ||
| ) | ||
| continue | ||
| } | ||
| const crl = await crlResponse.json() | ||
| if (crl) crls.push(crl) | ||
sourcery-ai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| issuer.keys = issKeys | ||
| issuer.crls = crls | ||
| issuersInfo.push(issuer) | ||
| } | ||
| } catch (error) { | ||
| console.error('Error creating Directory:', error) | ||
| } | ||
|
|
||
| return new Directory(issuersInfo) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.