@sphereon/oid4vci-common
Advanced tools
Comparing version 0.4.1-unstable.260 to 0.4.1-unstable.261
@@ -1,3 +0,10 @@ | ||
import { CredentialIssuerMetadata, CredentialOfferFormat, CredentialSupported } from '../types'; | ||
export declare function getCredentialsSupported(issuerMetadata: CredentialIssuerMetadata, credentialTypes?: (CredentialOfferFormat | string)[], supportedType?: CredentialOfferFormat | string): CredentialSupported[]; | ||
import { CredentialIssuerMetadata, CredentialOfferFormat, CredentialSupported, CredentialSupportedTypeV1_0_08, CredentialSupportedV1_0_08, IssuerMetadataV1_0_08, OpenId4VCIVersion } from '../types'; | ||
export declare function getSupportedCredentials(opts?: { | ||
issuerMetadata?: CredentialIssuerMetadata | IssuerMetadataV1_0_08; | ||
version: OpenId4VCIVersion; | ||
credentialTypes?: (CredentialOfferFormat | string)[]; | ||
supportedType?: CredentialOfferFormat | string; | ||
}): CredentialSupported[]; | ||
export declare function credentialsSupportedV8ToV11(supportedV8: CredentialSupportedTypeV1_0_08): CredentialSupported[]; | ||
export declare function credentialSupportedV8ToV11(key: string, supportedV8: CredentialSupportedV1_0_08): CredentialSupported[]; | ||
//# sourceMappingURL=IssuerMetadataUtils.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getCredentialsSupported = void 0; | ||
function getCredentialsSupported(issuerMetadata, credentialTypes, supportedType) { | ||
const credentialsSupported = issuerMetadata === null || issuerMetadata === void 0 ? void 0 : issuerMetadata.credentials_supported; | ||
exports.credentialSupportedV8ToV11 = exports.credentialsSupportedV8ToV11 = exports.getSupportedCredentials = void 0; | ||
const types_1 = require("../types"); | ||
function getSupportedCredentials(opts) { | ||
const { issuerMetadata } = opts !== null && opts !== void 0 ? opts : {}; | ||
let credentialsSupported; | ||
if (!issuerMetadata) { | ||
return []; | ||
} | ||
const { version, credentialTypes, supportedType } = opts !== null && opts !== void 0 ? opts : { version: types_1.OpenId4VCIVersion.VER_1_0_11 }; | ||
if (version === types_1.OpenId4VCIVersion.VER_1_0_08 || !Array.isArray(issuerMetadata.credentials_supported)) { | ||
credentialsSupported = credentialsSupportedV8ToV11(issuerMetadata.credentials_supported.credentials_supported); | ||
/* const credentialsSupportedV8: CredentialSupportedV1_0_08 = credentialsSupported as CredentialSupportedV1_0_08 | ||
// const initiationTypes = credentialTypes.map(type => typeof type === 'string' ? [type] : type.types) | ||
const supported: IssuerCredentialSubject = {} | ||
for (const [key, value] of Object.entries(credentialsSupportedV8)) { | ||
if (initiationTypes.find((type) => (typeof type === 'string' ? type === key : type.types.includes(key)))) { | ||
supported[key] = value | ||
} | ||
} | ||
// todo: fix this later. we're returning CredentialSupportedV1_0_08 as a list of CredentialSupported (for v09 onward) | ||
return supported as unknown as CredentialSupported[]*/ | ||
} | ||
else { | ||
credentialsSupported = issuerMetadata.credentials_supported; | ||
} | ||
if (!credentialsSupported) { | ||
@@ -16,14 +38,2 @@ return []; | ||
const initiationTypes = supportedType ? [supportedType] : credentialTypes; | ||
if (!Array.isArray(credentialsSupported)) { | ||
const credentialsSupportedV8 = credentialsSupported; | ||
// const initiationTypes = credentialTypes.map(type => typeof type === 'string' ? [type] : type.types) | ||
const supported = {}; | ||
for (const [key, value] of Object.entries(credentialsSupportedV8)) { | ||
if (initiationTypes.find((type) => (typeof type === 'string' ? type === key : type.types.includes(key)))) { | ||
supported[key] = value; | ||
} | ||
} | ||
// todo: fix this later. we're returning CredentialSupportedV1_0_08 as a list of CredentialSupported (for v09 onward) | ||
return supported; | ||
} | ||
const credentialSupportedOverlap = []; | ||
@@ -46,3 +56,24 @@ for (const offerType of initiationTypes) { | ||
} | ||
exports.getCredentialsSupported = getCredentialsSupported; | ||
exports.getSupportedCredentials = getSupportedCredentials; | ||
function credentialsSupportedV8ToV11(supportedV8) { | ||
return Object.entries(supportedV8).flatMap((entry) => { | ||
const type = entry[0]; | ||
const supportedV8 = entry[1]; | ||
return credentialSupportedV8ToV11(type, supportedV8); | ||
}); | ||
} | ||
exports.credentialsSupportedV8ToV11 = credentialsSupportedV8ToV11; | ||
function credentialSupportedV8ToV11(key, supportedV8) { | ||
return Object.entries(supportedV8.formats).map((entry) => { | ||
const format = entry[0]; | ||
const credentialSupportBrief = entry[1]; | ||
if (typeof format !== 'string') { | ||
throw Error(`Unknown format received ${JSON.stringify(format)}`); | ||
} | ||
let credentialSupport = {}; | ||
credentialSupport = Object.assign(Object.assign({ format, display: supportedV8.display }, credentialSupportBrief), { credentialSubject: supportedV8.claims }); | ||
return credentialSupport; | ||
}); | ||
} | ||
exports.credentialSupportedV8ToV11 = credentialSupportedV8ToV11; | ||
//# sourceMappingURL=IssuerMetadataUtils.js.map |
import { ICredentialContextType, IVerifiableCredential, W3CVerifiableCredential } from '@sphereon/ssi-types'; | ||
import { ProofOfPossession } from './CredentialIssuance.types'; | ||
import { Oauth2ASWithOID4VCIMetadata } from './OpenID4VCIServerMetadata'; | ||
import { IssuerMetadataV1_0_08 } from './v1_0_08.types'; | ||
import { CredentialRequestV1_0_11 } from './v1_0_11.types'; | ||
@@ -75,8 +76,2 @@ /** | ||
} | ||
export interface CredentialOfferCredentialDefinition { | ||
'@context': ICredentialContextType[]; | ||
types: string[]; | ||
credentialSubject?: IssuerCredentialSubject; | ||
order?: string[]; | ||
} | ||
export declare enum GrantType { | ||
@@ -87,12 +82,2 @@ AUTHORIZATION_CODE = "authorization_code", | ||
} | ||
export interface CommonAccessTokenRequest { | ||
client_id?: string; | ||
code?: string; | ||
code_verifier?: string; | ||
grant_type: GrantType; | ||
'pre-authorized_code'?: string; | ||
redirect_uri?: string; | ||
scope?: string; | ||
user_pin?: string; | ||
} | ||
export declare enum TokenErrorResponse { | ||
@@ -104,12 +89,2 @@ invalid_request = "invalid_request", | ||
} | ||
export interface CommonAccessTokenResponse { | ||
access_token: string; | ||
scope?: string; | ||
token_type?: string; | ||
expires_in?: number; | ||
c_nonce?: string; | ||
c_nonce_expires_in?: number; | ||
authorization_pending?: boolean; | ||
interval?: number; | ||
} | ||
export interface ErrorResponse extends Response { | ||
@@ -146,2 +121,5 @@ error: string; | ||
} | ||
export interface CredentialResponseJwtVcJson { | ||
credential: string; | ||
} | ||
export type IssuerCredentialSubjectDisplay = CredentialSubjectDisplay & { | ||
@@ -158,5 +136,2 @@ [key: string]: CredentialSubjectDisplay; | ||
} | ||
export interface CredentialResponseJwtVcJson { | ||
credential: string; | ||
} | ||
export interface Grant { | ||
@@ -195,4 +170,4 @@ authorization_code?: GrantAuthorizationCode; | ||
authorization_endpoint?: string; | ||
issuerMetadata?: CredentialIssuerMetadata | Oauth2ASWithOID4VCIMetadata; | ||
issuerMetadata?: CredentialIssuerMetadata | Oauth2ASWithOID4VCIMetadata | IssuerMetadataV1_0_08; | ||
} | ||
//# sourceMappingURL=Generic.types.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.WellKnownEndpoints = exports.PRE_AUTH_CODE_LITERAL = exports.TokenErrorResponse = exports.GrantType = void 0; | ||
/* | ||
export interface CredentialOfferCredentialDefinition { | ||
'@context': ICredentialContextType[]; | ||
types: string[]; | ||
credentialSubject?: IssuerCredentialSubject; | ||
order?: string[]; // An array of claims.display.name values that lists them in the order they should be displayed by the Wallet. | ||
} | ||
*/ | ||
var GrantType; | ||
@@ -10,2 +18,14 @@ (function (GrantType) { | ||
})(GrantType = exports.GrantType || (exports.GrantType = {})); | ||
/* | ||
export interface CommonAccessTokenRequest { | ||
client_id?: string; | ||
code?: string; | ||
code_verifier?: string; | ||
grant_type: GrantType; | ||
'pre-authorized_code'?: string; | ||
redirect_uri?: string; | ||
scope?: string; | ||
user_pin?: string; | ||
} | ||
*/ | ||
var TokenErrorResponse; | ||
@@ -12,0 +32,0 @@ (function (TokenErrorResponse) { |
@@ -1,23 +0,4 @@ | ||
import { CredentialFormat } from '@sphereon/ssi-types'; | ||
import { CredentialIssuerMetadata, IssuerCredentialSubject, MetadataDisplay, NameAndLocale } from './Generic.types'; | ||
import { CredentialIssuerMetadata } from './Generic.types'; | ||
import { OAuth2ASMetadata } from './OAuth2ASMetadata'; | ||
export type Oauth2ASWithOID4VCIMetadata = OAuth2ASMetadata & CredentialIssuerMetadata; | ||
export interface CredentialIssuer { | ||
display?: NameAndLocale[]; | ||
} | ||
export interface CredentialMetadata { | ||
display?: MetadataDisplay[]; | ||
formats: Formats; | ||
claims?: IssuerCredentialSubject; | ||
} | ||
export type OpenID4VCICredentialFormatTypes = CredentialFormat | 'mdl_iso' | 'ac_vc' | string; | ||
export interface CredentialFormatSupport { | ||
types: string[]; | ||
cryptographic_binding_methods_supported?: string[]; | ||
cryptographic_suites_supported?: string[]; | ||
[x: string]: any; | ||
} | ||
export type Formats = { | ||
[format in OpenID4VCICredentialFormatTypes]: CredentialFormatSupport; | ||
}; | ||
//# sourceMappingURL=OpenID4VCIServerMetadata.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// export type OpenID4VCICredentialFormatTypes = CredentialFormat | 'mdl_iso' | 'ac_vc' | string; | ||
/*export interface CredentialFormatSupport { | ||
types: string[]; //REQUIRED. Array of strings representing a format specific type of a Credential. This value corresponds to type in W3C [VC_DATA] and a doctype in ISO/IEC 18013-5 (mobile Driving License). | ||
cryptographic_binding_methods_supported?: string[]; //OPTIONAL. Array of case sensitive strings that identify how the Credential is bound to the identifier of the End-User who possesses the Credential as defined in Section 9.1. A non-exhaustive list of valid values defined by this specification are did, jwk, and mso. | ||
cryptographic_suites_supported?: string[]; //OPTIONAL. Array of case sensitive strings that identify the cryptographic suites that are supported for the cryptographic_binding_methods_supported. Cryptosuites for Credentials in jwt_vc format should use algorithm names defined in IANA JOSE Algorithms Registry. Cryptosuites for Credentials in ldp_vc format should use signature suites names defined in Linked Data Cryptographic Suite Registry. | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
[x: string]: any; //We use any, so you can access properties if you know the structure | ||
}*/ | ||
/* | ||
export type Formats = { | ||
[format in OpenID4VCICredentialFormatTypes]: CredentialFormatSupport; | ||
}; | ||
*/ | ||
//# sourceMappingURL=OpenID4VCIServerMetadata.js.map |
@@ -1,9 +0,39 @@ | ||
import { CredentialIssuerMetadata, CredentialOfferFormat, CredentialSupported, CredentialSupportedV1_0_08, IssuerCredentialSubject } from '../types'; | ||
import { | ||
CredentialIssuerMetadata, | ||
CredentialOfferFormat, | ||
CredentialSupported, | ||
CredentialSupportedTypeV1_0_08, | ||
CredentialSupportedV1_0_08, | ||
IssuerMetadataV1_0_08, | ||
OpenId4VCIVersion, | ||
} from '../types'; | ||
export function getCredentialsSupported( | ||
issuerMetadata: CredentialIssuerMetadata, | ||
credentialTypes?: (CredentialOfferFormat | string)[], | ||
supportedType?: CredentialOfferFormat | string | ||
): CredentialSupported[] { | ||
const credentialsSupported = issuerMetadata?.credentials_supported; | ||
export function getSupportedCredentials(opts?: { | ||
issuerMetadata?: CredentialIssuerMetadata | IssuerMetadataV1_0_08; | ||
version: OpenId4VCIVersion; | ||
credentialTypes?: (CredentialOfferFormat | string)[]; | ||
supportedType?: CredentialOfferFormat | string; | ||
}): CredentialSupported[] { | ||
const { issuerMetadata } = opts ?? {}; | ||
let credentialsSupported: CredentialSupported[]; | ||
if (!issuerMetadata) { | ||
return []; | ||
} | ||
const { version, credentialTypes, supportedType } = opts ?? { version: OpenId4VCIVersion.VER_1_0_11 }; | ||
if (version === OpenId4VCIVersion.VER_1_0_08 || !Array.isArray(issuerMetadata.credentials_supported)) { | ||
credentialsSupported = credentialsSupportedV8ToV11((issuerMetadata.credentials_supported as IssuerMetadataV1_0_08).credentials_supported); | ||
/* const credentialsSupportedV8: CredentialSupportedV1_0_08 = credentialsSupported as CredentialSupportedV1_0_08 | ||
// const initiationTypes = credentialTypes.map(type => typeof type === 'string' ? [type] : type.types) | ||
const supported: IssuerCredentialSubject = {} | ||
for (const [key, value] of Object.entries(credentialsSupportedV8)) { | ||
if (initiationTypes.find((type) => (typeof type === 'string' ? type === key : type.types.includes(key)))) { | ||
supported[key] = value | ||
} | ||
} | ||
// todo: fix this later. we're returning CredentialSupportedV1_0_08 as a list of CredentialSupported (for v09 onward) | ||
return supported as unknown as CredentialSupported[]*/ | ||
} else { | ||
credentialsSupported = (issuerMetadata as CredentialIssuerMetadata).credentials_supported; | ||
} | ||
if (!credentialsSupported) { | ||
@@ -18,14 +48,2 @@ return []; | ||
const initiationTypes = supportedType ? [supportedType] : credentialTypes; | ||
if (!Array.isArray(credentialsSupported)) { | ||
const credentialsSupportedV8: CredentialSupportedV1_0_08 = credentialsSupported as CredentialSupportedV1_0_08; | ||
// const initiationTypes = credentialTypes.map(type => typeof type === 'string' ? [type] : type.types) | ||
const supported: IssuerCredentialSubject = {}; | ||
for (const [key, value] of Object.entries(credentialsSupportedV8)) { | ||
if (initiationTypes.find((type) => (typeof type === 'string' ? type === key : type.types.includes(key)))) { | ||
supported[key] = value; | ||
} | ||
} | ||
// todo: fix this later. we're returning CredentialSupportedV1_0_08 as a list of CredentialSupported (for v09 onward) | ||
return supported as unknown as CredentialSupported[]; | ||
} | ||
@@ -46,3 +64,29 @@ const credentialSupportedOverlap: CredentialSupported[] = []; | ||
} | ||
return credentialSupportedOverlap as CredentialSupported[]; | ||
return credentialSupportedOverlap; | ||
} | ||
export function credentialsSupportedV8ToV11(supportedV8: CredentialSupportedTypeV1_0_08): CredentialSupported[] { | ||
return Object.entries(supportedV8).flatMap((entry) => { | ||
const type = entry[0]; | ||
const supportedV8 = entry[1]; | ||
return credentialSupportedV8ToV11(type, supportedV8); | ||
}); | ||
} | ||
export function credentialSupportedV8ToV11(key: string, supportedV8: CredentialSupportedV1_0_08): CredentialSupported[] { | ||
return Object.entries(supportedV8.formats).map((entry) => { | ||
const format = entry[0]; | ||
const credentialSupportBrief = entry[1]; | ||
if (typeof format !== 'string') { | ||
throw Error(`Unknown format received ${JSON.stringify(format)}`); | ||
} | ||
let credentialSupport: Partial<CredentialSupported> = {}; | ||
credentialSupport = { | ||
format, | ||
display: supportedV8.display, | ||
...credentialSupportBrief, | ||
credentialSubject: supportedV8.claims, | ||
}; | ||
return credentialSupport as CredentialSupported; | ||
}); | ||
} |
@@ -5,2 +5,3 @@ import { ICredentialContextType, IVerifiableCredential, W3CVerifiableCredential } from '@sphereon/ssi-types'; | ||
import { Oauth2ASWithOID4VCIMetadata } from './OpenID4VCIServerMetadata'; | ||
import { IssuerMetadataV1_0_08 } from './v1_0_08.types'; | ||
import { CredentialRequestV1_0_11 } from './v1_0_11.types'; | ||
@@ -103,2 +104,3 @@ | ||
/* | ||
export interface CredentialOfferCredentialDefinition { | ||
@@ -110,2 +112,3 @@ '@context': ICredentialContextType[]; | ||
} | ||
*/ | ||
@@ -118,2 +121,3 @@ export enum GrantType { | ||
/* | ||
export interface CommonAccessTokenRequest { | ||
@@ -129,2 +133,3 @@ client_id?: string; | ||
} | ||
*/ | ||
@@ -138,2 +143,3 @@ export enum TokenErrorResponse { | ||
/* | ||
export interface CommonAccessTokenResponse { | ||
@@ -149,2 +155,3 @@ access_token: string; | ||
} | ||
*/ | ||
@@ -189,2 +196,5 @@ export interface ErrorResponse extends Response { | ||
export interface CredentialResponseJwtVcJson { | ||
credential: string; | ||
} | ||
// export type CredentialSubjectDisplay = NameAndLocale[]; | ||
@@ -204,6 +214,2 @@ | ||
export interface CredentialResponseJwtVcJson { | ||
credential: string; | ||
} | ||
export interface Grant { | ||
@@ -247,3 +253,3 @@ authorization_code?: GrantAuthorizationCode; | ||
authorization_endpoint?: string; | ||
issuerMetadata?: CredentialIssuerMetadata | Oauth2ASWithOID4VCIMetadata; | ||
issuerMetadata?: CredentialIssuerMetadata | Oauth2ASWithOID4VCIMetadata | IssuerMetadataV1_0_08; | ||
} |
@@ -1,4 +0,2 @@ | ||
import { CredentialFormat } from '@sphereon/ssi-types'; | ||
import { CredentialIssuerMetadata, IssuerCredentialSubject, MetadataDisplay, NameAndLocale } from './Generic.types'; | ||
import { CredentialIssuerMetadata } from './Generic.types'; | ||
import { OAuth2ASMetadata } from './OAuth2ASMetadata'; | ||
@@ -8,16 +6,5 @@ | ||
export interface CredentialIssuer { | ||
display?: NameAndLocale[]; //OPTIONAL. An array of objects, where each object contains display properties of a Credential issuer for a certain language. Below is a non-exhaustive list of valid parameters that MAY be included: | ||
} | ||
// export type OpenID4VCICredentialFormatTypes = CredentialFormat | 'mdl_iso' | 'ac_vc' | string; | ||
// https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html#name-credential-metadata-object | ||
export interface CredentialMetadata { | ||
display?: MetadataDisplay[]; //OPTIONAL. An array of objects, where each object contains display properties of a certain Credential for a certain language. Below is a non-exhaustive list of parameters that MAY be included. Note that the display name of the Credential is obtained from display.name and individual claim names from claims.display.name values. | ||
formats: Formats; //REQUIRED. A JSON object containing a list of key value pairs, where the key is a string identifying the format of the Credential. Below is a non-exhaustive list of valid key values defined by this specification: | ||
claims?: IssuerCredentialSubject; //REQUIRED. A JSON object containing a list of key value pairs, where the key identifies the claim offered in the Credential. The value is a JSON object detailing the specifics about the support for the claim | ||
} | ||
export type OpenID4VCICredentialFormatTypes = CredentialFormat | 'mdl_iso' | 'ac_vc' | string; | ||
export interface CredentialFormatSupport { | ||
/*export interface CredentialFormatSupport { | ||
types: string[]; //REQUIRED. Array of strings representing a format specific type of a Credential. This value corresponds to type in W3C [VC_DATA] and a doctype in ISO/IEC 18013-5 (mobile Driving License). | ||
@@ -28,3 +15,4 @@ cryptographic_binding_methods_supported?: string[]; //OPTIONAL. Array of case sensitive strings that identify how the Credential is bound to the identifier of the End-User who possesses the Credential as defined in Section 9.1. A non-exhaustive list of valid values defined by this specification are did, jwk, and mso. | ||
[x: string]: any; //We use any, so you can access properties if you know the structure | ||
} | ||
}*/ | ||
/* | ||
@@ -34,1 +22,2 @@ export type Formats = { | ||
}; | ||
*/ |
{ | ||
"name": "@sphereon/oid4vci-common", | ||
"version": "0.4.1-unstable.260+c6d95a3", | ||
"version": "0.4.1-unstable.261+b06fa22", | ||
"description": "OpenID 4 Verifiable Credential Issuance Common Types", | ||
@@ -48,3 +48,3 @@ "source": "lib/index.ts", | ||
}, | ||
"gitHead": "c6d95a36e9a57bb52f81d703b7d16774a45d1e9d" | ||
"gitHead": "b06fa221bed33e69aa76ae0234779f80314f2887" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
217947
3208