@sphereon/oid4vci-common 0.18.2 → 0.19.1-next.2

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/index.d.cts CHANGED
@@ -3,66 +3,6 @@ import { CredentialFormat, ICredentialContextType, W3CVerifiableCredential, IVer
3
3
  import { DynamicRegistrationClientMetadata, SigningAlgo, JWK, BaseJWK, CreateDPoPClientOpts } from '@sphereon/oid4vc-common';
4
4
  import { SupportedEncodings } from 'uint8arrays/to-string';
5
5
 
6
- // limit of Crypto.getRandomValues()
7
- // https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
8
- const MAX_BYTES = 65536;
9
-
10
- // Node supports requesting up to this number of bytes
11
- // https://github.com/nodejs/node/blob/master/lib/internal/crypto/random.js#L48
12
- const MAX_UINT32 = 4294967295;
13
-
14
- function oldBrowser() {
15
- throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11');
16
- }
17
-
18
- // eslint-disable-next-line no-undef
19
- const _global = typeof globalThis !== 'undefined' ? globalThis : global;
20
-
21
- let crypto = _global.crypto || _global.msCrypto;
22
- if (!crypto) {
23
- try {
24
- // eslint-disable-next-line no-undef
25
- crypto = require('crypto');
26
- } catch (err) {
27
- throw Error('crypto module is not available');
28
- }
29
- }
30
-
31
-
32
- const randomBytes = (size) => {
33
- // phantomjs needs to throw
34
- if (size > MAX_UINT32) throw new Error('requested too many random bytes');
35
-
36
- // eslint-disable-next-line no-undef
37
- const bytes = Buffer.allocUnsafe(size);
38
-
39
- if (size > 0) {
40
- // getRandomValues fails on IE if size == 0
41
- if (size > MAX_BYTES) {
42
- // this is the max bytes crypto.getRandomValues
43
- // can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
44
- for (let generated = 0; generated < size; generated += MAX_BYTES) {
45
- // buffer.slice automatically checks if the end is past the end of
46
- // the buffer so we don't have to here
47
- crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES));
48
- }
49
- } else {
50
- crypto.getRandomValues(bytes);
51
- }
52
- }
53
- return Uint8Array.from(bytes);
54
- };
55
-
56
-
57
-
58
- if (crypto && crypto.getRandomValues) {
59
- // eslint-disable-next-line no-undef
60
- module.exports = randomBytes;
61
- } else {
62
- // eslint-disable-next-line no-undef
63
- module.exports = oldBrowser;
64
- }
65
-
66
6
  /**
67
7
  * Copied from openid-client
68
8
  */
@@ -1151,7 +1091,7 @@ interface ProofOfPossessionCallbacks {
1151
1091
  * Signature algorithms.
1152
1092
  *
1153
1093
  * TODO: Move towards string literal unions and string type, given we do not provide signature/key implementations in this library to begin with
1154
- * @See: https://github.com/Sphereon-Opensource/OID4VCI/issues/88
1094
+ * @See: https://github.com/Sphereon-Opensource/OID4VC/issues/88
1155
1095
  */
1156
1096
  declare enum Alg {
1157
1097
  EdDSA = "EdDSA",
@@ -1897,4 +1837,4 @@ declare const EVENTS: EventManager;
1897
1837
  declare const VCI_LOGGERS: Loggers;
1898
1838
  declare const VCI_LOG_COMMON: _sphereon_ssi_types.ISimpleLogger<unknown>;
1899
1839
 
1900
- export { ACCESS_TOKEN_ISSUER_REQUIRED_ERROR, ALG_ERROR, AUD_ERROR, type AccessTokenFromAuthorizationResponseOpts, type AccessTokenRequest, type AccessTokenRequestOpts, type AccessTokenRequestOptsV1_0_11, type AccessTokenResponse, Alg, type AlgValue, type AssertedUniformCredentialOffer, type AuthorizationChallengeCodeResponse, AuthorizationChallengeError, type AuthorizationChallengeErrorResponse, type AuthorizationChallengeRequestOpts, type AuthorizationDetails, type AuthorizationDetailsJwtVcJson, type AuthorizationDetailsJwtVcJsonLdAndLdpVc, type AuthorizationDetailsMsoMdoc, type AuthorizationDetailsSdJwtVc, type AuthorizationGrantResponse, type AuthorizationRequest, type AuthorizationRequestJwtVcJson, type AuthorizationRequestJwtVcJsonLdAndLdpVc, type AuthorizationRequestMsoMdoc, type AuthorizationRequestOpts, type AuthorizationRequestSdJwtVc, type AuthorizationRequestV1_0_09, type AuthorizationRequestV1_0_11, type AuthorizationResponse, type AuthorizationServerClientOpts, type AuthorizationServerMetadata, type AuthorizationServerOpts, type AuthorizationServerType, AuthzFlowType, BAD_PARAMS, type CNonceState, CODE_VERIFIER_DEFAULT_LENGTH, CREDENTIAL_MISSING_ERROR, type ClientAuthMethod, type ClientMetadata, type ClientResponseType, CodeChallengeMethod, type CommonAuthorizationChallengeRequest, type CommonAuthorizationDetails, type CommonAuthorizationRequest, type CommonCredentialOfferFormat, type CommonCredentialRequest, type CommonCredentialResponse, type CommonCredentialSupported, type CompactJWSHeaderParameters, type ComponentOptions, type CreateCredentialOfferURIResult, CreateRequestObjectMode, type CredentialConfigurationSupported, type CredentialConfigurationSupportedCommonV1_0_13, type CredentialConfigurationSupportedJwtVcJsonLdAndLdpVcV1_0_13, type CredentialConfigurationSupportedJwtVcJsonV1_0_13, type CredentialConfigurationSupportedMsoMdocV1_0_13, type CredentialConfigurationSupportedSdJwtVcV1_0_13, type CredentialConfigurationSupportedV1_0_13, type CredentialDataSupplierInput, type CredentialDefinitionJwtVcJsonLdAndLdpVcV1_0_13, type CredentialDefinitionJwtVcJsonV1_0_13, CredentialEventNames, type CredentialIssuerMetadata, type CredentialIssuerMetadataOpts, type CredentialIssuerMetadataOptsV1_0_13, type CredentialIssuerMetadataV1_0_11, type CredentialIssuerMetadataV1_0_13, type CredentialOffer, CredentialOfferEventNames, type CredentialOfferFormatJwtVcJson, type CredentialOfferFormatJwtVcJsonLdAndLdpVc, type CredentialOfferFormatMsoMdoc, type CredentialOfferFormatSdJwtVc, type CredentialOfferFormatV1_0_11, type CredentialOfferMode, type CredentialOfferPayload, type CredentialOfferPayloadLatest, type CredentialOfferPayloadV1_0_08, type CredentialOfferPayloadV1_0_09, type CredentialOfferPayloadV1_0_11, type CredentialOfferPayloadV1_0_13, type CredentialOfferRESTRequest, type CredentialOfferRESTRequestV1_0_11, type CredentialOfferRequestWithBaseUrl, type CredentialOfferRequestWithBaseUrlV1_0_11, type CredentialOfferSession, type CredentialOfferV1_0_09, type CredentialOfferV1_0_11, type CredentialOfferV1_0_13, type CredentialRequest, type CredentialRequestJwtVcJson, type CredentialRequestJwtVcJsonLdAndLdpVc, type CredentialRequestJwtVcJsonLdAndLdpVcV1_0_13, type CredentialRequestJwtVcJsonV1_0_13, type CredentialRequestMsoMdoc, type CredentialRequestSdJwtVc, type CredentialRequestV1_0_08, type CredentialRequestV1_0_11, type CredentialRequestV1_0_13, type CredentialRequestV1_0_13Common, type CredentialRequestV1_0_13CredentialIdentifier, type CredentialRequestV1_0_13ResponseEncryption, type CredentialRequestWithoutProofV1_0_13, type CredentialResponse, type CredentialResponseJwtVc, type CredentialResponseLdpVc, type CredentialResponseSdJwtVc, type CredentialSubjectDisplay, type CredentialSupplierConfig, type CredentialSupportedBrief, type CredentialSupportedFormatV1_0_08, type CredentialSupportedJwtVcJson, type CredentialSupportedJwtVcJsonLdAndLdpVc, type CredentialSupportedMsoMdoc, type CredentialSupportedSdJwtVc, type CredentialSupportedTypeV1_0_08, type CredentialSupportedV1_0_08, type CredentialsSupportedDisplay, type CredentialsSupportedLegacy, DID_NO_DIDDOC_ERROR, type DPoPResponseParams, type DecodeURIAsJsonOpts, DefaultURISchemes, EVENTS, EXPERIMENTAL_SUBJECT_PROOF_MODE_ENABLED, EXPIRED_PRE_AUTHORIZED_CODE, type EncValue, type EncodeJsonAsURIOpts, Encoding, type EndpointMetadata, type EndpointMetadataResult, type EndpointMetadataResultV1_0_11, type EndpointMetadataResultV1_0_13, type ErrorResponse, type EventNames, type ExperimentalSubjectIssuance, GRANTS_MUST_NOT_BE_UNDEFINED, type Grant, type GrantAuthorizationCode, GrantTypes, type GrantUrnIetf, IAT_ERROR, INVALID_PRE_AUTHORIZED_CODE, ISSUER_CONFIG_ERROR, ISS_MUST_BE_CLIENT_ID, ISS_PRESENT_IN_PRE_AUTHORIZED_CODE_CONTEXT, type IStateManager, type ImageInfo, type InputCharSet, IssueStatus, type IssueStatusResponse, type IssuerCredentialSubject, type IssuerCredentialSubjectDisplay, type IssuerMetadata, type IssuerMetadataV1_0_08, type IssuerMetadataV1_0_13, type IssuerOpts, type JWSHeaderParameters, JWS_NOT_VALID, type JWTHeader, type JWTHeaderParameters, type JWTPayload, type JWTSignerCallback, type JWTVerifyCallback, JWT_SIGNER_CALLBACK_REQUIRED_ERROR, JWT_VERIFY_CONFIG_ERROR, type JoseHeaderParameters, type JsonLdIssuerCredentialDefinition, JsonURIMode, type Jwt, type JwtProps, type JwtVerifyResult, KID_DID_NO_DID_ERROR, KID_JWK_X5C_ERROR, type KeyProofType, type LogEvents, type LogoAndColor, type MetadataDisplay, NONCE_ERROR, NONCE_LENGTH, NONCE_STATE_MANAGER_REQUIRED_ERROR, NO_ISS_IN_AUTHORIZATION_CODE_CONTEXT, NO_JWT_PROVIDED, type NameAndLocale, type NotificationError, type NotificationErrorResponse, type NotificationEventType, type NotificationRequest, type NotificationResponseResult, NotificationStatusEventNames, type OAuthGrantType, type OAuthResponseMode, type OAuthResponseType, type OAuthScope, type OID4VCICredentialFormat, type OpenIDResponse, OpenId4VCIVersion, PARMode, PIN_NOT_MATCH_ERROR, PIN_VALIDATION_ERROR, type PKCECodeChallengeMethod, type PKCEOpts, PRE_AUTHORIZED_CODE_REQUIRED_ERROR, PRE_AUTH_CODE_LITERAL, PRE_AUTH_GRANT_LITERAL, PROOF_CANT_BE_CONSTRUCTED, type PoPMode, type ProofOfPossession, type ProofOfPossessionCallbacks, type ProofType, type ProofTypesSupported, type PushedAuthorizationResponse, type QRCodeOpts, type RequestObjectOpts, type ResponseEncryption, ResponseType, type RevocationEndpointAuthMethod, type RevocationEndpointAuthSigningAlg, STATE_MANAGER_REQUIRED_ERROR, STATE_MISSING_ERROR, type SearchValue, type StateType, type StatusListOpts, type SubjectProofMode, type SubjectProofNotificationEventsSupported, TYP_ERROR, type TokenEndpointAuthMethod, type TokenEndpointAuthSigningAlg, TokenError, TokenErrorResponse, type TxCode, type TxCodeAndPinRequired, type Typ, UNKNOWN_CLIENT_ERROR, UNSUPPORTED_GRANT_TYPE_ERROR, type URIState, URL_NOT_VALID, USER_PIN_NOT_REQUIRED_ERROR, USER_PIN_REQUIRED_ERROR, USER_PIN_TX_CODE_SPEC_ERROR, type UniformCredentialOffer, type UniformCredentialOfferPayload, type UniformCredentialOfferRequest, type UniformCredentialRequest, VCI_LOGGERS, VCI_LOG_COMMON, WRONG_METADATA_FORMAT, WellKnownEndpoints, acquireDeferredCredential, adjustUrl, assertValidCodeVerifier, assertedUniformCredentialOffer, authorizationServerMetadataFieldNames, convertJsonToURI, convertURIToJsonObject, createCodeChallenge, createProofOfPossession, credentialIssuerMetadataFieldNames, credentialSupportedV8ToV13, credentialsSupportedV8ToV13, decodeJsonProperties, determineFlowType, determineGrantTypes, determineSpecVersionFromOffer, determineSpecVersionFromScheme, determineSpecVersionFromURI, determineVersionsFromIssuerMetadata, extractBearerToken, formPost, generateCodeVerifier, generateNonce, generateRandomString, getClientIdFromCredentialOfferPayload, getCredentialOfferPayload, getCredentialRequestForVersion, getFormatForVersion, getIssuerDisplays, getIssuerFromCredentialOfferPayload, getIssuerName, getJson, getNumberOrUndefined, getScheme, getStateFromCredentialOfferPayload, getSupportedCredential, getSupportedCredentials, getTypesFromAuthorizationDetails, getTypesFromCredentialOffer, getTypesFromCredentialSupported, getTypesFromObject, getTypesFromOfferV1_0_11, getTypesFromRequest, getURIComponentsAsArray, getUniformFormat, isAuthorizationRequestV1_0_09, isAuthorizationRequestV1_0_11, isCredentialOfferVersion, isDeferredCredentialIssuancePending, isDeferredCredentialResponse, isFormat, isJWS, isNotFormat, isPreAuthCode, isValidURL, isW3cCredentialSupported, post, randomBytes, resolveCredentialOfferURI, toAuthorizationResponsePayload, toUniformCredentialOfferPayload, toUniformCredentialOfferRequest, trimBoth, trimEnd, trimStart, validateJWT };
1840
+ export { ACCESS_TOKEN_ISSUER_REQUIRED_ERROR, ALG_ERROR, AUD_ERROR, type AccessTokenFromAuthorizationResponseOpts, type AccessTokenRequest, type AccessTokenRequestOpts, type AccessTokenRequestOptsV1_0_11, type AccessTokenResponse, Alg, type AlgValue, type AssertedUniformCredentialOffer, type AuthorizationChallengeCodeResponse, AuthorizationChallengeError, type AuthorizationChallengeErrorResponse, type AuthorizationChallengeRequestOpts, type AuthorizationDetails, type AuthorizationDetailsJwtVcJson, type AuthorizationDetailsJwtVcJsonLdAndLdpVc, type AuthorizationDetailsMsoMdoc, type AuthorizationDetailsSdJwtVc, type AuthorizationGrantResponse, type AuthorizationRequest, type AuthorizationRequestJwtVcJson, type AuthorizationRequestJwtVcJsonLdAndLdpVc, type AuthorizationRequestMsoMdoc, type AuthorizationRequestOpts, type AuthorizationRequestSdJwtVc, type AuthorizationRequestV1_0_09, type AuthorizationRequestV1_0_11, type AuthorizationResponse, type AuthorizationServerClientOpts, type AuthorizationServerMetadata, type AuthorizationServerOpts, type AuthorizationServerType, AuthzFlowType, BAD_PARAMS, type CNonceState, CODE_VERIFIER_DEFAULT_LENGTH, CREDENTIAL_MISSING_ERROR, type ClientAuthMethod, type ClientMetadata, type ClientResponseType, CodeChallengeMethod, type CommonAuthorizationChallengeRequest, type CommonAuthorizationDetails, type CommonAuthorizationRequest, type CommonCredentialOfferFormat, type CommonCredentialRequest, type CommonCredentialResponse, type CommonCredentialSupported, type CompactJWSHeaderParameters, type ComponentOptions, type CreateCredentialOfferURIResult, CreateRequestObjectMode, type CredentialConfigurationSupported, type CredentialConfigurationSupportedCommonV1_0_13, type CredentialConfigurationSupportedJwtVcJsonLdAndLdpVcV1_0_13, type CredentialConfigurationSupportedJwtVcJsonV1_0_13, type CredentialConfigurationSupportedMsoMdocV1_0_13, type CredentialConfigurationSupportedSdJwtVcV1_0_13, type CredentialConfigurationSupportedV1_0_13, type CredentialDataSupplierInput, type CredentialDefinitionJwtVcJsonLdAndLdpVcV1_0_13, type CredentialDefinitionJwtVcJsonV1_0_13, CredentialEventNames, type CredentialIssuerMetadata, type CredentialIssuerMetadataOpts, type CredentialIssuerMetadataOptsV1_0_13, type CredentialIssuerMetadataV1_0_11, type CredentialIssuerMetadataV1_0_13, type CredentialOffer, CredentialOfferEventNames, type CredentialOfferFormatJwtVcJson, type CredentialOfferFormatJwtVcJsonLdAndLdpVc, type CredentialOfferFormatMsoMdoc, type CredentialOfferFormatSdJwtVc, type CredentialOfferFormatV1_0_11, type CredentialOfferMode, type CredentialOfferPayload, type CredentialOfferPayloadLatest, type CredentialOfferPayloadV1_0_08, type CredentialOfferPayloadV1_0_09, type CredentialOfferPayloadV1_0_11, type CredentialOfferPayloadV1_0_13, type CredentialOfferRESTRequest, type CredentialOfferRESTRequestV1_0_11, type CredentialOfferRequestWithBaseUrl, type CredentialOfferRequestWithBaseUrlV1_0_11, type CredentialOfferSession, type CredentialOfferV1_0_09, type CredentialOfferV1_0_11, type CredentialOfferV1_0_13, type CredentialRequest, type CredentialRequestJwtVcJson, type CredentialRequestJwtVcJsonLdAndLdpVc, type CredentialRequestJwtVcJsonLdAndLdpVcV1_0_13, type CredentialRequestJwtVcJsonV1_0_13, type CredentialRequestMsoMdoc, type CredentialRequestSdJwtVc, type CredentialRequestV1_0_08, type CredentialRequestV1_0_11, type CredentialRequestV1_0_13, type CredentialRequestV1_0_13Common, type CredentialRequestV1_0_13CredentialIdentifier, type CredentialRequestV1_0_13ResponseEncryption, type CredentialRequestWithoutProofV1_0_13, type CredentialResponse, type CredentialResponseJwtVc, type CredentialResponseLdpVc, type CredentialResponseSdJwtVc, type CredentialSubjectDisplay, type CredentialSupplierConfig, type CredentialSupportedBrief, type CredentialSupportedFormatV1_0_08, type CredentialSupportedJwtVcJson, type CredentialSupportedJwtVcJsonLdAndLdpVc, type CredentialSupportedMsoMdoc, type CredentialSupportedSdJwtVc, type CredentialSupportedTypeV1_0_08, type CredentialSupportedV1_0_08, type CredentialsSupportedDisplay, type CredentialsSupportedLegacy, DID_NO_DIDDOC_ERROR, type DPoPResponseParams, type DecodeURIAsJsonOpts, DefaultURISchemes, EVENTS, EXPERIMENTAL_SUBJECT_PROOF_MODE_ENABLED, EXPIRED_PRE_AUTHORIZED_CODE, type EncValue, type EncodeJsonAsURIOpts, Encoding, type EndpointMetadata, type EndpointMetadataResult, type EndpointMetadataResultV1_0_11, type EndpointMetadataResultV1_0_13, type ErrorResponse, type EventNames, type ExperimentalSubjectIssuance, GRANTS_MUST_NOT_BE_UNDEFINED, type Grant, type GrantAuthorizationCode, GrantTypes, type GrantUrnIetf, IAT_ERROR, INVALID_PRE_AUTHORIZED_CODE, ISSUER_CONFIG_ERROR, ISS_MUST_BE_CLIENT_ID, ISS_PRESENT_IN_PRE_AUTHORIZED_CODE_CONTEXT, type IStateManager, type ImageInfo, type InputCharSet, IssueStatus, type IssueStatusResponse, type IssuerCredentialSubject, type IssuerCredentialSubjectDisplay, type IssuerMetadata, type IssuerMetadataV1_0_08, type IssuerMetadataV1_0_13, type IssuerOpts, type JWSHeaderParameters, JWS_NOT_VALID, type JWTHeader, type JWTHeaderParameters, type JWTPayload, type JWTSignerCallback, type JWTVerifyCallback, JWT_SIGNER_CALLBACK_REQUIRED_ERROR, JWT_VERIFY_CONFIG_ERROR, type JoseHeaderParameters, type JsonLdIssuerCredentialDefinition, JsonURIMode, type Jwt, type JwtProps, type JwtVerifyResult, KID_DID_NO_DID_ERROR, KID_JWK_X5C_ERROR, type KeyProofType, type LogEvents, type LogoAndColor, type MetadataDisplay, NONCE_ERROR, NONCE_LENGTH, NONCE_STATE_MANAGER_REQUIRED_ERROR, NO_ISS_IN_AUTHORIZATION_CODE_CONTEXT, NO_JWT_PROVIDED, type NameAndLocale, type NotificationError, type NotificationErrorResponse, type NotificationEventType, type NotificationRequest, type NotificationResponseResult, NotificationStatusEventNames, type OAuthGrantType, type OAuthResponseMode, type OAuthResponseType, type OAuthScope, type OID4VCICredentialFormat, type OpenIDResponse, OpenId4VCIVersion, PARMode, PIN_NOT_MATCH_ERROR, PIN_VALIDATION_ERROR, type PKCECodeChallengeMethod, type PKCEOpts, PRE_AUTHORIZED_CODE_REQUIRED_ERROR, PRE_AUTH_CODE_LITERAL, PRE_AUTH_GRANT_LITERAL, PROOF_CANT_BE_CONSTRUCTED, type PoPMode, type ProofOfPossession, type ProofOfPossessionCallbacks, type ProofType, type ProofTypesSupported, type PushedAuthorizationResponse, type QRCodeOpts, type RequestObjectOpts, type ResponseEncryption, ResponseType, type RevocationEndpointAuthMethod, type RevocationEndpointAuthSigningAlg, STATE_MANAGER_REQUIRED_ERROR, STATE_MISSING_ERROR, type SearchValue, type StateType, type StatusListOpts, type SubjectProofMode, type SubjectProofNotificationEventsSupported, TYP_ERROR, type TokenEndpointAuthMethod, type TokenEndpointAuthSigningAlg, TokenError, TokenErrorResponse, type TxCode, type TxCodeAndPinRequired, type Typ, UNKNOWN_CLIENT_ERROR, UNSUPPORTED_GRANT_TYPE_ERROR, type URIState, URL_NOT_VALID, USER_PIN_NOT_REQUIRED_ERROR, USER_PIN_REQUIRED_ERROR, USER_PIN_TX_CODE_SPEC_ERROR, type UniformCredentialOffer, type UniformCredentialOfferPayload, type UniformCredentialOfferRequest, type UniformCredentialRequest, VCI_LOGGERS, VCI_LOG_COMMON, WRONG_METADATA_FORMAT, WellKnownEndpoints, acquireDeferredCredential, adjustUrl, assertValidCodeVerifier, assertedUniformCredentialOffer, authorizationServerMetadataFieldNames, convertJsonToURI, convertURIToJsonObject, createCodeChallenge, createProofOfPossession, credentialIssuerMetadataFieldNames, credentialSupportedV8ToV13, credentialsSupportedV8ToV13, decodeJsonProperties, determineFlowType, determineGrantTypes, determineSpecVersionFromOffer, determineSpecVersionFromScheme, determineSpecVersionFromURI, determineVersionsFromIssuerMetadata, extractBearerToken, formPost, generateCodeVerifier, generateNonce, generateRandomString, getClientIdFromCredentialOfferPayload, getCredentialOfferPayload, getCredentialRequestForVersion, getFormatForVersion, getIssuerDisplays, getIssuerFromCredentialOfferPayload, getIssuerName, getJson, getNumberOrUndefined, getScheme, getStateFromCredentialOfferPayload, getSupportedCredential, getSupportedCredentials, getTypesFromAuthorizationDetails, getTypesFromCredentialOffer, getTypesFromCredentialSupported, getTypesFromObject, getTypesFromOfferV1_0_11, getTypesFromRequest, getURIComponentsAsArray, getUniformFormat, isAuthorizationRequestV1_0_09, isAuthorizationRequestV1_0_11, isCredentialOfferVersion, isDeferredCredentialIssuancePending, isDeferredCredentialResponse, isFormat, isJWS, isNotFormat, isPreAuthCode, isValidURL, isW3cCredentialSupported, post, resolveCredentialOfferURI, toAuthorizationResponsePayload, toUniformCredentialOfferPayload, toUniformCredentialOfferRequest, trimBoth, trimEnd, trimStart, validateJWT };
package/dist/index.d.ts CHANGED
@@ -3,66 +3,6 @@ import { CredentialFormat, ICredentialContextType, W3CVerifiableCredential, IVer
3
3
  import { DynamicRegistrationClientMetadata, SigningAlgo, JWK, BaseJWK, CreateDPoPClientOpts } from '@sphereon/oid4vc-common';
4
4
  import { SupportedEncodings } from 'uint8arrays/to-string';
5
5
 
6
- // limit of Crypto.getRandomValues()
7
- // https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
8
- const MAX_BYTES = 65536;
9
-
10
- // Node supports requesting up to this number of bytes
11
- // https://github.com/nodejs/node/blob/master/lib/internal/crypto/random.js#L48
12
- const MAX_UINT32 = 4294967295;
13
-
14
- function oldBrowser() {
15
- throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11');
16
- }
17
-
18
- // eslint-disable-next-line no-undef
19
- const _global = typeof globalThis !== 'undefined' ? globalThis : global;
20
-
21
- let crypto = _global.crypto || _global.msCrypto;
22
- if (!crypto) {
23
- try {
24
- // eslint-disable-next-line no-undef
25
- crypto = require('crypto');
26
- } catch (err) {
27
- throw Error('crypto module is not available');
28
- }
29
- }
30
-
31
-
32
- const randomBytes = (size) => {
33
- // phantomjs needs to throw
34
- if (size > MAX_UINT32) throw new Error('requested too many random bytes');
35
-
36
- // eslint-disable-next-line no-undef
37
- const bytes = Buffer.allocUnsafe(size);
38
-
39
- if (size > 0) {
40
- // getRandomValues fails on IE if size == 0
41
- if (size > MAX_BYTES) {
42
- // this is the max bytes crypto.getRandomValues
43
- // can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
44
- for (let generated = 0; generated < size; generated += MAX_BYTES) {
45
- // buffer.slice automatically checks if the end is past the end of
46
- // the buffer so we don't have to here
47
- crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES));
48
- }
49
- } else {
50
- crypto.getRandomValues(bytes);
51
- }
52
- }
53
- return Uint8Array.from(bytes);
54
- };
55
-
56
-
57
-
58
- if (crypto && crypto.getRandomValues) {
59
- // eslint-disable-next-line no-undef
60
- module.exports = randomBytes;
61
- } else {
62
- // eslint-disable-next-line no-undef
63
- module.exports = oldBrowser;
64
- }
65
-
66
6
  /**
67
7
  * Copied from openid-client
68
8
  */
@@ -1151,7 +1091,7 @@ interface ProofOfPossessionCallbacks {
1151
1091
  * Signature algorithms.
1152
1092
  *
1153
1093
  * TODO: Move towards string literal unions and string type, given we do not provide signature/key implementations in this library to begin with
1154
- * @See: https://github.com/Sphereon-Opensource/OID4VCI/issues/88
1094
+ * @See: https://github.com/Sphereon-Opensource/OID4VC/issues/88
1155
1095
  */
1156
1096
  declare enum Alg {
1157
1097
  EdDSA = "EdDSA",
@@ -1897,4 +1837,4 @@ declare const EVENTS: EventManager;
1897
1837
  declare const VCI_LOGGERS: Loggers;
1898
1838
  declare const VCI_LOG_COMMON: _sphereon_ssi_types.ISimpleLogger<unknown>;
1899
1839
 
1900
- export { ACCESS_TOKEN_ISSUER_REQUIRED_ERROR, ALG_ERROR, AUD_ERROR, type AccessTokenFromAuthorizationResponseOpts, type AccessTokenRequest, type AccessTokenRequestOpts, type AccessTokenRequestOptsV1_0_11, type AccessTokenResponse, Alg, type AlgValue, type AssertedUniformCredentialOffer, type AuthorizationChallengeCodeResponse, AuthorizationChallengeError, type AuthorizationChallengeErrorResponse, type AuthorizationChallengeRequestOpts, type AuthorizationDetails, type AuthorizationDetailsJwtVcJson, type AuthorizationDetailsJwtVcJsonLdAndLdpVc, type AuthorizationDetailsMsoMdoc, type AuthorizationDetailsSdJwtVc, type AuthorizationGrantResponse, type AuthorizationRequest, type AuthorizationRequestJwtVcJson, type AuthorizationRequestJwtVcJsonLdAndLdpVc, type AuthorizationRequestMsoMdoc, type AuthorizationRequestOpts, type AuthorizationRequestSdJwtVc, type AuthorizationRequestV1_0_09, type AuthorizationRequestV1_0_11, type AuthorizationResponse, type AuthorizationServerClientOpts, type AuthorizationServerMetadata, type AuthorizationServerOpts, type AuthorizationServerType, AuthzFlowType, BAD_PARAMS, type CNonceState, CODE_VERIFIER_DEFAULT_LENGTH, CREDENTIAL_MISSING_ERROR, type ClientAuthMethod, type ClientMetadata, type ClientResponseType, CodeChallengeMethod, type CommonAuthorizationChallengeRequest, type CommonAuthorizationDetails, type CommonAuthorizationRequest, type CommonCredentialOfferFormat, type CommonCredentialRequest, type CommonCredentialResponse, type CommonCredentialSupported, type CompactJWSHeaderParameters, type ComponentOptions, type CreateCredentialOfferURIResult, CreateRequestObjectMode, type CredentialConfigurationSupported, type CredentialConfigurationSupportedCommonV1_0_13, type CredentialConfigurationSupportedJwtVcJsonLdAndLdpVcV1_0_13, type CredentialConfigurationSupportedJwtVcJsonV1_0_13, type CredentialConfigurationSupportedMsoMdocV1_0_13, type CredentialConfigurationSupportedSdJwtVcV1_0_13, type CredentialConfigurationSupportedV1_0_13, type CredentialDataSupplierInput, type CredentialDefinitionJwtVcJsonLdAndLdpVcV1_0_13, type CredentialDefinitionJwtVcJsonV1_0_13, CredentialEventNames, type CredentialIssuerMetadata, type CredentialIssuerMetadataOpts, type CredentialIssuerMetadataOptsV1_0_13, type CredentialIssuerMetadataV1_0_11, type CredentialIssuerMetadataV1_0_13, type CredentialOffer, CredentialOfferEventNames, type CredentialOfferFormatJwtVcJson, type CredentialOfferFormatJwtVcJsonLdAndLdpVc, type CredentialOfferFormatMsoMdoc, type CredentialOfferFormatSdJwtVc, type CredentialOfferFormatV1_0_11, type CredentialOfferMode, type CredentialOfferPayload, type CredentialOfferPayloadLatest, type CredentialOfferPayloadV1_0_08, type CredentialOfferPayloadV1_0_09, type CredentialOfferPayloadV1_0_11, type CredentialOfferPayloadV1_0_13, type CredentialOfferRESTRequest, type CredentialOfferRESTRequestV1_0_11, type CredentialOfferRequestWithBaseUrl, type CredentialOfferRequestWithBaseUrlV1_0_11, type CredentialOfferSession, type CredentialOfferV1_0_09, type CredentialOfferV1_0_11, type CredentialOfferV1_0_13, type CredentialRequest, type CredentialRequestJwtVcJson, type CredentialRequestJwtVcJsonLdAndLdpVc, type CredentialRequestJwtVcJsonLdAndLdpVcV1_0_13, type CredentialRequestJwtVcJsonV1_0_13, type CredentialRequestMsoMdoc, type CredentialRequestSdJwtVc, type CredentialRequestV1_0_08, type CredentialRequestV1_0_11, type CredentialRequestV1_0_13, type CredentialRequestV1_0_13Common, type CredentialRequestV1_0_13CredentialIdentifier, type CredentialRequestV1_0_13ResponseEncryption, type CredentialRequestWithoutProofV1_0_13, type CredentialResponse, type CredentialResponseJwtVc, type CredentialResponseLdpVc, type CredentialResponseSdJwtVc, type CredentialSubjectDisplay, type CredentialSupplierConfig, type CredentialSupportedBrief, type CredentialSupportedFormatV1_0_08, type CredentialSupportedJwtVcJson, type CredentialSupportedJwtVcJsonLdAndLdpVc, type CredentialSupportedMsoMdoc, type CredentialSupportedSdJwtVc, type CredentialSupportedTypeV1_0_08, type CredentialSupportedV1_0_08, type CredentialsSupportedDisplay, type CredentialsSupportedLegacy, DID_NO_DIDDOC_ERROR, type DPoPResponseParams, type DecodeURIAsJsonOpts, DefaultURISchemes, EVENTS, EXPERIMENTAL_SUBJECT_PROOF_MODE_ENABLED, EXPIRED_PRE_AUTHORIZED_CODE, type EncValue, type EncodeJsonAsURIOpts, Encoding, type EndpointMetadata, type EndpointMetadataResult, type EndpointMetadataResultV1_0_11, type EndpointMetadataResultV1_0_13, type ErrorResponse, type EventNames, type ExperimentalSubjectIssuance, GRANTS_MUST_NOT_BE_UNDEFINED, type Grant, type GrantAuthorizationCode, GrantTypes, type GrantUrnIetf, IAT_ERROR, INVALID_PRE_AUTHORIZED_CODE, ISSUER_CONFIG_ERROR, ISS_MUST_BE_CLIENT_ID, ISS_PRESENT_IN_PRE_AUTHORIZED_CODE_CONTEXT, type IStateManager, type ImageInfo, type InputCharSet, IssueStatus, type IssueStatusResponse, type IssuerCredentialSubject, type IssuerCredentialSubjectDisplay, type IssuerMetadata, type IssuerMetadataV1_0_08, type IssuerMetadataV1_0_13, type IssuerOpts, type JWSHeaderParameters, JWS_NOT_VALID, type JWTHeader, type JWTHeaderParameters, type JWTPayload, type JWTSignerCallback, type JWTVerifyCallback, JWT_SIGNER_CALLBACK_REQUIRED_ERROR, JWT_VERIFY_CONFIG_ERROR, type JoseHeaderParameters, type JsonLdIssuerCredentialDefinition, JsonURIMode, type Jwt, type JwtProps, type JwtVerifyResult, KID_DID_NO_DID_ERROR, KID_JWK_X5C_ERROR, type KeyProofType, type LogEvents, type LogoAndColor, type MetadataDisplay, NONCE_ERROR, NONCE_LENGTH, NONCE_STATE_MANAGER_REQUIRED_ERROR, NO_ISS_IN_AUTHORIZATION_CODE_CONTEXT, NO_JWT_PROVIDED, type NameAndLocale, type NotificationError, type NotificationErrorResponse, type NotificationEventType, type NotificationRequest, type NotificationResponseResult, NotificationStatusEventNames, type OAuthGrantType, type OAuthResponseMode, type OAuthResponseType, type OAuthScope, type OID4VCICredentialFormat, type OpenIDResponse, OpenId4VCIVersion, PARMode, PIN_NOT_MATCH_ERROR, PIN_VALIDATION_ERROR, type PKCECodeChallengeMethod, type PKCEOpts, PRE_AUTHORIZED_CODE_REQUIRED_ERROR, PRE_AUTH_CODE_LITERAL, PRE_AUTH_GRANT_LITERAL, PROOF_CANT_BE_CONSTRUCTED, type PoPMode, type ProofOfPossession, type ProofOfPossessionCallbacks, type ProofType, type ProofTypesSupported, type PushedAuthorizationResponse, type QRCodeOpts, type RequestObjectOpts, type ResponseEncryption, ResponseType, type RevocationEndpointAuthMethod, type RevocationEndpointAuthSigningAlg, STATE_MANAGER_REQUIRED_ERROR, STATE_MISSING_ERROR, type SearchValue, type StateType, type StatusListOpts, type SubjectProofMode, type SubjectProofNotificationEventsSupported, TYP_ERROR, type TokenEndpointAuthMethod, type TokenEndpointAuthSigningAlg, TokenError, TokenErrorResponse, type TxCode, type TxCodeAndPinRequired, type Typ, UNKNOWN_CLIENT_ERROR, UNSUPPORTED_GRANT_TYPE_ERROR, type URIState, URL_NOT_VALID, USER_PIN_NOT_REQUIRED_ERROR, USER_PIN_REQUIRED_ERROR, USER_PIN_TX_CODE_SPEC_ERROR, type UniformCredentialOffer, type UniformCredentialOfferPayload, type UniformCredentialOfferRequest, type UniformCredentialRequest, VCI_LOGGERS, VCI_LOG_COMMON, WRONG_METADATA_FORMAT, WellKnownEndpoints, acquireDeferredCredential, adjustUrl, assertValidCodeVerifier, assertedUniformCredentialOffer, authorizationServerMetadataFieldNames, convertJsonToURI, convertURIToJsonObject, createCodeChallenge, createProofOfPossession, credentialIssuerMetadataFieldNames, credentialSupportedV8ToV13, credentialsSupportedV8ToV13, decodeJsonProperties, determineFlowType, determineGrantTypes, determineSpecVersionFromOffer, determineSpecVersionFromScheme, determineSpecVersionFromURI, determineVersionsFromIssuerMetadata, extractBearerToken, formPost, generateCodeVerifier, generateNonce, generateRandomString, getClientIdFromCredentialOfferPayload, getCredentialOfferPayload, getCredentialRequestForVersion, getFormatForVersion, getIssuerDisplays, getIssuerFromCredentialOfferPayload, getIssuerName, getJson, getNumberOrUndefined, getScheme, getStateFromCredentialOfferPayload, getSupportedCredential, getSupportedCredentials, getTypesFromAuthorizationDetails, getTypesFromCredentialOffer, getTypesFromCredentialSupported, getTypesFromObject, getTypesFromOfferV1_0_11, getTypesFromRequest, getURIComponentsAsArray, getUniformFormat, isAuthorizationRequestV1_0_09, isAuthorizationRequestV1_0_11, isCredentialOfferVersion, isDeferredCredentialIssuancePending, isDeferredCredentialResponse, isFormat, isJWS, isNotFormat, isPreAuthCode, isValidURL, isW3cCredentialSupported, post, randomBytes, resolveCredentialOfferURI, toAuthorizationResponsePayload, toUniformCredentialOfferPayload, toUniformCredentialOfferRequest, trimBoth, trimEnd, trimStart, validateJWT };
1840
+ export { ACCESS_TOKEN_ISSUER_REQUIRED_ERROR, ALG_ERROR, AUD_ERROR, type AccessTokenFromAuthorizationResponseOpts, type AccessTokenRequest, type AccessTokenRequestOpts, type AccessTokenRequestOptsV1_0_11, type AccessTokenResponse, Alg, type AlgValue, type AssertedUniformCredentialOffer, type AuthorizationChallengeCodeResponse, AuthorizationChallengeError, type AuthorizationChallengeErrorResponse, type AuthorizationChallengeRequestOpts, type AuthorizationDetails, type AuthorizationDetailsJwtVcJson, type AuthorizationDetailsJwtVcJsonLdAndLdpVc, type AuthorizationDetailsMsoMdoc, type AuthorizationDetailsSdJwtVc, type AuthorizationGrantResponse, type AuthorizationRequest, type AuthorizationRequestJwtVcJson, type AuthorizationRequestJwtVcJsonLdAndLdpVc, type AuthorizationRequestMsoMdoc, type AuthorizationRequestOpts, type AuthorizationRequestSdJwtVc, type AuthorizationRequestV1_0_09, type AuthorizationRequestV1_0_11, type AuthorizationResponse, type AuthorizationServerClientOpts, type AuthorizationServerMetadata, type AuthorizationServerOpts, type AuthorizationServerType, AuthzFlowType, BAD_PARAMS, type CNonceState, CODE_VERIFIER_DEFAULT_LENGTH, CREDENTIAL_MISSING_ERROR, type ClientAuthMethod, type ClientMetadata, type ClientResponseType, CodeChallengeMethod, type CommonAuthorizationChallengeRequest, type CommonAuthorizationDetails, type CommonAuthorizationRequest, type CommonCredentialOfferFormat, type CommonCredentialRequest, type CommonCredentialResponse, type CommonCredentialSupported, type CompactJWSHeaderParameters, type ComponentOptions, type CreateCredentialOfferURIResult, CreateRequestObjectMode, type CredentialConfigurationSupported, type CredentialConfigurationSupportedCommonV1_0_13, type CredentialConfigurationSupportedJwtVcJsonLdAndLdpVcV1_0_13, type CredentialConfigurationSupportedJwtVcJsonV1_0_13, type CredentialConfigurationSupportedMsoMdocV1_0_13, type CredentialConfigurationSupportedSdJwtVcV1_0_13, type CredentialConfigurationSupportedV1_0_13, type CredentialDataSupplierInput, type CredentialDefinitionJwtVcJsonLdAndLdpVcV1_0_13, type CredentialDefinitionJwtVcJsonV1_0_13, CredentialEventNames, type CredentialIssuerMetadata, type CredentialIssuerMetadataOpts, type CredentialIssuerMetadataOptsV1_0_13, type CredentialIssuerMetadataV1_0_11, type CredentialIssuerMetadataV1_0_13, type CredentialOffer, CredentialOfferEventNames, type CredentialOfferFormatJwtVcJson, type CredentialOfferFormatJwtVcJsonLdAndLdpVc, type CredentialOfferFormatMsoMdoc, type CredentialOfferFormatSdJwtVc, type CredentialOfferFormatV1_0_11, type CredentialOfferMode, type CredentialOfferPayload, type CredentialOfferPayloadLatest, type CredentialOfferPayloadV1_0_08, type CredentialOfferPayloadV1_0_09, type CredentialOfferPayloadV1_0_11, type CredentialOfferPayloadV1_0_13, type CredentialOfferRESTRequest, type CredentialOfferRESTRequestV1_0_11, type CredentialOfferRequestWithBaseUrl, type CredentialOfferRequestWithBaseUrlV1_0_11, type CredentialOfferSession, type CredentialOfferV1_0_09, type CredentialOfferV1_0_11, type CredentialOfferV1_0_13, type CredentialRequest, type CredentialRequestJwtVcJson, type CredentialRequestJwtVcJsonLdAndLdpVc, type CredentialRequestJwtVcJsonLdAndLdpVcV1_0_13, type CredentialRequestJwtVcJsonV1_0_13, type CredentialRequestMsoMdoc, type CredentialRequestSdJwtVc, type CredentialRequestV1_0_08, type CredentialRequestV1_0_11, type CredentialRequestV1_0_13, type CredentialRequestV1_0_13Common, type CredentialRequestV1_0_13CredentialIdentifier, type CredentialRequestV1_0_13ResponseEncryption, type CredentialRequestWithoutProofV1_0_13, type CredentialResponse, type CredentialResponseJwtVc, type CredentialResponseLdpVc, type CredentialResponseSdJwtVc, type CredentialSubjectDisplay, type CredentialSupplierConfig, type CredentialSupportedBrief, type CredentialSupportedFormatV1_0_08, type CredentialSupportedJwtVcJson, type CredentialSupportedJwtVcJsonLdAndLdpVc, type CredentialSupportedMsoMdoc, type CredentialSupportedSdJwtVc, type CredentialSupportedTypeV1_0_08, type CredentialSupportedV1_0_08, type CredentialsSupportedDisplay, type CredentialsSupportedLegacy, DID_NO_DIDDOC_ERROR, type DPoPResponseParams, type DecodeURIAsJsonOpts, DefaultURISchemes, EVENTS, EXPERIMENTAL_SUBJECT_PROOF_MODE_ENABLED, EXPIRED_PRE_AUTHORIZED_CODE, type EncValue, type EncodeJsonAsURIOpts, Encoding, type EndpointMetadata, type EndpointMetadataResult, type EndpointMetadataResultV1_0_11, type EndpointMetadataResultV1_0_13, type ErrorResponse, type EventNames, type ExperimentalSubjectIssuance, GRANTS_MUST_NOT_BE_UNDEFINED, type Grant, type GrantAuthorizationCode, GrantTypes, type GrantUrnIetf, IAT_ERROR, INVALID_PRE_AUTHORIZED_CODE, ISSUER_CONFIG_ERROR, ISS_MUST_BE_CLIENT_ID, ISS_PRESENT_IN_PRE_AUTHORIZED_CODE_CONTEXT, type IStateManager, type ImageInfo, type InputCharSet, IssueStatus, type IssueStatusResponse, type IssuerCredentialSubject, type IssuerCredentialSubjectDisplay, type IssuerMetadata, type IssuerMetadataV1_0_08, type IssuerMetadataV1_0_13, type IssuerOpts, type JWSHeaderParameters, JWS_NOT_VALID, type JWTHeader, type JWTHeaderParameters, type JWTPayload, type JWTSignerCallback, type JWTVerifyCallback, JWT_SIGNER_CALLBACK_REQUIRED_ERROR, JWT_VERIFY_CONFIG_ERROR, type JoseHeaderParameters, type JsonLdIssuerCredentialDefinition, JsonURIMode, type Jwt, type JwtProps, type JwtVerifyResult, KID_DID_NO_DID_ERROR, KID_JWK_X5C_ERROR, type KeyProofType, type LogEvents, type LogoAndColor, type MetadataDisplay, NONCE_ERROR, NONCE_LENGTH, NONCE_STATE_MANAGER_REQUIRED_ERROR, NO_ISS_IN_AUTHORIZATION_CODE_CONTEXT, NO_JWT_PROVIDED, type NameAndLocale, type NotificationError, type NotificationErrorResponse, type NotificationEventType, type NotificationRequest, type NotificationResponseResult, NotificationStatusEventNames, type OAuthGrantType, type OAuthResponseMode, type OAuthResponseType, type OAuthScope, type OID4VCICredentialFormat, type OpenIDResponse, OpenId4VCIVersion, PARMode, PIN_NOT_MATCH_ERROR, PIN_VALIDATION_ERROR, type PKCECodeChallengeMethod, type PKCEOpts, PRE_AUTHORIZED_CODE_REQUIRED_ERROR, PRE_AUTH_CODE_LITERAL, PRE_AUTH_GRANT_LITERAL, PROOF_CANT_BE_CONSTRUCTED, type PoPMode, type ProofOfPossession, type ProofOfPossessionCallbacks, type ProofType, type ProofTypesSupported, type PushedAuthorizationResponse, type QRCodeOpts, type RequestObjectOpts, type ResponseEncryption, ResponseType, type RevocationEndpointAuthMethod, type RevocationEndpointAuthSigningAlg, STATE_MANAGER_REQUIRED_ERROR, STATE_MISSING_ERROR, type SearchValue, type StateType, type StatusListOpts, type SubjectProofMode, type SubjectProofNotificationEventsSupported, TYP_ERROR, type TokenEndpointAuthMethod, type TokenEndpointAuthSigningAlg, TokenError, TokenErrorResponse, type TxCode, type TxCodeAndPinRequired, type Typ, UNKNOWN_CLIENT_ERROR, UNSUPPORTED_GRANT_TYPE_ERROR, type URIState, URL_NOT_VALID, USER_PIN_NOT_REQUIRED_ERROR, USER_PIN_REQUIRED_ERROR, USER_PIN_TX_CODE_SPEC_ERROR, type UniformCredentialOffer, type UniformCredentialOfferPayload, type UniformCredentialOfferRequest, type UniformCredentialRequest, VCI_LOGGERS, VCI_LOG_COMMON, WRONG_METADATA_FORMAT, WellKnownEndpoints, acquireDeferredCredential, adjustUrl, assertValidCodeVerifier, assertedUniformCredentialOffer, authorizationServerMetadataFieldNames, convertJsonToURI, convertURIToJsonObject, createCodeChallenge, createProofOfPossession, credentialIssuerMetadataFieldNames, credentialSupportedV8ToV13, credentialsSupportedV8ToV13, decodeJsonProperties, determineFlowType, determineGrantTypes, determineSpecVersionFromOffer, determineSpecVersionFromScheme, determineSpecVersionFromURI, determineVersionsFromIssuerMetadata, extractBearerToken, formPost, generateCodeVerifier, generateNonce, generateRandomString, getClientIdFromCredentialOfferPayload, getCredentialOfferPayload, getCredentialRequestForVersion, getFormatForVersion, getIssuerDisplays, getIssuerFromCredentialOfferPayload, getIssuerName, getJson, getNumberOrUndefined, getScheme, getStateFromCredentialOfferPayload, getSupportedCredential, getSupportedCredentials, getTypesFromAuthorizationDetails, getTypesFromCredentialOffer, getTypesFromCredentialSupported, getTypesFromObject, getTypesFromOfferV1_0_11, getTypesFromRequest, getURIComponentsAsArray, getUniformFormat, isAuthorizationRequestV1_0_09, isAuthorizationRequestV1_0_11, isCredentialOfferVersion, isDeferredCredentialIssuancePending, isDeferredCredentialResponse, isFormat, isJWS, isNotFormat, isPreAuthCode, isValidURL, isW3cCredentialSupported, post, resolveCredentialOfferURI, toAuthorizationResponsePayload, toUniformCredentialOfferPayload, toUniformCredentialOfferRequest, trimBoth, trimEnd, trimStart, validateJWT };
package/dist/index.js CHANGED
@@ -1,4 +1,9 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
2
7
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
8
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
4
9
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
@@ -6,45 +11,62 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
6
11
  if (typeof require !== "undefined") return require.apply(this, arguments);
7
12
  throw Error('Dynamic require of "' + x + '" is not supported');
8
13
  });
9
-
10
- // lib/index.ts
11
- import { Loggers } from "@sphereon/ssi-types";
14
+ var __commonJS = (cb, mod) => function __require2() {
15
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
16
+ };
17
+ var __copyProps = (to, from, except, desc) => {
18
+ if (from && typeof from === "object" || typeof from === "function") {
19
+ for (let key of __getOwnPropNames(from))
20
+ if (!__hasOwnProp.call(to, key) && key !== except)
21
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22
+ }
23
+ return to;
24
+ };
25
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26
+ // If the importer is in node compatibility mode or this is not an ESM
27
+ // file that has been converted to a CommonJS file using a Babel-
28
+ // compatible transform (i.e. "__esModule" has not been set), then set
29
+ // "default" to the CommonJS "module.exports" for node compatibility.
30
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31
+ mod
32
+ ));
12
33
 
13
34
  // lib/functions/randomBytes.cjs
14
- var MAX_BYTES = 65536;
15
- var MAX_UINT32 = 4294967295;
16
- function oldBrowser() {
17
- throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11");
18
- }
19
- __name(oldBrowser, "oldBrowser");
20
- var _global = typeof globalThis !== "undefined" ? globalThis : global;
21
- var crypto = _global.crypto || _global.msCrypto;
22
- if (!crypto) {
23
- try {
24
- crypto = __require("crypto");
25
- } catch (err) {
26
- throw Error("crypto module is not available");
27
- }
28
- }
29
- var randomBytes = /* @__PURE__ */ __name((size) => {
30
- if (size > MAX_UINT32) throw new Error("requested too many random bytes");
31
- const bytes = Buffer.allocUnsafe(size);
32
- if (size > 0) {
33
- if (size > MAX_BYTES) {
34
- for (let generated = 0; generated < size; generated += MAX_BYTES) {
35
- crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES));
35
+ var require_randomBytes = __commonJS({
36
+ "lib/functions/randomBytes.cjs"(exports, module) {
37
+ "use strict";
38
+ var MAX_BYTES = 65536;
39
+ var MAX_UINT32 = 4294967295;
40
+ var _global = typeof globalThis !== "undefined" ? globalThis : global;
41
+ var crypto = _global.crypto || _global.msCrypto;
42
+ if (!crypto) {
43
+ try {
44
+ crypto = __require("crypto");
45
+ } catch (err) {
46
+ throw Error("crypto module is not available");
36
47
  }
37
- } else {
38
- crypto.getRandomValues(bytes);
39
48
  }
49
+ function randomBytes2(size) {
50
+ if (size > MAX_UINT32) throw new Error("requested too many random bytes");
51
+ const bytes = Buffer.allocUnsafe(size);
52
+ if (size > 0) {
53
+ if (size > MAX_BYTES) {
54
+ for (let generated = 0; generated < size; generated += MAX_BYTES) {
55
+ crypto.getRandomValues(bytes.slice(generated, generated + MAX_BYTES));
56
+ }
57
+ } else {
58
+ crypto.getRandomValues(bytes);
59
+ }
60
+ }
61
+ return Uint8Array.from(bytes);
62
+ }
63
+ __name(randomBytes2, "randomBytes");
64
+ module.exports = randomBytes2;
40
65
  }
41
- return Uint8Array.from(bytes);
42
- }, "randomBytes");
43
- if (crypto && crypto.getRandomValues) {
44
- module.exports = randomBytes;
45
- } else {
46
- module.exports = oldBrowser;
47
- }
66
+ });
67
+
68
+ // lib/index.ts
69
+ import { Loggers as Loggers4 } from "@sphereon/ssi-types";
48
70
 
49
71
  // lib/types/Generic.types.ts
50
72
  var PRE_AUTH_CODE_LITERAL = "pre-authorized_code";
@@ -391,9 +413,9 @@ function getCredentialRequestForVersion(credentialRequest, version) {
391
413
  __name(getCredentialRequestForVersion, "getCredentialRequestForVersion");
392
414
 
393
415
  // lib/functions/HttpUtils.ts
416
+ import { Loggers } from "@sphereon/ssi-types";
394
417
  import { fetch } from "cross-fetch";
395
- import Debug from "debug";
396
- var debug = Debug("sphereon:openid4vci:http");
418
+ var logger = Loggers.DEFAULT.get("sphereon:openid4vci:http");
397
419
  var getJson = /* @__PURE__ */ __name(async (URL1, opts) => {
398
420
  return await openIdFetch(URL1, void 0, {
399
421
  method: "GET",
@@ -438,25 +460,25 @@ var openIdFetch = /* @__PURE__ */ __name(async (url, body, opts) => {
438
460
  headers,
439
461
  body
440
462
  };
441
- debug(`START fetching url: ${url}`);
463
+ logger.debug(`START fetching url: ${url}`);
442
464
  if (body) {
443
- debug(`Body:\r
465
+ logger.debug(`Body:\r
444
466
  ${typeof body == "string" ? body : JSON.stringify(body)}`);
445
467
  }
446
- debug(`Headers:\r
468
+ logger.debug(`Headers:\r
447
469
  ${JSON.stringify(payload.headers)}`);
448
470
  const origResponse = await fetch(url, payload);
449
471
  const isJSONResponse = accept === "application/json" || origResponse.headers.get("Content-Type") === "application/json";
450
472
  const success = origResponse && origResponse.status >= 200 && origResponse.status < 400;
451
473
  const responseText = await origResponse.text();
452
474
  const responseBody = isJSONResponse && responseText.includes("{") ? JSON.parse(responseText) : responseText;
453
- debug(`${success ? "success" : "error"} status: ${origResponse.status}, body:\r
475
+ logger.debug(`${success ? "success" : "error"} status: ${origResponse.status}, body:\r
454
476
  ${JSON.stringify(responseBody)}`);
455
477
  if (!success && opts?.exceptionOnHttpErrorStatus) {
456
478
  const error = JSON.stringify(responseBody);
457
479
  throw new Error(error === "{}" ? '{"error": "not found"}' : error);
458
480
  }
459
- debug(`END fetching url: ${url}`);
481
+ logger.debug(`END fetching url: ${url}`);
460
482
  return {
461
483
  origResponse,
462
484
  successBody: success ? responseBody : void 0,
@@ -587,9 +609,9 @@ async function acquireDeferredCredentialImpl({ bearerToken, transactionId, defer
587
609
  __name(acquireDeferredCredentialImpl, "acquireDeferredCredentialImpl");
588
610
 
589
611
  // lib/functions/CredentialOfferUtil.ts
590
- import Debug2 from "debug";
612
+ import { Loggers as Loggers2 } from "@sphereon/ssi-types";
591
613
  import { jwtDecode } from "jwt-decode";
592
- var debug2 = Debug2("sphereon:oid4vci:offer");
614
+ var logger2 = Loggers2.DEFAULT.get("sphereon:oid4vci:offer");
593
615
  function determineSpecVersionFromURI(uri) {
594
616
  let version = determineSpecVersionFromScheme(uri, OpenId4VCIVersion.VER_UNKNOWN) ?? OpenId4VCIVersion.VER_UNKNOWN;
595
617
  version = getVersionFromURIParam(uri, version, [
@@ -717,10 +739,10 @@ function isCredentialOfferVersion(offer, min, max) {
717
739
  }
718
740
  const version = determineSpecVersionFromOffer(offer);
719
741
  if (version.valueOf() < min.valueOf()) {
720
- debug2(`Credential offer version (${version.valueOf()}) is lower than minimum required version (${min.valueOf()})`);
742
+ logger2.debug(`Credential offer version (${version.valueOf()}) is lower than minimum required version (${min.valueOf()})`);
721
743
  return false;
722
744
  } else if (max && version.valueOf() > max.valueOf()) {
723
- debug2(`Credential offer version (${version.valueOf()}) is higher than maximum required version (${max.valueOf()})`);
745
+ logger2.debug(`Credential offer version (${version.valueOf()}) is higher than maximum required version (${max.valueOf()})`);
724
746
  return false;
725
747
  }
726
748
  return true;
@@ -1407,12 +1429,12 @@ function getIssuerName(url, credentialIssuerMetadata) {
1407
1429
  __name(getIssuerName, "getIssuerName");
1408
1430
 
1409
1431
  // lib/functions/ProofUtil.ts
1410
- import Debug3 from "debug";
1432
+ import { Loggers as Loggers3 } from "@sphereon/ssi-types";
1411
1433
  import { jwtDecode as jwtDecode2 } from "jwt-decode";
1412
- var debug3 = Debug3("sphereon:openid4vci:common");
1434
+ var logger3 = Loggers3.DEFAULT.get("sphereon:oid4vci:common");
1413
1435
  var createProofOfPossession = /* @__PURE__ */ __name(async (popMode, callbacks, jwtProps, existingJwt) => {
1414
1436
  if (!callbacks.signCallback) {
1415
- debug3(`no jwt signer callback or arguments supplied!`);
1437
+ logger3.debug(`no jwt signer callback or arguments supplied!`);
1416
1438
  throw new Error(BAD_PARAMS);
1417
1439
  }
1418
1440
  const jwtPayload = createJWT(popMode, jwtProps, existingJwt);
@@ -1424,18 +1446,18 @@ var createProofOfPossession = /* @__PURE__ */ __name(async (popMode, callbacks,
1424
1446
  try {
1425
1447
  partiallyValidateJWS(jwt);
1426
1448
  if (callbacks.verifyCallback) {
1427
- debug3(`Calling supplied verify callback....`);
1449
+ logger3.debug(`Calling supplied verify callback....`);
1428
1450
  await callbacks.verifyCallback({
1429
1451
  jwt,
1430
1452
  kid: jwtPayload.header.kid
1431
1453
  });
1432
- debug3(`Supplied verify callback return success result`);
1454
+ logger3.debug(`Supplied verify callback return success result`);
1433
1455
  }
1434
1456
  } catch {
1435
- debug3(`JWS was not valid`);
1457
+ logger3.debug(`JWS was not valid`);
1436
1458
  throw new Error(JWS_NOT_VALID);
1437
1459
  }
1438
- debug3(`Proof of Possession JWT:\r
1460
+ logger3.debug(`Proof of Possession JWT:\r
1439
1461
  ${jwt}`);
1440
1462
  return proof;
1441
1463
  }, "createProofOfPossession");
@@ -1572,10 +1594,12 @@ var toAuthorizationResponsePayload = /* @__PURE__ */ __name((input) => {
1572
1594
  // lib/functions/RandomUtils.ts
1573
1595
  import { defaultHasher } from "@sphereon/oid4vc-common";
1574
1596
  import * as u8a from "uint8arrays";
1597
+ var import_randomBytes = __toESM(require_randomBytes(), 1);
1598
+ var { toString } = u8a;
1575
1599
  var CODE_VERIFIER_DEFAULT_LENGTH = 128;
1576
1600
  var NONCE_LENGTH = 32;
1577
1601
  var generateRandomString = /* @__PURE__ */ __name((length, encoding) => {
1578
- return u8a.toString(randomBytes(length), encoding).slice(0, length);
1602
+ return toString((0, import_randomBytes.default)(length), encoding).slice(0, length);
1579
1603
  }, "generateRandomString");
1580
1604
  var generateNonce = /* @__PURE__ */ __name((length) => {
1581
1605
  return generateRandomString(length ?? NONCE_LENGTH);
@@ -1589,7 +1613,7 @@ var createCodeChallenge = /* @__PURE__ */ __name((codeVerifier, codeChallengeMet
1589
1613
  if (codeChallengeMethod === CodeChallengeMethod.plain) {
1590
1614
  return codeVerifier;
1591
1615
  } else if (!codeChallengeMethod || codeChallengeMethod === CodeChallengeMethod.S256) {
1592
- return u8a.toString(defaultHasher(codeVerifier, "sha256"), "base64url");
1616
+ return toString(defaultHasher(codeVerifier, "sha256"), "base64url");
1593
1617
  } else {
1594
1618
  throw Error(`code challenge method ${codeChallengeMethod} not implemented`);
1595
1619
  }
@@ -1627,7 +1651,7 @@ var NotificationStatusEventNames = /* @__PURE__ */ function(NotificationStatusEv
1627
1651
  var EVENTS = EventManager.instance();
1628
1652
 
1629
1653
  // lib/index.ts
1630
- var VCI_LOGGERS = Loggers.DEFAULT;
1654
+ var VCI_LOGGERS = Loggers4.DEFAULT;
1631
1655
  var VCI_LOG_COMMON = VCI_LOGGERS.get("sphereon:oid4vci:common");
1632
1656
  export {
1633
1657
  ACCESS_TOKEN_ISSUER_REQUIRED_ERROR,
@@ -1750,7 +1774,6 @@ export {
1750
1774
  isValidURL,
1751
1775
  isW3cCredentialSupported,
1752
1776
  post,
1753
- randomBytes,
1754
1777
  resolveCredentialOfferURI,
1755
1778
  toAuthorizationResponsePayload,
1756
1779
  toUniformCredentialOfferPayload,