@eudiplo/sdk-core 1.14.0-main.0f12c71
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 +271 -0
- package/dist/api/index.d.mts +3125 -0
- package/dist/api/index.d.ts +3125 -0
- package/dist/api/index.js +1395 -0
- package/dist/api/index.mjs +1307 -0
- package/dist/index.d.mts +297 -0
- package/dist/index.d.ts +297 -0
- package/dist/index.js +1668 -0
- package/dist/index.mjs +1575 -0
- package/package.json +63 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { Session } from './api/index.mjs';
|
|
2
|
+
export { AllowListPolicy, ApiKeyConfig, AppControllerMainData, AppControllerMainResponses, AttestationBasedPolicy, AuthControllerGetGlobalJwksData, AuthControllerGetGlobalJwksResponses, AuthControllerGetOAuth2TokenData, AuthControllerGetOAuth2TokenErrors, AuthControllerGetOAuth2TokenResponse, AuthControllerGetOAuth2TokenResponses, AuthControllerGetOidcDiscoveryData, AuthControllerGetOidcDiscoveryResponses, AuthenticationMethodAuth, AuthenticationMethodNone, AuthenticationMethodPresentation, AuthenticationUrlConfig, AuthorizationResponse, AuthorizeControllerAuthorizationChallengeEndpointData, AuthorizeControllerAuthorizationChallengeEndpointResponses, AuthorizeControllerAuthorizeData, AuthorizeControllerAuthorizeResponses, AuthorizeControllerParData, AuthorizeControllerParResponse, AuthorizeControllerParResponses, AuthorizeControllerTokenData, AuthorizeControllerTokenResponse, AuthorizeControllerTokenResponses, AuthorizeQueries, CertControllerAddCertificateData, CertControllerAddCertificateResponse, CertControllerAddCertificateResponses, CertControllerDeleteCertificateData, CertControllerDeleteCertificateResponses, CertControllerExportConfigData, CertControllerExportConfigResponse, CertControllerExportConfigResponses, CertControllerGetCertificateData, CertControllerGetCertificateResponse, CertControllerGetCertificateResponses, CertControllerGetCertificatesData, CertControllerGetCertificatesResponse, CertControllerGetCertificatesResponses, CertControllerUpdateCertificateData, CertControllerUpdateCertificateResponses, CertEntity, CertImportDto, CertResponseDto, CertUpdateDto, CertUsageEntity, Claim, ClaimsQuery, ClientControllerCreateClientData, ClientControllerCreateClientResponse, ClientControllerCreateClientResponses, ClientControllerDeleteClientData, ClientControllerDeleteClientResponses, ClientControllerGetClientData, ClientControllerGetClientResponse, ClientControllerGetClientResponses, ClientControllerGetClientSecretData, ClientControllerGetClientSecretResponse, ClientControllerGetClientSecretResponses, ClientControllerGetClientsData, ClientControllerGetClientsResponse, ClientControllerGetClientsResponses, ClientControllerUpdateClientData, ClientControllerUpdateClientResponse, ClientControllerUpdateClientResponses, ClientCredentialsDto, ClientEntity, ClientOptions, ClientSecretResponseDto, CreateClientDto, CreateStatusListDto, CreateTenantDto, CredentialConfig, CredentialConfigControllerDeleteIssuanceConfigurationData, CredentialConfigControllerDeleteIssuanceConfigurationResponses, CredentialConfigControllerGetConfigByIdData, CredentialConfigControllerGetConfigByIdResponse, CredentialConfigControllerGetConfigByIdResponses, CredentialConfigControllerGetConfigsData, CredentialConfigControllerGetConfigsResponse, CredentialConfigControllerGetConfigsResponses, CredentialConfigControllerStoreCredentialConfigurationData, CredentialConfigControllerStoreCredentialConfigurationResponse, CredentialConfigControllerStoreCredentialConfigurationResponses, CredentialConfigControllerUpdateCredentialConfigurationData, CredentialConfigControllerUpdateCredentialConfigurationResponse, CredentialConfigControllerUpdateCredentialConfigurationResponses, CredentialConfigCreate, CredentialConfigUpdate, CredentialOfferControllerGetOfferData, CredentialOfferControllerGetOfferResponse, CredentialOfferControllerGetOfferResponses, CredentialQuery, CredentialSetQuery, Dcql, Display, DisplayImage, DisplayInfo, DisplayLogo, EcPublic, EmbeddedDisclosurePolicy, FileUploadDto, HealthControllerCheckData, HealthControllerCheckError, HealthControllerCheckErrors, HealthControllerCheckResponse, HealthControllerCheckResponses, ImportTenantDto, IssuanceConfig, IssuanceConfigControllerGetIssuanceConfigurationsData, IssuanceConfigControllerGetIssuanceConfigurationsResponse, IssuanceConfigControllerGetIssuanceConfigurationsResponses, IssuanceConfigControllerStoreIssuanceConfigurationData, IssuanceConfigControllerStoreIssuanceConfigurationResponse, IssuanceConfigControllerStoreIssuanceConfigurationResponses, IssuanceDto, IssuerMetadataCredentialConfig, JwksResponseDto, Key, KeyControllerAddKeyData, KeyControllerAddKeyResponses, KeyControllerDeleteKeyData, KeyControllerDeleteKeyResponses, KeyControllerGetKeyData, KeyControllerGetKeyResponse, KeyControllerGetKeyResponses, KeyControllerGetKeysData, KeyControllerGetKeysResponse, KeyControllerGetKeysResponses, KeyControllerUpdateKeyData, KeyControllerUpdateKeyResponses, KeyEntity, KeyImportDto, NoneTrustPolicy, NotificationRequestDto, OfferRequestDto, OfferResponse, Oid4VciControllerCredentialData, Oid4VciControllerCredentialResponses, Oid4VciControllerNonceData, Oid4VciControllerNonceResponses, Oid4VciControllerNotificationsData, Oid4VciControllerNotificationsResponses, Oid4VciMetadataControllerVctData, Oid4VciMetadataControllerVctResponse, Oid4VciMetadataControllerVctResponses, Oid4VpControllerGetPostRequestWithSessionData, Oid4VpControllerGetPostRequestWithSessionResponse, Oid4VpControllerGetPostRequestWithSessionResponses, Oid4VpControllerGetRequestWithSessionData, Oid4VpControllerGetRequestWithSessionResponse, Oid4VpControllerGetRequestWithSessionResponses, Oid4VpControllerGetResponseData, Oid4VpControllerGetResponseResponse, Oid4VpControllerGetResponseResponses, Options, ParResponseDto, PolicyCredential, PresentationAttachment, PresentationConfig, PresentationConfigCreateDto, PresentationConfigUpdateDto, PresentationDuringIssuanceConfig, PresentationManagementControllerConfigurationData, PresentationManagementControllerConfigurationResponse, PresentationManagementControllerConfigurationResponses, PresentationManagementControllerDeleteConfigurationData, PresentationManagementControllerDeleteConfigurationResponses, PresentationManagementControllerGetConfigurationData, PresentationManagementControllerGetConfigurationResponse, PresentationManagementControllerGetConfigurationResponses, PresentationManagementControllerStorePresentationConfigData, PresentationManagementControllerStorePresentationConfigResponse, PresentationManagementControllerStorePresentationConfigResponses, PresentationManagementControllerUpdateConfigurationData, PresentationManagementControllerUpdateConfigurationResponse, PresentationManagementControllerUpdateConfigurationResponses, PresentationRequest, PrometheusControllerIndexData, PrometheusControllerIndexResponses, RegistrationCertificateRequest, RoleDto, RootOfTrustPolicy, SchemaResponse, SessionConfigControllerGetConfigData, SessionConfigControllerGetConfigResponse, SessionConfigControllerGetConfigResponses, SessionConfigControllerResetConfigData, SessionConfigControllerResetConfigResponses, SessionConfigControllerUpdateConfigData, SessionConfigControllerUpdateConfigResponse, SessionConfigControllerUpdateConfigResponses, SessionControllerDeleteSessionData, SessionControllerDeleteSessionResponses, SessionControllerGetAllSessionsData, SessionControllerGetAllSessionsResponse, SessionControllerGetAllSessionsResponses, SessionControllerGetSessionData, SessionControllerGetSessionResponse, SessionControllerGetSessionResponses, SessionControllerRevokeAllData, SessionControllerRevokeAllResponses, SessionStorageConfig, StatusListAggregationDto, StatusListConfig, StatusListConfigControllerGetConfigData, StatusListConfigControllerGetConfigResponse, StatusListConfigControllerGetConfigResponses, StatusListConfigControllerResetConfigData, StatusListConfigControllerResetConfigResponse, StatusListConfigControllerResetConfigResponses, StatusListConfigControllerUpdateConfigData, StatusListConfigControllerUpdateConfigResponse, StatusListConfigControllerUpdateConfigResponses, StatusListControllerGetListData, StatusListControllerGetListResponse, StatusListControllerGetListResponses, StatusListControllerGetStatusListAggregationData, StatusListControllerGetStatusListAggregationResponse, StatusListControllerGetStatusListAggregationResponses, StatusListImportDto, StatusListManagementControllerCreateListData, StatusListManagementControllerCreateListResponse, StatusListManagementControllerCreateListResponses, StatusListManagementControllerDeleteListData, StatusListManagementControllerDeleteListResponse, StatusListManagementControllerDeleteListResponses, StatusListManagementControllerGetListData, StatusListManagementControllerGetListResponse, StatusListManagementControllerGetListResponses, StatusListManagementControllerGetListsData, StatusListManagementControllerGetListsResponse, StatusListManagementControllerGetListsResponses, StatusListManagementControllerUpdateListData, StatusListManagementControllerUpdateListResponse, StatusListManagementControllerUpdateListResponses, StatusListResponseDto, StatusUpdateDto, StorageControllerDownloadData, StorageControllerDownloadResponses, StorageControllerUploadData, StorageControllerUploadResponse, StorageControllerUploadResponses, TenantControllerDeleteTenantData, TenantControllerDeleteTenantResponses, TenantControllerGetTenantData, TenantControllerGetTenantResponse, TenantControllerGetTenantResponses, TenantControllerGetTenantsData, TenantControllerGetTenantsResponse, TenantControllerGetTenantsResponses, TenantControllerInitTenantData, TenantControllerInitTenantResponses, TenantControllerUpdateTenantData, TenantControllerUpdateTenantResponse, TenantControllerUpdateTenantResponses, TenantEntity, TokenResponse, TrustList, TrustListControllerCreateTrustListData, TrustListControllerCreateTrustListResponse, TrustListControllerCreateTrustListResponses, TrustListControllerDeleteTrustListData, TrustListControllerDeleteTrustListResponses, TrustListControllerExportTrustListData, TrustListControllerExportTrustListResponse, TrustListControllerExportTrustListResponses, TrustListControllerGetAllTrustListsData, TrustListControllerGetAllTrustListsResponse, TrustListControllerGetAllTrustListsResponses, TrustListControllerGetTrustListData, TrustListControllerGetTrustListResponse, TrustListControllerGetTrustListResponses, TrustListControllerGetTrustListVersionData, TrustListControllerGetTrustListVersionResponse, TrustListControllerGetTrustListVersionResponses, TrustListControllerGetTrustListVersionsData, TrustListControllerGetTrustListVersionsResponse, TrustListControllerGetTrustListVersionsResponses, TrustListControllerUpdateTrustListData, TrustListControllerUpdateTrustListResponse, TrustListControllerUpdateTrustListResponses, TrustListCreateDto, TrustListPublicControllerGetTrustListJwtData, TrustListPublicControllerGetTrustListJwtResponse, TrustListPublicControllerGetTrustListJwtResponses, TrustListVersion, TrustedAuthorityQuery, UpdateClientDto, UpdateKeyDto, UpdateSessionConfigDto, UpdateStatusListConfigDto, UpdateStatusListDto, UpdateTenantDto, Vct, VerifierOfferControllerGetOfferData, VerifierOfferControllerGetOfferResponse, VerifierOfferControllerGetOfferResponses, WebHookAuthConfigHeader, WebHookAuthConfigNone, WebhookConfig, WellKnownControllerAuthzMetadata0Data, WellKnownControllerAuthzMetadata0Responses, WellKnownControllerAuthzMetadata1Data, WellKnownControllerAuthzMetadata1Responses, WellKnownControllerGetJwks0Data, WellKnownControllerGetJwks0Response, WellKnownControllerGetJwks0Responses, WellKnownControllerGetJwks1Data, WellKnownControllerGetJwks1Response, WellKnownControllerGetJwks1Responses, WellKnownControllerIssuerMetadata0Data, WellKnownControllerIssuerMetadata0Response, WellKnownControllerIssuerMetadata0Responses, WellKnownControllerIssuerMetadata1Data, WellKnownControllerIssuerMetadata1Response, WellKnownControllerIssuerMetadata1Responses, appControllerMain, authControllerGetGlobalJwks, authControllerGetOAuth2Token, authControllerGetOidcDiscovery, authorizeControllerAuthorizationChallengeEndpoint, authorizeControllerAuthorize, authorizeControllerPar, authorizeControllerToken, certControllerAddCertificate, certControllerDeleteCertificate, certControllerExportConfig, certControllerGetCertificate, certControllerGetCertificates, certControllerUpdateCertificate, clientControllerCreateClient, clientControllerDeleteClient, clientControllerGetClient, clientControllerGetClientSecret, clientControllerGetClients, clientControllerUpdateClient, credentialConfigControllerDeleteIssuanceConfiguration, credentialConfigControllerGetConfigById, credentialConfigControllerGetConfigs, credentialConfigControllerStoreCredentialConfiguration, credentialConfigControllerUpdateCredentialConfiguration, credentialOfferControllerGetOffer, healthControllerCheck, issuanceConfigControllerGetIssuanceConfigurations, issuanceConfigControllerStoreIssuanceConfiguration, keyControllerAddKey, keyControllerDeleteKey, keyControllerGetKey, keyControllerGetKeys, keyControllerUpdateKey, oid4VciControllerCredential, oid4VciControllerNonce, oid4VciControllerNotifications, oid4VciMetadataControllerVct, oid4VpControllerGetPostRequestWithSession, oid4VpControllerGetRequestWithSession, oid4VpControllerGetResponse, presentationManagementControllerConfiguration, presentationManagementControllerDeleteConfiguration, presentationManagementControllerGetConfiguration, presentationManagementControllerStorePresentationConfig, presentationManagementControllerUpdateConfiguration, prometheusControllerIndex, sessionConfigControllerGetConfig, sessionConfigControllerResetConfig, sessionConfigControllerUpdateConfig, sessionControllerDeleteSession, sessionControllerGetAllSessions, sessionControllerGetSession, sessionControllerRevokeAll, statusListConfigControllerGetConfig, statusListConfigControllerResetConfig, statusListConfigControllerUpdateConfig, statusListControllerGetList, statusListControllerGetStatusListAggregation, statusListManagementControllerCreateList, statusListManagementControllerDeleteList, statusListManagementControllerGetList, statusListManagementControllerGetLists, statusListManagementControllerUpdateList, storageControllerDownload, storageControllerUpload, tenantControllerDeleteTenant, tenantControllerGetTenant, tenantControllerGetTenants, tenantControllerInitTenant, tenantControllerUpdateTenant, trustListControllerCreateTrustList, trustListControllerDeleteTrustList, trustListControllerExportTrustList, trustListControllerGetAllTrustLists, trustListControllerGetTrustList, trustListControllerGetTrustListVersion, trustListControllerGetTrustListVersions, trustListControllerUpdateTrustList, trustListPublicControllerGetTrustListJwt, verifierOfferControllerGetOffer, wellKnownControllerAuthzMetadata0, wellKnownControllerAuthzMetadata1, wellKnownControllerGetJwks0, wellKnownControllerGetJwks1, wellKnownControllerIssuerMetadata0, wellKnownControllerIssuerMetadata1 } from './api/index.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Configuration options for the EudiploClient
|
|
6
|
+
*/
|
|
7
|
+
interface EudiploClientConfig {
|
|
8
|
+
/** Base URL of the EUDIPLO server (e.g., 'https://eudiplo.example.com') */
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
/** OAuth2 client ID */
|
|
11
|
+
clientId: string;
|
|
12
|
+
/** OAuth2 client secret */
|
|
13
|
+
clientSecret: string;
|
|
14
|
+
/** Optional: Auto-refresh token before expiry (default: true) */
|
|
15
|
+
autoRefresh?: boolean;
|
|
16
|
+
/** Optional: Custom fetch implementation (useful for Cloudflare Workers) */
|
|
17
|
+
fetch?: typeof fetch;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Options for session polling
|
|
21
|
+
*/
|
|
22
|
+
interface SessionPollingOptions {
|
|
23
|
+
/** Polling interval in milliseconds (default: 1000) */
|
|
24
|
+
interval?: number;
|
|
25
|
+
/** Maximum time to wait in milliseconds (default: 300000 = 5 minutes) */
|
|
26
|
+
timeout?: number;
|
|
27
|
+
/** Callback on each poll */
|
|
28
|
+
onUpdate?: (session: Session) => void;
|
|
29
|
+
/** AbortSignal to cancel polling */
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Simplified options for creating an issuance offer
|
|
34
|
+
*/
|
|
35
|
+
interface IssuanceOfferOptions {
|
|
36
|
+
/** Credential configuration IDs to issue */
|
|
37
|
+
credentialConfigurationIds: string[];
|
|
38
|
+
/** Claims to include in the credentials (keyed by config ID) */
|
|
39
|
+
claims?: Record<string, Record<string, unknown>>;
|
|
40
|
+
/** Response type: 'qrcode' returns a data URL, 'uri' returns the offer URI */
|
|
41
|
+
responseType?: 'qrcode' | 'uri' | 'dc-api';
|
|
42
|
+
/** Transaction code for pre-authorized flow */
|
|
43
|
+
txCode?: string;
|
|
44
|
+
/** Flow type (default: 'pre_authorized_code') */
|
|
45
|
+
flow?: 'authorization_code' | 'pre_authorized_code';
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Simplified options for creating a presentation request
|
|
49
|
+
*/
|
|
50
|
+
interface PresentationRequestOptions {
|
|
51
|
+
/** ID of the presentation configuration */
|
|
52
|
+
configId: string;
|
|
53
|
+
/** Response type: 'qrcode' returns a data URL, 'uri' returns the request URI */
|
|
54
|
+
responseType?: 'qrcode' | 'uri' | 'dc-api';
|
|
55
|
+
/** Optional redirect URI after presentation completes */
|
|
56
|
+
redirectUri?: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Result of creating an offer or request
|
|
60
|
+
*/
|
|
61
|
+
interface OfferResult {
|
|
62
|
+
/** The URI to encode in a QR code or use directly */
|
|
63
|
+
uri: string;
|
|
64
|
+
/** Session ID for polling */
|
|
65
|
+
sessionId: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Framework-agnostic EUDIPLO client for demos and integrations.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* import { EudiploClient } from '@eudiplo/sdk-core';
|
|
73
|
+
*
|
|
74
|
+
* const client = new EudiploClient({
|
|
75
|
+
* baseUrl: 'https://eudiplo.example.com',
|
|
76
|
+
* clientId: 'my-demo',
|
|
77
|
+
* clientSecret: 'secret123'
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* // Create a presentation request for age verification
|
|
81
|
+
* const { uri, sessionId } = await client.createPresentationRequest({
|
|
82
|
+
* configId: 'age-over-18'
|
|
83
|
+
* });
|
|
84
|
+
*
|
|
85
|
+
* // Display QR code with `uri`, then wait for completion
|
|
86
|
+
* const session = await client.waitForSession(sessionId);
|
|
87
|
+
* console.log('Verified:', session.credentials);
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
declare class EudiploClient {
|
|
91
|
+
private config;
|
|
92
|
+
private accessToken?;
|
|
93
|
+
private tokenExpiresAt?;
|
|
94
|
+
private refreshPromise?;
|
|
95
|
+
constructor(config: EudiploClientConfig);
|
|
96
|
+
/**
|
|
97
|
+
* Authenticate and obtain an access token.
|
|
98
|
+
* Called automatically by other methods, but can be called explicitly.
|
|
99
|
+
*/
|
|
100
|
+
authenticate(): Promise<void>;
|
|
101
|
+
private _doAuthenticate;
|
|
102
|
+
/**
|
|
103
|
+
* Ensure we have a valid access token, refreshing if necessary.
|
|
104
|
+
*/
|
|
105
|
+
private ensureAuthenticated;
|
|
106
|
+
/**
|
|
107
|
+
* Create a credential issuance offer.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* const { uri, sessionId } = await client.createIssuanceOffer({
|
|
112
|
+
* credentialConfigurationIds: ['PID'],
|
|
113
|
+
* claims: {
|
|
114
|
+
* PID: { given_name: 'John', family_name: 'Doe' }
|
|
115
|
+
* }
|
|
116
|
+
* });
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
createIssuanceOffer(options: IssuanceOfferOptions): Promise<OfferResult>;
|
|
120
|
+
/**
|
|
121
|
+
* Create a presentation request (for verification).
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* // Age verification
|
|
126
|
+
* const { uri, sessionId } = await client.createPresentationRequest({
|
|
127
|
+
* configId: 'age-over-18'
|
|
128
|
+
* });
|
|
129
|
+
*
|
|
130
|
+
* // Show QR code, wait for wallet to respond
|
|
131
|
+
* const session = await client.waitForSession(sessionId);
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
createPresentationRequest(options: PresentationRequestOptions): Promise<OfferResult>;
|
|
135
|
+
/**
|
|
136
|
+
* Get the current status of a session.
|
|
137
|
+
*/
|
|
138
|
+
getSession(sessionId: string): Promise<Session>;
|
|
139
|
+
/**
|
|
140
|
+
* Wait for a session to complete (polling).
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* const session = await client.waitForSession(sessionId, {
|
|
145
|
+
* interval: 1000,
|
|
146
|
+
* timeout: 60000,
|
|
147
|
+
* onUpdate: (s) => console.log('Status:', s.status)
|
|
148
|
+
* });
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
waitForSession(sessionId: string, options?: SessionPollingOptions): Promise<Session>;
|
|
152
|
+
/**
|
|
153
|
+
* Helper to sleep with abort support
|
|
154
|
+
*/
|
|
155
|
+
private sleep;
|
|
156
|
+
/**
|
|
157
|
+
* Get the current access token (for advanced usage)
|
|
158
|
+
*/
|
|
159
|
+
getAccessToken(): string | undefined;
|
|
160
|
+
/**
|
|
161
|
+
* Get the configured base URL
|
|
162
|
+
*/
|
|
163
|
+
getBaseUrl(): string;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Credentials for EUDIPLO authentication
|
|
167
|
+
*/
|
|
168
|
+
interface EudiploCredentials {
|
|
169
|
+
baseUrl: string;
|
|
170
|
+
clientId: string;
|
|
171
|
+
clientSecret: string;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Options for the verify function
|
|
175
|
+
*/
|
|
176
|
+
interface VerifyOptions extends EudiploCredentials {
|
|
177
|
+
/** Presentation configuration ID */
|
|
178
|
+
configId: string;
|
|
179
|
+
/** Optional redirect URI */
|
|
180
|
+
redirectUri?: string;
|
|
181
|
+
/** Polling options */
|
|
182
|
+
polling?: SessionPollingOptions;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Options for the issue function
|
|
186
|
+
*/
|
|
187
|
+
interface IssueOptions extends EudiploCredentials {
|
|
188
|
+
/** Credential configuration IDs */
|
|
189
|
+
credentialConfigurationIds: string[];
|
|
190
|
+
/** Claims per credential config */
|
|
191
|
+
claims?: Record<string, Record<string, unknown>>;
|
|
192
|
+
/** Transaction code (optional) */
|
|
193
|
+
txCode?: string;
|
|
194
|
+
/** Polling options */
|
|
195
|
+
polling?: SessionPollingOptions;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Result of a verification or issuance flow
|
|
199
|
+
*/
|
|
200
|
+
interface FlowResult {
|
|
201
|
+
/** URI for QR code */
|
|
202
|
+
uri: string;
|
|
203
|
+
/** Session ID */
|
|
204
|
+
sessionId: string;
|
|
205
|
+
/** Wait for the session to complete */
|
|
206
|
+
waitForCompletion: (options?: SessionPollingOptions) => Promise<Session>;
|
|
207
|
+
/** Get current session status */
|
|
208
|
+
getStatus: () => Promise<Session>;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Create a presentation request for verification.
|
|
212
|
+
* Returns a URI for QR code and a function to wait for completion.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* import { verify } from '@eudiplo/sdk-core';
|
|
217
|
+
*
|
|
218
|
+
* const { uri, waitForCompletion } = await verify({
|
|
219
|
+
* baseUrl: 'https://eudiplo.example.com',
|
|
220
|
+
* clientId: 'demo',
|
|
221
|
+
* clientSecret: 'secret',
|
|
222
|
+
* configId: 'age-over-18'
|
|
223
|
+
* });
|
|
224
|
+
*
|
|
225
|
+
* console.log('Scan this:', uri);
|
|
226
|
+
* const session = await waitForCompletion();
|
|
227
|
+
* console.log('Verified!', session.credentials);
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
declare function verify(options: VerifyOptions): Promise<FlowResult>;
|
|
231
|
+
/**
|
|
232
|
+
* Create a credential issuance offer.
|
|
233
|
+
* Returns a URI for QR code and a function to wait for completion.
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```typescript
|
|
237
|
+
* import { issue } from '@eudiplo/sdk-core';
|
|
238
|
+
*
|
|
239
|
+
* const { uri, waitForCompletion } = await issue({
|
|
240
|
+
* baseUrl: 'https://eudiplo.example.com',
|
|
241
|
+
* clientId: 'demo',
|
|
242
|
+
* clientSecret: 'secret',
|
|
243
|
+
* credentialConfigurationIds: ['PID'],
|
|
244
|
+
* claims: {
|
|
245
|
+
* PID: { given_name: 'John', family_name: 'Doe' }
|
|
246
|
+
* }
|
|
247
|
+
* });
|
|
248
|
+
*
|
|
249
|
+
* console.log('Scan this:', uri);
|
|
250
|
+
* const session = await waitForCompletion();
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
declare function issue(options: IssueOptions): Promise<FlowResult>;
|
|
254
|
+
/**
|
|
255
|
+
* One-liner: Verify and wait for result in a single call.
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* ```typescript
|
|
259
|
+
* import { verifyAndWait } from '@eudiplo/sdk-core';
|
|
260
|
+
*
|
|
261
|
+
* const session = await verifyAndWait({
|
|
262
|
+
* baseUrl: 'https://eudiplo.example.com',
|
|
263
|
+
* clientId: 'demo',
|
|
264
|
+
* clientSecret: 'secret',
|
|
265
|
+
* configId: 'age-over-18',
|
|
266
|
+
* onUri: (uri) => showQRCode(uri),
|
|
267
|
+
* onUpdate: (s) => console.log('Status:', s.status)
|
|
268
|
+
* });
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
declare function verifyAndWait(options: VerifyOptions & {
|
|
272
|
+
/** Called with the URI when available - use to display QR code */
|
|
273
|
+
onUri: (uri: string) => void;
|
|
274
|
+
}): Promise<Session>;
|
|
275
|
+
/**
|
|
276
|
+
* One-liner: Issue credential and wait for completion in a single call.
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```typescript
|
|
280
|
+
* import { issueAndWait } from '@eudiplo/sdk-core';
|
|
281
|
+
*
|
|
282
|
+
* const session = await issueAndWait({
|
|
283
|
+
* baseUrl: 'https://eudiplo.example.com',
|
|
284
|
+
* clientId: 'demo',
|
|
285
|
+
* clientSecret: 'secret',
|
|
286
|
+
* credentialConfigurationIds: ['PID'],
|
|
287
|
+
* claims: { PID: { given_name: 'John' } },
|
|
288
|
+
* onUri: (uri) => showQRCode(uri)
|
|
289
|
+
* });
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
declare function issueAndWait(options: IssueOptions & {
|
|
293
|
+
/** Called with the URI when available - use to display QR code */
|
|
294
|
+
onUri: (uri: string) => void;
|
|
295
|
+
}): Promise<Session>;
|
|
296
|
+
|
|
297
|
+
export { EudiploClient, type EudiploClientConfig, type EudiploCredentials, type FlowResult, type IssuanceOfferOptions, type IssueOptions, type OfferResult, type PresentationRequestOptions, Session, type SessionPollingOptions, type VerifyOptions, issue, issueAndWait, verify, verifyAndWait };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { Session } from './api/index.js';
|
|
2
|
+
export { AllowListPolicy, ApiKeyConfig, AppControllerMainData, AppControllerMainResponses, AttestationBasedPolicy, AuthControllerGetGlobalJwksData, AuthControllerGetGlobalJwksResponses, AuthControllerGetOAuth2TokenData, AuthControllerGetOAuth2TokenErrors, AuthControllerGetOAuth2TokenResponse, AuthControllerGetOAuth2TokenResponses, AuthControllerGetOidcDiscoveryData, AuthControllerGetOidcDiscoveryResponses, AuthenticationMethodAuth, AuthenticationMethodNone, AuthenticationMethodPresentation, AuthenticationUrlConfig, AuthorizationResponse, AuthorizeControllerAuthorizationChallengeEndpointData, AuthorizeControllerAuthorizationChallengeEndpointResponses, AuthorizeControllerAuthorizeData, AuthorizeControllerAuthorizeResponses, AuthorizeControllerParData, AuthorizeControllerParResponse, AuthorizeControllerParResponses, AuthorizeControllerTokenData, AuthorizeControllerTokenResponse, AuthorizeControllerTokenResponses, AuthorizeQueries, CertControllerAddCertificateData, CertControllerAddCertificateResponse, CertControllerAddCertificateResponses, CertControllerDeleteCertificateData, CertControllerDeleteCertificateResponses, CertControllerExportConfigData, CertControllerExportConfigResponse, CertControllerExportConfigResponses, CertControllerGetCertificateData, CertControllerGetCertificateResponse, CertControllerGetCertificateResponses, CertControllerGetCertificatesData, CertControllerGetCertificatesResponse, CertControllerGetCertificatesResponses, CertControllerUpdateCertificateData, CertControllerUpdateCertificateResponses, CertEntity, CertImportDto, CertResponseDto, CertUpdateDto, CertUsageEntity, Claim, ClaimsQuery, ClientControllerCreateClientData, ClientControllerCreateClientResponse, ClientControllerCreateClientResponses, ClientControllerDeleteClientData, ClientControllerDeleteClientResponses, ClientControllerGetClientData, ClientControllerGetClientResponse, ClientControllerGetClientResponses, ClientControllerGetClientSecretData, ClientControllerGetClientSecretResponse, ClientControllerGetClientSecretResponses, ClientControllerGetClientsData, ClientControllerGetClientsResponse, ClientControllerGetClientsResponses, ClientControllerUpdateClientData, ClientControllerUpdateClientResponse, ClientControllerUpdateClientResponses, ClientCredentialsDto, ClientEntity, ClientOptions, ClientSecretResponseDto, CreateClientDto, CreateStatusListDto, CreateTenantDto, CredentialConfig, CredentialConfigControllerDeleteIssuanceConfigurationData, CredentialConfigControllerDeleteIssuanceConfigurationResponses, CredentialConfigControllerGetConfigByIdData, CredentialConfigControllerGetConfigByIdResponse, CredentialConfigControllerGetConfigByIdResponses, CredentialConfigControllerGetConfigsData, CredentialConfigControllerGetConfigsResponse, CredentialConfigControllerGetConfigsResponses, CredentialConfigControllerStoreCredentialConfigurationData, CredentialConfigControllerStoreCredentialConfigurationResponse, CredentialConfigControllerStoreCredentialConfigurationResponses, CredentialConfigControllerUpdateCredentialConfigurationData, CredentialConfigControllerUpdateCredentialConfigurationResponse, CredentialConfigControllerUpdateCredentialConfigurationResponses, CredentialConfigCreate, CredentialConfigUpdate, CredentialOfferControllerGetOfferData, CredentialOfferControllerGetOfferResponse, CredentialOfferControllerGetOfferResponses, CredentialQuery, CredentialSetQuery, Dcql, Display, DisplayImage, DisplayInfo, DisplayLogo, EcPublic, EmbeddedDisclosurePolicy, FileUploadDto, HealthControllerCheckData, HealthControllerCheckError, HealthControllerCheckErrors, HealthControllerCheckResponse, HealthControllerCheckResponses, ImportTenantDto, IssuanceConfig, IssuanceConfigControllerGetIssuanceConfigurationsData, IssuanceConfigControllerGetIssuanceConfigurationsResponse, IssuanceConfigControllerGetIssuanceConfigurationsResponses, IssuanceConfigControllerStoreIssuanceConfigurationData, IssuanceConfigControllerStoreIssuanceConfigurationResponse, IssuanceConfigControllerStoreIssuanceConfigurationResponses, IssuanceDto, IssuerMetadataCredentialConfig, JwksResponseDto, Key, KeyControllerAddKeyData, KeyControllerAddKeyResponses, KeyControllerDeleteKeyData, KeyControllerDeleteKeyResponses, KeyControllerGetKeyData, KeyControllerGetKeyResponse, KeyControllerGetKeyResponses, KeyControllerGetKeysData, KeyControllerGetKeysResponse, KeyControllerGetKeysResponses, KeyControllerUpdateKeyData, KeyControllerUpdateKeyResponses, KeyEntity, KeyImportDto, NoneTrustPolicy, NotificationRequestDto, OfferRequestDto, OfferResponse, Oid4VciControllerCredentialData, Oid4VciControllerCredentialResponses, Oid4VciControllerNonceData, Oid4VciControllerNonceResponses, Oid4VciControllerNotificationsData, Oid4VciControllerNotificationsResponses, Oid4VciMetadataControllerVctData, Oid4VciMetadataControllerVctResponse, Oid4VciMetadataControllerVctResponses, Oid4VpControllerGetPostRequestWithSessionData, Oid4VpControllerGetPostRequestWithSessionResponse, Oid4VpControllerGetPostRequestWithSessionResponses, Oid4VpControllerGetRequestWithSessionData, Oid4VpControllerGetRequestWithSessionResponse, Oid4VpControllerGetRequestWithSessionResponses, Oid4VpControllerGetResponseData, Oid4VpControllerGetResponseResponse, Oid4VpControllerGetResponseResponses, Options, ParResponseDto, PolicyCredential, PresentationAttachment, PresentationConfig, PresentationConfigCreateDto, PresentationConfigUpdateDto, PresentationDuringIssuanceConfig, PresentationManagementControllerConfigurationData, PresentationManagementControllerConfigurationResponse, PresentationManagementControllerConfigurationResponses, PresentationManagementControllerDeleteConfigurationData, PresentationManagementControllerDeleteConfigurationResponses, PresentationManagementControllerGetConfigurationData, PresentationManagementControllerGetConfigurationResponse, PresentationManagementControllerGetConfigurationResponses, PresentationManagementControllerStorePresentationConfigData, PresentationManagementControllerStorePresentationConfigResponse, PresentationManagementControllerStorePresentationConfigResponses, PresentationManagementControllerUpdateConfigurationData, PresentationManagementControllerUpdateConfigurationResponse, PresentationManagementControllerUpdateConfigurationResponses, PresentationRequest, PrometheusControllerIndexData, PrometheusControllerIndexResponses, RegistrationCertificateRequest, RoleDto, RootOfTrustPolicy, SchemaResponse, SessionConfigControllerGetConfigData, SessionConfigControllerGetConfigResponse, SessionConfigControllerGetConfigResponses, SessionConfigControllerResetConfigData, SessionConfigControllerResetConfigResponses, SessionConfigControllerUpdateConfigData, SessionConfigControllerUpdateConfigResponse, SessionConfigControllerUpdateConfigResponses, SessionControllerDeleteSessionData, SessionControllerDeleteSessionResponses, SessionControllerGetAllSessionsData, SessionControllerGetAllSessionsResponse, SessionControllerGetAllSessionsResponses, SessionControllerGetSessionData, SessionControllerGetSessionResponse, SessionControllerGetSessionResponses, SessionControllerRevokeAllData, SessionControllerRevokeAllResponses, SessionStorageConfig, StatusListAggregationDto, StatusListConfig, StatusListConfigControllerGetConfigData, StatusListConfigControllerGetConfigResponse, StatusListConfigControllerGetConfigResponses, StatusListConfigControllerResetConfigData, StatusListConfigControllerResetConfigResponse, StatusListConfigControllerResetConfigResponses, StatusListConfigControllerUpdateConfigData, StatusListConfigControllerUpdateConfigResponse, StatusListConfigControllerUpdateConfigResponses, StatusListControllerGetListData, StatusListControllerGetListResponse, StatusListControllerGetListResponses, StatusListControllerGetStatusListAggregationData, StatusListControllerGetStatusListAggregationResponse, StatusListControllerGetStatusListAggregationResponses, StatusListImportDto, StatusListManagementControllerCreateListData, StatusListManagementControllerCreateListResponse, StatusListManagementControllerCreateListResponses, StatusListManagementControllerDeleteListData, StatusListManagementControllerDeleteListResponse, StatusListManagementControllerDeleteListResponses, StatusListManagementControllerGetListData, StatusListManagementControllerGetListResponse, StatusListManagementControllerGetListResponses, StatusListManagementControllerGetListsData, StatusListManagementControllerGetListsResponse, StatusListManagementControllerGetListsResponses, StatusListManagementControllerUpdateListData, StatusListManagementControllerUpdateListResponse, StatusListManagementControllerUpdateListResponses, StatusListResponseDto, StatusUpdateDto, StorageControllerDownloadData, StorageControllerDownloadResponses, StorageControllerUploadData, StorageControllerUploadResponse, StorageControllerUploadResponses, TenantControllerDeleteTenantData, TenantControllerDeleteTenantResponses, TenantControllerGetTenantData, TenantControllerGetTenantResponse, TenantControllerGetTenantResponses, TenantControllerGetTenantsData, TenantControllerGetTenantsResponse, TenantControllerGetTenantsResponses, TenantControllerInitTenantData, TenantControllerInitTenantResponses, TenantControllerUpdateTenantData, TenantControllerUpdateTenantResponse, TenantControllerUpdateTenantResponses, TenantEntity, TokenResponse, TrustList, TrustListControllerCreateTrustListData, TrustListControllerCreateTrustListResponse, TrustListControllerCreateTrustListResponses, TrustListControllerDeleteTrustListData, TrustListControllerDeleteTrustListResponses, TrustListControllerExportTrustListData, TrustListControllerExportTrustListResponse, TrustListControllerExportTrustListResponses, TrustListControllerGetAllTrustListsData, TrustListControllerGetAllTrustListsResponse, TrustListControllerGetAllTrustListsResponses, TrustListControllerGetTrustListData, TrustListControllerGetTrustListResponse, TrustListControllerGetTrustListResponses, TrustListControllerGetTrustListVersionData, TrustListControllerGetTrustListVersionResponse, TrustListControllerGetTrustListVersionResponses, TrustListControllerGetTrustListVersionsData, TrustListControllerGetTrustListVersionsResponse, TrustListControllerGetTrustListVersionsResponses, TrustListControllerUpdateTrustListData, TrustListControllerUpdateTrustListResponse, TrustListControllerUpdateTrustListResponses, TrustListCreateDto, TrustListPublicControllerGetTrustListJwtData, TrustListPublicControllerGetTrustListJwtResponse, TrustListPublicControllerGetTrustListJwtResponses, TrustListVersion, TrustedAuthorityQuery, UpdateClientDto, UpdateKeyDto, UpdateSessionConfigDto, UpdateStatusListConfigDto, UpdateStatusListDto, UpdateTenantDto, Vct, VerifierOfferControllerGetOfferData, VerifierOfferControllerGetOfferResponse, VerifierOfferControllerGetOfferResponses, WebHookAuthConfigHeader, WebHookAuthConfigNone, WebhookConfig, WellKnownControllerAuthzMetadata0Data, WellKnownControllerAuthzMetadata0Responses, WellKnownControllerAuthzMetadata1Data, WellKnownControllerAuthzMetadata1Responses, WellKnownControllerGetJwks0Data, WellKnownControllerGetJwks0Response, WellKnownControllerGetJwks0Responses, WellKnownControllerGetJwks1Data, WellKnownControllerGetJwks1Response, WellKnownControllerGetJwks1Responses, WellKnownControllerIssuerMetadata0Data, WellKnownControllerIssuerMetadata0Response, WellKnownControllerIssuerMetadata0Responses, WellKnownControllerIssuerMetadata1Data, WellKnownControllerIssuerMetadata1Response, WellKnownControllerIssuerMetadata1Responses, appControllerMain, authControllerGetGlobalJwks, authControllerGetOAuth2Token, authControllerGetOidcDiscovery, authorizeControllerAuthorizationChallengeEndpoint, authorizeControllerAuthorize, authorizeControllerPar, authorizeControllerToken, certControllerAddCertificate, certControllerDeleteCertificate, certControllerExportConfig, certControllerGetCertificate, certControllerGetCertificates, certControllerUpdateCertificate, clientControllerCreateClient, clientControllerDeleteClient, clientControllerGetClient, clientControllerGetClientSecret, clientControllerGetClients, clientControllerUpdateClient, credentialConfigControllerDeleteIssuanceConfiguration, credentialConfigControllerGetConfigById, credentialConfigControllerGetConfigs, credentialConfigControllerStoreCredentialConfiguration, credentialConfigControllerUpdateCredentialConfiguration, credentialOfferControllerGetOffer, healthControllerCheck, issuanceConfigControllerGetIssuanceConfigurations, issuanceConfigControllerStoreIssuanceConfiguration, keyControllerAddKey, keyControllerDeleteKey, keyControllerGetKey, keyControllerGetKeys, keyControllerUpdateKey, oid4VciControllerCredential, oid4VciControllerNonce, oid4VciControllerNotifications, oid4VciMetadataControllerVct, oid4VpControllerGetPostRequestWithSession, oid4VpControllerGetRequestWithSession, oid4VpControllerGetResponse, presentationManagementControllerConfiguration, presentationManagementControllerDeleteConfiguration, presentationManagementControllerGetConfiguration, presentationManagementControllerStorePresentationConfig, presentationManagementControllerUpdateConfiguration, prometheusControllerIndex, sessionConfigControllerGetConfig, sessionConfigControllerResetConfig, sessionConfigControllerUpdateConfig, sessionControllerDeleteSession, sessionControllerGetAllSessions, sessionControllerGetSession, sessionControllerRevokeAll, statusListConfigControllerGetConfig, statusListConfigControllerResetConfig, statusListConfigControllerUpdateConfig, statusListControllerGetList, statusListControllerGetStatusListAggregation, statusListManagementControllerCreateList, statusListManagementControllerDeleteList, statusListManagementControllerGetList, statusListManagementControllerGetLists, statusListManagementControllerUpdateList, storageControllerDownload, storageControllerUpload, tenantControllerDeleteTenant, tenantControllerGetTenant, tenantControllerGetTenants, tenantControllerInitTenant, tenantControllerUpdateTenant, trustListControllerCreateTrustList, trustListControllerDeleteTrustList, trustListControllerExportTrustList, trustListControllerGetAllTrustLists, trustListControllerGetTrustList, trustListControllerGetTrustListVersion, trustListControllerGetTrustListVersions, trustListControllerUpdateTrustList, trustListPublicControllerGetTrustListJwt, verifierOfferControllerGetOffer, wellKnownControllerAuthzMetadata0, wellKnownControllerAuthzMetadata1, wellKnownControllerGetJwks0, wellKnownControllerGetJwks1, wellKnownControllerIssuerMetadata0, wellKnownControllerIssuerMetadata1 } from './api/index.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Configuration options for the EudiploClient
|
|
6
|
+
*/
|
|
7
|
+
interface EudiploClientConfig {
|
|
8
|
+
/** Base URL of the EUDIPLO server (e.g., 'https://eudiplo.example.com') */
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
/** OAuth2 client ID */
|
|
11
|
+
clientId: string;
|
|
12
|
+
/** OAuth2 client secret */
|
|
13
|
+
clientSecret: string;
|
|
14
|
+
/** Optional: Auto-refresh token before expiry (default: true) */
|
|
15
|
+
autoRefresh?: boolean;
|
|
16
|
+
/** Optional: Custom fetch implementation (useful for Cloudflare Workers) */
|
|
17
|
+
fetch?: typeof fetch;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Options for session polling
|
|
21
|
+
*/
|
|
22
|
+
interface SessionPollingOptions {
|
|
23
|
+
/** Polling interval in milliseconds (default: 1000) */
|
|
24
|
+
interval?: number;
|
|
25
|
+
/** Maximum time to wait in milliseconds (default: 300000 = 5 minutes) */
|
|
26
|
+
timeout?: number;
|
|
27
|
+
/** Callback on each poll */
|
|
28
|
+
onUpdate?: (session: Session) => void;
|
|
29
|
+
/** AbortSignal to cancel polling */
|
|
30
|
+
signal?: AbortSignal;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Simplified options for creating an issuance offer
|
|
34
|
+
*/
|
|
35
|
+
interface IssuanceOfferOptions {
|
|
36
|
+
/** Credential configuration IDs to issue */
|
|
37
|
+
credentialConfigurationIds: string[];
|
|
38
|
+
/** Claims to include in the credentials (keyed by config ID) */
|
|
39
|
+
claims?: Record<string, Record<string, unknown>>;
|
|
40
|
+
/** Response type: 'qrcode' returns a data URL, 'uri' returns the offer URI */
|
|
41
|
+
responseType?: 'qrcode' | 'uri' | 'dc-api';
|
|
42
|
+
/** Transaction code for pre-authorized flow */
|
|
43
|
+
txCode?: string;
|
|
44
|
+
/** Flow type (default: 'pre_authorized_code') */
|
|
45
|
+
flow?: 'authorization_code' | 'pre_authorized_code';
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Simplified options for creating a presentation request
|
|
49
|
+
*/
|
|
50
|
+
interface PresentationRequestOptions {
|
|
51
|
+
/** ID of the presentation configuration */
|
|
52
|
+
configId: string;
|
|
53
|
+
/** Response type: 'qrcode' returns a data URL, 'uri' returns the request URI */
|
|
54
|
+
responseType?: 'qrcode' | 'uri' | 'dc-api';
|
|
55
|
+
/** Optional redirect URI after presentation completes */
|
|
56
|
+
redirectUri?: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Result of creating an offer or request
|
|
60
|
+
*/
|
|
61
|
+
interface OfferResult {
|
|
62
|
+
/** The URI to encode in a QR code or use directly */
|
|
63
|
+
uri: string;
|
|
64
|
+
/** Session ID for polling */
|
|
65
|
+
sessionId: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Framework-agnostic EUDIPLO client for demos and integrations.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* import { EudiploClient } from '@eudiplo/sdk-core';
|
|
73
|
+
*
|
|
74
|
+
* const client = new EudiploClient({
|
|
75
|
+
* baseUrl: 'https://eudiplo.example.com',
|
|
76
|
+
* clientId: 'my-demo',
|
|
77
|
+
* clientSecret: 'secret123'
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* // Create a presentation request for age verification
|
|
81
|
+
* const { uri, sessionId } = await client.createPresentationRequest({
|
|
82
|
+
* configId: 'age-over-18'
|
|
83
|
+
* });
|
|
84
|
+
*
|
|
85
|
+
* // Display QR code with `uri`, then wait for completion
|
|
86
|
+
* const session = await client.waitForSession(sessionId);
|
|
87
|
+
* console.log('Verified:', session.credentials);
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
declare class EudiploClient {
|
|
91
|
+
private config;
|
|
92
|
+
private accessToken?;
|
|
93
|
+
private tokenExpiresAt?;
|
|
94
|
+
private refreshPromise?;
|
|
95
|
+
constructor(config: EudiploClientConfig);
|
|
96
|
+
/**
|
|
97
|
+
* Authenticate and obtain an access token.
|
|
98
|
+
* Called automatically by other methods, but can be called explicitly.
|
|
99
|
+
*/
|
|
100
|
+
authenticate(): Promise<void>;
|
|
101
|
+
private _doAuthenticate;
|
|
102
|
+
/**
|
|
103
|
+
* Ensure we have a valid access token, refreshing if necessary.
|
|
104
|
+
*/
|
|
105
|
+
private ensureAuthenticated;
|
|
106
|
+
/**
|
|
107
|
+
* Create a credential issuance offer.
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* const { uri, sessionId } = await client.createIssuanceOffer({
|
|
112
|
+
* credentialConfigurationIds: ['PID'],
|
|
113
|
+
* claims: {
|
|
114
|
+
* PID: { given_name: 'John', family_name: 'Doe' }
|
|
115
|
+
* }
|
|
116
|
+
* });
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
createIssuanceOffer(options: IssuanceOfferOptions): Promise<OfferResult>;
|
|
120
|
+
/**
|
|
121
|
+
* Create a presentation request (for verification).
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* // Age verification
|
|
126
|
+
* const { uri, sessionId } = await client.createPresentationRequest({
|
|
127
|
+
* configId: 'age-over-18'
|
|
128
|
+
* });
|
|
129
|
+
*
|
|
130
|
+
* // Show QR code, wait for wallet to respond
|
|
131
|
+
* const session = await client.waitForSession(sessionId);
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
createPresentationRequest(options: PresentationRequestOptions): Promise<OfferResult>;
|
|
135
|
+
/**
|
|
136
|
+
* Get the current status of a session.
|
|
137
|
+
*/
|
|
138
|
+
getSession(sessionId: string): Promise<Session>;
|
|
139
|
+
/**
|
|
140
|
+
* Wait for a session to complete (polling).
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* const session = await client.waitForSession(sessionId, {
|
|
145
|
+
* interval: 1000,
|
|
146
|
+
* timeout: 60000,
|
|
147
|
+
* onUpdate: (s) => console.log('Status:', s.status)
|
|
148
|
+
* });
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
waitForSession(sessionId: string, options?: SessionPollingOptions): Promise<Session>;
|
|
152
|
+
/**
|
|
153
|
+
* Helper to sleep with abort support
|
|
154
|
+
*/
|
|
155
|
+
private sleep;
|
|
156
|
+
/**
|
|
157
|
+
* Get the current access token (for advanced usage)
|
|
158
|
+
*/
|
|
159
|
+
getAccessToken(): string | undefined;
|
|
160
|
+
/**
|
|
161
|
+
* Get the configured base URL
|
|
162
|
+
*/
|
|
163
|
+
getBaseUrl(): string;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Credentials for EUDIPLO authentication
|
|
167
|
+
*/
|
|
168
|
+
interface EudiploCredentials {
|
|
169
|
+
baseUrl: string;
|
|
170
|
+
clientId: string;
|
|
171
|
+
clientSecret: string;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Options for the verify function
|
|
175
|
+
*/
|
|
176
|
+
interface VerifyOptions extends EudiploCredentials {
|
|
177
|
+
/** Presentation configuration ID */
|
|
178
|
+
configId: string;
|
|
179
|
+
/** Optional redirect URI */
|
|
180
|
+
redirectUri?: string;
|
|
181
|
+
/** Polling options */
|
|
182
|
+
polling?: SessionPollingOptions;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Options for the issue function
|
|
186
|
+
*/
|
|
187
|
+
interface IssueOptions extends EudiploCredentials {
|
|
188
|
+
/** Credential configuration IDs */
|
|
189
|
+
credentialConfigurationIds: string[];
|
|
190
|
+
/** Claims per credential config */
|
|
191
|
+
claims?: Record<string, Record<string, unknown>>;
|
|
192
|
+
/** Transaction code (optional) */
|
|
193
|
+
txCode?: string;
|
|
194
|
+
/** Polling options */
|
|
195
|
+
polling?: SessionPollingOptions;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Result of a verification or issuance flow
|
|
199
|
+
*/
|
|
200
|
+
interface FlowResult {
|
|
201
|
+
/** URI for QR code */
|
|
202
|
+
uri: string;
|
|
203
|
+
/** Session ID */
|
|
204
|
+
sessionId: string;
|
|
205
|
+
/** Wait for the session to complete */
|
|
206
|
+
waitForCompletion: (options?: SessionPollingOptions) => Promise<Session>;
|
|
207
|
+
/** Get current session status */
|
|
208
|
+
getStatus: () => Promise<Session>;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Create a presentation request for verification.
|
|
212
|
+
* Returns a URI for QR code and a function to wait for completion.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* import { verify } from '@eudiplo/sdk-core';
|
|
217
|
+
*
|
|
218
|
+
* const { uri, waitForCompletion } = await verify({
|
|
219
|
+
* baseUrl: 'https://eudiplo.example.com',
|
|
220
|
+
* clientId: 'demo',
|
|
221
|
+
* clientSecret: 'secret',
|
|
222
|
+
* configId: 'age-over-18'
|
|
223
|
+
* });
|
|
224
|
+
*
|
|
225
|
+
* console.log('Scan this:', uri);
|
|
226
|
+
* const session = await waitForCompletion();
|
|
227
|
+
* console.log('Verified!', session.credentials);
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
230
|
+
declare function verify(options: VerifyOptions): Promise<FlowResult>;
|
|
231
|
+
/**
|
|
232
|
+
* Create a credential issuance offer.
|
|
233
|
+
* Returns a URI for QR code and a function to wait for completion.
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```typescript
|
|
237
|
+
* import { issue } from '@eudiplo/sdk-core';
|
|
238
|
+
*
|
|
239
|
+
* const { uri, waitForCompletion } = await issue({
|
|
240
|
+
* baseUrl: 'https://eudiplo.example.com',
|
|
241
|
+
* clientId: 'demo',
|
|
242
|
+
* clientSecret: 'secret',
|
|
243
|
+
* credentialConfigurationIds: ['PID'],
|
|
244
|
+
* claims: {
|
|
245
|
+
* PID: { given_name: 'John', family_name: 'Doe' }
|
|
246
|
+
* }
|
|
247
|
+
* });
|
|
248
|
+
*
|
|
249
|
+
* console.log('Scan this:', uri);
|
|
250
|
+
* const session = await waitForCompletion();
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
declare function issue(options: IssueOptions): Promise<FlowResult>;
|
|
254
|
+
/**
|
|
255
|
+
* One-liner: Verify and wait for result in a single call.
|
|
256
|
+
*
|
|
257
|
+
* @example
|
|
258
|
+
* ```typescript
|
|
259
|
+
* import { verifyAndWait } from '@eudiplo/sdk-core';
|
|
260
|
+
*
|
|
261
|
+
* const session = await verifyAndWait({
|
|
262
|
+
* baseUrl: 'https://eudiplo.example.com',
|
|
263
|
+
* clientId: 'demo',
|
|
264
|
+
* clientSecret: 'secret',
|
|
265
|
+
* configId: 'age-over-18',
|
|
266
|
+
* onUri: (uri) => showQRCode(uri),
|
|
267
|
+
* onUpdate: (s) => console.log('Status:', s.status)
|
|
268
|
+
* });
|
|
269
|
+
* ```
|
|
270
|
+
*/
|
|
271
|
+
declare function verifyAndWait(options: VerifyOptions & {
|
|
272
|
+
/** Called with the URI when available - use to display QR code */
|
|
273
|
+
onUri: (uri: string) => void;
|
|
274
|
+
}): Promise<Session>;
|
|
275
|
+
/**
|
|
276
|
+
* One-liner: Issue credential and wait for completion in a single call.
|
|
277
|
+
*
|
|
278
|
+
* @example
|
|
279
|
+
* ```typescript
|
|
280
|
+
* import { issueAndWait } from '@eudiplo/sdk-core';
|
|
281
|
+
*
|
|
282
|
+
* const session = await issueAndWait({
|
|
283
|
+
* baseUrl: 'https://eudiplo.example.com',
|
|
284
|
+
* clientId: 'demo',
|
|
285
|
+
* clientSecret: 'secret',
|
|
286
|
+
* credentialConfigurationIds: ['PID'],
|
|
287
|
+
* claims: { PID: { given_name: 'John' } },
|
|
288
|
+
* onUri: (uri) => showQRCode(uri)
|
|
289
|
+
* });
|
|
290
|
+
* ```
|
|
291
|
+
*/
|
|
292
|
+
declare function issueAndWait(options: IssueOptions & {
|
|
293
|
+
/** Called with the URI when available - use to display QR code */
|
|
294
|
+
onUri: (uri: string) => void;
|
|
295
|
+
}): Promise<Session>;
|
|
296
|
+
|
|
297
|
+
export { EudiploClient, type EudiploClientConfig, type EudiploCredentials, type FlowResult, type IssuanceOfferOptions, type IssueOptions, type OfferResult, type PresentationRequestOptions, Session, type SessionPollingOptions, type VerifyOptions, issue, issueAndWait, verify, verifyAndWait };
|