From af1572b9e58332526714784bd630dc252d724112 Mon Sep 17 00:00:00 2001 From: Irakli Gozalishvili Date: Wed, 12 Oct 2022 12:13:51 -0700 Subject: [PATCH 1/3] feat: upgrade to multiformat@10.0 --- package.json | 36 +++--- pnpm-lock.yaml | 308 ++++++++++++++++++++++++----------------------- src/lib.js | 36 ++++-- src/ucan.ts | 65 +++------- test/lib.spec.js | 6 +- 5 files changed, 219 insertions(+), 232 deletions(-) diff --git a/package.json b/package.json index d1c1c03..e414a0d 100644 --- a/package.json +++ b/package.json @@ -29,9 +29,24 @@ "check": "tsc --build" }, "dependencies": { - "@ipld/dag-cbor": "^7.0.1", - "@ipld/dag-json": "^8.0.9", - "multiformats": "^9.6.4" + "@ipld/dag-cbor": "^7.0.3", + "@ipld/dag-json": "^8.0.11", + "multiformats": "^10.0.0" + }, + "devDependencies": { + "@stablelib/ed25519": "^1.0.3", + "@noble/ed25519": "^1.6.0", + "@types/chai": "^4.3.0", + "@types/mocha": "^9.1.0", + "@web-std/fetch": "^4.0.0", + "@web-std/file": "^3.0.2", + "c8": "^7.11.0", + "chai": "^4.3.6", + "mocha": "^10.0.0", + "nyc": "^15.1.0", + "playwright-test": "^8.1.1", + "typescript": "4.8.3", + "ucans": "0.9.0" }, "type": "module", "main": "src/lib.js", @@ -77,20 +92,5 @@ "dist/**" ] }, - "devDependencies": { - "@stablelib/ed25519": "^1.0.3", - "@noble/ed25519": "^1.6.0", - "@types/chai": "^4.3.0", - "@types/mocha": "^9.1.0", - "@web-std/fetch": "^4.0.0", - "@web-std/file": "^3.0.2", - "c8": "^7.11.0", - "chai": "^4.3.6", - "mocha": "^10.0.0", - "nyc": "^15.1.0", - "playwright-test": "^8.1.1", - "typescript": "4.8.3", - "ucans": "0.9.0" - }, "license": "(Apache-2.0 AND MIT)" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6996892..ec32645 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,18 +1,18 @@ lockfileVersion: 5.4 specifiers: - '@ipld/dag-cbor': ^7.0.1 - '@ipld/dag-json': ^8.0.9 - '@noble/ed25519': ^1.6.0 + '@ipld/dag-cbor': ^7.0.3 + '@ipld/dag-json': ^8.0.11 + '@noble/ed25519': ^1.7.1 '@stablelib/ed25519': ^1.0.3 - '@types/chai': ^4.3.0 - '@types/mocha': ^9.1.0 - '@web-std/fetch': ^4.0.0 + '@types/chai': ^4.3.3 + '@types/mocha': ^9.1.1 + '@web-std/fetch': ^4.1.0 '@web-std/file': ^3.0.2 - c8: ^7.11.0 + c8: ^7.12.0 chai: ^4.3.6 mocha: ^10.0.0 - multiformats: ^9.6.4 + multiformats: ^10.0.0 nyc: ^15.1.0 playwright-test: ^8.1.1 typescript: 4.8.3 @@ -21,10 +21,10 @@ specifiers: dependencies: '@ipld/dag-cbor': 7.0.3 '@ipld/dag-json': 8.0.11 - multiformats: 9.8.1 + multiformats: 10.0.0 devDependencies: - '@noble/ed25519': 1.7.0 + '@noble/ed25519': 1.7.1 '@stablelib/ed25519': 1.0.3 '@types/chai': 4.3.3 '@types/mocha': 9.1.1 @@ -45,7 +45,7 @@ packages: engines: {node: '>=6.0.0'} dependencies: '@jridgewell/gen-mapping': 0.1.1 - '@jridgewell/trace-mapping': 0.3.15 + '@jridgewell/trace-mapping': 0.3.16 dev: true /@arr/every/1.0.1: @@ -60,26 +60,26 @@ packages: '@babel/highlight': 7.18.6 dev: true - /@babel/compat-data/7.19.0: - resolution: {integrity: sha512-y5rqgTTPTmaF5e2nVhOxw+Ur9HDJLsWb6U/KpgUzRZEdPfE6VOubXBKLdbcUTijzRptednSBDQbYZBOSqJxpJw==} + /@babel/compat-data/7.19.4: + resolution: {integrity: sha512-CHIGpJcUQ5lU9KrPHTjBMhVwQG6CQjxfg36fGXl3qk/Gik1WwWachaXFuo0uCWJT/mStOKtcbFJCaVLihC1CMw==} engines: {node: '>=6.9.0'} dev: true - /@babel/core/7.19.0: - resolution: {integrity: sha512-reM4+U7B9ss148rh2n1Qs9ASS+w94irYXga7c2jaQv9RVzpS7Mv1a9rnYYwuDa45G+DkORt9g6An2k/V4d9LbQ==} + /@babel/core/7.19.3: + resolution: {integrity: sha512-WneDJxdsjEvyKtXKsaBGbDeiyOjR5vYq4HcShxnIbG0qixpoHjI3MqeZM9NDvsojNCEBItQE4juOo/bU6e72gQ==} engines: {node: '>=6.9.0'} dependencies: '@ampproject/remapping': 2.2.0 '@babel/code-frame': 7.18.6 - '@babel/generator': 7.19.0 - '@babel/helper-compilation-targets': 7.19.0_@babel+core@7.19.0 + '@babel/generator': 7.19.5 + '@babel/helper-compilation-targets': 7.19.3_@babel+core@7.19.3 '@babel/helper-module-transforms': 7.19.0 - '@babel/helpers': 7.19.0 - '@babel/parser': 7.19.0 + '@babel/helpers': 7.19.4 + '@babel/parser': 7.19.4 '@babel/template': 7.18.10 - '@babel/traverse': 7.19.0 - '@babel/types': 7.19.0 - convert-source-map: 1.8.0 + '@babel/traverse': 7.19.4 + '@babel/types': 7.19.4 + convert-source-map: 1.9.0 debug: 4.3.4 gensync: 1.0.0-beta.2 json5: 2.2.1 @@ -88,25 +88,25 @@ packages: - supports-color dev: true - /@babel/generator/7.19.0: - resolution: {integrity: sha512-S1ahxf1gZ2dpoiFgA+ohK9DIpz50bJ0CWs7Zlzb54Z4sG8qmdIrGrVqmy1sAtTVRb+9CU6U8VqT9L0Zj7hxHVg==} + /@babel/generator/7.19.5: + resolution: {integrity: sha512-DxbNz9Lz4aMZ99qPpO1raTbcrI1ZeYh+9NR9qhfkQIbFtVEqotHojEBxHzmxhVONkGt6VyrqVQcgpefMy9pqcg==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.19.0 + '@babel/types': 7.19.4 '@jridgewell/gen-mapping': 0.3.2 jsesc: 2.5.2 dev: true - /@babel/helper-compilation-targets/7.19.0_@babel+core@7.19.0: - resolution: {integrity: sha512-Ai5bNWXIvwDvWM7njqsG3feMlL9hCVQsPYXodsZyLwshYkZVJt59Gftau4VrE8S9IT9asd2uSP1hG6wCNw+sXA==} + /@babel/helper-compilation-targets/7.19.3_@babel+core@7.19.3: + resolution: {integrity: sha512-65ESqLGyGmLvgR0mst5AdW1FkNlj9rQsCKduzEoEPhBCDFGXvz2jW6bXFG6i0/MrV2s7hhXjjb2yAzcPuQlLwg==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0 dependencies: - '@babel/compat-data': 7.19.0 - '@babel/core': 7.19.0 + '@babel/compat-data': 7.19.4 + '@babel/core': 7.19.3 '@babel/helper-validator-option': 7.18.6 - browserslist: 4.21.3 + browserslist: 4.21.4 semver: 6.3.0 dev: true @@ -120,21 +120,21 @@ packages: engines: {node: '>=6.9.0'} dependencies: '@babel/template': 7.18.10 - '@babel/types': 7.19.0 + '@babel/types': 7.19.4 dev: true /@babel/helper-hoist-variables/7.18.6: resolution: {integrity: sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.19.0 + '@babel/types': 7.19.4 dev: true /@babel/helper-module-imports/7.18.6: resolution: {integrity: sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.19.0 + '@babel/types': 7.19.4 dev: true /@babel/helper-module-transforms/7.19.0: @@ -143,37 +143,37 @@ packages: dependencies: '@babel/helper-environment-visitor': 7.18.9 '@babel/helper-module-imports': 7.18.6 - '@babel/helper-simple-access': 7.18.6 + '@babel/helper-simple-access': 7.19.4 '@babel/helper-split-export-declaration': 7.18.6 - '@babel/helper-validator-identifier': 7.18.6 + '@babel/helper-validator-identifier': 7.19.1 '@babel/template': 7.18.10 - '@babel/traverse': 7.19.0 - '@babel/types': 7.19.0 + '@babel/traverse': 7.19.4 + '@babel/types': 7.19.4 transitivePeerDependencies: - supports-color dev: true - /@babel/helper-simple-access/7.18.6: - resolution: {integrity: sha512-iNpIgTgyAvDQpDj76POqg+YEt8fPxx3yaNBg3S30dxNKm2SWfYhD0TGrK/Eu9wHpUW63VQU894TsTg+GLbUa1g==} + /@babel/helper-simple-access/7.19.4: + resolution: {integrity: sha512-f9Xq6WqBFqaDfbCzn2w85hwklswz5qsKlh7f08w4Y9yhJHpnNC0QemtSkK5YyOY8kPGvyiwdzZksGUhnGdaUIg==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.19.0 + '@babel/types': 7.19.4 dev: true /@babel/helper-split-export-declaration/7.18.6: resolution: {integrity: sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==} engines: {node: '>=6.9.0'} dependencies: - '@babel/types': 7.19.0 + '@babel/types': 7.19.4 dev: true - /@babel/helper-string-parser/7.18.10: - resolution: {integrity: sha512-XtIfWmeNY3i4t7t4D2t02q50HvqHybPqW2ki1kosnvWCwuCMeo81Jf0gwr85jy/neUdg5XDdeFE/80DXiO+njw==} + /@babel/helper-string-parser/7.19.4: + resolution: {integrity: sha512-nHtDoQcuqFmwYNYPz3Rah5ph2p8PFeFCsZk9A/48dPc/rGocJ5J3hAAZ7pb76VWX3fZKu+uEr/FhH5jLx7umrw==} engines: {node: '>=6.9.0'} dev: true - /@babel/helper-validator-identifier/7.18.6: - resolution: {integrity: sha512-MmetCkz9ej86nJQV+sFCxoGGrUbU3q02kgLciwkrt9QqEB7cP39oKEY0PakknEO0Gu20SskMRi+AYZ3b1TpN9g==} + /@babel/helper-validator-identifier/7.19.1: + resolution: {integrity: sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==} engines: {node: '>=6.9.0'} dev: true @@ -182,13 +182,13 @@ packages: engines: {node: '>=6.9.0'} dev: true - /@babel/helpers/7.19.0: - resolution: {integrity: sha512-DRBCKGwIEdqY3+rPJgG/dKfQy9+08rHIAJx8q2p+HSWP87s2HCrQmaAMMyMll2kIXKCW0cO1RdQskx15Xakftg==} + /@babel/helpers/7.19.4: + resolution: {integrity: sha512-G+z3aOx2nfDHwX/kyVii5fJq+bgscg89/dJNWpYeKeBv3v9xX8EIabmx1k6u9LS04H7nROFVRVK+e3k0VHp+sw==} engines: {node: '>=6.9.0'} dependencies: '@babel/template': 7.18.10 - '@babel/traverse': 7.19.0 - '@babel/types': 7.19.0 + '@babel/traverse': 7.19.4 + '@babel/types': 7.19.4 transitivePeerDependencies: - supports-color dev: true @@ -197,17 +197,17 @@ packages: resolution: {integrity: sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==} engines: {node: '>=6.9.0'} dependencies: - '@babel/helper-validator-identifier': 7.18.6 + '@babel/helper-validator-identifier': 7.19.1 chalk: 2.4.2 js-tokens: 4.0.0 dev: true - /@babel/parser/7.19.0: - resolution: {integrity: sha512-74bEXKX2h+8rrfQUfsBfuZZHzsEs6Eql4pqy/T4Nn6Y9wNPggQOqD6z6pn5Bl8ZfysKouFZT/UXEH94ummEeQw==} + /@babel/parser/7.19.4: + resolution: {integrity: sha512-qpVT7gtuOLjWeDTKLkJ6sryqLliBaFpAtGeqw5cs5giLldvh+Ch0plqnUMKoVAUS6ZEueQQiZV+p5pxtPitEsA==} engines: {node: '>=6.0.0'} hasBin: true dependencies: - '@babel/types': 7.19.0 + '@babel/types': 7.19.4 dev: true /@babel/template/7.18.10: @@ -215,34 +215,34 @@ packages: engines: {node: '>=6.9.0'} dependencies: '@babel/code-frame': 7.18.6 - '@babel/parser': 7.19.0 - '@babel/types': 7.19.0 + '@babel/parser': 7.19.4 + '@babel/types': 7.19.4 dev: true - /@babel/traverse/7.19.0: - resolution: {integrity: sha512-4pKpFRDh+utd2mbRC8JLnlsMUii3PMHjpL6a0SZ4NMZy7YFP9aXORxEhdMVOc9CpWtDF09IkciQLEhK7Ml7gRA==} + /@babel/traverse/7.19.4: + resolution: {integrity: sha512-w3K1i+V5u2aJUOXBFFC5pveFLmtq1s3qcdDNC2qRI6WPBQIDaKFqXxDEqDO/h1dQ3HjsZoZMyIy6jGLq0xtw+g==} engines: {node: '>=6.9.0'} dependencies: '@babel/code-frame': 7.18.6 - '@babel/generator': 7.19.0 + '@babel/generator': 7.19.5 '@babel/helper-environment-visitor': 7.18.9 '@babel/helper-function-name': 7.19.0 '@babel/helper-hoist-variables': 7.18.6 '@babel/helper-split-export-declaration': 7.18.6 - '@babel/parser': 7.19.0 - '@babel/types': 7.19.0 + '@babel/parser': 7.19.4 + '@babel/types': 7.19.4 debug: 4.3.4 globals: 11.12.0 transitivePeerDependencies: - supports-color dev: true - /@babel/types/7.19.0: - resolution: {integrity: sha512-YuGopBq3ke25BVSiS6fgF49Ul9gH1x70Bcr6bqRLjWCkcX8Hre1/5+z+IiWOIerRMSSEfGZVB9z9kyq7wVs9YA==} + /@babel/types/7.19.4: + resolution: {integrity: sha512-M5LK7nAeS6+9j7hAq+b3fQs+pNfUtTGq+yFFfHnauFA8zQtLRfmuipmsKDKKLuyG+wC8ABW43A153YNawNTEtw==} engines: {node: '>=6.9.0'} dependencies: - '@babel/helper-string-parser': 7.18.10 - '@babel/helper-validator-identifier': 7.18.6 + '@babel/helper-string-parser': 7.19.4 + '@babel/helper-validator-identifier': 7.19.1 to-fast-properties: 2.0.0 dev: true @@ -254,14 +254,14 @@ packages: resolution: {integrity: sha512-1VVh2huHsuohdXC1bGJNE8WR72slZ9XE2T3wbBBq31dm7ZBatmKLLxrB+XAqafxfRFjv08RZmj/W/ZqaM13AuA==} dependencies: cborg: 1.9.5 - multiformats: 9.8.1 + multiformats: 9.9.0 dev: false /@ipld/dag-json/8.0.11: resolution: {integrity: sha512-Pea7JXeYHTWXRTIhBqBlhw7G53PJ7yta3G/sizGEZyzdeEwhZRr0od5IQ0r2ZxOt1Do+2czddjeEPp+YTxDwCA==} dependencies: cborg: 1.9.5 - multiformats: 9.8.1 + multiformats: 9.9.0 dev: false /@istanbuljs/load-nyc-config/1.1.0: @@ -294,7 +294,7 @@ packages: dependencies: '@jridgewell/set-array': 1.1.2 '@jridgewell/sourcemap-codec': 1.4.14 - '@jridgewell/trace-mapping': 0.3.15 + '@jridgewell/trace-mapping': 0.3.16 dev: true /@jridgewell/resolve-uri/3.1.0: @@ -311,15 +311,15 @@ packages: resolution: {integrity: sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==} dev: true - /@jridgewell/trace-mapping/0.3.15: - resolution: {integrity: sha512-oWZNOULl+UbhsgB51uuZzglikfIKSUBO/M9W2OfEjn7cmqoAiCgmv9lyACTUacZwBz0ITnJ2NqjU8Tx0DHL88g==} + /@jridgewell/trace-mapping/0.3.16: + resolution: {integrity: sha512-LCQ+NeThyJ4k1W2d+vIKdxuSt9R3pQSZ4P92m7EakaYuXcVWbHuT5bjNcqLd4Rdgi6xYWYDvBJZJLZSLanjDcA==} dependencies: '@jridgewell/resolve-uri': 3.1.0 '@jridgewell/sourcemap-codec': 1.4.14 dev: true - /@noble/ed25519/1.7.0: - resolution: {integrity: sha512-LeAxFK0+181zQOhOUuKE8Jnd3duzYhDNd3iCLxpmzA5K+e4I1FdbrK3Ot0ZHBwZMeRD/6EojyUfTbpHZ+hkQHg==} + /@noble/ed25519/1.7.1: + resolution: {integrity: sha512-Rk4SkJFaXZiznFyC/t77Q0NKS4FL7TLJJsVG2V2oiEq3kJVeTdxysEe/yRWSpnWMe808XRDJ+VFh5pt/FN5plw==} dev: true /@nodelib/fs.scandir/2.1.5: @@ -518,7 +518,7 @@ packages: resolution: {integrity: sha512-7yeyCEurROLQJFv5Xj4lEGTy0borxepjFv1g22oAdqFu//SrAlDl1O1Nxx15SH1RoliUml6p8dwJW9jvZughhg==} engines: {node: '>=8'} dependencies: - default-require-extensions: 3.0.0 + default-require-extensions: 3.0.1 dev: true /archy/1.0.0: @@ -541,7 +541,7 @@ packages: dependencies: call-bind: 1.0.2 define-properties: 1.1.4 - es-abstract: 1.20.2 + es-abstract: 1.20.4 is-string: 1.0.7 dev: true @@ -604,15 +604,15 @@ packages: resolution: {integrity: sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==} dev: true - /browserslist/4.21.3: - resolution: {integrity: sha512-898rgRXLAyRkM1GryrrBHGkqA5hlpkV5MhtZwg9QXeiyLUYs2k00Un05aX5l2/yJIOObYKOpS2JNo8nJDE7fWQ==} + /browserslist/4.21.4: + resolution: {integrity: sha512-CBHJJdDmgjl3daYjN5Cp5kbTf1mUhZoS+beLklHIvkOWscs83YAhLlF3Wsh/lciQYAcbBJgTOD44VtG31ZM4Hw==} engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} hasBin: true dependencies: - caniuse-lite: 1.0.30001390 - electron-to-chromium: 1.4.242 + caniuse-lite: 1.0.30001418 + electron-to-chromium: 1.4.279 node-releases: 2.0.6 - update-browserslist-db: 1.0.7_browserslist@4.21.3 + update-browserslist-db: 1.0.10_browserslist@4.21.4 dev: true /buffer/6.0.3: @@ -655,7 +655,7 @@ packages: resolution: {integrity: sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==} dependencies: function-bind: 1.1.1 - get-intrinsic: 1.1.2 + get-intrinsic: 1.1.3 dev: true /camelcase/5.3.1: @@ -668,8 +668,8 @@ packages: engines: {node: '>=10'} dev: true - /caniuse-lite/1.0.30001390: - resolution: {integrity: sha512-sS4CaUM+/+vqQUlCvCJ2WtDlV81aWtHhqeEVkLokVJJa3ViN4zDxAGfq9R8i1m90uGHxo99cy10Od+lvn3hf0g==} + /caniuse-lite/1.0.30001418: + resolution: {integrity: sha512-oIs7+JL3K9JRQ3jPZjlH6qyYDp+nBTCais7hjh0s+fuBwufc7uZ7hPYMXrDOJhV360KGMTcczMRObk0/iMqZRg==} dev: true /cborg/1.9.5: @@ -707,8 +707,8 @@ packages: supports-color: 7.2.0 dev: true - /chalk/5.0.1: - resolution: {integrity: sha512-Fo07WOYGqMfCWHOzSXOt2CxDbC6skS/jO9ynEcmpANMoPrD+W1r1K6Vx7iNm+AQmETU1Xr2t+n8nzkV9t6xh3w==} + /chalk/5.1.1: + resolution: {integrity: sha512-OItMegkSDU3P7OJRWBbNRsQsL8SzgwlIGXSZRVfHCLBYrDgzYDuozwDMwvEDpiZdjr50tdOTbTzuubirtEozsg==} engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} dev: true @@ -802,13 +802,11 @@ packages: dev: true /concat-map/0.0.1: - resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=} + resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} dev: true - /convert-source-map/1.8.0: - resolution: {integrity: sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA==} - dependencies: - safe-buffer: 5.1.2 + /convert-source-map/1.9.0: + resolution: {integrity: sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==} dev: true /cp-file/9.1.0: @@ -903,7 +901,7 @@ packages: dependencies: call-bind: 1.0.2 es-get-iterator: 1.1.2 - get-intrinsic: 1.1.2 + get-intrinsic: 1.1.3 is-arguments: 1.1.1 is-date-object: 1.0.5 is-regex: 1.1.4 @@ -918,15 +916,15 @@ packages: which-typed-array: 1.1.8 dev: true - /default-require-extensions/3.0.0: - resolution: {integrity: sha512-ek6DpXq/SCpvjhpFsLFRVtIxJCRw6fUR42lYMVZuUMK7n8eMz4Uh5clckdBjEpLhn/gEBZo7hDJnJcwdKLKQjg==} + /default-require-extensions/3.0.1: + resolution: {integrity: sha512-eXTJmRbm2TIt9MgWTsOH1wEuhew6XGZcMeGKCtLedIg/NCsg1iBePXkceTdK4Fii7pzmN9tGsZhKzZ4h7O/fxw==} engines: {node: '>=8'} dependencies: strip-bom: 4.0.0 dev: true - /defaults/1.0.3: - resolution: {integrity: sha512-s82itHOnYrN0Ib8r+z7laQz3sdE+4FP3d9Q7VLO7U+KRT+CR0GsWuyHxzdAY82I7cXv0G/twrqomTJLOssO5HA==} + /defaults/1.0.4: + resolution: {integrity: sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==} dependencies: clone: 1.0.4 dev: true @@ -939,8 +937,8 @@ packages: object-keys: 1.1.1 dev: true - /defined/1.0.0: - resolution: {integrity: sha512-Y2caI5+ZwS5c3RiNDJ6u53VhQHv+hHKwhkI1iHvceKUHw9Df6EK2zRLfjejRgMuCuxK7PfSWIMwWecceVvThjQ==} + /defined/1.0.1: + resolution: {integrity: sha512-hsBd2qSVCRE+5PmNdHt1uzyrFu5d3RwmFDKzyNZMFq/EwDNJF7Ee5+D5oEKF0hU6LhtoUF1macFvOe4AskQC1Q==} dev: true /diff/5.0.0: @@ -962,29 +960,29 @@ packages: minimatch: 3.1.2 dev: true - /electron-to-chromium/1.4.242: - resolution: {integrity: sha512-nPdgMWtjjWGCtreW/2adkrB2jyHjClo9PtVhR6rW+oxa4E4Wom642Tn+5LslHP3XPL5MCpkn5/UEY60EXylNeQ==} + /electron-to-chromium/1.4.279: + resolution: {integrity: sha512-xs7vEuSZ84+JsHSTFqqG0TE3i8EAivHomRQZhhcRvsmnjsh5C2KdhwNKf4ZRYtzq75wojpFyqb62m32Oam57wA==} dev: true /emoji-regex/8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} dev: true - /es-abstract/1.20.2: - resolution: {integrity: sha512-XxXQuVNrySBNlEkTYJoDNFe5+s2yIOpzq80sUHEdPdQr0S5nTLz4ZPPPswNIpKseDDUS5yghX1gfLIHQZ1iNuQ==} + /es-abstract/1.20.4: + resolution: {integrity: sha512-0UtvRN79eMe2L+UNEF1BwRe364sj/DXhQ/k5FmivgoSdpM90b8Jc0mDzKMGo7QS0BVbOP/bTwBKNnDc9rNzaPA==} engines: {node: '>= 0.4'} dependencies: call-bind: 1.0.2 es-to-primitive: 1.2.1 function-bind: 1.1.1 function.prototype.name: 1.1.5 - get-intrinsic: 1.1.2 + get-intrinsic: 1.1.3 get-symbol-description: 1.0.0 has: 1.0.3 has-property-descriptors: 1.0.0 has-symbols: 1.0.3 internal-slot: 1.0.3 - is-callable: 1.2.4 + is-callable: 1.2.7 is-negative-zero: 2.0.2 is-regex: 1.1.4 is-shared-array-buffer: 1.0.2 @@ -994,6 +992,7 @@ packages: object-keys: 1.1.1 object.assign: 4.1.4 regexp.prototype.flags: 1.4.3 + safe-regex-test: 1.0.0 string.prototype.trimend: 1.0.5 string.prototype.trimstart: 1.0.5 unbox-primitive: 1.0.2 @@ -1003,7 +1002,7 @@ packages: resolution: {integrity: sha512-+DTO8GYwbMCwbywjimwZMHp8AuYXOS2JZFWoi2AlPOS3ebnII9w/NLpNZtA7A0YLaVDw+O7KFCeoIV7OPvM7hQ==} dependencies: call-bind: 1.0.2 - get-intrinsic: 1.1.2 + get-intrinsic: 1.1.3 has-symbols: 1.0.3 is-arguments: 1.1.1 is-map: 2.0.2 @@ -1016,7 +1015,7 @@ packages: resolution: {integrity: sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==} engines: {node: '>= 0.4'} dependencies: - is-callable: 1.2.4 + is-callable: 1.2.7 is-date-object: 1.0.5 is-symbol: 1.0.4 dev: true @@ -1321,7 +1320,7 @@ packages: /for-each/0.3.3: resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==} dependencies: - is-callable: 1.2.4 + is-callable: 1.2.7 dev: true /foreground-child/2.0.0: @@ -1358,7 +1357,7 @@ packages: dependencies: call-bind: 1.0.2 define-properties: 1.1.4 - es-abstract: 1.20.2 + es-abstract: 1.20.4 functions-have-names: 1.2.3 dev: true @@ -1380,8 +1379,8 @@ packages: resolution: {integrity: sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==} dev: true - /get-intrinsic/1.1.2: - resolution: {integrity: sha512-Jfm3OyCxHh9DJyc28qGk+JmfkpO41A4XkneDSujN9MDXrm4oDKdHvndhZ2dN94+ERNfkYJWDclW6k2L/ZGHjXA==} + /get-intrinsic/1.1.3: + resolution: {integrity: sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A==} dependencies: function-bind: 1.1.1 has: 1.0.3 @@ -1398,7 +1397,7 @@ packages: engines: {node: '>= 0.4'} dependencies: call-bind: 1.0.2 - get-intrinsic: 1.1.2 + get-intrinsic: 1.1.3 dev: true /glob-parent/5.1.2: @@ -1458,7 +1457,7 @@ packages: resolution: {integrity: sha512-X3fbtsZmwb6W7fJGR9o7x65fZoodygCrZ3TVycvghP62yYQfS0t4RS0Qcz+j5tQYUKeSWS09tHkWW6WhFV3XhQ==} dependencies: call-bind: 1.0.2 - get-intrinsic: 1.1.2 + get-intrinsic: 1.1.3 dev: true /has-flag/3.0.0: @@ -1474,7 +1473,7 @@ packages: /has-property-descriptors/1.0.0: resolution: {integrity: sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==} dependencies: - get-intrinsic: 1.1.2 + get-intrinsic: 1.1.3 dev: true /has-symbols/1.0.3: @@ -1552,7 +1551,7 @@ packages: resolution: {integrity: sha512-O0DB1JC/sPyZl7cIo78n5dR7eUSwwpYPiXRhTzNxZVAMUuB8vlnRFyLxdrVToks6XPLVnFfbzaVd5WLjhgg+vA==} engines: {node: '>= 0.4'} dependencies: - get-intrinsic: 1.1.2 + get-intrinsic: 1.1.3 has: 1.0.3 side-channel: 1.0.4 dev: true @@ -1586,8 +1585,8 @@ packages: has-tostringtag: 1.0.0 dev: true - /is-callable/1.2.4: - resolution: {integrity: sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w==} + /is-callable/1.2.7: + resolution: {integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==} engines: {node: '>= 0.4'} dev: true @@ -1707,7 +1706,7 @@ packages: dependencies: available-typed-arrays: 1.0.5 call-bind: 1.0.2 - es-abstract: 1.20.2 + es-abstract: 1.20.4 for-each: 0.3.3 has-tostringtag: 1.0.0 dev: true @@ -1740,7 +1739,7 @@ packages: resolution: {integrity: sha512-t2yVvttHkQktwnNNmBQ98AhENLdPUTDTE21uPqAQ0ARwQfGeQKRVS0NNurH7bTf7RrvcVn1OOge45CnBeHCSmg==} dependencies: call-bind: 1.0.2 - get-intrinsic: 1.1.2 + get-intrinsic: 1.1.3 dev: true /is-windows/1.0.2: @@ -1772,7 +1771,7 @@ packages: resolution: {integrity: sha512-BXgQl9kf4WTCPCCpmFGoJkz/+uhvm7h7PFKUYxh7qarQd3ER33vHG//qaE8eN25l07YqZPpHXU9I09l/RD5aGQ==} engines: {node: '>=8'} dependencies: - '@babel/core': 7.19.0 + '@babel/core': 7.19.3 '@istanbuljs/schema': 0.1.3 istanbul-lib-coverage: 3.2.0 semver: 6.3.0 @@ -1900,7 +1899,7 @@ packages: resolution: {integrity: sha512-l0x2DvrW294C9uDCoQe1VSU4gf529FkSZ6leBl4TiqZH/e+0R7hSfHQBNut2mNygDgHwvYHfFLn6Oxb3VWj2rA==} engines: {node: '>=12'} dependencies: - chalk: 5.0.1 + chalk: 5.1.1 is-unicode-supported: 1.3.0 dev: true @@ -1969,8 +1968,8 @@ packages: brace-expansion: 2.0.1 dev: true - /minimist/1.2.6: - resolution: {integrity: sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==} + /minimist/1.2.7: + resolution: {integrity: sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==} dev: true /mocha/10.0.0: @@ -2020,8 +2019,13 @@ packages: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} dev: true - /multiformats/9.8.1: - resolution: {integrity: sha512-Cu7NfUYtCV+WN7w59WsRRF138S+um4tTo11ScYsWbNgWyCEGOu8wID1e5eMJs91gFZ0I7afodkkdxCF8NGkqZQ==} + /multiformats/10.0.0: + resolution: {integrity: sha512-qEj/ansAK86ufzupmp8B/JbiNSLJhNFcqW2Aa1dWxQc0OfoorpknwKkJeXAbtZ62AJlA6qKsGrCY3OjdFWZOrQ==} + engines: {node: '>=16.0.0', npm: '>=7.0.0'} + dev: false + + /multiformats/9.9.0: + resolution: {integrity: sha512-HoMUjhH9T8DDBNT+6xzkrd9ga/XiBI4xLr58LJACwK6G3HTOPeMz4nB4KJs33L2BelrIJa7P0VuNaVF3hMYfjg==} /nanoid/3.3.3: resolution: {integrity: sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==} @@ -2063,7 +2067,7 @@ packages: '@istanbuljs/load-nyc-config': 1.1.0 '@istanbuljs/schema': 0.1.3 caching-transform: 4.0.0 - convert-source-map: 1.8.0 + convert-source-map: 1.9.0 decamelize: 1.2.0 find-cache-dir: 3.3.2 find-up: 4.1.0 @@ -2140,7 +2144,7 @@ packages: engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} dependencies: bl: 5.0.0 - chalk: 5.0.1 + chalk: 5.1.1 cli-cursor: 4.0.0 cli-spinners: 2.7.0 is-interactive: 2.0.0 @@ -2328,7 +2332,7 @@ packages: source-map: 0.6.1 stream-browserify: 3.0.0 strip-ansi: 7.0.1 - tape: 5.6.0 + tape: 5.6.1 tempy: 3.0.0 test-exclude: 6.0.0 v8-to-istanbul: 9.0.1 @@ -2463,21 +2467,25 @@ packages: mri: 1.2.0 dev: true - /safe-buffer/5.1.2: - resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} - dev: true - /safe-buffer/5.2.1: resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} dev: true + /safe-regex-test/1.0.0: + resolution: {integrity: sha512-JBUUzyOgEwXQY1NuPtvcj/qcBDbDmEvWufhlnXZIm75DEHp+afM1r1ujJpJsV/gSM4t59tpDyPi1sd6ZaPFfsA==} + dependencies: + call-bind: 1.0.2 + get-intrinsic: 1.1.3 + is-regex: 1.1.4 + dev: true + /semver/6.3.0: resolution: {integrity: sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==} hasBin: true dev: true - /semver/7.3.7: - resolution: {integrity: sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==} + /semver/7.3.8: + resolution: {integrity: sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==} engines: {node: '>=10'} hasBin: true dependencies: @@ -2510,7 +2518,7 @@ packages: resolution: {integrity: sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==} dependencies: call-bind: 1.0.2 - get-intrinsic: 1.1.2 + get-intrinsic: 1.1.3 object-inspect: 1.12.2 dev: true @@ -2575,7 +2583,7 @@ packages: dependencies: call-bind: 1.0.2 define-properties: 1.1.4 - es-abstract: 1.20.2 + es-abstract: 1.20.4 dev: true /string.prototype.trimend/1.0.5: @@ -2583,7 +2591,7 @@ packages: dependencies: call-bind: 1.0.2 define-properties: 1.1.4 - es-abstract: 1.20.2 + es-abstract: 1.20.4 dev: true /string.prototype.trimstart/1.0.5: @@ -2591,7 +2599,7 @@ packages: dependencies: call-bind: 1.0.2 define-properties: 1.1.4 - es-abstract: 1.20.2 + es-abstract: 1.20.4 dev: true /string_decoder/1.3.0: @@ -2650,14 +2658,14 @@ packages: engines: {node: '>= 0.4'} dev: true - /tape/5.6.0: - resolution: {integrity: sha512-LyM4uqbiTAqDgsHTY0r1LH66yE24P3SZaz5TL3mPUds0XCTFl/0AMUBrjgBjUclvbPTFB4IalXg0wFfbTuuu/Q==} + /tape/5.6.1: + resolution: {integrity: sha512-reNzS3rzsJtKk0f+zJx2XlzIsjJXlIcOIrIxk5shHAG/DzW3BKyMg8UfN79oluYlcWo4lIt56ahLqwgpRT4idg==} hasBin: true dependencies: array.prototype.every: 1.1.3 call-bind: 1.0.2 deep-equal: 2.0.5 - defined: 1.0.0 + defined: 1.0.1 dotignore: 0.1.2 for-each: 0.3.3 get-package-type: 0.1.0 @@ -2666,7 +2674,7 @@ packages: has-dynamic-import: 2.0.1 inherits: 2.0.4 is-regex: 1.1.4 - minimist: 1.2.6 + minimist: 1.2.7 object-inspect: 1.12.2 object-is: 1.1.5 object-keys: 1.1.1 @@ -2767,14 +2775,14 @@ packages: dependencies: '@stablelib/ed25519': 1.0.3 one-webcrypto: 1.0.3 - semver: 7.3.7 - uint8arrays: 3.1.0 + semver: 7.3.8 + uint8arrays: 3.1.1 dev: true - /uint8arrays/3.1.0: - resolution: {integrity: sha512-ei5rfKtoRO8OyOIor2Rz5fhzjThwIHJZ3uyDPnDHTXbP0aMQ1RN/6AI5B5d9dBxJOU+BvOAk7ZQ1xphsX8Lrog==} + /uint8arrays/3.1.1: + resolution: {integrity: sha512-+QJa8QRnbdXVpHYjLoTpJIdCTiw9Ir62nocClWuXIq2JIh4Uta0cQsTSpFL678p2CN8B+XSApwcU+pQEqVpKWg==} dependencies: - multiformats: 9.8.1 + multiformats: 9.9.0 dev: true /unbox-primitive/1.0.2: @@ -2793,13 +2801,13 @@ packages: crypto-random-string: 4.0.0 dev: true - /update-browserslist-db/1.0.7_browserslist@4.21.3: - resolution: {integrity: sha512-iN/XYesmZ2RmmWAiI4Z5rq0YqSiv0brj9Ce9CfhNE4xIW2h+MFxcgkxIzZ+ShkFPUkjU3gQ+3oypadD3RAMtrg==} + /update-browserslist-db/1.0.10_browserslist@4.21.4: + resolution: {integrity: sha512-OztqDenkfFkbSG+tRxBeAnCVPckDBcvibKd35yDONx6OU8N7sqgwc7rCbkJ/WcYtVRZ4ba68d6byhC21GFh7sQ==} hasBin: true peerDependencies: browserslist: '>= 4.21.0' dependencies: - browserslist: 4.21.3 + browserslist: 4.21.4 escalade: 3.1.1 picocolors: 1.0.0 dev: true @@ -2828,15 +2836,15 @@ packages: resolution: {integrity: sha512-74Y4LqY74kLE6IFyIjPtkSTWzUZmj8tdHT9Ii/26dvQ6K9Dl2NbEfj0XgU2sHCtKgt5VupqhlO/5aWuqS+IY1w==} engines: {node: '>=10.12.0'} dependencies: - '@jridgewell/trace-mapping': 0.3.15 + '@jridgewell/trace-mapping': 0.3.16 '@types/istanbul-lib-coverage': 2.0.4 - convert-source-map: 1.8.0 + convert-source-map: 1.9.0 dev: true /wcwidth/1.0.1: resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==} dependencies: - defaults: 1.0.3 + defaults: 1.0.4 dev: true /web-encoding/1.1.5: @@ -2881,7 +2889,7 @@ packages: dependencies: available-typed-arrays: 1.0.5 call-bind: 1.0.2 - es-abstract: 1.20.2 + es-abstract: 1.20.4 for-each: 0.3.3 has-tostringtag: 1.0.0 is-typed-array: 1.1.9 diff --git a/src/lib.js b/src/lib.js index 131b3db..b69346e 100644 --- a/src/lib.js +++ b/src/lib.js @@ -6,7 +6,7 @@ import * as View from "./view.js" import * as Parser from "./parser.js" import * as Formatter from "./formatter.js" import { sha256 } from "multiformats/hashes/sha2" -import { CID } from "multiformats/cid" +import { create as createIPLDLink } from "multiformats/link" import { format as formatDID } from "./did.js" export * from "./ucan.js" @@ -15,8 +15,15 @@ export * from "./ucan.js" export const VERSION = "0.9.1" export const name = "dag-ucan" -/** @type {typeof CBOR.code|typeof RAW.code} */ -export const code = CBOR.code +export const code = /** @type {typeof CBOR.code|typeof RAW.code} */ (CBOR.code) + +/** + * We cast sha256 to workaround typescripts limited inference problem when using + * sha256 as default. If hasher is omitted type `A` should match shar256.code + * but TS fails to deduce that. + * @type {UCAN.MultihashHasher} + */ +const defaultHasher = sha256 /** * Encodes given UCAN (in either IPLD or JWT representation) and encodes it into @@ -65,19 +72,24 @@ export const link = async (ucan, options) => { /** * @template {UCAN.Capabilities} C - * @template {number} [A=number] - Multihash code + * @template {number} [A=typeof sha256.code] - Multihash code * @param {UCAN.View} ucan - * @param {{hasher?: UCAN.MultihashHasher}} [options] - * @returns {Promise>} + * @param {{hasher?: UCAN.MultihashHasher}} options + * @returns {Promise>} */ -export const write = async (ucan, options) => { - const hasher = options?.hasher || sha256 +export const write = async (ucan, { hasher = defaultHasher } = {}) => { + /** @type {UCAN.ByteView>} */ const bytes = ucan.code === RAW.code ? ucan.bytes : CBOR.encode(ucan.model) - - const cid = /** @type {UCAN.Link} */ ( - CID.createV1(ucan.code, await hasher.digest(bytes)) + const digest = await hasher.digest(bytes) + const link = /** @type {UCAN.Link} */ ( + createIPLDLink(ucan.code, digest) ) - return { cid, bytes, data: ucan.model } + + return { + bytes, + cid: link, + data: ucan.model, + } } /** diff --git a/src/ucan.ts b/src/ucan.ts index e68006a..d2c51c9 100644 --- a/src/ucan.ts +++ b/src/ucan.ts @@ -1,16 +1,16 @@ import type { - MultihashDigest, - MultihashHasher, -} from "multiformats/hashes/interface" -import type { + Link as IPLDLink, + Version as LinkVersion, MultibaseEncoder, MultibaseDecoder, -} from "multiformats/bases/interface" + MultihashDigest, + MultihashHasher, + Block as IPLDBlock, +} from "multiformats" import type { code as RAW_CODE } from "multiformats/codecs/raw" import type { code as CBOR_CODE } from "@ipld/dag-cbor" import * as Crypto from "./crypto.js" import type { Phantom, ByteView, ToString } from "./marker.js" -import type { CID as MultiformatsCID } from "multiformats/cid" export * from "./crypto.js" export * from "./marker.js" @@ -207,32 +207,30 @@ export interface UCANOptions< } /** - * Represents a UCAN {@link IPLDLink} in either IPLD or JWT format + * Represents an IPLD link to a UCAN in either IPLD or JWT format * * @template Cap - {@link Capability} * @template Alg - multicodec code corresponding to the hashing algorithm of the CID */ -export type Link< - Cap extends Capabilities = Capabilities, - Alg extends number = number -> = - | IPLDLink, typeof CBOR_CODE, Alg> - | IPLDLink, typeof RAW_CODE, Alg> +export interface Link< + C extends Capabilities = Capabilities, + F extends Code = Code, + A extends number = number +> extends IPLDLink, F, A> {} /** * Represents a UCAN IPLD block * * Note: once we change the Capability generic to an array we can merge this with ucanto transport block * - * @template C - {@link Capability} + * @template C - {@link Capabilities} * @template A - Multicodec code corresponding to the hashing algorithm of the {@link Link} */ export interface Block< C extends Capabilities = Capabilities, + F extends Code = Code, A extends number = number -> { - bytes: ByteView> - cid: Link +> extends IPLDBlock, F, A> { data?: UCAN } @@ -264,36 +262,3 @@ export interface Capability< } export type Capabilities = Tuple - -export type CIDVersion = 0 | 1 - -/** - * Represents an IPLD link to a specific data of type `T`. - * - * Note: this extends MultiformatsCID until multiformats 10 is shipped - * - * @template Data - Logical type of the data being linked to. - * @template Format - multicodec code corresponding to a codec linked data is encoded with - * @template Alg - multicodec code corresponding to the hashing algorithm of the CID - * @template V - CID version - */ -export interface IPLDLink< - Data extends unknown = unknown, - Format extends number = number, - Alg extends number = number, - V extends CIDVersion = 1 -> extends Phantom, - MultiformatsCID { - readonly version: V - readonly code: Format - readonly multihash: MultihashDigest - - readonly byteOffset: number - readonly byteLength: number - readonly bytes: ByteView> - - equals(other: unknown): other is IPLDLink - toString( - base?: MultibaseEncoder - ): ToString, Prefix> -} diff --git a/test/lib.spec.js b/test/lib.spec.js index e4ba18b..758df3d 100644 --- a/test/lib.spec.js +++ b/test/lib.spec.js @@ -1158,9 +1158,11 @@ describe("api compatibility", () => { hasher: sha256, }) + block.bytes + const { cid, bytes } = await UCAN.write(ucan, { hasher: sha256 }) - assert.deepEqual(block.cid, cid) - assert.deepEqual(block.bytes, bytes) + assert.deepEqual(cid, block.cid) + assert.deepEqual(bytes, /** @type {Uint8Array} */ (block.bytes)) assert.deepEqual(block.value, ucan) }) }) From 598ff699921fd0a76494f54082271364bcbe0ab5 Mon Sep 17 00:00:00 2001 From: Irakli Gozalishvili Date: Wed, 12 Oct 2022 14:01:41 -0700 Subject: [PATCH 2/3] fix: update lockfile --- pnpm-lock.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ec32645..60ee97a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3,13 +3,13 @@ lockfileVersion: 5.4 specifiers: '@ipld/dag-cbor': ^7.0.3 '@ipld/dag-json': ^8.0.11 - '@noble/ed25519': ^1.7.1 + '@noble/ed25519': ^1.6.0 '@stablelib/ed25519': ^1.0.3 - '@types/chai': ^4.3.3 - '@types/mocha': ^9.1.1 - '@web-std/fetch': ^4.1.0 + '@types/chai': ^4.3.0 + '@types/mocha': ^9.1.0 + '@web-std/fetch': ^4.0.0 '@web-std/file': ^3.0.2 - c8: ^7.12.0 + c8: ^7.11.0 chai: ^4.3.6 mocha: ^10.0.0 multiformats: ^10.0.0 From 5c1d9fd6cac59a2f46babcedb9c915dd4b898f32 Mon Sep 17 00:00:00 2001 From: Irakli Gozalishvili Date: Thu, 13 Oct 2022 11:40:21 -0700 Subject: [PATCH 3/3] Update test/lib.spec.js Co-authored-by: Hugo Dias --- test/lib.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/lib.spec.js b/test/lib.spec.js index 758df3d..75e77d3 100644 --- a/test/lib.spec.js +++ b/test/lib.spec.js @@ -1158,7 +1158,6 @@ describe("api compatibility", () => { hasher: sha256, }) - block.bytes const { cid, bytes } = await UCAN.write(ucan, { hasher: sha256 }) assert.deepEqual(cid, block.cid)