@lti-tool/core 0.9.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/CHANGELOG.md +15 -0
- package/README.md +60 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/interfaces/index.d.ts +7 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/index.js +1 -0
- package/dist/interfaces/jwks.d.ts +18 -0
- package/dist/interfaces/jwks.d.ts.map +1 -0
- package/dist/interfaces/jwks.js +1 -0
- package/dist/interfaces/ltiClient.d.ts +24 -0
- package/dist/interfaces/ltiClient.d.ts.map +1 -0
- package/dist/interfaces/ltiClient.js +1 -0
- package/dist/interfaces/ltiConfig.d.ts +26 -0
- package/dist/interfaces/ltiConfig.d.ts.map +1 -0
- package/dist/interfaces/ltiConfig.js +1 -0
- package/dist/interfaces/ltiDeployment.d.ts +15 -0
- package/dist/interfaces/ltiDeployment.d.ts.map +1 -0
- package/dist/interfaces/ltiDeployment.js +1 -0
- package/dist/interfaces/ltiLaunchConfig.d.ts +19 -0
- package/dist/interfaces/ltiLaunchConfig.d.ts.map +1 -0
- package/dist/interfaces/ltiLaunchConfig.js +1 -0
- package/dist/interfaces/ltiSession.d.ts +110 -0
- package/dist/interfaces/ltiSession.d.ts.map +1 -0
- package/dist/interfaces/ltiSession.js +1 -0
- package/dist/interfaces/ltiStorage.d.ts +122 -0
- package/dist/interfaces/ltiStorage.d.ts.map +1 -0
- package/dist/interfaces/ltiStorage.js +1 -0
- package/dist/ltiTool.d.ts +184 -0
- package/dist/ltiTool.d.ts.map +1 -0
- package/dist/ltiTool.js +305 -0
- package/dist/schemas/client.schema.d.ts +33 -0
- package/dist/schemas/client.schema.d.ts.map +1 -0
- package/dist/schemas/client.schema.js +14 -0
- package/dist/schemas/common.schema.d.ts +6 -0
- package/dist/schemas/common.schema.d.ts.map +1 -0
- package/dist/schemas/common.schema.js +5 -0
- package/dist/schemas/deployment.schema.d.ts +8 -0
- package/dist/schemas/deployment.schema.d.ts.map +1 -0
- package/dist/schemas/deployment.schema.js +11 -0
- package/dist/schemas/index.d.ts +5 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +4 -0
- package/dist/schemas/lti13/ags/scoreSubmission.schema.d.ts +34 -0
- package/dist/schemas/lti13/ags/scoreSubmission.schema.d.ts.map +1 -0
- package/dist/schemas/lti13/ags/scoreSubmission.schema.js +41 -0
- package/dist/schemas/lti13/claims/baseJwtClaims.schema.d.ts +11 -0
- package/dist/schemas/lti13/claims/baseJwtClaims.schema.d.ts.map +1 -0
- package/dist/schemas/lti13/claims/baseJwtClaims.schema.js +10 -0
- package/dist/schemas/lti13/claims/contextClaims.schema.d.ts +11 -0
- package/dist/schemas/lti13/claims/contextClaims.schema.d.ts.map +1 -0
- package/dist/schemas/lti13/claims/contextClaims.schema.js +14 -0
- package/dist/schemas/lti13/claims/coreLtiClaims.schema.d.ts +9 -0
- package/dist/schemas/lti13/claims/coreLtiClaims.schema.d.ts.map +1 -0
- package/dist/schemas/lti13/claims/coreLtiClaims.schema.js +11 -0
- package/dist/schemas/lti13/claims/platformClaims.schema.d.ts +19 -0
- package/dist/schemas/lti13/claims/platformClaims.schema.d.ts.map +1 -0
- package/dist/schemas/lti13/claims/platformClaims.schema.js +24 -0
- package/dist/schemas/lti13/claims/privacyClaims.schema.d.ts +8 -0
- package/dist/schemas/lti13/claims/privacyClaims.schema.d.ts.map +1 -0
- package/dist/schemas/lti13/claims/privacyClaims.schema.js +7 -0
- package/dist/schemas/lti13/claims/serviceClaims.schema.d.ts +20 -0
- package/dist/schemas/lti13/claims/serviceClaims.schema.d.ts.map +1 -0
- package/dist/schemas/lti13/claims/serviceClaims.schema.js +25 -0
- package/dist/schemas/lti13/lti13JwtPayload.schema.d.ts +66 -0
- package/dist/schemas/lti13/lti13JwtPayload.schema.d.ts.map +1 -0
- package/dist/schemas/lti13/lti13JwtPayload.schema.js +22 -0
- package/dist/schemas/lti13/lti13Launch.schema.d.ts +14 -0
- package/dist/schemas/lti13/lti13Launch.schema.d.ts.map +1 -0
- package/dist/schemas/lti13/lti13Launch.schema.js +13 -0
- package/dist/schemas/lti13/lti13Login.schema.d.ts +23 -0
- package/dist/schemas/lti13/lti13Login.schema.d.ts.map +1 -0
- package/dist/schemas/lti13/lti13Login.schema.js +16 -0
- package/dist/services/ags.service.d.ts +38 -0
- package/dist/services/ags.service.d.ts.map +1 -0
- package/dist/services/ags.service.js +69 -0
- package/dist/services/session.service.d.ts +11 -0
- package/dist/services/session.service.d.ts.map +1 -0
- package/dist/services/session.service.js +103 -0
- package/dist/services/token.service.d.ts +36 -0
- package/dist/services/token.service.d.ts.map +1 -0
- package/dist/services/token.service.js +74 -0
- package/dist/utils/launchConfigValidation.d.ts +3 -0
- package/dist/utils/launchConfigValidation.d.ts.map +1 -0
- package/dist/utils/launchConfigValidation.js +7 -0
- package/package.json +53 -0
- package/src/index.ts +3 -0
- package/src/interfaces/index.ts +6 -0
- package/src/interfaces/jwks.ts +20 -0
- package/src/interfaces/ltiClient.ts +24 -0
- package/src/interfaces/ltiConfig.ts +31 -0
- package/src/interfaces/ltiDeployment.ts +17 -0
- package/src/interfaces/ltiLaunchConfig.ts +23 -0
- package/src/interfaces/ltiSession.ts +119 -0
- package/src/interfaces/ltiStorage.ts +161 -0
- package/src/ltiTool.ts +394 -0
- package/src/schemas/client.schema.ts +17 -0
- package/src/schemas/common.schema.ts +7 -0
- package/src/schemas/deployment.schema.ts +12 -0
- package/src/schemas/index.ts +10 -0
- package/src/schemas/lti13/ags/scoreSubmission.schema.ts +54 -0
- package/src/schemas/lti13/claims/baseJwtClaims.schema.ts +11 -0
- package/src/schemas/lti13/claims/contextClaims.schema.ts +16 -0
- package/src/schemas/lti13/claims/coreLtiClaims.schema.ts +12 -0
- package/src/schemas/lti13/claims/platformClaims.schema.ts +27 -0
- package/src/schemas/lti13/claims/privacyClaims.schema.ts +8 -0
- package/src/schemas/lti13/claims/serviceClaims.schema.ts +28 -0
- package/src/schemas/lti13/lti13JwtPayload.schema.ts +36 -0
- package/src/schemas/lti13/lti13Launch.schema.ts +15 -0
- package/src/schemas/lti13/lti13Login.schema.ts +18 -0
- package/src/services/ags.service.ts +92 -0
- package/src/services/session.service.ts +115 -0
- package/src/services/token.service.ts +84 -0
- package/src/utils/launchConfigValidation.ts +16 -0
- package/tsconfig.json +8 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Schema for submitting grades via LTI Assignment and Grade Services (AGS).
|
|
4
|
+
* Validates score data according to LTI AGS v2.0 specification.
|
|
5
|
+
*
|
|
6
|
+
* @see https://www.imsglobal.org/spec/lti-ags/v2p0/#score-publish-service
|
|
7
|
+
*/
|
|
8
|
+
export const ScoreSubmissionSchema = z.object({
|
|
9
|
+
/** Points awarded to the student (must be non-negative) */
|
|
10
|
+
scoreGiven: z.number().min(0),
|
|
11
|
+
/** Maximum possible points for this assignment (must be non-negative) */
|
|
12
|
+
scoreMaximum: z.number().min(0),
|
|
13
|
+
/** Optional feedback comment to display to the student */
|
|
14
|
+
comment: z.string().optional(),
|
|
15
|
+
/** User ID to submit score for (optional - defaults to session user if not provided) */
|
|
16
|
+
userId: z.string().optional(),
|
|
17
|
+
/** Timestamp when score was generated (optional - defaults to current time) */
|
|
18
|
+
timestamp: z.iso.datetime().optional(),
|
|
19
|
+
/**
|
|
20
|
+
* Student's progress on the activity itself.
|
|
21
|
+
* - Initialized: Student has started but not made progress
|
|
22
|
+
* - Started: Student has begun working
|
|
23
|
+
* - InProgress: Student is actively working
|
|
24
|
+
* - Submitted: Student has submitted work for review
|
|
25
|
+
* - Completed: Student has finished the activity
|
|
26
|
+
*/
|
|
27
|
+
activityProgress: z
|
|
28
|
+
.enum(['Initialized', 'Started', 'InProgress', 'Submitted', 'Completed'])
|
|
29
|
+
.default('Completed'),
|
|
30
|
+
/**
|
|
31
|
+
* Instructor's progress on grading the submission.
|
|
32
|
+
* - NotReady: Submission not ready for grading
|
|
33
|
+
* - Failed: Grading failed due to error
|
|
34
|
+
* - Pending: Awaiting automatic grading
|
|
35
|
+
* - PendingManual: Awaiting manual grading
|
|
36
|
+
* - FullyGraded: Grading is complete
|
|
37
|
+
*/
|
|
38
|
+
gradingProgress: z
|
|
39
|
+
.enum(['NotReady', 'Failed', 'Pending', 'PendingManual', 'FullyGraded'])
|
|
40
|
+
.default('FullyGraded'),
|
|
41
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const BaseJwtClaimsSchema: z.ZodObject<{
|
|
3
|
+
iss: z.ZodString;
|
|
4
|
+
sub: z.ZodString;
|
|
5
|
+
aud: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
6
|
+
exp: z.ZodNumber;
|
|
7
|
+
iat: z.ZodNumber;
|
|
8
|
+
nbf: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
nonce: z.ZodString;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
//# sourceMappingURL=baseJwtClaims.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseJwtClaims.schema.d.ts","sourceRoot":"","sources":["../../../../src/schemas/lti13/claims/baseJwtClaims.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,mBAAmB;;;;;;;;iBAQ9B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ResourceLinkSchema: z.ZodOptional<z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
title: z.ZodOptional<z.ZodString>;
|
|
5
|
+
}, z.core.$strip>>;
|
|
6
|
+
export declare const ContextSchema: z.ZodOptional<z.ZodObject<{
|
|
7
|
+
id: z.ZodString;
|
|
8
|
+
label: z.ZodOptional<z.ZodString>;
|
|
9
|
+
title: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>>;
|
|
11
|
+
//# sourceMappingURL=contextClaims.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contextClaims.schema.d.ts","sourceRoot":"","sources":["../../../../src/schemas/lti13/claims/contextClaims.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,kBAAkB;;;kBAKlB,CAAC;AAEd,eAAO,MAAM,aAAa;;;;kBAMb,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const ResourceLinkSchema = z
|
|
3
|
+
.object({
|
|
4
|
+
id: z.string(),
|
|
5
|
+
title: z.string().optional(),
|
|
6
|
+
})
|
|
7
|
+
.optional();
|
|
8
|
+
export const ContextSchema = z
|
|
9
|
+
.object({
|
|
10
|
+
id: z.string(),
|
|
11
|
+
label: z.string().optional(),
|
|
12
|
+
title: z.string().optional(),
|
|
13
|
+
})
|
|
14
|
+
.optional();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const CoreLtiClaimsSchema: z.ZodObject<{
|
|
3
|
+
'https://purl.imsglobal.org/spec/lti/claim/message_type': z.ZodUnion<readonly [z.ZodLiteral<"LtiResourceLinkRequest">, z.ZodLiteral<"LtiDeepLinkingRequest">]>;
|
|
4
|
+
'https://purl.imsglobal.org/spec/lti/claim/version': z.ZodLiteral<"1.3.0">;
|
|
5
|
+
'https://purl.imsglobal.org/spec/lti/claim/deployment_id': z.ZodString;
|
|
6
|
+
'https://purl.imsglobal.org/spec/lti/claim/target_link_uri': z.ZodString;
|
|
7
|
+
'https://purl.imsglobal.org/spec/lti/claim/roles': z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
//# sourceMappingURL=coreLtiClaims.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coreLtiClaims.schema.d.ts","sourceRoot":"","sources":["../../../../src/schemas/lti13/claims/coreLtiClaims.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,mBAAmB;;;;;;iBAS9B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const CoreLtiClaimsSchema = z.object({
|
|
3
|
+
'https://purl.imsglobal.org/spec/lti/claim/message_type': z.union([
|
|
4
|
+
z.literal('LtiResourceLinkRequest'),
|
|
5
|
+
z.literal('LtiDeepLinkingRequest'),
|
|
6
|
+
]),
|
|
7
|
+
'https://purl.imsglobal.org/spec/lti/claim/version': z.literal('1.3.0'),
|
|
8
|
+
'https://purl.imsglobal.org/spec/lti/claim/deployment_id': z.string(),
|
|
9
|
+
'https://purl.imsglobal.org/spec/lti/claim/target_link_uri': z.string(),
|
|
10
|
+
'https://purl.imsglobal.org/spec/lti/claim/roles': z.array(z.string()).optional(),
|
|
11
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ToolPlatformSchema: z.ZodOptional<z.ZodObject<{
|
|
3
|
+
guid: z.ZodString;
|
|
4
|
+
name: z.ZodOptional<z.ZodString>;
|
|
5
|
+
description: z.ZodOptional<z.ZodString>;
|
|
6
|
+
url: z.ZodOptional<z.ZodString>;
|
|
7
|
+
product_family_code: z.ZodOptional<z.ZodString>;
|
|
8
|
+
contact_email: z.ZodOptional<z.ZodString>;
|
|
9
|
+
version: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, z.core.$strip>>;
|
|
11
|
+
export declare const LaunchPresentationSchema: z.ZodOptional<z.ZodObject<{
|
|
12
|
+
target: z.ZodOptional<z.ZodString>;
|
|
13
|
+
url: z.ZodOptional<z.ZodString>;
|
|
14
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
15
|
+
}, z.core.$strip>>;
|
|
16
|
+
export declare const LisSchema: z.ZodOptional<z.ZodObject<{
|
|
17
|
+
person_sourcedid: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}, z.core.$strip>>;
|
|
19
|
+
//# sourceMappingURL=platformClaims.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platformClaims.schema.d.ts","sourceRoot":"","sources":["../../../../src/schemas/lti13/claims/platformClaims.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,kBAAkB;;;;;;;;kBAUlB,CAAC;AAEd,eAAO,MAAM,wBAAwB;;;;kBAMxB,CAAC;AAEd,eAAO,MAAM,SAAS;;kBAIT,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const ToolPlatformSchema = z
|
|
3
|
+
.object({
|
|
4
|
+
guid: z.string(),
|
|
5
|
+
name: z.string().optional(),
|
|
6
|
+
description: z.string().optional(),
|
|
7
|
+
url: z.string().optional(),
|
|
8
|
+
product_family_code: z.string().optional(),
|
|
9
|
+
contact_email: z.string().optional(),
|
|
10
|
+
version: z.string().optional(),
|
|
11
|
+
})
|
|
12
|
+
.optional();
|
|
13
|
+
export const LaunchPresentationSchema = z
|
|
14
|
+
.object({
|
|
15
|
+
target: z.string().optional(),
|
|
16
|
+
url: z.string().optional(),
|
|
17
|
+
locale: z.string().optional(),
|
|
18
|
+
})
|
|
19
|
+
.optional();
|
|
20
|
+
export const LisSchema = z
|
|
21
|
+
.object({
|
|
22
|
+
person_sourcedid: z.string().optional(),
|
|
23
|
+
})
|
|
24
|
+
.optional();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privacyClaims.schema.d.ts","sourceRoot":"","sources":["../../../../src/schemas/lti13/claims/privacyClaims.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,mBAAmB;;;;;iBAK9B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const AgsEndpointSchema: z.ZodOptional<z.ZodObject<{
|
|
3
|
+
scope: z.ZodArray<z.ZodString>;
|
|
4
|
+
lineitem: z.ZodOptional<z.ZodString>;
|
|
5
|
+
lineitems: z.ZodOptional<z.ZodString>;
|
|
6
|
+
}, z.core.$strip>>;
|
|
7
|
+
export declare const NrpsServiceSchema: z.ZodOptional<z.ZodObject<{
|
|
8
|
+
context_memberships_url: z.ZodString;
|
|
9
|
+
service_versions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
10
|
+
}, z.core.$strip>>;
|
|
11
|
+
export declare const DeepLinkingSettingsSchema: z.ZodOptional<z.ZodObject<{
|
|
12
|
+
deep_link_return_url: z.ZodString;
|
|
13
|
+
accept_types: z.ZodArray<z.ZodString>;
|
|
14
|
+
accept_presentation_document_targets: z.ZodArray<z.ZodString>;
|
|
15
|
+
accept_media_types: z.ZodOptional<z.ZodString>;
|
|
16
|
+
accept_multiple: z.ZodOptional<z.ZodBoolean>;
|
|
17
|
+
auto_create: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
+
data: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, z.core.$strip>>;
|
|
20
|
+
//# sourceMappingURL=serviceClaims.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serviceClaims.schema.d.ts","sourceRoot":"","sources":["../../../../src/schemas/lti13/claims/serviceClaims.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,iBAAiB;;;;kBAMjB,CAAC;AAEd,eAAO,MAAM,iBAAiB;;;kBAKjB,CAAC;AAEd,eAAO,MAAM,yBAAyB;;;;;;;;kBAUzB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const AgsEndpointSchema = z
|
|
3
|
+
.object({
|
|
4
|
+
scope: z.array(z.string()),
|
|
5
|
+
lineitem: z.string().optional(),
|
|
6
|
+
lineitems: z.string().optional(),
|
|
7
|
+
})
|
|
8
|
+
.optional();
|
|
9
|
+
export const NrpsServiceSchema = z
|
|
10
|
+
.object({
|
|
11
|
+
context_memberships_url: z.string(),
|
|
12
|
+
service_versions: z.array(z.string()).optional(),
|
|
13
|
+
})
|
|
14
|
+
.optional();
|
|
15
|
+
export const DeepLinkingSettingsSchema = z
|
|
16
|
+
.object({
|
|
17
|
+
deep_link_return_url: z.string(),
|
|
18
|
+
accept_types: z.array(z.string()),
|
|
19
|
+
accept_presentation_document_targets: z.array(z.string()),
|
|
20
|
+
accept_media_types: z.string().optional(),
|
|
21
|
+
accept_multiple: z.boolean().optional(),
|
|
22
|
+
auto_create: z.boolean().optional(),
|
|
23
|
+
data: z.string().optional(),
|
|
24
|
+
})
|
|
25
|
+
.optional();
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const LTI13JwtPayloadSchema: z.ZodObject<{
|
|
3
|
+
iss: z.ZodString;
|
|
4
|
+
sub: z.ZodString;
|
|
5
|
+
aud: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
6
|
+
exp: z.ZodNumber;
|
|
7
|
+
iat: z.ZodNumber;
|
|
8
|
+
nbf: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
nonce: z.ZodString;
|
|
10
|
+
given_name: z.ZodString;
|
|
11
|
+
family_name: z.ZodString;
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
email: z.ZodString;
|
|
14
|
+
'https://purl.imsglobal.org/spec/lti/claim/message_type': z.ZodUnion<readonly [z.ZodLiteral<"LtiResourceLinkRequest">, z.ZodLiteral<"LtiDeepLinkingRequest">]>;
|
|
15
|
+
'https://purl.imsglobal.org/spec/lti/claim/version': z.ZodLiteral<"1.3.0">;
|
|
16
|
+
'https://purl.imsglobal.org/spec/lti/claim/deployment_id': z.ZodString;
|
|
17
|
+
'https://purl.imsglobal.org/spec/lti/claim/target_link_uri': z.ZodString;
|
|
18
|
+
'https://purl.imsglobal.org/spec/lti/claim/roles': z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
19
|
+
'https://purl.imsglobal.org/spec/lti/claim/resource_link': z.ZodOptional<z.ZodObject<{
|
|
20
|
+
id: z.ZodString;
|
|
21
|
+
title: z.ZodOptional<z.ZodString>;
|
|
22
|
+
}, z.core.$strip>>;
|
|
23
|
+
'https://purl.imsglobal.org/spec/lti/claim/context': z.ZodOptional<z.ZodObject<{
|
|
24
|
+
id: z.ZodString;
|
|
25
|
+
label: z.ZodOptional<z.ZodString>;
|
|
26
|
+
title: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, z.core.$strip>>;
|
|
28
|
+
'https://purl.imsglobal.org/spec/lti/claim/tool_platform': z.ZodOptional<z.ZodObject<{
|
|
29
|
+
guid: z.ZodString;
|
|
30
|
+
name: z.ZodOptional<z.ZodString>;
|
|
31
|
+
description: z.ZodOptional<z.ZodString>;
|
|
32
|
+
url: z.ZodOptional<z.ZodString>;
|
|
33
|
+
product_family_code: z.ZodOptional<z.ZodString>;
|
|
34
|
+
contact_email: z.ZodOptional<z.ZodString>;
|
|
35
|
+
version: z.ZodOptional<z.ZodString>;
|
|
36
|
+
}, z.core.$strip>>;
|
|
37
|
+
'https://purl.imsglobal.org/spec/lti/claim/lis': z.ZodOptional<z.ZodObject<{
|
|
38
|
+
person_sourcedid: z.ZodOptional<z.ZodString>;
|
|
39
|
+
}, z.core.$strip>>;
|
|
40
|
+
'https://purl.imsglobal.org/spec/lti/claim/launch_presentation': z.ZodOptional<z.ZodObject<{
|
|
41
|
+
target: z.ZodOptional<z.ZodString>;
|
|
42
|
+
url: z.ZodOptional<z.ZodString>;
|
|
43
|
+
locale: z.ZodOptional<z.ZodString>;
|
|
44
|
+
}, z.core.$strip>>;
|
|
45
|
+
'https://purl.imsglobal.org/spec/lti/claim/custom': z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
46
|
+
'https://purl.imsglobal.org/spec/lti-ags/claim/endpoint': z.ZodOptional<z.ZodObject<{
|
|
47
|
+
scope: z.ZodArray<z.ZodString>;
|
|
48
|
+
lineitem: z.ZodOptional<z.ZodString>;
|
|
49
|
+
lineitems: z.ZodOptional<z.ZodString>;
|
|
50
|
+
}, z.core.$strip>>;
|
|
51
|
+
'https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice': z.ZodOptional<z.ZodObject<{
|
|
52
|
+
context_memberships_url: z.ZodString;
|
|
53
|
+
service_versions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
54
|
+
}, z.core.$strip>>;
|
|
55
|
+
'https://purl.imsglobal.org/spec/lti-dl/claim/deep_linking_settings': z.ZodOptional<z.ZodObject<{
|
|
56
|
+
deep_link_return_url: z.ZodString;
|
|
57
|
+
accept_types: z.ZodArray<z.ZodString>;
|
|
58
|
+
accept_presentation_document_targets: z.ZodArray<z.ZodString>;
|
|
59
|
+
accept_media_types: z.ZodOptional<z.ZodString>;
|
|
60
|
+
accept_multiple: z.ZodOptional<z.ZodBoolean>;
|
|
61
|
+
auto_create: z.ZodOptional<z.ZodBoolean>;
|
|
62
|
+
data: z.ZodOptional<z.ZodString>;
|
|
63
|
+
}, z.core.$strip>>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
export type LTI13JwtPayload = z.infer<typeof LTI13JwtPayloadSchema>;
|
|
66
|
+
//# sourceMappingURL=lti13JwtPayload.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lti13JwtPayload.schema.d.ts","sourceRoot":"","sources":["../../../src/schemas/lti13/lti13JwtPayload.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiBxB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgB9B,CAAC;AAEL,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { BaseJwtClaimsSchema } from './claims/baseJwtClaims.schema.js';
|
|
3
|
+
import { ContextSchema, ResourceLinkSchema } from './claims/contextClaims.schema.js';
|
|
4
|
+
import { CoreLtiClaimsSchema } from './claims/coreLtiClaims.schema.js';
|
|
5
|
+
import { LaunchPresentationSchema, LisSchema, ToolPlatformSchema, } from './claims/platformClaims.schema.js';
|
|
6
|
+
import { PrivacyClaimsSchema } from './claims/privacyClaims.schema.js';
|
|
7
|
+
import { AgsEndpointSchema, DeepLinkingSettingsSchema, NrpsServiceSchema, } from './claims/serviceClaims.schema.js';
|
|
8
|
+
export const LTI13JwtPayloadSchema = BaseJwtClaimsSchema.extend(PrivacyClaimsSchema.shape)
|
|
9
|
+
.extend(CoreLtiClaimsSchema.shape)
|
|
10
|
+
.extend({
|
|
11
|
+
'https://purl.imsglobal.org/spec/lti/claim/resource_link': ResourceLinkSchema,
|
|
12
|
+
'https://purl.imsglobal.org/spec/lti/claim/context': ContextSchema,
|
|
13
|
+
'https://purl.imsglobal.org/spec/lti/claim/tool_platform': ToolPlatformSchema,
|
|
14
|
+
'https://purl.imsglobal.org/spec/lti/claim/lis': LisSchema,
|
|
15
|
+
'https://purl.imsglobal.org/spec/lti/claim/launch_presentation': LaunchPresentationSchema,
|
|
16
|
+
'https://purl.imsglobal.org/spec/lti/claim/custom': z
|
|
17
|
+
.record(z.string(), z.string())
|
|
18
|
+
.optional(),
|
|
19
|
+
'https://purl.imsglobal.org/spec/lti-ags/claim/endpoint': AgsEndpointSchema,
|
|
20
|
+
'https://purl.imsglobal.org/spec/lti-nrps/claim/namesroleservice': NrpsServiceSchema,
|
|
21
|
+
'https://purl.imsglobal.org/spec/lti-dl/claim/deep_linking_settings': DeepLinkingSettingsSchema,
|
|
22
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const LTI13LaunchSchema: z.ZodObject<{
|
|
3
|
+
id_token: z.ZodJWT;
|
|
4
|
+
state: z.ZodString;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
/**
|
|
7
|
+
* Schema for verifyLaunch method parameters - uses consistent camelCase naming
|
|
8
|
+
* for method parameters while LTI13LaunchSchema uses spec-compliant snake_case
|
|
9
|
+
*/
|
|
10
|
+
export declare const VerifyLaunchParamsSchema: z.ZodObject<{
|
|
11
|
+
idToken: z.ZodString;
|
|
12
|
+
state: z.ZodString;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
//# sourceMappingURL=lti13Launch.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lti13Launch.schema.d.ts","sourceRoot":"","sources":["../../../src/schemas/lti13/lti13Launch.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,iBAAiB;;;iBAG5B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;iBAGnC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const LTI13LaunchSchema = z.object({
|
|
3
|
+
id_token: z.jwt(),
|
|
4
|
+
state: z.string(),
|
|
5
|
+
});
|
|
6
|
+
/**
|
|
7
|
+
* Schema for verifyLaunch method parameters - uses consistent camelCase naming
|
|
8
|
+
* for method parameters while LTI13LaunchSchema uses spec-compliant snake_case
|
|
9
|
+
*/
|
|
10
|
+
export const VerifyLaunchParamsSchema = z.object({
|
|
11
|
+
idToken: z.string().min(1, 'idToken is required'),
|
|
12
|
+
state: z.string().min(1, 'state is required'),
|
|
13
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const LTI13LoginSchema: z.ZodObject<{
|
|
3
|
+
iss: z.ZodString;
|
|
4
|
+
login_hint: z.ZodString;
|
|
5
|
+
target_link_uri: z.ZodURL;
|
|
6
|
+
client_id: z.ZodString;
|
|
7
|
+
lti_deployment_id: z.ZodString;
|
|
8
|
+
lti_message_hint: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
/**
|
|
11
|
+
* Schema for handleLogin method parameters - extends LTI13LoginSchema
|
|
12
|
+
* with the additional launchUrl parameter needed for method calls
|
|
13
|
+
*/
|
|
14
|
+
export declare const HandleLoginParamsSchema: z.ZodObject<{
|
|
15
|
+
iss: z.ZodString;
|
|
16
|
+
login_hint: z.ZodString;
|
|
17
|
+
target_link_uri: z.ZodURL;
|
|
18
|
+
client_id: z.ZodString;
|
|
19
|
+
lti_deployment_id: z.ZodString;
|
|
20
|
+
lti_message_hint: z.ZodOptional<z.ZodString>;
|
|
21
|
+
launchUrl: z.ZodUnion<readonly [z.ZodURL, z.ZodCustom<URL, URL>]>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
//# sourceMappingURL=lti13Login.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lti13Login.schema.d.ts","sourceRoot":"","sources":["../../../src/schemas/lti13/lti13Login.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,gBAAgB;;;;;;;iBAO3B,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;iBAElC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const LTI13LoginSchema = z.object({
|
|
3
|
+
iss: z.string().min(1),
|
|
4
|
+
login_hint: z.string().min(1),
|
|
5
|
+
target_link_uri: z.url(),
|
|
6
|
+
client_id: z.string().min(1),
|
|
7
|
+
lti_deployment_id: z.string().min(1),
|
|
8
|
+
lti_message_hint: z.string().optional(),
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* Schema for handleLogin method parameters - extends LTI13LoginSchema
|
|
12
|
+
* with the additional launchUrl parameter needed for method calls
|
|
13
|
+
*/
|
|
14
|
+
export const HandleLoginParamsSchema = LTI13LoginSchema.extend({
|
|
15
|
+
launchUrl: z.union([z.url(), z.instanceof(URL)]),
|
|
16
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { BaseLogger } from 'pino';
|
|
2
|
+
import type { LTISession } from '../interfaces/ltiSession.js';
|
|
3
|
+
import type { LTIStorage } from '../interfaces/ltiStorage.js';
|
|
4
|
+
import type { ScoreSubmission } from '../schemas/lti13/ags/scoreSubmission.schema.js';
|
|
5
|
+
import type { TokenService } from './token.service.js';
|
|
6
|
+
/**
|
|
7
|
+
* Assignment and Grade Services (AGS) implementation for LTI 1.3.
|
|
8
|
+
* Provides methods to submit grades and scores back to the platform.
|
|
9
|
+
*
|
|
10
|
+
* @see https://www.imsglobal.org/spec/lti-ags/v2p0
|
|
11
|
+
*/
|
|
12
|
+
export declare class AGSService {
|
|
13
|
+
private tokenService;
|
|
14
|
+
private storage;
|
|
15
|
+
private logger;
|
|
16
|
+
constructor(tokenService: TokenService, storage: LTIStorage, logger: BaseLogger);
|
|
17
|
+
/**
|
|
18
|
+
* Submits a grade score to the platform using LTI Assignment and Grade Services.
|
|
19
|
+
*
|
|
20
|
+
* @param session - Active LTI session containing AGS endpoint configuration
|
|
21
|
+
* @param score - Score submission data including grade value and metadata
|
|
22
|
+
* @returns Promise resolving to the HTTP response from the platform
|
|
23
|
+
* @throws {Error} When AGS is not available for the session or submission fails
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* await agsService.submitScore(session, {
|
|
28
|
+
* scoreGiven: 85,
|
|
29
|
+
* scoreMaximum: 100,
|
|
30
|
+
* comment: 'Great work!',
|
|
31
|
+
* activityProgress: 'Completed',
|
|
32
|
+
* gradingProgress: 'FullyGraded'
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
submitScore(session: LTISession, score: ScoreSubmission): Promise<Response>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=ags.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ags.service.d.ts","sourceRoot":"","sources":["../../src/services/ags.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AAGtF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;;;GAKG;AACH,qBAAa,UAAU;IAEnB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,MAAM;gBAFN,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,UAAU;IAG5B;;;;;;;;;;;;;;;;;;OAkBG;IACG,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,QAAQ,CAAC;CAkDlF"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { getValidLaunchConfig } from '../utils/launchConfigValidation.js';
|
|
2
|
+
/**
|
|
3
|
+
* Assignment and Grade Services (AGS) implementation for LTI 1.3.
|
|
4
|
+
* Provides methods to submit grades and scores back to the platform.
|
|
5
|
+
*
|
|
6
|
+
* @see https://www.imsglobal.org/spec/lti-ags/v2p0
|
|
7
|
+
*/
|
|
8
|
+
export class AGSService {
|
|
9
|
+
tokenService;
|
|
10
|
+
storage;
|
|
11
|
+
logger;
|
|
12
|
+
constructor(tokenService, storage, logger) {
|
|
13
|
+
this.tokenService = tokenService;
|
|
14
|
+
this.storage = storage;
|
|
15
|
+
this.logger = logger;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Submits a grade score to the platform using LTI Assignment and Grade Services.
|
|
19
|
+
*
|
|
20
|
+
* @param session - Active LTI session containing AGS endpoint configuration
|
|
21
|
+
* @param score - Score submission data including grade value and metadata
|
|
22
|
+
* @returns Promise resolving to the HTTP response from the platform
|
|
23
|
+
* @throws {Error} When AGS is not available for the session or submission fails
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* await agsService.submitScore(session, {
|
|
28
|
+
* scoreGiven: 85,
|
|
29
|
+
* scoreMaximum: 100,
|
|
30
|
+
* comment: 'Great work!',
|
|
31
|
+
* activityProgress: 'Completed',
|
|
32
|
+
* gradingProgress: 'FullyGraded'
|
|
33
|
+
* });
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
async submitScore(session, score) {
|
|
37
|
+
if (!session.services?.ags?.lineitem) {
|
|
38
|
+
throw new Error('AGS not available for this session');
|
|
39
|
+
}
|
|
40
|
+
// Get launch config to access token URL
|
|
41
|
+
const launchConfig = await getValidLaunchConfig(this.storage, session.platform.issuer, session.platform.clientId, session.platform.deploymentId);
|
|
42
|
+
const token = await this.tokenService.getBearerToken(session.platform.clientId,
|
|
43
|
+
// Need to get token URL from platform storage
|
|
44
|
+
launchConfig.tokenUrl, 'https://purl.imsglobal.org/spec/lti-ags/scope/score');
|
|
45
|
+
const scorePayload = {
|
|
46
|
+
userId: score.userId,
|
|
47
|
+
scoreGiven: score.scoreGiven,
|
|
48
|
+
scoreMaximum: score.scoreMaximum,
|
|
49
|
+
comment: score.comment,
|
|
50
|
+
timestamp: score.timestamp || new Date().toISOString(),
|
|
51
|
+
activityProgress: score.activityProgress,
|
|
52
|
+
gradingProgress: score.gradingProgress,
|
|
53
|
+
};
|
|
54
|
+
const response = await fetch(`${session.services.ags.lineitem}/scores`, {
|
|
55
|
+
method: 'POST',
|
|
56
|
+
headers: {
|
|
57
|
+
Authorization: `Bearer ${token}`,
|
|
58
|
+
'Content-Type': 'application/vnd.ims.lis.v1.score+json',
|
|
59
|
+
},
|
|
60
|
+
body: JSON.stringify(scorePayload),
|
|
61
|
+
});
|
|
62
|
+
if (!response.ok) {
|
|
63
|
+
const error = await response.json();
|
|
64
|
+
this.logger.error({ error, status: response.status, statusText: response.statusText }, 'AGS score submission failed');
|
|
65
|
+
throw new Error(`AGS score submission failed: ${response.statusText}`);
|
|
66
|
+
}
|
|
67
|
+
return response;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { LTISession } from '../interfaces/ltiSession.js';
|
|
2
|
+
import type { LTI13JwtPayload } from '../schemas/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates an LTI session object from a validated LTI 1.3 JWT payload.
|
|
5
|
+
* Extracts user information, context data, and available services into a structured session.
|
|
6
|
+
*
|
|
7
|
+
* @param lti13JwtPayload - Validated LTI 1.3 JWT payload from successful launch
|
|
8
|
+
* @returns Complete LTI session object with user, context, and service information
|
|
9
|
+
*/
|
|
10
|
+
export declare function createSession(lti13JwtPayload: LTI13JwtPayload): LTISession;
|
|
11
|
+
//# sourceMappingURL=session.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.service.d.ts","sourceRoot":"","sources":["../../src/services/session.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D;;;;;;GAMG;AAEH,wBAAgB,aAAa,CAAC,eAAe,EAAE,eAAe,GAAG,UAAU,CAuG1E"}
|