@learncard/types 5.17.4 → 5.17.6
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/README.md +5 -5
- package/dist/bitstring-status-list.d.ts +1 -1
- package/dist/bitstring-status-list.d.ts.map +1 -1
- package/dist/clr.d.ts +1 -1
- package/dist/clr.d.ts.map +1 -1
- package/dist/credential-format.d.ts +1 -1
- package/dist/credential-format.d.ts.map +1 -1
- package/dist/crypto.d.ts +1 -1
- package/dist/crypto.d.ts.map +1 -1
- package/dist/did.d.ts +1 -1
- package/dist/did.d.ts.map +1 -1
- package/dist/lcn.d.ts +9 -2
- package/dist/lcn.d.ts.map +1 -1
- package/dist/learncard.d.ts +1 -1
- package/dist/learncard.d.ts.map +1 -1
- package/dist/learncloud.d.ts +1 -1
- package/dist/learncloud.d.ts.map +1 -1
- package/dist/mongo.d.ts +1 -1
- package/dist/mongo.d.ts.map +1 -1
- package/dist/obv3.d.ts +1 -1
- package/dist/obv3.d.ts.map +1 -1
- package/dist/queries.d.ts +1 -1
- package/dist/queries.d.ts.map +1 -1
- package/dist/types.cjs.development.cjs +83 -81
- package/dist/types.cjs.development.cjs.map +3 -3
- package/dist/types.cjs.production.min.cjs +1 -1
- package/dist/types.cjs.production.min.cjs.map +3 -3
- package/dist/types.esm.js +15 -13
- package/dist/types.esm.js.map +2 -2
- package/dist/vc.d.ts +1 -1
- package/dist/vc.d.ts.map +1 -1
- package/package.json +64 -62
- package/src/auth.ts +460 -0
- package/src/bitstring-status-list.ts +44 -0
- package/src/clr.ts +68 -0
- package/src/credential-format.ts +154 -0
- package/src/crypto.ts +41 -0
- package/src/did.ts +47 -0
- package/src/helpers.ts +10 -0
- package/src/index.ts +17 -0
- package/src/lcn.ts +2182 -0
- package/src/learncard.ts +123 -0
- package/src/learncloud.ts +26 -0
- package/src/mongo.ts +14 -0
- package/src/obv3.ts +252 -0
- package/src/queries.ts +56 -0
- package/src/registries.ts +9 -0
- package/src/vc.ts +221 -0
- package/src/wasm.ts +1 -0
package/src/vc.ts
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
|
|
3
|
+
export const ContextValidator = z.array(z.string().or(z.record(z.string(), z.any())));
|
|
4
|
+
export type Context = z.infer<typeof ContextValidator>;
|
|
5
|
+
|
|
6
|
+
export const AchievementCriteriaValidator = z.object({
|
|
7
|
+
type: z.string().optional(),
|
|
8
|
+
narrative: z.string().optional(),
|
|
9
|
+
});
|
|
10
|
+
export type AchievementCriteria = z.infer<typeof AchievementCriteriaValidator>;
|
|
11
|
+
|
|
12
|
+
export const ImageValidator = z.string().or(
|
|
13
|
+
z.object({
|
|
14
|
+
id: z.string(),
|
|
15
|
+
type: z.string(),
|
|
16
|
+
caption: z.string().optional(),
|
|
17
|
+
})
|
|
18
|
+
);
|
|
19
|
+
export type Image = z.infer<typeof ImageValidator>;
|
|
20
|
+
|
|
21
|
+
export const GeoCoordinatesValidator = z.object({
|
|
22
|
+
type: z.string().min(1).or(z.string().array().nonempty()),
|
|
23
|
+
latitude: z.number(),
|
|
24
|
+
longitude: z.number(),
|
|
25
|
+
});
|
|
26
|
+
export type GeoCoordinates = z.infer<typeof GeoCoordinatesValidator>;
|
|
27
|
+
|
|
28
|
+
export const AddressValidator = z.object({
|
|
29
|
+
type: z.string().min(1).or(z.string().array().nonempty()),
|
|
30
|
+
addressCountry: z.string().optional(),
|
|
31
|
+
addressCountryCode: z.string().optional(),
|
|
32
|
+
addressRegion: z.string().optional(),
|
|
33
|
+
addressLocality: z.string().optional(),
|
|
34
|
+
streetAddress: z.string().optional(),
|
|
35
|
+
postOfficeBoxNumber: z.string().optional(),
|
|
36
|
+
postalCode: z.string().optional(),
|
|
37
|
+
geo: GeoCoordinatesValidator.optional(),
|
|
38
|
+
});
|
|
39
|
+
export type Address = z.infer<typeof AddressValidator>;
|
|
40
|
+
|
|
41
|
+
export const IdentifierTypeValidator = z
|
|
42
|
+
.enum([
|
|
43
|
+
'sourcedId',
|
|
44
|
+
'systemId',
|
|
45
|
+
'productId',
|
|
46
|
+
'userName',
|
|
47
|
+
'accountId',
|
|
48
|
+
'emailAddress',
|
|
49
|
+
'nationalIdentityNumber',
|
|
50
|
+
'isbn',
|
|
51
|
+
'issn',
|
|
52
|
+
'lisSourcedId',
|
|
53
|
+
'oneRosterSourcedId',
|
|
54
|
+
'sisSourcedId',
|
|
55
|
+
'ltiContextId',
|
|
56
|
+
'ltiDeploymentId',
|
|
57
|
+
'ltiToolId',
|
|
58
|
+
'ltiPlatformId',
|
|
59
|
+
'ltiUserId',
|
|
60
|
+
'identifier',
|
|
61
|
+
])
|
|
62
|
+
.or(z.string());
|
|
63
|
+
export type IdentifierType = z.infer<typeof IdentifierTypeValidator>;
|
|
64
|
+
|
|
65
|
+
export const IdentifierEntryValidator = z.object({
|
|
66
|
+
type: z.string().min(1).or(z.string().array().nonempty()),
|
|
67
|
+
identifier: z.string(),
|
|
68
|
+
identifierType: IdentifierTypeValidator,
|
|
69
|
+
});
|
|
70
|
+
export type IdentifierEntry = z.infer<typeof IdentifierEntryValidator>;
|
|
71
|
+
|
|
72
|
+
export const ProfileValidator = z.string().or(
|
|
73
|
+
z
|
|
74
|
+
.object({
|
|
75
|
+
id: z.string().optional(),
|
|
76
|
+
type: z.string().or(z.string().array().nonempty().optional()),
|
|
77
|
+
name: z.string().optional(),
|
|
78
|
+
url: z.string().optional(),
|
|
79
|
+
phone: z.string().optional(),
|
|
80
|
+
description: z.string().optional(),
|
|
81
|
+
endorsement: z.any().array().optional(), // Recursive type
|
|
82
|
+
image: ImageValidator.optional(),
|
|
83
|
+
email: z.string().email().optional(),
|
|
84
|
+
address: AddressValidator.optional(),
|
|
85
|
+
otherIdentifier: IdentifierEntryValidator.array().optional(),
|
|
86
|
+
official: z.string().optional(),
|
|
87
|
+
parentOrg: z.any().optional(), // Recursive types are annoying =(
|
|
88
|
+
familyName: z.string().optional(),
|
|
89
|
+
givenName: z.string().optional(),
|
|
90
|
+
additionalName: z.string().optional(),
|
|
91
|
+
patronymicName: z.string().optional(),
|
|
92
|
+
honorificPrefix: z.string().optional(),
|
|
93
|
+
honorificSuffix: z.string().optional(),
|
|
94
|
+
familyNamePrefix: z.string().optional(),
|
|
95
|
+
dateOfBirth: z.string().optional(),
|
|
96
|
+
})
|
|
97
|
+
.catchall(z.any())
|
|
98
|
+
);
|
|
99
|
+
export type Profile = z.infer<typeof ProfileValidator>;
|
|
100
|
+
|
|
101
|
+
export const CredentialSubjectValidator = z.object({ id: z.string().optional() }).catchall(z.any());
|
|
102
|
+
export type CredentialSubject = z.infer<typeof CredentialSubjectValidator>;
|
|
103
|
+
|
|
104
|
+
export const CredentialStatusValidator = z
|
|
105
|
+
.object({ type: z.string(), id: z.string() })
|
|
106
|
+
.catchall(z.any());
|
|
107
|
+
export type CredentialStatus = z.infer<typeof CredentialStatusValidator>;
|
|
108
|
+
|
|
109
|
+
export const CredentialSchemaValidator = z
|
|
110
|
+
.object({ id: z.string(), type: z.string() })
|
|
111
|
+
.catchall(z.any());
|
|
112
|
+
export type CredentialSchema = z.infer<typeof CredentialSchemaValidator>;
|
|
113
|
+
|
|
114
|
+
export const RefreshServiceValidator = z
|
|
115
|
+
.object({ id: z.string().optional(), type: z.string() })
|
|
116
|
+
.catchall(z.any());
|
|
117
|
+
export type RefreshService = z.infer<typeof RefreshServiceValidator>;
|
|
118
|
+
|
|
119
|
+
export const TermsOfUseValidator = z
|
|
120
|
+
.object({ type: z.string(), id: z.string().optional() })
|
|
121
|
+
.catchall(z.any());
|
|
122
|
+
export type TermsOfUse = z.infer<typeof TermsOfUseValidator>;
|
|
123
|
+
|
|
124
|
+
export const VC2EvidenceValidator = z
|
|
125
|
+
.object({
|
|
126
|
+
id: z.string().optional(),
|
|
127
|
+
type: z.array(z.string()).nonempty(),
|
|
128
|
+
name: z.string().optional(),
|
|
129
|
+
narrative: z.string().optional(),
|
|
130
|
+
description: z.string().optional(),
|
|
131
|
+
genre: z.string().optional(),
|
|
132
|
+
audience: z.string().optional(),
|
|
133
|
+
})
|
|
134
|
+
.catchall(z.any());
|
|
135
|
+
export type VC2Evidence = z.infer<typeof VC2EvidenceValidator>;
|
|
136
|
+
|
|
137
|
+
export const TemplateRenderMethodValidator = z.object({
|
|
138
|
+
type: z.literal('TemplateRenderMethod'),
|
|
139
|
+
renderSuite: z.string(),
|
|
140
|
+
template: z.string(),
|
|
141
|
+
renderProperty: z.array(z.string()).optional(),
|
|
142
|
+
outputPreference: z
|
|
143
|
+
.object({
|
|
144
|
+
mediaType: z.string(),
|
|
145
|
+
})
|
|
146
|
+
.optional(),
|
|
147
|
+
});
|
|
148
|
+
export type TemplateRenderMethod = z.infer<typeof TemplateRenderMethodValidator>;
|
|
149
|
+
|
|
150
|
+
export const RenderMethodValidator = z.union([
|
|
151
|
+
TemplateRenderMethodValidator,
|
|
152
|
+
z.record(z.string(), z.any()),
|
|
153
|
+
]);
|
|
154
|
+
export type RenderMethod = z.infer<typeof RenderMethodValidator>;
|
|
155
|
+
|
|
156
|
+
export const UnsignedVCValidator = z
|
|
157
|
+
.object({
|
|
158
|
+
'@context': ContextValidator,
|
|
159
|
+
id: z.string().optional(),
|
|
160
|
+
type: z.string().array().nonempty(),
|
|
161
|
+
issuer: ProfileValidator,
|
|
162
|
+
credentialSubject: CredentialSubjectValidator.or(CredentialSubjectValidator.array()),
|
|
163
|
+
refreshService: RefreshServiceValidator.or(RefreshServiceValidator.array()).optional(),
|
|
164
|
+
credentialSchema: CredentialSchemaValidator.or(
|
|
165
|
+
CredentialSchemaValidator.array()
|
|
166
|
+
).optional(),
|
|
167
|
+
|
|
168
|
+
// V1
|
|
169
|
+
issuanceDate: z.string().optional(),
|
|
170
|
+
expirationDate: z.string().optional(),
|
|
171
|
+
credentialStatus: CredentialStatusValidator.or(
|
|
172
|
+
CredentialStatusValidator.array()
|
|
173
|
+
).optional(),
|
|
174
|
+
|
|
175
|
+
// V2
|
|
176
|
+
name: z.string().optional(),
|
|
177
|
+
description: z.string().optional(),
|
|
178
|
+
validFrom: z.string().optional(),
|
|
179
|
+
validUntil: z.string().optional(),
|
|
180
|
+
status: CredentialStatusValidator.or(CredentialStatusValidator.array()).optional(),
|
|
181
|
+
termsOfUse: TermsOfUseValidator.or(TermsOfUseValidator.array()).optional(),
|
|
182
|
+
evidence: z.union([VC2EvidenceValidator, z.array(VC2EvidenceValidator)]).optional(),
|
|
183
|
+
renderMethod: z.union([RenderMethodValidator, z.array(RenderMethodValidator)]).optional(),
|
|
184
|
+
})
|
|
185
|
+
.catchall(z.any());
|
|
186
|
+
export type UnsignedVC = z.infer<typeof UnsignedVCValidator>;
|
|
187
|
+
|
|
188
|
+
export const ProofValidator = z
|
|
189
|
+
.object({
|
|
190
|
+
type: z.string(),
|
|
191
|
+
created: z.string(),
|
|
192
|
+
challenge: z.string().optional(),
|
|
193
|
+
domain: z.string().optional(),
|
|
194
|
+
nonce: z.string().optional(),
|
|
195
|
+
proofPurpose: z.string(),
|
|
196
|
+
verificationMethod: z.string(),
|
|
197
|
+
jws: z.string().optional(),
|
|
198
|
+
})
|
|
199
|
+
.catchall(z.any());
|
|
200
|
+
export type Proof = z.infer<typeof ProofValidator>;
|
|
201
|
+
|
|
202
|
+
export const VCValidator = UnsignedVCValidator.extend({
|
|
203
|
+
proof: ProofValidator.or(ProofValidator.array()),
|
|
204
|
+
});
|
|
205
|
+
export type VC = z.infer<typeof VCValidator>;
|
|
206
|
+
|
|
207
|
+
export const UnsignedVPValidator = z
|
|
208
|
+
.object({
|
|
209
|
+
'@context': ContextValidator,
|
|
210
|
+
id: z.string().optional(),
|
|
211
|
+
type: z.string().or(z.string().array().nonempty()),
|
|
212
|
+
verifiableCredential: VCValidator.or(VCValidator.array()).optional(),
|
|
213
|
+
holder: z.string().optional(),
|
|
214
|
+
})
|
|
215
|
+
.catchall(z.any());
|
|
216
|
+
export type UnsignedVP = z.infer<typeof UnsignedVPValidator>;
|
|
217
|
+
|
|
218
|
+
export const VPValidator = UnsignedVPValidator.extend({
|
|
219
|
+
proof: ProofValidator.or(ProofValidator.array()),
|
|
220
|
+
});
|
|
221
|
+
export type VP = z.infer<typeof VPValidator>;
|
package/src/wasm.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|