dcql 0.2.18 → 0.2.19

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.
Files changed (109) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +131 -0
  3. package/dist/index.d.mts +2885 -0
  4. package/dist/index.d.ts +2885 -0
  5. package/dist/index.js +1014 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/index.mjs +951 -0
  8. package/dist/index.mjs.map +1 -0
  9. package/package.json +18 -23
  10. package/dist/src/dcql-error/e-base.d.ts +0 -15
  11. package/dist/src/dcql-error/e-base.d.ts.map +0 -1
  12. package/dist/src/dcql-error/e-base.js +0 -78
  13. package/dist/src/dcql-error/e-base.js.map +0 -1
  14. package/dist/src/dcql-error/e-dcql.d.ts +0 -50
  15. package/dist/src/dcql-error/e-dcql.d.ts.map +0 -1
  16. package/dist/src/dcql-error/e-dcql.js +0 -53
  17. package/dist/src/dcql-error/e-dcql.js.map +0 -1
  18. package/dist/src/dcql-error/index.d.ts +0 -3
  19. package/dist/src/dcql-error/index.d.ts.map +0 -1
  20. package/dist/src/dcql-error/index.js +0 -23
  21. package/dist/src/dcql-error/index.js.map +0 -1
  22. package/dist/src/dcql-parser/claims-path.test.d.ts +0 -2
  23. package/dist/src/dcql-parser/claims-path.test.d.ts.map +0 -1
  24. package/dist/src/dcql-parser/claims-path.test.js +0 -103
  25. package/dist/src/dcql-parser/claims-path.test.js.map +0 -1
  26. package/dist/src/dcql-parser/dcql-claims-query-result.d.ts +0 -25
  27. package/dist/src/dcql-parser/dcql-claims-query-result.d.ts.map +0 -1
  28. package/dist/src/dcql-parser/dcql-claims-query-result.js +0 -179
  29. package/dist/src/dcql-parser/dcql-claims-query-result.js.map +0 -1
  30. package/dist/src/dcql-parser/dcql-credential-query-result.d.ts +0 -8
  31. package/dist/src/dcql-parser/dcql-credential-query-result.d.ts.map +0 -1
  32. package/dist/src/dcql-parser/dcql-credential-query-result.js +0 -65
  33. package/dist/src/dcql-parser/dcql-credential-query-result.js.map +0 -1
  34. package/dist/src/dcql-presentation/index.d.ts +0 -4
  35. package/dist/src/dcql-presentation/index.d.ts.map +0 -1
  36. package/dist/src/dcql-presentation/index.js +0 -13
  37. package/dist/src/dcql-presentation/index.js.map +0 -1
  38. package/dist/src/dcql-presentation/m-dcql-credential-presentation.d.ts +0 -59
  39. package/dist/src/dcql-presentation/m-dcql-credential-presentation.d.ts.map +0 -1
  40. package/dist/src/dcql-presentation/m-dcql-credential-presentation.js +0 -55
  41. package/dist/src/dcql-presentation/m-dcql-credential-presentation.js.map +0 -1
  42. package/dist/src/dcql-presentation/m-dcql-presentation-result.d.ts +0 -660
  43. package/dist/src/dcql-presentation/m-dcql-presentation-result.d.ts.map +0 -1
  44. package/dist/src/dcql-presentation/m-dcql-presentation-result.js +0 -132
  45. package/dist/src/dcql-presentation/m-dcql-presentation-result.js.map +0 -1
  46. package/dist/src/dcql-presentation/m-dcql-presentation.d.ts +0 -14
  47. package/dist/src/dcql-presentation/m-dcql-presentation.d.ts.map +0 -1
  48. package/dist/src/dcql-presentation/m-dcql-presentation.js +0 -42
  49. package/dist/src/dcql-presentation/m-dcql-presentation.js.map +0 -1
  50. package/dist/src/dcql-query/dcql-query-complex.test.d.ts +0 -2
  51. package/dist/src/dcql-query/dcql-query-complex.test.d.ts.map +0 -1
  52. package/dist/src/dcql-query/dcql-query-complex.test.js +0 -3204
  53. package/dist/src/dcql-query/dcql-query-complex.test.js.map +0 -1
  54. package/dist/src/dcql-query/dcql-query-with-json-transform.test.d.ts +0 -2
  55. package/dist/src/dcql-query/dcql-query-with-json-transform.test.d.ts.map +0 -1
  56. package/dist/src/dcql-query/dcql-query-with-json-transform.test.js +0 -188
  57. package/dist/src/dcql-query/dcql-query-with-json-transform.test.js.map +0 -1
  58. package/dist/src/dcql-query/dcql-query.test.d.ts +0 -2
  59. package/dist/src/dcql-query/dcql-query.test.d.ts.map +0 -1
  60. package/dist/src/dcql-query/dcql-query.test.js +0 -378
  61. package/dist/src/dcql-query/dcql-query.test.js.map +0 -1
  62. package/dist/src/dcql-query/index.d.ts +0 -5
  63. package/dist/src/dcql-query/index.d.ts.map +0 -1
  64. package/dist/src/dcql-query/index.js +0 -12
  65. package/dist/src/dcql-query/index.js.map +0 -1
  66. package/dist/src/dcql-query/m-dcql-claims-query.d.ts +0 -35
  67. package/dist/src/dcql-query/m-dcql-claims-query.d.ts.map +0 -1
  68. package/dist/src/dcql-query/m-dcql-claims-query.js +0 -57
  69. package/dist/src/dcql-query/m-dcql-claims-query.js.map +0 -1
  70. package/dist/src/dcql-query/m-dcql-credential-query.d.ts +0 -186
  71. package/dist/src/dcql-query/m-dcql-credential-query.d.ts.map +0 -1
  72. package/dist/src/dcql-query/m-dcql-credential-query.js +0 -85
  73. package/dist/src/dcql-query/m-dcql-credential-query.js.map +0 -1
  74. package/dist/src/dcql-query/m-dcql-credential-set-query.d.ts +0 -18
  75. package/dist/src/dcql-query/m-dcql-credential-set-query.d.ts.map +0 -1
  76. package/dist/src/dcql-query/m-dcql-credential-set-query.js +0 -41
  77. package/dist/src/dcql-query/m-dcql-credential-set-query.js.map +0 -1
  78. package/dist/src/dcql-query/m-dcql-query.d.ts +0 -843
  79. package/dist/src/dcql-query/m-dcql-query.d.ts.map +0 -1
  80. package/dist/src/dcql-query/m-dcql-query.js +0 -89
  81. package/dist/src/dcql-query/m-dcql-query.js.map +0 -1
  82. package/dist/src/dcql-query-result/index.d.ts +0 -3
  83. package/dist/src/dcql-query-result/index.d.ts.map +0 -1
  84. package/dist/src/dcql-query-result/index.js +0 -8
  85. package/dist/src/dcql-query-result/index.js.map +0 -1
  86. package/dist/src/dcql-query-result/m-dcql-query-result.d.ts +0 -883
  87. package/dist/src/dcql-query-result/m-dcql-query-result.d.ts.map +0 -1
  88. package/dist/src/dcql-query-result/m-dcql-query-result.js +0 -69
  89. package/dist/src/dcql-query-result/m-dcql-query-result.js.map +0 -1
  90. package/dist/src/dcql-query-result/run-dcql-query.d.ts +0 -8
  91. package/dist/src/dcql-query-result/run-dcql-query.d.ts.map +0 -1
  92. package/dist/src/dcql-query-result/run-dcql-query.js +0 -56
  93. package/dist/src/dcql-query-result/run-dcql-query.js.map +0 -1
  94. package/dist/src/index.d.ts +0 -6
  95. package/dist/src/index.d.ts.map +0 -1
  96. package/dist/src/index.js +0 -27
  97. package/dist/src/index.js.map +0 -1
  98. package/dist/src/u-dcql-credential.d.ts +0 -104
  99. package/dist/src/u-dcql-credential.d.ts.map +0 -1
  100. package/dist/src/u-dcql-credential.js +0 -84
  101. package/dist/src/u-dcql-credential.js.map +0 -1
  102. package/dist/src/u-dcql.d.ts +0 -17
  103. package/dist/src/u-dcql.d.ts.map +0 -1
  104. package/dist/src/u-dcql.js +0 -98
  105. package/dist/src/u-dcql.js.map +0 -1
  106. package/dist/src/u-model.d.ts +0 -27
  107. package/dist/src/u-model.d.ts.map +0 -1
  108. package/dist/src/u-model.js +0 -65
  109. package/dist/src/u-model.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/dcql-error/e-base.ts","../src/dcql-error/e-dcql.ts","../src/dcql-presentation/m-dcql-credential-presentation.ts","../src/u-dcql-credential.ts","../src/u-dcql.ts","../src/u-model.ts","../src/dcql-presentation/m-dcql-presentation-result.ts","../src/dcql-parser/dcql-credential-query-result.ts","../src/dcql-parser/dcql-claims-query-result.ts","../src/dcql-query-result/m-dcql-query-result.ts","../src/dcql-query/m-dcql-credential-query.ts","../src/dcql-query/m-dcql-claims-query.ts","../src/dcql-query/m-dcql-credential-set-query.ts","../src/dcql-presentation/m-dcql-presentation.ts","../src/dcql-query-result/run-dcql-query.ts","../src/dcql-query/m-dcql-query.ts"],"sourcesContent":["function isObject(value: unknown): value is Record<string, unknown> {\n return !!value && !Array.isArray(value) && typeof value === 'object'\n}\n\nclass UnknownCauseError extends Error {\n [key: string]: unknown\n}\n\nexport function getCauseFromUnknown(cause: unknown): Error | undefined {\n if (cause instanceof Error) {\n return cause\n }\n\n const type = typeof cause\n if (type === 'undefined' || type === 'function' || cause === null) {\n return undefined\n }\n\n // Primitive types just get wrapped in an error\n if (type !== 'object') {\n return new Error(String(cause))\n }\n\n // If it's an object, we'll create a synthetic error\n if (isObject(cause)) {\n const err = new UnknownCauseError()\n for (const key in cause) {\n err[key] = cause[key]\n }\n return err\n }\n\n return undefined\n}\n\nexport const isDcqlError = (cause: unknown): cause is DcqlError => {\n if (cause instanceof DcqlError) {\n return true\n }\n if (cause instanceof Error && cause.name === 'DcqlError') {\n // https://github.com/trpc/trpc/pull/4848\n return true\n }\n\n return false\n}\n\nexport function getDcqlErrorFromUnknown(cause: unknown): DcqlError {\n if (isDcqlError(cause)) {\n return cause\n }\n\n const dcqlError = new DcqlError({\n code: 'INTERNAL_SERVER_ERROR',\n cause,\n })\n\n // Inherit stack from error\n if (cause instanceof Error && cause.stack) {\n dcqlError.stack = cause.stack\n }\n\n return dcqlError\n}\n\ntype DCQL_ERROR_CODE = 'PARSE_ERROR' | 'INTERNAL_SERVER_ERROR' | 'NOT_IMPLEMENTED' | 'BAD_REQUEST'\n\nexport class DcqlError extends Error {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore override doesn't work in all environments due to \"This member cannot have an 'override' modifier because it is not declared in the base class 'Error'\"\n public override readonly cause?: Error\n public readonly code\n\n constructor(opts: {\n message?: string\n code: DCQL_ERROR_CODE\n cause?: unknown\n }) {\n const cause = getCauseFromUnknown(opts.cause)\n const message = opts.message ?? cause?.message ?? opts.code\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore https://github.com/tc39/proposal-error-cause\n super(message, { cause })\n\n this.code = opts.code\n this.name = 'DcqlError'\n\n if (!this.cause) {\n // < ES2022 / < Node 16.9.0 compatability\n this.cause = cause\n }\n }\n}\n","import { DcqlError } from './e-base.js'\n\nexport class DcqlCredentialSetError extends DcqlError {\n constructor(opts: { message: string; cause?: unknown }) {\n super({ code: 'BAD_REQUEST', ...opts })\n }\n}\n\nexport class DcqlUndefinedClaimSetIdError extends DcqlError {\n constructor(opts: { message: string; cause?: unknown }) {\n super({ code: 'BAD_REQUEST', ...opts })\n }\n}\n\nexport class DcqlNonUniqueCredentialQueryIdsError extends DcqlError {\n constructor(opts: { message: string; cause?: unknown }) {\n super({ code: 'BAD_REQUEST', ...opts })\n }\n}\n\nexport class DcqlParseError extends DcqlError {\n constructor(opts: { message: string; cause?: unknown }) {\n super({ code: 'PARSE_ERROR', ...opts })\n }\n}\n\nexport class DcqlInvalidClaimsQueryIdError extends DcqlError {\n constructor(opts: { message: string; cause?: unknown }) {\n super({ code: 'BAD_REQUEST', ...opts })\n }\n}\n\nexport class DcqlMissingClaimSetParseError extends DcqlError {\n constructor(opts: { message: string; cause?: unknown }) {\n super({ code: 'PARSE_ERROR', ...opts })\n }\n}\n\nexport class DcqlInvalidPresentationRecordError extends DcqlError {\n constructor(opts: { message: string; cause?: unknown }) {\n super({ code: 'BAD_REQUEST', ...opts })\n }\n}\n\nexport class DcqlPresentationResultError extends DcqlError {\n constructor(opts: { message: string; cause?: unknown }) {\n super({ code: 'BAD_REQUEST', ...opts })\n }\n}\n","import * as v from 'valibot'\nimport { DcqlMdocCredential, DcqlSdJwtVcCredential, DcqlW3cVcCredential } from '../u-dcql-credential'\nimport type { InferModelTypes } from '../u-model'\nimport { Model } from '../u-model'\n\nexport namespace DcqlMdocPresentation {\n export const vModel = DcqlMdocCredential.vModel\n export const model = new Model({ vModel })\n export type Model = InferModelTypes<typeof model>\n}\nexport type DcqlMdocPresentation = DcqlMdocPresentation.Model['Output']\n\nexport namespace DcqlSdJwtVcPresentation {\n export const vModel = DcqlSdJwtVcCredential.vModel\n export const model = new Model({ vModel })\n export type Model = InferModelTypes<typeof model>\n}\nexport type DcqlSdJwtVcPresentation = DcqlSdJwtVcPresentation.Model['Output']\n\nexport namespace DcqlW3cVcPresentation {\n export const vModel = DcqlW3cVcCredential.vModel\n export const model = new Model({ vModel })\n export type Model = InferModelTypes<typeof model>\n}\nexport type DcqlW3cVcPresentation = DcqlW3cVcPresentation.Model['Output']\n\nexport namespace DcqlCredentialPresentation {\n export const model = new Model({\n vModel: v.variant('credential_format', [\n DcqlMdocPresentation.vModel,\n DcqlSdJwtVcPresentation.vModel,\n DcqlW3cVcPresentation.vModel,\n ]),\n })\n export type Model = InferModelTypes<typeof model>\n}\nexport type DcqlCredentialPresentation = DcqlCredentialPresentation.Model['Output']\n","import * as v from 'valibot'\nimport { vJsonRecord, vNonEmptyArray } from './u-dcql.js'\nimport type { InferModelTypes } from './u-model'\nimport { Model } from './u-model.js'\n\nexport namespace DcqlMdocCredential {\n export const vNamespaces = v.record(v.string(), v.record(v.string(), v.unknown()))\n export const vModel = v.object({\n credential_format: v.literal('mso_mdoc'),\n doctype: v.string(),\n namespaces: vNamespaces,\n })\n\n export const model = new Model({ vModel })\n export type Model = InferModelTypes<typeof model>\n export type NameSpaces = v.InferOutput<typeof vNamespaces>\n}\nexport type DcqlMdocCredential = DcqlMdocCredential.Model['Output']\n\nexport namespace DcqlSdJwtVcCredential {\n export const vClaims = vJsonRecord\n export const vModel = v.object({\n credential_format: v.picklist(['vc+sd-jwt', 'dc+sd-jwt']),\n vct: v.string(),\n claims: vClaims,\n })\n export const model = new Model({ vModel })\n export type Model = InferModelTypes<typeof model>\n export type Claims = Model['Output']['claims']\n}\nexport type DcqlSdJwtVcCredential = DcqlSdJwtVcCredential.Model['Output']\n\nexport namespace DcqlW3cVcCredential {\n export const vClaims = vJsonRecord\n export const vModel = v.object({\n credential_format: v.picklist(['jwt_vc_json-ld', 'jwt_vc_json']),\n claims: vClaims,\n })\n\n export const model = new Model({ vModel })\n export type Model = InferModelTypes<typeof model>\n export type Claims = Model['Output']['claims']\n}\nexport type DcqlW3cVcCredential = DcqlW3cVcCredential.Model['Output']\n\nexport namespace DcqlCredential {\n export const vModel = v.variant('credential_format', [\n DcqlMdocCredential.vModel,\n DcqlSdJwtVcCredential.vModel,\n DcqlW3cVcCredential.vModel,\n ])\n\n export const vParseSuccess = v.object({\n success: v.literal(true),\n typed: v.literal(true),\n issues: v.optional(v.undefined()),\n input_credential_index: v.number(),\n claim_set_index: v.union([v.number(), v.undefined()]),\n output: DcqlCredential.vModel,\n })\n\n export const vParseFailure = v.object({\n success: v.literal(false),\n typed: v.boolean(),\n output: v.unknown(),\n issues: v.pipe(v.array(v.unknown()), vNonEmptyArray()),\n input_credential_index: v.number(),\n claim_set_index: v.union([v.number(), v.undefined()]),\n })\n export const model = new Model({ vModel })\n export type Model = InferModelTypes<typeof model>\n}\nexport type DcqlCredential = DcqlCredential.Model['Output']\n","import * as v from 'valibot'\nimport type { UnknownBaseSchema } from './u-model'\nexport const idRegex = /^[a-zA-Z0-9_-]+$/\n\nexport const vNonEmptyArray = <T extends unknown[]>() => {\n return v.custom<[T[number], ...T]>((input) => (input as T).length > 0)\n}\n\nexport const vIdString = v.pipe(v.string(), v.regex(idRegex))\n\nexport type Json = string | number | boolean | null | { [key: string]: Json } | Json[]\n\ninterface HasToJson {\n toJson(): Json\n}\n\nfunction isToJsonable(value: unknown): value is HasToJson {\n if (value === null || typeof value !== 'object') return false\n\n // biome-ignore lint/suspicious/noExplicitAny: <explanation>\n const toJsonFn = (value as any).toJson\n return typeof toJsonFn === 'function'\n}\n\nexport const vWithJT = <Schema extends UnknownBaseSchema>(schema: Schema) =>\n v.pipe(\n v.custom<v.InferInput<Schema>>(() => true),\n v.rawTransform<v.InferInput<Schema>, v.InferOutput<Schema>>(({ dataset, addIssue, NEVER }) => {\n const result = v.safeParse(schema, dataset.value)\n if (result.success) return dataset.value\n\n if (!isToJsonable(dataset.value)) {\n for (const safeParseIssue of result.issues) {\n addIssue({\n ...safeParseIssue,\n expected: safeParseIssue.expected ?? undefined,\n })\n }\n\n return NEVER\n }\n\n let json: Json\n\n try {\n json = dataset.value.toJson()\n } catch (error) {\n for (const safeParseIssue of result.issues) {\n addIssue({\n ...safeParseIssue,\n expected: safeParseIssue.expected ?? undefined,\n })\n }\n addIssue({ message: 'Json Transformation failed' })\n return NEVER\n }\n\n const safeParseResult: v.SafeParseResult<Schema> = v.safeParse(schema, json)\n if (safeParseResult.success) return dataset.value\n\n for (const safeParseIssue of safeParseResult.issues) {\n addIssue({\n ...safeParseIssue,\n expected: safeParseIssue.expected ?? undefined,\n })\n }\n\n return NEVER\n })\n )\n\nexport const vJsonLiteral = v.union([v.string(), v.number(), v.boolean(), v.null()])\n\nexport type JsonLiteral = v.InferOutput<typeof vJsonLiteral>\n\nexport const vJson: v.GenericSchema<Json> = v.lazy(() =>\n v.union([vJsonLiteral, v.array(vJson), v.record(v.string(), vJson)])\n)\n\nexport const vJsonWithJT: v.GenericSchema<Json> = v.lazy(() =>\n vWithJT(v.union([vJsonLiteral, v.array(vJson), v.record(v.string(), vJson)]))\n)\n\nexport const vJsonRecord = v.record(v.string(), vJson)\nexport type JsonRecord = v.InferOutput<typeof vJsonRecord>\n\nexport const vStringToJson = v.rawTransform<string, Json>(({ dataset, addIssue, NEVER }) => {\n try {\n return JSON.parse(dataset.value) as Json\n } catch (error) {\n addIssue({ message: 'Invalid JSON' })\n return NEVER\n }\n})\n","import * as v from 'valibot'\nimport { DcqlParseError } from './dcql-error/e-dcql'\n\nexport type UnknownBaseSchema = v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>\n\ntype EnsureOutputAssignableToInput<T extends UnknownBaseSchema> = v.InferOutput<T> extends v.InferInput<T> ? T : never\n\nexport class Model<T extends UnknownBaseSchema> {\n constructor(private input: { vModel: EnsureOutputAssignableToInput<T> }) {}\n\n public get v() {\n return this.input.vModel\n }\n\n public parse(input: T) {\n const result = this.safeParse(input)\n\n if (result.success) {\n return result.output\n }\n\n return new DcqlParseError({\n message: JSON.stringify(result.flattened),\n cause: result.error,\n })\n }\n\n public safeParse(\n input: unknown\n ):\n | { success: true; output: v.InferOutput<T> }\n | { success: false; flattened: v.FlatErrors<T>; error: v.ValiError<T> } {\n const res = v.safeParse(this.input.vModel, input)\n if (res.success) {\n return { success: true, output: res.output }\n }\n return {\n success: false,\n error: new v.ValiError(res.issues),\n flattened: v.flatten<T>(res.issues),\n }\n }\n\n public is(input: unknown): input is v.InferOutput<T> {\n return v.is(this.v, input)\n }\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: <explanation>\nexport type InferModelTypes<T extends Model<any>> = T extends Model<infer U>\n ? {\n Input: v.InferInput<U>\n Output: v.InferOutput<U>\n }\n : never\n","import * as v from 'valibot'\n\nimport { DcqlInvalidPresentationRecordError, DcqlPresentationResultError } from '../dcql-error/e-dcql.js'\nimport { runCredentialQuery } from '../dcql-parser/dcql-credential-query-result.js'\nimport { DcqlQueryResult } from '../dcql-query-result/m-dcql-query-result.js'\nimport type { DcqlQuery } from '../dcql-query/m-dcql-query.js'\nimport { DcqlCredential } from '../u-dcql-credential.js'\nimport { idRegex } from '../u-dcql.js'\nimport type { DcqlCredentialPresentation } from './m-dcql-credential-presentation.js'\n\nexport namespace DcqlPresentationResult {\n export const vModel = v.object({\n ...v.omit(DcqlQueryResult.vModel, ['credential_matches']).entries,\n\n invalid_matches: v.union([\n v.record(\n v.pipe(v.string(), v.regex(idRegex)),\n v.object({\n ...v.omit(DcqlCredential.vParseFailure, ['input_credential_index']).entries,\n presentation_id: v.pipe(v.string(), v.regex(idRegex)),\n })\n ),\n v.undefined(),\n ]),\n\n valid_matches: v.record(\n v.pipe(v.string(), v.regex(idRegex)),\n v.object({\n ...v.omit(DcqlCredential.vParseSuccess, ['issues', 'input_credential_index']).entries,\n presentation_id: v.pipe(v.string(), v.regex(idRegex)),\n })\n ),\n })\n\n export type Input = v.InferInput<typeof vModel>\n export type Output = v.InferOutput<typeof vModel>\n\n export const parse = (input: Input | DcqlQueryResult) => {\n return v.parse(vModel, input)\n }\n\n /**\n * Query if the presentation record can be satisfied by the provided presentations\n * considering the dcql query\n *\n * @param dcqlQuery\n * @param dcqlPresentation\n */\n export const fromDcqlPresentation = (\n dcqlPresentation: Record<string, DcqlCredentialPresentation>,\n ctx: { dcqlQuery: DcqlQuery }\n ): Output => {\n const { dcqlQuery } = ctx\n\n const presentationQueriesResults = Object.fromEntries(\n Object.entries(dcqlPresentation).map(([queryId, presentation]) => {\n const credentialQuery = dcqlQuery.credentials.find((c) => c.id === queryId)\n if (!credentialQuery) {\n throw new DcqlPresentationResultError({\n message: `Query ${queryId} not found in the dcql query. Cannot validate presentation.`,\n })\n }\n\n return [\n queryId,\n runCredentialQuery(credentialQuery, {\n presentation: true,\n credentials: [presentation],\n }),\n ]\n })\n )\n\n let invalidMatches: DcqlPresentationResult['invalid_matches'] = undefined\n const validMatches: DcqlPresentationResult['valid_matches'] = {}\n\n for (const [queryId, presentationQueryResult] of Object.entries(presentationQueriesResults)) {\n for (const presentationQueryResultForClaimSet of presentationQueryResult) {\n // biome-ignore lint/style/noNonNullAssertion: <explanation>\n const result = presentationQueryResultForClaimSet[0]!\n if (result.success) {\n const { issues, input_credential_index, ...rest } = result\n validMatches[queryId] = { ...rest, presentation_id: queryId }\n } else {\n if (!invalidMatches) invalidMatches = {}\n const { input_credential_index, ...rest } = result\n invalidMatches[queryId] = {\n ...rest,\n presentation_id: queryId,\n }\n }\n }\n }\n\n const credentialSetResults = dcqlQuery.credential_sets?.map((set) => {\n const matchingOptions = set.options.filter((option) =>\n option.every((credentialQueryId) => validMatches[credentialQueryId]?.success)\n )\n\n return {\n ...set,\n matching_options: matchingOptions.length > 0 ? (matchingOptions as [string[], ...string[][]]) : undefined,\n }\n }) as DcqlQueryResult.Output['credential_sets']\n\n const dqclQueryMatched = credentialSetResults\n ? credentialSetResults.every((set) => !set.required || set.matching_options)\n : !invalidMatches\n\n return {\n ...dcqlQuery,\n canBeSatisfied: dqclQueryMatched,\n valid_matches: validMatches,\n invalid_matches: invalidMatches,\n credential_sets: credentialSetResults,\n }\n }\n\n export const validate = (dcqlQueryResult: DcqlPresentationResult) => {\n if (!dcqlQueryResult.canBeSatisfied) {\n throw new DcqlInvalidPresentationRecordError({\n message: 'Invalid Presentation record',\n cause: dcqlQueryResult,\n })\n }\n\n return dcqlQueryResult satisfies Output\n }\n}\nexport type DcqlPresentationResult = DcqlPresentationResult.Output\n","import * as v from 'valibot'\nimport type { DcqlQueryResult } from '../dcql-query-result/m-dcql-query-result.js'\nimport type { DcqlCredentialQuery } from '../dcql-query/m-dcql-credential-query.js'\nimport type { DcqlCredential } from '../u-dcql-credential.js'\nimport type {} from '../u-dcql.js'\nimport { getCredentialQueryParser } from './dcql-claims-query-result.js'\n\nexport const runCredentialQuery = (\n credentialQuery: DcqlCredentialQuery,\n ctx: {\n credentials: DcqlCredential[]\n presentation: boolean\n }\n): DcqlQueryResult.CredentialQueryResult => {\n const { credentials, presentation } = ctx\n const claimSets = credentialQuery.claim_sets ?? [undefined]\n\n const credentialQueryResult: v.InferInput<typeof DcqlQueryResult.vCredentialQueryResult> = new Array(\n claimSets.length\n ).fill([])\n\n for (const [claimSetIndex, claim_set] of claimSets.entries()) {\n const credentialParser = getCredentialQueryParser(credentialQuery, {\n claimSet: claim_set,\n presentation,\n })\n\n for (const [credentialIndex, credential] of credentials.entries()) {\n if (claimSetIndex > 0) {\n // if one the credential was successfully parsed against a previous claimsset we don't need to further validate other claim sets\n const previous = credentialQueryResult[claimSetIndex - 1]?.[credentialIndex]\n\n // if the previous credential was successfully parsed we don't need to further validate the current credential\n // we set all further parsing attempts to undefined\n if (previous?.success || !previous) {\n // biome-ignore lint/style/noNonNullAssertion: <explanation>\n credentialQueryResult[claimSetIndex]![credentialIndex] = undefined\n continue\n }\n }\n\n const parseResult = v.safeParse(credentialParser, credential)\n credentialQueryResult[claimSetIndex]?.push({\n ...parseResult,\n ...(parseResult.issues && {\n flattened: v.flatten<typeof credentialParser>(parseResult.issues),\n }),\n input_credential_index: credentialIndex,\n claim_set_index: credentialQuery.claim_sets ? claimSetIndex : undefined,\n })\n }\n }\n\n return credentialQueryResult as DcqlQueryResult.CredentialQueryResult\n}\n","import * as v from 'valibot'\nimport { DcqlInvalidClaimsQueryIdError, DcqlMissingClaimSetParseError } from '../dcql-error/e-dcql.js'\nimport type { DcqlClaimsQuery } from '../dcql-query/m-dcql-claims-query.js'\nimport type { DcqlCredentialQuery } from '../dcql-query/m-dcql-credential-query.js'\nimport { vWithJT } from '../u-dcql'\nimport { vJson, vJsonRecord } from '../u-dcql.js'\n\nconst getClaimParser = (input: {\n value?: string | number | boolean\n values?: (string | number | boolean)[]\n}) => {\n const { value, values } = input\n if (value) {\n return vWithJT(v.literal(value))\n }\n\n if (values) {\n return vWithJT(v.union(values.map((val) => v.literal(val))))\n }\n\n return v.nonNullish(v.any())\n}\n\nexport const getNamespacesParser = (claimsQueries: DcqlClaimsQuery.Mdoc[]) => {\n const claimsForNamespace: Record<string, ReturnType<typeof getMdocClaimsQueriesForClaimSet>> = {}\n\n for (const claimQuery of claimsQueries) {\n if (claimsForNamespace[claimQuery.namespace]) {\n claimsForNamespace[claimQuery.namespace]?.push({ ...claimQuery })\n } else {\n claimsForNamespace[claimQuery.namespace] = [{ ...claimQuery }]\n }\n }\n\n const parsersForNamespaces = Object.entries(claimsForNamespace).map(([namespace, claims]) => {\n const claimParsers = Object.fromEntries(claims.map((claim) => [claim.claim_name, getClaimParser(claim)]))\n return [namespace, v.object(claimParsers)]\n })\n\n return v.object(Object.fromEntries(parsersForNamespaces))\n}\n\nconst getClaimQueryParser = (\n claimQuery: DcqlClaimsQuery.W3cAndSdJwtVc,\n ctx: { index: number; presentation: boolean }\n): typeof vJson => {\n const { index, presentation } = ctx\n const pathElement = claimQuery.path[index]\n const isLast = index === claimQuery.path.length - 1\n\n const vClaimParser = getClaimParser(claimQuery)\n\n if (typeof pathElement === 'number') {\n const elementParser = isLast ? vClaimParser : getClaimQueryParser(claimQuery, { ...ctx, index: index + 1 })\n\n if (presentation) {\n // We allow both the concrete value and an array of one value\n return v.union([\n v.pipe(\n v.array(vJson),\n v.length(1),\n v.transform((input) => input[0]),\n elementParser\n ),\n elementParser,\n ])\n }\n\n return v.pipe(\n v.array(vJson),\n v.transform((input) => input[pathElement]),\n elementParser\n )\n }\n if (typeof pathElement === 'string') {\n return v.object({\n [pathElement]: isLast ? vClaimParser : getClaimQueryParser(claimQuery, { ...ctx, index: index + 1 }),\n })\n }\n return isLast ? v.array(vClaimParser) : v.array(getClaimQueryParser(claimQuery, { ...ctx, index: index + 1 }))\n}\n\nexport const getJsonClaimsParser = (claimsQueries: DcqlClaimsQuery.W3cAndSdJwtVc[], ctx: { presentation: boolean }) => {\n const claimParser = v.intersect(\n claimsQueries.map(\n (claimQuery) =>\n getClaimQueryParser(claimQuery, {\n ...ctx,\n index: 0,\n }) as typeof vJsonRecord\n )\n )\n\n return claimParser\n}\n\nexport const getMdocClaimsQueriesForClaimSet = (\n claimsQueries: DcqlClaimsQuery.Mdoc[],\n claimSet: string[]\n): DcqlClaimsQuery.Mdoc[] => {\n return claimSet.map((credential_id) => {\n const query = claimsQueries.find((query) => query.id === credential_id)\n if (!query) {\n throw new DcqlInvalidClaimsQueryIdError({\n message: `Claims-query with id '${credential_id}' not found.`,\n })\n }\n return query\n })\n}\n\nexport const getJsonClaimsQueriesForClaimSet = (\n claimsQueries: DcqlClaimsQuery.W3cAndSdJwtVc[],\n claimSet: string[]\n): DcqlClaimsQuery.W3cAndSdJwtVc[] => {\n return claimSet.map((credential_id) => {\n const query = claimsQueries.find((query) => query.id === credential_id)\n if (!query) {\n throw new DcqlInvalidClaimsQueryIdError({\n message: `Claims-query with id '${credential_id}' not found.`,\n })\n }\n return query\n })\n}\n\nconst getMdocParser = (\n credentialQuery: DcqlCredentialQuery.Mdoc,\n ctx: { claimSet?: NonNullable<DcqlCredentialQuery['claim_sets']>[number] }\n) => {\n const { claimSet } = ctx\n\n const vDoctype = credentialQuery.meta?.doctype_value ? v.literal(credentialQuery.meta.doctype_value) : v.string()\n\n const claimSetQueries =\n credentialQuery.claims && claimSet\n ? getMdocClaimsQueriesForClaimSet(credentialQuery.claims, claimSet)\n : credentialQuery.claims\n\n const credentialParser = v.object({\n credential_format: v.literal('mso_mdoc'),\n doctype: vDoctype,\n namespaces: claimSetQueries\n ? getNamespacesParser(claimSetQueries)\n : v.record(v.string(), v.record(v.string(), v.unknown())),\n })\n\n return credentialParser\n}\n\nconst getW3cVcSdJwtVcParser = (\n credentialQuery: DcqlCredentialQuery.SdJwtVc | DcqlCredentialQuery.W3cVc,\n ctx: {\n claimSet?: NonNullable<DcqlCredentialQuery['claim_sets']>[number]\n presentation: boolean\n }\n) => {\n const { claimSet } = ctx\n const claimSetQueries =\n credentialQuery.claims && claimSet\n ? getJsonClaimsQueriesForClaimSet(credentialQuery.claims, claimSet)\n : credentialQuery.claims\n\n if (credentialQuery.format === 'vc+sd-jwt' || credentialQuery.format === 'dc+sd-jwt') {\n return v.object({\n credential_format: v.literal(credentialQuery.format),\n vct: credentialQuery.meta?.vct_values ? v.picklist(credentialQuery.meta.vct_values) : v.string(),\n claims: claimSetQueries ? getJsonClaimsParser(claimSetQueries, ctx) : vJsonRecord,\n })\n }\n const credentialParser = v.object({\n credential_format: v.picklist(['jwt_vc_json', 'jwt_vc_json-ld']),\n claims: claimSetQueries ? getJsonClaimsParser(claimSetQueries, ctx) : vJsonRecord,\n })\n\n return credentialParser\n}\n\nexport const getCredentialQueryParser = (\n credentialQuery: DcqlCredentialQuery,\n ctx: {\n claimSet?: NonNullable<DcqlCredentialQuery['claim_sets']>[number]\n presentation: boolean\n }\n) => {\n if (credentialQuery.claim_sets && !ctx.claimSet) {\n throw new DcqlMissingClaimSetParseError({\n message: 'credentialQuery specifies claim_sets but no claim_set for parsing is provided.',\n })\n }\n\n if (credentialQuery.format === 'mso_mdoc') {\n return getMdocParser(credentialQuery, ctx)\n }\n return getW3cVcSdJwtVcParser(credentialQuery, ctx)\n}\n","import * as v from 'valibot'\nimport { DcqlCredentialQuery } from '../dcql-query/m-dcql-credential-query.js'\nimport { CredentialSetQuery } from '../dcql-query/m-dcql-credential-set-query.js'\nimport { DcqlCredential } from '../u-dcql-credential.js'\nimport { idRegex, vNonEmptyArray } from '../u-dcql.js'\n\nexport namespace DcqlQueryResult {\n export const vCredentialQueryResult = v.pipe(\n v.array(v.array(v.union([v.undefined(), DcqlCredential.vParseSuccess, DcqlCredential.vParseFailure]))),\n vNonEmptyArray()\n )\n\n export type CredentialQueryResult = v.InferOutput<typeof vCredentialQueryResult>\n\n export const vModel = v.object({\n credentials: v.pipe(\n v.array(DcqlCredentialQuery.vModel),\n vNonEmptyArray(),\n v.description(\n 'REQUIRED. A non-empty array of Credential Queries that specify the requested Verifiable Credentials.'\n )\n ),\n\n credential_matches: v.record(\n v.pipe(v.string(), v.regex(idRegex)),\n v.union([\n v.object({\n ...DcqlCredential.vParseSuccess.entries,\n all: v.pipe(\n v.array(\n v.pipe(\n v.array(v.union([v.undefined(), DcqlCredential.vParseSuccess, DcqlCredential.vParseFailure])),\n vNonEmptyArray()\n )\n ),\n vNonEmptyArray()\n ),\n }),\n v.object({\n success: DcqlCredential.vParseFailure.entries.success,\n all: v.pipe(\n v.array(\n v.pipe(\n v.array(v.union([v.undefined(), DcqlCredential.vParseSuccess, DcqlCredential.vParseFailure])),\n vNonEmptyArray()\n )\n ),\n vNonEmptyArray()\n ),\n }),\n ])\n ),\n\n credential_sets: v.optional(\n v.pipe(\n v.array(\n v.object({\n ...CredentialSetQuery.vModel.entries,\n matching_options: v.union([v.undefined(), v.pipe(v.array(v.array(v.string())), vNonEmptyArray())]),\n })\n ),\n vNonEmptyArray(),\n v.description(\n 'OPTIONAL. A non-empty array of credential set queries that specifies additional constraints on which of the requested Verifiable Credentials to return.'\n )\n )\n ),\n\n canBeSatisfied: v.boolean(),\n })\n export type Input = v.InferInput<typeof vModel>\n export type Output = v.InferOutput<typeof vModel>\n\n export type CredentialMatch = Input['credential_matches'][number]\n export type CredentialMatchRecord = Input['credential_matches']\n}\nexport type DcqlQueryResult = DcqlQueryResult.Output\n","import * as v from 'valibot'\nimport { DcqlUndefinedClaimSetIdError } from '../dcql-error/e-dcql.js'\nimport { idRegex, vNonEmptyArray } from '../u-dcql.js'\nimport { DcqlClaimsQuery } from './m-dcql-claims-query.js'\n\n/**\n * A Credential Query is an object representing a request for a presentation of one Credential.\n */\nexport namespace DcqlCredentialQuery {\n const vBase = v.object({\n id: v.pipe(\n v.string(),\n v.regex(idRegex),\n v.description(\n `REQUIRED. A string identifying the Credential in the response and, if provided, the constraints in 'credential_sets'.`\n )\n ),\n claim_sets: v.pipe(\n v.optional(v.pipe(v.array(v.array(v.pipe(v.string(), v.regex(idRegex)))), vNonEmptyArray())),\n v.description(\n `OPTIONAL. A non-empty array containing arrays of identifiers for elements in 'claims' that specifies which combinations of 'claims' for the Credential are requested.`\n )\n ),\n })\n\n export const vMdoc = v.object({\n ...vBase.entries,\n format: v.pipe(\n v.literal('mso_mdoc'),\n v.description('REQUIRED. A string that specifies the format of the requested Verifiable Credential.')\n ),\n claims: v.pipe(\n v.optional(v.pipe(v.array(DcqlClaimsQuery.vMdoc), vNonEmptyArray())),\n v.description('OPTIONAL. A non-empty array of objects as that specifies claims in the requested Credential.')\n ),\n meta: v.pipe(\n v.optional(\n v.object({\n doctype_value: v.pipe(\n v.optional(v.string()),\n v.description(\n 'OPTIONAL. String that specifies an allowed value for the doctype of the requested Verifiable Credential.'\n )\n ),\n })\n ),\n v.description(\n 'OPTIONAL. An object defining additional properties requested by the Verifier that apply to the metadata and validity data of the Credential.'\n )\n ),\n })\n export type Mdoc = v.InferOutput<typeof vMdoc>\n\n export const vSdJwtVc = v.object({\n ...vBase.entries,\n format: v.pipe(\n v.picklist(['vc+sd-jwt', 'dc+sd-jwt']),\n v.description('REQUIRED. A string that specifies the format of the requested Verifiable Credential.')\n ),\n claims: v.pipe(\n v.optional(v.pipe(v.array(DcqlClaimsQuery.vW3cSdJwtVc), vNonEmptyArray())),\n v.description('OPTIONAL. A non-empty array of objects as that specifies claims in the requested Credential.')\n ),\n meta: v.pipe(\n v.optional(\n v.pipe(\n v.object({\n vct_values: v.optional(v.array(v.string())),\n }),\n v.description(\n 'OPTIONAL. An array of strings that specifies allowed values for the type of the requested Verifiable Credential.'\n )\n )\n ),\n v.description(\n 'OPTIONAL. An object defining additional properties requested by the Verifier that apply to the metadata and validity data of the Credential.'\n )\n ),\n })\n export type SdJwtVc = v.InferOutput<typeof vSdJwtVc>\n\n export const vW3cVc = v.object({\n ...vBase.entries,\n format: v.picklist(['jwt_vc_json', 'jwt_vc_json-ld']),\n claims: v.optional(v.pipe(v.array(DcqlClaimsQuery.vW3cSdJwtVc), vNonEmptyArray())),\n })\n export type W3cVc = v.InferOutput<typeof vW3cVc>\n\n export const vModel = v.variant('format', [vMdoc, vSdJwtVc, vW3cVc])\n export type Input = v.InferInput<typeof vModel>\n export type Output = v.InferOutput<typeof vModel>\n\n export const validate = (credentialQuery: Output) => {\n claimSetIdsAreDefined(credentialQuery)\n }\n}\nexport type DcqlCredentialQuery = DcqlCredentialQuery.Output\n\n// --- validations --- //\n\nconst claimSetIdsAreDefined = (credentialQuery: DcqlCredentialQuery) => {\n if (!credentialQuery.claim_sets) return\n const claimIds = new Set(credentialQuery.claims?.map((claim) => claim.id))\n\n const undefinedClaims: string[] = []\n for (const claim_set of credentialQuery.claim_sets) {\n for (const claim_id of claim_set) {\n if (!claimIds.has(claim_id)) {\n undefinedClaims.push(claim_id)\n }\n }\n }\n\n if (undefinedClaims.length > 0) {\n throw new DcqlUndefinedClaimSetIdError({\n message: `Credential set contains undefined credential id${undefinedClaims.length === 0 ? '' : '`s'} '${undefinedClaims.join(', ')}'`,\n })\n }\n}\n","import * as v from 'valibot'\nimport { idRegex } from '../u-dcql.js'\n\n/**\n * Specifies claims withing a requested Credential.\n */\nexport namespace DcqlClaimsQuery {\n export const vValue = v.union([v.string(), v.pipe(v.number(), v.integer()), v.boolean()])\n\n export const vPath = v.union([v.string(), v.pipe(v.number(), v.integer(), v.minValue(0)), v.null()])\n\n export const vW3cSdJwtVc = v.object({\n id: v.pipe(\n v.optional(v.pipe(v.string(), v.regex(idRegex))),\n v.description(\n 'A string identifying the particular claim. The value MUST be a non-empty string consisting of alphanumeric, underscore (_) or hyphen (-) characters. Within the particular claims array, the same id MUST NOT be present more than once.'\n )\n ),\n path: v.pipe(\n v.array(vPath),\n v.description(\n 'A non-empty array representing a claims path pointer that specifies the path to a claim within the Verifiable Credential.'\n )\n ),\n values: v.pipe(\n v.optional(v.array(vValue)),\n v.description(\n 'An array of strings, integers or boolean values that specifies the expected values of the claim. If the values property is present, the Wallet SHOULD return the claim only if the type and value of the claim both match for at least one of the elements in the array.'\n )\n ),\n })\n export type W3cAndSdJwtVc = v.InferOutput<typeof vW3cSdJwtVc>\n\n export const vMdoc = v.object({\n id: v.pipe(\n v.optional(v.pipe(v.string(), v.regex(idRegex))),\n v.description(\n 'A string identifying the particular claim. The value MUST be a non-empty string consisting of alphanumeric, underscore (_) or hyphen (-) characters. Within the particular claims array, the same id MUST NOT be present more than once.'\n )\n ),\n namespace: v.pipe(\n v.string(),\n v.description(\n 'A string that specifies the namespace of the data element within the mdoc, e.g., org.iso.18013.5.1.'\n )\n ),\n claim_name: v.pipe(\n v.string(),\n v.description(\n 'A string that specifies the data element identifier of the data element within the provided namespace in the mdoc, e.g., first_name.'\n )\n ),\n values: v.pipe(\n v.optional(v.array(vValue)),\n v.description(\n 'An array of strings, integers or boolean values that specifies the expected values of the claim. If the values property is present, the Wallet SHOULD return the claim only if the type and value of the claim both match for at least one of the elements in the array.'\n )\n ),\n })\n export type Mdoc = v.InferOutput<typeof vMdoc>\n\n export const vModel = v.union([vMdoc, vW3cSdJwtVc])\n export type Input = v.InferInput<typeof vModel>\n export type Out = v.InferOutput<typeof vModel>\n}\nexport type DcqlClaimsQuery = DcqlClaimsQuery.Out\n","import * as v from 'valibot'\nimport { vIdString, vNonEmptyArray } from '../u-dcql.js'\n\n/**\n * A Credential Set Query is an object representing\n * a request for one or more credentials to satisfy a particular use case with the Verifier.\n */\nexport namespace CredentialSetQuery {\n export const vModel = v.object({\n options: v.pipe(\n v.array(v.array(vIdString)),\n vNonEmptyArray(),\n v.description(\n 'REQUIRED. A non-empty array, where each value in the array is a list of Credential Query identifiers representing one set of Credentials that satisfies the use case.'\n )\n ),\n required: v.pipe(\n v.optional(v.boolean(), true),\n v.description(\n `OPTIONAL. Boolean which indicates whether this set of Credentials is required to satisfy the particular use case at the Verifier. If omitted, the default value is 'true'.`\n )\n ),\n purpose: v.pipe(\n v.optional(v.union([v.string(), v.number(), v.record(v.string(), v.unknown())])),\n v.description('OPTIONAL. A string, number or object specifying the purpose of the query.')\n ),\n })\n\n export type Input = v.InferInput<typeof vModel>\n export type Output = v.InferOutput<typeof vModel>\n}\nexport type CredentialSetQuery = CredentialSetQuery.Output\n","import * as v from 'valibot'\nimport { idRegex, vJsonRecord, vStringToJson } from '../u-dcql.js'\n\nexport namespace DcqlPresentation {\n export const vModel = v.record(v.pipe(v.string(), v.regex(idRegex)), v.union([v.string(), vJsonRecord]))\n\n export type Input = v.InferInput<typeof vModel>\n export type Output = v.InferOutput<typeof vModel>\n export const parse = (input: Input | string) => {\n if (typeof input === 'string') {\n return v.parse(v.pipe(v.string(), vStringToJson, vModel), input)\n }\n\n return v.parse(vModel, input)\n }\n\n export const encode = (input: Output) => {\n return JSON.stringify(input)\n }\n}\nexport type DcqlPresentation = DcqlPresentation.Output\n","import type * as v from 'valibot'\nimport { runCredentialQuery } from '../dcql-parser/dcql-credential-query-result.js'\nimport type { DcqlQuery } from '../dcql-query/m-dcql-query.js'\nimport type { DcqlCredential } from '../u-dcql-credential.js'\nimport type { DcqlQueryResult } from './m-dcql-query-result.js'\n\nexport const runDcqlQuery = (\n dcqlQuery: DcqlQuery.Output,\n ctx: {\n credentials: DcqlCredential[]\n presentation: boolean\n }\n): DcqlQueryResult => {\n const credentialQueriesResults = Object.fromEntries(\n dcqlQuery.credentials.map((credentialQuery) => [credentialQuery.id, runCredentialQuery(credentialQuery, ctx)])\n )\n\n const credentialMatches = Object.fromEntries(\n Object.entries(credentialQueriesResults).map(([key, credentialQueryResult]) => {\n // Find the best match for each credential query\n let bestMatch: v.InferOutput<typeof DcqlCredential.vParseSuccess> | undefined = undefined\n\n for (const credentialParseResult of credentialQueryResult) {\n const bestMatchForCredential = credentialParseResult.find((result) => result?.success === true)\n\n if (!bestMatch && bestMatchForCredential) {\n const { issues, ...matchWithoutIssues } = bestMatchForCredential\n bestMatch = matchWithoutIssues\n continue\n }\n\n // biome-ignore lint/style/noNonNullAssertion: <explanation>\n if (bestMatchForCredential && bestMatchForCredential.claim_set_index! < bestMatch?.claim_set_index!) {\n const { issues, ...matchWithoutIssues } = bestMatchForCredential\n bestMatch = matchWithoutIssues\n }\n }\n\n return [\n key,\n bestMatch ? { ...bestMatch, all: credentialQueryResult } : { success: false, all: credentialQueryResult },\n ]\n })\n ) satisfies DcqlQueryResult.CredentialMatchRecord\n\n const credentialSetResults = dcqlQuery.credential_sets?.map((set) => {\n const matchingOptions = set.options.filter((option) =>\n option.every((credentialQueryId) => credentialMatches[credentialQueryId]?.success)\n )\n\n return {\n ...set,\n matching_options: matchingOptions.length > 0 ? (matchingOptions as [string[], ...string[][]]) : undefined,\n }\n }) as DcqlQueryResult.Output['credential_sets']\n\n const dqclQueryMatched = credentialSetResults\n ? credentialSetResults.every((set) => !set.required || set.matching_options)\n : Object.values(credentialMatches).every((query) => query.success)\n\n return {\n ...dcqlQuery,\n canBeSatisfied: dqclQueryMatched,\n credential_matches: credentialMatches as DcqlQueryResult['credential_matches'],\n credential_sets: credentialSetResults,\n }\n}\n","import * as v from 'valibot'\nimport { DcqlCredentialSetError, DcqlNonUniqueCredentialQueryIdsError } from '../dcql-error/e-dcql.js'\nimport { runDcqlQuery } from '../dcql-query-result/run-dcql-query.js'\nimport type { DcqlCredential } from '../u-dcql-credential.js'\nimport { vNonEmptyArray } from '../u-dcql.js'\nimport { DcqlCredentialQuery } from './m-dcql-credential-query.js'\nimport { CredentialSetQuery } from './m-dcql-credential-set-query.js'\n\n/**\n * The Digital Credentials Query Language (DCQL, pronounced [ˈdakl̩]) is a\n * JSON-encoded query language that allows the Verifier to request Verifiable\n * Presentations that match the query. The Verifier MAY encode constraints on the\n * combinations of credentials and claims that are requested. The Wallet evaluates\n * the query against the Verifiable Credentials it holds and returns Verifiable\n * Presentations matching the query.\n */\nexport namespace DcqlQuery {\n export const vModel = v.object({\n credentials: v.pipe(\n v.array(DcqlCredentialQuery.vModel),\n vNonEmptyArray(),\n v.description(\n 'REQUIRED. A non-empty array of Credential Queries that specify the requested Verifiable Credentials.'\n )\n ),\n credential_sets: v.pipe(\n v.optional(v.pipe(v.array(CredentialSetQuery.vModel), vNonEmptyArray())),\n v.description(\n 'OPTIONAL. A non-empty array of credential set queries that specifies additional constraints on which of the requested Verifiable Credentials to return.'\n )\n ),\n })\n export type Input = v.InferInput<typeof vModel>\n export type Output = v.InferOutput<typeof vModel>\n export const validate = (dcqlQuery: Output) => {\n validateUniqueCredentialQueryIds(dcqlQuery)\n validateCredentialSets(dcqlQuery)\n dcqlQuery.credentials.forEach(DcqlCredentialQuery.validate)\n }\n export const query = (dcqlQuery: Output, credentials: DcqlCredential[]) => {\n return runDcqlQuery(dcqlQuery, { credentials, presentation: false })\n }\n\n export const parse = (input: Input) => {\n return v.parse(vModel, input)\n }\n}\nexport type DcqlQuery = DcqlQuery.Output\n\n// --- validations --- //\n\nconst validateUniqueCredentialQueryIds = (query: DcqlQuery.Output) => {\n const ids = query.credentials.map((c) => c.id)\n const duplicates = ids.filter((id, index) => ids.indexOf(id) !== index)\n\n if (duplicates.length > 0) {\n throw new DcqlNonUniqueCredentialQueryIdsError({\n message: `Duplicate credential query ids found: ${duplicates.join(', ')}`,\n })\n }\n}\n\nconst validateCredentialSets = (query: DcqlQuery.Output) => {\n if (!query.credential_sets) return\n\n const credentialQueryIds = new Set(query.credentials.map((c) => c.id))\n\n const undefinedCredentialQueryIds: string[] = []\n for (const credential_set of query.credential_sets) {\n for (const credentialSetOption of credential_set.options) {\n for (const credentialQueryId of credentialSetOption) {\n if (!credentialQueryIds.has(credentialQueryId)) {\n undefinedCredentialQueryIds.push(credentialQueryId)\n }\n }\n }\n }\n\n if (undefinedCredentialQueryIds.length > 0) {\n throw new DcqlCredentialSetError({\n message: `Credential set contains undefined credential id${undefinedCredentialQueryIds.length === 1 ? '' : '`s'} '${undefinedCredentialQueryIds.join(', ')}'`,\n })\n }\n}\n"],"mappings":";AAAA,SAAS,SAAS,OAAkD;AAClE,SAAO,CAAC,CAAC,SAAS,CAAC,MAAM,QAAQ,KAAK,KAAK,OAAO,UAAU;AAC9D;AAEA,IAAM,oBAAN,cAAgC,MAAM;AAEtC;AAEO,SAAS,oBAAoB,OAAmC;AACrE,MAAI,iBAAiB,OAAO;AAC1B,WAAO;AAAA,EACT;AAEA,QAAM,OAAO,OAAO;AACpB,MAAI,SAAS,eAAe,SAAS,cAAc,UAAU,MAAM;AACjE,WAAO;AAAA,EACT;AAGA,MAAI,SAAS,UAAU;AACrB,WAAO,IAAI,MAAM,OAAO,KAAK,CAAC;AAAA,EAChC;AAGA,MAAI,SAAS,KAAK,GAAG;AACnB,UAAM,MAAM,IAAI,kBAAkB;AAClC,eAAW,OAAO,OAAO;AACvB,UAAI,GAAG,IAAI,MAAM,GAAG;AAAA,IACtB;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,IAAM,cAAc,CAAC,UAAuC;AACjE,MAAI,iBAAiB,WAAW;AAC9B,WAAO;AAAA,EACT;AACA,MAAI,iBAAiB,SAAS,MAAM,SAAS,aAAa;AAExD,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,SAAS,wBAAwB,OAA2B;AACjE,MAAI,YAAY,KAAK,GAAG;AACtB,WAAO;AAAA,EACT;AAEA,QAAM,YAAY,IAAI,UAAU;AAAA,IAC9B,MAAM;AAAA,IACN;AAAA,EACF,CAAC;AAGD,MAAI,iBAAiB,SAAS,MAAM,OAAO;AACzC,cAAU,QAAQ,MAAM;AAAA,EAC1B;AAEA,SAAO;AACT;AAIO,IAAM,YAAN,cAAwB,MAAM;AAAA,EAMnC,YAAY,MAIT;AACD,UAAM,QAAQ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MAAI,4BAA4B,SAAS,GAAG;AAC1C,UAAM,IAAI,uBAAuB;AAAA,MAC/B,SAAS,kDAAkD,4BAA4B,WAAW,IAAI,KAAK,IAAI,KAAK,4BAA4B,KAAK,IAAI,CAAC;AAAA,IAC5J,CAAC;AAAA,EACH;AACF;","names":["v","v","v","DcqlMdocCredential","DcqlSdJwtVcCredential","DcqlW3cVcCredential","DcqlCredential","DcqlMdocPresentation","DcqlSdJwtVcPresentation","DcqlW3cVcPresentation","DcqlCredentialPresentation","v","v","v","query","v","v","v","DcqlClaimsQuery","DcqlCredentialQuery","v","CredentialSetQuery","DcqlQueryResult","DcqlPresentationResult","v","DcqlPresentation","v","DcqlQuery"]}
package/package.json CHANGED
@@ -2,18 +2,8 @@
2
2
  "name": "dcql",
3
3
  "description": "Digital Credentials Query Language (DCQL)",
4
4
  "author": "Martin Auer",
5
- "version": "0.2.18",
5
+ "version": "0.2.19",
6
6
  "private": false,
7
- "main": "./dist/src/index.js",
8
- "module": "./dist/src/index.js",
9
- "types": "./dist/src/index.d.ts",
10
- "exports": {
11
- ".": {
12
- "import": "./dist/src/index.js",
13
- "require": "./dist/src/index.js",
14
- "types": "./dist/src/index.d.ts"
15
- }
16
- },
17
7
  "files": [
18
8
  "dist"
19
9
  ],
@@ -22,18 +12,14 @@
22
12
  "valibot": "1.0.0-beta.8"
23
13
  },
24
14
  "devDependencies": {
25
- "@ausweis/eslint": "^0.2.43",
26
- "@ausweis/prettier": "^0.2.43",
27
- "@ausweis/typescript": "^0.2.43",
28
15
  "@types/node": "^20.16.10",
29
- "eslint": "^9.9.0",
30
- "prettier": "^3.3.3",
31
- "typescript": "^5.6.2"
16
+ "tsup": "^8.3.5",
17
+ "typescript": "^5.6.3",
18
+ "vitest": "^2.1.5"
32
19
  },
33
- "prettier": "@ausweis/prettier",
34
20
  "repository": {
35
21
  "type": "git",
36
- "url": "https://github.com/auer-martin/vp-query"
22
+ "url": "https://github.com/auer-martin/dcql"
37
23
  },
38
24
  "keywords": [
39
25
  "Digital Credentials Query Language (DCQL)",
@@ -56,10 +42,19 @@
56
42
  ],
57
43
  "scripts": {
58
44
  "clean": "git clean -xdf .cache .turbo node_modules dist",
59
- "build": "tsc",
60
- "format": "prettier --check . --ignore-path ./../.gitignore",
61
- "lint": "eslint .",
45
+ "build": "tsup src/index.ts --format cjs,esm --dts --clean --sourcemap",
62
46
  "typecheck": "tsc --noEmit",
63
- "test": "node --test"
47
+ "test": "vitest"
48
+ },
49
+ "main": "./dist/index.js",
50
+ "module": "./dist/index.mjs",
51
+ "types": "./dist/index.d.ts",
52
+ "exports": {
53
+ ".": {
54
+ "import": "./dist/index.mjs",
55
+ "require": "./dist/index.js",
56
+ "types": "./dist/index.d.ts"
57
+ },
58
+ "./package.json": "./package.json"
64
59
  }
65
60
  }
@@ -1,15 +0,0 @@
1
- export declare function getCauseFromUnknown(cause: unknown): Error | undefined;
2
- export declare const isDcqlError: (cause: unknown) => cause is DcqlError;
3
- export declare function getDcqlErrorFromUnknown(cause: unknown): DcqlError;
4
- type DCQL_ERROR_CODE = 'PARSE_ERROR' | 'INTERNAL_SERVER_ERROR' | 'NOT_IMPLEMENTED' | 'BAD_REQUEST';
5
- export declare class DcqlError extends Error {
6
- readonly cause?: Error;
7
- readonly code: DCQL_ERROR_CODE;
8
- constructor(opts: {
9
- message?: string;
10
- code: DCQL_ERROR_CODE;
11
- cause?: unknown;
12
- });
13
- }
14
- export {};
15
- //# sourceMappingURL=e-base.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"e-base.d.ts","sourceRoot":"","sources":["../../../src/dcql-error/e-base.ts"],"names":[],"mappings":"AAQA,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,GAAG,SAAS,CAyBrE;AAED,eAAO,MAAM,WAAW,UAAW,OAAO,KAAG,KAAK,IAAI,SAUrD,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAgBjE;AAED,KAAK,eAAe,GAChB,aAAa,GACb,uBAAuB,GACvB,iBAAiB,GACjB,aAAa,CAAC;AAElB,qBAAa,SAAU,SAAQ,KAAK;IAGlC,SAAyB,KAAK,CAAC,EAAE,KAAK,CAAC;IACvC,SAAgB,IAAI,kBAAC;gBAET,IAAI,EAAE;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,eAAe,CAAC;QACtB,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB;CAgBF"}
@@ -1,78 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DcqlError = exports.isDcqlError = void 0;
4
- exports.getCauseFromUnknown = getCauseFromUnknown;
5
- exports.getDcqlErrorFromUnknown = getDcqlErrorFromUnknown;
6
- function isObject(value) {
7
- return !!value && !Array.isArray(value) && typeof value === 'object';
8
- }
9
- class UnknownCauseError extends Error {
10
- }
11
- function getCauseFromUnknown(cause) {
12
- if (cause instanceof Error) {
13
- return cause;
14
- }
15
- const type = typeof cause;
16
- if (type === 'undefined' || type === 'function' || cause === null) {
17
- return undefined;
18
- }
19
- // Primitive types just get wrapped in an error
20
- if (type !== 'object') {
21
- return new Error(String(cause));
22
- }
23
- // If it's an object, we'll create a synthetic error
24
- if (isObject(cause)) {
25
- const err = new UnknownCauseError();
26
- for (const key in cause) {
27
- err[key] = cause[key];
28
- }
29
- return err;
30
- }
31
- return undefined;
32
- }
33
- const isDcqlError = (cause) => {
34
- if (cause instanceof DcqlError) {
35
- return true;
36
- }
37
- if (cause instanceof Error && cause.name === 'DcqlError') {
38
- // https://github.com/trpc/trpc/pull/4848
39
- return true;
40
- }
41
- return false;
42
- };
43
- exports.isDcqlError = isDcqlError;
44
- function getDcqlErrorFromUnknown(cause) {
45
- if ((0, exports.isDcqlError)(cause)) {
46
- return cause;
47
- }
48
- const dcqlError = new DcqlError({
49
- code: 'INTERNAL_SERVER_ERROR',
50
- cause,
51
- });
52
- // Inherit stack from error
53
- if (cause instanceof Error && cause.stack) {
54
- dcqlError.stack = cause.stack;
55
- }
56
- return dcqlError;
57
- }
58
- class DcqlError extends Error {
59
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
60
- // @ts-ignore override doesn't work in all environments due to "This member cannot have an 'override' modifier because it is not declared in the base class 'Error'"
61
- cause;
62
- code;
63
- constructor(opts) {
64
- const cause = getCauseFromUnknown(opts.cause);
65
- const message = opts.message ?? cause?.message ?? opts.code;
66
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
67
- // @ts-ignore https://github.com/tc39/proposal-error-cause
68
- super(message, { cause });
69
- this.code = opts.code;
70
- this.name = 'DcqlError';
71
- if (!this.cause) {
72
- // < ES2022 / < Node 16.9.0 compatability
73
- this.cause = cause;
74
- }
75
- }
76
- }
77
- exports.DcqlError = DcqlError;
78
- //# sourceMappingURL=e-base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"e-base.js","sourceRoot":"","sources":["../../../src/dcql-error/e-base.ts"],"names":[],"mappings":";;;AAQA,kDAyBC;AAcD,0DAgBC;AA/DD,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AACvE,CAAC;AAED,MAAM,iBAAkB,SAAQ,KAAK;CAEpC;AAED,SAAgB,mBAAmB,CAAC,KAAc;IAChD,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,KAAK,CAAC;IAC1B,IAAI,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,UAAU,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAClE,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,+CAA+C;IAC/C,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtB,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK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AAK,CAAC,CAAC;QAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,KAAK,EAAE,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC;QAE5D,6DAA6D;QAC7D,0DAA0D;QAC1D,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAE1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QAExB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,yCAAyC;YACzC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;IACH,CAAC;CACF;AA1BD,8BA0BC"}
@@ -1,50 +0,0 @@
1
- import { DcqlError } from './e-base.js';
2
- export declare class DcqlCredentialSetError extends DcqlError {
3
- constructor(opts: {
4
- message: string;
5
- cause?: unknown;
6
- });
7
- }
8
- export declare class DcqlUndefinedClaimSetIdError extends DcqlError {
9
- constructor(opts: {
10
- message: string;
11
- cause?: unknown;
12
- });
13
- }
14
- export declare class DcqlNonUniqueCredentialQueryIdsError extends DcqlError {
15
- constructor(opts: {
16
- message: string;
17
- cause?: unknown;
18
- });
19
- }
20
- export declare class DcqlParseError extends DcqlError {
21
- constructor(opts: {
22
- message: string;
23
- cause?: unknown;
24
- });
25
- }
26
- export declare class DcqlInvalidClaimsQueryIdError extends DcqlError {
27
- constructor(opts: {
28
- message: string;
29
- cause?: unknown;
30
- });
31
- }
32
- export declare class DcqlMissingClaimSetParseError extends DcqlError {
33
- constructor(opts: {
34
- message: string;
35
- cause?: unknown;
36
- });
37
- }
38
- export declare class DcqlInvalidPresentationRecordError extends DcqlError {
39
- constructor(opts: {
40
- message: string;
41
- cause?: unknown;
42
- });
43
- }
44
- export declare class DcqlPresentationResultError extends DcqlError {
45
- constructor(opts: {
46
- message: string;
47
- cause?: unknown;
48
- });
49
- }
50
- //# sourceMappingURL=e-dcql.d.ts.map
@@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- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DcqlPresentationResultError = exports.DcqlInvalidPresentationRecordError = exports.DcqlMissingClaimSetParseError = exports.DcqlInvalidClaimsQueryIdError = exports.DcqlParseError = exports.DcqlNonUniqueCredentialQueryIdsError = exports.DcqlUndefinedClaimSetIdError = exports.DcqlCredentialSetError = void 0;
4
- const e_base_js_1 = require("./e-base.js");
5
- class DcqlCredentialSetError extends e_base_js_1.DcqlError {
6
- constructor(opts) {
7
- super({ code: 'BAD_REQUEST', ...opts });
8
- }
9
- }
10
- exports.DcqlCredentialSetError = DcqlCredentialSetError;
11
- class DcqlUndefinedClaimSetIdError extends e_base_js_1.DcqlError {
12
- constructor(opts) {
13
- super({ code: 'BAD_REQUEST', ...opts });
14
- }
15
- }
16
- exports.DcqlUndefinedClaimSetIdError = DcqlUndefinedClaimSetIdError;
17
- class DcqlNonUniqueCredentialQueryIdsError extends e_base_js_1.DcqlError {
18
- constructor(opts) {
19
- super({ code: 'BAD_REQUEST', ...opts });
20
- }
21
- }
22
- exports.DcqlNonUniqueCredentialQueryIdsError = DcqlNonUniqueCredentialQueryIdsError;
23
- class DcqlParseError extends e_base_js_1.DcqlError {
24
- constructor(opts) {
25
- super({ code: 'PARSE_ERROR', ...opts });
26
- }
27
- }
28
- exports.DcqlParseError = DcqlParseError;
29
- class DcqlInvalidClaimsQueryIdError extends e_base_js_1.DcqlError {
30
- constructor(opts) {
31
- super({ code: 'BAD_REQUEST', ...opts });
32
- }
33
- }
34
- exports.DcqlInvalidClaimsQueryIdError = DcqlInvalidClaimsQueryIdError;
35
- class DcqlMissingClaimSetParseError extends e_base_js_1.DcqlError {
36
- constructor(opts) {
37
- super({ code: 'PARSE_ERROR', ...opts });
38
- }
39
- }
40
- exports.DcqlMissingClaimSetParseError = DcqlMissingClaimSetParseError;
41
- class DcqlInvalidPresentationRecordError extends e_base_js_1.DcqlError {
42
- constructor(opts) {
43
- super({ code: 'BAD_REQUEST', ...opts });
44
- }
45
- }
46
- exports.DcqlInvalidPresentationRecordError = DcqlInvalidPresentationRecordError;
47
- class DcqlPresentationResultError extends e_base_js_1.DcqlError {
48
- constructor(opts) {
49
- super({ code: 'BAD_REQUEST', ...opts });
50
- }
51
- }
52
- exports.DcqlPresentationResultError = DcqlPresentationResultError;
53
- //# sourceMappingURL=e-dcql.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"e-dcql.js","sourceRoot":"","sources":["../../../src/dcql-error/e-dcql.ts"],"names":[],"mappings":";;;AAAA,2CAAwC;AAExC,MAAa,sBAAuB,SAAQ,qBAAS;IACnD,YAAY,IAA0C;QACpD,KAAK,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;CACF;AAJD,wDAIC;AAED,MAAa,4BAA6B,SAAQ,qBAAS;IACzD,YAAY,IAA0C;QACpD,KAAK,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;CACF;AAJD,oEAIC;AAED,MAAa,oCAAqC,SAAQ,qBAAS;IACjE,YAAY,IAA0C;QACpD,KAAK,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;CACF;AAJD,oFAIC;AAED,MAAa,cAAe,SAAQ,qBAAS;IAC3C,YAAY,IAA0C;QACpD,KAAK,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;CACF;AAJD,wCAIC;AAED,MAAa,6BAA8B,SAAQ,qBAAS;IAC1D,YAAY,IAA0C;QACpD,KAAK,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;CACF;AAJD,sEAIC;AAED,MAAa,6BAA8B,SAAQ,qBAAS;IAC1D,YAAY,IAA0C;QACpD,KAAK,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;CACF;AAJD,sEAIC;AAED,MAAa,kCAAmC,SAAQ,qBAAS;IAC/D,YAAY,IAA0C;QACpD,KAAK,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;CACF;AAJD,gFAIC;AAED,MAAa,2BAA4B,SAAQ,qBAAS;IACxD,YAAY,IAA0C;QACpD,KAAK,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;CACF;AAJD,kEAIC"}
@@ -1,3 +0,0 @@
1
- export { DcqlError, getCauseFromUnknown, getDcqlErrorFromUnknown, } from './e-base.js';
2
- export * from './e-dcql.js';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dcql-error/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,cAAc,aAAa,CAAC"}
@@ -1,23 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.getDcqlErrorFromUnknown = exports.getCauseFromUnknown = exports.DcqlError = void 0;
18
- var e_base_js_1 = require("./e-base.js");
19
- Object.defineProperty(exports, "DcqlError", { enumerable: true, get: function () { return e_base_js_1.DcqlError; } });
20
- Object.defineProperty(exports, "getCauseFromUnknown", { enumerable: true, get: function () { return e_base_js_1.getCauseFromUnknown; } });
21
- Object.defineProperty(exports, "getDcqlErrorFromUnknown", { enumerable: true, get: function () { return e_base_js_1.getDcqlErrorFromUnknown; } });
22
- __exportStar(require("./e-dcql.js"), exports);
23
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/dcql-error/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yCAIqB;AAHnB,sGAAA,SAAS,OAAA;AACT,gHAAA,mBAAmB,OAAA;AACnB,oHAAA,uBAAuB,OAAA;AAEzB,8CAA4B"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=claims-path.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"claims-path.test.d.ts","sourceRoot":"","sources":["../../../src/dcql-parser/claims-path.test.ts"],"names":[],"mappings":""}
@@ -1,103 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const node_assert_1 = __importDefault(require("node:assert"));
30
- const node_test_1 = require("node:test");
31
- const v = __importStar(require("valibot"));
32
- const dcql_claims_query_result_js_1 = require("./dcql-claims-query-result.js");
33
- const claimsPathPointerExample = {
34
- name: 'Arthur Dent',
35
- address: {
36
- street_address: '42 Market Street',
37
- locality: 'Milliways',
38
- postal_code: '12345',
39
- },
40
- degrees: [
41
- {
42
- type: 'Bachelor of Science',
43
- university: 'University of Betelgeuse',
44
- },
45
- {
46
- type: 'Master of Science',
47
- university: 'University of Betelgeuse',
48
- },
49
- ],
50
- nationalities: ['British', 'Betelgeusian'],
51
- };
52
- void (0, node_test_1.describe)('claims-path', () => {
53
- void (0, node_test_1.it)('name', _t => {
54
- const parser = (0, dcql_claims_query_result_js_1.getJsonClaimsParser)([{ path: ['name'] }], {
55
- presentation: false,
56
- });
57
- const res = v.parse(parser, claimsPathPointerExample);
58
- node_assert_1.default.deepStrictEqual(res, {
59
- name: 'Arthur Dent',
60
- });
61
- });
62
- void (0, node_test_1.it)('address', _t => {
63
- const parser = (0, dcql_claims_query_result_js_1.getJsonClaimsParser)([{ path: ['address'] }], {
64
- presentation: false,
65
- });
66
- const res = v.parse(parser, claimsPathPointerExample);
67
- node_assert_1.default.deepStrictEqual(res, {
68
- address: {
69
- street_address: '42 Market Street',
70
- locality: 'Milliways',
71
- postal_code: '12345',
72
- },
73
- });
74
- });
75
- void (0, node_test_1.it)('address street address', _t => {
76
- const parser = (0, dcql_claims_query_result_js_1.getJsonClaimsParser)([{ path: ['address', 'street_address'] }], { presentation: false });
77
- const res = v.parse(parser, claimsPathPointerExample);
78
- node_assert_1.default.deepStrictEqual(res, {
79
- address: {
80
- street_address: '42 Market Street',
81
- },
82
- });
83
- });
84
- void (0, node_test_1.it)('nationalities', _t => {
85
- const parser = (0, dcql_claims_query_result_js_1.getJsonClaimsParser)([{ path: ['nationalities', 1] }], {
86
- presentation: false,
87
- });
88
- const res = v.parse(parser, claimsPathPointerExample);
89
- node_assert_1.default.deepStrictEqual(res, {
90
- nationalities: 'Betelgeusian',
91
- });
92
- });
93
- void (0, node_test_1.it)('all degree types', _t => {
94
- const parser = (0, dcql_claims_query_result_js_1.getJsonClaimsParser)([{ path: ['degrees', null, 'type'] }], {
95
- presentation: false,
96
- });
97
- const res = v.parse(parser, claimsPathPointerExample);
98
- node_assert_1.default.deepStrictEqual(res, {
99
- degrees: [{ type: 'Bachelor of Science' }, { type: 'Master of Science' }],
100
- });
101
- });
102
- });
103
- //# sourceMappingURL=claims-path.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"claims-path.test.js","sourceRoot":"","sources":["../../../src/dcql-parser/claims-path.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAiC;AACjC,yCAAyC;AACzC,2CAA6B;AAC7B,+EAAoE;AAEpE,MAAM,wBAAwB,GAAG;IAC/B,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE;QACP,cAAc,EAAE,kBAAkB;QAClC,QAAQ,EAAE,WAAW;QACrB,WAAW,EAAE,OAAO;KACrB;IACD,OAAO,EAAE;QACP;YACE,IAAI,EAAE,qBAAqB;YAC3B,UAAU,EAAE,0BAA0B;SACvC;QACD;YACE,IAAI,EAAE,mBAAmB;YACzB,UAAU,EAAE,0BAA0B;SACvC;KACF;IACD,aAAa,EAAE,CAAC,SAAS,EAAE,cAAc,CAAC;CAC3C,CAAC;AAEF,KAAK,IAAA,oBAAQ,EAAC,aAAa,EAAE,GAAG,EAAE;IAChC,KAAK,IAAA,cAAE,EAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACnB,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,CAAC,CAAC;IAEH,KAAK,IAAA,cAAE,EAAC,eAAe,EAAE,EAAE,CAAC,EAAE;QAC5B,MAAM,MAAM,GAAG,IAAA,iDAAmB,EAAC,CAAC,EAAE,IAAI,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE;YACnE,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;QACH,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;QAEtD,qBAAM,CAAC,eAAe,CAAC,GAAG,EAAE;YAC1B,aAAa,EAAE,cAAc;SAC9B,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,KAAK,IAAA,cAAE,EAAC,kBAAkB,EAAE,EAAE,CAAC,EAAE;QAC/B,MAAM,MAAM,GAAG,IAAA,iDAAmB,EAAC,CAAC,EAAE,IAAI,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,CAAC,EAAE;YACxE,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;QACH,MAAM,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;QAEtD,qBAAM,CAAC,eAAe,CAAC,GAAG,EAAE;YAC1B,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,qBAAqB,EAAE,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE,CAAC;SAC1E,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,25 +0,0 @@
1
- import * as v from 'valibot';
2
- import type { DcqlClaimsQuery } from '../dcql-query/m-dcql-claims-query.js';
3
- import type { DcqlCredentialQuery } from '../dcql-query/m-dcql-credential-query.js';
4
- export declare const getNamespacesParser: (claimsQueries: DcqlClaimsQuery.Mdoc[]) => v.ObjectSchema<any, undefined>;
5
- export declare const getJsonClaimsParser: (claimsQueries: DcqlClaimsQuery.W3cAndSdJwtVc[], ctx: {
6
- presentation: boolean;
7
- }) => v.IntersectSchema<v.RecordSchema<v.StringSchema<undefined>, v.GenericSchema<import("../u-dcql").Json, import("../u-dcql").Json, v.BaseIssue<unknown>>, undefined>[], undefined>;
8
- export declare const getMdocClaimsQueriesForClaimSet: (claimsQueries: DcqlClaimsQuery.Mdoc[], claimSet: string[]) => DcqlClaimsQuery.Mdoc[];
9
- export declare const getJsonClaimsQueriesForClaimSet: (claimsQueries: DcqlClaimsQuery.W3cAndSdJwtVc[], claimSet: string[]) => DcqlClaimsQuery.W3cAndSdJwtVc[];
10
- export declare const getCredentialQueryParser: (credentialQuery: DcqlCredentialQuery, ctx: {
11
- claimSet?: NonNullable<DcqlCredentialQuery["claim_sets"]>[number];
12
- presentation: boolean;
13
- }) => v.ObjectSchema<{
14
- readonly credential_format: v.LiteralSchema<"mso_mdoc", undefined>;
15
- readonly doctype: v.StringSchema<undefined> | v.LiteralSchema<string, undefined>;
16
- readonly namespaces: v.RecordSchema<v.StringSchema<undefined>, v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined> | v.ObjectSchema<any, undefined>;
17
- }, undefined> | v.ObjectSchema<{
18
- readonly credential_format: v.LiteralSchema<"vc+sd-jwt" | "dc+sd-jwt", undefined>;
19
- readonly vct: v.StringSchema<undefined> | v.PicklistSchema<string[], undefined>;
20
- readonly claims: v.RecordSchema<v.StringSchema<undefined>, v.GenericSchema<import("../u-dcql").Json, import("../u-dcql").Json, v.BaseIssue<unknown>>, undefined> | v.IntersectSchema<v.RecordSchema<v.StringSchema<undefined>, v.GenericSchema<import("../u-dcql").Json, import("../u-dcql").Json, v.BaseIssue<unknown>>, undefined>[], undefined>;
21
- }, undefined> | v.ObjectSchema<{
22
- readonly credential_format: v.PicklistSchema<["jwt_vc_json", "jwt_vc_json-ld"], undefined>;
23
- readonly claims: v.RecordSchema<v.StringSchema<undefined>, v.GenericSchema<import("../u-dcql").Json, import("../u-dcql").Json, v.BaseIssue<unknown>>, undefined> | v.IntersectSchema<v.RecordSchema<v.StringSchema<undefined>, v.GenericSchema<import("../u-dcql").Json, import("../u-dcql").Json, v.BaseIssue<unknown>>, undefined>[], undefined>;
24
- }, undefined>;
25
- //# sourceMappingURL=dcql-claims-query-result.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dcql-claims-query-result.d.ts","sourceRoot":"","sources":["../../../src/dcql-parser/dcql-claims-query-result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAK7B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAoBpF,eAAO,MAAM,mBAAmB,kBAAmB,eAAe,CAAC,IAAI,EAAE,mCAwBxE,CAAC;AAgDF,eAAO,MAAM,mBAAmB,kBACf,eAAe,CAAC,aAAa,EAAE,OACzC;IAAE,YAAY,EAAE,OAAO,CAAA;CAAE,oLAa/B,CAAC;AAEF,eAAO,MAAM,+BAA+B,kBAC3B,eAAe,CAAC,IAAI,EAAE,YAC3B,MAAM,EAAE,KACjB,eAAe,CAAC,IAAI,EAUtB,CAAC;AAEF,eAAO,MAAM,+BAA+B,kBAC3B,eAAe,CAAC,aAAa,EAAE,YACpC,MAAM,EAAE,KACjB,eAAe,CAAC,aAAa,EAU/B,CAAC;AAkEF,eAAO,MAAM,wBAAwB,oBAClB,mBAAmB,OAC/B;IACH,QAAQ,CAAC,EAAE,WAAW,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAClE,YAAY,EAAE,OAAO,CAAC;CACvB;;;;;;;;;;;aAaF,CAAC"}