From a7046dbe3d321dc91e636eaeb00d6c95cefcdd4f Mon Sep 17 00:00:00 2001 From: gabe Date: Tue, 3 Oct 2023 13:50:48 -0700 Subject: [PATCH 01/11] init commit --- impls/ts/.c8rc.json | 19 ++++++ impls/ts/.eslintrc.cjs | 56 +++++++++++++++ impls/ts/.mocharc.json | 5 ++ impls/ts/package.json | 41 +++++++++++ impls/ts/src/codec.ts | 22 ++++++ impls/ts/src/did-dht.ts | 129 +++++++++++++++++++++++++++++++++++ impls/ts/src/util.ts | 0 impls/ts/tests/codec.spec.ts | 20 ++++++ impls/ts/tests/tsconfig.json | 16 +++++ impls/ts/tsconfig.cjs.json | 20 ++++++ 10 files changed, 328 insertions(+) create mode 100644 impls/ts/.c8rc.json create mode 100644 impls/ts/.eslintrc.cjs create mode 100644 impls/ts/.mocharc.json create mode 100644 impls/ts/package.json create mode 100644 impls/ts/src/codec.ts create mode 100644 impls/ts/src/did-dht.ts create mode 100644 impls/ts/src/util.ts create mode 100644 impls/ts/tests/codec.spec.ts create mode 100644 impls/ts/tests/tsconfig.json create mode 100644 impls/ts/tsconfig.cjs.json diff --git a/impls/ts/.c8rc.json b/impls/ts/.c8rc.json new file mode 100644 index 00000000..8e2c6a1b --- /dev/null +++ b/impls/ts/.c8rc.json @@ -0,0 +1,19 @@ +{ + "all": true, + "cache": false, + "extension": [ + ".js" + ], + "include": [ + "tests/compiled/src/**" + ], + "exclude": [ + "tests/compiled/src/index.js", + "tests/compiled/src/types.js", + "tests/compiled/src/types/**" + ], + "reporter": [ + "cobertura", + "text" + ] +} diff --git a/impls/ts/.eslintrc.cjs b/impls/ts/.eslintrc.cjs new file mode 100644 index 00000000..65bd48ee --- /dev/null +++ b/impls/ts/.eslintrc.cjs @@ -0,0 +1,56 @@ +/** @type {import('eslint').ESLint.ConfigData} */ +module.exports = { + root : true, + extends : ['eslint:recommended', 'plugin:@typescript-eslint/recommended'], + parser : '@typescript-eslint/parser', + parserOptions : { + ecmaVersion : 2022, + sourceType : 'module' + }, + plugins : ['@typescript-eslint', 'mocha'], + env : { + node : true, + es2022 : true, + browser : true + }, + 'ignorePatterns': [ + 'dist', + '**/tests/compiled' + ], + rules: { + 'key-spacing': [ + 'error', + { + 'align': { + 'afterColon' : true, + 'beforeColon' : true, + 'on' : 'colon' + } + } + ], + 'quotes': [ + 'error', + 'single', + { 'allowTemplateLiterals': true } + ], + 'semi' : ['error', 'always'], + 'indent' : ['error', 2, { 'SwitchCase': 1 }], + 'no-unused-vars' : 'off', + 'prefer-const' : 'off', + '@typescript-eslint/no-unused-vars' : [ + 'error', + { + 'vars' : 'all', + 'args' : 'after-used', + 'ignoreRestSiblings' : true, + 'argsIgnorePattern' : '^_', + 'varsIgnorePattern' : '^_' + } + ], + '@typescript-eslint/no-explicit-any' : 'off', + 'no-trailing-spaces' : ['error'], + '@typescript-eslint/no-non-null-assertion' : 'off', + '@typescript-eslint/ban-ts-comment' : 'off', + 'mocha/no-exclusive-tests' : 'warn' + } +}; diff --git a/impls/ts/.mocharc.json b/impls/ts/.mocharc.json new file mode 100644 index 00000000..ab67dfc3 --- /dev/null +++ b/impls/ts/.mocharc.json @@ -0,0 +1,5 @@ +{ + "enable-source-maps": true, + "exit": true, + "spec": ["tests/compiled/**/*.spec.js"] +} diff --git a/impls/ts/package.json b/impls/ts/package.json new file mode 100644 index 00000000..669ae67a --- /dev/null +++ b/impls/ts/package.json @@ -0,0 +1,41 @@ +{ + "name": "did-dht-method", + "version": "0.0.1", + "type": "module", + "main": "./dist/cjs/index.js", + "module": "./dist/esm/index.js", + "types": "./dist/types/index.d.ts", + "scripts": { + "clean": "rimraf dist coverage tests/compiled", + "test": "tsc -p tests/tsconfig.json && c8 mocha", + "lint": "eslint . --ext .ts --max-warnings 0", + "lint:fix": "eslint . --ext .ts --fix" + }, + "engines": { + "node": ">=18.0.0" + }, + "devDependencies": { + "@types/b4a": "^1.6.1", + "@types/chai": "^4.3.6", + "@types/mocha": "^10.0.2", + "@typescript-eslint/eslint-plugin": "^6.7.4", + "eslint": "^8.50.0", + "eslint-config-standard-with-typescript": "^39.1.0", + "eslint-plugin-import": "^2.28.1", + "eslint-plugin-mocha": "^10.2.0", + "eslint-plugin-n": "^16.1.0", + "eslint-plugin-promise": "^6.1.1", + "eslint-plugin-react": "^7.33.2", + "typescript": "^5.2.2" + }, + "dependencies": { + "@web5/crypto": "^0.2.0", + "@web5/dids": "^0.2.0", + "b4a": "^1.6.4", + "brotli-compress": "^1.3.3", + "brotli-wasm": "^2.0.0", + "c8": "^8.0.1", + "chai": "^4.3.10", + "rimraf": "^5.0.5" + } +} diff --git a/impls/ts/src/codec.ts b/impls/ts/src/codec.ts new file mode 100644 index 00000000..46fbd710 --- /dev/null +++ b/impls/ts/src/codec.ts @@ -0,0 +1,22 @@ +import brotli from 'brotli-compress'; +import b4a from 'b4a'; + +export class Codec { + /** + * @param records An array of arrays containing strings + */ + async encode(records: string[][]): Promise { + const string = JSON.stringify(records); + const encoded = b4a.from(string); + return await brotli.compress(encoded); + } + + /** + * @param encoded A Uint8Array containing the encoded data + */ + async decode(encoded: Uint8Array): Promise { + const decoded = await brotli.decompress(encoded); + const string = b4a.toString(b4a.from(decoded)); + return JSON.parse(string); + } +} diff --git a/impls/ts/src/did-dht.ts b/impls/ts/src/did-dht.ts new file mode 100644 index 00000000..61239596 --- /dev/null +++ b/impls/ts/src/did-dht.ts @@ -0,0 +1,129 @@ +import type { PrivateKeyJwk, PublicKeyJwk, JwkKeyPair } from '@web5/crypto'; +import type { + DidDocument, + DidKeySetVerificationMethodKey, + DidMethod, + DidResolutionResult, + DidService, + PortableDid +} from '@web5/dids'; +import {EcdsaAlgorithm, EdDsaAlgorithm, Jose, Web5Crypto} from '@web5/crypto'; + +const SupportedCryptoAlgorithms = [ + 'Ed25519', + 'secp256k1' +] as const; + +export type DidDhtCreateOptions = { + publish?: boolean; + keySet?: DidDhtKeySet; + services?: DidService[]; +} + +export type DidDhtKeySet = { + identityKey?: JwkKeyPair; + verificationMethodKeys?: DidKeySetVerificationMethodKey[]; +} + +export class DidDhtMethod implements DidMethod { + + public static methodName = 'dht'; + + public static async create(options?: DidDhtCreateOptions): Promise { + let { publish, keySet, services } = options ?? { }; + + // Begin constructing a PortableDid + const did: Partial = {}; + + // Generate missing keys if not provided in the options + did.keySet = await this.generateKeySet({ keySet }); + + // Get the identifier + throw new Error('Method not implemented.'); + } + + public static async publish(key: DidDhtKeySet, didDocument: DidDocument): Promise { + throw new Error('Method not implemented.'); + } + + public static async resolve(did: string): Promise { + throw new Error('Method not implemented.'); + } + + public static async generateJwkKeyPair(options: { + keyAlgorithm: typeof SupportedCryptoAlgorithms[number], + keyId?: string + }): Promise { + const { keyAlgorithm, keyId } = options; + + let cryptoKeyPair: Web5Crypto.CryptoKeyPair; + + switch (keyAlgorithm) { + case 'Ed25519': { + cryptoKeyPair = await new EdDsaAlgorithm().generateKey({ + algorithm : { name: 'EdDSA', namedCurve: 'Ed25519' }, + extractable : true, + keyUsages : ['sign', 'verify'] + }); + break; + } + + case 'secp256k1': { + cryptoKeyPair = await new EcdsaAlgorithm().generateKey({ + algorithm : { name: 'ECDSA', namedCurve: 'secp256k1' }, + extractable : true, + keyUsages : ['sign', 'verify'] + }); + break; + } + + default: { + throw new Error(`Unsupported crypto algorithm: '${keyAlgorithm}'`); + } + } + + // Convert the CryptoKeyPair to JwkKeyPair. + const jwkKeyPair = await Jose.cryptoKeyToJwkPair({ keyPair: cryptoKeyPair }); + + // Set kid values. + if (keyId) { + jwkKeyPair.privateKeyJwk.kid = keyId; + jwkKeyPair.publicKeyJwk.kid = keyId; + } else { + // If a key ID is not specified, generate RFC 7638 JWK thumbprint. + const jwkThumbprint = await Jose.jwkThumbprint({ key: jwkKeyPair.publicKeyJwk }); + jwkKeyPair.privateKeyJwk.kid = jwkThumbprint; + jwkKeyPair.publicKeyJwk.kid = jwkThumbprint; + } + + return jwkKeyPair; + } + + public static async generateKeySet(options?: { + keySet?: DidDhtKeySet + }): Promise { + let { keySet = {} } = options ?? { }; + + if (!keySet.identityKey) { + const identityKeyPair = await this.generateJwkKeyPair({ + keyAlgorithm : 'Ed25519', + keyId : '0' + }); + keySet.identityKey = identityKeyPair; + keySet.verificationMethodKeys = [{ + ...identityKeyPair, + relationships: ['authentication', 'assertionMethod', 'capabilityInvocation', 'capabilityDelegation'] + }]; + } + + // Generate RFC 7638 JWK thumbprints if `kid` is missing from any key. + if (keySet.verificationMethodKeys) { + for (const key of keySet.verificationMethodKeys) { + if (key.publicKeyJwk) key.publicKeyJwk.kid ??= await Jose.jwkThumbprint({key: key.publicKeyJwk}); + if (key.privateKeyJwk) key.privateKeyJwk.kid ??= await Jose.jwkThumbprint({key: key.privateKeyJwk}); + } + } + + return keySet; + } +} diff --git a/impls/ts/src/util.ts b/impls/ts/src/util.ts new file mode 100644 index 00000000..e69de29b diff --git a/impls/ts/tests/codec.spec.ts b/impls/ts/tests/codec.spec.ts new file mode 100644 index 00000000..39a7a41d --- /dev/null +++ b/impls/ts/tests/codec.spec.ts @@ -0,0 +1,20 @@ +import { expect } from 'chai'; +import {Codec} from "../src/codec.js"; + +describe('Codec', async () => { + const codec = new Codec(); + + it('encodes and decodes an uncompressable value', async () => { + const uncompressable = [['2'], ['3']]; + const encoded = await codec.encode(uncompressable); + const decoded = await codec.decode(encoded); + expect(decoded).to.deep.equal(uncompressable); + }); + + it('encodes and decodes a compressable value', async() =>{ + const records = [['did', '{"@context":"https://w3id.org/did/v1", "id": "did:example:123"}']]; + const encoded = await codec.encode(records); + const decoded = await codec.decode(encoded); + expect(decoded).to.deep.equal(records); + }); +}); diff --git a/impls/ts/tests/tsconfig.json b/impls/ts/tests/tsconfig.json new file mode 100644 index 00000000..02e6ac4f --- /dev/null +++ b/impls/ts/tests/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "outDir": "compiled", + "declarationDir": "compiled/types", + "sourceMap": true, + }, + "include": [ + "../src", + "../typings", + ".", + ], + "exclude": [ + "./compiled" + ] +} diff --git a/impls/ts/tsconfig.cjs.json b/impls/ts/tsconfig.cjs.json new file mode 100644 index 00000000..56db98ae --- /dev/null +++ b/impls/ts/tsconfig.cjs.json @@ -0,0 +1,20 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "lib": [ + "DOM", + "ES5", + ], + "target": "ES5", + "module": "CommonJS", + "outDir": "dist/cjs", + "declaration": false, + "declarationMap": false, + "declarationDir": null, + "downlevelIteration": true + }, + "include": [ + "src", + "typings" + ] +} From 16654ab630fcb268fe4f0207d64bd6087e334d57 Mon Sep 17 00:00:00 2001 From: gabe Date: Sat, 14 Oct 2023 14:34:08 -0700 Subject: [PATCH 02/11] to dns packet --- impl/cmd/cli/identity.go | 10 ++- impl/go.mod | 6 ++ impl/go.sum | 13 +++ impl/internal/did/did.go | 149 ++++++++++++++++++++++++++++++++-- impl/internal/did/did_test.go | 32 ++++++++ impl/pkg/dht/pkarr.go | 38 +++++---- impl/pkg/dht/pkarr_test.go | 14 +++- 7 files changed, 231 insertions(+), 31 deletions(-) diff --git a/impl/cmd/cli/identity.go b/impl/cmd/cli/identity.go index 7b8fd77b..8431456d 100644 --- a/impl/cmd/cli/identity.go +++ b/impl/cmd/cli/identity.go @@ -92,8 +92,16 @@ var identityAddCmd = &cobra.Command{ rrds = append(rrds, &rr) } + msg := dns.Msg{ + MsgHdr: dns.MsgHdr{ + Id: 0, + Response: true, + Authoritative: true, + }, + Answer: rrds, + } // generate put request - putReq, err := dht.CreatePKARRPutRequest(pubKey, privKey, rrds) + putReq, err := dht.CreatePKARRPutRequest(pubKey, privKey, msg) if err != nil { logrus.WithError(err).Error("failed to create put request") return err diff --git a/impl/go.mod b/impl/go.mod index 791d1ed9..107ffe22 100644 --- a/impl/go.mod +++ b/impl/go.mod @@ -42,6 +42,7 @@ require ( github.com/go-playground/validator/v10 v10.13.0 // indirect github.com/goccy/go-json v0.10.2 // indirect github.com/google/uuid v1.3.0 // indirect + github.com/gowebpki/jcs v1.0.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/huandu/xstrings v1.3.2 // indirect github.com/hyperledger/aries-framework-go v0.3.1 // indirect @@ -51,6 +52,7 @@ require ( github.com/hyperledger/aries-framework-go/spi v0.0.0-20230427134832-0c9969493bd3 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/kilic/bls12-381 v0.1.1-0.20210503002446-7b7597926c69 // indirect + github.com/klauspost/cpuid/v2 v2.0.9 // indirect github.com/leodido/go-urn v1.2.3 // indirect github.com/lestrrat-go/blackmagic v1.0.1 // indirect github.com/lestrrat-go/httpcc v1.0.1 // indirect @@ -60,11 +62,13 @@ require ( github.com/lestrrat-go/option v1.0.1 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/miekg/dns v1.1.56 // indirect + github.com/minio/sha256-simd v1.0.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/multiformats/go-base32 v0.1.0 // indirect github.com/multiformats/go-base36 v0.1.0 // indirect github.com/multiformats/go-multibase v0.2.0 // indirect github.com/multiformats/go-multicodec v0.9.0 // indirect + github.com/multiformats/go-multihash v0.2.1 // indirect github.com/multiformats/go-varint v0.0.7 // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect github.com/piprate/json-gold v0.5.0 // indirect @@ -75,6 +79,7 @@ require ( github.com/sagikazarmark/locafero v0.3.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sourcegraph/conc v0.3.0 // indirect + github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/spf13/afero v1.10.0 // indirect github.com/spf13/cast v1.5.1 // indirect github.com/spf13/pflag v1.0.5 // indirect @@ -92,4 +97,5 @@ require ( golang.org/x/tools v0.13.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + lukechampine.com/blake3 v1.1.6 // indirect ) diff --git a/impl/go.sum b/impl/go.sum index d7d6acd3..5e111df9 100644 --- a/impl/go.sum +++ b/impl/go.sum @@ -245,6 +245,8 @@ github.com/gopherjs/gopherjs v0.0.0-20190309154008-847fc94819f9/go.mod h1:wJfORR github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= +github.com/gowebpki/jcs v1.0.0 h1:0pZtOgGetfH/L7yXb4KWcJqIyZNA43WXFyMd7ftZACw= +github.com/gowebpki/jcs v1.0.0/go.mod h1:CID1cNZ+sHp1CCpAR8mPf6QRtagFBgPJE0FCUQ6+BrI= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= @@ -281,6 +283,9 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V github.com/kilic/bls12-381 v0.1.1-0.20210503002446-7b7597926c69 h1:kMJlf8z8wUcpyI+FQJIdGjAhfTww1y0AbQEv86bpVQI= github.com/kilic/bls12-381 v0.1.1-0.20210503002446-7b7597926c69/go.mod h1:tlkavyke+Ac7h8R3gZIjI5LKBcvMlSWnXNMgT3vZXo8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= @@ -313,6 +318,8 @@ github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3v github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.1.56 h1:5imZaSeoRNvpM9SzWNhEcP9QliKiz20/dA2QabIGVnE= github.com/miekg/dns v1.1.56/go.mod h1:cRm6Oo2C8TY9ZS/TqsSrseAcncm74lfK5G+ikN2SWWY= +github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g= +github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= @@ -333,6 +340,8 @@ github.com/multiformats/go-multibase v0.2.0 h1:isdYCVLvksgWlMW9OZRYJEa9pZETFivnc github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6oPyjtnzK/XTFDPkNuk= github.com/multiformats/go-multicodec v0.9.0 h1:pb/dlPnzee/Sxv/j4PmkDRxCOi3hXTz3IbPKOXWJkmg= github.com/multiformats/go-multicodec v0.9.0/go.mod h1:L3QTQvMIaVBkXOXXtVmYE+LI16i14xuaojr/H7Ai54k= +github.com/multiformats/go-multihash v0.2.1 h1:aem8ZT0VA2nCHHk7bPJ1BjUbHNciqZC/d16Vve9l108= +github.com/multiformats/go-multihash v0.2.1/go.mod h1:WxoMcYG85AZVQUyRyo9s4wULvW5qrI9vb2Lt6evduFc= github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8= github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= @@ -395,6 +404,8 @@ github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:X github.com/smartystreets/goconvey v0.0.0-20190306220146-200a235640ff/go.mod h1:KSQcGKpxUMHk3nbYzs/tIBAM2iDooCn0BmttHOJEbLs= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= +github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= +github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.10.0 h1:EaGW2JJh15aKOejeuJ+wpFSHnbd7GE6Wvp3TsNhb6LY= github.com/spf13/afero v1.10.0/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ= github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA= @@ -807,6 +818,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +lukechampine.com/blake3 v1.1.6 h1:H3cROdztr7RCfoaTpGZFQsrqvweFLrqS73j7L7cmR5c= +lukechampine.com/blake3 v1.1.6/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/impl/internal/did/did.go b/impl/internal/did/did.go index 4ae045bc..a65396ab 100644 --- a/impl/internal/did/did.go +++ b/impl/internal/did/did.go @@ -2,6 +2,7 @@ package did import ( "crypto/ed25519" + "encoding/base64" "fmt" "strings" @@ -76,11 +77,11 @@ func CreateDIDDHTDID(pubKey ed25519.PublicKey, opts CreateDIDDHTOpts) (*did.Docu // validate opts and build verification methods, key purposes, and services var vms []did.VerificationMethod - var authentication []did.VerificationMethodSet - var assertionMethod []did.VerificationMethodSet - var keyAgreement []did.VerificationMethodSet - var capabilityInvocation []did.VerificationMethodSet - var capabilityDelegation []did.VerificationMethodSet + authentication := []did.VerificationMethodSet{"#0"} + assertionMethod := []did.VerificationMethodSet{"#0"} + keyAgreement := []did.VerificationMethodSet{"#0"} + capabilityInvocation := []did.VerificationMethodSet{"#0"} + capabilityDelegation := []did.VerificationMethodSet{"#0"} if len(opts.VerificationMethods) > 0 { seenIDs := make(map[string]bool) for _, vm := range opts.VerificationMethods { @@ -168,11 +169,141 @@ func GetDIDDHTIdentifier(pubKey []byte) string { return strings.Join([]string{Prefix, zbase32.EncodeToString(pubKey)}, ":") } -func (d DHT) ToDNSPacket(did did.Document) ([]dns.RR, error) { - if d.String() != did.ID { - return nil, fmt.Errorf("did and dht id mismatch") +// ToDNSPacket converts a did document to a DNS packet +func (d DHT) ToDNSPacket(doc did.Document) (*dns.Msg, error) { + var records []dns.RR + var rootRecord []string + keyLookup := make(map[string]string) + + // build all key records + var vmIDs []string + for i, vm := range doc.VerificationMethod { + recordIdentifier := fmt.Sprintf("k%d", i) + vmID := strings.Split(vm.ID, "#")[1] + keyLookup[vm.ID] = recordIdentifier + + var keyType int + switch vm.PublicKeyJWK.ALG { + case "EdDSA": + keyType = 0 + case "ES256K": + keyType = 1 + default: + return nil, fmt.Errorf("unsupported key type: %s", vm.PublicKeyJWK.ALG) + } + + // convert the public key to a base64url encoded string + pubKey, err := vm.PublicKeyJWK.ToPublicKey() + if err != nil { + return nil, err + } + pubKeyBytes, err := crypto.PubKeyToBytes(pubKey) + if err != nil { + return nil, err + } + keyBase64Url := base64.RawURLEncoding.EncodeToString(pubKeyBytes) + + keyRecord := dns.TXT{ + Hdr: dns.RR_Header{ + Name: fmt.Sprintf("_%s._did", recordIdentifier), + Rrtype: dns.TypeTXT, + Class: dns.ClassINET, + Ttl: 7200, + }, + Txt: []string{fmt.Sprintf("id=%s,t=%d,k=%s", vmID, keyType, keyBase64Url)}, + } + + records = append(records, &keyRecord) + vmIDs = append(vmIDs, recordIdentifier) } - return nil, nil + // add verification methods to the root record + rootRecord = append(rootRecord, fmt.Sprintf("vm=%s", strings.Join(vmIDs, ","))) + + var svcIDs []string + for i, service := range doc.Services { + recordIdentifier := fmt.Sprintf("s%d", i) + sID := strings.Split("#", service.ID)[1] + + serviceRecord := dns.TXT{ + Hdr: dns.RR_Header{ + Name: fmt.Sprintf("_%s._did", recordIdentifier), + Rrtype: dns.TypeTXT, + Class: dns.ClassINET, + Ttl: 7200, + }, + Txt: []string{fmt.Sprintf("id=%s,t=%s,uri=%s", sID, service.Type, service.ServiceEndpoint)}, + } + + records = append(records, &serviceRecord) + svcIDs = append(svcIDs, recordIdentifier) + } + // add services to the root record + if len(svcIDs) != 0 { + rootRecord = append(rootRecord, fmt.Sprintf("svc=%s", strings.Join(svcIDs, ","))) + } + + // add verification relationships to the root record + var authIDs []string + for _, auth := range doc.Authentication { + authIDs = append(authIDs, keyLookup[doc.ID+auth.(string)]) + } + if len(authIDs) != 0 { + rootRecord = append(rootRecord, fmt.Sprintf("auth=%s", strings.Join(authIDs, ","))) + } + + var assertionIDs []string + for _, assertion := range doc.AssertionMethod { + assertionIDs = append(assertionIDs, keyLookup[doc.ID+assertion.(string)]) + } + if len(assertionIDs) != 0 { + rootRecord = append(rootRecord, fmt.Sprintf("asm=%s", strings.Join(assertionIDs, ","))) + } + + var keyAgreementIDs []string + for _, keyAgreement := range doc.KeyAgreement { + keyAgreementIDs = append(keyAgreementIDs, keyLookup[doc.ID+keyAgreement.(string)]) + } + if len(keyAgreementIDs) != 0 { + rootRecord = append(rootRecord, fmt.Sprintf("agm=%s", strings.Join(keyAgreementIDs, ","))) + } + + var capabilityInvocationIDs []string + for _, capabilityInvocation := range doc.CapabilityInvocation { + capabilityInvocationIDs = append(capabilityInvocationIDs, keyLookup[doc.ID+capabilityInvocation.(string)]) + } + if len(capabilityInvocationIDs) != 0 { + rootRecord = append(rootRecord, fmt.Sprintf("inv=%s", strings.Join(capabilityInvocationIDs, ","))) + } + + var capabilityDelegationIDs []string + for _, capabilityDelegation := range doc.CapabilityDelegation { + capabilityDelegationIDs = append(capabilityDelegationIDs, keyLookup[doc.ID+capabilityDelegation.(string)]) + } + if len(capabilityDelegationIDs) != 0 { + rootRecord = append(rootRecord, fmt.Sprintf("del=%s", strings.Join(capabilityDelegationIDs, ","))) + } + + // add the root record + rootAnswer := dns.TXT{ + Hdr: dns.RR_Header{ + Name: "_did", + Rrtype: dns.TypeTXT, + Class: dns.ClassINET, + Ttl: 7200, + }, + Txt: []string{strings.Join(rootRecord, ";")}, + } + records = append(records, &rootAnswer) + + // build the dns packet + return &dns.Msg{ + MsgHdr: dns.MsgHdr{ + Id: 0, + Response: true, + Authoritative: true, + }, + Answer: records, + }, nil } func (d DHT) FromDNSPacket() (*did.Document, error) { diff --git a/impl/internal/did/did_test.go b/impl/internal/did/did_test.go index 2bfcc86b..8f7fcced 100644 --- a/impl/internal/did/did_test.go +++ b/impl/internal/did/did_test.go @@ -1 +1,33 @@ package did + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestGenerateDIDDHT(t *testing.T) { + t.Run("test generate did:dht with no options", func(t *testing.T) { + privKey, doc, err := GenerateDIDDHT(CreateDIDDHTOpts{}) + require.NoError(t, err) + require.NotEmpty(t, privKey) + require.NotEmpty(t, doc) + }) +} + +func TestToDNSPacket(t *testing.T) { + t.Run("test to dns packet", func(t *testing.T) { + privKey, doc, err := GenerateDIDDHT(CreateDIDDHTOpts{}) + require.NoError(t, err) + require.NotEmpty(t, privKey) + require.NotEmpty(t, doc) + + did := DHT(doc.ID) + + packet, err := did.ToDNSPacket(*doc) + require.NoError(t, err) + require.NotEmpty(t, packet) + + println(packet.String()) + }) +} diff --git a/impl/pkg/dht/pkarr.go b/impl/pkg/dht/pkarr.go index eeef02b4..7f012fa0 100644 --- a/impl/pkg/dht/pkarr.go +++ b/impl/pkg/dht/pkarr.go @@ -10,26 +10,28 @@ import ( ) // CreatePKARRPutRequest creates a put request for the given records. Requires a public/private keypair and the records to put. -// The records are expected to be a slice of DNS resource records, such as: +// The records are expected to be a DNS message packet, such as: // -// [][]dns.RR{ -// dns.TXT{ -// Hdr: dns.RR_Header{ -// Name: "_did.", -// Rrtype: dns.TypeTXT, -// Class: dns.ClassINET, -// Ttl: 7200, +// dns.Msg{ +// MsgHdr: dns.MsgHdr{ +// Id: 0, +// Response: true, +// Authoritative: true, // }, -// Txt: []string{ -// "hello pkarr", -// }, -// } -// } -func CreatePKARRPutRequest(publicKey ed25519.PublicKey, privateKey ed25519.PrivateKey, records []dns.RR) (*bep44.Put, error) { - msg := new(dns.Msg) - for _, record := range records { - msg.Answer = append(msg.Answer, record) - } +// Answer: dns.RR{ +// dns.TXT{ +// Hdr: dns.RR_Header{ +// Name: "_did.", +// Rrtype: dns.TypeTXT, +// Class: dns.ClassINET, +// Ttl: 7200, +// }, +// Txt: []string{ +// "hello pkarr", +// }, +// } +// } +func CreatePKARRPutRequest(publicKey ed25519.PublicKey, privateKey ed25519.PrivateKey, msg dns.Msg) (*bep44.Put, error) { packed, err := msg.Pack() if err != nil { logrus.WithError(err).Error("failed to pack records") diff --git a/impl/pkg/dht/pkarr_test.go b/impl/pkg/dht/pkarr_test.go index 6a7392e9..809a4875 100644 --- a/impl/pkg/dht/pkarr_test.go +++ b/impl/pkg/dht/pkarr_test.go @@ -18,7 +18,7 @@ func TestGetPutPKARRDHT(t *testing.T) { pubKey, privKey, err := util.GenerateKeypair() require.NoError(t, err) - txtPacket := dns.TXT{ + txtRecord := dns.TXT{ Hdr: dns.RR_Header{ Name: "_did.", Rrtype: dns.TypeTXT, @@ -29,7 +29,15 @@ func TestGetPutPKARRDHT(t *testing.T) { "hello pkarr", }, } - put, err := CreatePKARRPutRequest(pubKey, privKey, []dns.RR{&txtPacket}) + msg := dns.Msg{ + MsgHdr: dns.MsgHdr{ + Id: 0, + Response: true, + Authoritative: true, + }, + Answer: []dns.RR{&txtRecord}, + } + put, err := CreatePKARRPutRequest(pubKey, privKey, msg) require.NoError(t, err) id, err := d.Put(context.Background(), pubKey, *put) @@ -44,5 +52,5 @@ func TestGetPutPKARRDHT(t *testing.T) { require.NoError(t, err) require.NotEmpty(t, gotRRs) - assert.Equal(t, txtPacket.Txt, gotRRs[0].(*dns.TXT).Txt) + assert.Equal(t, txtRecord.Txt, gotRRs[0].(*dns.TXT).Txt) } From c0207915f588656d9c34dd76ec50ce663b6b02b7 Mon Sep 17 00:00:00 2001 From: gabe Date: Sat, 14 Oct 2023 14:35:01 -0700 Subject: [PATCH 03/11] remove ts --- impls/ts/.c8rc.json | 19 ------ impls/ts/.eslintrc.cjs | 56 --------------- impls/ts/.mocharc.json | 5 -- impls/ts/package.json | 41 ----------- impls/ts/src/codec.ts | 22 ------ impls/ts/src/did-dht.ts | 129 ----------------------------------- impls/ts/src/util.ts | 0 impls/ts/tests/codec.spec.ts | 20 ------ impls/ts/tests/tsconfig.json | 16 ----- impls/ts/tsconfig.cjs.json | 20 ------ 10 files changed, 328 deletions(-) delete mode 100644 impls/ts/.c8rc.json delete mode 100644 impls/ts/.eslintrc.cjs delete mode 100644 impls/ts/.mocharc.json delete mode 100644 impls/ts/package.json delete mode 100644 impls/ts/src/codec.ts delete mode 100644 impls/ts/src/did-dht.ts delete mode 100644 impls/ts/src/util.ts delete mode 100644 impls/ts/tests/codec.spec.ts delete mode 100644 impls/ts/tests/tsconfig.json delete mode 100644 impls/ts/tsconfig.cjs.json diff --git a/impls/ts/.c8rc.json b/impls/ts/.c8rc.json deleted file mode 100644 index 8e2c6a1b..00000000 --- a/impls/ts/.c8rc.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "all": true, - "cache": false, - "extension": [ - ".js" - ], - "include": [ - "tests/compiled/src/**" - ], - "exclude": [ - "tests/compiled/src/index.js", - "tests/compiled/src/types.js", - "tests/compiled/src/types/**" - ], - "reporter": [ - "cobertura", - "text" - ] -} diff --git a/impls/ts/.eslintrc.cjs b/impls/ts/.eslintrc.cjs deleted file mode 100644 index 65bd48ee..00000000 --- a/impls/ts/.eslintrc.cjs +++ /dev/null @@ -1,56 +0,0 @@ -/** @type {import('eslint').ESLint.ConfigData} */ -module.exports = { - root : true, - extends : ['eslint:recommended', 'plugin:@typescript-eslint/recommended'], - parser : '@typescript-eslint/parser', - parserOptions : { - ecmaVersion : 2022, - sourceType : 'module' - }, - plugins : ['@typescript-eslint', 'mocha'], - env : { - node : true, - es2022 : true, - browser : true - }, - 'ignorePatterns': [ - 'dist', - '**/tests/compiled' - ], - rules: { - 'key-spacing': [ - 'error', - { - 'align': { - 'afterColon' : true, - 'beforeColon' : true, - 'on' : 'colon' - } - } - ], - 'quotes': [ - 'error', - 'single', - { 'allowTemplateLiterals': true } - ], - 'semi' : ['error', 'always'], - 'indent' : ['error', 2, { 'SwitchCase': 1 }], - 'no-unused-vars' : 'off', - 'prefer-const' : 'off', - '@typescript-eslint/no-unused-vars' : [ - 'error', - { - 'vars' : 'all', - 'args' : 'after-used', - 'ignoreRestSiblings' : true, - 'argsIgnorePattern' : '^_', - 'varsIgnorePattern' : '^_' - } - ], - '@typescript-eslint/no-explicit-any' : 'off', - 'no-trailing-spaces' : ['error'], - '@typescript-eslint/no-non-null-assertion' : 'off', - '@typescript-eslint/ban-ts-comment' : 'off', - 'mocha/no-exclusive-tests' : 'warn' - } -}; diff --git a/impls/ts/.mocharc.json b/impls/ts/.mocharc.json deleted file mode 100644 index ab67dfc3..00000000 --- a/impls/ts/.mocharc.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "enable-source-maps": true, - "exit": true, - "spec": ["tests/compiled/**/*.spec.js"] -} diff --git a/impls/ts/package.json b/impls/ts/package.json deleted file mode 100644 index 669ae67a..00000000 --- a/impls/ts/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "did-dht-method", - "version": "0.0.1", - "type": "module", - "main": "./dist/cjs/index.js", - "module": "./dist/esm/index.js", - "types": "./dist/types/index.d.ts", - "scripts": { - "clean": "rimraf dist coverage tests/compiled", - "test": "tsc -p tests/tsconfig.json && c8 mocha", - "lint": "eslint . --ext .ts --max-warnings 0", - "lint:fix": "eslint . --ext .ts --fix" - }, - "engines": { - "node": ">=18.0.0" - }, - "devDependencies": { - "@types/b4a": "^1.6.1", - "@types/chai": "^4.3.6", - "@types/mocha": "^10.0.2", - "@typescript-eslint/eslint-plugin": "^6.7.4", - "eslint": "^8.50.0", - "eslint-config-standard-with-typescript": "^39.1.0", - "eslint-plugin-import": "^2.28.1", - "eslint-plugin-mocha": "^10.2.0", - "eslint-plugin-n": "^16.1.0", - "eslint-plugin-promise": "^6.1.1", - "eslint-plugin-react": "^7.33.2", - "typescript": "^5.2.2" - }, - "dependencies": { - "@web5/crypto": "^0.2.0", - "@web5/dids": "^0.2.0", - "b4a": "^1.6.4", - "brotli-compress": "^1.3.3", - "brotli-wasm": "^2.0.0", - "c8": "^8.0.1", - "chai": "^4.3.10", - "rimraf": "^5.0.5" - } -} diff --git a/impls/ts/src/codec.ts b/impls/ts/src/codec.ts deleted file mode 100644 index 46fbd710..00000000 --- a/impls/ts/src/codec.ts +++ /dev/null @@ -1,22 +0,0 @@ -import brotli from 'brotli-compress'; -import b4a from 'b4a'; - -export class Codec { - /** - * @param records An array of arrays containing strings - */ - async encode(records: string[][]): Promise { - const string = JSON.stringify(records); - const encoded = b4a.from(string); - return await brotli.compress(encoded); - } - - /** - * @param encoded A Uint8Array containing the encoded data - */ - async decode(encoded: Uint8Array): Promise { - const decoded = await brotli.decompress(encoded); - const string = b4a.toString(b4a.from(decoded)); - return JSON.parse(string); - } -} diff --git a/impls/ts/src/did-dht.ts b/impls/ts/src/did-dht.ts deleted file mode 100644 index 61239596..00000000 --- a/impls/ts/src/did-dht.ts +++ /dev/null @@ -1,129 +0,0 @@ -import type { PrivateKeyJwk, PublicKeyJwk, JwkKeyPair } from '@web5/crypto'; -import type { - DidDocument, - DidKeySetVerificationMethodKey, - DidMethod, - DidResolutionResult, - DidService, - PortableDid -} from '@web5/dids'; -import {EcdsaAlgorithm, EdDsaAlgorithm, Jose, Web5Crypto} from '@web5/crypto'; - -const SupportedCryptoAlgorithms = [ - 'Ed25519', - 'secp256k1' -] as const; - -export type DidDhtCreateOptions = { - publish?: boolean; - keySet?: DidDhtKeySet; - services?: DidService[]; -} - -export type DidDhtKeySet = { - identityKey?: JwkKeyPair; - verificationMethodKeys?: DidKeySetVerificationMethodKey[]; -} - -export class DidDhtMethod implements DidMethod { - - public static methodName = 'dht'; - - public static async create(options?: DidDhtCreateOptions): Promise { - let { publish, keySet, services } = options ?? { }; - - // Begin constructing a PortableDid - const did: Partial = {}; - - // Generate missing keys if not provided in the options - did.keySet = await this.generateKeySet({ keySet }); - - // Get the identifier - throw new Error('Method not implemented.'); - } - - public static async publish(key: DidDhtKeySet, didDocument: DidDocument): Promise { - throw new Error('Method not implemented.'); - } - - public static async resolve(did: string): Promise { - throw new Error('Method not implemented.'); - } - - public static async generateJwkKeyPair(options: { - keyAlgorithm: typeof SupportedCryptoAlgorithms[number], - keyId?: string - }): Promise { - const { keyAlgorithm, keyId } = options; - - let cryptoKeyPair: Web5Crypto.CryptoKeyPair; - - switch (keyAlgorithm) { - case 'Ed25519': { - cryptoKeyPair = await new EdDsaAlgorithm().generateKey({ - algorithm : { name: 'EdDSA', namedCurve: 'Ed25519' }, - extractable : true, - keyUsages : ['sign', 'verify'] - }); - break; - } - - case 'secp256k1': { - cryptoKeyPair = await new EcdsaAlgorithm().generateKey({ - algorithm : { name: 'ECDSA', namedCurve: 'secp256k1' }, - extractable : true, - keyUsages : ['sign', 'verify'] - }); - break; - } - - default: { - throw new Error(`Unsupported crypto algorithm: '${keyAlgorithm}'`); - } - } - - // Convert the CryptoKeyPair to JwkKeyPair. - const jwkKeyPair = await Jose.cryptoKeyToJwkPair({ keyPair: cryptoKeyPair }); - - // Set kid values. - if (keyId) { - jwkKeyPair.privateKeyJwk.kid = keyId; - jwkKeyPair.publicKeyJwk.kid = keyId; - } else { - // If a key ID is not specified, generate RFC 7638 JWK thumbprint. - const jwkThumbprint = await Jose.jwkThumbprint({ key: jwkKeyPair.publicKeyJwk }); - jwkKeyPair.privateKeyJwk.kid = jwkThumbprint; - jwkKeyPair.publicKeyJwk.kid = jwkThumbprint; - } - - return jwkKeyPair; - } - - public static async generateKeySet(options?: { - keySet?: DidDhtKeySet - }): Promise { - let { keySet = {} } = options ?? { }; - - if (!keySet.identityKey) { - const identityKeyPair = await this.generateJwkKeyPair({ - keyAlgorithm : 'Ed25519', - keyId : '0' - }); - keySet.identityKey = identityKeyPair; - keySet.verificationMethodKeys = [{ - ...identityKeyPair, - relationships: ['authentication', 'assertionMethod', 'capabilityInvocation', 'capabilityDelegation'] - }]; - } - - // Generate RFC 7638 JWK thumbprints if `kid` is missing from any key. - if (keySet.verificationMethodKeys) { - for (const key of keySet.verificationMethodKeys) { - if (key.publicKeyJwk) key.publicKeyJwk.kid ??= await Jose.jwkThumbprint({key: key.publicKeyJwk}); - if (key.privateKeyJwk) key.privateKeyJwk.kid ??= await Jose.jwkThumbprint({key: key.privateKeyJwk}); - } - } - - return keySet; - } -} diff --git a/impls/ts/src/util.ts b/impls/ts/src/util.ts deleted file mode 100644 index e69de29b..00000000 diff --git a/impls/ts/tests/codec.spec.ts b/impls/ts/tests/codec.spec.ts deleted file mode 100644 index 39a7a41d..00000000 --- a/impls/ts/tests/codec.spec.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { expect } from 'chai'; -import {Codec} from "../src/codec.js"; - -describe('Codec', async () => { - const codec = new Codec(); - - it('encodes and decodes an uncompressable value', async () => { - const uncompressable = [['2'], ['3']]; - const encoded = await codec.encode(uncompressable); - const decoded = await codec.decode(encoded); - expect(decoded).to.deep.equal(uncompressable); - }); - - it('encodes and decodes a compressable value', async() =>{ - const records = [['did', '{"@context":"https://w3id.org/did/v1", "id": "did:example:123"}']]; - const encoded = await codec.encode(records); - const decoded = await codec.decode(encoded); - expect(decoded).to.deep.equal(records); - }); -}); diff --git a/impls/ts/tests/tsconfig.json b/impls/ts/tests/tsconfig.json deleted file mode 100644 index 02e6ac4f..00000000 --- a/impls/ts/tests/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "outDir": "compiled", - "declarationDir": "compiled/types", - "sourceMap": true, - }, - "include": [ - "../src", - "../typings", - ".", - ], - "exclude": [ - "./compiled" - ] -} diff --git a/impls/ts/tsconfig.cjs.json b/impls/ts/tsconfig.cjs.json deleted file mode 100644 index 56db98ae..00000000 --- a/impls/ts/tsconfig.cjs.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "lib": [ - "DOM", - "ES5", - ], - "target": "ES5", - "module": "CommonJS", - "outDir": "dist/cjs", - "declaration": false, - "declarationMap": false, - "declarationDir": null, - "downlevelIteration": true - }, - "include": [ - "src", - "typings" - ] -} From b28d7c52ca3e5e980a966aa6306527a51edeeb85 Mon Sep 17 00:00:00 2001 From: gabe Date: Sat, 14 Oct 2023 16:24:36 -0700 Subject: [PATCH 04/11] roundtrip dns packet --- impl/internal/did/did.go | 128 ++++++++++++++++++++++++++++++++-- impl/internal/did/did_test.go | 35 +++++++++- 2 files changed, 157 insertions(+), 6 deletions(-) diff --git a/impl/internal/did/did.go b/impl/internal/did/did.go index a65396ab..7a3916b0 100644 --- a/impl/internal/did/did.go +++ b/impl/internal/did/did.go @@ -152,7 +152,6 @@ func CreateDIDDHTDID(pubKey ed25519.PublicKey, opts CreateDIDDHTOpts) (*did.Docu PublicKeyJWK: key0JWK, } return &did.Document{ - Context: []string{did.KnownDIDContext}, ID: id, VerificationMethod: append([]did.VerificationMethod{vm0}, vms...), Services: opts.Services, @@ -169,7 +168,7 @@ func GetDIDDHTIdentifier(pubKey []byte) string { return strings.Join([]string{Prefix, zbase32.EncodeToString(pubKey)}, ":") } -// ToDNSPacket converts a did document to a DNS packet +// ToDNSPacket converts a DID DHT Document to a DNS packet func (d DHT) ToDNSPacket(doc did.Document) (*dns.Msg, error) { var records []dns.RR var rootRecord []string @@ -306,6 +305,127 @@ func (d DHT) ToDNSPacket(doc did.Document) (*dns.Msg, error) { }, nil } -func (d DHT) FromDNSPacket() (*did.Document, error) { - return nil, nil +// FromDNSPacket converts a DNS packet to a DID DHT Document +func (d DHT) FromDNSPacket(msg *dns.Msg) (*did.Document, error) { + doc := did.Document{ + ID: d.String(), + } + + keyLookup := make(map[string]string) + for _, rr := range msg.Answer { + switch record := rr.(type) { + case *dns.TXT: + if strings.HasPrefix(record.Hdr.Name, "_k") { + data := parseTxtData(strings.Join(record.Txt, ",")) + vmID := data["id"] + keyType := keyTypeLookUp(data["t"]) + keyBase64URL := data["k"] + + // Convert keyBase64URL back to PublicKeyJWK + pubKeyBytes, err := base64.RawURLEncoding.DecodeString(keyBase64URL) + if err != nil { + return nil, err + } + pubKey, err := crypto.BytesToPubKey(pubKeyBytes, keyType) + if err != nil { + return nil, err + } + pubKeyJWK, err := jwx.PublicKeyToPublicKeyJWK(vmID, pubKey) + if err != nil { + return nil, err + } + + vm := did.VerificationMethod{ + ID: d.String() + "#" + vmID, + Type: cryptosuite.JSONWebKey2020Type, + Controller: d.String(), + PublicKeyJWK: pubKeyJWK, + } + doc.VerificationMethod = append(doc.VerificationMethod, vm) + + // add to key lookup (e.g. "k1" -> "#key1") + keyLookup[strings.Split(record.Hdr.Name, ".")[0][1:]] = "#" + vmID + } else if strings.HasPrefix(record.Hdr.Name, "_s") { + data := parseTxtData(strings.Join(record.Txt, ",")) + sID := data["id"] + serviceType := data["t"] + serviceEndpoint := data["uri"] + + service := did.Service{ + ID: d.String() + "#" + sID, + Type: serviceType, + ServiceEndpoint: serviceEndpoint, + } + doc.Services = append(doc.Services, service) + + } else if record.Hdr.Name == "_did" { + rootData := strings.Join(record.Txt, ";") + rootItems := strings.Split(rootData, ";") + + for _, item := range rootItems { + kv := strings.Split(item, "=") + if len(kv) != 2 { + continue + } + + key, values := kv[0], kv[1] + valueItems := strings.Split(values, ",") + + switch key { + case "vm": + // These are already processed in the "_k" prefix case + continue + case "srv": + // These are already processed in the "_s" prefix case + continue + case "auth": + for _, valueItem := range valueItems { + doc.Authentication = append(doc.Authentication, keyLookup[valueItem]) + } + case "asm": + for _, valueItem := range valueItems { + doc.AssertionMethod = append(doc.AssertionMethod, keyLookup[valueItem]) + } + case "agm": + for _, valueItem := range valueItems { + doc.KeyAgreement = append(doc.KeyAgreement, keyLookup[valueItem]) + } + case "inv": + for _, valueItem := range valueItems { + doc.CapabilityInvocation = append(doc.CapabilityInvocation, keyLookup[valueItem]) + } + case "del": + for _, valueItem := range valueItems { + doc.CapabilityDelegation = append(doc.CapabilityDelegation, keyLookup[valueItem]) + } + } + } + } + } + } + + return &doc, nil +} + +func parseTxtData(data string) map[string]string { + pairs := strings.Split(data, ",") + result := make(map[string]string) + for _, pair := range pairs { + kv := strings.Split(pair, "=") + if len(kv) == 2 { + result[kv[0]] = kv[1] + } + } + return result +} + +func keyTypeLookUp(keyType string) crypto.KeyType { + switch keyType { + case "0": + return crypto.Ed25519 + case "1": + return crypto.SECP256k1 + default: + return "" + } } diff --git a/impl/internal/did/did_test.go b/impl/internal/did/did_test.go index 8f7fcced..216dd30c 100644 --- a/impl/internal/did/did_test.go +++ b/impl/internal/did/did_test.go @@ -3,6 +3,7 @@ package did import ( "testing" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -12,11 +13,37 @@ func TestGenerateDIDDHT(t *testing.T) { require.NoError(t, err) require.NotEmpty(t, privKey) require.NotEmpty(t, doc) + + assert.NotEmpty(t, doc.ID) + assert.Empty(t, doc.Context) + assert.NotEmpty(t, doc.VerificationMethod) + assert.NotEmpty(t, doc.Authentication) + assert.NotEmpty(t, doc.AssertionMethod) + assert.NotEmpty(t, doc.CapabilityDelegation) + assert.NotEmpty(t, doc.CapabilityInvocation) + assert.Empty(t, doc.Services) + + assert.Len(t, doc.VerificationMethod, 1) + assert.Len(t, doc.Authentication, 1) + assert.Len(t, doc.AssertionMethod, 1) + assert.Len(t, doc.CapabilityDelegation, 1) + assert.Len(t, doc.CapabilityInvocation, 1) + + assert.NotEmpty(t, doc.VerificationMethod[0].ID) + assert.EqualValues(t, doc.ID+"#0", doc.VerificationMethod[0].ID) + assert.NotEmpty(t, doc.VerificationMethod[0].Controller) + assert.Equal(t, doc.ID, doc.VerificationMethod[0].Controller) + assert.NotEmpty(t, doc.VerificationMethod[0].Type) + assert.NotEmpty(t, doc.VerificationMethod[0].PublicKeyJWK) + }) + + t.Run("test generate did:dht with opts", func(t *testing.T) { + }) } func TestToDNSPacket(t *testing.T) { - t.Run("test to dns packet", func(t *testing.T) { + t.Run("simple doc - test to dns packet round trip", func(t *testing.T) { privKey, doc, err := GenerateDIDDHT(CreateDIDDHTOpts{}) require.NoError(t, err) require.NotEmpty(t, privKey) @@ -28,6 +55,10 @@ func TestToDNSPacket(t *testing.T) { require.NoError(t, err) require.NotEmpty(t, packet) - println(packet.String()) + decodedDoc, err := did.FromDNSPacket(packet) + require.NoError(t, err) + require.NotEmpty(t, decodedDoc) + + assert.EqualValues(t, *doc, *decodedDoc) }) } From 81d0c8338f7f231e3fa690ace35eaf6eac356591 Mon Sep 17 00:00:00 2001 From: gabe Date: Sat, 14 Oct 2023 17:06:38 -0700 Subject: [PATCH 05/11] pending --- impl/go.mod | 26 +++++++------- impl/go.sum | 66 ++++++++++++++++++++++------------- impl/internal/did/did.go | 4 +-- impl/internal/did/did_test.go | 38 ++++++++++++++++++++ 4 files changed, 95 insertions(+), 39 deletions(-) diff --git a/impl/go.mod b/impl/go.mod index 107ffe22..a052b106 100644 --- a/impl/go.mod +++ b/impl/go.mod @@ -3,11 +3,11 @@ module github.com/TBD54566975/did-dht-method go 1.21 require ( - github.com/TBD54566975/ssi-sdk v0.0.4-alpha + github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20231012171634-7bd066d36fb1 github.com/anacrolix/dht/v2 v2.20.0 github.com/anacrolix/torrent v1.52.5 - github.com/andybalholm/brotli v1.0.5 github.com/magefile/mage v1.15.0 + github.com/miekg/dns v1.1.56 github.com/mitchellh/go-homedir v1.1.0 github.com/mr-tron/base58 v1.2.0 github.com/sirupsen/logrus v1.9.3 @@ -32,20 +32,22 @@ require ( github.com/benbjohnson/immutable v0.4.1-0.20221220213129-8932b999621d // indirect github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect + github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 // indirect github.com/cloudflare/circl v1.3.3 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/edsrzf/mmap-go v1.1.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/gabriel-vasile/mimetype v1.4.2 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.13.0 // indirect + github.com/go-playground/validator/v10 v10.15.1 // indirect github.com/goccy/go-json v0.10.2 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/google/uuid v1.3.1 // indirect github.com/gowebpki/jcs v1.0.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/huandu/xstrings v1.3.2 // indirect - github.com/hyperledger/aries-framework-go v0.3.1 // indirect + github.com/hyperledger/aries-framework-go v0.3.2 // indirect github.com/hyperledger/aries-framework-go/component/kmscrypto v0.0.0-20230427134832-0c9969493bd3 // indirect github.com/hyperledger/aries-framework-go/component/log v0.0.0-20230427134832-0c9969493bd3 // indirect github.com/hyperledger/aries-framework-go/component/models v0.0.0-20230501135648-a9a7ad029347 // indirect @@ -53,22 +55,21 @@ require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/kilic/bls12-381 v0.1.1-0.20210503002446-7b7597926c69 // indirect github.com/klauspost/cpuid/v2 v2.0.9 // indirect - github.com/leodido/go-urn v1.2.3 // indirect - github.com/lestrrat-go/blackmagic v1.0.1 // indirect + github.com/leodido/go-urn v1.2.4 // indirect + github.com/lestrrat-go/blackmagic v1.0.2 // indirect github.com/lestrrat-go/httpcc v1.0.1 // indirect github.com/lestrrat-go/httprc v1.0.4 // indirect github.com/lestrrat-go/iter v1.0.2 // indirect - github.com/lestrrat-go/jwx/v2 v2.0.9-0.20230429214153-5090ec1bd2cd // indirect + github.com/lestrrat-go/jwx/v2 v2.0.13 // indirect github.com/lestrrat-go/option v1.0.1 // indirect github.com/magiconair/properties v1.8.7 // indirect - github.com/miekg/dns v1.1.56 // indirect github.com/minio/sha256-simd v1.0.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/multiformats/go-base32 v0.1.0 // indirect github.com/multiformats/go-base36 v0.1.0 // indirect github.com/multiformats/go-multibase v0.2.0 // indirect github.com/multiformats/go-multicodec v0.9.0 // indirect - github.com/multiformats/go-multihash v0.2.1 // indirect + github.com/multiformats/go-multihash v0.2.3 // indirect github.com/multiformats/go-varint v0.0.7 // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect github.com/piprate/json-gold v0.5.0 // indirect @@ -78,6 +79,7 @@ require ( github.com/rs/dnscache v0.0.0-20211102005908-e0241e321417 // indirect github.com/sagikazarmark/locafero v0.3.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect + github.com/segmentio/asm v1.2.0 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/spf13/afero v1.10.0 // indirect @@ -86,10 +88,10 @@ require ( github.com/subosito/gotenv v1.6.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.9.0 // indirect - golang.org/x/crypto v0.13.0 // indirect + golang.org/x/crypto v0.14.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/mod v0.12.0 // indirect - golang.org/x/net v0.15.0 // indirect + golang.org/x/net v0.17.0 // indirect golang.org/x/sync v0.3.0 // indirect golang.org/x/sys v0.13.0 // indirect golang.org/x/text v0.13.0 // indirect diff --git a/impl/go.sum b/impl/go.sum index 5e111df9..afb2ebba 100644 --- a/impl/go.sum +++ b/impl/go.sum @@ -47,8 +47,8 @@ github.com/RoaringBitmap/roaring v0.4.17/go.mod h1:D3qVegWTmfCaX4Bl5CrBE9hfrSrrX github.com/RoaringBitmap/roaring v0.4.23/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06Mq5mKs52e1TwOo= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= -github.com/TBD54566975/ssi-sdk v0.0.4-alpha h1:GbZG0S3xeaWQi2suWw2VjGRhM/S2RrIsfiubxSHlViE= -github.com/TBD54566975/ssi-sdk v0.0.4-alpha/go.mod h1:O4iANflxGCX0NbjHOhthq0X0il2ZYNMYlUnjEa0rsC0= +github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20231012171634-7bd066d36fb1 h1:X1ay773wbND0WFMmrpnWgDIdOuk62W9A+yeZI8S15VQ= +github.com/TBD54566975/ssi-sdk v0.0.4-alpha.0.20231012171634-7bd066d36fb1/go.mod h1:M/z16HzB/Nyi1yxVKlIw5aNyOGZ4ziKJpArdiKZ8mO0= github.com/alecthomas/assert/v2 v2.0.0-alpha3 h1:pcHeMvQ3OMstAWgaeaXIAL8uzB9xMm2zlxt+/4ml8lk= github.com/alecthomas/assert/v2 v2.0.0-alpha3/go.mod h1:+zD0lmDXTeQj7TgDgCt0ePWxb0hMC1G+PGTsTCv1B9o= github.com/alecthomas/atomic v0.1.0-alpha2 h1:dqwXmax66gXvHhsOS4pGPZKqYOlTkapELkLb3MNdlH8= @@ -98,8 +98,6 @@ github.com/anacrolix/tagflag v1.0.0/go.mod h1:1m2U/K6ZT+JZG0+bdMK6qauP49QT4wE5pm github.com/anacrolix/tagflag v1.1.0/go.mod h1:Scxs9CV10NQatSmbyjqmqmeQNwGzlNe0CMUMIxqHIG8= github.com/anacrolix/torrent v1.52.5 h1:jWowdx+EU6zFVfBwmnL0d3H4J6vTFEGOrHI35YdfIT8= github.com/anacrolix/torrent v1.52.5/go.mod h1:CcM8oPMYye5J42cSqJrmUpqwRFgSsJQ1jCEHwygqnqQ= -github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= -github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/benbjohnson/immutable v0.2.0/go.mod h1:uc6OHo6PN2++n98KHLxW8ef4W42ylHiQSENghE1ezxI= github.com/benbjohnson/immutable v0.4.1-0.20221220213129-8932b999621d h1:2qVb9bsAMtmAfnxXltm+6eBzrrS7SZ52c3SedsulaMI= @@ -113,6 +111,8 @@ github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8 h1:GKTyiRCL6zVf5wWaq github.com/bradfitz/iter v0.0.0-20191230175014-e8f45d346db8/go.mod h1:spo1JLcs67NmW1aVLEgtA8Yy1elc+X8y5SRW1sFW4Og= github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U= github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 h1:KdUfX2zKommPRa+PD0sWZUyXe9w277ABlgELO7H04IM= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce h1:YtWJF7RHm2pYCvA5t0RPmAaLUhREsKuKd+SLhxFbFeQ= github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce/go.mod h1:0DVlHczLPewLcPGEIeUEzfOJhqGPQ0mJJRDBtD307+o= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= @@ -131,6 +131,7 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y= github.com/decred/dcrd/crypto/blake256 v1.0.1/go.mod h1:2OfgNZ5wDpcsFmHmCK5gZTPcCXqlm2ArzUIkw9czNJo= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= @@ -153,6 +154,8 @@ github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7z github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= +github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= github.com/glycerine/go-unsnap-stream v0.0.0-20190901134440-81cf024a9e0a/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= @@ -166,12 +169,14 @@ github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.13.0 h1:cFRQdfaSMCOSfGCCLB20MHvuoHb/s5G8L5pu2ppK5AQ= -github.com/go-playground/validator/v10 v10.13.0/go.mod h1:dwu7+CG8/CtBiJFZDz4e+5Upb6OLw04gtBYw0mcG/z4= +github.com/go-playground/validator/v10 v10.15.1 h1:BSe8uhN+xQ4r5guV/ywQI4gO59C2raYcGffYWZEjZzM= +github.com/go-playground/validator/v10 v10.15.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= @@ -234,8 +239,8 @@ github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= @@ -247,6 +252,8 @@ github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51 github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs= github.com/gowebpki/jcs v1.0.0 h1:0pZtOgGetfH/L7yXb4KWcJqIyZNA43WXFyMd7ftZACw= github.com/gowebpki/jcs v1.0.0/go.mod h1:CID1cNZ+sHp1CCpAR8mPf6QRtagFBgPJE0FCUQ6+BrI= +github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw= +github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= @@ -259,14 +266,16 @@ github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63 github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw= github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= -github.com/hyperledger/aries-framework-go v0.3.1 h1:44hOqFdVtXPRmfxK1dHds1g1mouJFNeP1D/PBjDxRv8= -github.com/hyperledger/aries-framework-go v0.3.1/go.mod h1:SorUysWEBw+uyXhY5RAtg2iyNkWTIIPM8+Slkt1Spno= +github.com/hyperledger/aries-framework-go v0.3.2 h1:GsSUaSEW82cr5X8b3Qf90GAi37kmTKHqpPJLhar13X8= +github.com/hyperledger/aries-framework-go v0.3.2/go.mod h1:SorUysWEBw+uyXhY5RAtg2iyNkWTIIPM8+Slkt1Spno= github.com/hyperledger/aries-framework-go/component/kmscrypto v0.0.0-20230427134832-0c9969493bd3 h1:PCbDSujjQ6oTEnAHgtThNmbS7SPAYEDBlKOnZFE+Ujw= github.com/hyperledger/aries-framework-go/component/kmscrypto v0.0.0-20230427134832-0c9969493bd3/go.mod h1:aEk0vHBmZsAdDfXaI12Kg5ipZGiB3qNqgbPt/e/Hm2s= github.com/hyperledger/aries-framework-go/component/log v0.0.0-20230427134832-0c9969493bd3 h1:x5qFQraTX86z9GCwF28IxfnPm6QH5YgHaX+4x97Jwvw= github.com/hyperledger/aries-framework-go/component/log v0.0.0-20230427134832-0c9969493bd3/go.mod h1:CvYs4l8X2NrrF93weLOu5RTOIJeVdoZITtjEflyuTyM= github.com/hyperledger/aries-framework-go/component/models v0.0.0-20230501135648-a9a7ad029347 h1:oPGUCpmnm7yxsVllcMQnHF3uc3hy4jfrSCh7nvzXA00= github.com/hyperledger/aries-framework-go/component/models v0.0.0-20230501135648-a9a7ad029347/go.mod h1:nF8fHsYY+GZl74AFAQaKAhYWOOSaLVzW/TZ0Sq/6axI= +github.com/hyperledger/aries-framework-go/component/storageutil v0.0.0-20230427134832-0c9969493bd3 h1:JGYA9l5zTlvsvfnXT9hYPpCokAjmVKX0/r7njba7OX4= +github.com/hyperledger/aries-framework-go/component/storageutil v0.0.0-20230427134832-0c9969493bd3/go.mod h1:aSG2dWjYVzu2PVBtOqsYghaChA5+UUXnBbL+MfVceYQ= github.com/hyperledger/aries-framework-go/spi v0.0.0-20230427134832-0c9969493bd3 h1:ytWmOQZIYQfVJ4msFvrqlp6d+ZLhT43wS8rgE2m+J1A= github.com/hyperledger/aries-framework-go/spi v0.0.0-20230427134832-0c9969493bd3/go.mod h1:oryUyWb23l/a3tAP9KW+GBbfcfqp9tZD4y5hSkFrkqI= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= @@ -296,18 +305,18 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/leodido/go-urn v1.2.3 h1:6BE2vPT0lqoz3fmOesHZiaiFh7889ssCo2GMvLCfiuA= -github.com/leodido/go-urn v1.2.3/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= -github.com/lestrrat-go/blackmagic v1.0.1 h1:lS5Zts+5HIC/8og6cGHb0uCcNCa3OUt1ygh3Qz2Fe80= -github.com/lestrrat-go/blackmagic v1.0.1/go.mod h1:UrEqBzIR2U6CnzVyUtfM6oZNMt/7O7Vohk2J0OGSAtU= +github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= +github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= +github.com/lestrrat-go/blackmagic v1.0.2 h1:Cg2gVSc9h7sz9NOByczrbUvLopQmXrfFx//N+AkAr5k= +github.com/lestrrat-go/blackmagic v1.0.2/go.mod h1:UrEqBzIR2U6CnzVyUtfM6oZNMt/7O7Vohk2J0OGSAtU= github.com/lestrrat-go/httpcc v1.0.1 h1:ydWCStUeJLkpYyjLDHihupbn2tYmZ7m22BGkcvZZrIE= github.com/lestrrat-go/httpcc v1.0.1/go.mod h1:qiltp3Mt56+55GPVCbTdM9MlqhvzyuL6W/NMDA8vA5E= github.com/lestrrat-go/httprc v1.0.4 h1:bAZymwoZQb+Oq8MEbyipag7iSq6YIga8Wj6GOiJGdI8= github.com/lestrrat-go/httprc v1.0.4/go.mod h1:mwwz3JMTPBjHUkkDv/IGJ39aALInZLrhBp0X7KGUZlo= github.com/lestrrat-go/iter v1.0.2 h1:gMXo1q4c2pHmC3dn8LzRhJfP1ceCbgSiT9lUydIzltI= github.com/lestrrat-go/iter v1.0.2/go.mod h1:Momfcq3AnRlRjI5b5O8/G5/BvpzrhoFTZcn06fEOPt4= -github.com/lestrrat-go/jwx/v2 v2.0.9-0.20230429214153-5090ec1bd2cd h1:jzU4xunmLFc7uF97O5PhEFmAuiRSuG7/RKrX2gkKWeY= -github.com/lestrrat-go/jwx/v2 v2.0.9-0.20230429214153-5090ec1bd2cd/go.mod h1:6etqt12jS77WEY6WPM9nmnIaG6fMo5yQmtTSqB2eLk4= +github.com/lestrrat-go/jwx/v2 v2.0.13 h1:XdxzJbudGaHEoNmyJACAT8aFCB+DmviiaiMoZwuJoUo= +github.com/lestrrat-go/jwx/v2 v2.0.13/go.mod h1:UzXMzcV99p9/xe1JsIb336NJDGXLsleR+Qj3ucEDtfI= github.com/lestrrat-go/option v1.0.0/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= github.com/lestrrat-go/option v1.0.1 h1:oAzP2fvZGQKWkvHa1/SAcFolBEca1oN+mQ7eooNBEYU= github.com/lestrrat-go/option v1.0.1/go.mod h1:5ZHFbivi4xwXxhxY9XHDe2FHo6/Z7WWmtT7T5nBBp3I= @@ -340,8 +349,8 @@ github.com/multiformats/go-multibase v0.2.0 h1:isdYCVLvksgWlMW9OZRYJEa9pZETFivnc github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6oPyjtnzK/XTFDPkNuk= github.com/multiformats/go-multicodec v0.9.0 h1:pb/dlPnzee/Sxv/j4PmkDRxCOi3hXTz3IbPKOXWJkmg= github.com/multiformats/go-multicodec v0.9.0/go.mod h1:L3QTQvMIaVBkXOXXtVmYE+LI16i14xuaojr/H7Ai54k= -github.com/multiformats/go-multihash v0.2.1 h1:aem8ZT0VA2nCHHk7bPJ1BjUbHNciqZC/d16Vve9l108= -github.com/multiformats/go-multihash v0.2.1/go.mod h1:WxoMcYG85AZVQUyRyo9s4wULvW5qrI9vb2Lt6evduFc= +github.com/multiformats/go-multihash v0.2.3 h1:7Lyc8XfX/IY2jWb/gI7JP+o7JEq9hOa7BFvVU9RSh+U= +github.com/multiformats/go-multihash v0.2.3/go.mod h1:dXgKXCXjBzdscBLk9JkjINiEsCKRVch90MdaGiKsvSM= github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8= github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= @@ -394,6 +403,8 @@ github.com/sagikazarmark/locafero v0.3.0 h1:zT7VEGWC2DTflmccN/5T1etyKvxSxpHsjb9c github.com/sagikazarmark/locafero v0.3.0/go.mod h1:w+v7UsPNFwzF1cHuOajOOzoq4U7v/ig1mpRjqV+Bu1U= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= +github.com/segmentio/asm v1.2.0 h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys= +github.com/segmentio/asm v1.2.0/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= @@ -467,9 +478,9 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE= -golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -547,9 +558,9 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= -golang.org/x/net v0.15.0 h1:ugBLEUaxABaB5AJqW9enI0ACdci2RUd4eP51NTBvuJ8= -golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -616,18 +627,21 @@ golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -800,6 +814,8 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogR gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY= +gopkg.in/h2non/gock.v1 v1.1.2/go.mod h1:n7UGz/ckNChHiK05rDoiC4MYSunEC/lyaUm2WWaDva0= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= diff --git a/impl/internal/did/did.go b/impl/internal/did/did.go index 7a3916b0..110eddd7 100644 --- a/impl/internal/did/did.go +++ b/impl/internal/did/did.go @@ -48,12 +48,12 @@ func (DHT) Method() did.Method { type CreateDIDDHTOpts struct { // VerificationMethods is a list of verification methods to include in the DID Document // Cannot contain id #0 which is reserved for the identity key - VerificationMethods []VerificationMethods + VerificationMethods []VerificationMethod // Services is a list of services to include in the DID Document Services []did.Service } -type VerificationMethods struct { +type VerificationMethod struct { VerificationMethod did.VerificationMethod `json:"verificationMethod"` Purposes []ion.PublicKeyPurpose `json:"purposes"` } diff --git a/impl/internal/did/did_test.go b/impl/internal/did/did_test.go index 216dd30c..bcb49286 100644 --- a/impl/internal/did/did_test.go +++ b/impl/internal/did/did_test.go @@ -3,6 +3,10 @@ package did import ( "testing" + "github.com/TBD54566975/ssi-sdk/crypto" + "github.com/TBD54566975/ssi-sdk/crypto/jwx" + "github.com/TBD54566975/ssi-sdk/did" + "github.com/TBD54566975/ssi-sdk/did/ion" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -38,7 +42,41 @@ func TestGenerateDIDDHT(t *testing.T) { }) t.Run("test generate did:dht with opts", func(t *testing.T) { + pubKey, _, err := crypto.GenerateSECP256k1Key() + require.NoError(t, err) + pubKeyJWK, err := jwx.PublicKeyToPublicKeyJWK("key1", pubKey) + require.NoError(t, err) + + opts := CreateDIDDHTOpts{ + VerificationMethods: []VerificationMethod{ + { + VerificationMethod: did.VerificationMethod{ + ID: "did:dht:123456789abcdefghi#key1", + Type: "JsonWebKey2020", + Controller: "did:dht:123456789abcdefghi", + PublicKeyJWK: pubKeyJWK, + }, + Purposes: []ion.PublicKeyPurpose{ion.AssertionMethod, ion.CapabilityInvocation}, + }, + }, + Services: []did.Service{ + { + ID: "did:dht:123456789abcdefghi#vcs", + Type: "VerifiableCredentialService", + ServiceEndpoint: "https://example.com/vc/", + }, + { + ID: "did:dht:123456789abcdefghi#hub", + Type: "MessagingService", + ServiceEndpoint: "https://example.com/hub/", + }, + }, + } + privKey, doc, err := GenerateDIDDHT(opts) + require.NoError(t, err) + require.NotEmpty(t, privKey) + require.NotEmpty(t, doc) }) } From fe84aa099b0cc1e0ba49043305e31bb4870da40a Mon Sep 17 00:00:00 2001 From: gabe Date: Sun, 15 Oct 2023 17:38:59 -0700 Subject: [PATCH 06/11] roundtrip tested --- impl/internal/did/did.go | 29 ++++++++----- impl/internal/did/did_test.go | 82 +++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 11 deletions(-) diff --git a/impl/internal/did/did.go b/impl/internal/did/did.go index 110eddd7..2c0015b6 100644 --- a/impl/internal/did/did.go +++ b/impl/internal/did/did.go @@ -77,9 +77,9 @@ func CreateDIDDHTDID(pubKey ed25519.PublicKey, opts CreateDIDDHTOpts) (*did.Docu // validate opts and build verification methods, key purposes, and services var vms []did.VerificationMethod + var keyAgreement []did.VerificationMethodSet authentication := []did.VerificationMethodSet{"#0"} assertionMethod := []did.VerificationMethodSet{"#0"} - keyAgreement := []did.VerificationMethodSet{"#0"} capabilityInvocation := []did.VerificationMethodSet{"#0"} capabilityDelegation := []did.VerificationMethodSet{"#0"} if len(opts.VerificationMethods) > 0 { @@ -107,27 +107,28 @@ func CreateDIDDHTDID(pubKey ed25519.PublicKey, opts CreateDIDDHTOpts) (*did.Docu vms = append(vms, vm.VerificationMethod) // add purposes + vmID := vm.VerificationMethod.ID[strings.LastIndex(vm.VerificationMethod.ID, "#"):] for _, purpose := range vm.Purposes { switch purpose { case ion.Authentication: - authentication = append(authentication, vm.VerificationMethod.ID) + authentication = append(authentication, vmID) case ion.AssertionMethod: - assertionMethod = append(assertionMethod, vm.VerificationMethod.ID) + assertionMethod = append(assertionMethod, vmID) case ion.KeyAgreement: - keyAgreement = append(keyAgreement, vm.VerificationMethod.ID) + keyAgreement = append(keyAgreement, vmID) case ion.CapabilityInvocation: - capabilityInvocation = append(capabilityInvocation, vm.VerificationMethod.ID) + capabilityInvocation = append(capabilityInvocation, vmID) case ion.CapabilityDelegation: - capabilityDelegation = append(capabilityDelegation, vm.VerificationMethod.ID) + capabilityDelegation = append(capabilityDelegation, vmID) default: - return nil, fmt.Errorf("unknown key purpose: %s:%s", vm.VerificationMethod.ID, purpose) + return nil, fmt.Errorf("unknown key purpose: %s:%s", vmID, purpose) } } } } if len(opts.Services) > 0 { seenIDs := make(map[string]bool) - for _, s := range opts.Services { + for i, s := range opts.Services { if seenIDs[s.ID] { return nil, fmt.Errorf("service id %s is not unique", s.ID) } @@ -136,7 +137,7 @@ func CreateDIDDHTDID(pubKey ed25519.PublicKey, opts CreateDIDDHTOpts) (*did.Docu seenIDs[s.ID] = true // update ID in place - s.ID = id + "#" + s.ID + opts.Services[i].ID = id + "#" + s.ID } } @@ -178,7 +179,10 @@ func (d DHT) ToDNSPacket(doc did.Document) (*dns.Msg, error) { var vmIDs []string for i, vm := range doc.VerificationMethod { recordIdentifier := fmt.Sprintf("k%d", i) - vmID := strings.Split(vm.ID, "#")[1] + vmID := vm.ID + if strings.Contains(vmID, "#") { + vmID = vmID[strings.LastIndex(vm.ID, "#")+1:] + } keyLookup[vm.ID] = recordIdentifier var keyType int @@ -221,7 +225,10 @@ func (d DHT) ToDNSPacket(doc did.Document) (*dns.Msg, error) { var svcIDs []string for i, service := range doc.Services { recordIdentifier := fmt.Sprintf("s%d", i) - sID := strings.Split("#", service.ID)[1] + sID := service.ID + if strings.Contains(sID, "#") { + sID = sID[strings.LastIndex(service.ID, "#")+1:] + } serviceRecord := dns.TXT{ Hdr: dns.RR_Header{ diff --git a/impl/internal/did/did_test.go b/impl/internal/did/did_test.go index bcb49286..b60ed57a 100644 --- a/impl/internal/did/did_test.go +++ b/impl/internal/did/did_test.go @@ -77,6 +77,39 @@ func TestGenerateDIDDHT(t *testing.T) { require.NoError(t, err) require.NotEmpty(t, privKey) require.NotEmpty(t, doc) + + assert.NotEmpty(t, doc.ID) + assert.Empty(t, doc.Context) + assert.NotEmpty(t, doc.VerificationMethod) + assert.NotEmpty(t, doc.Authentication) + assert.NotEmpty(t, doc.AssertionMethod) + assert.Empty(t, doc.KeyAgreement) + assert.NotEmpty(t, doc.CapabilityDelegation) + assert.NotEmpty(t, doc.CapabilityInvocation) + assert.NotEmpty(t, doc.Services) + + assert.Len(t, doc.VerificationMethod, 2) + assert.Len(t, doc.Authentication, 1) + assert.Len(t, doc.AssertionMethod, 2) + assert.Len(t, doc.KeyAgreement, 0) + assert.Len(t, doc.CapabilityDelegation, 1) + assert.Len(t, doc.CapabilityInvocation, 2) + assert.Len(t, doc.Services, 2) + + assert.NotEmpty(t, doc.VerificationMethod[0].ID) + assert.EqualValues(t, doc.ID+"#0", doc.VerificationMethod[0].ID) + assert.NotEmpty(t, doc.VerificationMethod[0].Controller) + assert.Equal(t, doc.ID, doc.VerificationMethod[0].Controller) + assert.NotEmpty(t, doc.VerificationMethod[0].Type) + assert.NotEmpty(t, doc.VerificationMethod[0].PublicKeyJWK) + + assert.Equal(t, doc.Services[0].ID, "did:dht:123456789abcdefghi#vcs") + assert.Equal(t, doc.Services[0].Type, "VerifiableCredentialService") + assert.Equal(t, doc.Services[0].ServiceEndpoint, "https://example.com/vc/") + + assert.Equal(t, doc.Services[1].ID, "did:dht:123456789abcdefghi#hub") + assert.Equal(t, doc.Services[1].Type, "MessagingService") + assert.Equal(t, doc.Services[1].ServiceEndpoint, "https://example.com/hub/") }) } @@ -99,4 +132,53 @@ func TestToDNSPacket(t *testing.T) { assert.EqualValues(t, *doc, *decodedDoc) }) + + t.Run("doc with multiple keys and services - test to dns packet round trip", func(t *testing.T) { + pubKey, _, err := crypto.GenerateSECP256k1Key() + require.NoError(t, err) + pubKeyJWK, err := jwx.PublicKeyToPublicKeyJWK("key1", pubKey) + require.NoError(t, err) + + opts := CreateDIDDHTOpts{ + VerificationMethods: []VerificationMethod{ + { + VerificationMethod: did.VerificationMethod{ + ID: "key1", + Type: "JsonWebKey2020", + Controller: "did:dht:123456789abcdefghi", + PublicKeyJWK: pubKeyJWK, + }, + Purposes: []ion.PublicKeyPurpose{ion.AssertionMethod, ion.CapabilityInvocation}, + }, + }, + Services: []did.Service{ + { + ID: "vcs", + Type: "VerifiableCredentialService", + ServiceEndpoint: "https://example.com/vc/", + }, + { + ID: "hub", + Type: "MessagingService", + ServiceEndpoint: "https://example.com/hub/", + }, + }, + } + privKey, doc, err := GenerateDIDDHT(opts) + require.NoError(t, err) + require.NotEmpty(t, privKey) + require.NotEmpty(t, doc) + + did := DHT(doc.ID) + + packet, err := did.ToDNSPacket(*doc) + require.NoError(t, err) + require.NotEmpty(t, packet) + + decodedDoc, err := did.FromDNSPacket(packet) + require.NoError(t, err) + require.NotEmpty(t, decodedDoc) + + assert.EqualValues(t, *doc, *decodedDoc) + }) } From b9fc12675b5fe827322ddb617ddccd4b0c0b2d0b Mon Sep 17 00:00:00 2001 From: gabe Date: Sun, 15 Oct 2023 17:43:14 -0700 Subject: [PATCH 07/11] add ci --- .github/dependabot.yml | 6 ++++ .github/workflows/ci.yml | 47 +++++++++++++++++++++++++++ .github/workflows/codeql-analysis.yml | 42 ++++++++++++++++++++++++ .github/workflows/golangci-lint.yml | 44 +++++++++++++++++++++++++ impl/internal/did/did_test.go | 10 +++--- impl/magefile.go | 27 +++++++++++++++ 6 files changed, 171 insertions(+), 5 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/codeql-analysis.yml create mode 100644 .github/workflows/golangci-lint.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..7976d63f --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "gomod" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..63426726 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,47 @@ +name: did-dht-ci + +# when: +# - a pull request is opened against main +# - commits are pushed to main +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + # used to run action manually via the UI + workflow_dispatch: + +jobs: + vulnerability-scan: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.21.3 + + - name: Install Mage + run: go install github.com/magefile/mage + + - name: Check Vulnerabilities + run: mage -v vuln + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.21.3 + + - name: Install Mage + run: go install github.com/magefile/mage + + - name: Build + run: mage build + + - name: Test + run: mage citest \ No newline at end of file diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 00000000..cf011ea4 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,42 @@ +name: "CodeQL" + +on: + push: + branches: [ main ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ main ] + schedule: + - cron: '34 18 * * 1' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + env: + GOFLAGS: "-tags=jwx_es256k" + + strategy: + fail-fast: false + matrix: + language: [ 'go' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 \ No newline at end of file diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 00000000..04ab734d --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,44 @@ +name: golangci-lint +on: + push: + tags: + - v* + branches: + - master + - main + pull_request: +permissions: + contents: read +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v3 + with: + go-version: 1.21.3 + - uses: actions/checkout@v3 + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version + version: latest + + # Optional: working directory, useful for monorepos + # working-directory: somedir + + # Optional: golangci-lint command line arguments. + args: --timeout=3m --verbose + + # Optional: show only new issues if it's a pull request. The default value is `false`. + # only-new-issues: true + + # Optional: if set to true then the all caching functionality will be complete disabled, + # takes precedence over all other caching options. + # skip-cache: true + + # Optional: if set to true then the action don't cache or restore ~/go/pkg. + # skip-pkg-cache: true + + # Optional: if set to true then the action don't cache or restore ~/.cache/go-build. + # skip-build-cache: true \ No newline at end of file diff --git a/impl/internal/did/did_test.go b/impl/internal/did/did_test.go index b60ed57a..36f237ac 100644 --- a/impl/internal/did/did_test.go +++ b/impl/internal/did/did_test.go @@ -51,7 +51,7 @@ func TestGenerateDIDDHT(t *testing.T) { VerificationMethods: []VerificationMethod{ { VerificationMethod: did.VerificationMethod{ - ID: "did:dht:123456789abcdefghi#key1", + ID: "key1", Type: "JsonWebKey2020", Controller: "did:dht:123456789abcdefghi", PublicKeyJWK: pubKeyJWK, @@ -61,12 +61,12 @@ func TestGenerateDIDDHT(t *testing.T) { }, Services: []did.Service{ { - ID: "did:dht:123456789abcdefghi#vcs", + ID: "vcs", Type: "VerifiableCredentialService", ServiceEndpoint: "https://example.com/vc/", }, { - ID: "did:dht:123456789abcdefghi#hub", + ID: "hub", Type: "MessagingService", ServiceEndpoint: "https://example.com/hub/", }, @@ -103,11 +103,11 @@ func TestGenerateDIDDHT(t *testing.T) { assert.NotEmpty(t, doc.VerificationMethod[0].Type) assert.NotEmpty(t, doc.VerificationMethod[0].PublicKeyJWK) - assert.Equal(t, doc.Services[0].ID, "did:dht:123456789abcdefghi#vcs") + assert.Equal(t, doc.Services[0].ID, doc.ID+"#vcs") assert.Equal(t, doc.Services[0].Type, "VerifiableCredentialService") assert.Equal(t, doc.Services[0].ServiceEndpoint, "https://example.com/vc/") - assert.Equal(t, doc.Services[1].ID, "did:dht:123456789abcdefghi#hub") + assert.Equal(t, doc.Services[1].ID, doc.ID+"#hub") assert.Equal(t, doc.Services[1].Type, "MessagingService") assert.Equal(t, doc.Services[1].ServiceEndpoint, "https://example.com/hub/") }) diff --git a/impl/magefile.go b/impl/magefile.go index 9115bbb7..e475e2ab 100644 --- a/impl/magefile.go +++ b/impl/magefile.go @@ -60,6 +60,33 @@ func runTests(extraTestArgs ...string) error { return err } +// CITest runs unit tests with coverage as a part of CI. +// The mage `-v` option will trigger a verbose output of the test +func CITest() error { + return runCITests() +} + +func runCITests(extraTestArgs ...string) error { + args := []string{"test"} + if mg.Verbose() { + args = append(args, "-v") + } + args = append(args, "-tags=jwx_es256k") + args = append(args, "-covermode=atomic") + args = append(args, "-coverprofile=coverage.out") + args = append(args, "-race") + args = append(args, extraTestArgs...) + args = append(args, "./...") + testEnv := map[string]string{ + "CGO_ENABLED": "1", + "GO111MODULE": "on", + } + writer := ColorizeTestStdout() + fmt.Printf("%+v", args) + _, err := sh.Exec(testEnv, writer, os.Stderr, Go, args...) + return err +} + func Deps() error { return brewInstall("golangci-lint") } From b185129a18a44d8a4e81104e13d835fe228f2e33 Mon Sep 17 00:00:00 2001 From: gabe Date: Sun, 15 Oct 2023 17:49:49 -0700 Subject: [PATCH 08/11] set wd --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 63426726..e11a51b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,9 +23,11 @@ jobs: go-version: 1.21.3 - name: Install Mage + working-directory: ./impl run: go install github.com/magefile/mage - name: Check Vulnerabilities + working-directory: ./impl run: mage -v vuln build: runs-on: ubuntu-latest @@ -38,10 +40,13 @@ jobs: go-version: 1.21.3 - name: Install Mage + working-directory: ./impl run: go install github.com/magefile/mage - name: Build + working-directory: ./impl run: mage build - name: Test + working-directory: ./impl run: mage citest \ No newline at end of file From 2d1dff28063938c7cf7457adc7dd342c44c47a82 Mon Sep 17 00:00:00 2001 From: gabe Date: Sun, 15 Oct 2023 17:51:04 -0700 Subject: [PATCH 09/11] Better --- .github/workflows/ci.yml | 11 ++++++----- .github/workflows/codeql-analysis.yml | 3 +++ .github/workflows/golangci-lint.yml | 3 +++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e11a51b8..667cd69f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,9 @@ on: jobs: vulnerability-scan: runs-on: ubuntu-latest + defaults: + run: + working-directory: ./impl steps: - uses: actions/checkout@v3 @@ -23,14 +26,15 @@ jobs: go-version: 1.21.3 - name: Install Mage - working-directory: ./impl run: go install github.com/magefile/mage - name: Check Vulnerabilities - working-directory: ./impl run: mage -v vuln build: runs-on: ubuntu-latest + defaults: + run: + working-directory: ./impl steps: - uses: actions/checkout@v3 @@ -40,13 +44,10 @@ jobs: go-version: 1.21.3 - name: Install Mage - working-directory: ./impl run: go install github.com/magefile/mage - name: Build - working-directory: ./impl run: mage build - name: Test - working-directory: ./impl run: mage citest \ No newline at end of file diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index cf011ea4..7dcb290e 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -13,6 +13,9 @@ jobs: analyze: name: Analyze runs-on: ubuntu-latest + defaults: + run: + working-directory: ./impl permissions: actions: read contents: read diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 04ab734d..0e6a1499 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -13,6 +13,9 @@ jobs: golangci: name: lint runs-on: ubuntu-latest + defaults: + run: + working-directory: ./impl steps: - uses: actions/setup-go@v3 with: From 53bae85c31664bbf0fbedd48b6099b7d698bbf94 Mon Sep 17 00:00:00 2001 From: gabe Date: Sun, 15 Oct 2023 17:54:26 -0700 Subject: [PATCH 10/11] one more --- .github/workflows/golangci-lint.yml | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 0e6a1499..df4b21bc 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -4,7 +4,6 @@ on: tags: - v* branches: - - master - main pull_request: permissions: @@ -24,24 +23,5 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version version: latest - - # Optional: working directory, useful for monorepos - # working-directory: somedir - - # Optional: golangci-lint command line arguments. - args: --timeout=3m --verbose - - # Optional: show only new issues if it's a pull request. The default value is `false`. - # only-new-issues: true - - # Optional: if set to true then the all caching functionality will be complete disabled, - # takes precedence over all other caching options. - # skip-cache: true - - # Optional: if set to true then the action don't cache or restore ~/go/pkg. - # skip-pkg-cache: true - - # Optional: if set to true then the action don't cache or restore ~/.cache/go-build. - # skip-build-cache: true \ No newline at end of file + args: --timeout=3m --verbose # skip-build-cache: true \ No newline at end of file From ca1e9d48fdf57a6260715244564e5e8ffdb66c0c Mon Sep 17 00:00:00 2001 From: gabe Date: Sun, 15 Oct 2023 17:58:31 -0700 Subject: [PATCH 11/11] remove lint for now --- .github/workflows/golangci-lint.yml | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 .github/workflows/golangci-lint.yml diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml deleted file mode 100644 index df4b21bc..00000000 --- a/.github/workflows/golangci-lint.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: golangci-lint -on: - push: - tags: - - v* - branches: - - main - pull_request: -permissions: - contents: read -jobs: - golangci: - name: lint - runs-on: ubuntu-latest - defaults: - run: - working-directory: ./impl - steps: - - uses: actions/setup-go@v3 - with: - go-version: 1.21.3 - - uses: actions/checkout@v3 - - name: golangci-lint - uses: golangci/golangci-lint-action@v3 - with: - version: latest - args: --timeout=3m --verbose # skip-build-cache: true \ No newline at end of file