@extrimian/agent 0.12.0-1 → 0.12.0-11
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/dist/agent.d.ts +77 -77
- package/dist/agent.js +173 -173
- package/dist/agent.js.map +1 -1
- package/dist/data-share-behaviours/data-share-behavior.d.ts +4 -4
- package/dist/data-share-behaviours/data-share-behavior.js +2 -2
- package/dist/data-share-behaviours/identity-data-share-behavior.d.ts +16 -16
- package/dist/data-share-behaviours/identity-data-share-behavior.js +2 -2
- package/dist/data-share-behaviours/identity-plaintext-data-share-behavior.d.ts +5 -5
- package/dist/data-share-behaviours/identity-plaintext-data-share-behavior.js +15 -15
- package/dist/data-share-behaviours/vcs/vc-share-behavior.d.ts +12 -12
- package/dist/data-share-behaviours/vcs/vc-share-behavior.js +2 -2
- package/dist/data-share-behaviours/vcs/vc-share-didcomm-behavior.d.ts +20 -20
- package/dist/data-share-behaviours/vcs/vc-share-didcomm-behavior.js +29 -29
- package/dist/did/did-services.d.ts +14 -14
- package/dist/did/did-services.js +14 -14
- package/dist/exceptions/agent-plugin-not-found.d.ts +2 -2
- package/dist/exceptions/agent-plugin-not-found.js +6 -6
- package/dist/exceptions/vc-protocol-not-found.d.ts +3 -3
- package/dist/exceptions/vc-protocol-not-found.js +11 -11
- package/dist/index.d.ts +32 -32
- package/dist/index.js +60 -60
- package/dist/messaging/messaging.d.ts +41 -41
- package/dist/messaging/messaging.js +90 -88
- package/dist/messaging/messaging.js.map +1 -1
- package/dist/models/agent-identity.d.ts +86 -86
- package/dist/models/agent-identity.js +399 -399
- package/dist/models/agent-identity.js.map +1 -1
- package/dist/models/agent-kms.d.ts +42 -42
- package/dist/models/agent-kms.js +78 -78
- package/dist/models/agent-pbk.d.ts +11 -11
- package/dist/models/agent-pbk.js +11 -11
- package/dist/models/agent-registry.d.ts +95 -94
- package/dist/models/agent-registry.js +130 -129
- package/dist/models/agent-registry.js.map +1 -1
- package/dist/models/agent-resolver-cache.d.ts +21 -21
- package/dist/models/agent-resolver-cache.js +47 -47
- package/dist/models/agent-resolver.d.ts +19 -19
- package/dist/models/agent-resolver.js +33 -33
- package/dist/models/agent-secure-storage.d.ts +3 -3
- package/dist/models/agent-secure-storage.js +2 -2
- package/dist/models/agent-secure-storages/filesystem-agent-secure-storage.d.ts +14 -14
- package/dist/models/agent-secure-storages/filesystem-agent-secure-storage.js +48 -48
- package/dist/models/agent-storage.d.ts +9 -9
- package/dist/models/agent-storage.js +2 -2
- package/dist/models/did.d.ts +19 -19
- package/dist/models/did.js +63 -63
- package/dist/models/transports/ami-transport.d.ts +30 -30
- package/dist/models/transports/ami-transport.js +183 -183
- package/dist/models/transports/connectable-transport.d.ts +25 -25
- package/dist/models/transports/connectable-transport.js +25 -25
- package/dist/models/transports/dwn-transport.d.ts +32 -32
- package/dist/models/transports/dwn-transport.js +191 -191
- package/dist/models/transports/messaging-transport.d.ts +3 -3
- package/dist/models/transports/messaging-transport.js +2 -2
- package/dist/models/transports/transport.d.ts +30 -30
- package/dist/models/transports/transport.js +7 -7
- package/dist/models/transports/websocket-client-transport.d.ts +5 -5
- package/dist/models/transports/websocket-client-transport.js +33 -33
- package/dist/models/transports/websocket-server-transport.d.ts +7 -7
- package/dist/models/transports/websocket-server-transport.js +21 -21
- package/dist/models/transports/websocket-transport.d.ts +30 -30
- package/dist/models/transports/websocket-transport.js +84 -84
- package/dist/models/vc-storage.d.ts +8 -8
- package/dist/models/vc-storage.js +2 -2
- package/dist/plugins/iplugin.d.ts +17 -17
- package/dist/plugins/iplugin.js +2 -2
- package/dist/plugins/istatus-list-plugin.d.ts +14 -14
- package/dist/plugins/istatus-list-plugin.js +2 -2
- package/dist/plugins/ivc-interceptor-plugin.d.ts +9 -9
- package/dist/plugins/ivc-interceptor-plugin.js +2 -2
- package/dist/plugins/plugin-dispatcher.d.ts +6 -6
- package/dist/plugins/plugin-dispatcher.js +19 -19
- package/dist/transport/transport.d.ts +43 -43
- package/dist/transport/transport.js +109 -109
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +14 -14
- package/dist/utils/lite-event.d.ts +25 -25
- package/dist/utils/lite-event.js +36 -36
- package/dist/vc/models/credentia-flow.d.ts +4 -4
- package/dist/vc/models/credentia-flow.js +8 -8
- package/dist/vc/models/credential-request.d.ts +3 -3
- package/dist/vc/models/credential-request.js +2 -2
- package/dist/vc/models/vc-create-key-request.d.ts +4 -4
- package/dist/vc/models/vc-create-key-request.js +2 -2
- package/dist/vc/models/waci-message.d.ts +3 -3
- package/dist/vc/models/waci-message.js +7 -7
- package/dist/vc/protocols/openid-protocol.d.ts +161 -161
- package/dist/vc/protocols/openid-protocol.js +125 -125
- package/dist/vc/protocols/vc-protocol.d.ts +106 -106
- package/dist/vc/protocols/vc-protocol.js +36 -36
- package/dist/vc/protocols/waci-protocol.d.ts +183 -183
- package/dist/vc/protocols/waci-protocol.js +552 -552
- package/dist/vc/vc.d.ts +225 -225
- package/dist/vc/vc.js +328 -328
- package/package.json +19 -20
- package/readme.md +392 -392
- package/dist/vc/vc-setup/vc-setup.d.ts +0 -0
|
@@ -1,161 +1,161 @@
|
|
|
1
|
-
import { IStorage } from '../../models/agent-storage';
|
|
2
|
-
import { DID } from '../../models/did';
|
|
3
|
-
import { CredentialFlow } from '../models/credentia-flow';
|
|
4
|
-
import { VCProtocol } from './vc-protocol';
|
|
5
|
-
export declare class OpenIDProtocol extends VCProtocol<any> {
|
|
6
|
-
private storage;
|
|
7
|
-
constructor(params?: {
|
|
8
|
-
issuer?: {};
|
|
9
|
-
hoder?: {};
|
|
10
|
-
verifier?: {};
|
|
11
|
-
storage: IStorage;
|
|
12
|
-
});
|
|
13
|
-
generateGUID(): string;
|
|
14
|
-
processMessage(message: any, context?: any, _did?: DID): Promise<any>;
|
|
15
|
-
isProtocolMessage(message: any): Promise<boolean>;
|
|
16
|
-
createInvitationMessage(flow: CredentialFlow, did: DID): Promise<any>;
|
|
17
|
-
}
|
|
18
|
-
export interface MicrosoftCredential {
|
|
19
|
-
jti: string;
|
|
20
|
-
iat: number;
|
|
21
|
-
response_type: string;
|
|
22
|
-
response_mode: string;
|
|
23
|
-
scope: string;
|
|
24
|
-
nonce: string;
|
|
25
|
-
client_id: string;
|
|
26
|
-
redirect_uri: string;
|
|
27
|
-
prompt: string;
|
|
28
|
-
state: string;
|
|
29
|
-
exp: number;
|
|
30
|
-
registration: Registration;
|
|
31
|
-
claims: Claims;
|
|
32
|
-
pin: Pin;
|
|
33
|
-
id_token_hint: string;
|
|
34
|
-
}
|
|
35
|
-
export interface Claims {
|
|
36
|
-
vp_token: VpToken;
|
|
37
|
-
}
|
|
38
|
-
export interface VpToken {
|
|
39
|
-
presentation_definition: PresentationDefinition;
|
|
40
|
-
}
|
|
41
|
-
export interface PresentationDefinition {
|
|
42
|
-
id: string;
|
|
43
|
-
input_descriptors: InputDescriptor[];
|
|
44
|
-
}
|
|
45
|
-
export interface InputDescriptor {
|
|
46
|
-
id: string;
|
|
47
|
-
schema: Schema[];
|
|
48
|
-
issuance: Issuance[];
|
|
49
|
-
}
|
|
50
|
-
export interface Issuance {
|
|
51
|
-
manifest: string;
|
|
52
|
-
}
|
|
53
|
-
export interface Schema {
|
|
54
|
-
uri: string;
|
|
55
|
-
}
|
|
56
|
-
export interface Pin {
|
|
57
|
-
length: number;
|
|
58
|
-
type: string;
|
|
59
|
-
alg: string;
|
|
60
|
-
iterations: number;
|
|
61
|
-
salt: string;
|
|
62
|
-
hash: string;
|
|
63
|
-
}
|
|
64
|
-
export interface Registration {
|
|
65
|
-
client_name: string;
|
|
66
|
-
subject_syntax_types_supported: string[];
|
|
67
|
-
vp_formats: VpFormats;
|
|
68
|
-
}
|
|
69
|
-
export interface VpFormats {
|
|
70
|
-
jwt_vp: JwtV;
|
|
71
|
-
jwt_vc: JwtV;
|
|
72
|
-
}
|
|
73
|
-
export interface JwtV {
|
|
74
|
-
alg: string[];
|
|
75
|
-
}
|
|
76
|
-
export interface MicrosoftCredentialInfo {
|
|
77
|
-
sub: string;
|
|
78
|
-
aud: string;
|
|
79
|
-
nonce: string;
|
|
80
|
-
sub_jwk: SubJwk;
|
|
81
|
-
did: string;
|
|
82
|
-
given_name: string;
|
|
83
|
-
family_name: string;
|
|
84
|
-
iss: string;
|
|
85
|
-
iat: number;
|
|
86
|
-
jti: string;
|
|
87
|
-
exp: number;
|
|
88
|
-
pin: Pin;
|
|
89
|
-
}
|
|
90
|
-
export interface Pin {
|
|
91
|
-
length: number;
|
|
92
|
-
type: string;
|
|
93
|
-
alg: string;
|
|
94
|
-
iterations: number;
|
|
95
|
-
salt: string;
|
|
96
|
-
hash: string;
|
|
97
|
-
}
|
|
98
|
-
export interface SubJwk {
|
|
99
|
-
crv: string;
|
|
100
|
-
kid: string;
|
|
101
|
-
kty: string;
|
|
102
|
-
x: string;
|
|
103
|
-
y: string;
|
|
104
|
-
}
|
|
105
|
-
export interface MicrosoftCredentialManifest {
|
|
106
|
-
id: string;
|
|
107
|
-
display: Display;
|
|
108
|
-
input: Input;
|
|
109
|
-
iss: string;
|
|
110
|
-
iat: number;
|
|
111
|
-
}
|
|
112
|
-
export interface Display {
|
|
113
|
-
locale: string;
|
|
114
|
-
contract: string;
|
|
115
|
-
card: Card;
|
|
116
|
-
consent: Consent;
|
|
117
|
-
claims: Claims;
|
|
118
|
-
id: string;
|
|
119
|
-
}
|
|
120
|
-
export interface Card {
|
|
121
|
-
title: string;
|
|
122
|
-
issuedBy: string;
|
|
123
|
-
backgroundColor: string;
|
|
124
|
-
textColor: string;
|
|
125
|
-
logo: Logo;
|
|
126
|
-
description: string;
|
|
127
|
-
}
|
|
128
|
-
export interface Logo {
|
|
129
|
-
uri: string;
|
|
130
|
-
description: string;
|
|
131
|
-
}
|
|
132
|
-
export interface Claims {
|
|
133
|
-
type: string;
|
|
134
|
-
label: string;
|
|
135
|
-
}
|
|
136
|
-
export interface VcCredentialSubject {
|
|
137
|
-
type: string;
|
|
138
|
-
label: string;
|
|
139
|
-
}
|
|
140
|
-
export interface Consent {
|
|
141
|
-
title: string;
|
|
142
|
-
instructions: string;
|
|
143
|
-
}
|
|
144
|
-
export interface Input {
|
|
145
|
-
credentialIssuer: string;
|
|
146
|
-
issuer: string;
|
|
147
|
-
attestations: Attestations;
|
|
148
|
-
id: string;
|
|
149
|
-
}
|
|
150
|
-
export interface Attestations {
|
|
151
|
-
accessTokens: AccessToken[];
|
|
152
|
-
}
|
|
153
|
-
export interface AccessToken {
|
|
154
|
-
id: string;
|
|
155
|
-
encrypted: boolean;
|
|
156
|
-
claims: any[];
|
|
157
|
-
required: boolean;
|
|
158
|
-
configuration: string;
|
|
159
|
-
resourceId: string;
|
|
160
|
-
oboScope: string;
|
|
161
|
-
}
|
|
1
|
+
import { IStorage } from '../../models/agent-storage';
|
|
2
|
+
import { DID } from '../../models/did';
|
|
3
|
+
import { CredentialFlow } from '../models/credentia-flow';
|
|
4
|
+
import { VCProtocol } from './vc-protocol';
|
|
5
|
+
export declare class OpenIDProtocol extends VCProtocol<any> {
|
|
6
|
+
private storage;
|
|
7
|
+
constructor(params?: {
|
|
8
|
+
issuer?: {};
|
|
9
|
+
hoder?: {};
|
|
10
|
+
verifier?: {};
|
|
11
|
+
storage: IStorage;
|
|
12
|
+
});
|
|
13
|
+
generateGUID(): string;
|
|
14
|
+
processMessage(message: any, context?: any, _did?: DID): Promise<any>;
|
|
15
|
+
isProtocolMessage(message: any): Promise<boolean>;
|
|
16
|
+
createInvitationMessage(flow: CredentialFlow, did: DID): Promise<any>;
|
|
17
|
+
}
|
|
18
|
+
export interface MicrosoftCredential {
|
|
19
|
+
jti: string;
|
|
20
|
+
iat: number;
|
|
21
|
+
response_type: string;
|
|
22
|
+
response_mode: string;
|
|
23
|
+
scope: string;
|
|
24
|
+
nonce: string;
|
|
25
|
+
client_id: string;
|
|
26
|
+
redirect_uri: string;
|
|
27
|
+
prompt: string;
|
|
28
|
+
state: string;
|
|
29
|
+
exp: number;
|
|
30
|
+
registration: Registration;
|
|
31
|
+
claims: Claims;
|
|
32
|
+
pin: Pin;
|
|
33
|
+
id_token_hint: string;
|
|
34
|
+
}
|
|
35
|
+
export interface Claims {
|
|
36
|
+
vp_token: VpToken;
|
|
37
|
+
}
|
|
38
|
+
export interface VpToken {
|
|
39
|
+
presentation_definition: PresentationDefinition;
|
|
40
|
+
}
|
|
41
|
+
export interface PresentationDefinition {
|
|
42
|
+
id: string;
|
|
43
|
+
input_descriptors: InputDescriptor[];
|
|
44
|
+
}
|
|
45
|
+
export interface InputDescriptor {
|
|
46
|
+
id: string;
|
|
47
|
+
schema: Schema[];
|
|
48
|
+
issuance: Issuance[];
|
|
49
|
+
}
|
|
50
|
+
export interface Issuance {
|
|
51
|
+
manifest: string;
|
|
52
|
+
}
|
|
53
|
+
export interface Schema {
|
|
54
|
+
uri: string;
|
|
55
|
+
}
|
|
56
|
+
export interface Pin {
|
|
57
|
+
length: number;
|
|
58
|
+
type: string;
|
|
59
|
+
alg: string;
|
|
60
|
+
iterations: number;
|
|
61
|
+
salt: string;
|
|
62
|
+
hash: string;
|
|
63
|
+
}
|
|
64
|
+
export interface Registration {
|
|
65
|
+
client_name: string;
|
|
66
|
+
subject_syntax_types_supported: string[];
|
|
67
|
+
vp_formats: VpFormats;
|
|
68
|
+
}
|
|
69
|
+
export interface VpFormats {
|
|
70
|
+
jwt_vp: JwtV;
|
|
71
|
+
jwt_vc: JwtV;
|
|
72
|
+
}
|
|
73
|
+
export interface JwtV {
|
|
74
|
+
alg: string[];
|
|
75
|
+
}
|
|
76
|
+
export interface MicrosoftCredentialInfo {
|
|
77
|
+
sub: string;
|
|
78
|
+
aud: string;
|
|
79
|
+
nonce: string;
|
|
80
|
+
sub_jwk: SubJwk;
|
|
81
|
+
did: string;
|
|
82
|
+
given_name: string;
|
|
83
|
+
family_name: string;
|
|
84
|
+
iss: string;
|
|
85
|
+
iat: number;
|
|
86
|
+
jti: string;
|
|
87
|
+
exp: number;
|
|
88
|
+
pin: Pin;
|
|
89
|
+
}
|
|
90
|
+
export interface Pin {
|
|
91
|
+
length: number;
|
|
92
|
+
type: string;
|
|
93
|
+
alg: string;
|
|
94
|
+
iterations: number;
|
|
95
|
+
salt: string;
|
|
96
|
+
hash: string;
|
|
97
|
+
}
|
|
98
|
+
export interface SubJwk {
|
|
99
|
+
crv: string;
|
|
100
|
+
kid: string;
|
|
101
|
+
kty: string;
|
|
102
|
+
x: string;
|
|
103
|
+
y: string;
|
|
104
|
+
}
|
|
105
|
+
export interface MicrosoftCredentialManifest {
|
|
106
|
+
id: string;
|
|
107
|
+
display: Display;
|
|
108
|
+
input: Input;
|
|
109
|
+
iss: string;
|
|
110
|
+
iat: number;
|
|
111
|
+
}
|
|
112
|
+
export interface Display {
|
|
113
|
+
locale: string;
|
|
114
|
+
contract: string;
|
|
115
|
+
card: Card;
|
|
116
|
+
consent: Consent;
|
|
117
|
+
claims: Claims;
|
|
118
|
+
id: string;
|
|
119
|
+
}
|
|
120
|
+
export interface Card {
|
|
121
|
+
title: string;
|
|
122
|
+
issuedBy: string;
|
|
123
|
+
backgroundColor: string;
|
|
124
|
+
textColor: string;
|
|
125
|
+
logo: Logo;
|
|
126
|
+
description: string;
|
|
127
|
+
}
|
|
128
|
+
export interface Logo {
|
|
129
|
+
uri: string;
|
|
130
|
+
description: string;
|
|
131
|
+
}
|
|
132
|
+
export interface Claims {
|
|
133
|
+
type: string;
|
|
134
|
+
label: string;
|
|
135
|
+
}
|
|
136
|
+
export interface VcCredentialSubject {
|
|
137
|
+
type: string;
|
|
138
|
+
label: string;
|
|
139
|
+
}
|
|
140
|
+
export interface Consent {
|
|
141
|
+
title: string;
|
|
142
|
+
instructions: string;
|
|
143
|
+
}
|
|
144
|
+
export interface Input {
|
|
145
|
+
credentialIssuer: string;
|
|
146
|
+
issuer: string;
|
|
147
|
+
attestations: Attestations;
|
|
148
|
+
id: string;
|
|
149
|
+
}
|
|
150
|
+
export interface Attestations {
|
|
151
|
+
accessTokens: AccessToken[];
|
|
152
|
+
}
|
|
153
|
+
export interface AccessToken {
|
|
154
|
+
id: string;
|
|
155
|
+
encrypted: boolean;
|
|
156
|
+
claims: any[];
|
|
157
|
+
required: boolean;
|
|
158
|
+
configuration: string;
|
|
159
|
+
resourceId: string;
|
|
160
|
+
oboScope: string;
|
|
161
|
+
}
|
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.OpenIDProtocol = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const jwt_decode_1 = __importDefault(require("jwt-decode"));
|
|
9
|
-
const utils_1 = require("../../utils");
|
|
10
|
-
const vc_protocol_1 = require("./vc-protocol");
|
|
11
|
-
class OpenIDProtocol extends vc_protocol_1.VCProtocol {
|
|
12
|
-
constructor(params) {
|
|
13
|
-
super();
|
|
14
|
-
this.storage = params.storage;
|
|
15
|
-
}
|
|
16
|
-
generateGUID() {
|
|
17
|
-
function generateSegment() {
|
|
18
|
-
return Math.floor((1 + Math.random()) * 0x10000)
|
|
19
|
-
.toString(16)
|
|
20
|
-
.substring(1);
|
|
21
|
-
}
|
|
22
|
-
return (generateSegment() +
|
|
23
|
-
generateSegment() +
|
|
24
|
-
'-' +
|
|
25
|
-
generateSegment() +
|
|
26
|
-
'-4' +
|
|
27
|
-
generateSegment().substr(0, 3) +
|
|
28
|
-
'-' +
|
|
29
|
-
generateSegment() +
|
|
30
|
-
'-' +
|
|
31
|
-
generateSegment() +
|
|
32
|
-
generateSegment() +
|
|
33
|
-
generateSegment());
|
|
34
|
-
}
|
|
35
|
-
async processMessage(message, context, _did) {
|
|
36
|
-
var _a;
|
|
37
|
-
const request_uri = (0, utils_1.getSearchParam)('request_uri', message);
|
|
38
|
-
const encodedData = (await axios_1.default.get(request_uri)).data;
|
|
39
|
-
const decodedData = (0, jwt_decode_1.default)(encodedData);
|
|
40
|
-
const credentialData = (0, jwt_decode_1.default)(decodedData.id_token_hint);
|
|
41
|
-
const manifestEncoded = (_a = (await axios_1.default.get(decodedData.claims.vp_token.presentation_definition.input_descriptors[0]
|
|
42
|
-
.issuance[0].manifest)).data) === null || _a === void 0 ? void 0 : _a.token;
|
|
43
|
-
const credentialManifest = (0, jwt_decode_1.default)(manifestEncoded);
|
|
44
|
-
const { did, sub, aud, exp, iat, iss, jti, nonce, sub_jwk, pin, ...rest } = credentialData;
|
|
45
|
-
const data = {
|
|
46
|
-
credentialSubject: {
|
|
47
|
-
...rest,
|
|
48
|
-
},
|
|
49
|
-
id: this.generateGUID(),
|
|
50
|
-
type: [
|
|
51
|
-
decodedData.claims.vp_token.presentation_definition.input_descriptors[0]
|
|
52
|
-
.id,
|
|
53
|
-
],
|
|
54
|
-
issuer: {
|
|
55
|
-
id: credentialData.iss,
|
|
56
|
-
name: credentialManifest.display.card.issuedBy,
|
|
57
|
-
},
|
|
58
|
-
issuanceDate: new Date(),
|
|
59
|
-
};
|
|
60
|
-
const claims = [
|
|
61
|
-
{
|
|
62
|
-
path: '$.credentialSubject.given_name',
|
|
63
|
-
label: 'First Name',
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
path: '$.credentialSubject.family_name',
|
|
67
|
-
label: 'Last Name',
|
|
68
|
-
},
|
|
69
|
-
];
|
|
70
|
-
const display = {
|
|
71
|
-
description: {
|
|
72
|
-
text: credentialManifest.display.card.description,
|
|
73
|
-
},
|
|
74
|
-
title: {
|
|
75
|
-
text: credentialManifest.display.card.title,
|
|
76
|
-
},
|
|
77
|
-
properties: claims.map((claim) => {
|
|
78
|
-
const value = {
|
|
79
|
-
label: claim.label,
|
|
80
|
-
path: [claim.path],
|
|
81
|
-
schema: {
|
|
82
|
-
type: 'string',
|
|
83
|
-
},
|
|
84
|
-
fallback: 'Unknown',
|
|
85
|
-
};
|
|
86
|
-
return value;
|
|
87
|
-
}),
|
|
88
|
-
};
|
|
89
|
-
const styles = {
|
|
90
|
-
thumbnail: {
|
|
91
|
-
alt: credentialManifest.display.card.logo.description,
|
|
92
|
-
uri: credentialManifest.display.card.logo.uri,
|
|
93
|
-
},
|
|
94
|
-
background: { color: credentialManifest.display.card.backgroundColor },
|
|
95
|
-
text: {
|
|
96
|
-
color: credentialManifest.display.card.textColor,
|
|
97
|
-
},
|
|
98
|
-
hero: {
|
|
99
|
-
uri: '',
|
|
100
|
-
alt: '',
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
const issuer = {
|
|
104
|
-
id: credentialData.iss,
|
|
105
|
-
name: credentialManifest.display.card.issuedBy,
|
|
106
|
-
};
|
|
107
|
-
this.onVcArrived.trigger({
|
|
108
|
-
credentials: [{ data, styles, display }],
|
|
109
|
-
messageId: "",
|
|
110
|
-
issuer,
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
async isProtocolMessage(message) {
|
|
114
|
-
if (typeof message === 'string' &&
|
|
115
|
-
message.includes('openid-vc://') &&
|
|
116
|
-
(0, utils_1.getSearchParam)('request_uri', message)) {
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
async createInvitationMessage(flow, did) {
|
|
122
|
-
throw new Error('Method not implemented.');
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
exports.OpenIDProtocol = OpenIDProtocol;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.OpenIDProtocol = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const jwt_decode_1 = __importDefault(require("jwt-decode"));
|
|
9
|
+
const utils_1 = require("../../utils");
|
|
10
|
+
const vc_protocol_1 = require("./vc-protocol");
|
|
11
|
+
class OpenIDProtocol extends vc_protocol_1.VCProtocol {
|
|
12
|
+
constructor(params) {
|
|
13
|
+
super();
|
|
14
|
+
this.storage = params.storage;
|
|
15
|
+
}
|
|
16
|
+
generateGUID() {
|
|
17
|
+
function generateSegment() {
|
|
18
|
+
return Math.floor((1 + Math.random()) * 0x10000)
|
|
19
|
+
.toString(16)
|
|
20
|
+
.substring(1);
|
|
21
|
+
}
|
|
22
|
+
return (generateSegment() +
|
|
23
|
+
generateSegment() +
|
|
24
|
+
'-' +
|
|
25
|
+
generateSegment() +
|
|
26
|
+
'-4' +
|
|
27
|
+
generateSegment().substr(0, 3) +
|
|
28
|
+
'-' +
|
|
29
|
+
generateSegment() +
|
|
30
|
+
'-' +
|
|
31
|
+
generateSegment() +
|
|
32
|
+
generateSegment() +
|
|
33
|
+
generateSegment());
|
|
34
|
+
}
|
|
35
|
+
async processMessage(message, context, _did) {
|
|
36
|
+
var _a;
|
|
37
|
+
const request_uri = (0, utils_1.getSearchParam)('request_uri', message);
|
|
38
|
+
const encodedData = (await axios_1.default.get(request_uri)).data;
|
|
39
|
+
const decodedData = (0, jwt_decode_1.default)(encodedData);
|
|
40
|
+
const credentialData = (0, jwt_decode_1.default)(decodedData.id_token_hint);
|
|
41
|
+
const manifestEncoded = (_a = (await axios_1.default.get(decodedData.claims.vp_token.presentation_definition.input_descriptors[0]
|
|
42
|
+
.issuance[0].manifest)).data) === null || _a === void 0 ? void 0 : _a.token;
|
|
43
|
+
const credentialManifest = (0, jwt_decode_1.default)(manifestEncoded);
|
|
44
|
+
const { did, sub, aud, exp, iat, iss, jti, nonce, sub_jwk, pin, ...rest } = credentialData;
|
|
45
|
+
const data = {
|
|
46
|
+
credentialSubject: {
|
|
47
|
+
...rest,
|
|
48
|
+
},
|
|
49
|
+
id: this.generateGUID(),
|
|
50
|
+
type: [
|
|
51
|
+
decodedData.claims.vp_token.presentation_definition.input_descriptors[0]
|
|
52
|
+
.id,
|
|
53
|
+
],
|
|
54
|
+
issuer: {
|
|
55
|
+
id: credentialData.iss,
|
|
56
|
+
name: credentialManifest.display.card.issuedBy,
|
|
57
|
+
},
|
|
58
|
+
issuanceDate: new Date(),
|
|
59
|
+
};
|
|
60
|
+
const claims = [
|
|
61
|
+
{
|
|
62
|
+
path: '$.credentialSubject.given_name',
|
|
63
|
+
label: 'First Name',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
path: '$.credentialSubject.family_name',
|
|
67
|
+
label: 'Last Name',
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
const display = {
|
|
71
|
+
description: {
|
|
72
|
+
text: credentialManifest.display.card.description,
|
|
73
|
+
},
|
|
74
|
+
title: {
|
|
75
|
+
text: credentialManifest.display.card.title,
|
|
76
|
+
},
|
|
77
|
+
properties: claims.map((claim) => {
|
|
78
|
+
const value = {
|
|
79
|
+
label: claim.label,
|
|
80
|
+
path: [claim.path],
|
|
81
|
+
schema: {
|
|
82
|
+
type: 'string',
|
|
83
|
+
},
|
|
84
|
+
fallback: 'Unknown',
|
|
85
|
+
};
|
|
86
|
+
return value;
|
|
87
|
+
}),
|
|
88
|
+
};
|
|
89
|
+
const styles = {
|
|
90
|
+
thumbnail: {
|
|
91
|
+
alt: credentialManifest.display.card.logo.description,
|
|
92
|
+
uri: credentialManifest.display.card.logo.uri,
|
|
93
|
+
},
|
|
94
|
+
background: { color: credentialManifest.display.card.backgroundColor },
|
|
95
|
+
text: {
|
|
96
|
+
color: credentialManifest.display.card.textColor,
|
|
97
|
+
},
|
|
98
|
+
hero: {
|
|
99
|
+
uri: '',
|
|
100
|
+
alt: '',
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
const issuer = {
|
|
104
|
+
id: credentialData.iss,
|
|
105
|
+
name: credentialManifest.display.card.issuedBy,
|
|
106
|
+
};
|
|
107
|
+
this.onVcArrived.trigger({
|
|
108
|
+
credentials: [{ data, styles, display }],
|
|
109
|
+
messageId: "",
|
|
110
|
+
issuer,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
async isProtocolMessage(message) {
|
|
114
|
+
if (typeof message === 'string' &&
|
|
115
|
+
message.includes('openid-vc://') &&
|
|
116
|
+
(0, utils_1.getSearchParam)('request_uri', message)) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
async createInvitationMessage(flow, did) {
|
|
122
|
+
throw new Error('Method not implemented.');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.OpenIDProtocol = OpenIDProtocol;
|
|
126
126
|
//# sourceMappingURL=openid-protocol.js.map
|