-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for signing keys APIs (#67)
- Loading branch information
1 parent
e5bc786
commit ab98bd7
Showing
10 changed files
with
709 additions
and
527 deletions.
There are no files selected for viewing
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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 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 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 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,36 @@ | ||
import {control} from '@gomomento/generated-types'; | ||
|
||
export class CreateSigningKeyResponse { | ||
private readonly keyId: string; | ||
private readonly endpoint: string; | ||
private readonly key: string; | ||
private readonly expiresAt: Date; | ||
|
||
constructor( | ||
endpoint: string, | ||
result?: control.control_client._CreateSigningKeyResponse | ||
) { | ||
const key = result?.key ?? ''; | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access | ||
this.keyId = JSON.parse(key)['kid']; | ||
this.endpoint = endpoint; | ||
this.key = key; | ||
this.expiresAt = new Date(result?.expires_at ?? 0 * 1000); | ||
} | ||
|
||
public getKeyId(): string { | ||
return this.keyId; | ||
} | ||
|
||
public getEndpoint(): string { | ||
return this.endpoint; | ||
} | ||
|
||
public getKey(): string { | ||
return this.key; | ||
} | ||
|
||
public getExpiresAt(): Date { | ||
return this.expiresAt; | ||
} | ||
} |
This file contains 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,31 @@ | ||
import {control} from '@gomomento/generated-types'; | ||
import {SigningKey} from './SigningKey'; | ||
|
||
export class ListSigningKeysResponse { | ||
private readonly nextToken: string | null; | ||
private readonly signingKeys: SigningKey[]; | ||
|
||
constructor( | ||
endpoint: string, | ||
result?: control.control_client._ListSigningKeysResponse | ||
) { | ||
this.nextToken = result?.next_token || null; | ||
this.signingKeys = | ||
result?.signing_key.map( | ||
signingKey => | ||
new SigningKey( | ||
signingKey.key_id, | ||
new Date(signingKey.expires_at * 1000), | ||
endpoint | ||
) | ||
) ?? []; | ||
} | ||
|
||
public getNextToken() { | ||
return this.nextToken; | ||
} | ||
|
||
public getSigningKeys() { | ||
return this.signingKeys; | ||
} | ||
} |
This file contains 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 @@ | ||
export class RevokeSigningKeyResponse {} |
This file contains 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,23 @@ | ||
export class SigningKey { | ||
private readonly keyId: string; | ||
private readonly expiresAt: Date; | ||
private readonly endpoint: string; | ||
|
||
constructor(keyId: string, expiresAt: Date, endpoint: string) { | ||
this.keyId = keyId; | ||
this.expiresAt = expiresAt; | ||
this.endpoint = endpoint; | ||
} | ||
|
||
public getKeyId() { | ||
return this.keyId; | ||
} | ||
|
||
public getExpiresAt() { | ||
return this.expiresAt; | ||
} | ||
|
||
public getEndpoint() { | ||
return this.endpoint; | ||
} | ||
} |