Hierarchy

  • Versioned
    • CredentialSchema

Constructors

  • Takes a schema object as per JSON-schema syntax (IJsonSchema), validates it and converts it to an internal representation (ISchema) and stores both as the one with JSON-schema syntax is added to the credential representation.

    Parameters

    • jsonSchema: IEmbeddedJsonSchema | IJsonSchema

      Could be a JSON schema with properties or contain an $id key which is used to fetch them

    • parsingOpts: Partial<ISchemaParsingOpts> = DefaultSchemaParsingOpts

      Options to parse the schema like whether to use defaults and what defaults to use

    • addMissingParsingOpts: boolean = true

      Whether to update parsingOpts for any missing options with default options. Pass false when deserializing to get the exact object that was serialized which is necessary when verifying signatures

    • Optionaloverrides: Partial<ISchemaOverrides>

      Override any properties of the schema

    • OptionalfullJsonSchema: IEmbeddedJsonSchema

      When jsonSchema does not contain the properties, this object is expected to contain them.

    • useConstantTimeEncoder: boolean = true

      Set to false when creating legacy schemas

    Returns CredentialSchema

Properties

_version: string
encoder: Encoder
fullJsonSchema?: IEmbeddedJsonSchema
parsingOptions: ISchemaParsingOpts
schema: ISchema
IGNORE_GENERIC_VALIDATION: Set<string> = ...

Keys to ignore from generic validation as they are already validated

IMPLICIT_FIELDS: {
    credentialSchema: {
        details: {
            type: string;
        };
        id: {
            type: string;
        };
        type: {
            type: string;
        };
        version: {
            type: string;
        };
    };
    cryptoVersion: {
        type: string;
    };
} = ...

Implicit fields for schema version >= 0.4.0

JSON_SCHEMA_CUSTOM_DEFS: {
    encryptableCompString: {
        type: string;
    };
    encryptableString: {
        type: string;
    };
} = ...

Custom definitions for JSON schema syntax

JSON_SCHEMA_OVERRIDE_DEFS: {
    #/definitions/encryptableCompString: {
        compress: boolean;
        type: string;
    };
    #/definitions/encryptableString: {
        compress: boolean;
        type: string;
    };
} = ...

Custom override definitions for JSON schema syntax. Any refs in the jsonschema that reference these will be overwritten

OLD_IMPLICIT_FIELDS: {
    credentialSchema: {
        type: string;
    };
    cryptoVersion: {
        type: string;
    };
} = ...

Implicit fields for schema version < 0.4.0

POSSIBLE_TYPES: Set<string> = ...
RESERVED_NAMES: Set<string> = ...

CredentialBuilder subject/claims cannot have any of these names

VERSION: string = '0.5.0'

Follows semver and must be updated accordingly when the logic of this class changes or the underlying crypto changes.

Accessors

Methods

  • Returns true if the JSON schema provided during the object creation was an embedded one.

    Returns boolean

  • Initialize the encoder as per the internal representation of schema, i.e. ISchema

    Parameters

    • useConstantTimeEncoder: boolean = true

    Returns void

  • Convert schema JSON to a data URI

    Parameters

    • jsonSchema: IEmbeddedJsonSchema | IJsonSchema
    • Optionalversion: string

      The schema version. This is needed as a different conversion to JSON function was used in older version and backward compatibility is needed.

    Returns string

  • Convert a schema object as per JSON-schema syntax (IJsonSchema) to the internal representation (ISchema). Currently, does not check if the needed JSON-schema definitions are actually present but assumes that they will be already passed.

    Parameters

    • inputNode: any
    • parsingOpts: ISchemaParsingOpts
    • nodeKeyName: string = ''

      Name of the node, used for throwing more informative error message

    • OptionalrootObject: object

    Returns object

  • Generate a schema based on the credential and with the help of a schema that defines some fields. For fields with a conflicting types between credential and schema, error will be thrown. For extra keys or items in schema, they will be removed in the returned schema. The missing keys or items in schema will be added in the returned schema.

    Parameters

    Returns CredentialSchema

  • Parameters

    • node: {
          minimum?: number;
          multipleOf: number;
      }
      • Optionalminimum?: number
      • multipleOf: number
    • parsingOpts: ISchemaParsingOpts
    • nodeName: string

    Returns object