-
Notifications
You must be signed in to change notification settings - Fork 9
[LC-1304] Feat: LinkedClaims Plugin - Endorsements #789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Custard7
wants to merge
16
commits into
main
Choose a base branch
from
plugin-linked-claims
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+724
β20
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
39a0823
Add endoresements context
309f0e3
Add LinkedClaims to CLI
4719a75
Add LinkedClaims Plugin
5daebfc
Add gitignore for linkedclaims
1ef6b6b
Add LinkedClaims Plugin
17167ba
Create slimy-tables-protect.md
Custard7 77c7941
Potential fix for code scanning alert no. 107: Incomplete URL substriβ¦
Custard7 ff22355
Merge main
c7a2ae0
Update dependent types type
0dc5ec7
Merge branch 'main' into plugin-linked-claims
Custard7 9d184d9
Fix documentation
2f83087
Update tests
bb982df
Merge branch 'main' into plugin-linked-claims
Custard7 c8b4213
Merge branch 'main' into plugin-linked-claims
Custard7 3511e47
Merge branch 'main' into plugin-linked-claims
Custard7 df025b2
Merge branch 'main' into plugin-linked-claims
Custard7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@learncard/cli": patch | ||
| "@learncard/linked-claims-plugin": patch | ||
| --- | ||
|
|
||
| Feat: LinkedClaims Plugin - Endorsements |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| node_modules/ | ||
| dist/ | ||
| tsconfig.tsbuildinfo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # LinkedClaims Plugin | ||
|
|
||
| Create, verify, store, and retrieve endorsement credentials using Open Badges v3 EndorsementCredential, linked to original credentials by subject id or original credential id. | ||
|
|
||
| ## Install | ||
| Workspace package. Build with Nx: | ||
|
|
||
| ``` | ||
| pnpm nx run linked-claims-plugin:build | ||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ```ts | ||
| import { getLinkedClaimsPlugin } from '@learncard/linked-claims-plugin'; | ||
|
|
||
| const lc = await LearnCard.fromSomewhere().then(lc => lc.addPlugin(getLinkedClaimsPlugin(lc))); | ||
|
|
||
| const endorsement = await lc.invoke.endorseCredential(originalVc, { | ||
| // OBv3 fields | ||
| endorsementComment: 'I endorse this credential.', | ||
| name: `Endorsement of ${originalVc.id ?? originalVc.credentialSubject?.id}`, | ||
| description: 'Peer endorsement', | ||
| }); | ||
|
|
||
| const verified = await lc.invoke.verifyEndorsement(endorsement); | ||
|
|
||
| const { uri } = await lc.invoke.storeEndorsement(endorsement); | ||
|
|
||
| const endorsements = await lc.invoke.getEndorsements(originalVc); | ||
| ``` | ||
|
|
||
| ## Endorsement Context | ||
| Uses VC v2 and OBv3 contexts: | ||
|
|
||
| ``` | ||
| "@context": [ | ||
| "https://www.w3.org/ns/credentials/v2", | ||
| "https://purl.imsglobal.org/spec/ob/v3p0/context-3.0.3.json" | ||
| ] | ||
| ``` | ||
|
|
||
| ### Endorsement Fields (details input) | ||
|
|
||
| - `endorsementComment?: string` | ||
| - `name?: string` | ||
| - `description?: string` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| module.exports = { | ||
| preset: 'ts-jest', | ||
| testEnvironment: 'node', | ||
| testMatch: ['**/src/test/**/*.test.ts'], | ||
| transform: { | ||
| '^.+\\.(t|j)sx?$': [ | ||
| 'ts-jest', | ||
| { | ||
| tsconfig: { | ||
| target: 'ES2020', | ||
| module: 'CommonJS', | ||
| moduleResolution: 'node', | ||
| esModuleInterop: true, | ||
| isolatedModules: true, | ||
| skipLibCheck: true, | ||
| allowSyntheticDefaultImports: true, | ||
| }, | ||
| diagnostics: false | ||
| } | ||
| ] | ||
| }, | ||
| transformIgnorePatterns: ['/node_modules/'], | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| { | ||
| "name": "@learncard/linked-claims-plugin", | ||
| "version": "0.1.0", | ||
| "description": "LinkedClaims plugin to create, verify, store, and query endorsement credentials.", | ||
| "main": "./dist/index.js", | ||
| "module": "./dist/linked-claims-plugin.esm.js", | ||
| "files": [ | ||
| "dist" | ||
| ], | ||
| "scripts": { | ||
| "build": "node ./scripts/build.mjs && shx cp ./scripts/mixedEntypoint.js ./dist/index.js && tsc --p tsconfig.json", | ||
| "test": "jest --passWithNoTests", | ||
| "test:watch": "jest --watch", | ||
| "test:coverage": "jest --silent --ci --coverage --coverageReporters=\"text\" --coverageReporters=\"text-summary\"" | ||
| }, | ||
| "author": "Learning Economy Foundation (www.learningeconomy.io)", | ||
| "license": "MIT", | ||
| "homepage": "https://github.com/WeLibraryOS/LearnCard#readme", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/WeLibraryOS/LearnCard.git" | ||
| }, | ||
| "bugs": { | ||
| "url": "https://github.com/WeLibraryOS/LearnCard/issues" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/jest": "^29.2.2", | ||
| "@types/node": "^17.0.31", | ||
| "aqu": "0.4.3", | ||
| "esbuild": "^0.14.38", | ||
| "esbuild-jest": "^0.5.0", | ||
| "esbuild-plugin-copy": "^1.3.0", | ||
| "jest": "^29.3.0", | ||
| "shx": "^0.3.4", | ||
| "ts-jest": "^29.0.3" | ||
| }, | ||
| "types": "./dist/index.d.ts", | ||
| "dependencies": { | ||
| "@learncard/core": "workspace:*", | ||
| "@learncard/types": "workspace:*", | ||
| "@learncard/vc-plugin": "workspace:^", | ||
| "why-is-node-running": "^2.2.2" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| "$schema": "../../../node_modules/nx/schemas/project-schema.json", | ||
| "name": "linked-claims-plugin", | ||
| "sourceRoot": "packages/plugins/linked-claims/src", | ||
| "projectType": "library", | ||
| "root": "packages/plugins/linked-claims", | ||
| "tags": [], | ||
| "implicitDependencies": ["core", "vc-plugin"], | ||
| "namedInputs": { | ||
| "scripts": ["{projectRoot}/scripts/**/*"], | ||
| "source": ["{projectRoot}/src/**/*"] | ||
| }, | ||
| "targets": { | ||
| "build": { | ||
| "executor": "nx:run-script", | ||
| "inputs": ["source", "scripts"], | ||
| "options": { "script": "build" } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| import path from 'path'; | ||
|
|
||
| import esbuild from 'esbuild'; | ||
| import rimraf from 'rimraf'; | ||
|
|
||
| const buildOptions = { | ||
| target: 'es2020', | ||
| sourcemap: true, | ||
| external: ['isomorphic-fetch', 'isomorphic-webcrypto'], | ||
| }; | ||
|
|
||
| const configurations = [ | ||
| { | ||
| keepNames: true, | ||
| bundle: true, | ||
| sourcemap: 'external', | ||
| incremental: true, | ||
| tsconfig: 'tsconfig.json', | ||
| plugins: [], | ||
| entryPoints: ['src/index.ts'], | ||
| format: 'cjs', | ||
| outfile: 'dist/linked-claims-plugin.cjs.development.js', | ||
| ...buildOptions, | ||
| }, | ||
| { | ||
| keepNames: true, | ||
| bundle: true, | ||
| sourcemap: 'external', | ||
| incremental: true, | ||
| tsconfig: 'tsconfig.json', | ||
| plugins: [], | ||
| entryPoints: ['src/index.ts'], | ||
| minify: true, | ||
| format: 'cjs', | ||
| outfile: 'dist/linked-claims-plugin.cjs.production.min.js', | ||
| ...buildOptions, | ||
| }, | ||
| { | ||
| keepNames: true, | ||
| bundle: true, | ||
| sourcemap: 'external', | ||
| incremental: true, | ||
| tsconfig: 'tsconfig.json', | ||
| plugins: [], | ||
| entryPoints: ['src/index.ts'], | ||
| format: 'esm', | ||
| outfile: 'dist/linked-claims-plugin.esm.js', | ||
| ...buildOptions, | ||
| }, | ||
| ]; | ||
|
|
||
| function asyncRimraf(path) { | ||
| return new Promise((resolve, reject) => { | ||
| rimraf(path, err => { | ||
| if (err) { | ||
| reject(err); | ||
| } else { | ||
| resolve(); | ||
| } | ||
| }); | ||
| }); | ||
| } | ||
|
|
||
| await Promise.all( | ||
| configurations.map(async config => { | ||
| var dir = config.outdir || path.dirname(config.outfile); | ||
| await asyncRimraf(dir).catch(() => { | ||
| console.log('Unable to delete directory', dir); | ||
| }); | ||
| }) | ||
| ); | ||
|
|
||
| await Promise.all(configurations.map(config => esbuild.build(config))).catch(err => { | ||
| console.error('β Build failed'); | ||
| process.exit(1); | ||
| }); | ||
|
|
||
| console.log('β Build successful'); | ||
| process.exit(0); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| 'use strict'; | ||
|
|
||
| if (process.env.NODE_ENV === 'production') { | ||
| module.exports = require('./linked-claims-plugin.cjs.production.min.js'); | ||
| } else { | ||
| module.exports = require('./linked-claims-plugin.cjs.development.js'); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π Bug - Missing Dependency: Add 'rimraf' as a devDependency in the package.json file, or replace the rimraf usage with Node.js built-in fs.rmSync() for a dependency-free solution.