diff --git a/package.json b/package.json index 3be995212..6d30d27b0 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,6 @@ "typedoc": "^0.22.15", "typescript": "^4.8.3" }, - "version": "0.33.0", + "version": "0.33.1", "packageManager": "yarn@3.3.1" } diff --git a/packages/asset-did/package.json b/packages/asset-did/package.json index d45398aaa..a93fb108c 100644 --- a/packages/asset-did/package.json +++ b/packages/asset-did/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/asset-did", - "version": "0.33.0", + "version": "0.33.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/augment-api/package.json b/packages/augment-api/package.json index 5d780a331..7a43d75cf 100644 --- a/packages/augment-api/package.json +++ b/packages/augment-api/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/augment-api", - "version": "0.33.0", + "version": "0.33.1", "description": "", "types": "./lib/index.d.ts", "type": "module", diff --git a/packages/chain-helpers/package.json b/packages/chain-helpers/package.json index 8c7d4a5ca..551adcb1f 100644 --- a/packages/chain-helpers/package.json +++ b/packages/chain-helpers/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/chain-helpers", - "version": "0.33.0", + "version": "0.33.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/config/package.json b/packages/config/package.json index 802d6ae5e..36cf3619d 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/config", - "version": "0.33.0", + "version": "0.33.1", "description": "", "type": "commonjs", "main": "./lib/index.js", diff --git a/packages/core/package.json b/packages/core/package.json index f5138906c..fdb8a976d 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/core", - "version": "0.33.0", + "version": "0.33.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", @@ -49,7 +49,6 @@ "@polkadot/keyring": "^12.0.0", "@polkadot/types": "^10.4.0", "@polkadot/util": "^12.0.0", - "@polkadot/util-crypto": "^12.0.0", - "cbor-web": "^8.0.0" + "@polkadot/util-crypto": "^12.0.0" } } diff --git a/packages/core/src/publicCredential/PublicCredential.chain.ts b/packages/core/src/publicCredential/PublicCredential.chain.ts index 6ef1bb3e0..76653e0e4 100644 --- a/packages/core/src/publicCredential/PublicCredential.chain.ts +++ b/packages/core/src/publicCredential/PublicCredential.chain.ts @@ -22,13 +22,11 @@ import type { PublicCredentialsCredentialsCredentialEntry, } from '@kiltprotocol/augment-api' -import { encode as cborEncode, decode as cborDecode } from 'cbor-web' - import { HexString } from '@polkadot/util/types' import { ConfigService } from '@kiltprotocol/config' import { fromChain as didFromChain } from '@kiltprotocol/did' import { validateUri } from '@kiltprotocol/asset-did' -import { SDKErrors } from '@kiltprotocol/utils' +import { SDKErrors, cbor } from '@kiltprotocol/utils' import { getIdForCredential } from './PublicCredential.js' import { flattenCalls, isBatch, retrieveExtrinsicFromBlock } from '../utils.js' @@ -51,7 +49,7 @@ export function toChain( ): EncodedPublicCredential { const { cTypeHash, claims, subject, delegationId } = publicCredential - const cborSerializedClaims = cborEncode(claims) + const cborSerializedClaims = cbor.encode(claims) return { ctypeHash: cTypeHash, @@ -72,7 +70,7 @@ function credentialInputFromChain({ const credentialSubject = subject.toUtf8() validateUri(credentialSubject) return { - claims: cborDecode(claims), + claims: cbor.decode(claims), cTypeHash: ctypeHash.toHex(), delegationId: authorization.unwrapOr(undefined)?.toHex() ?? null, subject: credentialSubject as AssetDidUri, diff --git a/packages/did/package.json b/packages/did/package.json index 7d23d0438..13ddcae72 100644 --- a/packages/did/package.json +++ b/packages/did/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/did", - "version": "0.33.0", + "version": "0.33.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", @@ -44,7 +44,6 @@ "@polkadot/types": "^10.4.0", "@polkadot/types-codec": "^10.4.0", "@polkadot/util": "^12.0.0", - "@polkadot/util-crypto": "^12.0.0", - "cbor-web": "^8.0.0" + "@polkadot/util-crypto": "^12.0.0" } } diff --git a/packages/did/src/DidDetails/LightDidDetails.ts b/packages/did/src/DidDetails/LightDidDetails.ts index 6adcbc177..30a752f6b 100644 --- a/packages/did/src/DidDetails/LightDidDetails.ts +++ b/packages/did/src/DidDetails/LightDidDetails.ts @@ -5,7 +5,6 @@ * found in the LICENSE file in the root directory of this source tree. */ -import { decode as cborDecode, encode as cborEncode } from 'cbor-web' import { base58Decode, base58Encode, @@ -22,7 +21,7 @@ import type { } from '@kiltprotocol/types' import { encryptionKeyTypes } from '@kiltprotocol/types' -import { SDKErrors, ss58Format } from '@kiltprotocol/utils' +import { SDKErrors, ss58Format, cbor } from '@kiltprotocol/utils' import { getAddressByKey, parse } from '../Did.utils.js' import { resourceIdToChain, validateService } from '../Did.chain.js' @@ -147,7 +146,7 @@ function serializeAdditionalLightDidDetails({ } const serializationVersion = 0x0 - const serialized = cborEncode(objectToSerialize) + const serialized = cbor.encode(objectToSerialize) return base58Encode([serializationVersion, ...serialized], true) } @@ -166,7 +165,7 @@ function deserializeAdditionalLightDidDetails( if (serializationVersion !== 0x0) { throw new SDKErrors.DidError('Serialization algorithm not supported') } - const deserialized: SerializableStructure = cborDecode(serialized) + const deserialized: SerializableStructure = cbor.decode(serialized) const keyAgreement = deserialized[KEY_AGREEMENT_MAP_KEY] return { diff --git a/packages/did/src/cbor-web.d.ts b/packages/did/src/cbor-web.d.ts deleted file mode 100644 index 4def7650e..000000000 --- a/packages/did/src/cbor-web.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module 'cbor-web' diff --git a/packages/messaging/package.json b/packages/messaging/package.json index ea74c3e65..74a297aad 100644 --- a/packages/messaging/package.json +++ b/packages/messaging/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/messaging", - "version": "0.33.0", + "version": "0.33.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/sdk-js/package.json b/packages/sdk-js/package.json index 59a4ca4b1..00b833d58 100644 --- a/packages/sdk-js/package.json +++ b/packages/sdk-js/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/sdk-js", - "version": "0.33.0", + "version": "0.33.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/testing/package.json b/packages/testing/package.json index d36e7e687..e450b37ae 100644 --- a/packages/testing/package.json +++ b/packages/testing/package.json @@ -1,7 +1,7 @@ { "name": "@kiltprotocol/testing", "private": true, - "version": "0.33.0", + "version": "0.33.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/type-definitions/package.json b/packages/type-definitions/package.json index d39869564..6ca78ae0b 100644 --- a/packages/type-definitions/package.json +++ b/packages/type-definitions/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/type-definitions", - "version": "0.33.0", + "version": "0.33.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/types/package.json b/packages/types/package.json index e7a609abd..d8ac81f4f 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/types", - "version": "0.33.0", + "version": "0.33.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/packages/utils/package.json b/packages/utils/package.json index 39111a069..4c7277ce2 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/utils", - "version": "0.33.0", + "version": "0.33.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", @@ -39,6 +39,7 @@ "@polkadot/keyring": "^12.0.0", "@polkadot/util": "^12.0.0", "@polkadot/util-crypto": "^12.0.0", + "cbor-web": "^8.0.0", "tweetnacl": "^1.0.3", "uuid": "^9.0.0" } diff --git a/packages/core/src/cbor-web.d.ts b/packages/utils/src/cbor-web.d.ts similarity index 100% rename from packages/core/src/cbor-web.d.ts rename to packages/utils/src/cbor-web.d.ts diff --git a/packages/utils/src/cbor.ts b/packages/utils/src/cbor.ts new file mode 100644 index 000000000..e8d6f254e --- /dev/null +++ b/packages/utils/src/cbor.ts @@ -0,0 +1,11 @@ +/** + * Copyright (c) 2018-2023, BOTLabs GmbH. + * + * This source code is licensed under the BSD 4-Clause "Original" license + * found in the LICENSE file in the root directory of this source tree. + */ + +// special import syntax as this is a pure cjs import +import * as cborImp from 'cbor-web' +// this is horrible but the only way to make this import work in both cjs & esm builds +export const cbor = cborImp?.default ?? cborImp diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index c4ef91110..30cbd3b3e 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -17,4 +17,5 @@ export * as DataUtils from './DataUtils.js' export * as SDKErrors from './SDKErrors.js' export * as JsonSchema from './json-schema/index.js' export { ss58Format } from './ss58Format.js' +export { cbor } from './cbor.js' export { Keyring } from '@polkadot/keyring' diff --git a/packages/vc-export/package.json b/packages/vc-export/package.json index 09e58b59a..f05ffef45 100644 --- a/packages/vc-export/package.json +++ b/packages/vc-export/package.json @@ -1,6 +1,6 @@ { "name": "@kiltprotocol/vc-export", - "version": "0.33.0", + "version": "0.33.1", "description": "", "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", diff --git a/yarn.lock b/yarn.lock index 9ae7a4c95..ef459b63e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1899,7 +1899,6 @@ __metadata: "@polkadot/util": ^12.0.0 "@polkadot/util-crypto": ^12.0.0 "@types/uuid": ^8.0.0 - cbor-web: ^8.0.0 rimraf: ^3.0.2 testcontainers: ^9.0.0 typescript: ^4.8.3 @@ -1921,7 +1920,6 @@ __metadata: "@polkadot/types-codec": ^10.4.0 "@polkadot/util": ^12.0.0 "@polkadot/util-crypto": ^12.0.0 - cbor-web: ^8.0.0 rimraf: ^3.0.2 typescript: ^4.8.3 languageName: unknown @@ -2016,6 +2014,7 @@ __metadata: "@polkadot/keyring": ^12.0.0 "@polkadot/util": ^12.0.0 "@polkadot/util-crypto": ^12.0.0 + cbor-web: ^8.0.0 rimraf: ^3.0.2 tweetnacl: ^1.0.3 typescript: ^4.8.3