• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hyperledger-identus / sdk-ts / 23159132029

16 Mar 2026 06:16PM UTC coverage: 71.673% (-0.03%) from 71.698%
23159132029

push

github

web-flow
fix: linter rules on e2e tests project (#510)

Signed-off-by: Francisco Javier Ribo Labrador <elribonazo@gmail.com>

1387 of 2155 branches covered (64.36%)

Branch coverage included in aggregate %.

3213 of 4263 relevant lines covered (75.37%)

45.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

42.86
/src/pluto/models/Credential.ts
1
import * as sha256 from '@stablelib/sha256';
2
import type { Model } from "./Model";
3
import { schemaFactory } from "./Schema";
4
import { JWTVerifiableCredentialRecoveryId } from "../../pollux/models/JWTVerifiableCredential";
5
import { AnonCredsRecoveryId } from "../../pollux/models/AnonCredsVerifiableCredential";
6
import { PlutoError } from '../../domain';
7
import { type MigrationStrategies } from '../types';
8

9
/**
10
 * Definition for Storable Credential model
11
 * Represents {@link Domain.Credential Credential}
12
 * 
13
 * @typedef {Object} CredentialModel
14
 */
15
export interface Credential extends Model {
16
  /**
17
   * Identifier for recovery
18
   */
19
  recoveryId: string;
20
  /**
21
   * Stringified JSON values
22
   */
23
  dataJson: string;
24

25
  // searchable properties
26
  issuer?: string;
27
  subject?: string;
28
  credentialCreated?: string;
29
  credentialUpdated?: string;
30
  credentialSchema?: string;
31
  validUntil?: number;
32
  revoked?: boolean;
33
  // availableClaims?: string[];
34
  id: string;
35
}
36

37
export const CredentialSchema = schemaFactory<Credential>(schema => {
55✔
38
  schema.addProperty("string", "recoveryId");
55✔
39
  schema.addProperty("string", "dataJson");
55✔
40

41
  schema.addProperty("string", "issuer");
55✔
42
  schema.addProperty("string", "subject");
55✔
43
  schema.addProperty("string", "credentialCreated");
55✔
44
  schema.addProperty("string", "credentialUpdated");
55✔
45
  schema.addProperty("string", "credentialSchema");
55✔
46
  schema.addProperty("number", "validUntil");
55✔
47
  schema.addProperty("boolean", "revoked");
55✔
48

49
  schema.setEncrypted("dataJson");
55✔
50
  schema.setVersion(2);
55✔
51

52
  //V1
53
  schema.addProperty("string", "id");
55✔
54
  schema.setRequired("recoveryId", "dataJson", "id");
55✔
55

56
});
57

58
export const CredentialMigration: MigrationStrategies = {
55✔
59
  1: function (document) {
60
    const recoveryId = document.recoveryId;
×
61
    if (recoveryId == JWTVerifiableCredentialRecoveryId) {
×
62
      const jwtObj = JSON.parse(document.dataJson);
×
63
      return {
×
64
        ...document,
65
        id: jwtObj.id
66
      }
67
    }
68
    if (recoveryId == AnonCredsRecoveryId) {
×
69
      const anoncredsObject = JSON.parse(document.dataJson);
×
70
      if (anoncredsObject.revoked !== undefined) {
×
71
        delete anoncredsObject.revoked;
×
72
      }
73
      const anoncredsStr = JSON.stringify(anoncredsObject)
×
74
      return {
×
75
        ...document,
76
        id: Buffer.from(sha256.hash(Buffer.from(anoncredsStr))).toString('hex')
77
      }
78

79
    }
80
    throw new PlutoError.UnknownCredentialTypeError();
×
81
  },
82
  2: function (document) {
83
    return {
×
84
      ...document,
85
      validUntil: document.validUntil ? new Date(document.validUntil).getTime() : undefined
×
86
    }
87
  }
88
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc