@sphereon/ssi-sdk.oidf-client 0.30.2-fix.199 → 0.30.2-fix.263
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IAgentPlugin } from
|
|
1
|
+
import { IAgentPlugin } from '@veramo/core';
|
|
2
2
|
import { IOIDFClient, OIDFClientArgs } from '../types/IOIDFClient';
|
|
3
3
|
export declare const oidfClientMethods: Array<string>;
|
|
4
4
|
export declare class OIDFClient implements IAgentPlugin {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OIDFClient.d.ts","sourceRoot":"","sources":["../../src/agent/OIDFClient.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"OIDFClient.d.ts","sourceRoot":"","sources":["../../src/agent/OIDFClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,OAAO,EAAE,WAAW,EAAE,cAAc,EAA2E,MAAM,sBAAsB,CAAA;AAS3I,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,MAAM,CAAiD,CAAA;AAE7F,qBAAa,UAAW,YAAW,YAAY;IAC7C,OAAO,CAAC,UAAU,CAAC,CAAkB;IACrC,QAAQ,CAAC,MAAM,MAAqB;gBAExB,IAAI,CAAC,EAAE,cAAc;IAYjC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAI5B;YAEa,iBAAiB;IAM/B,OAAO,CAAC,+BAA+B;YAgCzB,OAAO;YAIP,SAAS;CAGxB"}
|
package/dist/agent/OIDFClient.js
CHANGED
|
@@ -16,18 +16,14 @@ var FederationClient = openid_federation_client_1.com.sphereon.oid.fed.client.Fe
|
|
|
16
16
|
var DefaultFetchJSImpl = openid_federation_client_1.com.sphereon.oid.fed.client.fetch.DefaultFetchJSImpl;
|
|
17
17
|
var DefaultTrustChainJSImpl = openid_federation_client_1.com.sphereon.oid.fed.client.trustchain.DefaultTrustChainJSImpl;
|
|
18
18
|
var DefaultCallbacks = openid_federation_client_1.com.sphereon.oid.fed.client.service.DefaultCallbacks;
|
|
19
|
-
exports.oidfClientMethods = [
|
|
20
|
-
'resolveTrustChain',
|
|
21
|
-
'signJwt',
|
|
22
|
-
'verifyJwt'
|
|
23
|
-
];
|
|
19
|
+
exports.oidfClientMethods = ['resolveTrustChain', 'signJwt', 'verifyJwt'];
|
|
24
20
|
class OIDFClient {
|
|
25
21
|
constructor(args) {
|
|
26
22
|
this.schema = index_1.schema.IOIDFClient;
|
|
27
23
|
this.methods = {
|
|
28
24
|
resolveTrustChain: this.resolveTrustChain.bind(this),
|
|
29
25
|
signJwt: this.signJwt.bind(this),
|
|
30
|
-
verifyJwt: this.verifyJwt.bind(this)
|
|
26
|
+
verifyJwt: this.verifyJwt.bind(this),
|
|
31
27
|
};
|
|
32
28
|
const { cryptoServiceCallback } = Object.assign({}, args);
|
|
33
29
|
if (cryptoServiceCallback !== undefined && cryptoServiceCallback !== null) {
|
|
@@ -47,25 +43,24 @@ class OIDFClient {
|
|
|
47
43
|
});
|
|
48
44
|
}
|
|
49
45
|
checkAndSetDefaultCryptoService(context) {
|
|
50
|
-
if (
|
|
51
|
-
context.agent.jwtVerifyJwsSignature !== null
|
|
46
|
+
if (context.agent.jwtVerifyJwsSignature !== undefined &&
|
|
47
|
+
context.agent.jwtVerifyJwsSignature !== null &&
|
|
52
48
|
(this.oidfClient === undefined || this.oidfClient === null)) {
|
|
53
49
|
try {
|
|
54
50
|
DefaultCallbacks.setCryptoServiceDefault({
|
|
55
51
|
verify: (jwt, key) => __awaiter(this, void 0, void 0, function* () {
|
|
56
52
|
const jwk = Object.assign({}, key);
|
|
57
53
|
try {
|
|
58
|
-
console.error(`JWT: ${jwt}\nJWK: ${JSON.stringify(jwk)}`);
|
|
59
54
|
return !(yield context.agent.jwtVerifyJwsSignature({
|
|
60
55
|
jws: jwt,
|
|
61
|
-
jwk
|
|
56
|
+
jwk,
|
|
62
57
|
})).error;
|
|
63
58
|
}
|
|
64
59
|
catch (e) {
|
|
65
60
|
console.error(`Error verifying the JWT: ${e.message}`);
|
|
66
61
|
return Promise.reject(e);
|
|
67
62
|
}
|
|
68
|
-
})
|
|
63
|
+
}),
|
|
69
64
|
});
|
|
70
65
|
DefaultCallbacks.setFetchServiceDefault(new DefaultFetchJSImpl());
|
|
71
66
|
DefaultCallbacks.setTrustChainServiceDefault(new DefaultTrustChainJSImpl());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OIDFClient.js","sourceRoot":"","sources":["../../src/agent/OIDFClient.ts"],"names":[],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"OIDFClient.js","sourceRoot":"","sources":["../../src/agent/OIDFClient.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,iFAAwD;AACxD,oCAAiC;AAEjC,IAAO,gBAAgB,GAAG,8BAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAA;AACtE,IAAO,kBAAkB,GAAG,8BAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAA;AAChF,IAAO,uBAAuB,GAAG,8BAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,uBAAuB,CAAA;AAC/F,IAAO,gBAAgB,GAAG,8BAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAA;AAEjE,QAAA,iBAAiB,GAAkB,CAAC,mBAAmB,EAAE,SAAS,EAAE,WAAW,CAAC,CAAA;AAE7F,MAAa,UAAU;IAIrB,YAAY,IAAqB;QAFxB,WAAM,GAAG,cAAM,CAAC,WAAW,CAAA;QAc3B,YAAO,GAAgB;YAC9B,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,CA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ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
"generate-plugin-schema": "ts-node ../../packages/dev/bin/sphereon.js dev generate-plugin-schema"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@sphereon/openid-federation-client": "0.1.0-unstable.
|
|
19
|
-
"@sphereon/openid-federation-common": "0.1.0-unstable.
|
|
20
|
-
"@sphereon/openid-federation-open-api": "0.1.0-unstable.
|
|
18
|
+
"@sphereon/openid-federation-client": "0.1.0-unstable.8663d94",
|
|
19
|
+
"@sphereon/openid-federation-common": "0.1.0-unstable.8663d94",
|
|
20
|
+
"@sphereon/openid-federation-open-api": "0.1.0-unstable.8663d94",
|
|
21
21
|
"@sphereon/ssi-sdk-ext.jwt-service": "0.25.0",
|
|
22
|
-
"@sphereon/ssi-types": "0.30.2-fix.
|
|
22
|
+
"@sphereon/ssi-types": "0.30.2-fix.263+339900d8"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@sphereon/ssi-sdk.agent-config": "0.30.2-fix.
|
|
25
|
+
"@sphereon/ssi-sdk.agent-config": "0.30.2-fix.263+339900d8",
|
|
26
26
|
"@veramo/remote-client": "4.2.0",
|
|
27
27
|
"@veramo/remote-server": "4.2.0",
|
|
28
28
|
"cross-fetch": "^3.1.8",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"Veramo",
|
|
50
50
|
"OpenID Federation"
|
|
51
51
|
],
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "339900d89cc96f1c3ed89635b31de3a89c542910"
|
|
53
53
|
}
|
package/src/agent/OIDFClient.ts
CHANGED
|
@@ -1,93 +1,81 @@
|
|
|
1
|
-
import {IAgentPlugin} from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
RequiredContext,
|
|
12
|
-
ResolveTrustChainArgs,
|
|
13
|
-
ResolveTrustChainCallbackResult
|
|
14
|
-
} from '../types/IOIDFClient';
|
|
15
|
-
import {com} from '@sphereon/openid-federation-client';
|
|
16
|
-
import {schema} from '../index';
|
|
17
|
-
import FederationClient = com.sphereon.oid.fed.client.FederationClient;
|
|
18
|
-
import DefaultFetchJSImpl = com.sphereon.oid.fed.client.fetch.DefaultFetchJSImpl;
|
|
19
|
-
import DefaultTrustChainJSImpl = com.sphereon.oid.fed.client.trustchain.DefaultTrustChainJSImpl;
|
|
20
|
-
import DefaultCallbacks = com.sphereon.oid.fed.client.service.DefaultCallbacks;
|
|
21
|
-
import {JWK} from "@sphereon/ssi-types";
|
|
1
|
+
import { IAgentPlugin } from '@veramo/core'
|
|
2
|
+
import { CreateJwsCompactArgs, IJwsValidationResult, JwtCompactResult, VerifyJwsArgs } from '@sphereon/ssi-sdk-ext.jwt-service'
|
|
3
|
+
import { IOIDFClient, OIDFClientArgs, RequiredContext, ResolveTrustChainArgs, ResolveTrustChainCallbackResult } from '../types/IOIDFClient'
|
|
4
|
+
import { com } from '@sphereon/openid-federation-client'
|
|
5
|
+
import { schema } from '../index'
|
|
6
|
+
import { JWK } from '@sphereon/ssi-types'
|
|
7
|
+
import FederationClient = com.sphereon.oid.fed.client.FederationClient
|
|
8
|
+
import DefaultFetchJSImpl = com.sphereon.oid.fed.client.fetch.DefaultFetchJSImpl
|
|
9
|
+
import DefaultTrustChainJSImpl = com.sphereon.oid.fed.client.trustchain.DefaultTrustChainJSImpl
|
|
10
|
+
import DefaultCallbacks = com.sphereon.oid.fed.client.service.DefaultCallbacks
|
|
22
11
|
|
|
23
|
-
export const oidfClientMethods: Array<string> = [
|
|
24
|
-
'resolveTrustChain',
|
|
25
|
-
'signJwt',
|
|
26
|
-
'verifyJwt'
|
|
27
|
-
]
|
|
12
|
+
export const oidfClientMethods: Array<string> = ['resolveTrustChain', 'signJwt', 'verifyJwt']
|
|
28
13
|
|
|
29
14
|
export class OIDFClient implements IAgentPlugin {
|
|
30
|
-
|
|
31
|
-
|
|
15
|
+
private oidfClient?: FederationClient
|
|
16
|
+
readonly schema = schema.IOIDFClient
|
|
32
17
|
|
|
33
|
-
|
|
34
|
-
|
|
18
|
+
constructor(args?: OIDFClientArgs) {
|
|
19
|
+
const { cryptoServiceCallback } = { ...args }
|
|
35
20
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
21
|
+
if (cryptoServiceCallback !== undefined && cryptoServiceCallback !== null) {
|
|
22
|
+
DefaultCallbacks.setCryptoServiceDefault(cryptoServiceCallback)
|
|
23
|
+
DefaultCallbacks.setFetchServiceDefault(new DefaultFetchJSImpl())
|
|
24
|
+
// Depends on the crypto and fetch services, thus it must be the last one to be set
|
|
25
|
+
DefaultCallbacks.setTrustChainServiceDefault(new DefaultTrustChainJSImpl())
|
|
26
|
+
this.oidfClient = new FederationClient()
|
|
43
27
|
}
|
|
28
|
+
}
|
|
44
29
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
30
|
+
readonly methods: IOIDFClient = {
|
|
31
|
+
resolveTrustChain: this.resolveTrustChain.bind(this),
|
|
32
|
+
signJwt: this.signJwt.bind(this),
|
|
33
|
+
verifyJwt: this.verifyJwt.bind(this),
|
|
34
|
+
}
|
|
50
35
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
36
|
+
private async resolveTrustChain(args: ResolveTrustChainArgs, context: RequiredContext): Promise<ResolveTrustChainCallbackResult> {
|
|
37
|
+
const { entityIdentifier, trustAnchors } = args
|
|
38
|
+
this.checkAndSetDefaultCryptoService(context)
|
|
39
|
+
return await this.oidfClient?.resolveTrustChain(entityIdentifier, trustAnchors)
|
|
40
|
+
}
|
|
56
41
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
42
|
+
private checkAndSetDefaultCryptoService(context: RequiredContext) {
|
|
43
|
+
if (
|
|
44
|
+
context.agent.jwtVerifyJwsSignature !== undefined &&
|
|
45
|
+
context.agent.jwtVerifyJwsSignature !== null &&
|
|
46
|
+
(this.oidfClient === undefined || this.oidfClient === null)
|
|
47
|
+
) {
|
|
48
|
+
try {
|
|
49
|
+
DefaultCallbacks.setCryptoServiceDefault({
|
|
50
|
+
verify: async (jwt: string, key: any): Promise<boolean> => {
|
|
51
|
+
const jwk: JWK = { ...key }
|
|
61
52
|
try {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
console.error(`JWT: ${jwt}\nJWK: ${JSON.stringify(jwk)}`)
|
|
67
|
-
return !(await context.agent.jwtVerifyJwsSignature({
|
|
68
|
-
jws: jwt,
|
|
69
|
-
jwk
|
|
70
|
-
})).error
|
|
71
|
-
} catch(e) {
|
|
72
|
-
console.error(`Error verifying the JWT: ${e.message}`)
|
|
73
|
-
return Promise.reject(e)
|
|
74
|
-
}
|
|
75
|
-
}
|
|
53
|
+
return !(
|
|
54
|
+
await context.agent.jwtVerifyJwsSignature({
|
|
55
|
+
jws: jwt,
|
|
56
|
+
jwk,
|
|
76
57
|
})
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
throw Error(`Could not initialize the federation client: ${error.message}`)
|
|
58
|
+
).error
|
|
59
|
+
} catch (e) {
|
|
60
|
+
console.error(`Error verifying the JWT: ${e.message}`)
|
|
61
|
+
return Promise.reject(e)
|
|
82
62
|
}
|
|
83
|
-
|
|
63
|
+
},
|
|
64
|
+
})
|
|
65
|
+
DefaultCallbacks.setFetchServiceDefault(new DefaultFetchJSImpl())
|
|
66
|
+
DefaultCallbacks.setTrustChainServiceDefault(new DefaultTrustChainJSImpl())
|
|
67
|
+
this.oidfClient = new FederationClient()
|
|
68
|
+
} catch (error) {
|
|
69
|
+
throw Error(`Could not initialize the federation client: ${error.message}`)
|
|
70
|
+
}
|
|
84
71
|
}
|
|
72
|
+
}
|
|
85
73
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
74
|
+
private async signJwt(args: CreateJwsCompactArgs, context: RequiredContext): Promise<JwtCompactResult> {
|
|
75
|
+
return await context.agent.jwtCreateJwsCompactSignature(args)
|
|
76
|
+
}
|
|
89
77
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
78
|
+
private async verifyJwt(args: VerifyJwsArgs, context: RequiredContext): Promise<IJwsValidationResult> {
|
|
79
|
+
return await context.agent.jwtVerifyJwsSignature(args)
|
|
80
|
+
}
|
|
93
81
|
}
|