-
Notifications
You must be signed in to change notification settings - Fork 28
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
feat(recaps): add proposed api #139
Draft
zachferland
wants to merge
2
commits into
main
Choose a base branch
from
feat/recaps-experimental
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.
Draft
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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 @@ | ||
src/abnf.ts |
This file contains 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,11 @@ | ||
{ | ||
"extends": ["3box", "3box/jest", "3box/typescript"], | ||
"parserOptions": { | ||
"project": ["tsconfig.lint.json"] | ||
}, | ||
"rules": { | ||
"@typescript-eslint/ban-ts-comment": "off", | ||
"@typescript-eslint/no-namespace": "off", | ||
"@typescript-eslint/no-unsafe-assignment": "off" | ||
} | ||
} |
This file contains 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,4 @@ | ||
*.log | ||
.DS_Store | ||
node_modules | ||
dist |
This file contains 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,5 @@ | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. |
This file contains 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,19 @@ | ||
The MIT License (MIT) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains 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,21 @@ | ||
> ⚠️ This package is experimental and based on a specification that is yet to be finalized. | ||
|
||
# ReCaps | ||
|
||
A library to create and manage ReCaps, including their (de)serialization and human-readable ReCap statements. Follows [EIP-5573](https://github.com/spruceid/EIPs/blob/19dae81ecc8354199bbe28f3b6248851f4cf49cf/EIPS/eip-5573.md) (not finalized). | ||
|
||
|
||
|
||
## Examples | ||
|
||
### TODO | ||
|
||
```typescript | ||
const recapstr = new Recap({ | ||
... | ||
}) | ||
``` | ||
|
||
## License | ||
|
||
Dual licensed with APACHE and MIT |
This file contains 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,22 @@ | ||
{ | ||
"moduleFileExtensions": ["js", "json", "ts"], | ||
"testRegex": ".(spec|test).ts$", | ||
"testEnvironment": "node", | ||
"extensionsToTreatAsEsm": [".ts"], | ||
"globals": { | ||
"ts-jest": { | ||
"useESM": true | ||
} | ||
}, | ||
"moduleNameMapper": { | ||
"^(\\.{1,2}/.*)\\.js$": "$1" | ||
}, | ||
"transform": { | ||
"^.+\\.(t|j)s$": [ | ||
"@swc/jest", | ||
{ | ||
"root": "../.." | ||
} | ||
] | ||
} | ||
} |
This file contains 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,57 @@ | ||
{ | ||
"name": "@didtools/recaps", | ||
"version": "0.0.1", | ||
"description": "Typescript library for ReCaps", | ||
"author": "3Box Labs", | ||
"license": "(Apache-2.0 OR MIT)", | ||
"type": "module", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"exports": { | ||
".": "./dist/index.js" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"engines": { | ||
"node": ">=14.14" | ||
}, | ||
"sideEffects": false, | ||
"scripts": { | ||
"build:clean": "del dist", | ||
"build:js": "swc src -d ./dist --config-file ../../.swcrc", | ||
"build:types": "tsc --emitDeclarationOnly --skipLibCheck", | ||
"build": "pnpm run build:clean && pnpm run build:types && pnpm run build:js", | ||
"lint": "eslint src test --fix", | ||
"test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js", | ||
"test:ci": "pnpm run test --ci --coverage", | ||
"prepare": "pnpm run build", | ||
"prepublishOnly": "package-check" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/ceramicnetwork/js-did.git" | ||
}, | ||
"keywords": [ | ||
"DID", | ||
"identity", | ||
"OCAP", | ||
"capabilities" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/ceramicnetwork/js-did/issues" | ||
}, | ||
"homepage": "https://github.com/ceramicnetwork/js-did#readme", | ||
"dependencies": { | ||
"@ipld/dag-cbor": "^7.0.1", | ||
"apg-js": "^4.1.1", | ||
"caip": "^1.1.0", | ||
"multiformats": "^9.5.1", | ||
"uint8arrays": "^4.0.2" | ||
}, | ||
"devDependencies": { | ||
"@types/luxon": "^3.0.0", | ||
"@types/node": "^18.11.7", | ||
"luxon": "^3.0.1" | ||
} | ||
} |
This file contains 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,93 @@ | ||
type CeramicWrite = { | ||
"ceramic/write": [] | ||
} | ||
|
||
type Actions = CeramicWrite | ||
type Capability = [string, Actions] | ||
type Capablities = Array<Capability> | ||
|
||
function validCeramicTarget(s: string): Uint8Array { | ||
// const modelResource = | ||
// const streamResource = | ||
// const allResource = "" | ||
return true | ||
} | ||
|
||
export class ReCap { | ||
_caps: Capablities | ||
|
||
constructor(caps:Capablities) { | ||
this._caps = caps | ||
} | ||
|
||
/** | ||
* Create ReCap instance from JSON representation | ||
*/ | ||
static fromJson(json:Map<string, Actions>):ReCap { | ||
// | ||
} | ||
|
||
/** | ||
* Create ReCap instance from URI representation, typically from a SIWX message | ||
*/ | ||
static fromURI(recap: string): Recap { | ||
|
||
} | ||
|
||
/** | ||
* Encode ReCap to ReCap URI (urn:recap:base64url-encoded-recap) to be used in SIWX message | ||
*/ | ||
encode():string { | ||
// | ||
} | ||
|
||
/** | ||
* Query if this ReCap is valid for a given action and resource/target | ||
*/ | ||
can(action: Actions, target: string):boolean { | ||
|
||
} | ||
|
||
/** | ||
* Generate the human readable ReCap statement for this ReCap, to be used in SIWX message | ||
*/ | ||
toStatement():string { | ||
|
||
} | ||
|
||
/** | ||
* Get JSON representation of ReCap | ||
*/ | ||
toJson():Map<string, Actions> { | ||
|
||
} | ||
|
||
/** | ||
* Add a capability (action & target) to a ReCap, returns new recap | ||
*/ | ||
addCapability(action: Actions, target: string):ReCap { | ||
|
||
} | ||
|
||
/** | ||
* Verify that a ReCap Statement is valid for this ReCap and encodes the same delegations | ||
*/ | ||
verifyStatment(statement:string):boolean { | ||
|
||
} | ||
|
||
/** | ||
* Get array of resources inlcuded in ReCap | ||
*/ | ||
get resourceList(): Array<string> { | ||
|
||
} | ||
|
||
/** | ||
* Get array of actions for given resource/target | ||
*/ | ||
get actionsByResource(resource:string): Array<Actions> { | ||
|
||
} | ||
} | ||
|
This file contains 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 @@ | ||
describe('Cacao Auth Verify', () => { | ||
test.todo('Verify') | ||
}) |
This file contains 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 @@ | ||
{ | ||
"extends": "../../tsconfig.build.json", | ||
"compilerOptions": { | ||
"outDir": "./dist" | ||
}, | ||
"include": ["src"] | ||
} |
This file contains 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,4 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"include": ["src", "test"] | ||
} |
This file contains 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 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
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.
Do we want to keep Ceramic specific things outside of here? Currently all Ceramic specific code of SIWx lives in the js-ceramic codebase.
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.
Mostly likely in the end, but thinking that for now everything ceramic specific goes here for now (to keep more self contained while experimental), and more useful to drive with specific use case first (ceramic), then generalize after
even if specs dont have namespaces, a general library will need to have some form of that, similar to spruce libs, lots of the rules/parsing are defined by that
likely will make sense to combine most of siwx + recap things together instead this separate library here