@owf/eudi-attestation-schema 0.2.0-alpha-20260507194220 → 0.2.0
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.cjs +57 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +87 -19
- package/dist/index.d.mts +87 -19
- package/dist/index.mjs +55 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -57,11 +57,52 @@ const TrustAuthoritySchema = zod.z.object({
|
|
|
57
57
|
if (ta.isLOTE !== void 0 && ta.frameworkType !== "etsi_tl") return false;
|
|
58
58
|
return true;
|
|
59
59
|
}, { message: "isLOTE SHALL only be used with frameworkType \"etsi_tl\"" });
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Credential-type metadata for dc+sd-jwt format.
|
|
62
|
+
* vct identifies the credential type per SD-JWT VC spec.
|
|
63
|
+
*/
|
|
64
|
+
const SdJwtMetaSchema = zod.z.object({ vct: zod.z.string().min(1) }).strict();
|
|
65
|
+
/**
|
|
66
|
+
* Credential-type metadata for mso_mdoc format.
|
|
67
|
+
* doctype_value is required.
|
|
68
|
+
*/
|
|
69
|
+
const MsoMdocMetaSchema = zod.z.object({ doctype_value: zod.z.string().min(1) }).strict();
|
|
70
|
+
/**
|
|
71
|
+
* Credential-type metadata for formats without format-specific fields.
|
|
72
|
+
* Allows additional properties for forward compatibility.
|
|
73
|
+
*/
|
|
74
|
+
const GenericMetaSchema = zod.z.object({});
|
|
75
|
+
const _schemaURIBase = {
|
|
62
76
|
uri: zod.z.string().url(),
|
|
63
77
|
integrity: zod.z.string().optional()
|
|
64
|
-
}
|
|
78
|
+
};
|
|
79
|
+
const SchemaURISchema = zod.z.discriminatedUnion("formatIdentifier", [
|
|
80
|
+
zod.z.object({
|
|
81
|
+
..._schemaURIBase,
|
|
82
|
+
formatIdentifier: zod.z.literal("dc+sd-jwt"),
|
|
83
|
+
meta: SdJwtMetaSchema
|
|
84
|
+
}),
|
|
85
|
+
zod.z.object({
|
|
86
|
+
..._schemaURIBase,
|
|
87
|
+
formatIdentifier: zod.z.literal("mso_mdoc"),
|
|
88
|
+
meta: MsoMdocMetaSchema
|
|
89
|
+
}),
|
|
90
|
+
zod.z.object({
|
|
91
|
+
..._schemaURIBase,
|
|
92
|
+
formatIdentifier: zod.z.literal("jwt_vc_json"),
|
|
93
|
+
meta: GenericMetaSchema
|
|
94
|
+
}),
|
|
95
|
+
zod.z.object({
|
|
96
|
+
..._schemaURIBase,
|
|
97
|
+
formatIdentifier: zod.z.literal("jwt_vc_json-ld"),
|
|
98
|
+
meta: GenericMetaSchema
|
|
99
|
+
}),
|
|
100
|
+
zod.z.object({
|
|
101
|
+
..._schemaURIBase,
|
|
102
|
+
formatIdentifier: zod.z.literal("ldp_vc"),
|
|
103
|
+
meta: GenericMetaSchema
|
|
104
|
+
})
|
|
105
|
+
]);
|
|
65
106
|
const SchemaMetaSchema = zod.z.object({
|
|
66
107
|
id: zod.z.string().optional(),
|
|
67
108
|
iat: zod.z.number().optional(),
|
|
@@ -141,6 +182,16 @@ var SchemaURIBuilder = class {
|
|
|
141
182
|
return this;
|
|
142
183
|
}
|
|
143
184
|
/**
|
|
185
|
+
* Set the format-specific credential metadata.
|
|
186
|
+
* - dc+sd-jwt: provide { vct }
|
|
187
|
+
* - mso_mdoc: provide { doctype_value }
|
|
188
|
+
* - other formats: provide {}
|
|
189
|
+
*/
|
|
190
|
+
meta(meta) {
|
|
191
|
+
this.data.meta = meta;
|
|
192
|
+
return this;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
144
195
|
* Build the SchemaURI object
|
|
145
196
|
*/
|
|
146
197
|
build() {
|
|
@@ -372,11 +423,14 @@ exports.BindingTypeSchema = BindingTypeSchema;
|
|
|
372
423
|
exports.BindingTypeValues = BindingTypeValues;
|
|
373
424
|
exports.FrameworkTypeSchema = FrameworkTypeSchema;
|
|
374
425
|
exports.FrameworkTypeValues = FrameworkTypeValues;
|
|
426
|
+
exports.GenericMetaSchema = GenericMetaSchema;
|
|
427
|
+
exports.MsoMdocMetaSchema = MsoMdocMetaSchema;
|
|
375
428
|
exports.SchemaMetaBuilder = SchemaMetaBuilder;
|
|
376
429
|
exports.SchemaMetaException = SchemaMetaException;
|
|
377
430
|
exports.SchemaMetaSchema = SchemaMetaSchema;
|
|
378
431
|
exports.SchemaURIBuilder = SchemaURIBuilder;
|
|
379
432
|
exports.SchemaURISchema = SchemaURISchema;
|
|
433
|
+
exports.SdJwtMetaSchema = SdJwtMetaSchema;
|
|
380
434
|
exports.TrustAuthorityBuilder = TrustAuthorityBuilder;
|
|
381
435
|
exports.TrustAuthoritySchema = TrustAuthoritySchema;
|
|
382
436
|
exports.assertValidSchemaMeta = assertValidSchemaMeta;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["IdentityException","z","parseCertificate"],"sources":["../src/schema-meta-exception.ts","../src/schemas.ts","../src/builders.ts","../src/signer.ts","../src/validator.ts","../src/verifier.ts"],"sourcesContent":["import { IdentityException } from '@owf/identity-common'\n\nexport class SchemaMetaException extends IdentityException {\n constructor(message: string, details?: unknown) {\n super(message, details)\n Object.setPrototypeOf(this, SchemaMetaException.prototype)\n this.name = 'SchemaMetaException'\n }\n}\n","/**\n * SchemaMeta Zod Schemas\n *\n * Zod schemas for the EUDI Catalogue of Attestations SchemaMeta data model.\n * Based on TS11 specification for interfaces and formats for the catalogue of\n * attributes and the catalogue of attestations.\n *\n * @see https://github.com/eu-digital-identity-wallet/eudi-doc-standards-and-technical-specifications/blob/main/docs/technical-specifications/ts11-interfaces-and-formats-for-catalogue-of-attributes-and-catalogue-of-schemes.md\n */\n\nimport { z } from 'zod'\n\n// ============================================================================\n// Enumerations\n// ============================================================================\n\nexport const AttestationFormatValues = ['dc+sd-jwt', 'mso_mdoc', 'jwt_vc_json', 'jwt_vc_json-ld', 'ldp_vc'] as const\n\nexport const AttestationFormatSchema = z.enum(AttestationFormatValues)\n\nexport const AttestationLoSValues = [\n 'iso_18045_high',\n 'iso_18045_moderate',\n 'iso_18045_enhanced-basic',\n 'iso_18045_basic',\n] as const\n\nexport const AttestationLoSSchema = z.enum(AttestationLoSValues)\n\nexport const BindingTypeValues = ['claim', 'key', 'biometric', 'none'] as const\n\nexport const BindingTypeSchema = z.enum(BindingTypeValues)\n\nexport const FrameworkTypeValues = ['aki', 'etsi_tl', 'openid_federation'] as const\n\nexport const FrameworkTypeSchema = z.enum(FrameworkTypeValues)\n\n// ============================================================================\n// TrustAuthority Sub-class (Section 4.3.3)\n// ============================================================================\n\nexport const TrustAuthoritySchema = z\n .object({\n frameworkType: FrameworkTypeSchema,\n value: z.string().min(1),\n isLOTE: z.boolean().optional(),\n })\n .refine(\n (ta) => {\n if (ta.isLOTE !== undefined && ta.frameworkType !== 'etsi_tl') {\n return false\n }\n return true\n },\n { message: 'isLOTE SHALL only be used with frameworkType \"etsi_tl\"' }\n )\n\n// ============================================================================\n// Schema Sub-class (Section 4.3.2)\n// ============================================================================\n\nexport const SchemaURISchema = z.object({\n formatIdentifier: AttestationFormatSchema,\n uri: z.string().url(),\n integrity: z.string().optional(),\n})\n\n// ============================================================================\n// SchemaMeta Main Class (Section 4.3.1)\n// ============================================================================\n\nexport const SchemaMetaSchema = z.object({\n id: z.string().optional(),\n iat: z.number().optional(),\n version: z.string().min(1),\n rulebookURI: z.string().url(),\n rulebookIntegrity: z.string().optional(),\n trustedAuthorities: z.array(TrustAuthoritySchema).optional(),\n attestationLoS: AttestationLoSSchema,\n bindingType: BindingTypeSchema,\n schemaURIs: z.array(SchemaURISchema).min(1),\n})\n","import { SchemaMetaException } from './schema-meta-exception'\nimport { SchemaMetaSchema, SchemaURISchema, TrustAuthoritySchema } from './schemas'\nimport type {\n AttestationFormat,\n AttestationLoS,\n BindingType,\n FrameworkType,\n SchemaMeta,\n SchemaURI,\n TrustAuthority,\n} from './types'\n\n/**\n * Builder for creating TrustAuthority objects with a fluent API\n */\nexport class TrustAuthorityBuilder {\n private data: Partial<TrustAuthority> = {}\n\n /**\n * Set the trust framework type\n */\n frameworkType(type: FrameworkType): this {\n this.data.frameworkType = type\n return this\n }\n\n /**\n * Set the trust authority value (base64url for AKI, URI for etsi_tl/openid_federation)\n */\n value(value: string): this {\n this.data.value = value\n return this\n }\n\n /**\n * Mark as a List of Trusted Entities (only for etsi_tl framework type)\n */\n isLoTE(value = true): this {\n this.data.isLOTE = value\n return this\n }\n\n /**\n * Build the TrustAuthority object\n */\n build(): TrustAuthority {\n const result = TrustAuthoritySchema.safeParse(this.data)\n\n if (!result.success) {\n const messages = result.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid TrustAuthority:\\n${messages}`)\n }\n\n return result.data\n }\n}\n\n/**\n * Builder for creating SchemaURI objects with a fluent API\n */\nexport class SchemaURIBuilder {\n private data: Partial<SchemaURI> = {}\n\n /**\n * Set the format identifier\n */\n format(format: AttestationFormat): this {\n this.data.formatIdentifier = format\n return this\n }\n\n /**\n * Set the schema URI\n */\n uri(uri: string): this {\n this.data.uri = uri\n return this\n }\n\n /**\n * Set the integrity metadata (W3C SRI format, e.g. \"sha256-...\")\n */\n integrity(integrity: string): this {\n this.data.integrity = integrity\n return this\n }\n\n /**\n * Build the SchemaURI object\n */\n build(): SchemaURI {\n const result = SchemaURISchema.safeParse(this.data)\n\n if (!result.success) {\n const messages = result.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid SchemaURI:\\n${messages}`)\n }\n\n return result.data\n }\n}\n\n/**\n * Builder for creating SchemaMeta objects with a fluent API\n */\nexport class SchemaMetaBuilder {\n private data: Partial<SchemaMeta> = {}\n\n /**\n * Set the schema identifier\n */\n id(id: string): this {\n this.data.id = id\n return this\n }\n\n /**\n * Set the schema version (SemVer)\n */\n version(version: string): this {\n this.data.version = version\n return this\n }\n\n /**\n * Set the Attestation Rulebook URI\n */\n rulebookURI(uri: string): this {\n this.data.rulebookURI = uri\n return this\n }\n\n /**\n * Set the integrity metadata for the Attestation Rulebook (W3C SRI format)\n */\n rulebookIntegrity(integrity: string): this {\n this.data.rulebookIntegrity = integrity\n return this\n }\n\n /**\n * Add a trusted authority\n */\n addTrustAuthority(trustAuthority: TrustAuthority): this {\n this.data.trustedAuthorities = this.data.trustedAuthorities ?? []\n this.data.trustedAuthorities.push(trustAuthority)\n return this\n }\n\n /**\n * Set the level of security\n */\n attestationLoS(los: AttestationLoS): this {\n this.data.attestationLoS = los\n return this\n }\n\n /**\n * Set the cryptographic binding type\n */\n bindingType(type: BindingType): this {\n this.data.bindingType = type\n return this\n }\n\n /**\n * Add a schema URI\n */\n addSchemaURI(schemaURI: SchemaURI): this {\n this.data.schemaURIs = this.data.schemaURIs ?? []\n this.data.schemaURIs.push(schemaURI)\n return this\n }\n\n /**\n * Build the SchemaMeta object\n */\n build(): SchemaMeta {\n const result = SchemaMetaSchema.safeParse(this.data)\n\n if (!result.success) {\n const messages = result.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid SchemaMeta:\\n${messages}`)\n }\n\n return result.data\n }\n}\n\n/**\n * Create a new SchemaMetaBuilder\n */\nexport function schemaMeta(): SchemaMetaBuilder {\n return new SchemaMetaBuilder()\n}\n\n/**\n * Create a new TrustAuthorityBuilder\n */\nexport function trustAuthority(): TrustAuthorityBuilder {\n return new TrustAuthorityBuilder()\n}\n\n/**\n * Create a new SchemaURIBuilder\n */\nexport function schemaURI(): SchemaURIBuilder {\n return new SchemaURIBuilder()\n}\n","import { parseCertificate } from '@owf/crypto'\nimport { base64urlEncode } from '@owf/identity-common'\nimport type { SignedSchemaMeta, SignOptions } from './types'\n\n/**\n * Sign a SchemaMeta object as a JWS\n *\n * Per TS11, the Catalogue of Attestations API returns SchemaMeta objects\n * wrapped in JWS-signed JWTs.\n *\n * @example Using a local key via @owf/crypto:\n * ```typescript\n * import { ES256 } from '@owf/crypto'\n * import { signSchemaMeta, schemaMeta, schemaURI } from '@owf/eudi-attestation-schema'\n *\n * const { privateKey } = await ES256.generateKeyPair()\n * const signer = await ES256.getSigner(privateKey)\n *\n * const meta = schemaMeta()\n * .version('1.0.0')\n * .rulebookURI('https://example.com/rulebook.md')\n * .attestationLoS('iso_18045_basic')\n * .bindingType('key')\n * .addSchemaURI(schemaURI().format('dc+sd-jwt').uri('https://example.com/schema.json').build())\n * .build()\n *\n * const signed = await signSchemaMeta({\n * schemaMeta: meta,\n * keyId: 'catalog-signer-2025',\n * certificates: [pemCertificate],\n * signer,\n * })\n * ```\n */\nexport async function signSchemaMeta(options: SignOptions): Promise<SignedSchemaMeta> {\n const { schemaMeta, keyId, algorithm = 'ES256', certificates, signer } = options\n\n const header: Record<string, unknown> = {\n alg: algorithm,\n typ: 'attestation-schema+jwt',\n kid: keyId,\n x5c: certificates.map(parseCertificate),\n }\n\n const iat = Math.floor(Date.now() / 1000)\n const jwtPayload = { ...schemaMeta, iat }\n\n const encodedHeader = base64urlEncode(JSON.stringify(header))\n const encodedPayload = base64urlEncode(JSON.stringify(jwtPayload))\n const signingInput = `${encodedHeader}.${encodedPayload}`\n\n const signature = await signer(signingInput)\n const jws = `${signingInput}.${signature}`\n\n return {\n jws,\n header: {\n alg: algorithm,\n typ: 'attestation-schema+jwt',\n kid: keyId,\n x5c: header.x5c as string[],\n },\n payload: schemaMeta,\n iat,\n }\n}\n","import { SchemaMetaException } from './schema-meta-exception'\nimport { SchemaMetaSchema } from './schemas'\nimport type { SchemaMeta } from './types'\n\nexport interface ValidationError {\n path: string\n message: string\n}\n\nexport interface ValidationResult {\n valid: boolean\n errors: ValidationError[]\n}\n\n/**\n * Validate a SchemaMeta object against the TS11 schema\n */\nexport function validateSchemaMeta(schemaMetaDocument: unknown): ValidationResult {\n const result = SchemaMetaSchema.safeParse(schemaMetaDocument)\n\n if (result.success) {\n return { valid: true, errors: [] }\n }\n\n const errors: ValidationError[] = result.error.issues.map((issue) => ({\n path: issue.path.join('.'),\n message: issue.message,\n }))\n\n return { valid: false, errors }\n}\n\n/**\n * Assert that a SchemaMeta object is valid, throwing if not\n */\nexport function assertValidSchemaMeta(schemaMetaDocument: unknown): asserts schemaMetaDocument is SchemaMeta {\n const result = validateSchemaMeta(schemaMetaDocument)\n if (!result.valid) {\n const errorMessages = result.errors.map((e) => `${e.path}: ${e.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid SchemaMeta:\\n${errorMessages}`)\n }\n}\n","import { decodeJwt } from '@owf/identity-common'\nimport { SchemaMetaException } from './schema-meta-exception'\nimport { SchemaMetaSchema } from './schemas'\nimport type { VerifiedSchemaMeta, VerifyOptions } from './types'\n\n/**\n * Verify and decode a signed SchemaMeta JWS\n *\n * Decodes the JWS, verifies the signature using the provided verifier,\n * and validates the payload against the TS11 SchemaMeta schema.\n *\n * @example\n * ```typescript\n * import { ES256 } from '@owf/crypto'\n * import { verifySchemaMeta } from '@owf/eudi-attestation-schema'\n *\n * const verifier = await ES256.getVerifier(publicKey)\n * const { header, payload } = await verifySchemaMeta({\n * jws: signedJws,\n * verifier,\n * })\n * ```\n */\nexport async function verifySchemaMeta(options: VerifyOptions): Promise<VerifiedSchemaMeta> {\n const { jws, verifier } = options\n\n const { header, payload, signature } = decodeJwt<Record<string, unknown>, Record<string, unknown>>(jws)\n\n const [encodedHeader, encodedPayload] = jws.split('.')\n const signingInput = `${encodedHeader}.${encodedPayload}`\n\n const isValid = await verifier(signingInput, signature)\n if (!isValid) {\n throw new SchemaMetaException('Invalid signature')\n }\n\n const parsed = SchemaMetaSchema.safeParse(payload)\n if (!parsed.success) {\n const messages = parsed.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid SchemaMeta payload:\\n${messages}`)\n }\n\n return {\n header: {\n alg: header.alg as string,\n typ: header.typ as string,\n kid: header.kid as string,\n x5c: header.x5c as string[],\n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,UAAU,CAErD,OAAM,IAAI,oBAAoB,oBAAoB;CAGpD,MAAM,SAAS,iBAAiB,UAAU,QAAQ;AAClD,KAAI,CAAC,OAAO,QAEV,OAAM,IAAI,oBAAoB,gCADb,OAAO,MAAM,OAAO,KAAK,MAAM,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,KAAK,GACtB;AAG3E,QAAO;EACL,QAAQ;GACN,KAAK,OAAO;GACZ,KAAK,OAAO;GACZ,KAAK,OAAO;GACZ,KAAK,OAAO;GACb;EACD,SAAS,OAAO;EAChB,KAAK,OAAO,KAAK,OAAO,KAAK,MAAM,KAAK,KAAK,GAAG,IAAK;EACtD"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["IdentityException","z","parseCertificate"],"sources":["../src/schema-meta-exception.ts","../src/schemas.ts","../src/builders.ts","../src/signer.ts","../src/validator.ts","../src/verifier.ts"],"sourcesContent":["import { IdentityException } from '@owf/identity-common'\n\nexport class SchemaMetaException extends IdentityException {\n constructor(message: string, details?: unknown) {\n super(message, details)\n Object.setPrototypeOf(this, SchemaMetaException.prototype)\n this.name = 'SchemaMetaException'\n }\n}\n","/**\n * SchemaMeta Zod Schemas\n *\n * Zod schemas for the EUDI Catalogue of Attestations SchemaMeta data model.\n * Based on TS11 specification for interfaces and formats for the catalogue of\n * attributes and the catalogue of attestations.\n *\n * @see https://github.com/eu-digital-identity-wallet/eudi-doc-standards-and-technical-specifications/blob/main/docs/technical-specifications/ts11-interfaces-and-formats-for-catalogue-of-attributes-and-catalogue-of-schemes.md\n */\n\nimport { z } from 'zod'\n\n// ============================================================================\n// Enumerations\n// ============================================================================\n\nexport const AttestationFormatValues = ['dc+sd-jwt', 'mso_mdoc', 'jwt_vc_json', 'jwt_vc_json-ld', 'ldp_vc'] as const\n\nexport const AttestationFormatSchema = z.enum(AttestationFormatValues)\n\nexport const AttestationLoSValues = [\n 'iso_18045_high',\n 'iso_18045_moderate',\n 'iso_18045_enhanced-basic',\n 'iso_18045_basic',\n] as const\n\nexport const AttestationLoSSchema = z.enum(AttestationLoSValues)\n\nexport const BindingTypeValues = ['claim', 'key', 'biometric', 'none'] as const\n\nexport const BindingTypeSchema = z.enum(BindingTypeValues)\n\nexport const FrameworkTypeValues = ['aki', 'etsi_tl', 'openid_federation'] as const\n\nexport const FrameworkTypeSchema = z.enum(FrameworkTypeValues)\n\n// ============================================================================\n// TrustAuthority Sub-class (Section 4.3.3)\n// ============================================================================\n\nexport const TrustAuthoritySchema = z\n .object({\n frameworkType: FrameworkTypeSchema,\n value: z.string().min(1),\n isLOTE: z.boolean().optional(),\n })\n .refine(\n (ta) => {\n if (ta.isLOTE !== undefined && ta.frameworkType !== 'etsi_tl') {\n return false\n }\n return true\n },\n { message: 'isLOTE SHALL only be used with frameworkType \"etsi_tl\"' }\n )\n\n// ============================================================================\n// SchemaURI Meta Sub-schemas\n// ============================================================================\n\n/**\n * Credential-type metadata for dc+sd-jwt format.\n * vct identifies the credential type per SD-JWT VC spec.\n */\nexport const SdJwtMetaSchema = z\n .object({\n vct: z.string().min(1),\n })\n .strict()\n\n/**\n * Credential-type metadata for mso_mdoc format.\n * doctype_value is required.\n */\nexport const MsoMdocMetaSchema = z\n .object({\n doctype_value: z.string().min(1),\n })\n .strict()\n\n/**\n * Credential-type metadata for formats without format-specific fields.\n * Allows additional properties for forward compatibility.\n */\nexport const GenericMetaSchema = z.object({})\n\n// ============================================================================\n// Schema Sub-class (Section 4.3.2)\n// ============================================================================\n\nconst _schemaURIBase = {\n uri: z.string().url(),\n integrity: z.string().optional(),\n}\n\nexport const SchemaURISchema = z.discriminatedUnion('formatIdentifier', [\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('dc+sd-jwt'), meta: SdJwtMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('mso_mdoc'), meta: MsoMdocMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('jwt_vc_json'), meta: GenericMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('jwt_vc_json-ld'), meta: GenericMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('ldp_vc'), meta: GenericMetaSchema }),\n])\n\n// ============================================================================\n// SchemaMeta Main Class (Section 4.3.1)\n// ============================================================================\n\nexport const SchemaMetaSchema = z.object({\n id: z.string().optional(),\n iat: z.number().optional(),\n version: z.string().min(1),\n rulebookURI: z.string().url(),\n rulebookIntegrity: z.string().optional(),\n trustedAuthorities: z.array(TrustAuthoritySchema).optional(),\n attestationLoS: AttestationLoSSchema,\n bindingType: BindingTypeSchema,\n schemaURIs: z.array(SchemaURISchema).min(1),\n})\n","import { SchemaMetaException } from './schema-meta-exception'\nimport { SchemaMetaSchema, SchemaURISchema, TrustAuthoritySchema } from './schemas'\nimport type {\n AttestationFormat,\n AttestationLoS,\n BindingType,\n FrameworkType,\n SchemaMeta,\n SchemaURI,\n SchemaURIMeta,\n TrustAuthority,\n} from './types'\n\n/**\n * Builder for creating TrustAuthority objects with a fluent API\n */\nexport class TrustAuthorityBuilder {\n private data: Partial<TrustAuthority> = {}\n\n /**\n * Set the trust framework type\n */\n frameworkType(type: FrameworkType): this {\n this.data.frameworkType = type\n return this\n }\n\n /**\n * Set the trust authority value (base64url for AKI, URI for etsi_tl/openid_federation)\n */\n value(value: string): this {\n this.data.value = value\n return this\n }\n\n /**\n * Mark as a List of Trusted Entities (only for etsi_tl framework type)\n */\n isLoTE(value = true): this {\n this.data.isLOTE = value\n return this\n }\n\n /**\n * Build the TrustAuthority object\n */\n build(): TrustAuthority {\n const result = TrustAuthoritySchema.safeParse(this.data)\n\n if (!result.success) {\n const messages = result.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid TrustAuthority:\\n${messages}`)\n }\n\n return result.data\n }\n}\n\n/**\n * Builder for creating SchemaURI objects with a fluent API\n */\nexport class SchemaURIBuilder {\n private data: Record<string, unknown> = {}\n\n /**\n * Set the format identifier\n */\n format(format: AttestationFormat): this {\n this.data.formatIdentifier = format\n return this\n }\n\n /**\n * Set the schema URI\n */\n uri(uri: string): this {\n this.data.uri = uri\n return this\n }\n\n /**\n * Set the integrity metadata (W3C SRI format, e.g. \"sha256-...\")\n */\n integrity(integrity: string): this {\n this.data.integrity = integrity\n return this\n }\n\n /**\n * Set the format-specific credential metadata.\n * - dc+sd-jwt: provide { vct }\n * - mso_mdoc: provide { doctype_value }\n * - other formats: provide {}\n */\n meta(meta: SchemaURIMeta): this {\n this.data.meta = meta\n return this\n }\n\n /**\n * Build the SchemaURI object\n */\n build(): SchemaURI {\n const result = SchemaURISchema.safeParse(this.data)\n\n if (!result.success) {\n const messages = result.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid SchemaURI:\\n${messages}`)\n }\n\n return result.data\n }\n}\n\n/**\n * Builder for creating SchemaMeta objects with a fluent API\n */\nexport class SchemaMetaBuilder {\n private data: Partial<SchemaMeta> = {}\n\n /**\n * Set the schema identifier\n */\n id(id: string): this {\n this.data.id = id\n return this\n }\n\n /**\n * Set the schema version (SemVer)\n */\n version(version: string): this {\n this.data.version = version\n return this\n }\n\n /**\n * Set the Attestation Rulebook URI\n */\n rulebookURI(uri: string): this {\n this.data.rulebookURI = uri\n return this\n }\n\n /**\n * Set the integrity metadata for the Attestation Rulebook (W3C SRI format)\n */\n rulebookIntegrity(integrity: string): this {\n this.data.rulebookIntegrity = integrity\n return this\n }\n\n /**\n * Add a trusted authority\n */\n addTrustAuthority(trustAuthority: TrustAuthority): this {\n this.data.trustedAuthorities = this.data.trustedAuthorities ?? []\n this.data.trustedAuthorities.push(trustAuthority)\n return this\n }\n\n /**\n * Set the level of security\n */\n attestationLoS(los: AttestationLoS): this {\n this.data.attestationLoS = los\n return this\n }\n\n /**\n * Set the cryptographic binding type\n */\n bindingType(type: BindingType): this {\n this.data.bindingType = type\n return this\n }\n\n /**\n * Add a schema URI\n */\n addSchemaURI(schemaURI: SchemaURI): this {\n this.data.schemaURIs = this.data.schemaURIs ?? []\n this.data.schemaURIs.push(schemaURI)\n return this\n }\n\n /**\n * Build the SchemaMeta object\n */\n build(): SchemaMeta {\n const result = SchemaMetaSchema.safeParse(this.data)\n\n if (!result.success) {\n const messages = result.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid SchemaMeta:\\n${messages}`)\n }\n\n return result.data\n }\n}\n\n/**\n * Create a new SchemaMetaBuilder\n */\nexport function schemaMeta(): SchemaMetaBuilder {\n return new SchemaMetaBuilder()\n}\n\n/**\n * Create a new TrustAuthorityBuilder\n */\nexport function trustAuthority(): TrustAuthorityBuilder {\n return new TrustAuthorityBuilder()\n}\n\n/**\n * Create a new SchemaURIBuilder\n */\nexport function schemaURI(): SchemaURIBuilder {\n return new SchemaURIBuilder()\n}\n","import { parseCertificate } from '@owf/crypto'\nimport { base64urlEncode } from '@owf/identity-common'\nimport type { SignedSchemaMeta, SignOptions } from './types'\n\n/**\n * Sign a SchemaMeta object as a JWS\n *\n * Per TS11, the Catalogue of Attestations API returns SchemaMeta objects\n * wrapped in JWS-signed JWTs.\n *\n * @example Using a local key via @owf/crypto:\n * ```typescript\n * import { ES256 } from '@owf/crypto'\n * import { signSchemaMeta, schemaMeta, schemaURI } from '@owf/eudi-attestation-schema'\n *\n * const { privateKey } = await ES256.generateKeyPair()\n * const signer = await ES256.getSigner(privateKey)\n *\n * const meta = schemaMeta()\n * .version('1.0.0')\n * .rulebookURI('https://example.com/rulebook.md')\n * .attestationLoS('iso_18045_basic')\n * .bindingType('key')\n * .addSchemaURI(schemaURI().format('dc+sd-jwt').uri('https://example.com/schema.json').build())\n * .build()\n *\n * const signed = await signSchemaMeta({\n * schemaMeta: meta,\n * keyId: 'catalog-signer-2025',\n * certificates: [pemCertificate],\n * signer,\n * })\n * ```\n */\nexport async function signSchemaMeta(options: SignOptions): Promise<SignedSchemaMeta> {\n const { schemaMeta, keyId, algorithm = 'ES256', certificates, signer } = options\n\n const header: Record<string, unknown> = {\n alg: algorithm,\n typ: 'attestation-schema+jwt',\n kid: keyId,\n x5c: certificates.map(parseCertificate),\n }\n\n const iat = Math.floor(Date.now() / 1000)\n const jwtPayload = { ...schemaMeta, iat }\n\n const encodedHeader = base64urlEncode(JSON.stringify(header))\n const encodedPayload = base64urlEncode(JSON.stringify(jwtPayload))\n const signingInput = `${encodedHeader}.${encodedPayload}`\n\n const signature = await signer(signingInput)\n const jws = `${signingInput}.${signature}`\n\n return {\n jws,\n header: {\n alg: algorithm,\n typ: 'attestation-schema+jwt',\n kid: keyId,\n x5c: header.x5c as string[],\n },\n payload: schemaMeta,\n iat,\n }\n}\n","import { SchemaMetaException } from './schema-meta-exception'\nimport { SchemaMetaSchema } from './schemas'\nimport type { SchemaMeta } from './types'\n\nexport interface ValidationError {\n path: string\n message: string\n}\n\nexport interface ValidationResult {\n valid: boolean\n errors: ValidationError[]\n}\n\n/**\n * Validate a SchemaMeta object against the TS11 schema\n */\nexport function validateSchemaMeta(schemaMetaDocument: unknown): ValidationResult {\n const result = SchemaMetaSchema.safeParse(schemaMetaDocument)\n\n if (result.success) {\n return { valid: true, errors: [] }\n }\n\n const errors: ValidationError[] = result.error.issues.map((issue) => ({\n path: issue.path.join('.'),\n message: issue.message,\n }))\n\n return { valid: false, errors }\n}\n\n/**\n * Assert that a SchemaMeta object is valid, throwing if not\n */\nexport function assertValidSchemaMeta(schemaMetaDocument: unknown): asserts schemaMetaDocument is SchemaMeta {\n const result = validateSchemaMeta(schemaMetaDocument)\n if (!result.valid) {\n const errorMessages = result.errors.map((e) => `${e.path}: ${e.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid SchemaMeta:\\n${errorMessages}`)\n }\n}\n","import { decodeJwt } from '@owf/identity-common'\nimport { SchemaMetaException } from './schema-meta-exception'\nimport { SchemaMetaSchema } from './schemas'\nimport type { VerifiedSchemaMeta, VerifyOptions } from './types'\n\n/**\n * Verify and decode a signed SchemaMeta JWS\n *\n * Decodes the JWS, verifies the signature using the provided verifier,\n * and validates the payload against the TS11 SchemaMeta schema.\n *\n * @example\n * ```typescript\n * import { ES256 } from '@owf/crypto'\n * import { verifySchemaMeta } from '@owf/eudi-attestation-schema'\n *\n * const verifier = await ES256.getVerifier(publicKey)\n * const { header, payload } = await verifySchemaMeta({\n * jws: signedJws,\n * verifier,\n * })\n * ```\n */\nexport async function verifySchemaMeta(options: VerifyOptions): Promise<VerifiedSchemaMeta> {\n const { jws, verifier } = options\n\n const { header, payload, signature } = decodeJwt<Record<string, unknown>, Record<string, unknown>>(jws)\n\n const [encodedHeader, encodedPayload] = jws.split('.')\n const signingInput = `${encodedHeader}.${encodedPayload}`\n\n const isValid = await verifier(signingInput, signature)\n if (!isValid) {\n throw new SchemaMetaException('Invalid signature')\n }\n\n const parsed = SchemaMetaSchema.safeParse(payload)\n if (!parsed.success) {\n const messages = parsed.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid SchemaMeta payload:\\n${messages}`)\n }\n\n return {\n header: {\n alg: header.alg as string,\n typ: header.typ as string,\n kid: header.kid as string,\n x5c: header.x5c as string[],\n },\n payload: parsed.data,\n iat: parsed.data.iat || Math.floor(Date.now() / 1000),\n }\n}\n"],"mappings":";;;;;AAEA,IAAa,sBAAb,MAAa,4BAA4BA,qBAAAA,kBAAkB;CACzD,YAAY,SAAiB,SAAmB;AAC9C,QAAM,SAAS,QAAQ;AACvB,SAAO,eAAe,MAAM,oBAAoB,UAAU;AAC1D,OAAK,OAAO;;;;;;;;;;;;;;ACUhB,MAAa,0BAA0B;CAAC;CAAa;CAAY;CAAe;CAAkB;CAAS;AAE3G,MAAa,0BAA0BC,IAAAA,EAAE,KAAK,wBAAwB;AAEtE,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACD;AAED,MAAa,uBAAuBA,IAAAA,EAAE,KAAK,qBAAqB;AAEhE,MAAa,oBAAoB;CAA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sB,oBAAuE;CAC3G,MAAM,SAAS,mBAAmB,mBAAmB;AACrD,KAAI,CAAC,OAAO,MAEV,OAAM,IAAI,oBAAoB,wBADR,OAAO,OAAO,KAAK,MAAM,GAAG,EAAE,KAAK,IAAI,EAAE,UAAU,CAAC,KAAK,KAAK,GACd;;;;;;;;;;;;;;;;;;;;;;AChB1E,eAAsB,iBAAiB,SAAqD;CAC1F,MAAM,EAAE,KAAK,aAAa;CAE1B,MAAM,EAAE,QAAQ,SAAS,eAAA,GAAA,qBAAA,WAA0E,IAAI;CAEvG,MAAM,CAAC,eAAe,kBAAkB,IAAI,MAAM,IAAI;AAItD,KAAI,CADY,MAAM,SAFD,GAAG,cAAc,GAAG,kBAEI,UAAU,CAErD,OAAM,IAAI,oBAAoB,oBAAoB;CAGpD,MAAM,SAAS,iBAAiB,UAAU,QAAQ;AAClD,KAAI,CAAC,OAAO,QAEV,OAAM,IAAI,oBAAoB,gCADb,OAAO,MAAM,OAAO,KAAK,MAAM,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,KAAK,GACtB;AAG3E,QAAO;EACL,QAAQ;GACN,KAAK,OAAO;GACZ,KAAK,OAAO;GACZ,KAAK,OAAO;GACZ,KAAK,OAAO;GACb;EACD,SAAS,OAAO;EAChB,KAAK,OAAO,KAAK,OAAO,KAAK,MAAM,KAAK,KAAK,GAAG,IAAK;EACtD"}
|
package/dist/index.d.cts
CHANGED
|
@@ -40,17 +40,55 @@ declare const TrustAuthoritySchema: z.ZodObject<{
|
|
|
40
40
|
value: z.ZodString;
|
|
41
41
|
isLOTE: z.ZodOptional<z.ZodBoolean>;
|
|
42
42
|
}, z.core.$strip>;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Credential-type metadata for dc+sd-jwt format.
|
|
45
|
+
* vct identifies the credential type per SD-JWT VC spec.
|
|
46
|
+
*/
|
|
47
|
+
declare const SdJwtMetaSchema: z.ZodObject<{
|
|
48
|
+
vct: z.ZodString;
|
|
49
|
+
}, z.core.$strict>;
|
|
50
|
+
/**
|
|
51
|
+
* Credential-type metadata for mso_mdoc format.
|
|
52
|
+
* doctype_value is required.
|
|
53
|
+
*/
|
|
54
|
+
declare const MsoMdocMetaSchema: z.ZodObject<{
|
|
55
|
+
doctype_value: z.ZodString;
|
|
56
|
+
}, z.core.$strict>;
|
|
57
|
+
/**
|
|
58
|
+
* Credential-type metadata for formats without format-specific fields.
|
|
59
|
+
* Allows additional properties for forward compatibility.
|
|
60
|
+
*/
|
|
61
|
+
declare const GenericMetaSchema: z.ZodObject<{}, z.core.$strip>;
|
|
62
|
+
declare const SchemaURISchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
63
|
+
formatIdentifier: z.ZodLiteral<"dc+sd-jwt">;
|
|
64
|
+
meta: z.ZodObject<{
|
|
65
|
+
vct: z.ZodString;
|
|
66
|
+
}, z.core.$strict>;
|
|
51
67
|
uri: z.ZodString;
|
|
52
68
|
integrity: z.ZodOptional<z.ZodString>;
|
|
53
|
-
}, z.core.$strip
|
|
69
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
70
|
+
formatIdentifier: z.ZodLiteral<"mso_mdoc">;
|
|
71
|
+
meta: z.ZodObject<{
|
|
72
|
+
doctype_value: z.ZodString;
|
|
73
|
+
}, z.core.$strict>;
|
|
74
|
+
uri: z.ZodString;
|
|
75
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
76
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
77
|
+
formatIdentifier: z.ZodLiteral<"jwt_vc_json">;
|
|
78
|
+
meta: z.ZodObject<{}, z.core.$strip>;
|
|
79
|
+
uri: z.ZodString;
|
|
80
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
81
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
82
|
+
formatIdentifier: z.ZodLiteral<"jwt_vc_json-ld">;
|
|
83
|
+
meta: z.ZodObject<{}, z.core.$strip>;
|
|
84
|
+
uri: z.ZodString;
|
|
85
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
86
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
87
|
+
formatIdentifier: z.ZodLiteral<"ldp_vc">;
|
|
88
|
+
meta: z.ZodObject<{}, z.core.$strip>;
|
|
89
|
+
uri: z.ZodString;
|
|
90
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
91
|
+
}, z.core.$strip>], "formatIdentifier">;
|
|
54
92
|
declare const SchemaMetaSchema: z.ZodObject<{
|
|
55
93
|
id: z.ZodOptional<z.ZodString>;
|
|
56
94
|
iat: z.ZodOptional<z.ZodNumber>;
|
|
@@ -78,17 +116,36 @@ declare const SchemaMetaSchema: z.ZodObject<{
|
|
|
78
116
|
biometric: "biometric";
|
|
79
117
|
none: "none";
|
|
80
118
|
}>;
|
|
81
|
-
schemaURIs: z.ZodArray<z.ZodObject<{
|
|
82
|
-
formatIdentifier: z.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
119
|
+
schemaURIs: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
120
|
+
formatIdentifier: z.ZodLiteral<"dc+sd-jwt">;
|
|
121
|
+
meta: z.ZodObject<{
|
|
122
|
+
vct: z.ZodString;
|
|
123
|
+
}, z.core.$strict>;
|
|
124
|
+
uri: z.ZodString;
|
|
125
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
126
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
127
|
+
formatIdentifier: z.ZodLiteral<"mso_mdoc">;
|
|
128
|
+
meta: z.ZodObject<{
|
|
129
|
+
doctype_value: z.ZodString;
|
|
130
|
+
}, z.core.$strict>;
|
|
131
|
+
uri: z.ZodString;
|
|
132
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
133
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
134
|
+
formatIdentifier: z.ZodLiteral<"jwt_vc_json">;
|
|
135
|
+
meta: z.ZodObject<{}, z.core.$strip>;
|
|
89
136
|
uri: z.ZodString;
|
|
90
137
|
integrity: z.ZodOptional<z.ZodString>;
|
|
91
|
-
}, z.core.$strip
|
|
138
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
139
|
+
formatIdentifier: z.ZodLiteral<"jwt_vc_json-ld">;
|
|
140
|
+
meta: z.ZodObject<{}, z.core.$strip>;
|
|
141
|
+
uri: z.ZodString;
|
|
142
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
143
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
144
|
+
formatIdentifier: z.ZodLiteral<"ldp_vc">;
|
|
145
|
+
meta: z.ZodObject<{}, z.core.$strip>;
|
|
146
|
+
uri: z.ZodString;
|
|
147
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
148
|
+
}, z.core.$strip>], "formatIdentifier">>;
|
|
92
149
|
}, z.core.$strip>;
|
|
93
150
|
//#endregion
|
|
94
151
|
//#region src/types.d.ts
|
|
@@ -97,6 +154,10 @@ type AttestationLoS = z.infer<typeof AttestationLoSSchema>;
|
|
|
97
154
|
type BindingType = z.infer<typeof BindingTypeSchema>;
|
|
98
155
|
type FrameworkType = z.infer<typeof FrameworkTypeSchema>;
|
|
99
156
|
type TrustAuthority = z.infer<typeof TrustAuthoritySchema>;
|
|
157
|
+
type SdJwtMeta = z.infer<typeof SdJwtMetaSchema>;
|
|
158
|
+
type MsoMdocMeta = z.infer<typeof MsoMdocMetaSchema>;
|
|
159
|
+
type GenericMeta = z.infer<typeof GenericMetaSchema>;
|
|
160
|
+
type SchemaURIMeta = SdJwtMeta | MsoMdocMeta | GenericMeta;
|
|
100
161
|
type SchemaURI = z.infer<typeof SchemaURISchema>;
|
|
101
162
|
type SchemaMeta = z.infer<typeof SchemaMetaSchema>;
|
|
102
163
|
interface SignOptions {
|
|
@@ -172,6 +233,13 @@ declare class SchemaURIBuilder {
|
|
|
172
233
|
* Set the integrity metadata (W3C SRI format, e.g. "sha256-...")
|
|
173
234
|
*/
|
|
174
235
|
integrity(integrity: string): this;
|
|
236
|
+
/**
|
|
237
|
+
* Set the format-specific credential metadata.
|
|
238
|
+
* - dc+sd-jwt: provide { vct }
|
|
239
|
+
* - mso_mdoc: provide { doctype_value }
|
|
240
|
+
* - other formats: provide {}
|
|
241
|
+
*/
|
|
242
|
+
meta(meta: SchemaURIMeta): this;
|
|
175
243
|
/**
|
|
176
244
|
* Build the SchemaURI object
|
|
177
245
|
*/
|
|
@@ -309,5 +377,5 @@ declare function assertValidSchemaMeta(schemaMetaDocument: unknown): asserts sch
|
|
|
309
377
|
*/
|
|
310
378
|
declare function verifySchemaMeta(options: VerifyOptions): Promise<VerifiedSchemaMeta>;
|
|
311
379
|
//#endregion
|
|
312
|
-
export { type AttestationFormat, AttestationFormatSchema, AttestationFormatValues, type AttestationLoS, AttestationLoSSchema, AttestationLoSValues, type BindingType, BindingTypeSchema, BindingTypeValues, type FrameworkType, FrameworkTypeSchema, FrameworkTypeValues, type SchemaMeta, SchemaMetaBuilder, SchemaMetaException, SchemaMetaSchema, type SchemaURI, SchemaURIBuilder, SchemaURISchema, type SignOptions, type SignedSchemaMeta, type TrustAuthority, TrustAuthorityBuilder, TrustAuthoritySchema, type ValidationError, type ValidationResult, type VerifiedSchemaMeta, type VerifyOptions, assertValidSchemaMeta, schemaMeta, schemaURI, signSchemaMeta, trustAuthority, validateSchemaMeta, verifySchemaMeta };
|
|
380
|
+
export { type AttestationFormat, AttestationFormatSchema, AttestationFormatValues, type AttestationLoS, AttestationLoSSchema, AttestationLoSValues, type BindingType, BindingTypeSchema, BindingTypeValues, type FrameworkType, FrameworkTypeSchema, FrameworkTypeValues, type GenericMeta, GenericMetaSchema, type MsoMdocMeta, MsoMdocMetaSchema, type SchemaMeta, SchemaMetaBuilder, SchemaMetaException, SchemaMetaSchema, type SchemaURI, SchemaURIBuilder, type SchemaURIMeta, SchemaURISchema, type SdJwtMeta, SdJwtMetaSchema, type SignOptions, type SignedSchemaMeta, type TrustAuthority, TrustAuthorityBuilder, TrustAuthoritySchema, type ValidationError, type ValidationResult, type VerifiedSchemaMeta, type VerifyOptions, assertValidSchemaMeta, schemaMeta, schemaURI, signSchemaMeta, trustAuthority, validateSchemaMeta, verifySchemaMeta };
|
|
313
381
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -40,17 +40,55 @@ declare const TrustAuthoritySchema: z.ZodObject<{
|
|
|
40
40
|
value: z.ZodString;
|
|
41
41
|
isLOTE: z.ZodOptional<z.ZodBoolean>;
|
|
42
42
|
}, z.core.$strip>;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Credential-type metadata for dc+sd-jwt format.
|
|
45
|
+
* vct identifies the credential type per SD-JWT VC spec.
|
|
46
|
+
*/
|
|
47
|
+
declare const SdJwtMetaSchema: z.ZodObject<{
|
|
48
|
+
vct: z.ZodString;
|
|
49
|
+
}, z.core.$strict>;
|
|
50
|
+
/**
|
|
51
|
+
* Credential-type metadata for mso_mdoc format.
|
|
52
|
+
* doctype_value is required.
|
|
53
|
+
*/
|
|
54
|
+
declare const MsoMdocMetaSchema: z.ZodObject<{
|
|
55
|
+
doctype_value: z.ZodString;
|
|
56
|
+
}, z.core.$strict>;
|
|
57
|
+
/**
|
|
58
|
+
* Credential-type metadata for formats without format-specific fields.
|
|
59
|
+
* Allows additional properties for forward compatibility.
|
|
60
|
+
*/
|
|
61
|
+
declare const GenericMetaSchema: z.ZodObject<{}, z.core.$strip>;
|
|
62
|
+
declare const SchemaURISchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
63
|
+
formatIdentifier: z.ZodLiteral<"dc+sd-jwt">;
|
|
64
|
+
meta: z.ZodObject<{
|
|
65
|
+
vct: z.ZodString;
|
|
66
|
+
}, z.core.$strict>;
|
|
51
67
|
uri: z.ZodString;
|
|
52
68
|
integrity: z.ZodOptional<z.ZodString>;
|
|
53
|
-
}, z.core.$strip
|
|
69
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
70
|
+
formatIdentifier: z.ZodLiteral<"mso_mdoc">;
|
|
71
|
+
meta: z.ZodObject<{
|
|
72
|
+
doctype_value: z.ZodString;
|
|
73
|
+
}, z.core.$strict>;
|
|
74
|
+
uri: z.ZodString;
|
|
75
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
76
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
77
|
+
formatIdentifier: z.ZodLiteral<"jwt_vc_json">;
|
|
78
|
+
meta: z.ZodObject<{}, z.core.$strip>;
|
|
79
|
+
uri: z.ZodString;
|
|
80
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
81
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
82
|
+
formatIdentifier: z.ZodLiteral<"jwt_vc_json-ld">;
|
|
83
|
+
meta: z.ZodObject<{}, z.core.$strip>;
|
|
84
|
+
uri: z.ZodString;
|
|
85
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
86
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
87
|
+
formatIdentifier: z.ZodLiteral<"ldp_vc">;
|
|
88
|
+
meta: z.ZodObject<{}, z.core.$strip>;
|
|
89
|
+
uri: z.ZodString;
|
|
90
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
91
|
+
}, z.core.$strip>], "formatIdentifier">;
|
|
54
92
|
declare const SchemaMetaSchema: z.ZodObject<{
|
|
55
93
|
id: z.ZodOptional<z.ZodString>;
|
|
56
94
|
iat: z.ZodOptional<z.ZodNumber>;
|
|
@@ -78,17 +116,36 @@ declare const SchemaMetaSchema: z.ZodObject<{
|
|
|
78
116
|
biometric: "biometric";
|
|
79
117
|
none: "none";
|
|
80
118
|
}>;
|
|
81
|
-
schemaURIs: z.ZodArray<z.ZodObject<{
|
|
82
|
-
formatIdentifier: z.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
119
|
+
schemaURIs: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
120
|
+
formatIdentifier: z.ZodLiteral<"dc+sd-jwt">;
|
|
121
|
+
meta: z.ZodObject<{
|
|
122
|
+
vct: z.ZodString;
|
|
123
|
+
}, z.core.$strict>;
|
|
124
|
+
uri: z.ZodString;
|
|
125
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
126
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
127
|
+
formatIdentifier: z.ZodLiteral<"mso_mdoc">;
|
|
128
|
+
meta: z.ZodObject<{
|
|
129
|
+
doctype_value: z.ZodString;
|
|
130
|
+
}, z.core.$strict>;
|
|
131
|
+
uri: z.ZodString;
|
|
132
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
133
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
134
|
+
formatIdentifier: z.ZodLiteral<"jwt_vc_json">;
|
|
135
|
+
meta: z.ZodObject<{}, z.core.$strip>;
|
|
89
136
|
uri: z.ZodString;
|
|
90
137
|
integrity: z.ZodOptional<z.ZodString>;
|
|
91
|
-
}, z.core.$strip
|
|
138
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
139
|
+
formatIdentifier: z.ZodLiteral<"jwt_vc_json-ld">;
|
|
140
|
+
meta: z.ZodObject<{}, z.core.$strip>;
|
|
141
|
+
uri: z.ZodString;
|
|
142
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
143
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
144
|
+
formatIdentifier: z.ZodLiteral<"ldp_vc">;
|
|
145
|
+
meta: z.ZodObject<{}, z.core.$strip>;
|
|
146
|
+
uri: z.ZodString;
|
|
147
|
+
integrity: z.ZodOptional<z.ZodString>;
|
|
148
|
+
}, z.core.$strip>], "formatIdentifier">>;
|
|
92
149
|
}, z.core.$strip>;
|
|
93
150
|
//#endregion
|
|
94
151
|
//#region src/types.d.ts
|
|
@@ -97,6 +154,10 @@ type AttestationLoS = z.infer<typeof AttestationLoSSchema>;
|
|
|
97
154
|
type BindingType = z.infer<typeof BindingTypeSchema>;
|
|
98
155
|
type FrameworkType = z.infer<typeof FrameworkTypeSchema>;
|
|
99
156
|
type TrustAuthority = z.infer<typeof TrustAuthoritySchema>;
|
|
157
|
+
type SdJwtMeta = z.infer<typeof SdJwtMetaSchema>;
|
|
158
|
+
type MsoMdocMeta = z.infer<typeof MsoMdocMetaSchema>;
|
|
159
|
+
type GenericMeta = z.infer<typeof GenericMetaSchema>;
|
|
160
|
+
type SchemaURIMeta = SdJwtMeta | MsoMdocMeta | GenericMeta;
|
|
100
161
|
type SchemaURI = z.infer<typeof SchemaURISchema>;
|
|
101
162
|
type SchemaMeta = z.infer<typeof SchemaMetaSchema>;
|
|
102
163
|
interface SignOptions {
|
|
@@ -172,6 +233,13 @@ declare class SchemaURIBuilder {
|
|
|
172
233
|
* Set the integrity metadata (W3C SRI format, e.g. "sha256-...")
|
|
173
234
|
*/
|
|
174
235
|
integrity(integrity: string): this;
|
|
236
|
+
/**
|
|
237
|
+
* Set the format-specific credential metadata.
|
|
238
|
+
* - dc+sd-jwt: provide { vct }
|
|
239
|
+
* - mso_mdoc: provide { doctype_value }
|
|
240
|
+
* - other formats: provide {}
|
|
241
|
+
*/
|
|
242
|
+
meta(meta: SchemaURIMeta): this;
|
|
175
243
|
/**
|
|
176
244
|
* Build the SchemaURI object
|
|
177
245
|
*/
|
|
@@ -309,5 +377,5 @@ declare function assertValidSchemaMeta(schemaMetaDocument: unknown): asserts sch
|
|
|
309
377
|
*/
|
|
310
378
|
declare function verifySchemaMeta(options: VerifyOptions): Promise<VerifiedSchemaMeta>;
|
|
311
379
|
//#endregion
|
|
312
|
-
export { type AttestationFormat, AttestationFormatSchema, AttestationFormatValues, type AttestationLoS, AttestationLoSSchema, AttestationLoSValues, type BindingType, BindingTypeSchema, BindingTypeValues, type FrameworkType, FrameworkTypeSchema, FrameworkTypeValues, type SchemaMeta, SchemaMetaBuilder, SchemaMetaException, SchemaMetaSchema, type SchemaURI, SchemaURIBuilder, SchemaURISchema, type SignOptions, type SignedSchemaMeta, type TrustAuthority, TrustAuthorityBuilder, TrustAuthoritySchema, type ValidationError, type ValidationResult, type VerifiedSchemaMeta, type VerifyOptions, assertValidSchemaMeta, schemaMeta, schemaURI, signSchemaMeta, trustAuthority, validateSchemaMeta, verifySchemaMeta };
|
|
380
|
+
export { type AttestationFormat, AttestationFormatSchema, AttestationFormatValues, type AttestationLoS, AttestationLoSSchema, AttestationLoSValues, type BindingType, BindingTypeSchema, BindingTypeValues, type FrameworkType, FrameworkTypeSchema, FrameworkTypeValues, type GenericMeta, GenericMetaSchema, type MsoMdocMeta, MsoMdocMetaSchema, type SchemaMeta, SchemaMetaBuilder, SchemaMetaException, SchemaMetaSchema, type SchemaURI, SchemaURIBuilder, type SchemaURIMeta, SchemaURISchema, type SdJwtMeta, SdJwtMetaSchema, type SignOptions, type SignedSchemaMeta, type TrustAuthority, TrustAuthorityBuilder, TrustAuthoritySchema, type ValidationError, type ValidationResult, type VerifiedSchemaMeta, type VerifyOptions, assertValidSchemaMeta, schemaMeta, schemaURI, signSchemaMeta, trustAuthority, validateSchemaMeta, verifySchemaMeta };
|
|
313
381
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -56,11 +56,52 @@ const TrustAuthoritySchema = z.object({
|
|
|
56
56
|
if (ta.isLOTE !== void 0 && ta.frameworkType !== "etsi_tl") return false;
|
|
57
57
|
return true;
|
|
58
58
|
}, { message: "isLOTE SHALL only be used with frameworkType \"etsi_tl\"" });
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Credential-type metadata for dc+sd-jwt format.
|
|
61
|
+
* vct identifies the credential type per SD-JWT VC spec.
|
|
62
|
+
*/
|
|
63
|
+
const SdJwtMetaSchema = z.object({ vct: z.string().min(1) }).strict();
|
|
64
|
+
/**
|
|
65
|
+
* Credential-type metadata for mso_mdoc format.
|
|
66
|
+
* doctype_value is required.
|
|
67
|
+
*/
|
|
68
|
+
const MsoMdocMetaSchema = z.object({ doctype_value: z.string().min(1) }).strict();
|
|
69
|
+
/**
|
|
70
|
+
* Credential-type metadata for formats without format-specific fields.
|
|
71
|
+
* Allows additional properties for forward compatibility.
|
|
72
|
+
*/
|
|
73
|
+
const GenericMetaSchema = z.object({});
|
|
74
|
+
const _schemaURIBase = {
|
|
61
75
|
uri: z.string().url(),
|
|
62
76
|
integrity: z.string().optional()
|
|
63
|
-
}
|
|
77
|
+
};
|
|
78
|
+
const SchemaURISchema = z.discriminatedUnion("formatIdentifier", [
|
|
79
|
+
z.object({
|
|
80
|
+
..._schemaURIBase,
|
|
81
|
+
formatIdentifier: z.literal("dc+sd-jwt"),
|
|
82
|
+
meta: SdJwtMetaSchema
|
|
83
|
+
}),
|
|
84
|
+
z.object({
|
|
85
|
+
..._schemaURIBase,
|
|
86
|
+
formatIdentifier: z.literal("mso_mdoc"),
|
|
87
|
+
meta: MsoMdocMetaSchema
|
|
88
|
+
}),
|
|
89
|
+
z.object({
|
|
90
|
+
..._schemaURIBase,
|
|
91
|
+
formatIdentifier: z.literal("jwt_vc_json"),
|
|
92
|
+
meta: GenericMetaSchema
|
|
93
|
+
}),
|
|
94
|
+
z.object({
|
|
95
|
+
..._schemaURIBase,
|
|
96
|
+
formatIdentifier: z.literal("jwt_vc_json-ld"),
|
|
97
|
+
meta: GenericMetaSchema
|
|
98
|
+
}),
|
|
99
|
+
z.object({
|
|
100
|
+
..._schemaURIBase,
|
|
101
|
+
formatIdentifier: z.literal("ldp_vc"),
|
|
102
|
+
meta: GenericMetaSchema
|
|
103
|
+
})
|
|
104
|
+
]);
|
|
64
105
|
const SchemaMetaSchema = z.object({
|
|
65
106
|
id: z.string().optional(),
|
|
66
107
|
iat: z.number().optional(),
|
|
@@ -140,6 +181,16 @@ var SchemaURIBuilder = class {
|
|
|
140
181
|
return this;
|
|
141
182
|
}
|
|
142
183
|
/**
|
|
184
|
+
* Set the format-specific credential metadata.
|
|
185
|
+
* - dc+sd-jwt: provide { vct }
|
|
186
|
+
* - mso_mdoc: provide { doctype_value }
|
|
187
|
+
* - other formats: provide {}
|
|
188
|
+
*/
|
|
189
|
+
meta(meta) {
|
|
190
|
+
this.data.meta = meta;
|
|
191
|
+
return this;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
143
194
|
* Build the SchemaURI object
|
|
144
195
|
*/
|
|
145
196
|
build() {
|
|
@@ -363,6 +414,6 @@ async function verifySchemaMeta(options) {
|
|
|
363
414
|
};
|
|
364
415
|
}
|
|
365
416
|
//#endregion
|
|
366
|
-
export { AttestationFormatSchema, AttestationFormatValues, AttestationLoSSchema, AttestationLoSValues, BindingTypeSchema, BindingTypeValues, FrameworkTypeSchema, FrameworkTypeValues, SchemaMetaBuilder, SchemaMetaException, SchemaMetaSchema, SchemaURIBuilder, SchemaURISchema, TrustAuthorityBuilder, TrustAuthoritySchema, assertValidSchemaMeta, schemaMeta, schemaURI, signSchemaMeta, trustAuthority, validateSchemaMeta, verifySchemaMeta };
|
|
417
|
+
export { AttestationFormatSchema, AttestationFormatValues, AttestationLoSSchema, AttestationLoSValues, BindingTypeSchema, BindingTypeValues, FrameworkTypeSchema, FrameworkTypeValues, GenericMetaSchema, MsoMdocMetaSchema, SchemaMetaBuilder, SchemaMetaException, SchemaMetaSchema, SchemaURIBuilder, SchemaURISchema, SdJwtMetaSchema, TrustAuthorityBuilder, TrustAuthoritySchema, assertValidSchemaMeta, schemaMeta, schemaURI, signSchemaMeta, trustAuthority, validateSchemaMeta, verifySchemaMeta };
|
|
367
418
|
|
|
368
419
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/schema-meta-exception.ts","../src/schemas.ts","../src/builders.ts","../src/signer.ts","../src/validator.ts","../src/verifier.ts"],"sourcesContent":["import { IdentityException } from '@owf/identity-common'\n\nexport class SchemaMetaException extends IdentityException {\n constructor(message: string, details?: unknown) {\n super(message, details)\n Object.setPrototypeOf(this, SchemaMetaException.prototype)\n this.name = 'SchemaMetaException'\n }\n}\n","/**\n * SchemaMeta Zod Schemas\n *\n * Zod schemas for the EUDI Catalogue of Attestations SchemaMeta data model.\n * Based on TS11 specification for interfaces and formats for the catalogue of\n * attributes and the catalogue of attestations.\n *\n * @see https://github.com/eu-digital-identity-wallet/eudi-doc-standards-and-technical-specifications/blob/main/docs/technical-specifications/ts11-interfaces-and-formats-for-catalogue-of-attributes-and-catalogue-of-schemes.md\n */\n\nimport { z } from 'zod'\n\n// ============================================================================\n// Enumerations\n// ============================================================================\n\nexport const AttestationFormatValues = ['dc+sd-jwt', 'mso_mdoc', 'jwt_vc_json', 'jwt_vc_json-ld', 'ldp_vc'] as const\n\nexport const AttestationFormatSchema = z.enum(AttestationFormatValues)\n\nexport const AttestationLoSValues = [\n 'iso_18045_high',\n 'iso_18045_moderate',\n 'iso_18045_enhanced-basic',\n 'iso_18045_basic',\n] as const\n\nexport const AttestationLoSSchema = z.enum(AttestationLoSValues)\n\nexport const BindingTypeValues = ['claim', 'key', 'biometric', 'none'] as const\n\nexport const BindingTypeSchema = z.enum(BindingTypeValues)\n\nexport const FrameworkTypeValues = ['aki', 'etsi_tl', 'openid_federation'] as const\n\nexport const FrameworkTypeSchema = z.enum(FrameworkTypeValues)\n\n// ============================================================================\n// TrustAuthority Sub-class (Section 4.3.3)\n// ============================================================================\n\nexport const TrustAuthoritySchema = z\n .object({\n frameworkType: FrameworkTypeSchema,\n value: z.string().min(1),\n isLOTE: z.boolean().optional(),\n })\n .refine(\n (ta) => {\n if (ta.isLOTE !== undefined && ta.frameworkType !== 'etsi_tl') {\n return false\n }\n return true\n },\n { message: 'isLOTE SHALL only be used with frameworkType \"etsi_tl\"' }\n )\n\n// ============================================================================\n// Schema Sub-class (Section 4.3.2)\n// ============================================================================\n\nexport const SchemaURISchema = z.object({\n formatIdentifier: AttestationFormatSchema,\n uri: z.string().url(),\n integrity: z.string().optional(),\n})\n\n// ============================================================================\n// SchemaMeta Main Class (Section 4.3.1)\n// ============================================================================\n\nexport const SchemaMetaSchema = z.object({\n id: z.string().optional(),\n iat: z.number().optional(),\n version: z.string().min(1),\n rulebookURI: z.string().url(),\n rulebookIntegrity: z.string().optional(),\n trustedAuthorities: z.array(TrustAuthoritySchema).optional(),\n attestationLoS: AttestationLoSSchema,\n bindingType: BindingTypeSchema,\n schemaURIs: z.array(SchemaURISchema).min(1),\n})\n","import { SchemaMetaException } from './schema-meta-exception'\nimport { SchemaMetaSchema, SchemaURISchema, TrustAuthoritySchema } from './schemas'\nimport type {\n AttestationFormat,\n AttestationLoS,\n BindingType,\n FrameworkType,\n SchemaMeta,\n SchemaURI,\n TrustAuthority,\n} from './types'\n\n/**\n * Builder for creating TrustAuthority objects with a fluent API\n */\nexport class TrustAuthorityBuilder {\n private data: Partial<TrustAuthority> = {}\n\n /**\n * Set the trust framework type\n */\n frameworkType(type: FrameworkType): this {\n this.data.frameworkType = type\n return this\n }\n\n /**\n * Set the trust authority value (base64url for AKI, URI for etsi_tl/openid_federation)\n */\n value(value: string): this {\n this.data.value = value\n return this\n }\n\n /**\n * Mark as a List of Trusted Entities (only for etsi_tl framework type)\n */\n isLoTE(value = true): this {\n this.data.isLOTE = value\n return this\n }\n\n /**\n * Build the TrustAuthority object\n */\n build(): TrustAuthority {\n const result = TrustAuthoritySchema.safeParse(this.data)\n\n if (!result.success) {\n const messages = result.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid TrustAuthority:\\n${messages}`)\n }\n\n return result.data\n }\n}\n\n/**\n * Builder for creating SchemaURI objects with a fluent API\n */\nexport class SchemaURIBuilder {\n private data: Partial<SchemaURI> = {}\n\n /**\n * Set the format identifier\n */\n format(format: AttestationFormat): this {\n this.data.formatIdentifier = format\n return this\n }\n\n /**\n * Set the schema URI\n */\n uri(uri: string): this {\n this.data.uri = uri\n return this\n }\n\n /**\n * Set the integrity metadata (W3C SRI format, e.g. \"sha256-...\")\n */\n integrity(integrity: string): this {\n this.data.integrity = integrity\n return this\n }\n\n /**\n * Build the SchemaURI object\n */\n build(): SchemaURI {\n const result = SchemaURISchema.safeParse(this.data)\n\n if (!result.success) {\n const messages = result.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid SchemaURI:\\n${messages}`)\n }\n\n return result.data\n }\n}\n\n/**\n * Builder for creating SchemaMeta objects with a fluent API\n */\nexport class SchemaMetaBuilder {\n private data: Partial<SchemaMeta> = {}\n\n /**\n * Set the schema identifier\n */\n id(id: string): this {\n this.data.id = id\n return this\n }\n\n /**\n * Set the schema version (SemVer)\n */\n version(version: string): this {\n this.data.version = version\n return this\n }\n\n /**\n * Set the Attestation Rulebook URI\n */\n rulebookURI(uri: string): this {\n this.data.rulebookURI = uri\n return this\n }\n\n /**\n * Set the integrity metadata for the Attestation Rulebook (W3C SRI format)\n */\n rulebookIntegrity(integrity: string): this {\n this.data.rulebookIntegrity = integrity\n return this\n }\n\n /**\n * Add a trusted authority\n */\n addTrustAuthority(trustAuthority: TrustAuthority): this {\n this.data.trustedAuthorities = this.data.trustedAuthorities ?? []\n this.data.trustedAuthorities.push(trustAuthority)\n return this\n }\n\n /**\n * Set the level of security\n */\n attestationLoS(los: AttestationLoS): this {\n this.data.attestationLoS = los\n return this\n }\n\n /**\n * Set the cryptographic binding type\n */\n bindingType(type: BindingType): this {\n this.data.bindingType = type\n return this\n }\n\n /**\n * Add a schema URI\n */\n addSchemaURI(schemaURI: SchemaURI): this {\n this.data.schemaURIs = this.data.schemaURIs ?? []\n this.data.schemaURIs.push(schemaURI)\n return this\n }\n\n /**\n * Build the SchemaMeta object\n */\n build(): SchemaMeta {\n const result = SchemaMetaSchema.safeParse(this.data)\n\n if (!result.success) {\n const messages = result.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid SchemaMeta:\\n${messages}`)\n }\n\n return result.data\n }\n}\n\n/**\n * Create a new SchemaMetaBuilder\n */\nexport function schemaMeta(): SchemaMetaBuilder {\n return new SchemaMetaBuilder()\n}\n\n/**\n * Create a new TrustAuthorityBuilder\n */\nexport function trustAuthority(): TrustAuthorityBuilder {\n return new TrustAuthorityBuilder()\n}\n\n/**\n * Create a new SchemaURIBuilder\n */\nexport function schemaURI(): SchemaURIBuilder {\n return new SchemaURIBuilder()\n}\n","import { parseCertificate } from '@owf/crypto'\nimport { base64urlEncode } from '@owf/identity-common'\nimport type { SignedSchemaMeta, SignOptions } from './types'\n\n/**\n * Sign a SchemaMeta object as a JWS\n *\n * Per TS11, the Catalogue of Attestations API returns SchemaMeta objects\n * wrapped in JWS-signed JWTs.\n *\n * @example Using a local key via @owf/crypto:\n * ```typescript\n * import { ES256 } from '@owf/crypto'\n * import { signSchemaMeta, schemaMeta, schemaURI } from '@owf/eudi-attestation-schema'\n *\n * const { privateKey } = await ES256.generateKeyPair()\n * const signer = await ES256.getSigner(privateKey)\n *\n * const meta = schemaMeta()\n * .version('1.0.0')\n * .rulebookURI('https://example.com/rulebook.md')\n * .attestationLoS('iso_18045_basic')\n * .bindingType('key')\n * .addSchemaURI(schemaURI().format('dc+sd-jwt').uri('https://example.com/schema.json').build())\n * .build()\n *\n * const signed = await signSchemaMeta({\n * schemaMeta: meta,\n * keyId: 'catalog-signer-2025',\n * certificates: [pemCertificate],\n * signer,\n * })\n * ```\n */\nexport async function signSchemaMeta(options: SignOptions): Promise<SignedSchemaMeta> {\n const { schemaMeta, keyId, algorithm = 'ES256', certificates, signer } = options\n\n const header: Record<string, unknown> = {\n alg: algorithm,\n typ: 'attestation-schema+jwt',\n kid: keyId,\n x5c: certificates.map(parseCertificate),\n }\n\n const iat = Math.floor(Date.now() / 1000)\n const jwtPayload = { ...schemaMeta, iat }\n\n const encodedHeader = base64urlEncode(JSON.stringify(header))\n const encodedPayload = base64urlEncode(JSON.stringify(jwtPayload))\n const signingInput = `${encodedHeader}.${encodedPayload}`\n\n const signature = await signer(signingInput)\n const jws = `${signingInput}.${signature}`\n\n return {\n jws,\n header: {\n alg: algorithm,\n typ: 'attestation-schema+jwt',\n kid: keyId,\n x5c: header.x5c as string[],\n },\n payload: schemaMeta,\n iat,\n }\n}\n","import { SchemaMetaException } from './schema-meta-exception'\nimport { SchemaMetaSchema } from './schemas'\nimport type { SchemaMeta } from './types'\n\nexport interface ValidationError {\n path: string\n message: string\n}\n\nexport interface ValidationResult {\n valid: boolean\n errors: ValidationError[]\n}\n\n/**\n * Validate a SchemaMeta object against the TS11 schema\n */\nexport function validateSchemaMeta(schemaMetaDocument: unknown): ValidationResult {\n const result = SchemaMetaSchema.safeParse(schemaMetaDocument)\n\n if (result.success) {\n return { valid: true, errors: [] }\n }\n\n const errors: ValidationError[] = result.error.issues.map((issue) => ({\n path: issue.path.join('.'),\n message: issue.message,\n }))\n\n return { valid: false, errors }\n}\n\n/**\n * Assert that a SchemaMeta object is valid, throwing if not\n */\nexport function assertValidSchemaMeta(schemaMetaDocument: unknown): asserts schemaMetaDocument is SchemaMeta {\n const result = validateSchemaMeta(schemaMetaDocument)\n if (!result.valid) {\n const errorMessages = result.errors.map((e) => `${e.path}: ${e.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid SchemaMeta:\\n${errorMessages}`)\n }\n}\n","import { decodeJwt } from '@owf/identity-common'\nimport { SchemaMetaException } from './schema-meta-exception'\nimport { SchemaMetaSchema } from './schemas'\nimport type { VerifiedSchemaMeta, VerifyOptions } from './types'\n\n/**\n * Verify and decode a signed SchemaMeta JWS\n *\n * Decodes the JWS, verifies the signature using the provided verifier,\n * and validates the payload against the TS11 SchemaMeta schema.\n *\n * @example\n * ```typescript\n * import { ES256 } from '@owf/crypto'\n * import { verifySchemaMeta } from '@owf/eudi-attestation-schema'\n *\n * const verifier = await ES256.getVerifier(publicKey)\n * const { header, payload } = await verifySchemaMeta({\n * jws: signedJws,\n * verifier,\n * })\n * ```\n */\nexport async function verifySchemaMeta(options: VerifyOptions): Promise<VerifiedSchemaMeta> {\n const { jws, verifier } = options\n\n const { header, payload, signature } = decodeJwt<Record<string, unknown>, Record<string, unknown>>(jws)\n\n const [encodedHeader, encodedPayload] = jws.split('.')\n const signingInput = `${encodedHeader}.${encodedPayload}`\n\n const isValid = await verifier(signingInput, signature)\n if (!isValid) {\n throw new SchemaMetaException('Invalid signature')\n }\n\n const parsed = SchemaMetaSchema.safeParse(payload)\n if (!parsed.success) {\n const messages = parsed.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid SchemaMeta payload:\\n${messages}`)\n }\n\n return {\n header: {\n alg: header.alg as string,\n typ: header.typ as string,\n kid: header.kid as string,\n x5c: header.x5c as string[],\n },\n payload: parsed.data,\n iat: parsed.data.iat || Math.floor(Date.now() / 1000),\n }\n}\n"],"mappings":";;;;AAEA,IAAa,sBAAb,MAAa,4BAA4B,kBAAkB;CACzD,YAAY,SAAiB,SAAmB;AAC9C,QAAM,SAAS,QAAQ;AACvB,SAAO,eAAe,MAAM,oBAAoB,UAAU;AAC1D,OAAK,OAAO;;;;;;;;;;;;;;ACUhB,MAAa,0BAA0B;CAAC;CAAa;CAAY;CAAe;CAAkB;CAAS;AAE3G,MAAa,0BAA0B,EAAE,KAAK,wBAAwB;AAEtE,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACD;AAED,MAAa,uBAAuB,EAAE,KAAK,qBAAqB;AAEhE,MAAa,oBAAoB;CAAC;CAAS;CAAO;CAAa;CAAO;AAEtE,MAAa,oBAAoB,EAAE,KAAK,kBAAkB;AAE1D,MAAa,sBAAsB;CAAC;CAAO;CAAW;CAAoB;AAE1E,MAAa,sBAAsB,EAAE,KAAK,oBAAoB;AAM9D,MAAa,uBAA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mB,mBAAmB;AACrD,KAAI,CAAC,OAAO,MAEV,OAAM,IAAI,oBAAoB,wBADR,OAAO,OAAO,KAAK,MAAM,GAAG,EAAE,KAAK,IAAI,EAAE,UAAU,CAAC,KAAK,KAAK,GACd;;;;;;;;;;;;;;;;;;;;;;AChB1E,eAAsB,iBAAiB,SAAqD;CAC1F,MAAM,EAAE,KAAK,aAAa;CAE1B,MAAM,EAAE,QAAQ,SAAS,cAAc,UAA4D,IAAI;CAEvG,MAAM,CAAC,eAAe,kBAAkB,IAAI,MAAM,IAAI;AAItD,KAAI,CADY,MAAM,SAFD,GAAG,cAAc,GAAG,kBAEI,UAAU,CAErD,OAAM,IAAI,oBAAoB,oBAAoB;CAGpD,MAAM,SAAS,iBAAiB,UAAU,QAAQ;AAClD,KAAI,CAAC,OAAO,QAEV,OAAM,IAAI,oBAAoB,gCADb,OAAO,MAAM,OAAO,KAAK,MAAM,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,KAAK,GACtB;AAG3E,QAAO;EACL,QAAQ;GACN,KAAK,OAAO;GACZ,KAAK,OAAO;GACZ,KAAK,OAAO;GACZ,KAAK,OAAO;GACb;EACD,SAAS,OAAO;EAChB,KAAK,OAAO,KAAK,OAAO,KAAK,MAAM,KAAK,KAAK,GAAG,IAAK;EACtD"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/schema-meta-exception.ts","../src/schemas.ts","../src/builders.ts","../src/signer.ts","../src/validator.ts","../src/verifier.ts"],"sourcesContent":["import { IdentityException } from '@owf/identity-common'\n\nexport class SchemaMetaException extends IdentityException {\n constructor(message: string, details?: unknown) {\n super(message, details)\n Object.setPrototypeOf(this, SchemaMetaException.prototype)\n this.name = 'SchemaMetaException'\n }\n}\n","/**\n * SchemaMeta Zod Schemas\n *\n * Zod schemas for the EUDI Catalogue of Attestations SchemaMeta data model.\n * Based on TS11 specification for interfaces and formats for the catalogue of\n * attributes and the catalogue of attestations.\n *\n * @see https://github.com/eu-digital-identity-wallet/eudi-doc-standards-and-technical-specifications/blob/main/docs/technical-specifications/ts11-interfaces-and-formats-for-catalogue-of-attributes-and-catalogue-of-schemes.md\n */\n\nimport { z } from 'zod'\n\n// ============================================================================\n// Enumerations\n// ============================================================================\n\nexport const AttestationFormatValues = ['dc+sd-jwt', 'mso_mdoc', 'jwt_vc_json', 'jwt_vc_json-ld', 'ldp_vc'] as const\n\nexport const AttestationFormatSchema = z.enum(AttestationFormatValues)\n\nexport const AttestationLoSValues = [\n 'iso_18045_high',\n 'iso_18045_moderate',\n 'iso_18045_enhanced-basic',\n 'iso_18045_basic',\n] as const\n\nexport const AttestationLoSSchema = z.enum(AttestationLoSValues)\n\nexport const BindingTypeValues = ['claim', 'key', 'biometric', 'none'] as const\n\nexport const BindingTypeSchema = z.enum(BindingTypeValues)\n\nexport const FrameworkTypeValues = ['aki', 'etsi_tl', 'openid_federation'] as const\n\nexport const FrameworkTypeSchema = z.enum(FrameworkTypeValues)\n\n// ============================================================================\n// TrustAuthority Sub-class (Section 4.3.3)\n// ============================================================================\n\nexport const TrustAuthoritySchema = z\n .object({\n frameworkType: FrameworkTypeSchema,\n value: z.string().min(1),\n isLOTE: z.boolean().optional(),\n })\n .refine(\n (ta) => {\n if (ta.isLOTE !== undefined && ta.frameworkType !== 'etsi_tl') {\n return false\n }\n return true\n },\n { message: 'isLOTE SHALL only be used with frameworkType \"etsi_tl\"' }\n )\n\n// ============================================================================\n// SchemaURI Meta Sub-schemas\n// ============================================================================\n\n/**\n * Credential-type metadata for dc+sd-jwt format.\n * vct identifies the credential type per SD-JWT VC spec.\n */\nexport const SdJwtMetaSchema = z\n .object({\n vct: z.string().min(1),\n })\n .strict()\n\n/**\n * Credential-type metadata for mso_mdoc format.\n * doctype_value is required.\n */\nexport const MsoMdocMetaSchema = z\n .object({\n doctype_value: z.string().min(1),\n })\n .strict()\n\n/**\n * Credential-type metadata for formats without format-specific fields.\n * Allows additional properties for forward compatibility.\n */\nexport const GenericMetaSchema = z.object({})\n\n// ============================================================================\n// Schema Sub-class (Section 4.3.2)\n// ============================================================================\n\nconst _schemaURIBase = {\n uri: z.string().url(),\n integrity: z.string().optional(),\n}\n\nexport const SchemaURISchema = z.discriminatedUnion('formatIdentifier', [\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('dc+sd-jwt'), meta: SdJwtMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('mso_mdoc'), meta: MsoMdocMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('jwt_vc_json'), meta: GenericMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('jwt_vc_json-ld'), meta: GenericMetaSchema }),\n z.object({ ..._schemaURIBase, formatIdentifier: z.literal('ldp_vc'), meta: GenericMetaSchema }),\n])\n\n// ============================================================================\n// SchemaMeta Main Class (Section 4.3.1)\n// ============================================================================\n\nexport const SchemaMetaSchema = z.object({\n id: z.string().optional(),\n iat: z.number().optional(),\n version: z.string().min(1),\n rulebookURI: z.string().url(),\n rulebookIntegrity: z.string().optional(),\n trustedAuthorities: z.array(TrustAuthoritySchema).optional(),\n attestationLoS: AttestationLoSSchema,\n bindingType: BindingTypeSchema,\n schemaURIs: z.array(SchemaURISchema).min(1),\n})\n","import { SchemaMetaException } from './schema-meta-exception'\nimport { SchemaMetaSchema, SchemaURISchema, TrustAuthoritySchema } from './schemas'\nimport type {\n AttestationFormat,\n AttestationLoS,\n BindingType,\n FrameworkType,\n SchemaMeta,\n SchemaURI,\n SchemaURIMeta,\n TrustAuthority,\n} from './types'\n\n/**\n * Builder for creating TrustAuthority objects with a fluent API\n */\nexport class TrustAuthorityBuilder {\n private data: Partial<TrustAuthority> = {}\n\n /**\n * Set the trust framework type\n */\n frameworkType(type: FrameworkType): this {\n this.data.frameworkType = type\n return this\n }\n\n /**\n * Set the trust authority value (base64url for AKI, URI for etsi_tl/openid_federation)\n */\n value(value: string): this {\n this.data.value = value\n return this\n }\n\n /**\n * Mark as a List of Trusted Entities (only for etsi_tl framework type)\n */\n isLoTE(value = true): this {\n this.data.isLOTE = value\n return this\n }\n\n /**\n * Build the TrustAuthority object\n */\n build(): TrustAuthority {\n const result = TrustAuthoritySchema.safeParse(this.data)\n\n if (!result.success) {\n const messages = result.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid TrustAuthority:\\n${messages}`)\n }\n\n return result.data\n }\n}\n\n/**\n * Builder for creating SchemaURI objects with a fluent API\n */\nexport class SchemaURIBuilder {\n private data: Record<string, unknown> = {}\n\n /**\n * Set the format identifier\n */\n format(format: AttestationFormat): this {\n this.data.formatIdentifier = format\n return this\n }\n\n /**\n * Set the schema URI\n */\n uri(uri: string): this {\n this.data.uri = uri\n return this\n }\n\n /**\n * Set the integrity metadata (W3C SRI format, e.g. \"sha256-...\")\n */\n integrity(integrity: string): this {\n this.data.integrity = integrity\n return this\n }\n\n /**\n * Set the format-specific credential metadata.\n * - dc+sd-jwt: provide { vct }\n * - mso_mdoc: provide { doctype_value }\n * - other formats: provide {}\n */\n meta(meta: SchemaURIMeta): this {\n this.data.meta = meta\n return this\n }\n\n /**\n * Build the SchemaURI object\n */\n build(): SchemaURI {\n const result = SchemaURISchema.safeParse(this.data)\n\n if (!result.success) {\n const messages = result.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid SchemaURI:\\n${messages}`)\n }\n\n return result.data\n }\n}\n\n/**\n * Builder for creating SchemaMeta objects with a fluent API\n */\nexport class SchemaMetaBuilder {\n private data: Partial<SchemaMeta> = {}\n\n /**\n * Set the schema identifier\n */\n id(id: string): this {\n this.data.id = id\n return this\n }\n\n /**\n * Set the schema version (SemVer)\n */\n version(version: string): this {\n this.data.version = version\n return this\n }\n\n /**\n * Set the Attestation Rulebook URI\n */\n rulebookURI(uri: string): this {\n this.data.rulebookURI = uri\n return this\n }\n\n /**\n * Set the integrity metadata for the Attestation Rulebook (W3C SRI format)\n */\n rulebookIntegrity(integrity: string): this {\n this.data.rulebookIntegrity = integrity\n return this\n }\n\n /**\n * Add a trusted authority\n */\n addTrustAuthority(trustAuthority: TrustAuthority): this {\n this.data.trustedAuthorities = this.data.trustedAuthorities ?? []\n this.data.trustedAuthorities.push(trustAuthority)\n return this\n }\n\n /**\n * Set the level of security\n */\n attestationLoS(los: AttestationLoS): this {\n this.data.attestationLoS = los\n return this\n }\n\n /**\n * Set the cryptographic binding type\n */\n bindingType(type: BindingType): this {\n this.data.bindingType = type\n return this\n }\n\n /**\n * Add a schema URI\n */\n addSchemaURI(schemaURI: SchemaURI): this {\n this.data.schemaURIs = this.data.schemaURIs ?? []\n this.data.schemaURIs.push(schemaURI)\n return this\n }\n\n /**\n * Build the SchemaMeta object\n */\n build(): SchemaMeta {\n const result = SchemaMetaSchema.safeParse(this.data)\n\n if (!result.success) {\n const messages = result.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid SchemaMeta:\\n${messages}`)\n }\n\n return result.data\n }\n}\n\n/**\n * Create a new SchemaMetaBuilder\n */\nexport function schemaMeta(): SchemaMetaBuilder {\n return new SchemaMetaBuilder()\n}\n\n/**\n * Create a new TrustAuthorityBuilder\n */\nexport function trustAuthority(): TrustAuthorityBuilder {\n return new TrustAuthorityBuilder()\n}\n\n/**\n * Create a new SchemaURIBuilder\n */\nexport function schemaURI(): SchemaURIBuilder {\n return new SchemaURIBuilder()\n}\n","import { parseCertificate } from '@owf/crypto'\nimport { base64urlEncode } from '@owf/identity-common'\nimport type { SignedSchemaMeta, SignOptions } from './types'\n\n/**\n * Sign a SchemaMeta object as a JWS\n *\n * Per TS11, the Catalogue of Attestations API returns SchemaMeta objects\n * wrapped in JWS-signed JWTs.\n *\n * @example Using a local key via @owf/crypto:\n * ```typescript\n * import { ES256 } from '@owf/crypto'\n * import { signSchemaMeta, schemaMeta, schemaURI } from '@owf/eudi-attestation-schema'\n *\n * const { privateKey } = await ES256.generateKeyPair()\n * const signer = await ES256.getSigner(privateKey)\n *\n * const meta = schemaMeta()\n * .version('1.0.0')\n * .rulebookURI('https://example.com/rulebook.md')\n * .attestationLoS('iso_18045_basic')\n * .bindingType('key')\n * .addSchemaURI(schemaURI().format('dc+sd-jwt').uri('https://example.com/schema.json').build())\n * .build()\n *\n * const signed = await signSchemaMeta({\n * schemaMeta: meta,\n * keyId: 'catalog-signer-2025',\n * certificates: [pemCertificate],\n * signer,\n * })\n * ```\n */\nexport async function signSchemaMeta(options: SignOptions): Promise<SignedSchemaMeta> {\n const { schemaMeta, keyId, algorithm = 'ES256', certificates, signer } = options\n\n const header: Record<string, unknown> = {\n alg: algorithm,\n typ: 'attestation-schema+jwt',\n kid: keyId,\n x5c: certificates.map(parseCertificate),\n }\n\n const iat = Math.floor(Date.now() / 1000)\n const jwtPayload = { ...schemaMeta, iat }\n\n const encodedHeader = base64urlEncode(JSON.stringify(header))\n const encodedPayload = base64urlEncode(JSON.stringify(jwtPayload))\n const signingInput = `${encodedHeader}.${encodedPayload}`\n\n const signature = await signer(signingInput)\n const jws = `${signingInput}.${signature}`\n\n return {\n jws,\n header: {\n alg: algorithm,\n typ: 'attestation-schema+jwt',\n kid: keyId,\n x5c: header.x5c as string[],\n },\n payload: schemaMeta,\n iat,\n }\n}\n","import { SchemaMetaException } from './schema-meta-exception'\nimport { SchemaMetaSchema } from './schemas'\nimport type { SchemaMeta } from './types'\n\nexport interface ValidationError {\n path: string\n message: string\n}\n\nexport interface ValidationResult {\n valid: boolean\n errors: ValidationError[]\n}\n\n/**\n * Validate a SchemaMeta object against the TS11 schema\n */\nexport function validateSchemaMeta(schemaMetaDocument: unknown): ValidationResult {\n const result = SchemaMetaSchema.safeParse(schemaMetaDocument)\n\n if (result.success) {\n return { valid: true, errors: [] }\n }\n\n const errors: ValidationError[] = result.error.issues.map((issue) => ({\n path: issue.path.join('.'),\n message: issue.message,\n }))\n\n return { valid: false, errors }\n}\n\n/**\n * Assert that a SchemaMeta object is valid, throwing if not\n */\nexport function assertValidSchemaMeta(schemaMetaDocument: unknown): asserts schemaMetaDocument is SchemaMeta {\n const result = validateSchemaMeta(schemaMetaDocument)\n if (!result.valid) {\n const errorMessages = result.errors.map((e) => `${e.path}: ${e.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid SchemaMeta:\\n${errorMessages}`)\n }\n}\n","import { decodeJwt } from '@owf/identity-common'\nimport { SchemaMetaException } from './schema-meta-exception'\nimport { SchemaMetaSchema } from './schemas'\nimport type { VerifiedSchemaMeta, VerifyOptions } from './types'\n\n/**\n * Verify and decode a signed SchemaMeta JWS\n *\n * Decodes the JWS, verifies the signature using the provided verifier,\n * and validates the payload against the TS11 SchemaMeta schema.\n *\n * @example\n * ```typescript\n * import { ES256 } from '@owf/crypto'\n * import { verifySchemaMeta } from '@owf/eudi-attestation-schema'\n *\n * const verifier = await ES256.getVerifier(publicKey)\n * const { header, payload } = await verifySchemaMeta({\n * jws: signedJws,\n * verifier,\n * })\n * ```\n */\nexport async function verifySchemaMeta(options: VerifyOptions): Promise<VerifiedSchemaMeta> {\n const { jws, verifier } = options\n\n const { header, payload, signature } = decodeJwt<Record<string, unknown>, Record<string, unknown>>(jws)\n\n const [encodedHeader, encodedPayload] = jws.split('.')\n const signingInput = `${encodedHeader}.${encodedPayload}`\n\n const isValid = await verifier(signingInput, signature)\n if (!isValid) {\n throw new SchemaMetaException('Invalid signature')\n }\n\n const parsed = SchemaMetaSchema.safeParse(payload)\n if (!parsed.success) {\n const messages = parsed.error.issues.map((i) => `${i.path.join('.')}: ${i.message}`).join('\\n')\n throw new SchemaMetaException(`Invalid SchemaMeta payload:\\n${messages}`)\n }\n\n return {\n header: {\n alg: header.alg as string,\n typ: header.typ as string,\n kid: header.kid as string,\n x5c: header.x5c as string[],\n },\n payload: parsed.data,\n iat: parsed.data.iat || Math.floor(Date.now() / 1000),\n }\n}\n"],"mappings":";;;;AAEA,IAAa,sBAAb,MAAa,4BAA4B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,SAAS,MAAM;GAChB,EAAE;EAE4B;;;;;AAMjC,SAAgB,sBAAsB,oBAAuE;CAC3G,MAAM,SAAS,mBAAmB,mBAAmB;AACrD,KAAI,CAAC,OAAO,MAEV,OAAM,IAAI,oBAAoB,wBADR,OAAO,OAAO,KAAK,MAAM,GAAG,EAAE,KAAK,IAAI,EAAE,UAAU,CAAC,KAAK,KAAK,GACd;;;;;;;;;;;;;;;;;;;;;;AChB1E,eAAsB,iBAAiB,SAAqD;CAC1F,MAAM,EAAE,KAAK,aAAa;CAE1B,MAAM,EAAE,QAAQ,SAAS,cAAc,UAA4D,IAAI;CAEvG,MAAM,CAAC,eAAe,kBAAkB,IAAI,MAAM,IAAI;AAItD,KAAI,CADY,MAAM,SAFD,GAAG,cAAc,GAAG,kBAEI,UAAU,CAErD,OAAM,IAAI,oBAAoB,oBAAoB;CAGpD,MAAM,SAAS,iBAAiB,UAAU,QAAQ;AAClD,KAAI,CAAC,OAAO,QAEV,OAAM,IAAI,oBAAoB,gCADb,OAAO,MAAM,OAAO,KAAK,MAAM,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,KAAK,KAAK,GACtB;AAG3E,QAAO;EACL,QAAQ;GACN,KAAK,OAAO;GACZ,KAAK,OAAO;GACZ,KAAK,OAAO;GACZ,KAAK,OAAO;GACb;EACD,SAAS,OAAO;EAChB,KAAK,OAAO,KAAK,OAAO,KAAK,MAAM,KAAK,KAAK,GAAG,IAAK;EACtD"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owf/eudi-attestation-schema",
|
|
3
|
-
"version": "0.2.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "SDK for creating, signing, and validating attestation schema metadata (SchemaMeta) per EUDI TS11 Catalogue of Attestations",
|
|
5
5
|
"experimental": true,
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
8
8
|
],
|
|
9
9
|
"license": "Apache-2.0",
|
|
10
|
+
"main": "./dist/index.cjs",
|
|
11
|
+
"module": "./dist/index.mjs",
|
|
12
|
+
"types": "./dist/index.d.mts",
|
|
10
13
|
"exports": {
|
|
11
14
|
".": {
|
|
12
15
|
"types": "./dist/index.d.mts",
|
|
@@ -37,13 +40,10 @@
|
|
|
37
40
|
],
|
|
38
41
|
"dependencies": {
|
|
39
42
|
"zod": "^4.4.3",
|
|
40
|
-
"@owf/crypto": "0.2.0
|
|
41
|
-
"@owf/identity-common": "0.2.0
|
|
43
|
+
"@owf/crypto": "0.2.0",
|
|
44
|
+
"@owf/identity-common": "0.2.0"
|
|
42
45
|
},
|
|
43
46
|
"scripts": {
|
|
44
47
|
"build": "tsdown src/index.ts --format esm,cjs --dts --sourcemap"
|
|
45
|
-
}
|
|
46
|
-
"main": "./dist/index.cjs",
|
|
47
|
-
"module": "./dist/index.mjs",
|
|
48
|
-
"types": "./dist/index.d.mts"
|
|
48
|
+
}
|
|
49
49
|
}
|