@interop/wallet-core 0.51.0 → 0.52.1

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 (239) hide show
  1. package/README.md +7 -11
  2. package/dist/clientAnnex/credentialAnchoredGenesis.d.ts +2 -2
  3. package/dist/clientAnnex/credentialAnchoredGenesis.d.ts.map +1 -1
  4. package/dist/clientAnnex/credentialAnchoredGenesis.js +1 -1
  5. package/dist/clientAnnex/forget.d.ts +18 -6
  6. package/dist/clientAnnex/forget.d.ts.map +1 -1
  7. package/dist/clientAnnex/forget.js +19 -6
  8. package/dist/clientAnnex/forget.js.map +1 -1
  9. package/dist/clientAnnex/forgetLast.d.ts +33 -20
  10. package/dist/clientAnnex/forgetLast.d.ts.map +1 -1
  11. package/dist/clientAnnex/forgetLast.js +43 -17
  12. package/dist/clientAnnex/forgetLast.js.map +1 -1
  13. package/dist/clientAnnex/gc.d.ts +3 -3
  14. package/dist/clientAnnex/gc.d.ts.map +1 -1
  15. package/dist/clientAnnex/gc.js +2 -2
  16. package/dist/clientAnnex/gc.js.map +1 -1
  17. package/dist/clientAnnex/index.d.ts +5 -5
  18. package/dist/clientAnnex/index.d.ts.map +1 -1
  19. package/dist/clientAnnex/index.js +4 -4
  20. package/dist/clientAnnex/index.js.map +1 -1
  21. package/dist/clientAnnex/ladder.d.ts +19 -11
  22. package/dist/clientAnnex/ladder.d.ts.map +1 -1
  23. package/dist/clientAnnex/ladder.js +77 -14
  24. package/dist/clientAnnex/ladder.js.map +1 -1
  25. package/dist/clientAnnex/ladderAnchored.d.ts +36 -7
  26. package/dist/clientAnnex/ladderAnchored.d.ts.map +1 -1
  27. package/dist/clientAnnex/ladderAnchored.js +80 -18
  28. package/dist/clientAnnex/ladderAnchored.js.map +1 -1
  29. package/dist/clientAnnex/log.d.ts +6 -6
  30. package/dist/clientAnnex/log.d.ts.map +1 -1
  31. package/dist/clientAnnex/log.js +8 -8
  32. package/dist/clientAnnex/log.js.map +1 -1
  33. package/dist/clientAnnex/recoveryLadderAnchored.d.ts +7 -7
  34. package/dist/clientAnnex/recoveryLadderAnchored.js +9 -9
  35. package/dist/clientAnnex/recoveryLadderAnchored.js.map +1 -1
  36. package/dist/clientAnnex/selfEnroll.d.ts +6 -4
  37. package/dist/clientAnnex/selfEnroll.d.ts.map +1 -1
  38. package/dist/clientAnnex/selfEnroll.js +19 -7
  39. package/dist/clientAnnex/selfEnroll.js.map +1 -1
  40. package/dist/clients/listing.d.ts +1 -1
  41. package/dist/clients/listing.d.ts.map +1 -1
  42. package/dist/clients/listing.js +1 -1
  43. package/dist/clients/listing.js.map +1 -1
  44. package/dist/clients/revocation.d.ts +1 -1
  45. package/dist/clients/rosterPolicy.d.ts +1 -1
  46. package/dist/clients/rosterPolicy.d.ts.map +1 -1
  47. package/dist/descriptors/acquire.js +1 -1
  48. package/dist/descriptors/logSource.d.ts +1 -2
  49. package/dist/descriptors/logSource.d.ts.map +1 -1
  50. package/dist/descriptors/logSource.js +2 -2
  51. package/dist/descriptors/logSource.js.map +1 -1
  52. package/dist/enrollment/enrollment.d.ts +1 -1
  53. package/dist/enrollment/enrollment.d.ts.map +1 -1
  54. package/dist/enrollment/enrollment.js +2 -1
  55. package/dist/enrollment/enrollment.js.map +1 -1
  56. package/dist/genesis/accountGenesis.d.ts +1 -1
  57. package/dist/genesis/accountGenesis.d.ts.map +1 -1
  58. package/dist/genesis/accountGenesis.js +1 -1
  59. package/dist/index.d.ts +1 -3
  60. package/dist/index.d.ts.map +1 -1
  61. package/dist/index.js +1 -3
  62. package/dist/index.js.map +1 -1
  63. package/dist/keyring/kdf.d.ts +6 -20
  64. package/dist/keyring/kdf.d.ts.map +1 -1
  65. package/dist/keyring/kdf.js +8 -5
  66. package/dist/keyring/kdf.js.map +1 -1
  67. package/dist/keyring/unlockSpace.js +1 -1
  68. package/dist/keys/rosterLogStore.d.ts +16 -14
  69. package/dist/keys/rosterLogStore.d.ts.map +1 -1
  70. package/dist/keys/rosterLogStore.js +149 -32
  71. package/dist/keys/rosterLogStore.js.map +1 -1
  72. package/dist/keys/rosterStore.d.ts +8 -7
  73. package/dist/keys/rosterStore.d.ts.map +1 -1
  74. package/dist/keys/rosterStore.js +6 -6
  75. package/dist/keys/rosterStore.js.map +1 -1
  76. package/dist/keys/spaceEpochs.d.ts +1 -1
  77. package/dist/keys/spaceEpochs.js +1 -1
  78. package/dist/keys/userKeyRoster.d.ts +3 -3
  79. package/dist/keys/userKeyRoster.d.ts.map +1 -1
  80. package/dist/keys/userKeyRoster.js +3 -3
  81. package/dist/keys/userKeyRoster.js.map +1 -1
  82. package/dist/recovery/index.d.ts +2 -2
  83. package/dist/recovery/index.js +2 -2
  84. package/dist/recovery/recoveryDelegation.js +1 -1
  85. package/dist/recovery/recoveryDelegation.js.map +1 -1
  86. package/dist/recovery/recoveryWebvh.d.ts +4 -4
  87. package/dist/recovery/recoveryWebvh.js +5 -5
  88. package/dist/request/appKey.d.ts +9 -3
  89. package/dist/request/appKey.d.ts.map +1 -1
  90. package/dist/request/appKey.js +13 -8
  91. package/dist/request/appKey.js.map +1 -1
  92. package/dist/request/classify.d.ts.map +1 -1
  93. package/dist/request/classify.js +13 -1
  94. package/dist/request/classify.js.map +1 -1
  95. package/dist/request/ephemeralExchange.d.ts +6 -1
  96. package/dist/request/ephemeralExchange.d.ts.map +1 -1
  97. package/dist/request/ephemeralExchange.js +6 -1
  98. package/dist/request/ephemeralExchange.js.map +1 -1
  99. package/dist/request/exchangeClient.d.ts +0 -23
  100. package/dist/request/exchangeClient.d.ts.map +1 -1
  101. package/dist/request/exchangeClient.js +30 -1
  102. package/dist/request/exchangeClient.js.map +1 -1
  103. package/dist/request/index.d.ts +4 -1
  104. package/dist/request/index.d.ts.map +1 -1
  105. package/dist/request/index.js +4 -1
  106. package/dist/request/index.js.map +1 -1
  107. package/dist/request/interactionRequest.d.ts +23 -0
  108. package/dist/request/interactionRequest.d.ts.map +1 -0
  109. package/dist/request/interactionRequest.js +46 -0
  110. package/dist/request/interactionRequest.js.map +1 -0
  111. package/dist/request/interactionUrl.d.ts +3 -14
  112. package/dist/request/interactionUrl.d.ts.map +1 -1
  113. package/dist/request/interactionUrl.js +20 -1
  114. package/dist/request/interactionUrl.js.map +1 -1
  115. package/dist/resourceLog/controller.d.ts +48 -49
  116. package/dist/resourceLog/controller.d.ts.map +1 -1
  117. package/dist/resourceLog/controller.js +40 -20
  118. package/dist/resourceLog/controller.js.map +1 -1
  119. package/dist/resourceLog/errors.d.ts +12 -78
  120. package/dist/resourceLog/errors.d.ts.map +1 -1
  121. package/dist/resourceLog/errors.js +12 -79
  122. package/dist/resourceLog/errors.js.map +1 -1
  123. package/dist/resourceLog/index.d.ts +17 -22
  124. package/dist/resourceLog/index.d.ts.map +1 -1
  125. package/dist/resourceLog/index.js +16 -21
  126. package/dist/resourceLog/index.js.map +1 -1
  127. package/dist/resourceLog/license.d.ts +27 -26
  128. package/dist/resourceLog/license.d.ts.map +1 -1
  129. package/dist/resourceLog/license.js +31 -30
  130. package/dist/resourceLog/license.js.map +1 -1
  131. package/dist/unlock/index.d.ts +6 -6
  132. package/dist/unlock/index.d.ts.map +1 -1
  133. package/dist/unlock/index.js +5 -5
  134. package/dist/unlock/retire.d.ts +29 -28
  135. package/dist/unlock/retire.d.ts.map +1 -1
  136. package/dist/unlock/retire.js +25 -16
  137. package/dist/unlock/retire.js.map +1 -1
  138. package/dist/unlock/standingClient.d.ts +1 -1
  139. package/dist/unlock/standingClient.js +3 -3
  140. package/dist/unlock/standingWebvh.d.ts +28 -10
  141. package/dist/unlock/standingWebvh.d.ts.map +1 -1
  142. package/dist/unlock/standingWebvh.js +75 -37
  143. package/dist/unlock/standingWebvh.js.map +1 -1
  144. package/dist/unlock/unlockRecord.js +1 -1
  145. package/dist/webvh/delegatedLogStore.d.ts +2 -2
  146. package/dist/webvh/delegatedLogStore.js +2 -2
  147. package/dist/webvh/didWeb.js +1 -1
  148. package/dist/webvh/didWeb.js.map +1 -1
  149. package/dist/webvh/didWebvh.d.ts +3 -3
  150. package/dist/webvh/didWebvh.d.ts.map +1 -1
  151. package/dist/webvh/didWebvh.js +5 -5
  152. package/dist/webvh/didWebvh.js.map +1 -1
  153. package/dist/webvh/listClients.js +1 -1
  154. package/dist/webvh/listClients.js.map +1 -1
  155. package/dist/webvh/verifyLog.d.ts +1 -1
  156. package/dist/webvh/verifyLog.d.ts.map +1 -1
  157. package/dist/webvh/verifyLog.js +1 -2
  158. package/dist/webvh/verifyLog.js.map +1 -1
  159. package/package.json +5 -9
  160. package/dist/display/alignment.d.ts +0 -55
  161. package/dist/display/alignment.d.ts.map +0 -1
  162. package/dist/display/alignment.js +0 -117
  163. package/dist/display/alignment.js.map +0 -1
  164. package/dist/display/credentialName.d.ts +0 -42
  165. package/dist/display/credentialName.d.ts.map +0 -1
  166. package/dist/display/credentialName.js +0 -106
  167. package/dist/display/credentialName.js.map +0 -1
  168. package/dist/display/displayFields.d.ts +0 -59
  169. package/dist/display/displayFields.d.ts.map +0 -1
  170. package/dist/display/displayFields.js +0 -136
  171. package/dist/display/displayFields.js.map +0 -1
  172. package/dist/display/evidence.d.ts +0 -50
  173. package/dist/display/evidence.d.ts.map +0 -1
  174. package/dist/display/evidence.js +0 -67
  175. package/dist/display/evidence.js.map +0 -1
  176. package/dist/display/image.d.ts +0 -18
  177. package/dist/display/image.d.ts.map +0 -1
  178. package/dist/display/image.js +0 -23
  179. package/dist/display/image.js.map +0 -1
  180. package/dist/display/index.d.ts +0 -38
  181. package/dist/display/index.d.ts.map +0 -1
  182. package/dist/display/index.js +0 -32
  183. package/dist/display/index.js.map +0 -1
  184. package/dist/display/issuer.d.ts +0 -105
  185. package/dist/display/issuer.d.ts.map +0 -1
  186. package/dist/display/issuer.js +0 -126
  187. package/dist/display/issuer.js.map +0 -1
  188. package/dist/display/obv3.d.ts +0 -82
  189. package/dist/display/obv3.d.ts.map +0 -1
  190. package/dist/display/obv3.js +0 -117
  191. package/dist/display/obv3.js.map +0 -1
  192. package/dist/display/parse.d.ts +0 -66
  193. package/dist/display/parse.d.ts.map +0 -1
  194. package/dist/display/parse.js +0 -104
  195. package/dist/display/parse.js.map +0 -1
  196. package/dist/display/subject.d.ts +0 -79
  197. package/dist/display/subject.d.ts.map +0 -1
  198. package/dist/display/subject.js +0 -124
  199. package/dist/display/subject.js.map +0 -1
  200. package/dist/display/text.d.ts +0 -53
  201. package/dist/display/text.d.ts.map +0 -1
  202. package/dist/display/text.js +0 -78
  203. package/dist/display/text.js.map +0 -1
  204. package/dist/display/types.d.ts +0 -55
  205. package/dist/display/types.d.ts.map +0 -1
  206. package/dist/display/types.js +0 -41
  207. package/dist/display/types.js.map +0 -1
  208. package/dist/display/validity.d.ts +0 -51
  209. package/dist/display/validity.d.ts.map +0 -1
  210. package/dist/display/validity.js +0 -51
  211. package/dist/display/validity.js.map +0 -1
  212. package/dist/display/verificationView.d.ts +0 -115
  213. package/dist/display/verificationView.d.ts.map +0 -1
  214. package/dist/display/verificationView.js +0 -199
  215. package/dist/display/verificationView.js.map +0 -1
  216. package/dist/resourceLog/append.d.ts +0 -112
  217. package/dist/resourceLog/append.d.ts.map +0 -1
  218. package/dist/resourceLog/append.js +0 -197
  219. package/dist/resourceLog/append.js.map +0 -1
  220. package/dist/resourceLog/entry.d.ts +0 -68
  221. package/dist/resourceLog/entry.d.ts.map +0 -1
  222. package/dist/resourceLog/entry.js +0 -167
  223. package/dist/resourceLog/entry.js.map +0 -1
  224. package/dist/resourceLog/pin.d.ts +0 -82
  225. package/dist/resourceLog/pin.d.ts.map +0 -1
  226. package/dist/resourceLog/pin.js +0 -57
  227. package/dist/resourceLog/pin.js.map +0 -1
  228. package/dist/resourceLog/seal.d.ts +0 -97
  229. package/dist/resourceLog/seal.d.ts.map +0 -1
  230. package/dist/resourceLog/seal.js +0 -113
  231. package/dist/resourceLog/seal.js.map +0 -1
  232. package/dist/resourceLog/verify.d.ts +0 -96
  233. package/dist/resourceLog/verify.d.ts.map +0 -1
  234. package/dist/resourceLog/verify.js +0 -474
  235. package/dist/resourceLog/verify.js.map +0 -1
  236. package/dist/resourceLog/vmFragment.d.ts +0 -33
  237. package/dist/resourceLog/vmFragment.d.ts.map +0 -1
  238. package/dist/resourceLog/vmFragment.js +0 -39
  239. package/dist/resourceLog/vmFragment.js.map +0 -1
@@ -1,117 +0,0 @@
1
- import { asRecord, getTrimmedString, recordList } from './text.js';
2
- /**
3
- * The recipient display name carried in an OBv3 `identifier` entry: the
4
- * `identityHash` of the first identifier that has one and is not marked
5
- * `hashed: true`. Returns `undefined` when no such identifier is present.
6
- *
7
- * Note: unlike the name-guarded path in `extractIssuedTo`, this returns the
8
- * hash of ANY identifier (regardless of `identityType`), matching DCW's
9
- * historical behavior. Callers wanting only name-typed identifiers use
10
- * `extractIssuedTo`.
11
- *
12
- * Non-object entries in the `identifier` array (a `null`, a bare string) are
13
- * skipped rather than dereferenced.
14
- *
15
- * @param credentialSubject {IOpenBadgeSubject | ICredentialSubject}
16
- * @returns {string | undefined}
17
- */
18
- export function extractNameFromOBV3Identifier(credentialSubject) {
19
- if (!credentialSubject?.identifier) {
20
- return undefined;
21
- }
22
- const identifiers = recordList(credentialSubject.identifier);
23
- const identifierWithHash = identifiers.find(identifier => identifier.identityHash &&
24
- (identifier.hashed === false || identifier.hashed === undefined));
25
- return getTrimmedString(identifierWithHash?.identityHash) || undefined;
26
- }
27
- /**
28
- * Normalizes a subject's `achievement` field to an array of records (a single
29
- * achievement object is wrapped; a missing one yields `[]`). Non-object entries
30
- * are dropped, so callers can read each achievement's fields directly.
31
- *
32
- * @param subject {Record<string, unknown>}
33
- * @returns {Record<string, unknown>[]}
34
- */
35
- export function achievementsList(subject) {
36
- return recordList(subject?.achievement);
37
- }
38
- /**
39
- * Normalizes a subject's `skill` field to an array of records (a single skill
40
- * object is wrapped; a missing one yields `[]`). Non-object entries are
41
- * dropped, so callers can read each skill's fields directly.
42
- *
43
- * @param subject {Record<string, unknown>}
44
- * @returns {Record<string, unknown>[]}
45
- */
46
- export function skillsList(subject) {
47
- return recordList(subject?.skill);
48
- }
49
- /**
50
- * The image URL of the first skill in a list: an object image's `id`, or a
51
- * string image, else `''`.
52
- *
53
- * @param skills {Record<string, unknown>[]}
54
- * @returns {string}
55
- */
56
- export function getSkillImage(skills) {
57
- const first = skills[0];
58
- if (!first) {
59
- return '';
60
- }
61
- const image = asRecord(first.image);
62
- if (image) {
63
- return getTrimmedString(image.id);
64
- }
65
- return getTrimmedString(first.image);
66
- }
67
- const IMAGE_EXTENSION_RE = /\.(jpe?g|png|gif|webp|svg|avif)(\?|$)/i;
68
- /**
69
- * The `id` (URL) of the first evidence item that looks like an image -- either
70
- * its `id` or `name` ends in a known image extension -- else `''`.
71
- *
72
- * @param evidence {unknown[]}
73
- * @returns {string}
74
- */
75
- export function getEvidenceImage(evidence) {
76
- for (const ev of evidence) {
77
- const item = asRecord(ev);
78
- if (!item) {
79
- continue;
80
- }
81
- const id = getTrimmedString(item.id);
82
- const name = getTrimmedString(item.name);
83
- if (id && (IMAGE_EXTENSION_RE.test(id) || IMAGE_EXTENSION_RE.test(name))) {
84
- return id;
85
- }
86
- }
87
- return '';
88
- }
89
- /**
90
- * The achievement's image URL: a string image directly, or an object image's
91
- * `id`, else `''`.
92
- *
93
- * @param primaryAchievement {IAchievement | undefined}
94
- * @returns {string}
95
- */
96
- export function getAchievementImage(primaryAchievement) {
97
- if (!primaryAchievement?.image) {
98
- return '';
99
- }
100
- if (typeof primaryAchievement.image === 'string') {
101
- return primaryAchievement.image;
102
- }
103
- return primaryAchievement.image.id ?? '';
104
- }
105
- /**
106
- * The achievement's `achievementType` when it is a string, else `''`.
107
- *
108
- * @param primaryAchievement {IAchievement | undefined}
109
- * @returns {string}
110
- */
111
- export function getAchievementType(primaryAchievement) {
112
- if (typeof primaryAchievement?.achievementType === 'string') {
113
- return primaryAchievement.achievementType;
114
- }
115
- return '';
116
- }
117
- //# sourceMappingURL=obv3.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"obv3.js","sour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 Interop Alliance. All rights reserved.
3
- */
4
- /**
5
- * Credential input parsing: turning decoded JSON (or a raw user / QR string)
6
- * into an array of Verifiable Credentials. File reading and network transport
7
- * stay app-side -- `resolveCredentialsInput` takes an injected `fetchUrl` so the
8
- * library never imports an HTTP client (DCW passes its `fetchWithTimeout`,
9
- * Freewallet its CORS-proxy `fetchFromURL`).
10
- *
11
- * Drift resolution: `credentialsFromJSON` (Freewallet) and
12
- * `extractCredentialsFrom` (DCW) both survive -- the former accepts an array /
13
- * a bare VC / a VP wrapper from a JSON string, the latter routes an
14
- * already-decoded object. Both now share the data-integrity-core shape guards
15
- * instead of open-coding the `type` checks. Freewallet's
16
- * `ResolveCredentialsInputError` code taxonomy is kept; DCW's
17
- * `VPQR_UNSUPPORTED_MESSAGE` constant is exported for apps that surface it.
18
- */
19
- import type { IVerifiableCredential, IVerifiablePresentation } from '@interop/data-integrity-core';
20
- /**
21
- * Message DCW surfaced for the (now unsupported) VPQR `VP1-` input.
22
- */
23
- export declare const VPQR_UNSUPPORTED_MESSAGE = "VPQR encoded credentials are not supported.";
24
- /**
25
- * Coded failure of {@link resolveCredentialsInput}.
26
- */
27
- export declare class ResolveCredentialsInputError extends Error {
28
- readonly code: 'empty' | 'invalid_input' | 'none_found' | 'vpqr_unsupported';
29
- constructor(code: 'empty' | 'invalid_input' | 'none_found' | 'vpqr_unsupported');
30
- }
31
- /**
32
- * Decodes one or more Verifiable Credentials from a JSON string: an array of
33
- * VCs (non-credential entries filtered out), a Verifiable Presentation wrapping
34
- * one or many credentials, or a single VC object. Throws when nothing decodes.
35
- *
36
- * @param text {string}
37
- * @returns {IVerifiableCredential[]}
38
- */
39
- export declare function credentialsFromJSON(text: string): IVerifiableCredential[];
40
- /**
41
- * Extracts the VCs from an already-decoded object: a bare VC becomes a
42
- * single-element array, a VP yields its `verifiableCredential` (VC-vs-VP
43
- * detection runs the VC check first), anything else yields `null`.
44
- *
45
- * @param obj {IVerifiableCredential | IVerifiablePresentation}
46
- * @returns {IVerifiableCredential[] | null}
47
- */
48
- export declare function extractCredentialsFrom(obj: IVerifiableCredential | IVerifiablePresentation): IVerifiableCredential[] | null;
49
- /**
50
- * Normalizes raw user / QR input into an array of VCs. A URL (http/https) is
51
- * fetched via the injected `fetchUrl` and its body parsed; raw JSON / JSON-LD
52
- * (`{` or `[`) is parsed directly; a `VP1-` (VPQR) prefix is detected but not
53
- * supported. Throws a coded {@link ResolveCredentialsInputError} on each
54
- * failure path.
55
- *
56
- * @param options {object}
57
- * @param options.raw {string} the raw input text
58
- * @param options.fetchUrl {(url: string) => Promise<string>} fetches a URL's
59
- * body text (app-provided transport)
60
- * @returns {Promise<IVerifiableCredential[]>}
61
- */
62
- export declare function resolveCredentialsInput({ raw, fetchUrl }: {
63
- raw: string;
64
- fetchUrl: (url: string) => Promise<string>;
65
- }): Promise<IVerifiableCredential[]>;
66
- //# sourceMappingURL=parse.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/display/parse.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EACV,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,8BAA8B,CAAA;AAMrC;;GAEG;AACH,eAAO,MAAM,wBAAwB,gDACU,CAAA;AAE/C;;GAEG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe,GAAG,YAAY,GAAG,kBAAkB,CAAA;gBAE1E,IAAI,EAAE,OAAO,GAAG,eAAe,GAAG,YAAY,GAAG,kBAAkB;CAMtE;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,qBAAqB,EAAE,CA0BzE;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,qBAAqB,GAAG,uBAAuB,GACnD,qBAAqB,EAAE,GAAG,IAAI,CAYhC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,uBAAuB,CAAC,EAC5C,GAAG,EACH,QAAQ,EACT,EAAE;IACD,GAAG,EAAE,MAAM,CAAA;IACX,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;CAC3C,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAwBnC"}
@@ -1,104 +0,0 @@
1
- import { isVerifiableCredential, isVerifiablePresentation } from '@interop/data-integrity-core/guards';
2
- /**
3
- * Message DCW surfaced for the (now unsupported) VPQR `VP1-` input.
4
- */
5
- export const VPQR_UNSUPPORTED_MESSAGE = 'VPQR encoded credentials are not supported.';
6
- /**
7
- * Coded failure of {@link resolveCredentialsInput}.
8
- */
9
- export class ResolveCredentialsInputError extends Error {
10
- code;
11
- constructor(code) {
12
- super(code);
13
- this.name = 'ResolveCredentialsInputError';
14
- this.code = code;
15
- }
16
- }
17
- /**
18
- * Decodes one or more Verifiable Credentials from a JSON string: an array of
19
- * VCs (non-credential entries filtered out), a Verifiable Presentation wrapping
20
- * one or many credentials, or a single VC object. Throws when nothing decodes.
21
- *
22
- * @param text {string}
23
- * @returns {IVerifiableCredential[]}
24
- */
25
- export function credentialsFromJSON(text) {
26
- const data = JSON.parse(text);
27
- if (Array.isArray(data)) {
28
- const vcs = data.filter(item => isVerifiableCredential(item));
29
- if (vcs.length > 0) {
30
- return vcs;
31
- }
32
- throw new Error('Array did not contain any Verifiable Credentials.');
33
- }
34
- if (isVerifiablePresentation(data) &&
35
- data &&
36
- typeof data === 'object' &&
37
- 'verifiableCredential' in data) {
38
- const wrapped = data.verifiableCredential;
39
- return Array.isArray(wrapped) ? wrapped : [wrapped];
40
- }
41
- if (isVerifiableCredential(data)) {
42
- return [data];
43
- }
44
- throw new Error('Could not decode Verifiable Credential(s) from the JSON.');
45
- }
46
- /**
47
- * Extracts the VCs from an already-decoded object: a bare VC becomes a
48
- * single-element array, a VP yields its `verifiableCredential` (VC-vs-VP
49
- * detection runs the VC check first), anything else yields `null`.
50
- *
51
- * @param obj {IVerifiableCredential | IVerifiablePresentation}
52
- * @returns {IVerifiableCredential[] | null}
53
- */
54
- export function extractCredentialsFrom(obj) {
55
- if (isVerifiableCredential(obj)) {
56
- return [obj];
57
- }
58
- if (isVerifiablePresentation(obj) && 'verifiableCredential' in obj) {
59
- const verifiableCredential = obj.verifiableCredential;
60
- if (Array.isArray(verifiableCredential)) {
61
- return verifiableCredential;
62
- }
63
- return [verifiableCredential];
64
- }
65
- return null;
66
- }
67
- /**
68
- * Normalizes raw user / QR input into an array of VCs. A URL (http/https) is
69
- * fetched via the injected `fetchUrl` and its body parsed; raw JSON / JSON-LD
70
- * (`{` or `[`) is parsed directly; a `VP1-` (VPQR) prefix is detected but not
71
- * supported. Throws a coded {@link ResolveCredentialsInputError} on each
72
- * failure path.
73
- *
74
- * @param options {object}
75
- * @param options.raw {string} the raw input text
76
- * @param options.fetchUrl {(url: string) => Promise<string>} fetches a URL's
77
- * body text (app-provided transport)
78
- * @returns {Promise<IVerifiableCredential[]>}
79
- */
80
- export async function resolveCredentialsInput({ raw, fetchUrl }) {
81
- const trimmed = raw.trimStart();
82
- if (!trimmed) {
83
- throw new ResolveCredentialsInputError('empty');
84
- }
85
- let credentials;
86
- if (trimmed.startsWith('http://') || trimmed.startsWith('https://')) {
87
- const jsonText = await fetchUrl(trimmed.trim());
88
- credentials = credentialsFromJSON(jsonText);
89
- }
90
- else if (trimmed.startsWith('{') || trimmed.startsWith('[')) {
91
- credentials = credentialsFromJSON(trimmed);
92
- }
93
- else if (trimmed.startsWith('VP1-')) {
94
- throw new ResolveCredentialsInputError('vpqr_unsupported');
95
- }
96
- else {
97
- throw new ResolveCredentialsInputError('invalid_input');
98
- }
99
- if (credentials.length === 0) {
100
- throw new ResolveCredentialsInputError('none_found');
101
- }
102
- return credentials;
103
- }
104
- //# sourceMappingURL=parse.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse.js","sourceRo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CAAC;SAAM,IAAI,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,4BAA4B,CAAC,kBAAkB,CAAC,CAAA;IAC5D,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,4BAA4B,CAAC,eAAe,CAAC,CAAA;IACzD,CAAC;IAED,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,4BAA4B,CAAC,YAAY,CAAC,CAAA;IACtD,CAAC;IAED,OAAO,WAAW,CAAA;AACpB,CAAC"}
@@ -1,79 +0,0 @@
1
- /*!
2
- * Copyright (c) 2026 Interop Alliance. All rights reserved.
3
- */
4
- /**
5
- * Credential-subject readers: pulling the (first) subject out of a VC, deriving
6
- * the recipient display name, and projecting the OBv3-flavored subject render
7
- * fields.
8
- *
9
- * Drift resolution:
10
- * - `getSubject` was identical in both apps -- take either.
11
- * - Recipient-name resolution DIVERGED. Freewallet's `extractIssuedTo` +
12
- * `resolvePersonFullName` win as the vc-level recipient resolver: they walk a
13
- * deeper person/contact structure (`person.contact.fullName`, string
14
- * `person.name`, `person.name.formattedName` / `.name`, `subject.name`) and
15
- * guard the OBv3 identifier on `identityType === 'name'` (more correct than
16
- * DCW's "any identityHash").
17
- * - `credentialSubjectRenderInfo` keeps DCW's subject-level shape and field set
18
- * (used by the OBv3 card renderer) but returns RAW `startDate` / `endDate`
19
- * ISO strings instead of moment-formatted `startDateFmt` / `endDateFmt` (the
20
- * raw-values seam); each app re-applies its own date formatting.
21
- */
22
- import type { IAlignment, ICredentialSubject, IVerifiableCredential } from '@interop/data-integrity-core';
23
- /**
24
- * The subject render fields for the credential detail / card view. All dates
25
- * are RAW ISO strings; the app formats them.
26
- */
27
- export interface SubjectRenderInfo {
28
- subjectName: string | null;
29
- issuedTo: string | null;
30
- degreeName: string | null;
31
- description: string | null;
32
- criteria: string | null;
33
- numberOfCredits: string | null;
34
- startDate: string | null;
35
- endDate: string | null;
36
- achievementImage: string | null;
37
- achievementType: string | null;
38
- alignment: IAlignment[] | undefined;
39
- }
40
- /**
41
- * The (first) credential subject. Partially supports VCs with multiple
42
- * `credentialSubject` entries by picking the first one.
43
- *
44
- * @param vc {IVerifiableCredential}
45
- * @returns {ICredentialSubject}
46
- */
47
- export declare function getSubject(vc: IVerifiableCredential): ICredentialSubject;
48
- /**
49
- * Resolves a display name from a subject's person / contact structure, in
50
- * order: `person.contact.fullName`, a string `person.name`, an object
51
- * `person.name.formattedName`, `person.name.name`, then `subject.name`.
52
- * Returns `''` when none is present.
53
- *
54
- * @param subject {Record<string, unknown>}
55
- * @returns {string}
56
- */
57
- export declare function resolvePersonFullName(subject: Record<string, unknown>): string;
58
- /**
59
- * The recipient name a credential was issued to: the resolved person full name,
60
- * else a name-typed OBv3 `identifier` hash, else the top-level credential
61
- * `name`. Returns `''` when nothing resolves.
62
- *
63
- * @param verifiableCredential {IVerifiableCredential}
64
- * @returns {string}
65
- */
66
- export declare function extractIssuedTo(verifiableCredential: IVerifiableCredential): string;
67
- /**
68
- * Projects a credential subject to the render fields used by the OBv3 card /
69
- * detail view. Dates are RAW ISO strings (see {@link SubjectRenderInfo}).
70
- *
71
- * Every field is read through a shape guard: a missing, primitive, or
72
- * array-shaped subject (and a `degree` / `achievement` of any shape) renders
73
- * the all-null fallback instead of throwing.
74
- *
75
- * @param credentialSubject {ICredentialSubject}
76
- * @returns {SubjectRenderInfo}
77
- */
78
- export declare function credentialSubjectRenderInfo(credentialSubject: ICredentialSubject): SubjectRenderInfo;
79
- //# sourceMappingURL=subject.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"subject.d.ts","sourceRoot":"","sources":["../../src/display/subject.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAEV,UAAU,EACV,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,8BAA8B,CAAA;AAKrC;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,SAAS,EAAE,UAAU,EAAE,GAAG,SAAS,CAAA;CACpC;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,qBAAqB,GAAG,kBAAkB,CAMxE;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,MAAM,CA4BR;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,oBAAoB,EAAE,qBAAqB,GAC1C,MAAM,CAyBR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CACzC,iBAAiB,EAAE,kBAAkB,GACpC,iBAAiB,CA+CnB"}
@@ -1,124 +0,0 @@
1
- import { extractNameFromOBV3Identifier } from './obv3.js';
2
- import { imageSourceFrom } from './image.js';
3
- import { asRecord, getTrimmedString, recordList } from './text.js';
4
- /**
5
- * The (first) credential subject. Partially supports VCs with multiple
6
- * `credentialSubject` entries by picking the first one.
7
- *
8
- * @param vc {IVerifiableCredential}
9
- * @returns {ICredentialSubject}
10
- */
11
- export function getSubject(vc) {
12
- const { credentialSubject } = vc;
13
- if (Array.isArray(credentialSubject)) {
14
- return credentialSubject[0];
15
- }
16
- return credentialSubject;
17
- }
18
- /**
19
- * Resolves a display name from a subject's person / contact structure, in
20
- * order: `person.contact.fullName`, a string `person.name`, an object
21
- * `person.name.formattedName`, `person.name.name`, then `subject.name`.
22
- * Returns `''` when none is present.
23
- *
24
- * @param subject {Record<string, unknown>}
25
- * @returns {string}
26
- */
27
- export function resolvePersonFullName(subject) {
28
- const person = asRecord(subject.person);
29
- const contact = asRecord(person?.contact);
30
- const contactFullName = getTrimmedString(contact?.fullName);
31
- if (contactFullName) {
32
- return contactFullName;
33
- }
34
- const personName = getTrimmedString(person?.name);
35
- if (personName) {
36
- return personName;
37
- }
38
- const personNameRecord = asRecord(person?.name);
39
- if (personNameRecord) {
40
- const formattedName = getTrimmedString(personNameRecord.formattedName);
41
- if (formattedName) {
42
- return formattedName;
43
- }
44
- const fallbackPersonName = getTrimmedString(personNameRecord.name);
45
- if (fallbackPersonName) {
46
- return fallbackPersonName;
47
- }
48
- }
49
- return getTrimmedString(subject.name);
50
- }
51
- /**
52
- * The recipient name a credential was issued to: the resolved person full name,
53
- * else a name-typed OBv3 `identifier` hash, else the top-level credential
54
- * `name`. Returns `''` when nothing resolves.
55
- *
56
- * @param verifiableCredential {IVerifiableCredential}
57
- * @returns {string}
58
- */
59
- export function extractIssuedTo(verifiableCredential) {
60
- const subject = asRecord(getSubject(verifiableCredential));
61
- if (!subject) {
62
- return getTrimmedString(verifiableCredential.name);
63
- }
64
- const resolvedName = resolvePersonFullName(subject);
65
- if (resolvedName) {
66
- return resolvedName;
67
- }
68
- if (Array.isArray(subject.identifier)) {
69
- const nameEntry = subject.identifier.find((identifier) => identifier?.identityType === 'name' || identifier?.type === 'name');
70
- if (nameEntry?.identityHash) {
71
- return nameEntry.identityHash;
72
- }
73
- }
74
- return getTrimmedString(verifiableCredential.name);
75
- }
76
- /**
77
- * Projects a credential subject to the render fields used by the OBv3 card /
78
- * detail view. Dates are RAW ISO strings (see {@link SubjectRenderInfo}).
79
- *
80
- * Every field is read through a shape guard: a missing, primitive, or
81
- * array-shaped subject (and a `degree` / `achievement` of any shape) renders
82
- * the all-null fallback instead of throwing.
83
- *
84
- * @param credentialSubject {ICredentialSubject}
85
- * @returns {SubjectRenderInfo}
86
- */
87
- export function credentialSubjectRenderInfo(credentialSubject) {
88
- const subject = (asRecord(credentialSubject) ?? {});
89
- // SkillClaimCredential: person.name is the subject name.
90
- const personName = subject?.person?.name;
91
- const personNameStr = typeof personName === 'string' && personName.trim()
92
- ? personName.trim()
93
- : null;
94
- const identityHashName = extractNameFromOBV3Identifier(subject) ?? null;
95
- // Used in non-OBv3 components.
96
- const subjectName = personNameStr ?? subject?.name ?? identityHashName ?? null;
97
- // Used in OBv3 components -- prioritize the identityHash over subject.name.
98
- const issuedTo = personNameStr ?? identityHashName ?? subject?.name ?? null;
99
- const degreeName = asRecord(subject.degree)?.name ?? null;
100
- const [achievement] = recordList(subject.achievement);
101
- const description = achievement?.description ?? null;
102
- const criteria = achievement?.criteria?.narrative ?? null;
103
- const numberOfCredits = achievement?.awardedOnCompletionOf?.numberOfCredits?.value ?? null;
104
- const achievementImage = imageSourceFrom(achievement?.image);
105
- const achievementType = achievement?.achievementType
106
- ? achievement.achievementType
107
- : null;
108
- const alignment = achievement?.alignment;
109
- const { startDate = null, endDate = null } = achievement?.awardedOnCompletionOf || {};
110
- return {
111
- subjectName,
112
- issuedTo,
113
- degreeName,
114
- description,
115
- criteria,
116
- numberOfCredits,
117
- startDate,
118
- endDate,
119
- achievementImage,
120
- achievementType,
121
- alignment
122
- };
123
- }
124
- //# sourceMappingURL=subject.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"subject.js","sourceRoot":"","sources":["../../src/display/subject.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAoBlE;;;;;;GAMG;AACH,MAAM,UAAU,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AAI,IAAI,CAAA;IAC9E,4EAA4E;IAC5E,MAAM,QAAQ,GAAG,aAAa,IAAI,gBAAgB,IAAI,OAAO,EAAE,IAAI,IAAI,IAAI,CAAA;IAC3E,MAAM,UAAU,GACb,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,IAA2B,IAAI,IAAI,CAAA;IAEhE,MAAM,CAAC,WAAW,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC,WAAW,CAEnD,CAAA;IAED,MAAM,WAAW,GAAG,WAAW,EAAE,WAAW,IAAI,IAAI,CAAA;IACpD,MAAM,QAAQ,GAAG,WAAW,EAAE,QAAQ,EAAE,SAAS,IAAI,IAAI,CAAA;IACzD,MAAM,eAAe,GACnB,WAAW,EAAE,qBAAqB,EAAE,eAAe,EAAE,KAAK,IAAI,IAAI,CAAA;IACpE,MAAM,gBAAgB,GAAG,eAAe,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;IAC5D,MAAM,eAAe,GAAG,WAAW,EAAE,eAAe;QAClD,CAAC,CAAC,WAAW,CAAC,eAAe;QAC7B,CAAC,CAAC,IAAI,CAAA;IACR,MAAM,SAAS,GAAG,WAAW,EAAE,SAAS,CAAA;IACxC,MAAM,EAAE,SAAS,GAAG,IAAI,EAAE,OAAO,GAAG,IAAI,EAAE,GACxC,WAAW,EAAE,qBAAqB,IAAI,EAAE,CAAA;IAE1C,OAAO;QACL,WAAW;QACX,QAAQ;QACR,UAAU;QACV,WAAW;QACX,QAAQ;QACR,eAAe;QACf,SAAS;QACT,OAAO;QACP,gBAAgB;QAChB,eAAe;QACf,SAAS;KACV,CAAA;AACH,CAAC"}
@@ -1,53 +0,0 @@
1
- /*!
2
- * Copyright (c) 2026 Interop Alliance. All rights reserved.
3
- */
4
- /**
5
- * Small string / record coercion helpers shared by the display derivation
6
- * functions. These read the loosely-typed fields of a decoded Verifiable
7
- * Credential without importing any UI or formatting library.
8
- *
9
- * Drift resolution: two apps had two slightly different "coerce to a usable
10
- * string" helpers. DCW's `asNonEmptyString` (stringifies any value, trims,
11
- * returns `null` when empty) and Freewallet's `getTrimmedString` (only accepts
12
- * an actual string, returns `''` when not). Both are kept verbatim because
13
- * their callers depend on the different empty conventions (`null` vs `''`).
14
- * `asRecord` is Freewallet's object narrower.
15
- */
16
- /**
17
- * Coerces an arbitrary value to a trimmed, non-empty string, or `null`. Any
18
- * non-string value is stringified first (so a number `3` becomes `'3'`).
19
- * `null` / `undefined` and whitespace-only values yield `null`.
20
- *
21
- * @param value {unknown}
22
- * @returns {string | null}
23
- */
24
- export declare function asNonEmptyString(value: unknown): string | null;
25
- /**
26
- * Returns the trimmed value when it is a string, else the empty string. Unlike
27
- * {@link asNonEmptyString} this never stringifies a non-string value.
28
- *
29
- * @param value {unknown}
30
- * @returns {string}
31
- */
32
- export declare function getTrimmedString(value: unknown): string;
33
- /**
34
- * Narrows an arbitrary value to a plain record (`Record<string, unknown>`), or
35
- * `undefined` when it is null / a primitive / an array is acceptable here since
36
- * arrays are objects too and callers pass only object-shaped subjects.
37
- *
38
- * @param value {unknown}
39
- * @returns {Record<string, unknown> | undefined}
40
- */
41
- export declare function asRecord(value: unknown): Record<string, unknown> | undefined;
42
- /**
43
- * Normalizes a loosely-typed JSON-LD field to an array of plain records: a
44
- * single object is wrapped, an array is filtered down to its object entries
45
- * (dropping `null`s and primitives), and anything else yields `[]`. Lets the
46
- * display derivations iterate attacker-supplied credential fields without
47
- * dereferencing a non-object.
48
- *
49
- * @param value {unknown}
50
- * @returns {Record<string, unknown>[]}
51
- */
52
- export declare function recordList(value: unknown): Record<string, unknown>[];
53
- //# sourceMappingURL=text.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/display/text.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;GAWG;AAEH;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAU9D;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAKvD;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAK5E;AAED;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAKpE"}
@@ -1,78 +0,0 @@
1
- /*!
2
- * Copyright (c) 2026 Interop Alliance. All rights reserved.
3
- */
4
- /**
5
- * Small string / record coercion helpers shared by the display derivation
6
- * functions. These read the loosely-typed fields of a decoded Verifiable
7
- * Credential without importing any UI or formatting library.
8
- *
9
- * Drift resolution: two apps had two slightly different "coerce to a usable
10
- * string" helpers. DCW's `asNonEmptyString` (stringifies any value, trims,
11
- * returns `null` when empty) and Freewallet's `getTrimmedString` (only accepts
12
- * an actual string, returns `''` when not). Both are kept verbatim because
13
- * their callers depend on the different empty conventions (`null` vs `''`).
14
- * `asRecord` is Freewallet's object narrower.
15
- */
16
- /**
17
- * Coerces an arbitrary value to a trimmed, non-empty string, or `null`. Any
18
- * non-string value is stringified first (so a number `3` becomes `'3'`).
19
- * `null` / `undefined` and whitespace-only values yield `null`.
20
- *
21
- * @param value {unknown}
22
- * @returns {string | null}
23
- */
24
- export function asNonEmptyString(value) {
25
- if (value === null || value === undefined) {
26
- return null;
27
- }
28
- if (typeof value === 'string') {
29
- const trimmed = value.trim();
30
- return trimmed.length ? trimmed : null;
31
- }
32
- const trimmed = `${value}`.trim();
33
- return trimmed.length ? trimmed : null;
34
- }
35
- /**
36
- * Returns the trimmed value when it is a string, else the empty string. Unlike
37
- * {@link asNonEmptyString} this never stringifies a non-string value.
38
- *
39
- * @param value {unknown}
40
- * @returns {string}
41
- */
42
- export function getTrimmedString(value) {
43
- if (typeof value !== 'string') {
44
- return '';
45
- }
46
- return value.trim();
47
- }
48
- /**
49
- * Narrows an arbitrary value to a plain record (`Record<string, unknown>`), or
50
- * `undefined` when it is null / a primitive / an array is acceptable here since
51
- * arrays are objects too and callers pass only object-shaped subjects.
52
- *
53
- * @param value {unknown}
54
- * @returns {Record<string, unknown> | undefined}
55
- */
56
- export function asRecord(value) {
57
- if (!value || typeof value !== 'object') {
58
- return undefined;
59
- }
60
- return value;
61
- }
62
- /**
63
- * Normalizes a loosely-typed JSON-LD field to an array of plain records: a
64
- * single object is wrapped, an array is filtered down to its object entries
65
- * (dropping `null`s and primitives), and anything else yields `[]`. Lets the
66
- * display derivations iterate attacker-supplied credential fields without
67
- * dereferencing a non-object.
68
- *
69
- * @param value {unknown}
70
- * @returns {Record<string, unknown>[]}
71
- */
72
- export function recordList(value) {
73
- const entries = Array.isArray(value) ? value : [value];
74
- return entries
75
- .map(entry => asRecord(entry))
76
- .filter((entry) => entry !== undefined);
77
- }
78
- //# sourceMappingURL=text.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/display/text.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH;;;;;;;;;;;GAWG;AAEH;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAA;IACb,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;QAC5B,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA;IACxC,CAAC;IACD,MAAM,OAAO,GAAG,GAAG,KAAK,EAAE,CAAC,IAAI,EAAE,CAAA;IACjC,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA;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