Skip to content

Commit

Permalink
fix: unify naming
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Apr 15, 2023
1 parent 975801e commit 94165cd
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 17 deletions.
1 change: 1 addition & 0 deletions packages/siopv2-oid4vp-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"access": "public"
},
"dependencies": {
"uint8arrays": "3.1.1",
"@sphereon/did-auth-siop": "^0.3.0-unstable.33"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions packages/siopv2-oid4vp-rp-rest-api/src/SIOPv2RPRestAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class SIOPv2RPRestAPI {
// Webapp endpoints
this.createAuthRequestWebappEndpoint()
this.authStatusWebappEndpoint()
this.deleteAuthRequestStateWebappEndpoint()
this.removeAuthRequestStateWebappEndpoint()

// SIOPv2 endpoints
this.getAuthRequestSIOPv2Endpoint()
Expand Down Expand Up @@ -93,7 +93,7 @@ export class SIOPv2RPRestAPI {
response.status(statusCode).send(message)
}

private deleteAuthRequestStateWebappEndpoint() {
private removeAuthRequestStateWebappEndpoint() {
this.express.delete(
this._opts?.webappDeleteAuthRequestPath ?? '/webapp/definitions/:definitionId/auth-requests/:correlationId',
async (request, response) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const agent = createAgent<IResolver & ISIOPv2OID4VPRPRestClient>({
describe('@sphereon/siopv2-oid4vp-rp-rest-client', () => {
// disabled because the delete call hangs. Since endpoints will be updated anyway, skiping this for now
xit('should call the endpoint for siopClientRemoveAuthRequestSession', async () => {
const authRequest: GenerateAuthRequestURIResponse = await agent.siopClientGenerateAuthRequest({})
agent.siopClientRemoveAuthRequestSession({
const authRequest: GenerateAuthRequestURIResponse = await agent.siopClientCreateAuthRequest({})
agent.siopClientRemoveAuthRequestState({
correlationId: authRequest.correlationId,
})

Expand All @@ -25,12 +25,12 @@ describe('@sphereon/siopv2-oid4vp-rp-rest-client', () => {
})

it('should call the endpoint for siopClientGenerateAuthRequest', async () => {
const result = await agent.siopClientGenerateAuthRequest({})
const result = await agent.siopClientCreateAuthRequest({})
expect(result.definitionId).toEqual(definitionId)
})

it('should call the endpoint for siopClientGetAuthStatus', async () => {
const authRequest = await agent.siopClientGenerateAuthRequest({})
const authRequest = await agent.siopClientCreateAuthRequest({})
const result = await agent.siopClientGetAuthStatus({
correlationId: authRequest.correlationId,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ describe('@sphereon/siopv2-oid4vp-rp-rest-client', () => {
const correlationId = 'test-correlation-id'
nock(`${baseUrl}/webapp/definitions/${definitionId}/auth-requests`).delete(`/${correlationId}`).times(5).reply(200, {})
await expect(
agent.siopClientRemoveAuthRequestSession({
agent.siopClientRemoveAuthRequestState({
correlationId: 'test-correlation-id',
})
).resolves.toBeUndefined()
})

it('should call the mock endpoint for siopClientGenerateAuthRequest', async () => {
nock(`${baseUrl}/webapp/definitions/${definitionId}`).get(`/auth-request-uri`).times(5).reply(200, {})
await expect(agent.siopClientGenerateAuthRequest({})).resolves.toBeDefined()
await expect(agent.siopClientCreateAuthRequest({})).resolves.toBeDefined()
})

it('should call the mock endpoint for siopClientGetAuthStatus', async () => {
Expand Down
3 changes: 3 additions & 0 deletions packages/siopv2-oid4vp-rp-rest-client/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "../include/api-extractor-base.json"
}
10 changes: 9 additions & 1 deletion packages/siopv2-oid4vp-rp-rest-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,26 @@
"name": "@sphereon/ssi-sdk-siopv2-oid4vp-rp-rest-client",
"description": "contains the client side to call REST endpoints of relying party",
"version": "0.9.0",
"source": "src/index.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"veramo": {
"pluginInterfaces": {
"ISIOPv2OID4VPRPRestClient": "./src/types/ISIOPv2OID4VPRPRestClient.ts"
}
},
"scripts": {
"build": "tsc --build",
"build:clean": "tsc --build --clean && tsc --build"
"build:clean": "tsc --build --clean && tsc --build",
"generate-plugin-schema": "node --loader ts-node/esm ../../node_modules/@veramo/cli/bin/veramo.js dev generate-plugin-schema"
},
"dependencies": {
"@sphereon/ssi-sdk-siopv2-oid4vp-common": "^0.9.0",
"@veramo/core": "4.2.0",
"cross-fetch": "^3.1.5"
},
"devDependencies": {
"@veramo/cli": "4.2.0",
"did-resolver": "^4.1.0",
"nock": "^13.3.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const debug = Debug('ssi-sdk-siopv2-oid4vp-rp-rest-client:SiopV2OID4VpRpRestClie

export class SIOPv2OID4VPRPRestClient implements IAgentPlugin {
readonly methods: ISIOPv2OID4VPRPRestClient = {
siopClientRemoveAuthRequestSession: this.siopClientRemoveAuthRequestSession.bind(this),
siopClientGenerateAuthRequest: this.siopClientGenerateAuthRequest.bind(this),
siopClientRemoveAuthRequestState: this.siopClientRemoveAuthRequestState.bind(this),
siopClientCreateAuthRequest: this.siopClientCreateAuthRequest.bind(this),
siopClientGetAuthStatus: this.siopClientGetAuthStatus.bind(this),
}

Expand All @@ -31,7 +31,7 @@ export class SIOPv2OID4VPRPRestClient implements IAgentPlugin {
}
}

private async siopClientRemoveAuthRequestSession(args: ISiopClientRemoveAuthRequestSessionArgs, context: IRequiredContext): Promise<void> {
private async siopClientRemoveAuthRequestState(args: ISiopClientRemoveAuthRequestSessionArgs, context: IRequiredContext): Promise<void> {
const baseUrl = this.checkBaseUrlParameter(args.baseUrl)
const definitionId = this.checkDefinitionIdParameter(args.definitionId)
await fetch(this.uriWithBase(`/webapp/definitions/${definitionId}/auth-requests/${args.correlationId}`, baseUrl), {
Expand Down Expand Up @@ -61,14 +61,20 @@ export class SIOPv2OID4VPRPRestClient implements IAgentPlugin {
}
}

private async siopClientGenerateAuthRequest(
private async siopClientCreateAuthRequest(
args: ISiopClientGenerateAuthRequestArgs,
context: IRequiredContext
): Promise<GenerateAuthRequestURIResponse> {
const baseUrl = this.checkBaseUrlParameter(args.baseUrl)
const definitionId = this.checkDefinitionIdParameter(args.definitionId)
const url = this.uriWithBase(`/webapp/definitions/${definitionId}/auth-request-uri`, baseUrl)
const origResponse = await fetch(url)
const url = this.uriWithBase(`/webapp/definitions/${definitionId}/auth-requests`, baseUrl)
const origResponse = await fetch(url,{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({})
})
return await origResponse.json()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { IAgentContext, IPluginMethodMap, IResolver } from '@veramo/core'
import { AuthStatusResponse, GenerateAuthRequestURIResponse } from '@sphereon/ssi-sdk-siopv2-oid4vp-common'

export interface ISIOPv2OID4VPRPRestClient extends IPluginMethodMap {
siopClientRemoveAuthRequestSession(args: ISiopClientRemoveAuthRequestSessionArgs, context: IRequiredContext): Promise<void>
siopClientRemoveAuthRequestState(args: ISiopClientRemoveAuthRequestSessionArgs, context: IRequiredContext): Promise<void>

siopClientGenerateAuthRequest(args: ISiopClientGenerateAuthRequestArgs, context: IRequiredContext): Promise<GenerateAuthRequestURIResponse>
siopClientCreateAuthRequest(args: ISiopClientGenerateAuthRequestArgs, context: IRequiredContext): Promise<GenerateAuthRequestURIResponse>

siopClientGetAuthStatus(args: ISiopClientGetAuthStatusArgs, context: IRequiredContext): Promise<AuthStatusResponse>
}
Expand Down
1 change: 1 addition & 0 deletions packages/siopv2-oid4vp-rp-rest-client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../tsconfig-base.json",
"compilerOptions": {
"esModuleInterop": true,
"rootDir": "src",
"outDir": "dist"
},
Expand Down

0 comments on commit 94165cd

Please sign in to comment.