-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Removed verifyJwt and register
- Loading branch information
Showing
8 changed files
with
89 additions
and
55 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
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
73 changes: 49 additions & 24 deletions
73
packages/oidf-client/__tests__/shared/oidfClientAgentLogic.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,38 @@ | ||
import {IAgentPlugin} from "@veramo/core"; | ||
import { | ||
IOIDFClient, | ||
OIDFClientArgs, | ||
ResolveTrustChainArgs, | ||
ResolveTrustChainCallbackResult, | ||
VerifyJwtArgs, | ||
VerifyJwtResult | ||
ResolveTrustChainCallbackResult | ||
} from "../types/IOIDFClient"; | ||
import { | ||
com | ||
} from "../../../../../OpenID-Federation/build/js/packages/openid-federation-modules-openid-federation-client"; | ||
import {schema} from "../index"; | ||
import FederationClient = com.sphereon.oid.fed.client.FederationClient; | ||
import CryptoServiceJS = com.sphereon.oid.fed.client.crypto.CryptoServiceJS; | ||
import CryptoService = com.sphereon.oid.fed.client.crypto.CryptoService; | ||
|
||
export const oidfClientMethods: Array<string> = [ | ||
'resolveTrustChain', | ||
'registerCryptoServiceCallback', | ||
'verifyJwt' | ||
'resolveTrustChain' | ||
] | ||
|
||
export class OIDFClient implements IAgentPlugin { | ||
readonly oidfClient: FederationClient | ||
readonly schema = schema.IContactManager | ||
readonly schema = schema.IOIDFClient | ||
|
||
constructor() { | ||
constructor(args?: OIDFClientArgs) { | ||
const { cryptoServiceCallback } = { ...args } | ||
console.log(cryptoServiceCallback) | ||
this.oidfClient = new FederationClient() | ||
CryptoService.register(cryptoServiceCallback) | ||
} | ||
|
||
readonly methods: IOIDFClient = { | ||
resolveTrustChain: this.resolveTrustChain.bind(this), | ||
verifyJwt: this.verifyJwt.bind(this) | ||
} | ||
|
||
private async resolveTrustChain(args: ResolveTrustChainArgs): Promise<ResolveTrustChainCallbackResult> { | ||
const { entityIdentifier, trustAnchors } = args | ||
return this.oidfClient.resolveTrustChain(entityIdentifier, trustAnchors) | ||
} | ||
|
||
private async verifyJwt(args: VerifyJwtArgs): Promise<VerifyJwtResult> { | ||
const { jwt } = args | ||
return await CryptoServiceJS.verify(jwt) | ||
return await this.oidfClient.resolveTrustChain(entityIdentifier, trustAnchors) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,22 +1,23 @@ | ||
import {IPluginMethodMap} from "@veramo/core"; | ||
import { | ||
com, | ||
Nullable | ||
} from "../../../../../OpenID-Federation/build/js/packages/openid-federation-modules-openid-federation-client"; | ||
import ICryptoServiceCallbackJS = com.sphereon.oid.fed.client.crypto.ICryptoServiceCallback; | ||
|
||
export interface IOIDFClient extends IPluginMethodMap { | ||
resolveTrustChain(args: ResolveTrustChainArgs): Promise<ResolveTrustChainCallbackResult> | ||
verifyJwt(args: VerifyJwtArgs): Promise<VerifyJwtResult> | ||
} | ||
|
||
export type ResolveTrustChainArgs = { | ||
entityIdentifier: string, | ||
trustAnchors: Array<string> | ||
} | ||
|
||
export type VerifyJwtArgs = { | ||
jwt: string | ||
export type OIDFClientArgs = { | ||
cryptoServiceCallback?: CryptoServiceCallbackArgs | ||
} | ||
|
||
export type ResolveTrustChainCallbackResult = Nullable<Array<string>> | ||
export type CryptoServiceCallbackArgs = ICryptoServiceCallbackJS | ||
|
||
export type VerifyJwtResult = boolean | ||
export type ResolveTrustChainCallbackResult = Nullable<Array<string>> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.