Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
shamilovtim committed Dec 1, 2023
2 parents fcd8768 + ae975ea commit dfb7279
Show file tree
Hide file tree
Showing 151 changed files with 11,860 additions and 7,678 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/docs-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Docs Continuous Integration

on:
push:
branches:
- main
pull_request:
branches:
- main

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
tbdocs-reporter:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2

- name: Set up Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: 18
registry-url: https://registry.npmjs.org/

- name: Install latest npm
run: npm install -g npm@latest

- name: Install dependencies
run: npm ci

- name: Build all workspace packages
run: npm run build

- name: TBDocs Reporter
id: tbdocs-reporter-protocol
uses: TBD54566975/tbdocs@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
report_changed_scope_only: false
fail_on_error: false
entry_points: |
- file: packages/api/src/index.ts
docsReporter: api-extractor
docsGenerator: typedoc-markdown
- name: Save Artifacts
uses: actions/upload-artifact@v3
if: always()
with:
name: tbdocs-reporter-output
path: ./.tbdocs
52 changes: 52 additions & 0 deletions .github/workflows/tbdocs-commenter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: TBDocs Commenter

on:
workflow_run:
workflows: ["Docs Continuous Integration"]
types:
- completed

jobs:
comment-action:
name: TBDocs PR Comment
runs-on: ubuntu-latest
# runs only if it's triggered from a PR
if: github.event.workflow_run.pull_requests[0].number != null

steps:
- name: Download TBDocs Report
uses: dawidd6/action-download-artifact@v2
with:
run_id: ${{ github.event.workflow_run.id }}
name: tbdocs-reporter-output
path: ./.tbdocs

- name: Add footer to markdown report
run: |
report_file='.tbdocs/docs-report.md'
head_sha="${{ github.event.workflow_run.pull_requests[0].head.sha }}"
short_sha=${head_sha:0:7}
timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
repo="${{ github.repository }}"
sha_link="https://github.com/$repo/commit/$head_sha"
footer_line="_TBDocs Report Updated at $timestamp [\`$short_sha\`]($sha_link)_"
echo "---" >> $report_file
echo $footer_line >> $report_file
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ github.event.workflow_run.pull_requests[0].number }}
comment-author: "github-actions[bot]"
body-includes: TBDocs Report

- name: Comment on PR
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.workflow_run.pull_requests[0].number }}
edit-mode: replace
body-path: .tbdocs/docs-report.md
37 changes: 1 addition & 36 deletions .github/workflows/tests-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,42 +124,7 @@ jobs:
run: until curl -sf http://localhost:3000/health; do echo -n .; sleep .1; done

- name: Run tests for all packages
run: npm run test:browser --ws -- --color
env:
TEST_DWN_URL: http://localhost:3000

tbdocs-reporter:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2

- name: Set up Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: 18
registry-url: https://registry.npmjs.org/

- name: Install latest npm
run: npm install -g npm@latest

- name: Install dependencies
run: npm ci

- name: Build all workspace packages
run: npm run build

- name: TBDocs Reporter
id: tbdocs-reporter-protocol
uses: TBD54566975/tbdocs@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
report_changed_scope_only: false
fail_on_error: false
entry_points: |
- file: packages/api/src/index.ts
docsReporter: api-extractor
docsGenerator: typedoc-markdown
run: npm run test:browser --ws

web5-spec:
runs-on: ubuntu-latest
Expand Down
15 changes: 10 additions & 5 deletions .web5-spec/credentials.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Request, Response } from 'express';
import { VerifiableCredential, SignOptions } from '@web5/credentials';
import { DidKeyMethod, PortableDid } from '@web5/dids';
import { Ed25519, Jose } from '@web5/crypto';
import { Ed25519, PrivateKeyJwk } from '@web5/crypto';
import { paths } from './openapi.js';

type Signer = (data: Uint8Array) => Promise<Uint8Array>;
Expand All @@ -24,17 +24,22 @@ export async function credentialIssue(req: Request, res: Response) {

// build signing options
const [signingKeyPair] = ownDid.keySet.verificationMethodKeys!;
const privateKey = (await Jose.jwkToKey({ key: signingKeyPair.privateKeyJwk!})).keyMaterial;
const subjectIssuerDid = body.credential.credentialSubject["id"] as string;
const signer = EdDsaSigner(privateKey);
const signer = EdDsaSigner(signingKeyPair.privateKeyJwk as PrivateKeyJwk);
const signOptions: SignOptions = {
issuerDid : ownDid.did,
subjectDid : subjectIssuerDid,
kid : '#' + ownDid.did.split(':')[2],
signer : signer
};

const vc: VerifiableCredential = VerifiableCredential.create(body.credential.type[body.credential.type.length - 1], body.credential.issuer, subjectIssuerDid, body.credential.credentialSubject);
const vc: VerifiableCredential = VerifiableCredential.create({
type: body.credential.type[body.credential.type.length - 1],
issuer: body.credential.issuer,
subject: subjectIssuerDid,
data: body.credential.credentialSubject
});

const vcJwt: string = await vc.sign(signOptions);

const resp: paths["/credentials/issue"]["post"]["responses"]["200"]["content"]["application/json"] =
Expand All @@ -45,7 +50,7 @@ export async function credentialIssue(req: Request, res: Response) {
res.json(resp);
}

function EdDsaSigner(privateKey: Uint8Array): Signer {
function EdDsaSigner(privateKey: PrivateKeyJwk): Signer {
return async (data: Uint8Array): Promise<Uint8Array> => {
const signature = await Ed25519.sign({ data, key: privateKey});
return signature;
Expand Down
17 changes: 2 additions & 15 deletions .web5-spec/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
// "strict": true,
"lib": [
"DOM",
"ES6"
],
"allowJs": true,
"target": "es6",
"module": "NodeNext",
"declaration": true,
"declarationMap": true,
"declarationDir": "dist/types",
"outDir": "dist",
// `NodeNext` will throw compilation errors if relative import paths are missing file extension
// reference: https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/#ecmascript-module-support-in-node-js
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"resolveJsonModule": true
"strict": false
},
"include": [
"main.ts",
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,20 @@ The query `request` contains the following properties:
- **`recipient`** - _`string`_ (_optional_): the DID in the `recipient` field of the record.
- **`schema`** - _`URI string`_ (_optional_): the URI of the schema bucket in which to query.
- **`dataFormat`** - _`Media Type string`_ (_optional_): the IANA string corresponding with the format of the data to filter for. See IANA's Media Type list here: https://www.iana.org/assignments/media-types/media-types.xhtml
- **`dateSort`** - _`DateSort`_ (_optional_): the `DateSort` value of the date field and direction to sort records by. Defaults to `CreatedAscending`.
- **`pagination`** - _`object`_ (_optional_): the properties used to paginate results.
- **`limit`** - _`number`_ (_optional_): the number of records that should be returned with this query. `undefined` returns all records.
- **`cursor`** - _`messageCid string`_ (_optional_): the `messageCid` of the records toc continue paginating from. This value is returned as a `cursor` in the response object of a `query` if there are more results beyond the `limit`.

#### **Response**

The query `response` contains the following properties:

- **`status`** - _`object`_: the status of the `request`:
- **`code`** - _`number`_: the `Response Status` code, following the response code patterns for `HTTP Response Status Codes`.
- **`detail`** _`string`_: a detailed message describing the response.
- **`records`** - _`Records array`_ (_optional_): the array of `Records` returned if the request was successful.
- **`cursor`** - _`messageCid string`_ (_optional_): the `messageCid` of the last message returned in the results if there are exist additional records beyond the specified `limit` in the `query`.

### **`web5.dwn.records.create(request)`**

Expand Down
Loading

0 comments on commit dfb7279

Please sign in to comment.