@timeback/clr 0.1.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/dist/client.d.ts +70 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/constants.d.ts +30 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +1703 -0
- package/dist/factory.d.ts +38 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/index.d.ts +589 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16884 -0
- package/dist/lib/index.d.ts +9 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/resolve.d.ts +21 -0
- package/dist/lib/resolve.d.ts.map +1 -0
- package/dist/lib/transport.d.ts +21 -0
- package/dist/lib/transport.d.ts.map +1 -0
- package/dist/public-types.d.ts +376 -0
- package/dist/public-types.d.ts.map +1 -0
- package/dist/public-types.js +0 -0
- package/dist/resources/credentials.d.ts +54 -0
- package/dist/resources/credentials.d.ts.map +1 -0
- package/dist/resources/discovery.d.ts +41 -0
- package/dist/resources/discovery.d.ts.map +1 -0
- package/dist/resources/index.d.ts +6 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/types/client.d.ts +48 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +11 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLR Client Factory
|
|
3
|
+
*
|
|
4
|
+
* Creates ClrClient classes bound to specific provider registries.
|
|
5
|
+
*/
|
|
6
|
+
import { CredentialsResource, DiscoveryResource } from './resources';
|
|
7
|
+
import type { AuthCheckResult, ProviderRegistry, TimebackProvider } from '@timeback/internal-client-infra';
|
|
8
|
+
import type { ClrClientConfig, ClrTransportLike } from './types';
|
|
9
|
+
/**
|
|
10
|
+
* Create a ClrClient class bound to a specific provider registry.
|
|
11
|
+
*
|
|
12
|
+
* @param registry - Provider registry to use (defaults to all Timeback platforms)
|
|
13
|
+
* @returns ClrClient class bound to the registry
|
|
14
|
+
*/
|
|
15
|
+
export declare function createClrClient(registry?: ProviderRegistry): {
|
|
16
|
+
new (config?: ClrClientConfig): {
|
|
17
|
+
/** @internal */
|
|
18
|
+
readonly transport: ClrTransportLike;
|
|
19
|
+
/** @internal */
|
|
20
|
+
readonly _provider?: TimebackProvider | undefined;
|
|
21
|
+
/** Upsert and manage CLR verifiable credentials */
|
|
22
|
+
readonly credentials: CredentialsResource;
|
|
23
|
+
/** Discover CLR API capabilities and endpoints */
|
|
24
|
+
readonly discovery: DiscoveryResource;
|
|
25
|
+
/**
|
|
26
|
+
* Get the underlying transport for advanced use cases.
|
|
27
|
+
* @returns The transport instance used by this client
|
|
28
|
+
*/
|
|
29
|
+
getTransport(): ClrTransportLike;
|
|
30
|
+
/**
|
|
31
|
+
* Verify that OAuth authentication is working.
|
|
32
|
+
* @returns Auth check result
|
|
33
|
+
* @throws {Error} If client was initialized with custom transport (no provider)
|
|
34
|
+
*/
|
|
35
|
+
checkAuth(): Promise<AuthCheckResult>;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAGpE,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAC1G,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAEhE;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,GAAE,gBAA4C;;QAOpF,gBAAgB;;QAGhB,gBAAgB;;QAGhB,mDAAmD;;QAEnD,kDAAkD;;QA0ClD;;;WAGG;;QAKH;;;;WAIG;;;EASJ"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,589 @@
|
|
|
1
|
+
import * as _timeback_internal_client_infra from '@timeback/internal-client-infra';
|
|
2
|
+
import { ClientConfig, TransportOnlyConfig, ClrPaths, RequestOptions, ProviderClientConfig, TransportConfigWithTokenProvider, ProviderRegistry, TimebackProvider, AuthCheckResult, BaseTransport } from '@timeback/internal-client-infra';
|
|
3
|
+
export { AuthCheckResult, EnvAuth, Environment, ExplicitAuth } from '@timeback/internal-client-infra';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* CLR Credential Types
|
|
7
|
+
*
|
|
8
|
+
* Types for the Comprehensive Learner Record (CLR) v2.0 Verifiable Credential model.
|
|
9
|
+
* Based on the IMS Global CLR v2.0 specification.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
13
|
+
// ENUMS
|
|
14
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Types of achievements that can be represented in a CLR credential.
|
|
18
|
+
*
|
|
19
|
+
* Defined by the IMS Global CLR v2.0 specification.
|
|
20
|
+
* Custom extensions are supported via the `ext:` prefix.
|
|
21
|
+
*/
|
|
22
|
+
type AchievementType =
|
|
23
|
+
| 'Achievement'
|
|
24
|
+
| 'ApprenticeshipCertificate'
|
|
25
|
+
| 'Assessment'
|
|
26
|
+
| 'Assignment'
|
|
27
|
+
| 'AssociateDegree'
|
|
28
|
+
| 'Award'
|
|
29
|
+
| 'Badge'
|
|
30
|
+
| 'BachelorDegree'
|
|
31
|
+
| 'Certificate'
|
|
32
|
+
| 'CertificateOfCompletion'
|
|
33
|
+
| 'Certification'
|
|
34
|
+
| 'CommunityService'
|
|
35
|
+
| 'Competency'
|
|
36
|
+
| 'Course'
|
|
37
|
+
| 'CoCurricular'
|
|
38
|
+
| 'Degree'
|
|
39
|
+
| 'Diploma'
|
|
40
|
+
| 'DoctoralDegree'
|
|
41
|
+
| 'Fieldwork'
|
|
42
|
+
| 'GeneralEducationDevelopment'
|
|
43
|
+
| 'JourneymanCertificate'
|
|
44
|
+
| 'LearningProgram'
|
|
45
|
+
| 'License'
|
|
46
|
+
| 'Membership'
|
|
47
|
+
| 'ProfessionalDoctorate'
|
|
48
|
+
| 'QualityAssuranceCredential'
|
|
49
|
+
| 'MasterCertificate'
|
|
50
|
+
| 'MasterDegree'
|
|
51
|
+
| 'MicroCredential'
|
|
52
|
+
| 'ResearchDoctorate'
|
|
53
|
+
| 'SecondarySchoolDiploma'
|
|
54
|
+
| (string & {})
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Types of associations between achievements or credentials.
|
|
58
|
+
*/
|
|
59
|
+
type AssociationType =
|
|
60
|
+
| 'exactMatchOf'
|
|
61
|
+
| 'isChildOf'
|
|
62
|
+
| 'isParentOf'
|
|
63
|
+
| 'isPartOf'
|
|
64
|
+
| 'isPeerOf'
|
|
65
|
+
| 'isRelatedTo'
|
|
66
|
+
| 'precedes'
|
|
67
|
+
| 'replacedBy'
|
|
68
|
+
|
|
69
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
70
|
+
// SHARED TYPES
|
|
71
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Image reference following the IMS Global Image model.
|
|
75
|
+
*/
|
|
76
|
+
interface ClrImage {
|
|
77
|
+
/** The URI or Data URI of the image. */
|
|
78
|
+
id: string
|
|
79
|
+
/** MUST be the IRI 'Image'. */
|
|
80
|
+
type: 'Image'
|
|
81
|
+
/** The caption for the image. */
|
|
82
|
+
caption?: string
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Profile representing an issuer or creator of a credential.
|
|
87
|
+
*
|
|
88
|
+
* Used for both the top-level issuer and achievement creators.
|
|
89
|
+
*/
|
|
90
|
+
interface ClrProfile {
|
|
91
|
+
/** URI identifier for the profile. */
|
|
92
|
+
id: string
|
|
93
|
+
/** Type identifiers (e.g., ['Profile']). */
|
|
94
|
+
type: string[]
|
|
95
|
+
/** Display name of the profile. */
|
|
96
|
+
name?: string
|
|
97
|
+
/** URL of the profile's website. */
|
|
98
|
+
url?: string
|
|
99
|
+
/** Phone number for the profile. */
|
|
100
|
+
phone?: string
|
|
101
|
+
/** Description of the profile. */
|
|
102
|
+
description?: string
|
|
103
|
+
/** Image associated with the profile. */
|
|
104
|
+
image?: ClrImage
|
|
105
|
+
/** Email address for the profile. */
|
|
106
|
+
email?: string
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Cryptographic proof ensuring credential integrity and authenticity.
|
|
111
|
+
*
|
|
112
|
+
* Supports DataIntegrityProof, JsonWebSignature2020, and other proof types.
|
|
113
|
+
*/
|
|
114
|
+
interface ClrProof {
|
|
115
|
+
/** The proof type (e.g., 'DataIntegrityProof', 'JsonWebSignature2020'). */
|
|
116
|
+
type: string
|
|
117
|
+
/** The purpose of the proof (e.g., 'assertionMethod'). */
|
|
118
|
+
proofPurpose: string
|
|
119
|
+
/** URI of the verification method used to create the proof. */
|
|
120
|
+
verificationMethod: string
|
|
121
|
+
/** ISO 8601 datetime when the proof was created. */
|
|
122
|
+
created: string
|
|
123
|
+
/** The proof value (e.g., base64-encoded signature). */
|
|
124
|
+
proofValue: string
|
|
125
|
+
/** The cryptographic suite used (e.g., 'eddsa-rdfc-2022'). */
|
|
126
|
+
cryptosuite?: string
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Schema reference for validating credentials.
|
|
131
|
+
*/
|
|
132
|
+
interface ClrCredentialSchema {
|
|
133
|
+
/** URI of the credential schema. */
|
|
134
|
+
id: string
|
|
135
|
+
/** Schema validator type. */
|
|
136
|
+
type: '1EdTechJsonSchemaValidator2019'
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
140
|
+
// ACHIEVEMENT TYPES
|
|
141
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Criteria for earning an achievement.
|
|
145
|
+
*/
|
|
146
|
+
interface AchievementCriteria {
|
|
147
|
+
/** The URI of a webpage that describes the criteria. */
|
|
148
|
+
id?: string
|
|
149
|
+
/** A narrative of what is needed to earn the achievement. */
|
|
150
|
+
narrative?: string
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* An achievement that a learner has earned.
|
|
155
|
+
*
|
|
156
|
+
* Represents a competency, course completion, badge, or other accomplishment.
|
|
157
|
+
*/
|
|
158
|
+
interface Achievement {
|
|
159
|
+
/** URI identifier for the achievement. */
|
|
160
|
+
id: string
|
|
161
|
+
/** Type identifiers (e.g., ['Achievement']). */
|
|
162
|
+
type: string[]
|
|
163
|
+
/** Display name of the achievement. */
|
|
164
|
+
name: string
|
|
165
|
+
/** Description of the achievement. */
|
|
166
|
+
description: string
|
|
167
|
+
/** Criteria for earning the achievement. */
|
|
168
|
+
criteria: AchievementCriteria
|
|
169
|
+
/** Image associated with the achievement. */
|
|
170
|
+
image?: ClrImage
|
|
171
|
+
/** Classification of the achievement. */
|
|
172
|
+
achievementType?: AchievementType
|
|
173
|
+
/** The profile of the entity that created the achievement. */
|
|
174
|
+
creator?: ClrProfile
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
178
|
+
// IDENTITY TYPES
|
|
179
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Identity object for the credential subject.
|
|
183
|
+
*
|
|
184
|
+
* Used to identify the learner, optionally with hashed identity for privacy.
|
|
185
|
+
*/
|
|
186
|
+
interface IdentityObject {
|
|
187
|
+
/** MUST be 'IdentityObject'. */
|
|
188
|
+
type: 'IdentityObject'
|
|
189
|
+
/** The identity hash (or plain value if not hashed). */
|
|
190
|
+
identityHash: string
|
|
191
|
+
/** The type of identity (e.g., 'emailAddress', 'sourcedId'). */
|
|
192
|
+
identityType: string
|
|
193
|
+
/** Whether the identityHash is hashed. */
|
|
194
|
+
hashed: boolean
|
|
195
|
+
/** Salt used for hashing, if applicable. */
|
|
196
|
+
salt?: string
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
200
|
+
// ASSOCIATION TYPES
|
|
201
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Association between two achievements or credentials.
|
|
205
|
+
*/
|
|
206
|
+
interface Association {
|
|
207
|
+
/** MUST be 'Association'. */
|
|
208
|
+
type: 'Association'
|
|
209
|
+
/** The type of association. */
|
|
210
|
+
associationType: AssociationType
|
|
211
|
+
/** URI of the source entity. */
|
|
212
|
+
sourceId: string
|
|
213
|
+
/** URI of the target entity. */
|
|
214
|
+
targetId: string
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
218
|
+
// VERIFIABLE CREDENTIAL (NESTED)
|
|
219
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Credential subject for a nested verifiable credential.
|
|
223
|
+
*/
|
|
224
|
+
interface NestedCredentialSubject {
|
|
225
|
+
/** URI identifier for the subject. */
|
|
226
|
+
id?: string
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* A verifiable credential nested within a CLR.
|
|
231
|
+
*
|
|
232
|
+
* Represents individual assertions (e.g., AchievementCredentials,
|
|
233
|
+
* OpenBadgeCredentials) packaged inside the CLR.
|
|
234
|
+
*/
|
|
235
|
+
interface VerifiableCredential {
|
|
236
|
+
/** JSON-LD context URIs. */
|
|
237
|
+
'@context': string[]
|
|
238
|
+
/** URI identifier for the credential. */
|
|
239
|
+
id: string
|
|
240
|
+
/** Type identifiers (e.g., ['VerifiableCredential', 'AchievementCredential']). */
|
|
241
|
+
type: string[]
|
|
242
|
+
/** The issuer of this credential. */
|
|
243
|
+
issuer: ClrProfile
|
|
244
|
+
/** ISO 8601 datetime from which the credential is valid. */
|
|
245
|
+
validFrom: string
|
|
246
|
+
/** ISO 8601 datetime until which the credential is valid. */
|
|
247
|
+
validUntil?: string
|
|
248
|
+
/** The subject of the credential. */
|
|
249
|
+
credentialSubject: NestedCredentialSubject
|
|
250
|
+
/** Cryptographic proofs for this credential. */
|
|
251
|
+
proof?: ClrProof[]
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
255
|
+
// CREDENTIAL SUBJECT
|
|
256
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* The subject of a CLR credential.
|
|
260
|
+
*
|
|
261
|
+
* Contains the learner's identity, achievements, nested credentials,
|
|
262
|
+
* and associations between them.
|
|
263
|
+
*/
|
|
264
|
+
interface ClrCredentialSubject {
|
|
265
|
+
/** URI identifier for the credential subject (the learner). */
|
|
266
|
+
id?: string
|
|
267
|
+
/** Type identifiers (e.g., ['ClrSubject']). */
|
|
268
|
+
type: string[]
|
|
269
|
+
/** Identity objects for the learner. */
|
|
270
|
+
identifier?: IdentityObject[]
|
|
271
|
+
/** Achievements earned by the learner. */
|
|
272
|
+
achievement?: Achievement[]
|
|
273
|
+
/** Individual verifiable credentials packaged in the CLR. */
|
|
274
|
+
verifiableCredential: VerifiableCredential[]
|
|
275
|
+
/** Associations between achievements or credentials. */
|
|
276
|
+
association?: Association[]
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
280
|
+
// CLR CREDENTIAL
|
|
281
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* A Comprehensive Learner Record (CLR) v2.0 Verifiable Credential.
|
|
285
|
+
*
|
|
286
|
+
* The top-level data structure representing a learner's full set of
|
|
287
|
+
* achievements issued by one or more learning providers. The platform
|
|
288
|
+
* acts as the publisher, digitally signing the CLR to ensure authenticity.
|
|
289
|
+
*
|
|
290
|
+
* Required fields for upsert: `@context`, `id`, `type`, `issuer`, `name`,
|
|
291
|
+
* `validFrom`, `credentialSubject`.
|
|
292
|
+
*/
|
|
293
|
+
interface ClrCredential {
|
|
294
|
+
/** JSON-LD context URIs. */
|
|
295
|
+
'@context': string[]
|
|
296
|
+
/** URI identifier for the CLR credential. */
|
|
297
|
+
id: string
|
|
298
|
+
/** Type identifiers (e.g., ['VerifiableCredential', 'ClrCredential']). */
|
|
299
|
+
type: string[]
|
|
300
|
+
/** The issuer (publisher) of the CLR. */
|
|
301
|
+
issuer: ClrProfile
|
|
302
|
+
/** Display name of the CLR. */
|
|
303
|
+
name: string
|
|
304
|
+
/** Description of the CLR. */
|
|
305
|
+
description?: string
|
|
306
|
+
/** ISO 8601 datetime from which the CLR is valid. */
|
|
307
|
+
validFrom: string
|
|
308
|
+
/** ISO 8601 datetime until which the CLR is valid. */
|
|
309
|
+
validUntil?: string
|
|
310
|
+
/** The learner and their achievements/credentials. */
|
|
311
|
+
credentialSubject: ClrCredentialSubject
|
|
312
|
+
/** Cryptographic proofs added by the platform. */
|
|
313
|
+
proof?: ClrProof[]
|
|
314
|
+
/** Schema references for credential validation. */
|
|
315
|
+
credentialSchema?: ClrCredentialSchema[]
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* CLR Discovery Types
|
|
320
|
+
*
|
|
321
|
+
* Types for the CLR v2.0 API discovery endpoint.
|
|
322
|
+
*/
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Response from the CLR discovery endpoint.
|
|
326
|
+
*
|
|
327
|
+
* Returns the OpenAPI 3.0 specification for the CLR v2.0 API,
|
|
328
|
+
* including available endpoints, OAuth2 flows, and supported scopes.
|
|
329
|
+
* This is a public endpoint (no auth required).
|
|
330
|
+
*/
|
|
331
|
+
type DiscoveryResponse = Record<string, unknown>
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Transport interface for CLR client.
|
|
335
|
+
*
|
|
336
|
+
* Extends base transport requirements with CLR-specific paths.
|
|
337
|
+
* Required when using transport mode with ClrClient.
|
|
338
|
+
*/
|
|
339
|
+
interface ClrTransportLike {
|
|
340
|
+
/** Base URL of the API */
|
|
341
|
+
baseUrl: string;
|
|
342
|
+
/** API path profiles for CLR operations */
|
|
343
|
+
paths: ClrPaths;
|
|
344
|
+
/** Make an authenticated request */
|
|
345
|
+
request<T>(path: string, options?: RequestOptions): Promise<T>;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* All supported CLR client configuration types.
|
|
349
|
+
*
|
|
350
|
+
* Supports four modes:
|
|
351
|
+
* - **Provider mode**: `{ provider: TimebackProvider }` — pre-built provider with token sharing
|
|
352
|
+
* - **Environment mode**: `{ platform?, env, auth }` — Timeback hosted APIs
|
|
353
|
+
* - **Explicit mode**: `{ baseUrl, auth: { authUrl } }` — custom API URLs
|
|
354
|
+
* - **Transport mode**: `{ transport }` — custom transport with paths
|
|
355
|
+
*/
|
|
356
|
+
type ClrClientConfig = ClientConfig | TransportOnlyConfig<ClrTransportLike> | ProviderClientConfig;
|
|
357
|
+
/**
|
|
358
|
+
* Configuration for CLR transport.
|
|
359
|
+
*/
|
|
360
|
+
interface ClrTransportConfig extends TransportConfigWithTokenProvider {
|
|
361
|
+
/** API path profiles for CLR operations */
|
|
362
|
+
paths: ClrPaths;
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Instance type of ClrClient.
|
|
366
|
+
*/
|
|
367
|
+
type ClrClientInstance = InstanceType<typeof ClrClient>;
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Credentials Resource
|
|
371
|
+
*
|
|
372
|
+
* Manage CLR (Comprehensive Learner Record) credentials.
|
|
373
|
+
*/
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Credentials resource for CLR credential management.
|
|
377
|
+
*
|
|
378
|
+
* Provides the ability to upsert verifiable CLR credentials.
|
|
379
|
+
* The platform acts as the publisher, digitally signing credentials
|
|
380
|
+
* to ensure their authenticity and integrity.
|
|
381
|
+
*/
|
|
382
|
+
declare class CredentialsResource {
|
|
383
|
+
private readonly transport;
|
|
384
|
+
constructor(transport: ClrTransportLike);
|
|
385
|
+
/**
|
|
386
|
+
* Upsert a Comprehensive Learner Record (CLR) credential.
|
|
387
|
+
*
|
|
388
|
+
* Creates a new credential or updates an existing one based on the credential ID.
|
|
389
|
+
* The platform will digitally sign the credential, adding a cryptographic proof
|
|
390
|
+
* to ensure authenticity.
|
|
391
|
+
*
|
|
392
|
+
* @param credential - The CLR credential to upsert
|
|
393
|
+
* @returns The upserted credential with platform-added proof
|
|
394
|
+
*
|
|
395
|
+
* @example
|
|
396
|
+
* ```typescript
|
|
397
|
+
* const result = await client.credentials.upsert({
|
|
398
|
+
* '@context': [
|
|
399
|
+
* 'https://www.w3.org/ns/credentials/v2',
|
|
400
|
+
* 'https://purl.imsglobal.org/spec/clr/v2p0/context-2.0.1',
|
|
401
|
+
* ],
|
|
402
|
+
* id: 'urn:uuid:example-clr-id',
|
|
403
|
+
* type: ['VerifiableCredential', 'ClrCredential'],
|
|
404
|
+
* issuer: {
|
|
405
|
+
* id: 'https://example.edu',
|
|
406
|
+
* type: ['Profile'],
|
|
407
|
+
* name: 'Example University',
|
|
408
|
+
* },
|
|
409
|
+
* name: 'Student Transcript',
|
|
410
|
+
* validFrom: '2024-01-01T00:00:00Z',
|
|
411
|
+
* credentialSubject: {
|
|
412
|
+
* type: ['ClrSubject'],
|
|
413
|
+
* verifiableCredential: [
|
|
414
|
+
* // nested credentials...
|
|
415
|
+
* ],
|
|
416
|
+
* },
|
|
417
|
+
* })
|
|
418
|
+
* ```
|
|
419
|
+
*/
|
|
420
|
+
upsert(credential: ClrCredential): Promise<ClrCredential>;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Discovery Resource
|
|
425
|
+
*
|
|
426
|
+
* CLR v2.0 API discovery endpoint.
|
|
427
|
+
*/
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* Discovery resource for CLR API capabilities.
|
|
431
|
+
*
|
|
432
|
+
* Provides access to the CLR v2.0 API discovery endpoint,
|
|
433
|
+
* which returns the OpenAPI specification including available
|
|
434
|
+
* endpoints, OAuth2 flows, and supported scopes.
|
|
435
|
+
*
|
|
436
|
+
* NOTE: The CLR v2.0 spec declares this endpoint as public (`security: []`),
|
|
437
|
+
* but the BeyondAI implementation enforces OAuth authentication. This client
|
|
438
|
+
* sends credentials on all requests, so this is handled transparently.
|
|
439
|
+
*/
|
|
440
|
+
declare class DiscoveryResource {
|
|
441
|
+
private readonly transport;
|
|
442
|
+
constructor(transport: ClrTransportLike);
|
|
443
|
+
/**
|
|
444
|
+
* Get CLR v2.0 API discovery information.
|
|
445
|
+
*
|
|
446
|
+
* Returns the OpenAPI 3.0 specification for the CLR v2.0 API,
|
|
447
|
+
* allowing clients to dynamically discover the service's capabilities.
|
|
448
|
+
*
|
|
449
|
+
* NOTE: Despite the spec declaring this as a public endpoint, the
|
|
450
|
+
* BeyondAI API requires authentication. An authenticated transport
|
|
451
|
+
* is required.
|
|
452
|
+
*
|
|
453
|
+
* @returns Discovery information (OpenAPI spec object)
|
|
454
|
+
*
|
|
455
|
+
* @example
|
|
456
|
+
* ```typescript
|
|
457
|
+
* const discovery = await client.discovery.get()
|
|
458
|
+
* console.log(discovery) // OpenAPI 3.0 spec
|
|
459
|
+
* ```
|
|
460
|
+
*/
|
|
461
|
+
get(): Promise<DiscoveryResponse>;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* CLR Client
|
|
466
|
+
*
|
|
467
|
+
* Main entry point for the CLR SDK.
|
|
468
|
+
*/
|
|
469
|
+
/**
|
|
470
|
+
* CLR API client for Comprehensive Learner Record management.
|
|
471
|
+
*
|
|
472
|
+
* Provides access to CLR endpoints including credential upsert
|
|
473
|
+
* and API discovery.
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* ```typescript
|
|
477
|
+
* // Environment mode (Timeback APIs)
|
|
478
|
+
* const client = new ClrClient({
|
|
479
|
+
* env: 'staging', // or 'production'
|
|
480
|
+
* auth: {
|
|
481
|
+
* clientId: 'your-client-id',
|
|
482
|
+
* clientSecret: 'your-client-secret',
|
|
483
|
+
* },
|
|
484
|
+
* })
|
|
485
|
+
* ```
|
|
486
|
+
*
|
|
487
|
+
* @example
|
|
488
|
+
* ```typescript
|
|
489
|
+
* // Provider mode (shared tokens)
|
|
490
|
+
* import { TimebackProvider } from '@timeback/internal-client-infra'
|
|
491
|
+
*
|
|
492
|
+
* const provider = new TimebackProvider({
|
|
493
|
+
* platform: 'BEYOND_AI',
|
|
494
|
+
* env: 'staging',
|
|
495
|
+
* auth: { clientId: '...', clientSecret: '...' },
|
|
496
|
+
* })
|
|
497
|
+
*
|
|
498
|
+
* const client = new ClrClient({ provider })
|
|
499
|
+
* ```
|
|
500
|
+
*
|
|
501
|
+
* @example
|
|
502
|
+
* ```typescript
|
|
503
|
+
* // Explicit mode (custom API)
|
|
504
|
+
* const client = new ClrClient({
|
|
505
|
+
* baseUrl: 'https://api.example.com',
|
|
506
|
+
* auth: {
|
|
507
|
+
* clientId: 'your-client-id',
|
|
508
|
+
* clientSecret: 'your-client-secret',
|
|
509
|
+
* authUrl: 'https://auth.example.com/oauth2/token',
|
|
510
|
+
* },
|
|
511
|
+
* })
|
|
512
|
+
* ```
|
|
513
|
+
*
|
|
514
|
+
* @example
|
|
515
|
+
* ```typescript
|
|
516
|
+
* // Environment variables fallback
|
|
517
|
+
* // Set CLR_BASE_URL, CLR_TOKEN_URL,
|
|
518
|
+
* // CLR_CLIENT_ID, CLR_CLIENT_SECRET
|
|
519
|
+
* const client = new ClrClient()
|
|
520
|
+
* ```
|
|
521
|
+
*/
|
|
522
|
+
declare const ClrClient: {
|
|
523
|
+
new (config?: ClrClientConfig): {
|
|
524
|
+
readonly transport: ClrTransportLike;
|
|
525
|
+
readonly _provider?: _timeback_internal_client_infra.TimebackProvider | undefined;
|
|
526
|
+
readonly credentials: CredentialsResource;
|
|
527
|
+
readonly discovery: DiscoveryResource;
|
|
528
|
+
getTransport(): ClrTransportLike;
|
|
529
|
+
checkAuth(): Promise<_timeback_internal_client_infra.AuthCheckResult>;
|
|
530
|
+
};
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
/**
|
|
534
|
+
* CLR Client Factory
|
|
535
|
+
*
|
|
536
|
+
* Creates ClrClient classes bound to specific provider registries.
|
|
537
|
+
*/
|
|
538
|
+
|
|
539
|
+
/**
|
|
540
|
+
* Create a ClrClient class bound to a specific provider registry.
|
|
541
|
+
*
|
|
542
|
+
* @param registry - Provider registry to use (defaults to all Timeback platforms)
|
|
543
|
+
* @returns ClrClient class bound to the registry
|
|
544
|
+
*/
|
|
545
|
+
declare function createClrClient(registry?: ProviderRegistry): {
|
|
546
|
+
new (config?: ClrClientConfig): {
|
|
547
|
+
/** @internal */
|
|
548
|
+
readonly transport: ClrTransportLike;
|
|
549
|
+
/** @internal */
|
|
550
|
+
readonly _provider?: TimebackProvider | undefined;
|
|
551
|
+
/** Upsert and manage CLR verifiable credentials */
|
|
552
|
+
readonly credentials: CredentialsResource;
|
|
553
|
+
/** Discover CLR API capabilities and endpoints */
|
|
554
|
+
readonly discovery: DiscoveryResource;
|
|
555
|
+
/**
|
|
556
|
+
* Get the underlying transport for advanced use cases.
|
|
557
|
+
* @returns The transport instance used by this client
|
|
558
|
+
*/
|
|
559
|
+
getTransport(): ClrTransportLike;
|
|
560
|
+
/**
|
|
561
|
+
* Verify that OAuth authentication is working.
|
|
562
|
+
* @returns Auth check result
|
|
563
|
+
* @throws {Error} If client was initialized with custom transport (no provider)
|
|
564
|
+
*/
|
|
565
|
+
checkAuth(): Promise<AuthCheckResult>;
|
|
566
|
+
};
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
/**
|
|
570
|
+
* Transport Layer
|
|
571
|
+
*
|
|
572
|
+
* HTTP transport for CLR API communication.
|
|
573
|
+
*/
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* HTTP transport layer for CLR API communication.
|
|
577
|
+
*
|
|
578
|
+
* CLR uses the IMS Global error format, which is handled by the
|
|
579
|
+
* base transport's built-in IMS error parsing. No custom pagination
|
|
580
|
+
* is needed since CLR endpoints don't return paginated results.
|
|
581
|
+
*/
|
|
582
|
+
declare class Transport extends BaseTransport {
|
|
583
|
+
/** API path profiles for CLR operations */
|
|
584
|
+
readonly paths: ClrPaths;
|
|
585
|
+
constructor(config: ClrTransportConfig);
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
export { ClrClient, Transport, createClrClient };
|
|
589
|
+
export type { Achievement, AchievementCriteria, AchievementType, Association, AssociationType, ClrClientConfig, ClrClientInstance, ClrCredential, ClrCredentialSchema, ClrCredentialSubject, ClrImage, ClrProfile, ClrProof, DiscoveryResponse, IdentityObject, NestedCredentialSubject, VerifiableCredential };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAMH,OAAO,EAAE,SAAS,EAAE,KAAK,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAE3C,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAMrD,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAExE,YAAY,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAA;AAEtE,YAAY,EACX,WAAW,EACX,mBAAmB,EACnB,eAAe,EACf,WAAW,EACX,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,iBAAiB,EACjB,cAAc,EACd,uBAAuB,EACvB,oBAAoB,GACpB,MAAM,+BAA+B,CAAA;AAMtC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA"}
|