@learncard/render-method-plugin 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +198 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/plugin.d.ts +35 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/read.d.ts +75 -0
- package/dist/read.d.ts.map +1 -0
- package/dist/render-method-plugin.cjs.development.js +32626 -0
- package/dist/render-method-plugin.cjs.development.js.map +7 -0
- package/dist/render-method-plugin.cjs.production.min.js +46 -0
- package/dist/render-method-plugin.cjs.production.min.js.map +7 -0
- package/dist/render-method-plugin.esm.js +32620 -0
- package/dist/render-method-plugin.esm.js.map +7 -0
- package/dist/types.d.ts +102 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Learning Economy Foundation <sdk@learningeconomy.io>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# @learncard/render-method-plugin
|
|
2
|
+
|
|
3
|
+
Attach W3C `renderMethod` entries to Verifiable Credentials using SVG Mustache templates.
|
|
4
|
+
|
|
5
|
+
The plugin is stateless and has no required dependent methods or control planes.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
This plugin is part of the LearnCard monorepo and is built with the workspace. It is registered automatically as part of the default LearnCard wallet stack (see `packages/learn-card-base/src/helpers/walletHelpers.ts`).
|
|
10
|
+
|
|
11
|
+
To add it manually to a custom LearnCard instance:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { getRenderMethodPlugin } from '@learncard/render-method-plugin';
|
|
15
|
+
|
|
16
|
+
const lc = await baseLc.addPlugin(getRenderMethodPlugin(baseLc));
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## API
|
|
20
|
+
|
|
21
|
+
### Write side
|
|
22
|
+
|
|
23
|
+
| Method | Signature | Description |
|
|
24
|
+
|---|---|---|
|
|
25
|
+
| `attachRenderMethod` | `(vc, config?) => UnsignedVC` | Attaches a `TemplateRenderMethod` to the VC and injects the JSON-LD context. **Opt-in:** returns the VC unchanged when `config` is omitted. Merges with existing `renderMethod` entries. |
|
|
26
|
+
| `buildTemplateRenderMethod` | `(config) => TemplateRenderMethod` | Builds a `TemplateRenderMethod` descriptor without mutating a VC. |
|
|
27
|
+
|
|
28
|
+
### Read side
|
|
29
|
+
|
|
30
|
+
Layered API — pick the level that fits your need:
|
|
31
|
+
|
|
32
|
+
| Method | Signature | When to use |
|
|
33
|
+
|---|---|---|
|
|
34
|
+
| `findTemplateRenderMethod` | `(vc, suite \| suites[]) => TemplateRenderMethod \| null` | **Most common.** Filter by `renderSuite` string. Pass an array for capability negotiation. |
|
|
35
|
+
| `findTemplateRenderMethods` | `(vc, suite \| suites[]) => TemplateRenderMethod[]` | All matches of a suite (or any of several). |
|
|
36
|
+
| `getSvgMustacheRenderMethod` | `(vc) => TemplateRenderMethod \| null` | Backward-compatible alias for `findTemplateRenderMethod(vc, 'svg-mustache')`. |
|
|
37
|
+
| `findRenderMethod` | `(vc, predicate) => T \| null` | Escape hatch: arbitrary predicate for non-template render methods. |
|
|
38
|
+
| `findRenderMethods` | `(vc, predicate) => T[]` | Same, all matches. |
|
|
39
|
+
| `getRenderMethods` | `(vc) => RenderMethod[]` | Raw access. Unwraps `CertifiedBoostCredential`, normalizes object↔array. No validation. |
|
|
40
|
+
| `buildRenderData` | `(vc, renderProperty?) => Record<string, unknown>` | Portable Mustache context (adds `vc` / `credential` / `credentialSubjects` aliases). Optional RFC 6901 overlay. |
|
|
41
|
+
|
|
42
|
+
### Type guards (composable selection)
|
|
43
|
+
|
|
44
|
+
| Guard | Narrows to |
|
|
45
|
+
|---|---|
|
|
46
|
+
| `isTemplateRenderMethod(rm)` | `TemplateRenderMethod` (Zod-validated shape) |
|
|
47
|
+
| `isSvgMustacheRenderMethod(rm)` | `TemplateRenderMethod` with `renderSuite === 'svg-mustache'` |
|
|
48
|
+
|
|
49
|
+
### Constants
|
|
50
|
+
|
|
51
|
+
- `DEFAULT_TEMPLATE_ID` — URL of the default hosted LearnCard template. Pass as `templateId` to opt in.
|
|
52
|
+
- `RENDER_METHOD_CONTEXT` — JSON-LD context URL injected by `attachRenderMethod`. See the [draft context warning](#draft-context-warning).
|
|
53
|
+
|
|
54
|
+
### Throws
|
|
55
|
+
|
|
56
|
+
- `attachRenderMethod` / `buildTemplateRenderMethod` throw if:
|
|
57
|
+
- `templateId` is provided but is not an `http://` or `https://` URL.
|
|
58
|
+
- `templateValue` is provided but is empty or whitespace-only.
|
|
59
|
+
- `buildTemplateRenderMethod` is called without either field set.
|
|
60
|
+
|
|
61
|
+
### `AttachRenderMethodConfig`
|
|
62
|
+
|
|
63
|
+
`templateId` and `templateValue` are mutually exclusive — provide one or the other. The discriminated union enforces this at compile time.
|
|
64
|
+
|
|
65
|
+
| Field | Type | Description |
|
|
66
|
+
|-------|------|-------------|
|
|
67
|
+
| `templateId` | `string` | HTTPS URL of a hosted SVG Mustache template. Only `http://` and `https://` schemes are accepted. |
|
|
68
|
+
| `templateValue` | `string` | Inline SVG Mustache content (embedded as a URL-encoded `data:image/svg+xml,` URI). Must be non-empty. |
|
|
69
|
+
| `renderProperty` | `string[]?` | JSON Pointer paths (RFC 6901) scoping which VC fields are exposed to the template. |
|
|
70
|
+
|
|
71
|
+
## Opt-in semantics
|
|
72
|
+
|
|
73
|
+
`attachRenderMethod` is **opt-in**. Calling it without a config returns the VC unchanged, which means callers must explicitly choose to attach a render method:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
// No-op — returns vc unchanged
|
|
77
|
+
lc.invoke.attachRenderMethod(vc);
|
|
78
|
+
|
|
79
|
+
// Attaches the default template
|
|
80
|
+
lc.invoke.attachRenderMethod(vc, { templateId: DEFAULT_TEMPLATE_ID });
|
|
81
|
+
|
|
82
|
+
// Attaches a custom hosted template
|
|
83
|
+
lc.invoke.attachRenderMethod(vc, { templateId: 'https://example.com/badge.svg' });
|
|
84
|
+
|
|
85
|
+
// Attaches an inline template (URL-encoded into a data: URI)
|
|
86
|
+
lc.invoke.attachRenderMethod(vc, { templateValue: '<svg>...</svg>' });
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
This contract intentionally avoids polluting every issued credential's `@context` with the draft render-method context URL. See the [draft context warning](#draft-context-warning).
|
|
90
|
+
|
|
91
|
+
## Quick start
|
|
92
|
+
|
|
93
|
+
### Use the default LearnCard template
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
import { DEFAULT_TEMPLATE_ID } from '@learncard/render-method-plugin';
|
|
97
|
+
|
|
98
|
+
const vcWithRender = lc.invoke.attachRenderMethod(unsignedVc, {
|
|
99
|
+
templateId: DEFAULT_TEMPLATE_ID,
|
|
100
|
+
});
|
|
101
|
+
const signedVc = await lc.invoke.issueCredential(vcWithRender);
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Use a custom hosted template
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
const vcWithRender = lc.invoke.attachRenderMethod(unsignedVc, {
|
|
108
|
+
templateId: 'https://templates.example.com/badge.svg',
|
|
109
|
+
renderProperty: ['/credentialSubject/name', '/credentialSubject/description'],
|
|
110
|
+
});
|
|
111
|
+
const signedVc = await lc.invoke.issueCredential(vcWithRender);
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Use an inline template
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
const svgTemplate =
|
|
118
|
+
'<svg xmlns="http://www.w3.org/2000/svg"><text>{{credentialSubject.name}}</text></svg>';
|
|
119
|
+
|
|
120
|
+
const vcWithRender = lc.invoke.attachRenderMethod(unsignedVc, {
|
|
121
|
+
templateValue: svgTemplate,
|
|
122
|
+
});
|
|
123
|
+
const signedVc = await lc.invoke.issueCredential(vcWithRender);
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Build a render method descriptor independently
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
const renderMethod = lc.invoke.buildTemplateRenderMethod({
|
|
130
|
+
templateId: 'https://templates.example.com/badge.svg',
|
|
131
|
+
});
|
|
132
|
+
// renderMethod.type === 'TemplateRenderMethod'
|
|
133
|
+
// renderMethod.renderSuite === 'svg-mustache'
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Feature-flag interaction
|
|
137
|
+
|
|
138
|
+
In `apps/learn-card-app`, the `useRenderMethodEnabled` hook gates the **display** path (the `RenderMethodDisplay` component, the `BoostDisplayStyleSelector`, the `getSvgMustacheRenderMethod` lookup). It does **not** gate the write path — whether to attach a render method to a credential is a per-callsite decision and follows the opt-in semantics above.
|
|
139
|
+
|
|
140
|
+
In other words: enabling the LaunchDarkly flag turns on rendering for credentials that already have a `renderMethod`, but it does not retroactively change which credentials carry one.
|
|
141
|
+
|
|
142
|
+
## Draft context warning
|
|
143
|
+
|
|
144
|
+
`RENDER_METHOD_CONTEXT` currently points to a community-group draft hosted on Digital Bazaar's GitHub Pages:
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
https://digitalbazaar.github.io/vc-render-method-context/contexts/v2rc2.jsonld
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
The `v2rc2` suffix means "v2, release candidate 2". This is **not** a finalized W3C TR. Risks of issuing VCs that reference this URL in their `@context`:
|
|
151
|
+
|
|
152
|
+
- The URL could move, be renamed, or 404 — JSON-LD context resolution would fail at verification time.
|
|
153
|
+
- Term definitions could change between rc2 and a final spec, breaking interpretation.
|
|
154
|
+
- The context is not statically cached by DidKit — verification incurs a network fetch.
|
|
155
|
+
|
|
156
|
+
Mitigation plan (not yet implemented):
|
|
157
|
+
|
|
158
|
+
- Bundle the context locally, mirroring the pattern in `packages/learn-card-contexts/`.
|
|
159
|
+
- Migrate to the stable W3C TR context URL when the spec finalizes.
|
|
160
|
+
|
|
161
|
+
Tracking: <https://www.w3.org/TR/vc-render-method/>
|
|
162
|
+
|
|
163
|
+
The opt-in semantics above are the primary mitigation for now — credentials that don't need a render method don't get this context URL.
|
|
164
|
+
|
|
165
|
+
## Extending: supporting a new render suite
|
|
166
|
+
|
|
167
|
+
The read-side API is intentionally generic so new render suites can be added by callers without a plugin release. For `TemplateRenderMethod`-shaped suites, you don't write any predicate code:
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
// Filter by a single suite
|
|
171
|
+
const found = lc.invoke.findTemplateRenderMethod(vc, 'html-mustache');
|
|
172
|
+
|
|
173
|
+
// Capability negotiation — first match across the suites your renderer supports
|
|
174
|
+
const renderable = lc.invoke.findTemplateRenderMethod(vc, [
|
|
175
|
+
'svg-mustache',
|
|
176
|
+
'html-mustache',
|
|
177
|
+
]);
|
|
178
|
+
|
|
179
|
+
// All matches (e.g., when offering the user a choice)
|
|
180
|
+
const allHtml = lc.invoke.findTemplateRenderMethods(vc, 'html-mustache');
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
For non-template render methods (e.g., a future `WebRenderingTemplate2022` with a different shape), use the predicate-based `findRenderMethod` escape hatch with your own type guard.
|
|
184
|
+
|
|
185
|
+
The plugin handles **selection** and **data shaping** uniformly across suites. The **actual rendering** (Mustache hydration + sanitization) stays in the app/UI layer because sanitization policy (DOMPurify for SVG, different rules for HTML, etc.) is renderer-specific.
|
|
186
|
+
|
|
187
|
+
## Architectural boundary
|
|
188
|
+
|
|
189
|
+
- **In the plugin** (this package): data domain — attach renderMethod to VCs, find renderMethod entries, shape Mustache contexts. Pure, isomorphic, CLI-safe.
|
|
190
|
+
- **In the app**: render domain — Mustache hydration into a target format, DOMPurify sanitization, DOM insertion. Browser-specific.
|
|
191
|
+
|
|
192
|
+
The seam is "data that describes how to render" (plugin) vs. "execute the render and put pixels on screen" (app).
|
|
193
|
+
|
|
194
|
+
## Notes
|
|
195
|
+
|
|
196
|
+
- Only `svg-mustache` is supported as a render suite at this time. The renderer in `apps/learn-card-app/src/helpers/renderMethod.helpers.ts` performs DOMPurify sanitization on the hydrated SVG before insertion.
|
|
197
|
+
- See `src/types.ts` for types, `src/plugin.ts` for the write side, `src/read.ts` for the read side.
|
|
198
|
+
- See `src/test/plugin.test.ts` for the full behavior contract.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
|
package/dist/index.js
ADDED
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { UnsignedVC, TemplateRenderMethod } from '@learncard/types';
|
|
2
|
+
import { AttachRenderMethodConfig, RenderMethodDependentLearnCard, RenderMethodPlugin } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* The default hosted SVG Mustache template, served from `packages/render-method-templates/`.
|
|
5
|
+
*
|
|
6
|
+
* Exported so callers can opt in to the default explicitly:
|
|
7
|
+
*
|
|
8
|
+
* lc.invoke.attachRenderMethod(vc, { templateId: DEFAULT_TEMPLATE_ID })
|
|
9
|
+
*
|
|
10
|
+
* Per the opt-in contract for `attachRenderMethod`, calling without a config will NOT attach this
|
|
11
|
+
* template — callers must be explicit.
|
|
12
|
+
*/
|
|
13
|
+
export declare const DEFAULT_TEMPLATE_ID = "https://templates.learncard.com/svg/card/card-1.0.0.svg";
|
|
14
|
+
/**
|
|
15
|
+
* Builds a `TemplateRenderMethod` from the given config. Inline `templateValue` takes priority
|
|
16
|
+
* and is URL-encoded into a `data:image/svg+xml,...` URI. Otherwise `templateId` is used as-is.
|
|
17
|
+
*
|
|
18
|
+
* @throws if neither `templateId` nor `templateValue` is provided, if `templateId` is not http(s),
|
|
19
|
+
* or if `templateValue` is empty.
|
|
20
|
+
*/
|
|
21
|
+
export declare const buildTemplateRenderMethod: (config: AttachRenderMethodConfig) => TemplateRenderMethod;
|
|
22
|
+
/**
|
|
23
|
+
* Attaches a `TemplateRenderMethod` to an unsigned VC, merging with any existing `renderMethod`
|
|
24
|
+
* entries. Injects the render-method JSON-LD context if not already present.
|
|
25
|
+
*
|
|
26
|
+
* **Opt-in semantics:** If `config` is omitted, the VC is returned UNCHANGED. The caller must
|
|
27
|
+
* explicitly opt in by providing `templateId` or `templateValue`. Pass `DEFAULT_TEMPLATE_ID` to
|
|
28
|
+
* use the default hosted template.
|
|
29
|
+
*
|
|
30
|
+
* This contract intentionally avoids polluting every issued credential's `@context` with the
|
|
31
|
+
* draft render-method context URL. See `RENDER_METHOD_CONTEXT` for the rationale.
|
|
32
|
+
*/
|
|
33
|
+
export declare const attachRenderMethod: (vc: UnsignedVC, config?: AttachRenderMethodConfig) => UnsignedVC;
|
|
34
|
+
export declare const getRenderMethodPlugin: (_learnCard: RenderMethodDependentLearnCard) => RenderMethodPlugin;
|
|
35
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAEpE,OAAO,EACH,wBAAwB,EACxB,8BAA8B,EAC9B,kBAAkB,EAErB,MAAM,SAAS,CAAC;AAWjB;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,4DAA4D,CAAC;AAe7F;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,WAC1B,wBAAwB,KACjC,oBAiCF,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,OACvB,UAAU,WACL,wBAAwB,KAClC,UA4BF,CAAC;AAEF,eAAO,MAAM,qBAAqB,eAClB,8BAA8B,KAC3C,kBAgBD,CAAC"}
|
package/dist/read.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { UnsignedVC, VC, RenderMethod, TemplateRenderMethod } from '@learncard/types';
|
|
2
|
+
type AnyCredential = VC | UnsignedVC;
|
|
3
|
+
type JsonRecord = Record<string, unknown>;
|
|
4
|
+
/** Mustache context shape produced by `buildRenderData`. */
|
|
5
|
+
export type RenderMethodData = JsonRecord;
|
|
6
|
+
/**
|
|
7
|
+
* Type guard for any `TemplateRenderMethod` (Zod-validated). Use for shape
|
|
8
|
+
* checks before treating an unknown `renderMethod` entry as a template render.
|
|
9
|
+
*/
|
|
10
|
+
export declare const isTemplateRenderMethod: (rm: unknown) => rm is TemplateRenderMethod;
|
|
11
|
+
/**
|
|
12
|
+
* Type guard for `TemplateRenderMethod` with `renderSuite === 'svg-mustache'`.
|
|
13
|
+
* Exported so consumers can compose their own selection (e.g., capability
|
|
14
|
+
* negotiation across multiple suites the renderer supports).
|
|
15
|
+
*/
|
|
16
|
+
export declare const isSvgMustacheRenderMethod: (rm: unknown) => rm is TemplateRenderMethod;
|
|
17
|
+
/**
|
|
18
|
+
* Returns all `renderMethod` entries on a VC. Normalizes single-object form to
|
|
19
|
+
* an array and unwraps `CertifiedBoostCredential` so callers don't have to
|
|
20
|
+
* think about the wrapping layer.
|
|
21
|
+
*
|
|
22
|
+
* Entries are NOT validated here. Callers apply type guards via
|
|
23
|
+
* `findRenderMethod` / `findRenderMethods`, or one of the typed conveniences.
|
|
24
|
+
*/
|
|
25
|
+
export declare const getRenderMethods: (vc: AnyCredential) => RenderMethod[];
|
|
26
|
+
/**
|
|
27
|
+
* First `renderMethod` matching a type-guard predicate, or `null` if none.
|
|
28
|
+
*
|
|
29
|
+
* The predicate receives raw entries so it can apply Zod-validated guards
|
|
30
|
+
* (e.g., `isSvgMustacheRenderMethod`). The return type is narrowed by the
|
|
31
|
+
* predicate.
|
|
32
|
+
*/
|
|
33
|
+
export declare function findRenderMethod<T extends RenderMethod = RenderMethod>(vc: AnyCredential, predicate: (rm: RenderMethod) => rm is T): T | null;
|
|
34
|
+
/** Like `findRenderMethod`, but returns every matching entry. */
|
|
35
|
+
export declare function findRenderMethods<T extends RenderMethod = RenderMethod>(vc: AnyCredential, predicate: (rm: RenderMethod) => rm is T): T[];
|
|
36
|
+
/**
|
|
37
|
+
* First `TemplateRenderMethod` on a VC whose `renderSuite` matches the given
|
|
38
|
+
* suite name, or `null`. Accepts a single suite string OR an array of suite
|
|
39
|
+
* strings (returns the first match across the list — useful for capability
|
|
40
|
+
* negotiation when a renderer supports multiple suites).
|
|
41
|
+
*
|
|
42
|
+
* Returns the Zod-parsed shape (not the raw entry).
|
|
43
|
+
*
|
|
44
|
+
* findTemplateRenderMethod(vc, 'svg-mustache')
|
|
45
|
+
* findTemplateRenderMethod(vc, ['svg-mustache', 'html-mustache'])
|
|
46
|
+
*/
|
|
47
|
+
export declare const findTemplateRenderMethod: (vc: AnyCredential, suite: string | readonly string[]) => TemplateRenderMethod | null;
|
|
48
|
+
/** Like `findTemplateRenderMethod`, but returns every matching entry. */
|
|
49
|
+
export declare const findTemplateRenderMethods: (vc: AnyCredential, suite: string | readonly string[]) => TemplateRenderMethod[];
|
|
50
|
+
/**
|
|
51
|
+
* Convenience: the first svg-mustache `TemplateRenderMethod` on a VC, or `null`.
|
|
52
|
+
* Equivalent to `findTemplateRenderMethod(vc, 'svg-mustache')`.
|
|
53
|
+
*/
|
|
54
|
+
export declare const getSvgMustacheRenderMethod: (vc: AnyCredential) => TemplateRenderMethod | null;
|
|
55
|
+
/**
|
|
56
|
+
* Builds the portable Mustache context for a VC. Designed for SVG / HTML /
|
|
57
|
+
* text Mustache templates that may have been authored against any of these
|
|
58
|
+
* shapes:
|
|
59
|
+
*
|
|
60
|
+
* {{credentialSubject.name}} // direct VC paths
|
|
61
|
+
* {{credential.credentialSubject.name}} // `credential` alias
|
|
62
|
+
* {{vc.issuer.name}} // `vc` alias
|
|
63
|
+
* {{#credentialSubjects}}{{name}}{{/credentialSubjects}} // section over array
|
|
64
|
+
*
|
|
65
|
+
* The top-level credential is the single source of truth; aliases keep older
|
|
66
|
+
* templates working. When `renderProperty` (RFC 6901 JSON Pointers) is given,
|
|
67
|
+
* those values are overlaid at their pointer paths in the resulting context.
|
|
68
|
+
*
|
|
69
|
+
* This function does NOT unwrap `CertifiedBoostCredential` — pass the layer
|
|
70
|
+
* you want the template to bind to. `getRenderMethods` is the helper that
|
|
71
|
+
* unwraps.
|
|
72
|
+
*/
|
|
73
|
+
export declare const buildRenderData: (vc: AnyCredential, renderProperty?: string[]) => RenderMethodData;
|
|
74
|
+
export {};
|
|
75
|
+
//# sourceMappingURL=read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../src/read.ts"],"names":[],"mappings":"AACA,OAAO,EACH,UAAU,EACV,EAAE,EACF,YAAY,EACZ,oBAAoB,EAEvB,MAAM,kBAAkB,CAAC;AAE1B,KAAK,aAAa,GAAG,EAAE,GAAG,UAAU,CAAC;AACrC,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1C,4DAA4D;AAC5D,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,sBAAsB,OAAQ,OAAO,KAAG,EAAE,IAAI,oBACJ,CAAC;AAExD;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,OAAQ,OAAO,KAAG,EAAE,IAAI,oBAG7D,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,OAAQ,aAAa,KAAG,YAAY,EAOhE,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,EAClE,EAAE,EAAE,aAAa,EACjB,SAAS,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,EAAE,IAAI,CAAC,GACzC,CAAC,GAAG,IAAI,CAKV;AAED,iEAAiE;AACjE,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,YAAY,GAAG,YAAY,EACnE,EAAE,EAAE,aAAa,EACjB,SAAS,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,EAAE,IAAI,CAAC,GACzC,CAAC,EAAE,CAEL;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,OAC7B,aAAa,SACV,MAAM,GAAG,SAAS,MAAM,EAAE,KAClC,oBAAoB,GAAG,IASzB,CAAC;AAEF,yEAAyE;AACzE,eAAO,MAAM,yBAAyB,OAC9B,aAAa,SACV,MAAM,GAAG,SAAS,MAAM,EAAE,KAClC,oBAAoB,EAUtB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,0BAA0B,OAC/B,aAAa,KAClB,oBAAoB,GAAG,IAAoD,CAAC;AAgE/E;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,eAAe,OACpB,aAAa,mBACA,MAAM,EAAE,KAC1B,gBAkBF,CAAC"}
|