@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.
Files changed (116) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +60 -0
  3. package/dist/index.d.ts +4 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +3 -0
  6. package/dist/interfaces/index.d.ts +7 -0
  7. package/dist/interfaces/index.d.ts.map +1 -0
  8. package/dist/interfaces/index.js +1 -0
  9. package/dist/interfaces/jwks.d.ts +18 -0
  10. package/dist/interfaces/jwks.d.ts.map +1 -0
  11. package/dist/interfaces/jwks.js +1 -0
  12. package/dist/interfaces/ltiClient.d.ts +24 -0
  13. package/dist/interfaces/ltiClient.d.ts.map +1 -0
  14. package/dist/interfaces/ltiClient.js +1 -0
  15. package/dist/interfaces/ltiConfig.d.ts +26 -0
  16. package/dist/interfaces/ltiConfig.d.ts.map +1 -0
  17. package/dist/interfaces/ltiConfig.js +1 -0
  18. package/dist/interfaces/ltiDeployment.d.ts +15 -0
  19. package/dist/interfaces/ltiDeployment.d.ts.map +1 -0
  20. package/dist/interfaces/ltiDeployment.js +1 -0
  21. package/dist/interfaces/ltiLaunchConfig.d.ts +19 -0
  22. package/dist/interfaces/ltiLaunchConfig.d.ts.map +1 -0
  23. package/dist/interfaces/ltiLaunchConfig.js +1 -0
  24. package/dist/interfaces/ltiSession.d.ts +110 -0
  25. package/dist/interfaces/ltiSession.d.ts.map +1 -0
  26. package/dist/interfaces/ltiSession.js +1 -0
  27. package/dist/interfaces/ltiStorage.d.ts +122 -0
  28. package/dist/interfaces/ltiStorage.d.ts.map +1 -0
  29. package/dist/interfaces/ltiStorage.js +1 -0
  30. package/dist/ltiTool.d.ts +184 -0
  31. package/dist/ltiTool.d.ts.map +1 -0
  32. package/dist/ltiTool.js +305 -0
  33. package/dist/schemas/client.schema.d.ts +33 -0
  34. package/dist/schemas/client.schema.d.ts.map +1 -0
  35. package/dist/schemas/client.schema.js +14 -0
  36. package/dist/schemas/common.schema.d.ts +6 -0
  37. package/dist/schemas/common.schema.d.ts.map +1 -0
  38. package/dist/schemas/common.schema.js +5 -0
  39. package/dist/schemas/deployment.schema.d.ts +8 -0
  40. package/dist/schemas/deployment.schema.d.ts.map +1 -0
  41. package/dist/schemas/deployment.schema.js +11 -0
  42. package/dist/schemas/index.d.ts +5 -0
  43. package/dist/schemas/index.d.ts.map +1 -0
  44. package/dist/schemas/index.js +4 -0
  45. package/dist/schemas/lti13/ags/scoreSubmission.schema.d.ts +34 -0
  46. package/dist/schemas/lti13/ags/scoreSubmission.schema.d.ts.map +1 -0
  47. package/dist/schemas/lti13/ags/scoreSubmission.schema.js +41 -0
  48. package/dist/schemas/lti13/claims/baseJwtClaims.schema.d.ts +11 -0
  49. package/dist/schemas/lti13/claims/baseJwtClaims.schema.d.ts.map +1 -0
  50. package/dist/schemas/lti13/claims/baseJwtClaims.schema.js +10 -0
  51. package/dist/schemas/lti13/claims/contextClaims.schema.d.ts +11 -0
  52. package/dist/schemas/lti13/claims/contextClaims.schema.d.ts.map +1 -0
  53. package/dist/schemas/lti13/claims/contextClaims.schema.js +14 -0
  54. package/dist/schemas/lti13/claims/coreLtiClaims.schema.d.ts +9 -0
  55. package/dist/schemas/lti13/claims/coreLtiClaims.schema.d.ts.map +1 -0
  56. package/dist/schemas/lti13/claims/coreLtiClaims.schema.js +11 -0
  57. package/dist/schemas/lti13/claims/platformClaims.schema.d.ts +19 -0
  58. package/dist/schemas/lti13/claims/platformClaims.schema.d.ts.map +1 -0
  59. package/dist/schemas/lti13/claims/platformClaims.schema.js +24 -0
  60. package/dist/schemas/lti13/claims/privacyClaims.schema.d.ts +8 -0
  61. package/dist/schemas/lti13/claims/privacyClaims.schema.d.ts.map +1 -0
  62. package/dist/schemas/lti13/claims/privacyClaims.schema.js +7 -0
  63. package/dist/schemas/lti13/claims/serviceClaims.schema.d.ts +20 -0
  64. package/dist/schemas/lti13/claims/serviceClaims.schema.d.ts.map +1 -0
  65. package/dist/schemas/lti13/claims/serviceClaims.schema.js +25 -0
  66. package/dist/schemas/lti13/lti13JwtPayload.schema.d.ts +66 -0
  67. package/dist/schemas/lti13/lti13JwtPayload.schema.d.ts.map +1 -0
  68. package/dist/schemas/lti13/lti13JwtPayload.schema.js +22 -0
  69. package/dist/schemas/lti13/lti13Launch.schema.d.ts +14 -0
  70. package/dist/schemas/lti13/lti13Launch.schema.d.ts.map +1 -0
  71. package/dist/schemas/lti13/lti13Launch.schema.js +13 -0
  72. package/dist/schemas/lti13/lti13Login.schema.d.ts +23 -0
  73. package/dist/schemas/lti13/lti13Login.schema.d.ts.map +1 -0
  74. package/dist/schemas/lti13/lti13Login.schema.js +16 -0
  75. package/dist/services/ags.service.d.ts +38 -0
  76. package/dist/services/ags.service.d.ts.map +1 -0
  77. package/dist/services/ags.service.js +69 -0
  78. package/dist/services/session.service.d.ts +11 -0
  79. package/dist/services/session.service.d.ts.map +1 -0
  80. package/dist/services/session.service.js +103 -0
  81. package/dist/services/token.service.d.ts +36 -0
  82. package/dist/services/token.service.d.ts.map +1 -0
  83. package/dist/services/token.service.js +74 -0
  84. package/dist/utils/launchConfigValidation.d.ts +3 -0
  85. package/dist/utils/launchConfigValidation.d.ts.map +1 -0
  86. package/dist/utils/launchConfigValidation.js +7 -0
  87. package/package.json +53 -0
  88. package/src/index.ts +3 -0
  89. package/src/interfaces/index.ts +6 -0
  90. package/src/interfaces/jwks.ts +20 -0
  91. package/src/interfaces/ltiClient.ts +24 -0
  92. package/src/interfaces/ltiConfig.ts +31 -0
  93. package/src/interfaces/ltiDeployment.ts +17 -0
  94. package/src/interfaces/ltiLaunchConfig.ts +23 -0
  95. package/src/interfaces/ltiSession.ts +119 -0
  96. package/src/interfaces/ltiStorage.ts +161 -0
  97. package/src/ltiTool.ts +394 -0
  98. package/src/schemas/client.schema.ts +17 -0
  99. package/src/schemas/common.schema.ts +7 -0
  100. package/src/schemas/deployment.schema.ts +12 -0
  101. package/src/schemas/index.ts +10 -0
  102. package/src/schemas/lti13/ags/scoreSubmission.schema.ts +54 -0
  103. package/src/schemas/lti13/claims/baseJwtClaims.schema.ts +11 -0
  104. package/src/schemas/lti13/claims/contextClaims.schema.ts +16 -0
  105. package/src/schemas/lti13/claims/coreLtiClaims.schema.ts +12 -0
  106. package/src/schemas/lti13/claims/platformClaims.schema.ts +27 -0
  107. package/src/schemas/lti13/claims/privacyClaims.schema.ts +8 -0
  108. package/src/schemas/lti13/claims/serviceClaims.schema.ts +28 -0
  109. package/src/schemas/lti13/lti13JwtPayload.schema.ts +36 -0
  110. package/src/schemas/lti13/lti13Launch.schema.ts +15 -0
  111. package/src/schemas/lti13/lti13Login.schema.ts +18 -0
  112. package/src/services/ags.service.ts +92 -0
  113. package/src/services/session.service.ts +115 -0
  114. package/src/services/token.service.ts +84 -0
  115. package/src/utils/launchConfigValidation.ts +16 -0
  116. package/tsconfig.json +8 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # @lti-tool/core
2
+
3
+ ## 0.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5257caa: Initial release of LTI Tool library
8
+ - Complete LTI 1.3 implementation with security validation
9
+ - Hono framework integration for serverless deployments
10
+ - DynamoDB storage adapter with caching
11
+ - In-memory storage adapter for development
12
+ - Cookie-free session management
13
+ - Assignment and Grade Services (AGS) support
14
+ - Deep Linking support
15
+ - Comprehensive TypeScript support
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # lti-tool core
2
+
3
+ <p align="center">
4
+ <a href="https://www.npmjs.com/package/@lti-tool/core"><img alt="npm" src="https://img.shields.io/npm/dm/%40lti-tool%2Fcore?style=flat-square" /></a>
5
+ <a href="https://github.com/lti-tool/lti-tool/actions/workflows/release.yml"><img alt="Build status" src="https://img.shields.io/github/actions/workflow/status/lti-tool/lti-tool/ci.yml?style=flat-square&branch=dev" /></a>
6
+ </p>
7
+ <p align="center">Modern LTI 1.3 toolkit, built for TypeScript.</p>
8
+
9
+ ## Core Features
10
+
11
+ - **LTI 1.3 OIDC Flow** - Complete authentication and launch verification
12
+ - **Security** - JWT verification, nonce validation, replay attack prevention
13
+ - **Assignment and Grade Services (AGS)** - Score submission to LMS
14
+ - **Session Management** - Secure session creation and retrieval
15
+ - **Client Management** - Platform and deployment configuration
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install @lti-tool/core
21
+ ```
22
+
23
+ ## Quick Start
24
+
25
+ ```typescript
26
+ import { LTITool } from '@lti-tool/core';
27
+
28
+ const ltiTool = new LTITool({
29
+ stateSecret: new TextEncoder().encode('your-secret-key'),
30
+ keyPair, // Your RSA keypair
31
+ storage: new MemoryStorage(),
32
+ });
33
+
34
+ // Configure your LMS
35
+ const clientId = await ltiTool.addClient({
36
+ /* ... */
37
+ });
38
+ await ltiTool.addDeployment(clientId, {
39
+ /* ... */
40
+ });
41
+
42
+ // Handle LTI flow
43
+ const authUrl = await ltiTool.handleLogin(loginParams);
44
+ const payload = await ltiTool.verifyLaunch(idToken, state);
45
+ const session = await ltiTool.createSession(payload);
46
+ ```
47
+
48
+ ## Documentation
49
+
50
+ - [API Reference](https://lti-tool.dev/docs) - (Coming soon) Complete API documentation
51
+ - [Examples](https://github.com/lti-tool/lti-tool-examples) - (Coming soon) Working examples
52
+
53
+ ## Security
54
+
55
+ Production security features
56
+
57
+ - JWT signature verification using platform JWKS
58
+ - Nonce validation prevents replay attacks
59
+ - State verification prevents CSRF
60
+ - Client ID and deployment validation
@@ -0,0 +1,4 @@
1
+ export * from './interfaces/index.js';
2
+ export * from './schemas/index.js';
3
+ export { LTITool } from './ltiTool.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './interfaces/index.js';
2
+ export * from './schemas/index.js';
3
+ export { LTITool } from './ltiTool.js';
@@ -0,0 +1,7 @@
1
+ export type { LTIClient } from './ltiClient.js';
2
+ export type { LTIConfig } from './ltiConfig.js';
3
+ export type { LTIDeployment } from './ltiDeployment.js';
4
+ export type { LTILaunchConfig } from './ltiLaunchConfig.js';
5
+ export type { LTISession } from './ltiSession.js';
6
+ export type { LTIStorage } from './ltiStorage.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ /**
2
+ * JSON Web Key Set (JWKS) structure as defined by RFC 7517.
3
+ * Used to expose public keys for JWT signature verification.
4
+ */
5
+ export interface JWKS {
6
+ /** Array of JSON Web Key (JWK) objects */
7
+ keys: Array<{
8
+ /** Key usage - typically 'sig' for signature verification */
9
+ use: string;
10
+ /** Algorithm intended for use with this key - typically 'RS256' for LTI */
11
+ alg: string;
12
+ /** Key identifier used to match keys in JWT headers */
13
+ kid: string;
14
+ /** Additional JWK parameters (kty, n, e, etc.) as defined by RFC 7517 */
15
+ [key: string]: unknown;
16
+ }>;
17
+ }
18
+ //# sourceMappingURL=jwks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwks.d.ts","sourceRoot":"","sources":["../../src/interfaces/jwks.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,IAAI;IACnB,0CAA0C;IAC1C,IAAI,EAAE,KAAK,CAAC;QACV,6DAA6D;QAC7D,GAAG,EAAE,MAAM,CAAC;QAEZ,2EAA2E;QAC3E,GAAG,EAAE,MAAM,CAAC;QAEZ,uDAAuD;QACvD,GAAG,EAAE,MAAM,CAAC;QAEZ,yEAAyE;QACzE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC,CAAC;CACJ"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ import type { LTIDeployment } from './ltiDeployment';
2
+ /**
3
+ * Represents an LTI (Learning Tools Interoperability) platform configuration.
4
+ * Contains all necessary endpoints and identifiers for LTI 1.3 integration.
5
+ */
6
+ export interface LTIClient {
7
+ /** Unique identifier for the client */
8
+ id: string;
9
+ /** human-readable name for the platform */
10
+ name: string;
11
+ /** Platform issuer (unique identifier) */
12
+ iss: string;
13
+ /** Your app's client ID on this platform */
14
+ clientId: string;
15
+ /** Platform's auth endpoint */
16
+ authUrl: string;
17
+ /** Platform's token endpoint */
18
+ tokenUrl: string;
19
+ /** Platform's JWKS endpoint */
20
+ jwksUrl: string;
21
+ /** Array of deployment IDs associated with this platform */
22
+ deployments: LTIDeployment[];
23
+ }
24
+ //# sourceMappingURL=ltiClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ltiClient.d.ts","sourceRoot":"","sources":["../../src/interfaces/ltiClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,uCAAuC;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,GAAG,EAAE,MAAM,CAAC;IACZ,4CAA4C;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,WAAW,EAAE,aAAa,EAAE,CAAC;CAC9B"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ import type { Logger } from 'pino';
2
+ import type { LTIStorage } from './ltiStorage.js';
3
+ /**
4
+ * Configuration object for initializing an LTI Tool instance.
5
+ * Contains cryptographic keys, secrets, and storage adapter.
6
+ */
7
+ export interface LTIConfig {
8
+ /** Secret key used for signing state JWTs during OIDC flow (minimum 32 bytes recommended) */
9
+ stateSecret: Uint8Array;
10
+ /** RSA key pair for signing JWTs and providing JWKS endpoint */
11
+ keyPair: CryptoKeyPair;
12
+ /** Storage adapter for persisting platforms, sessions, and nonces */
13
+ storage: LTIStorage;
14
+ /** Optional pino logger */
15
+ logger?: Logger;
16
+ /** Security configuration options */
17
+ security?: {
18
+ /** Key ID for JWKS and JWT signing (defaults to 'main') */
19
+ keyId?: string;
20
+ /** State JWT expiration time in seconds (defaults to 600 = 10 minutes) */
21
+ stateExpirationSeconds?: number;
22
+ /** Nonce expiration time in seconds (defaults to 600 = 10 minutes) */
23
+ nonceExpirationSeconds?: number;
24
+ };
25
+ }
26
+ //# sourceMappingURL=ltiConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ltiConfig.d.ts","sourceRoot":"","sources":["../../src/interfaces/ltiConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,6FAA6F;IAC7F,WAAW,EAAE,UAAU,CAAC;IAExB,gEAAgE;IAChE,OAAO,EAAE,aAAa,CAAC;IAEvB,qEAAqE;IACrE,OAAO,EAAE,UAAU,CAAC;IAEpB,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,qCAAqC;IACrC,QAAQ,CAAC,EAAE;QACT,2DAA2D;QAC3D,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,0EAA0E;QAC1E,sBAAsB,CAAC,EAAE,MAAM,CAAC;QAChC,sEAAsE;QACtE,sBAAsB,CAAC,EAAE,MAAM,CAAC;KACjC,CAAC;CACH"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Represents a specific deployment of your LTI tool within a platform/LMS.
3
+ * Each platform can have multiple deployments (e.g., different courses, contexts).
4
+ */
5
+ export interface LTIDeployment {
6
+ /** Internal stable UUID for this deployment configuration */
7
+ id: string;
8
+ /** LMS-provided deployment identifier used in LTI launch requests */
9
+ deploymentId: string;
10
+ /** Optional human-readable name for this deployment */
11
+ name?: string;
12
+ /** Optional description of what this deployment is used for */
13
+ description?: string;
14
+ }
15
+ //# sourceMappingURL=ltiDeployment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ltiDeployment.d.ts","sourceRoot":"","sources":["../../src/interfaces/ltiDeployment.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,6DAA6D;IAC7D,EAAE,EAAE,MAAM,CAAC;IAEX,qEAAqE;IACrE,YAAY,EAAE,MAAM,CAAC;IAErB,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Configuration required for LTI 1.3 launch authentication flow.
3
+ * Contains platform endpoints and identifiers needed for OIDC authentication.
4
+ */
5
+ export interface LTILaunchConfig {
6
+ /** Platform issuer URL that uniquely identifies the LMS */
7
+ iss: string;
8
+ /** OAuth2 client identifier assigned to your tool by the platform */
9
+ clientId: string;
10
+ /** Deployment identifier within the platform context */
11
+ deploymentId: string;
12
+ /** Platform's OIDC authentication endpoint URL */
13
+ authUrl: string;
14
+ /** Platform's OAuth2 token endpoint URL for service access */
15
+ tokenUrl: string;
16
+ /** Platform's JSON Web Key Set endpoint URL for JWT verification */
17
+ jwksUrl: string;
18
+ }
19
+ //# sourceMappingURL=ltiLaunchConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ltiLaunchConfig.d.ts","sourceRoot":"","sources":["../../src/interfaces/ltiLaunchConfig.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,2DAA2D;IAC3D,GAAG,EAAE,MAAM,CAAC;IAEZ,qEAAqE;IACrE,QAAQ,EAAE,MAAM,CAAC;IAEjB,wDAAwD;IACxD,YAAY,EAAE,MAAM,CAAC;IAErB,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAC;IAEhB,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,CAAC;IAEjB,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAC;CACjB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,110 @@
1
+ import type { JWTPayload } from 'jose';
2
+ /**
3
+ * Represents an active LTI session containing user information, context data,
4
+ * and available services after successful launch verification.
5
+ */
6
+ export interface LTISession {
7
+ /** Original JWT payload from the platform for reference */
8
+ jwtPayload: JWTPayload;
9
+ /** Unique session identifier (UUID) */
10
+ id: string;
11
+ /** User information extracted from LTI claims */
12
+ user: {
13
+ /** Unique user identifier from the platform */
14
+ id: string;
15
+ /** User's display name */
16
+ name?: string;
17
+ /** User's email address */
18
+ email?: string;
19
+ /** User's family/last name */
20
+ familyName?: string;
21
+ /** User's given/first name */
22
+ givenName?: string;
23
+ /** Array of LTI role URIs (e.g., 'http://purl.imsglobal.org/vocab/lis/v2/membership#Instructor') */
24
+ roles: string[];
25
+ };
26
+ /** Course/context information */
27
+ context: {
28
+ /** Unique context identifier from the platform */
29
+ id: string;
30
+ /** Short context label (e.g., course code) */
31
+ label: string;
32
+ /** Full context title (e.g., course name) */
33
+ title: string;
34
+ };
35
+ /** Platform identification */
36
+ platform: {
37
+ /** Platform issuer URL */
38
+ issuer: string;
39
+ /** OAuth2 client identifier */
40
+ clientId: string;
41
+ /** Deployment identifier */
42
+ deploymentId: string;
43
+ /** Human-readable platform name */
44
+ name: string;
45
+ };
46
+ /** Launch target information */
47
+ launch: {
48
+ /** Target link URI where user should be directed */
49
+ target: string;
50
+ };
51
+ /** Resource link information (if applicable) */
52
+ resourceLink?: {
53
+ /** Unique resource link identifier */
54
+ id: string;
55
+ /** Resource link title */
56
+ title?: string;
57
+ };
58
+ /** Available LTI Advantage services */
59
+ services?: {
60
+ /** Assignment and Grade Services (AGS) configuration */
61
+ ags?: {
62
+ /** Single line item endpoint URL */
63
+ lineitem?: string;
64
+ /** Line items collection endpoint URL */
65
+ lineitems?: string;
66
+ /** Available AGS scopes */
67
+ scopes: string[];
68
+ };
69
+ /** Names and Role Provisioning Services (NRPS) configuration */
70
+ nrps?: {
71
+ /** Membership endpoint URL */
72
+ membershipUrl: string;
73
+ /** Supported NRPS versions */
74
+ versions: string[];
75
+ };
76
+ /** Deep Linking configuration */
77
+ deepLinking?: {
78
+ /** URL to return deep linking response */
79
+ returnUrl: string;
80
+ /** Accepted content types */
81
+ acceptTypes: string[];
82
+ /** Accepted presentation targets */
83
+ acceptPresentationDocumentTargets: string[];
84
+ /** Accepted media types */
85
+ acceptMediaTypes?: string;
86
+ /** Whether multiple items can be selected */
87
+ acceptMultiple: boolean;
88
+ /** Whether items should be auto-created */
89
+ autoCreate: boolean;
90
+ /** Platform-specific data to return */
91
+ data?: string;
92
+ };
93
+ };
94
+ /** Custom parameters passed from platform */
95
+ customParameters: Record<string, string>;
96
+ /** Convenience flags for role checking */
97
+ /** True if user has administrator privileges */
98
+ isAdmin: boolean;
99
+ /** True if user has instructor/teacher role */
100
+ isInstructor: boolean;
101
+ /** True if user has student/learner role */
102
+ isStudent: boolean;
103
+ /** True if Assignment and Grade Services are available */
104
+ isAssignmentAndGradesAvailable: boolean;
105
+ /** True if Deep Linking is available */
106
+ isDeepLinkingAvailable: boolean;
107
+ /** True if Names and Role Provisioning Services are available */
108
+ isNameAndRolesAvailable: boolean;
109
+ }
110
+ //# sourceMappingURL=ltiSession.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ltiSession.d.ts","sourceRoot":"","sources":["../../src/interfaces/ltiSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,2DAA2D;IAC3D,UAAU,EAAE,UAAU,CAAC;IAEvB,uCAAuC;IACvC,EAAE,EAAE,MAAM,CAAC;IAEX,iDAAiD;IACjD,IAAI,EAAE;QACJ,+CAA+C;QAC/C,EAAE,EAAE,MAAM,CAAC;QACX,0BAA0B;QAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,2BAA2B;QAC3B,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,8BAA8B;QAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,8BAA8B;QAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,oGAAoG;QACpG,KAAK,EAAE,MAAM,EAAE,CAAC;KACjB,CAAC;IAEF,iCAAiC;IACjC,OAAO,EAAE;QACP,kDAAkD;QAClD,EAAE,EAAE,MAAM,CAAC;QACX,8CAA8C;QAC9C,KAAK,EAAE,MAAM,CAAC;QACd,6CAA6C;QAC7C,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IAEF,8BAA8B;IAC9B,QAAQ,EAAE;QACR,0BAA0B;QAC1B,MAAM,EAAE,MAAM,CAAC;QACf,+BAA+B;QAC/B,QAAQ,EAAE,MAAM,CAAC;QACjB,4BAA4B;QAC5B,YAAY,EAAE,MAAM,CAAC;QACrB,mCAAmC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,YAAY,EAAE,OAAO,CAAC;IACtB,4CAA4C;IAC5C,SAAS,EAAE,OAAO,CAAC;IACnB,0DAA0D;IAC1D,8BAA8B,EAAE,OAAO,CAAC;IACxC,wCAAwC;IACxC,sBAAsB,EAAE,OAAO,CAAC;IAChC,iEAAiE;IACjE,uBAAuB,EAAE,OAAO,CAAC;CAClC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,122 @@
1
+ import type { LTIClient } from './ltiClient.js';
2
+ import type { LTIDeployment } from './ltiDeployment.js';
3
+ import type { LTILaunchConfig } from './ltiLaunchConfig.js';
4
+ import type { LTISession } from './ltiSession.js';
5
+ /**
6
+ * Storage interface for persisting LTI Client configurations, user sessions, and security nonces.
7
+ * Implement this interface to use different storage backends (memory, database, Redis, etc.).
8
+ */
9
+ export interface LTIStorage {
10
+ /**
11
+ * Retrieves all clients configured in the system.
12
+ *
13
+ * @returns Array of all client configurations
14
+ */
15
+ listClients(): Promise<Omit<LTIClient, 'deployments'>[]>;
16
+ /**
17
+ * Retrieves client configuration by its unique id.
18
+ *
19
+ * @param clientId - Unique client identifier
20
+ * @returns Client configuration if found, undefined otherwise
21
+ */
22
+ getClientById(clientId: string): Promise<LTIClient | undefined>;
23
+ /**
24
+ * Adds a new client configuration to storage.
25
+ *
26
+ * @param client - Partial client configuration object
27
+ */
28
+ addClient(client: Omit<LTIClient, 'id' | 'deployments'>): Promise<string>;
29
+ /**
30
+ * Updates an existing client configuration.
31
+ *
32
+ * @param clientId - Unique client identifier
33
+ * @param client - Partial client object with fields to update
34
+ */
35
+ updateClient(clientId: string, client: Partial<Omit<LTIClient, 'id' | 'deployments'>>): Promise<void>;
36
+ /**
37
+ * Removes a client configuration from storage.
38
+ *
39
+ * @param clientId - Unique client identifier
40
+ */
41
+ deleteClient(clientId: string): Promise<void>;
42
+ /**
43
+ * Lists all deployments for a specific client.
44
+ *
45
+ * @param clientId - Client identifier
46
+ * @returns Array of deployment configurations
47
+ */
48
+ listDeployments(clientId: string): Promise<LTIDeployment[]>;
49
+ /**
50
+ * Retrieves deployment configuration by client ID and deployment ID (admin use).
51
+ *
52
+ * @param clientId - Unique client identifier
53
+ * @param deploymentId - Deployment identifier
54
+ * @returns Deployment configuration if found, undefined otherwise
55
+ */
56
+ getDeployment(clientId: string, deploymentId: string): Promise<LTIDeployment | undefined>;
57
+ /**
58
+ * Adds a new deployment to an existing client.
59
+ *
60
+ * @param clientId - Client identifier
61
+ * @param deployment - Deployment configuration to add
62
+ */
63
+ addDeployment(clientId: string, deployment: Omit<LTIDeployment, 'id'>): Promise<string>;
64
+ /**
65
+ * Updates an existing deployment configuration.
66
+ * @param clientId - Client identifier
67
+ * @param deploymentId - Deployment identifier to update
68
+ * @param deployment - Partial deployment object with fields to update
69
+ */
70
+ updateDeployment(clientId: string, deploymentId: string, deployment: Partial<LTIDeployment>): Promise<void>;
71
+ /**
72
+ * Removes a deployment from a Client.
73
+ *
74
+ * @param clientId - Client identifier
75
+ * @param deploymentId - Deployment identifier to remove
76
+ */
77
+ deleteDeployment(clientId: string, deploymentId: string): Promise<void>;
78
+ /**
79
+ * Retrieves an active user session by session ID.
80
+ *
81
+ * @param sessionId - Unique session identifier (typically a UUID)
82
+ * @returns Session object if found and valid, undefined otherwise
83
+ */
84
+ getSession(sessionId: string): Promise<LTISession | undefined>;
85
+ /**
86
+ * Stores a new user session after successful LTI launch.
87
+ *
88
+ * @param session - Complete session object with user, context, and service data
89
+ * @returns The session ID for reference
90
+ */
91
+ addSession(session: LTISession): Promise<string>;
92
+ /**
93
+ * Stores a nonce with expiration time for replay attack prevention.
94
+ *
95
+ * @param nonce - Unique nonce value (typically a UUID)
96
+ * @param expiresAt - When this nonce should be considered expired
97
+ */
98
+ storeNonce(nonce: string, expiresAt: Date): Promise<void>;
99
+ /**
100
+ * Validates a nonce and marks it as used to prevent replay attacks.
101
+ *
102
+ * @param nonce - Nonce value to validate
103
+ * @returns true if nonce is valid and unused, false if already used or expired
104
+ */
105
+ validateNonce(nonce: string): Promise<boolean>;
106
+ /**
107
+ * Retrieves launch configuration for LTI authentication flow.
108
+ *
109
+ * @param iss - Platform issuer URL (identifies the LMS)
110
+ * @param clientId - OAuth2 client identifier for this tool
111
+ * @param deploymentId - Deployment identifier within the platform
112
+ * @returns Launch configuration if found, undefined otherwise
113
+ */
114
+ getLaunchConfig(iss: string, clientId: string, deploymentId: string): Promise<LTILaunchConfig | undefined>;
115
+ /**
116
+ * Stores launch configuration for platform authentication.
117
+ *
118
+ * @param launchConfig - Complete launch configuration with auth URLs and keys
119
+ */
120
+ saveLaunchConfig(launchConfig: LTILaunchConfig): Promise<void>;
121
+ }
122
+ //# sourceMappingURL=ltiStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ltiStorage.d.ts","sourceRoot":"","sources":["../../src/interfaces/ltiStorage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;GAGG;AACH,MAAM,WAAW,UAAU;IAGzB;;;;OAIG;IACH,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,EAAE,CAAC,CAAC;IAEzD;;;;;OAKG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;IAEhE;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,GAAG,aAAa,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1E;;;;;OAKG;IACH,YAAY,CACV,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE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