@learncard/helpers 1.3.9 → 1.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers.cjs.development.cjs +1997 -1831
- package/dist/helpers.cjs.development.cjs.map +3 -3
- package/dist/helpers.cjs.production.min.cjs +25 -25
- package/dist/helpers.cjs.production.min.cjs.map +4 -4
- package/dist/helpers.d.cts +14 -9
- package/dist/helpers.d.ts +14 -9
- package/dist/helpers.esm.js +145 -5
- package/dist/helpers.esm.js.map +3 -3
- package/package.json +2 -2
- package/src/bitstring-status-list/index.ts +5 -1
- package/src/did.ts +12 -0
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@learncard/helpers",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.11",
|
|
4
4
|
"description": "Shared helpers for LearnCard packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@noble/hashes": "^1.8.0",
|
|
61
61
|
"@sd-jwt/decode": "^0.19.0",
|
|
62
|
-
"@learncard/types": "5.
|
|
62
|
+
"@learncard/types": "5.18.1",
|
|
63
63
|
"@trpc/server": "11.7.1",
|
|
64
64
|
"immer": "^10.0.3",
|
|
65
65
|
"use-immer": "^0.9.0",
|
|
@@ -15,11 +15,15 @@ export const isBitstringStatusListEntry = (status: unknown): status is Bitstring
|
|
|
15
15
|
if (!status || typeof status !== 'object') return false;
|
|
16
16
|
|
|
17
17
|
const record = status as Record<string, unknown>;
|
|
18
|
+
const statusListIndex = record.statusListIndex;
|
|
18
19
|
|
|
19
20
|
return (
|
|
20
21
|
record.type === 'BitstringStatusListEntry' &&
|
|
21
22
|
(record.statusPurpose === 'revocation' || record.statusPurpose === 'suspension') &&
|
|
22
|
-
typeof
|
|
23
|
+
(typeof statusListIndex === 'string' ||
|
|
24
|
+
(typeof statusListIndex === 'number' &&
|
|
25
|
+
Number.isInteger(statusListIndex) &&
|
|
26
|
+
statusListIndex >= 0)) &&
|
|
23
27
|
typeof record.statusListCredential === 'string'
|
|
24
28
|
);
|
|
25
29
|
};
|
package/src/did.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Generates a did:web for a user given the app domain and profile ID. */
|
|
2
|
+
export const getDidWeb = (domain: string, profileId: string): string => {
|
|
3
|
+
let decodedDomain = domain;
|
|
4
|
+
|
|
5
|
+
try {
|
|
6
|
+
decodedDomain = decodeURIComponent(domain);
|
|
7
|
+
} catch {
|
|
8
|
+
// Keep the original domain when it is not valid URI-encoded input.
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return `did:web:${encodeURIComponent(decodedDomain)}:users:${profileId}`;
|
|
12
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -85,6 +85,7 @@ export * from './Utilities';
|
|
|
85
85
|
// Export app install helpers
|
|
86
86
|
export * from './app-install';
|
|
87
87
|
export * from './credential-format';
|
|
88
|
+
export * from './did';
|
|
88
89
|
|
|
89
90
|
// ADR-0001 Phase 1: format-tagged credential storage projector
|
|
90
91
|
export * from './credential-format';
|