@interop/wallet-core 0.1.1 → 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.
Files changed (103) hide show
  1. package/README.md +18 -2
  2. package/dist/display/alignment.d.ts +49 -0
  3. package/dist/display/alignment.d.ts.map +1 -0
  4. package/dist/display/alignment.js +114 -0
  5. package/dist/display/alignment.js.map +1 -0
  6. package/dist/display/credentialName.d.ts +42 -0
  7. package/dist/display/credentialName.d.ts.map +1 -0
  8. package/dist/display/credentialName.js +106 -0
  9. package/dist/display/credentialName.js.map +1 -0
  10. package/dist/display/displayFields.d.ts +55 -0
  11. package/dist/display/displayFields.d.ts.map +1 -0
  12. package/dist/display/displayFields.js +136 -0
  13. package/dist/display/displayFields.js.map +1 -0
  14. package/dist/display/evidence.d.ts +44 -0
  15. package/dist/display/evidence.d.ts.map +1 -0
  16. package/dist/display/evidence.js +65 -0
  17. package/dist/display/evidence.js.map +1 -0
  18. package/dist/display/image.d.ts +18 -0
  19. package/dist/display/image.d.ts.map +1 -0
  20. package/dist/display/image.js +23 -0
  21. package/dist/display/image.js.map +1 -0
  22. package/dist/display/index.d.ts +38 -0
  23. package/dist/display/index.d.ts.map +1 -0
  24. package/dist/display/index.js +32 -0
  25. package/dist/display/index.js.map +1 -0
  26. package/dist/display/issuer.d.ts +97 -0
  27. package/dist/display/issuer.d.ts.map +1 -0
  28. package/dist/display/issuer.js +126 -0
  29. package/dist/display/issuer.js.map +1 -0
  30. package/dist/display/obv3.d.ts +77 -0
  31. package/dist/display/obv3.d.ts.map +1 -0
  32. package/dist/display/obv3.js +127 -0
  33. package/dist/display/obv3.js.map +1 -0
  34. package/dist/display/parse.d.ts +62 -0
  35. package/dist/display/parse.d.ts.map +1 -0
  36. package/dist/display/parse.js +100 -0
  37. package/dist/display/parse.js.map +1 -0
  38. package/dist/display/subject.d.ts +75 -0
  39. package/dist/display/subject.d.ts.map +1 -0
  40. package/dist/display/subject.js +122 -0
  41. package/dist/display/subject.js.map +1 -0
  42. package/dist/display/text.d.ts +42 -0
  43. package/dist/display/text.d.ts.map +1 -0
  44. package/dist/display/text.js +62 -0
  45. package/dist/display/text.js.map +1 -0
  46. package/dist/display/types.d.ts +55 -0
  47. package/dist/display/types.d.ts.map +1 -0
  48. package/dist/display/types.js +41 -0
  49. package/dist/display/types.js.map +1 -0
  50. package/dist/display/validity.d.ts +51 -0
  51. package/dist/display/validity.d.ts.map +1 -0
  52. package/dist/display/validity.js +51 -0
  53. package/dist/display/validity.js.map +1 -0
  54. package/dist/display/verificationView.d.ts +101 -0
  55. package/dist/display/verificationView.d.ts.map +1 -0
  56. package/dist/display/verificationView.js +199 -0
  57. package/dist/display/verificationView.js.map +1 -0
  58. package/dist/index.d.ts +11 -2
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +11 -2
  61. package/dist/index.js.map +1 -1
  62. package/dist/request/classify.d.ts +112 -0
  63. package/dist/request/classify.d.ts.map +1 -0
  64. package/dist/request/classify.js +210 -0
  65. package/dist/request/classify.js.map +1 -0
  66. package/dist/request/composeVp.d.ts +52 -0
  67. package/dist/request/composeVp.d.ts.map +1 -0
  68. package/dist/request/composeVp.js +177 -0
  69. package/dist/request/composeVp.js.map +1 -0
  70. package/dist/request/exchangeClient.d.ts +165 -0
  71. package/dist/request/exchangeClient.d.ts.map +1 -0
  72. package/dist/request/exchangeClient.js +212 -0
  73. package/dist/request/exchangeClient.js.map +1 -0
  74. package/dist/request/index.d.ts +35 -0
  75. package/dist/request/index.d.ts.map +1 -0
  76. package/dist/request/index.js +35 -0
  77. package/dist/request/index.js.map +1 -0
  78. package/dist/request/interactionUrl.d.ts +53 -0
  79. package/dist/request/interactionUrl.d.ts.map +1 -0
  80. package/dist/request/interactionUrl.js +83 -0
  81. package/dist/request/interactionUrl.js.map +1 -0
  82. package/dist/request/matching.d.ts +69 -0
  83. package/dist/request/matching.d.ts.map +1 -0
  84. package/dist/request/matching.js +183 -0
  85. package/dist/request/matching.js.map +1 -0
  86. package/dist/request/parse.d.ts +68 -0
  87. package/dist/request/parse.d.ts.map +1 -0
  88. package/dist/request/parse.js +114 -0
  89. package/dist/request/parse.js.map +1 -0
  90. package/dist/request/presentationSuite.d.ts +71 -0
  91. package/dist/request/presentationSuite.d.ts.map +1 -0
  92. package/dist/request/presentationSuite.js +139 -0
  93. package/dist/request/presentationSuite.js.map +1 -0
  94. package/dist/request/processRequest.d.ts +48 -0
  95. package/dist/request/processRequest.d.ts.map +1 -0
  96. package/dist/request/processRequest.js +139 -0
  97. package/dist/request/processRequest.js.map +1 -0
  98. package/dist/request/types.d.ts +150 -0
  99. package/dist/request/types.d.ts.map +1 -0
  100. package/dist/request/types.js +2 -0
  101. package/dist/request/types.js.map +1 -0
  102. package/dist/sync/types.d.ts.map +1 -1
  103. package/package.json +21 -2
@@ -0,0 +1,51 @@
1
+ /*!
2
+ * Copyright (c) 2026 Interop Alliance. All rights reserved.
3
+ */
4
+ /**
5
+ * Validity-period readers for both VC Data Model 1.0 (`issuanceDate` /
6
+ * `expirationDate`) and 2.0 (`validFrom` / `validUntil`). The library returns
7
+ * the raw ISO strings and a `Date` -- never a formatted string -- so each app
8
+ * applies its own locale formatting on top (the raw-values seam).
9
+ *
10
+ * Drift resolution: this is the union of DCW's `credentialValidityPeriod.ts`
11
+ * (which had `getIssuanceDate` / `getExpirationDate` / `isExpired` returning
12
+ * `undefined` when absent) and Freewallet's `formatDate.ts` (which had
13
+ * `getExpirationInstant` returning `Date | null`, plus an empty-string variant
14
+ * of `getExpirationDate`). DCW's `undefined` convention wins for the string
15
+ * getters; Freewallet's `''`-returning wrapper is trivially reproduced app-side
16
+ * as `getExpirationDate(vc) ?? ''`.
17
+ */
18
+ import type { IVerifiableCredential } from '@interop/data-integrity-core';
19
+ /**
20
+ * The issuance instant as a raw ISO string: VC 2.0 `validFrom` preferred, else
21
+ * VC 1.0 `issuanceDate`, else `undefined`.
22
+ *
23
+ * @param credential {IVerifiableCredential}
24
+ * @returns {string | undefined}
25
+ */
26
+ export declare function getIssuanceDate(credential: IVerifiableCredential): string | undefined;
27
+ /**
28
+ * The expiration instant as a raw ISO string: VC 2.0 `validUntil` preferred,
29
+ * else VC 1.0 `expirationDate`, else `undefined`.
30
+ *
31
+ * @param credential {IVerifiableCredential}
32
+ * @returns {string | undefined}
33
+ */
34
+ export declare function getExpirationDate(credential: IVerifiableCredential): string | undefined;
35
+ /**
36
+ * The expiration instant as a `Date`, or `null` when there is no expiration or
37
+ * it does not parse.
38
+ *
39
+ * @param credential {IVerifiableCredential}
40
+ * @returns {Date | null}
41
+ */
42
+ export declare function getExpirationInstant(credential: IVerifiableCredential): Date | null;
43
+ /**
44
+ * Whether the credential has an expiration date that is already in the past.
45
+ * A credential with no expiration is never expired.
46
+ *
47
+ * @param credential {IVerifiableCredential}
48
+ * @returns {boolean}
49
+ */
50
+ export declare function isExpired(credential: IVerifiableCredential): boolean;
51
+ //# sourceMappingURL=validity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validity.d.ts","sourceRoot":"","sources":["../../src/display/validity.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AAEzE;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,qBAAqB,GAChC,MAAM,GAAG,SAAS,CAEpB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,qBAAqB,GAChC,MAAM,GAAG,SAAS,CAEpB;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,qBAAqB,GAChC,IAAI,GAAG,IAAI,CAOb;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,qBAAqB,GAAG,OAAO,CAOpE"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * The issuance instant as a raw ISO string: VC 2.0 `validFrom` preferred, else
3
+ * VC 1.0 `issuanceDate`, else `undefined`.
4
+ *
5
+ * @param credential {IVerifiableCredential}
6
+ * @returns {string | undefined}
7
+ */
8
+ export function getIssuanceDate(credential) {
9
+ return credential.validFrom ?? credential.issuanceDate;
10
+ }
11
+ /**
12
+ * The expiration instant as a raw ISO string: VC 2.0 `validUntil` preferred,
13
+ * else VC 1.0 `expirationDate`, else `undefined`.
14
+ *
15
+ * @param credential {IVerifiableCredential}
16
+ * @returns {string | undefined}
17
+ */
18
+ export function getExpirationDate(credential) {
19
+ return credential.validUntil ?? credential.expirationDate;
20
+ }
21
+ /**
22
+ * The expiration instant as a `Date`, or `null` when there is no expiration or
23
+ * it does not parse.
24
+ *
25
+ * @param credential {IVerifiableCredential}
26
+ * @returns {Date | null}
27
+ */
28
+ export function getExpirationInstant(credential) {
29
+ const iso = getExpirationDate(credential);
30
+ if (!iso) {
31
+ return null;
32
+ }
33
+ const d = new Date(iso);
34
+ return Number.isNaN(d.getTime()) ? null : d;
35
+ }
36
+ /**
37
+ * Whether the credential has an expiration date that is already in the past.
38
+ * A credential with no expiration is never expired.
39
+ *
40
+ * @param credential {IVerifiableCredential}
41
+ * @returns {boolean}
42
+ */
43
+ export function isExpired(credential) {
44
+ const expiration = getExpirationDate(credential);
45
+ if (!expiration) {
46
+ return false;
47
+ }
48
+ const t = Date.parse(String(expiration));
49
+ return !Number.isNaN(t) && t < Date.now();
50
+ }
51
+ //# sourceMappingURL=validity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validity.js","sourceRoot":"","sources":["../../src/display/validity.ts"],"names":[],"mappings":"AAmBA;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC7B,UAAiC;IAEjC,OAAO,UAAU,CAAC,SAAS,IAAI,UAAU,CAAC,YAAY,CAAA;AACxD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAC/B,UAAiC;IAEjC,OAAO,UAAU,CAAC,UAAU,IAAI,UAAU,CAAC,cAAc,CAAA;AAC3D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,UAAiC;IAEjC,MAAM,GAAG,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAA;IACzC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,IAAI,CAAA;IACb,CAAC;IACD,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAA;IACvB,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;AAC7C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,UAAiC;IACzD,MAAM,UAAU,GAAG,iBAAiB,CAAC,UAAU,CAAC,CAAA;IAChD,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,KAAK,CAAA;IACd,CAAC;IACD,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAA;IACxC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;AAC3C,CAAC"}
@@ -0,0 +1,101 @@
1
+ /*!
2
+ * Copyright (c) 2026 Interop Alliance. All rights reserved.
3
+ */
4
+ /**
5
+ * Verification-to-UI derivation: pure readers over a `verifyCredential` result
6
+ * `log[]`. No conflict existed between the apps -- they read different things
7
+ * from the same log -- so both are extracted:
8
+ *
9
+ * - `buildVerificationChecklist` (Freewallet) builds the five-step
10
+ * supportedFormat / signature / issuer / revocation / expiration checklist,
11
+ * each `{ valid, message, status }`, plus the `getVerificationAggregateStatus`
12
+ * / `isFullyVerified` / `isExpiredOnly` / `hasVerificationWarning` rollups.
13
+ * - `issuerRecognizedByVerification` (backs DCW's `shouldDisableUrls`) reports
14
+ * whether the `registered_issuer` entry confirms a registry match.
15
+ *
16
+ * i18n stays OUT of the library: instead of Freewallet's injected `TFunction`
17
+ * or DCW's hardcoded English, `buildVerificationChecklist` takes an injected
18
+ * `labels` map keyed by {@link ChecklistMsgKey}. Each app supplies its own
19
+ * strings (Freewallet from `t(...)`, DCW its English literals).
20
+ */
21
+ import type { IVerifiableCredential } from '@interop/data-integrity-core';
22
+ /** Per-step severity. */
23
+ export type VerificationStepStatus = 'positive' | 'warning' | 'negative';
24
+ /** One checklist step. */
25
+ export interface VerificationStep {
26
+ valid: boolean;
27
+ message: string;
28
+ status: VerificationStepStatus;
29
+ error?: string;
30
+ }
31
+ /** The five-step checklist, with `expiry` / `status` legacy aliases. */
32
+ export interface VerificationChecklist {
33
+ supportedFormat: VerificationStep;
34
+ signature: VerificationStep;
35
+ issuer: VerificationStep;
36
+ revocation: VerificationStep;
37
+ expiration: VerificationStep;
38
+ /** @deprecated Use `expiration`. */
39
+ expiry: VerificationStep;
40
+ /** @deprecated Use `revocation`. */
41
+ status: VerificationStep;
42
+ }
43
+ /** Rolled-up verification outcome. */
44
+ export type VerificationAggregateStatus = 'verified' | 'warning' | 'not_verified';
45
+ /** The message keys `buildVerificationChecklist` looks up in the `labels` map. */
46
+ export type ChecklistMsgKey = 'supportedFormatOk' | 'supportedFormatFail' | 'signatureOk' | 'signatureFail' | 'issuerOk' | 'issuerFail' | 'revocationOk' | 'revocationFail' | 'expirationOk' | 'expirationFail' | 'noExpiration';
47
+ /**
48
+ * Builds the five-step verification checklist from a raw `verifyCredential`
49
+ * payload, the credential, and an injected `labels` map.
50
+ *
51
+ * @param raw {Record<string, unknown>} the raw verify result
52
+ * @param credential {IVerifiableCredential}
53
+ * @param labels {Record<ChecklistMsgKey, string>} localized message strings
54
+ * @returns {VerificationChecklist}
55
+ */
56
+ export declare function buildVerificationChecklist(raw: Record<string, unknown>, credential: IVerifiableCredential, labels: Record<ChecklistMsgKey, string>): VerificationChecklist;
57
+ /**
58
+ * Rolls the checklist up to a single status. Hard failures (bad signature /
59
+ * format / revocation) yield `'not_verified'`; a soft issue (unknown issuer or
60
+ * expired) yields `'warning'`; otherwise `'verified'`.
61
+ *
62
+ * @param result {VerificationChecklist | null}
63
+ * @returns {VerificationAggregateStatus | null}
64
+ */
65
+ export declare function getVerificationAggregateStatus(result: VerificationChecklist | null): VerificationAggregateStatus | null;
66
+ /**
67
+ * Whether every check passed.
68
+ *
69
+ * @param result {VerificationChecklist | null}
70
+ * @returns {boolean}
71
+ */
72
+ export declare function isFullyVerified(result: VerificationChecklist | null): boolean;
73
+ /**
74
+ * Whether the only failing check is expiration (everything else passed).
75
+ *
76
+ * @param result {VerificationChecklist | null}
77
+ * @returns {boolean}
78
+ */
79
+ export declare function isExpiredOnly(result: VerificationChecklist | null): boolean;
80
+ /**
81
+ * Whether the aggregate status is a warning.
82
+ *
83
+ * @param result {VerificationChecklist | null}
84
+ * @returns {boolean}
85
+ */
86
+ export declare function hasVerificationWarning(result: VerificationChecklist | null): boolean;
87
+ /**
88
+ * Whether verification confirms a registered issuer: the `registered_issuer`
89
+ * log entry is valid and (when present) its `matchingIssuers` is non-empty.
90
+ * Backs DCW's `shouldDisableUrls` (a one-line app wrapper:
91
+ * `!issuerRecognizedByVerification(log)`).
92
+ *
93
+ * @param log {Array<{ id: string; valid?: boolean; matchingIssuers?: unknown[] }> | undefined}
94
+ * @returns {boolean}
95
+ */
96
+ export declare function issuerRecognizedByVerification(log?: Array<{
97
+ id: string;
98
+ valid?: boolean;
99
+ matchingIssuers?: unknown[];
100
+ }>): boolean;
101
+ //# sourceMappingURL=verificationView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verificationView.d.ts","sourceRoot":"","sources":["../../src/display/verificationView.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAA;AAIzE,yBAAyB;AACzB,MAAM,MAAM,sBAAsB,GAAG,UAAU,GAAG,SAAS,GAAG,UAAU,CAAA;A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,OAAO,CAW3E;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,qBAAqB,GAAG,IAAI,GACnC,OAAO,CAET;AAED;;;;;;;;GAQG;AACH,wBAAgB,8BAA8B,CAC5C,GAAG,CAAC,EAAE,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,eAAe,CAAC,EAAE,OAAO,EAAE,CAAA;CAAE,CAAC,GACxE,OAAO,CAcT"}
@@ -0,0 +1,199 @@
1
+ import { getExpirationInstant } from './validity.js';
2
+ import { typeArray } from '@interop/data-integrity-core/guards';
3
+ const STEP_ID = {
4
+ validSignature: 'valid_signature',
5
+ expiration: 'expiration',
6
+ revocation: 'revocation_status',
7
+ registeredIssuer: 'registered_issuer'
8
+ };
9
+ const SUPPORTED_CREDENTIAL_TYPES = [
10
+ 'VerifiableCredential',
11
+ 'OpenBadgeCredential'
12
+ ];
13
+ function getVerifyLogFromPayload(raw) {
14
+ const results = raw.results;
15
+ const logFromFirstResult = results?.[0]?.log;
16
+ if (Array.isArray(logFromFirstResult)) {
17
+ return logFromFirstResult;
18
+ }
19
+ const topLevelLog = raw.log;
20
+ if (Array.isArray(topLevelLog)) {
21
+ return topLevelLog;
22
+ }
23
+ return [];
24
+ }
25
+ function step(valid, message, severity, error) {
26
+ return {
27
+ valid,
28
+ message,
29
+ status: severity,
30
+ ...(error ? { error } : {})
31
+ };
32
+ }
33
+ function logValid(entry) {
34
+ if (!entry) {
35
+ return undefined;
36
+ }
37
+ return entry.valid === true && !entry.error;
38
+ }
39
+ function supportedFormatStep(credential, labels) {
40
+ const hasKnownType = typeArray(credential.type).some(type => SUPPORTED_CREDENTIAL_TYPES.includes(type));
41
+ return step(hasKnownType, hasKnownType ? labels.supportedFormatOk : labels.supportedFormatFail, hasKnownType ? 'positive' : 'negative');
42
+ }
43
+ function signatureStep(entry, labels) {
44
+ const valid = logValid(entry) ?? false;
45
+ return step(valid, valid ? labels.signatureOk : labels.signatureFail, valid ? 'positive' : 'negative', entry?.error?.message);
46
+ }
47
+ function issuerStep(entry, labels) {
48
+ const valid = logValid(entry) ?? false;
49
+ return step(valid, valid ? labels.issuerOk : labels.issuerFail, valid ? 'positive' : 'warning', entry?.error?.message);
50
+ }
51
+ function revocationStep(entry, credential, labels) {
52
+ if (!credential.credentialStatus && !entry) {
53
+ return step(true, labels.revocationOk, 'positive');
54
+ }
55
+ const valid = logValid(entry) ?? true;
56
+ return step(valid, valid ? labels.revocationOk : labels.revocationFail, valid ? 'positive' : 'negative', entry?.error?.message);
57
+ }
58
+ function expirationStep(entry, credential, labels) {
59
+ const exp = getExpirationInstant(credential);
60
+ const hasExpirationDate = exp != null;
61
+ if (!hasExpirationDate && !entry) {
62
+ return step(true, labels.noExpiration, 'positive');
63
+ }
64
+ if (entry) {
65
+ const valid = logValid(entry) ?? false;
66
+ return step(valid, valid ? labels.expirationOk : labels.expirationFail, valid ? 'positive' : 'warning', entry.error?.message);
67
+ }
68
+ const expired = exp.getTime() < Date.now();
69
+ return step(!expired, expired ? labels.expirationFail : labels.expirationOk, expired ? 'warning' : 'positive');
70
+ }
71
+ function withGlobalErr(stepValue, globalErr) {
72
+ if (stepValue.valid || !globalErr) {
73
+ return stepValue;
74
+ }
75
+ return { ...stepValue, error: stepValue.error ?? globalErr };
76
+ }
77
+ function attachLegacyAliases(checklist) {
78
+ return {
79
+ ...checklist,
80
+ expiry: checklist.expiration,
81
+ status: checklist.revocation
82
+ };
83
+ }
84
+ /**
85
+ * Builds the five-step verification checklist from a raw `verifyCredential`
86
+ * payload, the credential, and an injected `labels` map.
87
+ *
88
+ * @param raw {Record<string, unknown>} the raw verify result
89
+ * @param credential {IVerifiableCredential}
90
+ * @param labels {Record<ChecklistMsgKey, string>} localized message strings
91
+ * @returns {VerificationChecklist}
92
+ */
93
+ export function buildVerificationChecklist(raw, credential, labels) {
94
+ const log = getVerifyLogFromPayload(raw);
95
+ const byId = (id) => log.find(line => line.id === id);
96
+ const resultsWithError = raw.results;
97
+ const globalErr = typeof resultsWithError?.[0]?.error?.message === 'string'
98
+ ? resultsWithError[0].error.message
99
+ : undefined;
100
+ const checklist = {
101
+ supportedFormat: supportedFormatStep(credential, labels),
102
+ signature: signatureStep(byId(STEP_ID.validSignature), labels),
103
+ issuer: issuerStep(byId(STEP_ID.registeredIssuer), labels),
104
+ revocation: revocationStep(byId(STEP_ID.revocation), credential, labels),
105
+ expiration: expirationStep(byId(STEP_ID.expiration), credential, labels)
106
+ };
107
+ if (!globalErr) {
108
+ return attachLegacyAliases(checklist);
109
+ }
110
+ return attachLegacyAliases({
111
+ supportedFormat: withGlobalErr(checklist.supportedFormat, globalErr),
112
+ signature: withGlobalErr(checklist.signature, globalErr),
113
+ issuer: withGlobalErr(checklist.issuer, globalErr),
114
+ revocation: withGlobalErr(checklist.revocation, globalErr),
115
+ expiration: withGlobalErr(checklist.expiration, globalErr)
116
+ });
117
+ }
118
+ /**
119
+ * Rolls the checklist up to a single status. Hard failures (bad signature /
120
+ * format / revocation) yield `'not_verified'`; a soft issue (unknown issuer or
121
+ * expired) yields `'warning'`; otherwise `'verified'`.
122
+ *
123
+ * @param result {VerificationChecklist | null}
124
+ * @returns {VerificationAggregateStatus | null}
125
+ */
126
+ export function getVerificationAggregateStatus(result) {
127
+ if (!result) {
128
+ return null;
129
+ }
130
+ const hasFailure = !result.signature.valid ||
131
+ !result.supportedFormat.valid ||
132
+ !result.revocation.valid;
133
+ const hasWarning = !result.issuer.valid || !result.expiration.valid;
134
+ if (hasFailure) {
135
+ return 'not_verified';
136
+ }
137
+ if (hasWarning) {
138
+ return 'warning';
139
+ }
140
+ return 'verified';
141
+ }
142
+ /**
143
+ * Whether every check passed.
144
+ *
145
+ * @param result {VerificationChecklist | null}
146
+ * @returns {boolean}
147
+ */
148
+ export function isFullyVerified(result) {
149
+ return getVerificationAggregateStatus(result) === 'verified';
150
+ }
151
+ /**
152
+ * Whether the only failing check is expiration (everything else passed).
153
+ *
154
+ * @param result {VerificationChecklist | null}
155
+ * @returns {boolean}
156
+ */
157
+ export function isExpiredOnly(result) {
158
+ if (!result) {
159
+ return false;
160
+ }
161
+ return (result.signature.valid &&
162
+ result.supportedFormat.valid &&
163
+ result.issuer.valid &&
164
+ result.revocation.valid &&
165
+ !result.expiration.valid);
166
+ }
167
+ /**
168
+ * Whether the aggregate status is a warning.
169
+ *
170
+ * @param result {VerificationChecklist | null}
171
+ * @returns {boolean}
172
+ */
173
+ export function hasVerificationWarning(result) {
174
+ return getVerificationAggregateStatus(result) === 'warning';
175
+ }
176
+ /**
177
+ * Whether verification confirms a registered issuer: the `registered_issuer`
178
+ * log entry is valid and (when present) its `matchingIssuers` is non-empty.
179
+ * Backs DCW's `shouldDisableUrls` (a one-line app wrapper:
180
+ * `!issuerRecognizedByVerification(log)`).
181
+ *
182
+ * @param log {Array<{ id: string; valid?: boolean; matchingIssuers?: unknown[] }> | undefined}
183
+ * @returns {boolean}
184
+ */
185
+ export function issuerRecognizedByVerification(log) {
186
+ if (!Array.isArray(log)) {
187
+ return false;
188
+ }
189
+ return log.some(entry => {
190
+ if (entry.id !== 'registered_issuer') {
191
+ return false;
192
+ }
193
+ const { matchingIssuers } = entry;
194
+ return entry.valid && Array.isArray(matchingIssuers)
195
+ ? matchingIssuers.length > 0
196
+ : Boolean(entry.valid);
197
+ });
198
+ }
199
+ //# sourceMappingURL=verificationView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verificationView.js","sourceRoot":"","sources":["../../src/display/verificationView.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAA;AA4C/D,MAAM,OAAO,GAAG;IACd,cAAc,EAAE,iBAAiB;IACjC,UAAU,EAAE,YAAY;IACxB,UAAU,EAAE,mBAAmB;IAC/B,gBAAgB,EAAE,mBAAmB;CAC7B,CAAA;AAEV,MAAM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MAAM,CAAC,SAAS,CAAC,KAAK;QACtB,MAAM,CAAC,eAAe,CAAC,KAAK;QAC5B,MAAM,CAAC,MAAM,CAAC,KAAK;QACnB,MAAM,CAAC,UAAU,CAAC,KAAK;QACvB,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CACzB,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAoC;IAEpC,OAAO,8BAA8B,CAAC,MAAM,CAAC,KAAK,SAAS,CAAA;AAC7D,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,8BAA8B,CAC5C,GAAyE;IAEzE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;QACtB,IAAI,KAAK,CAAC,EAAE,KAAK,mBAAmB,EAAE,CAAC;YACrC,OAAO,KAAK,CAAA;QACd,CAAC;QACD,MAAM,EAAE,eAAe,EAAE,GAAG,KAAK,CAAA;QACjC,OAAO,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,eAAe,CAAC;YAClD,CAAC,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC;YAC5B,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IAC1B,CAAC,CAAC,CAAA;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -3,12 +3,21 @@
3
3
  */
4
4
  /**
5
5
  * `@interop/wallet-core` -- shared wallet-domain logic for Interop wallet apps.
6
- * The two subpaths are canonical and can be imported directly:
6
+ * The subpaths are canonical and can be imported directly:
7
7
  *
8
8
  * - `@interop/wallet-core/sync` -- the WAS replication engine core.
9
9
  * - `@interop/wallet-core/space` -- the wallet Space layout contract.
10
+ * - `@interop/wallet-core/request` -- wallet-request / exchange protocol
11
+ * handling (classification and parsing, QueryByExample matching, cryptosuite
12
+ * negotiation, VP composition, the VC-API exchange client, and VCALM
13
+ * `interaction:` URL handling).
14
+ * - `@interop/wallet-core/display` -- pure VC derivation / display helpers and
15
+ * credential input parsing (raw values out; formatting stays in the UI).
10
16
  *
11
- * This root re-exports both for convenience.
17
+ * This root re-exports `sync` and `space` for convenience. `request` and
18
+ * `display` are deliberately NOT re-exported here, so plaintext consumers of
19
+ * the root never pull the signing / document-loader dependency graph (the
20
+ * was-client subpath-isolation pattern).
12
21
  */
13
22
  export * from './sync/index.js';
14
23
  export * from './space/index.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;GAQG;AACH,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;GAiBG;AACH,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA"}
package/dist/index.js CHANGED
@@ -3,12 +3,21 @@
3
3
  */
4
4
  /**
5
5
  * `@interop/wallet-core` -- shared wallet-domain logic for Interop wallet apps.
6
- * The two subpaths are canonical and can be imported directly:
6
+ * The subpaths are canonical and can be imported directly:
7
7
  *
8
8
  * - `@interop/wallet-core/sync` -- the WAS replication engine core.
9
9
  * - `@interop/wallet-core/space` -- the wallet Space layout contract.
10
+ * - `@interop/wallet-core/request` -- wallet-request / exchange protocol
11
+ * handling (classification and parsing, QueryByExample matching, cryptosuite
12
+ * negotiation, VP composition, the VC-API exchange client, and VCALM
13
+ * `interaction:` URL handling).
14
+ * - `@interop/wallet-core/display` -- pure VC derivation / display helpers and
15
+ * credential input parsing (raw values out; formatting stays in the UI).
10
16
  *
11
- * This root re-exports both for convenience.
17
+ * This root re-exports `sync` and `space` for convenience. `request` and
18
+ * `display` are deliberately NOT re-exported here, so plaintext consumers of
19
+ * the root never pull the signing / document-loader dependency graph (the
20
+ * was-client subpath-isolation pattern).
12
21
  */
13
22
  export * from './sync/index.js';
14
23
  export * from './space/index.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;GAQG;AACH,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;GAiBG;AACH,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA"}
@@ -0,0 +1,112 @@
1
+ /*!
2
+ * Copyright (c) 2026 Interop Alliance. All rights reserved.
3
+ */
4
+ /**
5
+ * Classification of incoming VC API messages: turns a raw CHAPI event (or a QR
6
+ * / pasted payload) into a typed `IVPRequest` / `IVPOffer`, and provides the
7
+ * helpers used to dispatch on what was actually asked for (VC sharing, DID
8
+ * Authentication, capability delegation, or a combination).
9
+ *
10
+ * Ported from Freewallet's `src/lib/walletRequest/classify.ts` (the superset of
11
+ * DCW's `app/lib/exchanges.ts` / `walletRequestApi.ts` dispatch helpers). The
12
+ * App Connect query kind is a Freewallet-only extension and stays app-side; the
13
+ * shared classifier covers the three VPR-spec query types.
14
+ */
15
+ import type { CHAPIStoreEvent, ICapabilityQueryDetail, ICredentialQuery, IQueryByExample, IVPOffer, IVPRequest, IVPRDetails, IVPRQuery, IVerifiableCredential, IVerifiablePresentation, WalletRequestProfile } from './types.js';
16
+ import type { CHAPIGetEvent } from './types.js';
17
+ /**
18
+ * The Verifiable Credentials carried by a presentation, normalized to an array.
19
+ *
20
+ * @param presentation {IVerifiablePresentation}
21
+ * @returns {IVerifiableCredential[]}
22
+ */
23
+ export declare function credentialsOf(presentation: IVerifiablePresentation): IVerifiableCredential[];
24
+ /**
25
+ * Wraps a CHAPI get event as an `IVPRequest`.
26
+ *
27
+ * @param event {CHAPIGetEvent}
28
+ * @returns {IVPRequest}
29
+ */
30
+ export declare function classifyCHAPIGetEvent(event: CHAPIGetEvent): IVPRequest;
31
+ /**
32
+ * Wraps a CHAPI store event as an `IVPOffer`. A bare offered credential is
33
+ * wrapped in an unsigned presentation, so downstream code always sees a VP.
34
+ *
35
+ * @param event {CHAPIStoreEvent}
36
+ * @returns {IVPOffer}
37
+ */
38
+ export declare function classifyCHAPIStoreEvent(event: CHAPIStoreEvent): IVPOffer;
39
+ /**
40
+ * Returns true if the query set contains a `DIDAuthentication` query. Throws if
41
+ * more than one is present -- a single DID-Auth proof answers the request.
42
+ *
43
+ * @param options {object}
44
+ * @param options.queries {IVPRQuery[]}
45
+ * @returns {boolean}
46
+ */
47
+ export declare function isDIDAuthRequested({ queries }: {
48
+ queries: IVPRQuery[];
49
+ }): boolean;
50
+ /**
51
+ * Normalizes a VPR's `query` (which may be a single object or an array) to an
52
+ * array, dropping anything that is not a typed query object. A VPR body can
53
+ * legitimately carry no queries at all -- a CHAPI request that names a
54
+ * `protocols` exchange sends an empty body -- so callers get an empty array
55
+ * rather than an array holding `undefined`.
56
+ *
57
+ * @param request {IVPRDetails}
58
+ * @returns {IVPRQuery[]}
59
+ */
60
+ export declare function queriesOf(request: IVPRDetails): IVPRQuery[];
61
+ /**
62
+ * Normalizes a `QueryByExample`'s `credentialQuery` (a single detail object or
63
+ * an array of them) to an array.
64
+ *
65
+ * @param query {IQueryByExample}
66
+ * @returns {ICredentialQuery[]}
67
+ */
68
+ export declare function credentialQueriesOf(query: IQueryByExample): ICredentialQuery[];
69
+ /**
70
+ * Collects the requested capabilities from a query set: filters the two zcap
71
+ * query type strings (`AuthorizationCapabilityQuery` canonical, `ZcapQuery`
72
+ * legacy alias), normalizes each `capabilityQuery` (object or array) to an
73
+ * array, and flattens. A zcap query whose `capabilityQuery` is missing or not
74
+ * an object is malformed -- there is nothing to ask consent for -- so it throws
75
+ * rather than letting an `undefined` descriptor reach grant resolution;
76
+ * classification-time callers surface the throw as a malformed-request state.
77
+ *
78
+ * @param queries {IVPRQuery[]}
79
+ * @returns {ICapabilityQueryDetail[]}
80
+ */
81
+ export declare function zcapQueriesOf(queries: IVPRQuery[]): ICapabilityQueryDetail[];
82
+ /**
83
+ * Classifies a VPR body onto the independent axes the consent screen and
84
+ * response assembly work from: whether DID Authentication is requested, and
85
+ * separately the credential (`QueryByExample`) and capability
86
+ * (`AuthorizationCapabilityQuery` / `ZcapQuery`) content asked for. Any
87
+ * combination is valid, including zcap-only.
88
+ *
89
+ * @param request {IVPRDetails}
90
+ * @returns {WalletRequestProfile}
91
+ */
92
+ export declare function classifyRequest(request: IVPRDetails): WalletRequestProfile;
93
+ /**
94
+ * Whether a classified request is DID-Authentication *only*: it asks the wallet
95
+ * to prove control of its DID and nothing else (no credential queries, no
96
+ * capability requests). Derived from the profile so a popup's restore fast-path
97
+ * and its render both dispatch on the one predicate.
98
+ *
99
+ * @param profile {WalletRequestProfile}
100
+ * @returns {boolean}
101
+ */
102
+ export declare function isDidAuthOnly(profile: WalletRequestProfile): boolean;
103
+ /**
104
+ * Returns true if the wallet can satisfy the DID method a `DIDAuthentication`
105
+ * query constrains to. A wallet holding only `did:key` can satisfy a request
106
+ * that lists `key` among `acceptedMethods` or omits the constraint entirely.
107
+ *
108
+ * @param queries {IVPRQuery[]}
109
+ * @returns {boolean}
110
+ */
111
+ export declare function didAuthMethodSupported(queries: IVPRQuery[]): boolean;
112
+ //# sourceMappingURL=classify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"classify.d.ts","sourceRoot":"","sources":["../../src/request/classify.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EACV,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAEhB,eAAe,EACf,QAAQ,EACR,UAAU,EACV,WAAW,EACX,SAAS,EACT,qBAAqB,EACrB,uBAAuB,EAEvB,oBAAoB,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