@credo-ts/core 0.5.0-alpha.120 → 0.5.0-alpha.122

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,7 @@ const bls12381g1g2_1 = require("./bls12381g1g2");
11
11
  const bls12381g2_1 = require("./bls12381g2");
12
12
  const ed25519_1 = require("./ed25519");
13
13
  const keyDidJsonWebKey_1 = require("./keyDidJsonWebKey");
14
+ const secp256k1_1 = require("./secp256k1");
14
15
  const x25519_1 = require("./x25519");
15
16
  // TODO: Maybe we should make this dynamically?
16
17
  const keyDidMapping = {
@@ -22,7 +23,7 @@ const keyDidMapping = {
22
23
  [KeyType_1.KeyType.P256]: keyDidJsonWebKey_1.keyDidJsonWebKey,
23
24
  [KeyType_1.KeyType.P384]: keyDidJsonWebKey_1.keyDidJsonWebKey,
24
25
  [KeyType_1.KeyType.P521]: keyDidJsonWebKey_1.keyDidJsonWebKey,
25
- [KeyType_1.KeyType.K256]: keyDidJsonWebKey_1.keyDidJsonWebKey,
26
+ [KeyType_1.KeyType.K256]: secp256k1_1.keyDidSecp256k1,
26
27
  };
27
28
  /**
28
29
  * Dynamically creates a mapping from verification method key type to the key Did interface
@@ -1 +1 @@
1
- {"version":3,"file":"keyDidMapping.js","sourceRoot":"","sources":["../../../../../src/modules/dids/domain/key-type/keyDidMapping.ts"],"names":[],"mappings":";;;AAEA,wDAAoD;AACpD,qDAA4D;AAC5D,6CAA8C;AAC9C,8DAK8B;AAC9B,yEAAmH;AAEnH,6CAA+C;AAC/C,iDAAmD;AACnD,6CAA+C;AAC/C,uCAAyC;AACzC,yDAAqD;AACrD,qCAAuC;AAQvC,+CAA+C;AAC/C,MAAM,aAAa,GAAmC;IACpD,CAAC,iBAAO,CAAC,OAAO,CAAC,EAAE,uBAAa;IAChC,CAAC,iBAAO,CAAC,MAAM,CAAC,EAAE,qBAAY;IAC9B,CAAC,iBAAO,CAAC,UAAU,CAAC,EAAE,6BAAgB;IACtC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,kBAAkB,CAAC,YAAY,CAAC,CAAC,GAAG,CAAA;KAC3D;IAED,IAAI,IAAA,+BAAU,EAAC,kBAAkB,CAAC,EAAE;QAClC,IAAI,CAAC,kBAAkB,CAAC,kBAAkB,EAAE;YAC1C,MAAM,IAAI,kBAAU,CAClB,+DAA+D,sDAAiC,EAAE,CACnG,CAAA;SACF;QAED,OAAO,IAAA,uCAAkB,EAAC,kBAAkB,CAAC,CAAA;KAC9C;IAED,MAAM,MAAM,GAAG,+BAA+B,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAA;IACvE,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,kBAAU,CAAC,sDAAsD,kBAAkB,CAAC,IAAI,GAAG,CAAC,CAAA;KACvG;IAED,OAAO,MAAM,CAAC,4BAA4B,CAAC,kBAAkB,CAAC,CAAA;AAChE,CAAC;AA7BD,oEA6BC;AAED,SAAgB,8CAA8C,CAAC,OAAgB;IAC7E,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,CAAA;IAErC,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,kBAAU,CAAC,sCAAsC,OAAO,GAAG,CAAC,CAAA;KACvE;IAED,OAAO,MAAM,CAAC,gCAAgC,CAAA;AAChD,CAAC;AARD,wGAQC"}
1
+ {"version":3,"file":"keyDidMapping.js","sourceRoot":"","sources":["../../../../../src/modules/dids/domain/key-type/keyDidMapping.ts"],"names":[],"mappings":";;;AAEA,wDAAoD;AACpD,qDAA4D;AAC5D,6CAA8C;AAC9C,8DAK8B;AAC9B,yEAAmH;AAEnH,6CAA+C;AAC/C,iDAAmD;AACnD,6CAA+C;AAC/C,uCAAyC;AACzC,yDAAqD;AACrD,2CAA6C;AAC7C,qCAAuC;AAQvC,+CAA+C;AAC/C,MAAM,aAAa,GAAmC;IACpD,CAAC,iBAAO,CAAC,OAAO,CAAC,EAAE,uBAAa;IAChC,CAAC,iBAAO,CAAC,MAAM,CAAC,EAAE,qBAAY;IAC9B,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AE,CACtG,CAAA;SACF;QAED,OAAO,IAAA,oBAAc,EAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC,GAAG,CAAA;KAC3D;IAED,IAAI,IAAA,+BAAU,EAAC,kBAAkB,CAAC,EAAE;QAClC,IAAI,CAAC,kBAAkB,CAAC,kBAAkB,EAAE;YAC1C,MAAM,IAAI,kBAAU,CAClB,+DAA+D,sDAAiC,EAAE,CACnG,CAAA;SACF;QAED,OAAO,IAAA,uCAAkB,EAAC,kBAAkB,CAAC,CAAA;KAC9C;IAED,MAAM,MAAM,GAAG,+BAA+B,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAA;IACvE,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,kBAAU,CAAC,sDAAsD,kBAAkB,CAAC,IAAI,GAAG,CAAC,CAAA;KACvG;IAED,OAAO,MAAM,CAAC,4BAA4B,CAAC,kBAAkB,CAAC,CAAA;AAChE,CAAC;AA7BD,oEA6BC;AAED,SAAgB,8CAA8C,CAAC,OAAgB;IAC7E,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,CAAA;IAErC,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,kBAAU,CAAC,sCAAsC,OAAO,GAAG,CAAC,CAAA;KACvE;IAED,OAAO,MAAM,CAAC,gCAAgC,CAAA;AAChD,CAAC;AARD,wGAQC"}
@@ -0,0 +1,2 @@
1
+ import type { KeyDidMapping } from './keyDidMapping';
2
+ export declare const keyDidSecp256k1: KeyDidMapping;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.keyDidSecp256k1 = void 0;
4
+ const KeyType_1 = require("../../../../crypto/KeyType");
5
+ const error_1 = require("../../../../error");
6
+ const verificationMethod_1 = require("../verificationMethod");
7
+ exports.keyDidSecp256k1 = {
8
+ supportedVerificationMethodTypes: [
9
+ verificationMethod_1.VERIFICATION_METHOD_TYPE_ECDSA_SECP256K1_VERIFICATION_KEY_2019,
10
+ verificationMethod_1.VERIFICATION_METHOD_TYPE_JSON_WEB_KEY_2020,
11
+ ],
12
+ getVerificationMethods: (did, key) => [(0, verificationMethod_1.getJsonWebKey2020)({ did, key })],
13
+ getKeyFromVerificationMethod: (verificationMethod) => {
14
+ if ((0, verificationMethod_1.isEcdsaSecp256k1VerificationKey2019)(verificationMethod)) {
15
+ return (0, verificationMethod_1.getKeyFromEcdsaSecp256k1VerificationKey2019)(verificationMethod);
16
+ }
17
+ if ((0, verificationMethod_1.isJsonWebKey2020)(verificationMethod)) {
18
+ return (0, verificationMethod_1.getKeyFromJsonWebKey2020)(verificationMethod);
19
+ }
20
+ throw new error_1.CredoError(`Verification method with type '${verificationMethod.type}' not supported for key type '${KeyType_1.KeyType.K256}'`);
21
+ },
22
+ };
23
+ //# sourceMappingURL=secp256k1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secp256k1.js","sourceRoot":"","sources":["../../../../../src/modules/dids/domain/key-type/secp256k1.ts"],"names":[],"mappings":";;;AAGA,wDAAoD;AACpD,6CAA8C;AAC9C,8DAQ8B;AAEjB,QAAA,eAAe,GAAkB;IAC5C,gCAAgC,EAAE;QAChC,mFAA8D;QAC9D,+DAA0C;KAC3C;IACD,sBAAsB,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,IAAA,sCAAiB,EAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;IACvE,4BAA4B,EAAE,CAAC,kBAAsC,EAAE,EAAE;QACvE,IAAI,IAAA,wDAAmC,EAAC,kBAAkB,CAAC,EAAE;YAC3D,OAAO,IAAA,gEAA2C,EAAC,kBAAkB,CAAC,CAAA;SACvE;QAED,IAAI,IAAA,qCAAgB,EAAC,kBAAkB,CAAC,EAAE;YACxC,OAAO,IAAA,6CAAwB,EAAC,kBAAkB,CAAC,CAAA;SACpD;QAED,MAAM,IAAI,kBAAU,CAClB,kCAAkC,kBAAkB,CAAC,IAAI,iCAAiC,iBAAO,CAAC,IAAI,GAAG,CAC1G,CAAA;IACH,CAAC;CACF,CAAA"}
@@ -0,0 +1,23 @@
1
+ import { Key } from '../../../../crypto/Key';
2
+ import { VerificationMethod } from './VerificationMethod';
3
+ export declare const VERIFICATION_METHOD_TYPE_ECDSA_SECP256K1_VERIFICATION_KEY_2019 = "EcdsaSecp256k1VerificationKey2019";
4
+ type EcdsaSecp256k1VerificationKey2019 = VerificationMethod & {
5
+ type: typeof VERIFICATION_METHOD_TYPE_ECDSA_SECP256K1_VERIFICATION_KEY_2019;
6
+ };
7
+ /**
8
+ * Get a EcdsaSecp256k1VerificationKey2019 verification method.
9
+ */
10
+ export declare function getEcdsaSecp256k1VerificationKey2019({ key, id, controller, }: {
11
+ id: string;
12
+ key: Key;
13
+ controller: string;
14
+ }): VerificationMethod;
15
+ /**
16
+ * Check whether a verification method is a EcdsaSecp256k1VerificationKey2019 verification method.
17
+ */
18
+ export declare function isEcdsaSecp256k1VerificationKey2019(verificationMethod: VerificationMethod): verificationMethod is EcdsaSecp256k1VerificationKey2019;
19
+ /**
20
+ * Get a key from a EcdsaSecp256k1VerificationKey2019 verification method.
21
+ */
22
+ export declare function getKeyFromEcdsaSecp256k1VerificationKey2019(verificationMethod: EcdsaSecp256k1VerificationKey2019): Key;
23
+ export {};
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getKeyFromEcdsaSecp256k1VerificationKey2019 = exports.isEcdsaSecp256k1VerificationKey2019 = exports.getEcdsaSecp256k1VerificationKey2019 = exports.VERIFICATION_METHOD_TYPE_ECDSA_SECP256K1_VERIFICATION_KEY_2019 = void 0;
4
+ const crypto_1 = require("../../../../crypto");
5
+ const Key_1 = require("../../../../crypto/Key");
6
+ const error_1 = require("../../../../error");
7
+ const VerificationMethod_1 = require("./VerificationMethod");
8
+ exports.VERIFICATION_METHOD_TYPE_ECDSA_SECP256K1_VERIFICATION_KEY_2019 = 'EcdsaSecp256k1VerificationKey2019';
9
+ /**
10
+ * Get a EcdsaSecp256k1VerificationKey2019 verification method.
11
+ */
12
+ function getEcdsaSecp256k1VerificationKey2019({ key, id, controller, }) {
13
+ return new VerificationMethod_1.VerificationMethod({
14
+ id,
15
+ type: exports.VERIFICATION_METHOD_TYPE_ECDSA_SECP256K1_VERIFICATION_KEY_2019,
16
+ controller,
17
+ publicKeyBase58: key.publicKeyBase58,
18
+ });
19
+ }
20
+ exports.getEcdsaSecp256k1VerificationKey2019 = getEcdsaSecp256k1VerificationKey2019;
21
+ /**
22
+ * Check whether a verification method is a EcdsaSecp256k1VerificationKey2019 verification method.
23
+ */
24
+ function isEcdsaSecp256k1VerificationKey2019(verificationMethod) {
25
+ return verificationMethod.type === exports.VERIFICATION_METHOD_TYPE_ECDSA_SECP256K1_VERIFICATION_KEY_2019;
26
+ }
27
+ exports.isEcdsaSecp256k1VerificationKey2019 = isEcdsaSecp256k1VerificationKey2019;
28
+ /**
29
+ * Get a key from a EcdsaSecp256k1VerificationKey2019 verification method.
30
+ */
31
+ function getKeyFromEcdsaSecp256k1VerificationKey2019(verificationMethod) {
32
+ if (!verificationMethod.publicKeyBase58) {
33
+ throw new error_1.CredoError('verification method is missing publicKeyBase58');
34
+ }
35
+ return Key_1.Key.fromPublicKeyBase58(verificationMethod.publicKeyBase58, crypto_1.KeyType.K256);
36
+ }
37
+ exports.getKeyFromEcdsaSecp256k1VerificationKey2019 = getKeyFromEcdsaSecp256k1VerificationKey2019;
38
+ //# sourceMappingURL=EcdsaSecp256k1VerificationKey2019.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EcdsaSecp256k1VerificationKey2019.js","sourceRoot":"","sources":["../../../../../src/modules/dids/domain/verificationMethod/EcdsaSecp256k1VerificationKey2019.ts"],"names":[],"mappings":";;;AAAA,+CAA4C;AAC5C,gDAA4C;AAC5C,6CAA8C;AAE9C,6DAAyD;AAE5C,QAAA,8DAA8D,GAAG,mCAAmC,CAAA;AAMjH;;GAEG;AACH,SAAgB,oCAAoC,CAAC,EACnD,GAAG,EACH,EAAE,EACF,UAAU,GAKX;IACC,OAAO,IAAI,uCAAkB,CAAC;QAC5B,EAAE;QACF,IAAI,EAAE,sEAA8D;QACpE,UAAU;QACV,eAAe,EAAE,GAAG,CAAC,eAAe;KACrC,CAAC,CAAA;AACJ,CAAC;AAfD,oFAeC;AAED;;GAEG;AACH,SAAgB,mCAAmC,CACjD,kBAAsC;IAEtC,OAAO,kBAAkB,CAAC,IAAI,KAAK,sEAA8D,CAAA;AACnG,CAAC;AAJD,kFAIC;AAED;;GAEG;AACH,SAAgB,2CAA2C,CAAC,kBAAqD;IAC/G,IAAI,CAAC,kBAAkB,CAAC,eAAe,EAAE;QACvC,MAAM,IAAI,kBAAU,CAAC,gDAAgD,CAAC,CAAA;KACvE;IAED,OAAO,SAAG,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,eAAe,EAAE,gBAAO,CAAC,IAAI,CAAC,CAAA;AAClF,CAAC;AAND,kGAMC"}
@@ -7,3 +7,4 @@ export * from './Ed25519VerificationKey2020';
7
7
  export * from './JsonWebKey2020';
8
8
  export * from './X25519KeyAgreementKey2019';
9
9
  export * from './Multikey';
10
+ export * from './EcdsaSecp256k1VerificationKey2019';
@@ -27,4 +27,5 @@ __exportStar(require("./Ed25519VerificationKey2020"), exports);
27
27
  __exportStar(require("./JsonWebKey2020"), exports);
28
28
  __exportStar(require("./X25519KeyAgreementKey2019"), exports);
29
29
  __exportStar(require("./Multikey"), exports);
30
+ __exportStar(require("./EcdsaSecp256k1VerificationKey2019"), exports);
30
31
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/dids/domain/verificationMethod/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2DAAyD;AAAhD,wHAAA,kBAAkB,OAAA;AAC3B,iFAA6G;AAApG,8IAAA,6BAA6B,OAAA;AAAE,6IAAA,4BAA4B,OAAA;AAEpE,sDAAmC;AACnC,sDAAmC;AACnC,+DAA4C;AAC5C,+DAA4C;AAC5C,mDAAgC;AAChC,8DAA2C;AAC3C,6CAA0B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/dids/domain/verificationMethod/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,2DAAyD;AAAhD,wHAAA,kBAAkB,OAAA;AAC3B,iFAA6G;AAApG,8IAAA,6BAA6B,OAAA;AAAE,6IAAA,4BAA4B,OAAA;AAEpE,sDAAmC;AACnC,sDAAmC;AACnC,+DAA4C;AAC5C,+DAA4C;AAC5C,mDAAgC;AAChC,8DAA2C;AAC3C,6CAA0B;AAC1B,sEAAmD"}
@@ -13,3 +13,4 @@ export declare const VERIFIABLE_CREDENTIAL_TYPE = "VerifiableCredential";
13
13
  export declare const VERIFIABLE_PRESENTATION_TYPE = "VerifiablePresentation";
14
14
  export declare const EXPANDED_TYPE_CREDENTIALS_CONTEXT_V1_VC_TYPE = "https://www.w3.org/2018/credentials#VerifiableCredential";
15
15
  export declare const SECURITY_JWS_CONTEXT_URL = "https://w3id.org/security/suites/jws-2020/v1";
16
+ export declare const SECURITY_CONTEXT_SECP256k1_URL = "https://w3id.org/security/suites/secp256k1-2019/v1";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SECURITY_JWS_CONTEXT_URL = exports.EXPANDED_TYPE_CREDENTIALS_CONTEXT_V1_VC_TYPE = exports.VERIFIABLE_PRESENTATION_TYPE = exports.VERIFIABLE_CREDENTIAL_TYPE = exports.SECURITY_SIGNATURE_URL = exports.SECURITY_PROOF_URL = exports.CREDENTIALS_ISSUER_URL = exports.SECURITY_CONTEXT_BBS_URL = exports.CREDENTIALS_CONTEXT_V1_URL = exports.DID_V1_CONTEXT_URL = exports.SECURITY_X25519_CONTEXT_URL = exports.SECURITY_CONTEXT_URL = exports.SECURITY_CONTEXT_V3_URL = exports.SECURITY_CONTEXT_V2_URL = exports.SECURITY_CONTEXT_V1_URL = void 0;
3
+ exports.SECURITY_CONTEXT_SECP256k1_URL = exports.SECURITY_JWS_CONTEXT_URL = exports.EXPANDED_TYPE_CREDENTIALS_CONTEXT_V1_VC_TYPE = exports.VERIFIABLE_PRESENTATION_TYPE = exports.VERIFIABLE_CREDENTIAL_TYPE = exports.SECURITY_SIGNATURE_URL = exports.SECURITY_PROOF_URL = exports.CREDENTIALS_ISSUER_URL = exports.SECURITY_CONTEXT_BBS_URL = exports.CREDENTIALS_CONTEXT_V1_URL = exports.DID_V1_CONTEXT_URL = exports.SECURITY_X25519_CONTEXT_URL = exports.SECURITY_CONTEXT_URL = exports.SECURITY_CONTEXT_V3_URL = exports.SECURITY_CONTEXT_V2_URL = exports.SECURITY_CONTEXT_V1_URL = void 0;
4
4
  exports.SECURITY_CONTEXT_V1_URL = 'https://w3id.org/security/v1';
5
5
  exports.SECURITY_CONTEXT_V2_URL = 'https://w3id.org/security/v2';
6
6
  exports.SECURITY_CONTEXT_V3_URL = 'https://w3id.org/security/v3-unstable';
@@ -16,4 +16,5 @@ exports.VERIFIABLE_CREDENTIAL_TYPE = 'VerifiableCredential';
16
16
  exports.VERIFIABLE_PRESENTATION_TYPE = 'VerifiablePresentation';
17
17
  exports.EXPANDED_TYPE_CREDENTIALS_CONTEXT_V1_VC_TYPE = 'https://www.w3.org/2018/credentials#VerifiableCredential';
18
18
  exports.SECURITY_JWS_CONTEXT_URL = 'https://w3id.org/security/suites/jws-2020/v1';
19
+ exports.SECURITY_CONTEXT_SECP256k1_URL = 'https://w3id.org/security/suites/secp256k1-2019/v1';
19
20
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/modules/vc/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,uBAAuB,GAAG,8BAA8B,CAAA;AACxD,QAAA,uBAAuB,GAAG,8BAA8B,CAAA;AACxD,QAA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AA,8BAA8B,GAAG,oDAAoD,CAAA"}
@@ -1,5 +1,25 @@
1
1
  import type { BaseAgent } from '../../../../agent/BaseAgent';
2
+ import type { W3cCredentialRecord } from '../../../../modules/vc/repository';
2
3
  /**
3
- * Re-saves the w3c credential records to add the new claimFormat tag.
4
+ * Re-saves the w3c credential records to add the new 'types' tag.
4
5
  */
5
6
  export declare function migrateW3cCredentialRecordToV0_5<Agent extends BaseAgent>(agent: Agent): Promise<void>;
7
+ /**
8
+ * Up until 0.5.0 the AskarStorageService contained a bug where a non-computed (so manually set on record) array tag values that contained a : in the value
9
+ * would be incorrectly parsed back from an askar tag to a tag on a record. This would only cause problems for the storage if the record was re-saved and not
10
+ * computed. The following would happen:
11
+ * - Create record with non-computed tag, e.g. expandedTypes that contains a value with a : in it
12
+ * - Save record. The tag is correctly set in Askar as `expandedTypes:https://example.com'
13
+ * - Read record. The tag is correctly read from Askar as `expandedTypes:https://example.com'. However the transformation would result in the tag value on the record being set to `https'.
14
+ * - Save record. The non-computed (important, as otherwise the correct computed value would overwrite the incorrect value before storing) tag value is now set to `https' instead of `https://example.com'
15
+ *
16
+ * This function checks if any of the values for expandedTypes is `https` and if so, re-calculates the correct value and sets it on the record.
17
+ *
18
+ * NOTE: This function needs to resolve the context of a W3cCredentialRecord to be able to correctly calculate the expanded types.
19
+ * To not brick a wallet that has no internet when updating, the storage update will allow the resolving of the expanded types to fail.
20
+ * If this is the case, at a later point the expanded types will need to be recalculated and set on the record.
21
+ *
22
+ * If w3c credential records are never re-saved this shouldn't be a problem though. By default w3c credential records are not re-saved,
23
+ * and so it only applies if you have implemented a custom flow that re-saves w3c credential records (e.g. if you add metadata).
24
+ */
25
+ export declare function fixIncorrectExpandedTypesWithAskarStorage<Agent extends BaseAgent>(agent: Agent, w3cCredentialRecord: W3cCredentialRecord): Promise<void>;
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.migrateW3cCredentialRecordToV0_5 = void 0;
3
+ exports.fixIncorrectExpandedTypesWithAskarStorage = exports.migrateW3cCredentialRecordToV0_5 = void 0;
4
+ const vc_1 = require("../../../../modules/vc");
5
+ const W3cJsonLdCredentialService_1 = require("../../../../modules/vc/data-integrity/W3cJsonLdCredentialService");
4
6
  const repository_1 = require("../../../../modules/vc/repository");
5
7
  /**
6
- * Re-saves the w3c credential records to add the new claimFormat tag.
8
+ * Re-saves the w3c credential records to add the new 'types' tag.
7
9
  */
8
10
  async function migrateW3cCredentialRecordToV0_5(agent) {
9
11
  agent.config.logger.info('Migration w3c credential records records to storage version 0.5');
@@ -12,11 +14,53 @@ async function migrateW3cCredentialRecordToV0_5(agent) {
12
14
  const records = await w3cCredentialRepository.getAll(agent.context);
13
15
  agent.config.logger.debug(`Found a total of ${records.length} w3c credential records to update.`);
14
16
  for (const record of records) {
15
- agent.config.logger.debug(`Re-saving w3c credential record with id ${record.id} to add claimFormat tag for storage version 0.5`);
17
+ agent.config.logger.debug(`Updating w3c credential record with id ${record.id} to add 'types' tag and fix 'expandedTypes' tag for storage version 0.5`);
18
+ await fixIncorrectExpandedTypesWithAskarStorage(agent, record);
16
19
  // Save updated record
17
20
  await w3cCredentialRepository.update(agent.context, record);
18
21
  agent.config.logger.debug(`Successfully migrated w3c credential record with id ${record.id} to storage version 0.5`);
19
22
  }
20
23
  }
21
24
  exports.migrateW3cCredentialRecordToV0_5 = migrateW3cCredentialRecordToV0_5;
25
+ /**
26
+ * Up until 0.5.0 the AskarStorageService contained a bug where a non-computed (so manually set on record) array tag values that contained a : in the value
27
+ * would be incorrectly parsed back from an askar tag to a tag on a record. This would only cause problems for the storage if the record was re-saved and not
28
+ * computed. The following would happen:
29
+ * - Create record with non-computed tag, e.g. expandedTypes that contains a value with a : in it
30
+ * - Save record. The tag is correctly set in Askar as `expandedTypes:https://example.com'
31
+ * - Read record. The tag is correctly read from Askar as `expandedTypes:https://example.com'. However the transformation would result in the tag value on the record being set to `https'.
32
+ * - Save record. The non-computed (important, as otherwise the correct computed value would overwrite the incorrect value before storing) tag value is now set to `https' instead of `https://example.com'
33
+ *
34
+ * This function checks if any of the values for expandedTypes is `https` and if so, re-calculates the correct value and sets it on the record.
35
+ *
36
+ * NOTE: This function needs to resolve the context of a W3cCredentialRecord to be able to correctly calculate the expanded types.
37
+ * To not brick a wallet that has no internet when updating, the storage update will allow the resolving of the expanded types to fail.
38
+ * If this is the case, at a later point the expanded types will need to be recalculated and set on the record.
39
+ *
40
+ * If w3c credential records are never re-saved this shouldn't be a problem though. By default w3c credential records are not re-saved,
41
+ * and so it only applies if you have implemented a custom flow that re-saves w3c credential records (e.g. if you add metadata).
42
+ */
43
+ async function fixIncorrectExpandedTypesWithAskarStorage(agent, w3cCredentialRecord) {
44
+ var _a;
45
+ // We don't store the expanded types for JWT credentials (should we? As you can have jwt_vc with json-ld)
46
+ if (!(w3cCredentialRecord.credential instanceof vc_1.W3cJsonLdVerifiableCredential))
47
+ return;
48
+ const expandedTypes = ((_a = w3cCredentialRecord.getTag('expandedTypes')) !== null && _a !== void 0 ? _a : []);
49
+ // Check if one of the values is `https`
50
+ const hasInvalidType = expandedTypes.some((type) => type === 'https');
51
+ if (!hasInvalidType)
52
+ return;
53
+ agent.context.config.logger.info(`W3c credential record with id '${w3cCredentialRecord.id}' contains invalid expanded types. Recalculating...`);
54
+ const w3cJsonLdCredentialService = agent.dependencyManager.resolve(W3cJsonLdCredentialService_1.W3cJsonLdCredentialService);
55
+ try {
56
+ // JsonLd credentials need expanded types to be stored.
57
+ const newExpandedTypes = await w3cJsonLdCredentialService.getExpandedTypesForCredential(agent.context, w3cCredentialRecord.credential);
58
+ w3cCredentialRecord.setTag('expandedTypes', newExpandedTypes);
59
+ agent.context.config.logger.info(`Successfully recalculated expanded types for w3c credential record with id ${w3cCredentialRecord.id} to ${newExpandedTypes} and set it on the record.`);
60
+ }
61
+ catch (error) {
62
+ agent.context.config.logger.error(`Retrieving expandedTypes fro w3c credential record with id ${w3cCredentialRecord.id} failed. To not brick the wallet, the storage update will not fail. Make sure to recalculate the expanded types at a later point. This is probably due to a missing internet connection. See https://credo.js.org/guides/updating/versions/0.4-to-0.5 for more information.`);
63
+ }
64
+ }
65
+ exports.fixIncorrectExpandedTypesWithAskarStorage = fixIncorrectExpandedTypesWithAskarStorage;
22
66
  //# sourceMappingURL=w3cCredentialRecord.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"w3cCredentialRecord.js","sourceRoot":"","sources":["../../../../../src/storage/migration/updates/0.4-0.5/w3cCredentialRecord.ts"],"names":[],"mappings":";;;AAEA,kEAA2E;AAE3E;;GAEG;AACI,KAAK,UAAU,gCAAgC,CAA0B,KAAY;IAC1F,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,iEAAiE,CAAC,CAAA;IAE3F,MAAM,uBAAuB,GAAG,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,oCAAuB,CAAC,CAAA;IAExF,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAA;IAC7E,MAAM,OAAO,GAAG,MAAM,uBAAuB,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAEnE,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,OAAO,CAAC,MAAM,oCAAoC,CAAC,CAAA;IAEjG,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC5B,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CACvB,2CAA2C,MAAM,CAAC,EAAE,iDAAiD,CACtG,CAAA;QAED,sBAAsB;QACtB,MAAM,uBAAuB,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;QAE3D,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,uDAAuD,MAAM,CAAC,EAAE,yBAAyB,CAAC,CAAA;KACrH;AACH,CAAC;AApBD,4EAoBC"}
1
+ {"version":3,"file":"w3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,MAAM,aAAa,GAAG,CAAC,MAAA,mBAAmB,CAAC,MAAM,CAAC,eAAe,CAAC,mCAAI,EAAE,CAAa,CAAA;IAErF,wCAAwC;IACxC,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,OAAO,CAAC,CAAA;IAErE,IAAI,CAAC,cAAc;QAAE,OAAM;IAE3B,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAC9B,kCAAkC,mBAAmB,CAAC,EAAE,qDAAqD,CAC9G,CAAA;IACD,MAAM,0BAA0B,GAAG,KAAK,CAAC,iBAAiB,CAAC,OAAO,CAAC,uDAA0B,CAAC,CAAA;IAE9F,IAAI;QACF,uDAAuD;QACvD,MAAM,gBAAgB,GAAG,MAAM,0BAA0B,CAAC,6BAA6B,CACrF,KAAK,CAAC,OAAO,EACb,mBAAmB,CAAC,UAAU,CAC/B,CAAA;QAED,mBAAmB,CAAC,MAAM,CAAC,eAAe,EAAE,gBAAgB,CAAC,CAAA;QAC7D,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAC9B,8EAA8E,mBAAmB,CAAC,EAAE,OAAO,gBAAgB,4BAA4B,CACxJ,CAAA;KACF;IAAC,OAAO,KAAK,EAAE;QACd,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAC/B,8DAA8D,mBAAmB,CAAC,EAAE,6QAA6Q,CAClW,CAAA;KACF;AACH,CAAC;AAnCD,8FAmCC"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@credo-ts/core",
3
3
  "main": "build/index",
4
4
  "types": "build/index",
5
- "version": "0.5.0-alpha.120+c5c5b850",
5
+ "version": "0.5.0-alpha.122+f245386e",
6
6
  "files": [
7
7
  "build"
8
8
  ],
@@ -67,5 +67,5 @@
67
67
  "tslog": "^4.8.2",
68
68
  "typescript": "~4.9.5"
69
69
  },
70
- "gitHead": "c5c5b850f27e66f7a2e39acd5fc14267babee208"
70
+ "gitHead": "f245386eef2e0daad7a5c948df29625f60a020ea"
71
71
  }