@vidos-id/openid4vc-wallet 0.0.0-test1
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/README.md +153 -0
- package/dist/index.d.mts +330 -0
- package/dist/index.mjs +1055 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
# @vidos-id/openid4vc-wallet
|
|
2
|
+
|
|
3
|
+
Minimal demo wallet library for importing, storing, and presenting `dc+sd-jwt` credentials.
|
|
4
|
+
|
|
5
|
+
For the CLI wrapper, see [`@vidos-id/openid4vc-wallet-cli`](../wallet-cli/). For the installed CLI flow, see the [root README](../../). For development, the CLI bin can be run with `bun packages/wallet-cli/src/index.ts`.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
Configure GitHub Packages in the consuming repo:
|
|
10
|
+
|
|
11
|
+
```ini
|
|
12
|
+
@vidos-id:registry=https://npm.pkg.github.com
|
|
13
|
+
//npm.pkg.github.com/:_authToken=${GITHUB_PACKAGES_TOKEN}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Install with your preferred package manager:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# bun
|
|
20
|
+
bun add @vidos-id/openid4vc-wallet
|
|
21
|
+
|
|
22
|
+
# npm
|
|
23
|
+
npm install @vidos-id/openid4vc-wallet
|
|
24
|
+
|
|
25
|
+
# pnpm
|
|
26
|
+
pnpm add @vidos-id/openid4vc-wallet
|
|
27
|
+
|
|
28
|
+
# yarn
|
|
29
|
+
yarn add @vidos-id/openid4vc-wallet
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
This package is currently published as raw TypeScript and is intended for Bun-based consumers.
|
|
33
|
+
|
|
34
|
+
## Features
|
|
35
|
+
|
|
36
|
+
- holder-key generation (ES256, ES384, EdDSA)
|
|
37
|
+
- holder-key import from JWK
|
|
38
|
+
- pluggable storage interface
|
|
39
|
+
- issuer JWK/JWKS credential verification (optional)
|
|
40
|
+
- direct OID4VCI receipt from credential offers
|
|
41
|
+
- on-demand credential status resolution via Token Status List JWTs
|
|
42
|
+
- DCQL matching with `dcql`
|
|
43
|
+
- `openid4vp://` authorization URL parsing for by-value DCQL requests
|
|
44
|
+
- selective disclosure presentation building
|
|
45
|
+
- KB-JWT holder binding
|
|
46
|
+
- `direct_post` and `direct_post.jwt` authorization response submission
|
|
47
|
+
|
|
48
|
+
## Example
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import {
|
|
52
|
+
InMemoryWalletStorage,
|
|
53
|
+
Wallet,
|
|
54
|
+
receiveCredentialFromOffer,
|
|
55
|
+
} from "@vidos-id/openid4vc-wallet";
|
|
56
|
+
|
|
57
|
+
const wallet = new Wallet(new InMemoryWalletStorage());
|
|
58
|
+
|
|
59
|
+
// Default holder key algorithm is ES256; pass "ES384" or "EdDSA" for alternatives
|
|
60
|
+
await wallet.getOrCreateHolderKey("ES256");
|
|
61
|
+
|
|
62
|
+
// Import a credential (after issuing with the issuer library)
|
|
63
|
+
await wallet.importCredential({
|
|
64
|
+
credential: "eyJ...",
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Optionally verify against issuer JWKS on import
|
|
68
|
+
await wallet.importCredential({
|
|
69
|
+
credential: "eyJ...",
|
|
70
|
+
issuer: { issuer: "https://issuer.example", jwks: { keys: [/* ... */] } },
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Receive directly from a minimal OID4VCI credential offer
|
|
74
|
+
await receiveCredentialFromOffer(
|
|
75
|
+
wallet,
|
|
76
|
+
'openid-credential-offer://?credential_offer=...'
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
// Or start from a by-reference offer URI
|
|
80
|
+
await receiveCredentialFromOffer(
|
|
81
|
+
wallet,
|
|
82
|
+
'openid-credential-offer://?credential_offer_uri=https%3A%2F%2Fissuer.example%2Foffers%2Fperson-1'
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
// Endpoint resolution is metadata-driven:
|
|
86
|
+
// 1. parse the offer or fetch credential_offer_uri first
|
|
87
|
+
// 2. read credential_issuer from the resolved offer
|
|
88
|
+
// 3. fetch /.well-known/openid-credential-issuer[issuer-path]
|
|
89
|
+
// 4. use token_endpoint / credential_endpoint / optional nonce_endpoint from metadata
|
|
90
|
+
|
|
91
|
+
// Resolve credential status only when needed
|
|
92
|
+
const status = await wallet.getCredentialStatus("credential-id");
|
|
93
|
+
|
|
94
|
+
// Create a presentation from a DCQL request
|
|
95
|
+
const presentation = await wallet.createPresentation({
|
|
96
|
+
client_id: "https://verifier.example",
|
|
97
|
+
nonce: "nonce-123",
|
|
98
|
+
dcql_query: {
|
|
99
|
+
credentials: [
|
|
100
|
+
{
|
|
101
|
+
id: "person",
|
|
102
|
+
format: "dc+sd-jwt",
|
|
103
|
+
meta: { vct_values: ["https://example.com/PersonCredential"] },
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Parse an openid4vp:// authorization URL
|
|
110
|
+
const request = Wallet.parseAuthorizationRequestUrl("openid4vp://authorize?...");
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Supported `openid4vp://` subset:
|
|
114
|
+
- by-value only
|
|
115
|
+
- requires `client_id`, `nonce`, and `dcql_query`
|
|
116
|
+
- rejects `request`, `request_uri`, `scope`, and Presentation Exchange input
|
|
117
|
+
|
|
118
|
+
Supported OID4VCI subset:
|
|
119
|
+
- by-value credential offers and by-reference `credential_offer_uri`
|
|
120
|
+
- pre-authorized-code flow only
|
|
121
|
+
- JWT proof only
|
|
122
|
+
- single `dc+sd-jwt` credential request + import
|
|
123
|
+
|
|
124
|
+
OID4VCI endpoint resolution:
|
|
125
|
+
- `receiveCredentialFromOffer` parses the offer input or fetches `credential_offer_uri`, then reads `credential_issuer`
|
|
126
|
+
- issuer metadata is fetched from `/.well-known/openid-credential-issuer` relative to that issuer
|
|
127
|
+
- if `credential_issuer` contains a path, that path is appended to the well-known URL
|
|
128
|
+
- the fetched metadata must repeat the same `credential_issuer`
|
|
129
|
+
- `token_endpoint` and `credential_endpoint` are taken from metadata, not hardcoded in the wallet
|
|
130
|
+
- `nonce_endpoint` is used only if the token response does not already include `c_nonce`
|
|
131
|
+
- there is no API to manually override discovered endpoints
|
|
132
|
+
|
|
133
|
+
Examples:
|
|
134
|
+
- `https://issuer.example` -> `https://issuer.example/.well-known/openid-credential-issuer`
|
|
135
|
+
- `https://issuer.example/tenant-a` -> `https://issuer.example/.well-known/openid-credential-issuer/tenant-a`
|
|
136
|
+
|
|
137
|
+
This allows issuers to use non-standard endpoint paths such as `/token` or `/credential`, as long as those exact URLs are returned in issuer metadata.
|
|
138
|
+
|
|
139
|
+
Current limitations:
|
|
140
|
+
- `credential_offer_uri` must return a supported by-value offer document
|
|
141
|
+
- issuer metadata must contain `token_endpoint`, `credential_endpoint`, `jwks`, and the requested credential configuration
|
|
142
|
+
- if the token response omits `c_nonce`, issuer metadata must provide `nonce_endpoint`
|
|
143
|
+
|
|
144
|
+
## See also
|
|
145
|
+
|
|
146
|
+
- [`@vidos-id/openid4vc-issuer`](../issuer/) - issuer library for credential issuance
|
|
147
|
+
- [`scripts/demo-e2e.ts`](../../scripts/demo-e2e.ts) - full programmatic flow using both libraries
|
|
148
|
+
|
|
149
|
+
## Test
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
bun test packages/wallet/src/wallet.test.ts
|
|
153
|
+
```
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { JWK, JWTHeaderParameters, importJWK } from "jose";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { DcqlQuery } from "dcql";
|
|
4
|
+
|
|
5
|
+
//#region src/schemas.d.ts
|
|
6
|
+
declare const JwkSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
7
|
+
declare const HolderKeyRecordSchema: z.ZodObject<{
|
|
8
|
+
id: z.ZodString;
|
|
9
|
+
algorithm: z.ZodEnum<{
|
|
10
|
+
ES256: "ES256";
|
|
11
|
+
ES384: "ES384";
|
|
12
|
+
EdDSA: "EdDSA";
|
|
13
|
+
}>;
|
|
14
|
+
publicJwk: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
15
|
+
privateJwk: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
16
|
+
createdAt: z.ZodString;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
declare const CredentialStatusListReferenceSchema: z.ZodObject<{
|
|
19
|
+
idx: z.ZodNumber;
|
|
20
|
+
uri: z.ZodString;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
declare const CredentialStatusSchema: z.ZodObject<{
|
|
23
|
+
status_list: z.ZodObject<{
|
|
24
|
+
idx: z.ZodNumber;
|
|
25
|
+
uri: z.ZodString;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
declare const StoredCredentialRecordSchema: z.ZodObject<{
|
|
29
|
+
id: z.ZodString;
|
|
30
|
+
format: z.ZodLiteral<"dc+sd-jwt">;
|
|
31
|
+
compactSdJwt: z.ZodString;
|
|
32
|
+
issuer: z.ZodString;
|
|
33
|
+
vct: z.ZodString;
|
|
34
|
+
holderKeyId: z.ZodString;
|
|
35
|
+
claims: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
36
|
+
status: z.ZodOptional<z.ZodObject<{
|
|
37
|
+
status_list: z.ZodObject<{
|
|
38
|
+
idx: z.ZodNumber;
|
|
39
|
+
uri: z.ZodString;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
}, z.core.$strip>>;
|
|
42
|
+
issuerKeyMaterial: z.ZodOptional<z.ZodLazy<z.ZodUnion<readonly [z.ZodObject<{
|
|
43
|
+
issuer: z.ZodString;
|
|
44
|
+
jwks: z.ZodObject<{
|
|
45
|
+
keys: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
48
|
+
issuer: z.ZodString;
|
|
49
|
+
jwk: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
50
|
+
}, z.core.$strip>]>>>;
|
|
51
|
+
importedAt: z.ZodString;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
declare const IssuerJwksSchema: z.ZodObject<{
|
|
54
|
+
issuer: z.ZodString;
|
|
55
|
+
jwks: z.ZodObject<{
|
|
56
|
+
keys: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
declare const IssuerJwkSchema: z.ZodObject<{
|
|
60
|
+
issuer: z.ZodString;
|
|
61
|
+
jwk: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
62
|
+
}, z.core.$strip>;
|
|
63
|
+
declare const IssuerKeyMaterialSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
64
|
+
issuer: z.ZodString;
|
|
65
|
+
jwks: z.ZodObject<{
|
|
66
|
+
keys: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
69
|
+
issuer: z.ZodString;
|
|
70
|
+
jwk: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
71
|
+
}, z.core.$strip>]>;
|
|
72
|
+
declare const ImportCredentialInputSchema: z.ZodObject<{
|
|
73
|
+
credential: z.ZodString;
|
|
74
|
+
issuer: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
75
|
+
issuer: z.ZodString;
|
|
76
|
+
jwks: z.ZodObject<{
|
|
77
|
+
keys: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
78
|
+
}, z.core.$strip>;
|
|
79
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
80
|
+
issuer: z.ZodString;
|
|
81
|
+
jwk: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
82
|
+
}, z.core.$strip>]>>;
|
|
83
|
+
}, z.core.$strip>;
|
|
84
|
+
declare const ResponseModeSchema: z.ZodEnum<{
|
|
85
|
+
direct_post: "direct_post";
|
|
86
|
+
"direct_post.jwt": "direct_post.jwt";
|
|
87
|
+
}>;
|
|
88
|
+
declare const VerifierClientMetadataSchema: z.ZodObject<{
|
|
89
|
+
jwks: z.ZodOptional<z.ZodObject<{
|
|
90
|
+
keys: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
91
|
+
}, z.core.$strip>>;
|
|
92
|
+
encrypted_response_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
93
|
+
vp_formats_supported: z.ZodOptional<z.ZodUnknown>;
|
|
94
|
+
}, z.core.$loose>;
|
|
95
|
+
declare const OpenId4VpRequestSchema: z.ZodObject<{
|
|
96
|
+
client_id: z.ZodString;
|
|
97
|
+
nonce: z.ZodString;
|
|
98
|
+
dcql_query: z.ZodUnknown;
|
|
99
|
+
state: z.ZodOptional<z.ZodString>;
|
|
100
|
+
response_type: z.ZodOptional<z.ZodLiteral<"vp_token">>;
|
|
101
|
+
response_mode: z.ZodOptional<z.ZodEnum<{
|
|
102
|
+
direct_post: "direct_post";
|
|
103
|
+
"direct_post.jwt": "direct_post.jwt";
|
|
104
|
+
}>>;
|
|
105
|
+
response_uri: z.ZodOptional<z.ZodString>;
|
|
106
|
+
client_metadata: z.ZodOptional<z.ZodObject<{
|
|
107
|
+
jwks: z.ZodOptional<z.ZodObject<{
|
|
108
|
+
keys: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
109
|
+
}, z.core.$strip>>;
|
|
110
|
+
encrypted_response_enc_values_supported: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
111
|
+
vp_formats_supported: z.ZodOptional<z.ZodUnknown>;
|
|
112
|
+
}, z.core.$loose>>;
|
|
113
|
+
scope: z.ZodOptional<z.ZodUnknown>;
|
|
114
|
+
presentation_definition: z.ZodOptional<z.ZodUnknown>;
|
|
115
|
+
}, z.core.$strip>;
|
|
116
|
+
declare const WalletConfigSchema: z.ZodObject<{
|
|
117
|
+
storage: z.ZodCustom<unknown, unknown>;
|
|
118
|
+
}, z.core.$strip>;
|
|
119
|
+
type HolderKeyRecord = z.infer<typeof HolderKeyRecordSchema>;
|
|
120
|
+
type CredentialStatus = z.infer<typeof CredentialStatusSchema>;
|
|
121
|
+
type CredentialStatusListReference = z.infer<typeof CredentialStatusListReferenceSchema>;
|
|
122
|
+
type StoredCredentialRecord = z.infer<typeof StoredCredentialRecordSchema>;
|
|
123
|
+
type IssuerKeyMaterial = z.infer<typeof IssuerKeyMaterialSchema>;
|
|
124
|
+
type ImportCredentialInput = z.infer<typeof ImportCredentialInputSchema>;
|
|
125
|
+
type OpenId4VpRequestInput = z.infer<typeof OpenId4VpRequestSchema>;
|
|
126
|
+
type VerifierClientMetadata = z.infer<typeof VerifierClientMetadataSchema>;
|
|
127
|
+
type ParsedDcqlQuery = ReturnType<typeof DcqlQuery.parse>;
|
|
128
|
+
//#endregion
|
|
129
|
+
//#region src/crypto.d.ts
|
|
130
|
+
declare const HOLDER_KEY_ALG = "ES256";
|
|
131
|
+
declare const SD_JWT_HASH_ALG = "sha-256";
|
|
132
|
+
type ImportedJwkKey = Awaited<ReturnType<typeof importJWK>>;
|
|
133
|
+
declare function sha256Base64Url(input: string): Promise<string>;
|
|
134
|
+
declare function sdJwtHasher(data: string | ArrayBuffer, alg: string): Promise<Uint8Array>;
|
|
135
|
+
declare function createHolderKeyRecord(alg?: HolderKeyRecord["algorithm"]): Promise<HolderKeyRecord>;
|
|
136
|
+
declare function getJwkThumbprint(jwk: JWK): Promise<string>;
|
|
137
|
+
declare function importPrivateKey(jwk: JWK, alg?: string): Promise<ImportedJwkKey>;
|
|
138
|
+
declare function importPublicKey(jwk: JWK, alg: string): Promise<ImportedJwkKey>;
|
|
139
|
+
declare function createKbJwt(input: {
|
|
140
|
+
holderPrivateJwk: JWK;
|
|
141
|
+
aud: string;
|
|
142
|
+
nonce: string;
|
|
143
|
+
sdJwtPresentation: string;
|
|
144
|
+
alg?: string;
|
|
145
|
+
}): Promise<string>;
|
|
146
|
+
declare function createOpenId4VciProofJwt(input: {
|
|
147
|
+
holderPrivateJwk: JWK;
|
|
148
|
+
holderPublicJwk: JWK;
|
|
149
|
+
aud: string;
|
|
150
|
+
nonce: string;
|
|
151
|
+
alg?: string;
|
|
152
|
+
}): Promise<string>;
|
|
153
|
+
declare function issueDemoCredential(input: {
|
|
154
|
+
issuer: string;
|
|
155
|
+
issuerPrivateJwk: JWK;
|
|
156
|
+
issuerAlg?: string;
|
|
157
|
+
issuerKid?: string;
|
|
158
|
+
holderPublicJwk: JWK;
|
|
159
|
+
vct: string;
|
|
160
|
+
claims: Record<string, unknown>;
|
|
161
|
+
disclosureFrame?: Record<string, unknown>;
|
|
162
|
+
headers?: JWTHeaderParameters;
|
|
163
|
+
issuedAt?: number;
|
|
164
|
+
saltGenerator?: (length: number) => Promise<string>;
|
|
165
|
+
}): Promise<string>;
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/storage.d.ts
|
|
168
|
+
interface WalletStorage {
|
|
169
|
+
getHolderKey(): Promise<HolderKeyRecord | null>;
|
|
170
|
+
setHolderKey(record: HolderKeyRecord): Promise<void>;
|
|
171
|
+
listCredentials(): Promise<StoredCredentialRecord[]>;
|
|
172
|
+
getCredential(id: string): Promise<StoredCredentialRecord | null>;
|
|
173
|
+
setCredential(record: StoredCredentialRecord): Promise<void>;
|
|
174
|
+
}
|
|
175
|
+
declare class InMemoryWalletStorage implements WalletStorage {
|
|
176
|
+
private holderKey;
|
|
177
|
+
private readonly credentials;
|
|
178
|
+
getHolderKey(): Promise<HolderKeyRecord | null>;
|
|
179
|
+
setHolderKey(record: HolderKeyRecord): Promise<void>;
|
|
180
|
+
listCredentials(): Promise<StoredCredentialRecord[]>;
|
|
181
|
+
getCredential(id: string): Promise<StoredCredentialRecord | null>;
|
|
182
|
+
setCredential(record: StoredCredentialRecord): Promise<void>;
|
|
183
|
+
}
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region src/wallet.d.ts
|
|
186
|
+
declare class WalletError extends Error {
|
|
187
|
+
constructor(message: string);
|
|
188
|
+
}
|
|
189
|
+
type MatchedCredential = {
|
|
190
|
+
queryId: string;
|
|
191
|
+
credentialId: string;
|
|
192
|
+
issuer: string;
|
|
193
|
+
vct: string;
|
|
194
|
+
claims: Record<string, unknown>;
|
|
195
|
+
claimPaths: Array<Array<string | number | null>>;
|
|
196
|
+
};
|
|
197
|
+
type QueryCredentialMatches = {
|
|
198
|
+
queryId: string;
|
|
199
|
+
credentials: MatchedCredential[];
|
|
200
|
+
};
|
|
201
|
+
type MatchDcqlQueryResult = {
|
|
202
|
+
query: ParsedDcqlQuery;
|
|
203
|
+
credentials: MatchedCredential[];
|
|
204
|
+
};
|
|
205
|
+
type InspectDcqlQueryResult = {
|
|
206
|
+
query: ParsedDcqlQuery;
|
|
207
|
+
queries: QueryCredentialMatches[];
|
|
208
|
+
};
|
|
209
|
+
type CreatePresentationResult = {
|
|
210
|
+
query: ParsedDcqlQuery;
|
|
211
|
+
vpToken: string;
|
|
212
|
+
dcqlPresentation: Record<string, string[]>;
|
|
213
|
+
matchedCredentials: MatchedCredential[];
|
|
214
|
+
};
|
|
215
|
+
type TokenStatusLabel = "VALID" | "INVALID" | "SUSPENDED" | "APPLICATION_SPECIFIC" | "UNASSIGNED";
|
|
216
|
+
type ResolvedCredentialStatus = {
|
|
217
|
+
credentialId: string;
|
|
218
|
+
statusReference: CredentialStatus["status_list"];
|
|
219
|
+
status: {
|
|
220
|
+
value: number;
|
|
221
|
+
label: TokenStatusLabel;
|
|
222
|
+
isValid: boolean;
|
|
223
|
+
};
|
|
224
|
+
statusList: {
|
|
225
|
+
uri: string;
|
|
226
|
+
bits: 1 | 2 | 4 | 8;
|
|
227
|
+
iat: number;
|
|
228
|
+
exp?: number;
|
|
229
|
+
ttl?: number;
|
|
230
|
+
aggregationUri?: string;
|
|
231
|
+
jwt: string;
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
declare class Wallet {
|
|
235
|
+
private readonly storage;
|
|
236
|
+
constructor(storage: WalletStorage);
|
|
237
|
+
getOrCreateHolderKey(alg?: HolderKeyRecord["algorithm"]): Promise<HolderKeyRecord>;
|
|
238
|
+
importHolderKey(input: {
|
|
239
|
+
privateJwk: Record<string, unknown>;
|
|
240
|
+
publicJwk: Record<string, unknown>;
|
|
241
|
+
algorithm: string;
|
|
242
|
+
}): Promise<HolderKeyRecord>;
|
|
243
|
+
listCredentials(): Promise<StoredCredentialRecord[]>;
|
|
244
|
+
getCredentialStatus(credentialId: string, options?: {
|
|
245
|
+
fetch?: typeof fetch;
|
|
246
|
+
}): Promise<ResolvedCredentialStatus | null>;
|
|
247
|
+
getVpFormatsSupported(): {
|
|
248
|
+
"dc+sd-jwt": {
|
|
249
|
+
kb_jwt_alg_values: string[];
|
|
250
|
+
sd_jwt_alg_values: string[];
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
importCredential(input: ImportCredentialInput): Promise<StoredCredentialRecord>;
|
|
254
|
+
matchDcqlQuery(input: OpenId4VpRequestInput): Promise<MatchDcqlQueryResult>;
|
|
255
|
+
inspectDcqlQuery(input: OpenId4VpRequestInput): Promise<InspectDcqlQueryResult>;
|
|
256
|
+
createPresentation(input: OpenId4VpRequestInput, options?: {
|
|
257
|
+
selectedCredentials?: Record<string, string>;
|
|
258
|
+
}): Promise<CreatePresentationResult>;
|
|
259
|
+
}
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region src/openid4vci.d.ts
|
|
262
|
+
declare const credentialOfferSchema: z.ZodObject<{
|
|
263
|
+
credential_issuer: z.ZodString;
|
|
264
|
+
credential_configuration_ids: z.ZodArray<z.ZodString>;
|
|
265
|
+
grants: z.ZodObject<{
|
|
266
|
+
"urn:ietf:params:oauth:grant-type:pre-authorized_code": z.ZodObject<{
|
|
267
|
+
"pre-authorized_code": z.ZodString;
|
|
268
|
+
tx_code: z.ZodOptional<z.ZodNever>;
|
|
269
|
+
}, z.core.$strip>;
|
|
270
|
+
}, z.core.$strip>;
|
|
271
|
+
}, z.core.$strip>;
|
|
272
|
+
declare const issuerMetadataSchema: z.ZodObject<{
|
|
273
|
+
credential_issuer: z.ZodString;
|
|
274
|
+
token_endpoint: z.ZodString;
|
|
275
|
+
credential_endpoint: z.ZodString;
|
|
276
|
+
nonce_endpoint: z.ZodOptional<z.ZodString>;
|
|
277
|
+
jwks: z.ZodObject<{
|
|
278
|
+
keys: z.ZodArray<z.ZodObject<{
|
|
279
|
+
kty: z.ZodString;
|
|
280
|
+
kid: z.ZodOptional<z.ZodString>;
|
|
281
|
+
alg: z.ZodOptional<z.ZodString>;
|
|
282
|
+
crv: z.ZodOptional<z.ZodString>;
|
|
283
|
+
x: z.ZodOptional<z.ZodString>;
|
|
284
|
+
y: z.ZodOptional<z.ZodString>;
|
|
285
|
+
d: z.ZodOptional<z.ZodString>;
|
|
286
|
+
n: z.ZodOptional<z.ZodString>;
|
|
287
|
+
e: z.ZodOptional<z.ZodString>;
|
|
288
|
+
x5c: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
289
|
+
}, z.core.$catchall<z.ZodUnknown>>>;
|
|
290
|
+
}, z.core.$strip>;
|
|
291
|
+
credential_configurations_supported: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
292
|
+
format: z.ZodLiteral<"dc+sd-jwt">;
|
|
293
|
+
vct: z.ZodString;
|
|
294
|
+
scope: z.ZodString;
|
|
295
|
+
proof_types_supported: z.ZodObject<{
|
|
296
|
+
jwt: z.ZodObject<{
|
|
297
|
+
proof_signing_alg_values_supported: z.ZodArray<z.ZodString>;
|
|
298
|
+
}, z.core.$strip>;
|
|
299
|
+
}, z.core.$strip>;
|
|
300
|
+
credential_signing_alg_values_supported: z.ZodArray<z.ZodString>;
|
|
301
|
+
}, z.core.$strip>>;
|
|
302
|
+
}, z.core.$strip>;
|
|
303
|
+
type OpenId4VciCredentialOffer = z.infer<typeof credentialOfferSchema>;
|
|
304
|
+
type OpenId4VciIssuerMetadata = z.infer<typeof issuerMetadataSchema>;
|
|
305
|
+
declare function parseCredentialOffer(input: unknown): OpenId4VciCredentialOffer;
|
|
306
|
+
declare function fetchIssuerMetadata(credentialIssuer: string, options?: {
|
|
307
|
+
fetch?: typeof fetch;
|
|
308
|
+
}): Promise<OpenId4VciIssuerMetadata>;
|
|
309
|
+
declare function receiveCredentialFromOffer(wallet: Wallet, offerInput: unknown, options?: {
|
|
310
|
+
fetch?: typeof fetch;
|
|
311
|
+
}): Promise<StoredCredentialRecord>;
|
|
312
|
+
//#endregion
|
|
313
|
+
//#region src/openid4vp.d.ts
|
|
314
|
+
type OpenId4VpAuthorizationResponse = {
|
|
315
|
+
vp_token: string;
|
|
316
|
+
state?: string;
|
|
317
|
+
};
|
|
318
|
+
type OpenId4VpResponseSubmissionResult = {
|
|
319
|
+
responseMode: "direct_post" | "direct_post.jwt";
|
|
320
|
+
responseUri: string;
|
|
321
|
+
status: number;
|
|
322
|
+
body?: unknown;
|
|
323
|
+
redirectUri?: string;
|
|
324
|
+
};
|
|
325
|
+
declare function parseOpenid4VpAuthorizationUrl(input: string): Promise<OpenId4VpRequestInput>;
|
|
326
|
+
declare function resolveOpenId4VpRequest(input: unknown): Promise<OpenId4VpRequestInput>;
|
|
327
|
+
declare function createOpenId4VpAuthorizationResponse(request: OpenId4VpRequestInput, presentation: CreatePresentationResult): OpenId4VpAuthorizationResponse;
|
|
328
|
+
declare function submitOpenId4VpAuthorizationResponse(request: OpenId4VpRequestInput, response: OpenId4VpAuthorizationResponse): Promise<OpenId4VpResponseSubmissionResult>;
|
|
329
|
+
//#endregion
|
|
330
|
+
export { CreatePresentationResult, CredentialStatus, CredentialStatusListReference, CredentialStatusListReferenceSchema, CredentialStatusSchema, HOLDER_KEY_ALG, HolderKeyRecord, HolderKeyRecordSchema, ImportCredentialInput, ImportCredentialInputSchema, InMemoryWalletStorage, InspectDcqlQueryResult, IssuerJwkSchema, IssuerJwksSchema, IssuerKeyMaterial, IssuerKeyMaterialSchema, JwkSchema, MatchDcqlQueryResult, MatchedCredential, OpenId4VciCredentialOffer, OpenId4VciIssuerMetadata, OpenId4VpAuthorizationResponse, OpenId4VpRequestInput, OpenId4VpRequestSchema, OpenId4VpResponseSubmissionResult, ParsedDcqlQuery, QueryCredentialMatches, ResolvedCredentialStatus, ResponseModeSchema, SD_JWT_HASH_ALG, StoredCredentialRecord, StoredCredentialRecordSchema, TokenStatusLabel, VerifierClientMetadata, VerifierClientMetadataSchema, Wallet, WalletConfigSchema, WalletError, WalletStorage, createHolderKeyRecord, createKbJwt, createOpenId4VciProofJwt, createOpenId4VpAuthorizationResponse, fetchIssuerMetadata, getJwkThumbprint, importPrivateKey, importPublicKey, issueDemoCredential, parseCredentialOffer, parseOpenid4VpAuthorizationUrl, receiveCredentialFromOffer, resolveOpenId4VpRequest, sdJwtHasher, sha256Base64Url, submitOpenId4VpAuthorizationResponse };
|