@sphereon/ssi-sdk.oidf-client 0.30.2-feature.SPRIND.84.139
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/dist/agent/OIDFClient.d.ts +15 -0
- package/dist/agent/OIDFClient.d.ts.map +1 -0
- package/dist/agent/OIDFClient.js +57 -0
- package/dist/agent/OIDFClient.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/ssi-sdk.oidf-client.d.ts +52 -0
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/types/IOIDFClient.d.ts +20 -0
- package/dist/types/IOIDFClient.d.ts.map +1 -0
- package/dist/types/IOIDFClient.js +3 -0
- package/dist/types/IOIDFClient.js.map +1 -0
- package/package.json +53 -0
- package/plugin.schema.json +3102 -0
- package/src/agent/OIDFClient.ts +58 -0
- package/src/index.ts +13 -0
- package/src/types/IOIDFClient.ts +32 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {IAgentPlugin} from "@veramo/core";
|
|
2
|
+
import {
|
|
3
|
+
CreateJwsCompactArgs,
|
|
4
|
+
IJwsValidationResult,
|
|
5
|
+
JwtCompactResult,
|
|
6
|
+
VerifyJwsArgs,
|
|
7
|
+
} from '@sphereon/ssi-sdk-ext.jwt-service'
|
|
8
|
+
import {
|
|
9
|
+
IOIDFClient,
|
|
10
|
+
OIDFClientArgs,
|
|
11
|
+
RequiredContext,
|
|
12
|
+
ResolveTrustChainArgs,
|
|
13
|
+
ResolveTrustChainCallbackResult
|
|
14
|
+
} from '../types/IOIDFClient';
|
|
15
|
+
// @ts-ignore // TODO fix import
|
|
16
|
+
import { com } from '@sphereon/openid-federation-client';
|
|
17
|
+
import {schema} from '../index';
|
|
18
|
+
import FederationClient = com.sphereon.oid.fed.client.FederationClient;
|
|
19
|
+
|
|
20
|
+
export const oidfClientMethods: Array<string> = [
|
|
21
|
+
'resolveTrustChain',
|
|
22
|
+
'signJwt',
|
|
23
|
+
'verifyJwt'
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
export class OIDFClient implements IAgentPlugin {
|
|
27
|
+
readonly oidfClient: FederationClient
|
|
28
|
+
readonly schema = schema.IOIDFClient
|
|
29
|
+
|
|
30
|
+
constructor(args?: OIDFClientArgs) {
|
|
31
|
+
const { cryptoServiceCallback } = { ...args }
|
|
32
|
+
if (cryptoServiceCallback) {
|
|
33
|
+
this.oidfClient = new FederationClient(null, cryptoServiceCallback)
|
|
34
|
+
} else {
|
|
35
|
+
//FIXME Default Federation client crypto callback
|
|
36
|
+
this.oidfClient = new FederationClient(null, null)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
readonly methods: IOIDFClient = {
|
|
41
|
+
resolveTrustChain: this.resolveTrustChain.bind(this),
|
|
42
|
+
signJwt: this.signJwt.bind(this),
|
|
43
|
+
verifyJwt: this.verifyJwt.bind(this)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private async resolveTrustChain(args: ResolveTrustChainArgs): Promise<ResolveTrustChainCallbackResult> {
|
|
47
|
+
const { entityIdentifier, trustAnchors } = args
|
|
48
|
+
return await this.oidfClient.resolveTrustChain(entityIdentifier, trustAnchors)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private async signJwt(args: CreateJwsCompactArgs, context: RequiredContext): Promise<JwtCompactResult> {
|
|
52
|
+
return await context.agent.jwtCreateJwsCompactSignature(args)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private async verifyJwt(args: VerifyJwsArgs, context: RequiredContext): Promise<IJwsValidationResult> {
|
|
56
|
+
return await context.agent.jwtVerifyJwsSignature(args)
|
|
57
|
+
}
|
|
58
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {Loggers} from '@sphereon/ssi-types'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
const schema = require('../plugin.schema.json')
|
|
7
|
+
export { schema }
|
|
8
|
+
|
|
9
|
+
export const logger = Loggers.DEFAULT.get('sphereon:oidf-client')
|
|
10
|
+
|
|
11
|
+
export { OIDFClient, oidfClientMethods } from './agent/OIDFClient'
|
|
12
|
+
|
|
13
|
+
export * from './types/IOIDFClient'
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {IAgentContext, IPluginMethodMap} from '@veramo/core';
|
|
2
|
+
// @ts-ignore // TODO fix import
|
|
3
|
+
import { com, Nullable } from '@sphereon/openid-federation-client';
|
|
4
|
+
import ICryptoServiceCallbackJS = com.sphereon.oid.fed.client.crypto.ICryptoServiceCallback;
|
|
5
|
+
import {
|
|
6
|
+
CreateJwsCompactArgs,
|
|
7
|
+
IJwsValidationResult,
|
|
8
|
+
IJwtService,
|
|
9
|
+
JwtCompactResult,
|
|
10
|
+
VerifyJwsArgs
|
|
11
|
+
} from '@sphereon/ssi-sdk-ext.jwt-service';
|
|
12
|
+
|
|
13
|
+
export interface IOIDFClient extends IPluginMethodMap {
|
|
14
|
+
resolveTrustChain(args: ResolveTrustChainArgs): Promise<ResolveTrustChainCallbackResult>
|
|
15
|
+
signJwt(args: CreateJwsCompactArgs, context: RequiredContext ): Promise<JwtCompactResult>
|
|
16
|
+
verifyJwt(args: VerifyJwsArgs, context: RequiredContext): Promise<IJwsValidationResult>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type ResolveTrustChainArgs = {
|
|
20
|
+
entityIdentifier: string,
|
|
21
|
+
trustAnchors: Array<string>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type OIDFClientArgs = {
|
|
25
|
+
cryptoServiceCallback?: CryptoServiceCallbackArgs
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type CryptoServiceCallbackArgs = ICryptoServiceCallbackJS
|
|
29
|
+
|
|
30
|
+
export type ResolveTrustChainCallbackResult = Nullable<Array<string>>
|
|
31
|
+
|
|
32
|
+
export type RequiredContext = IAgentContext<IJwtService>
|