Options
All
  • Public
  • Public/Protected
  • All
Menu

@truestamp/id - v1.2.0

Index

Type Aliases

IdV1Decode: z.infer<typeof IdV1Decode>
IdV1DecodeArgs: z.infer<typeof IdV1DecodeArgs>
IdV1DecodeUnsafely: z.infer<typeof IdV1DecodeUnsafely>
IdV1EncodeArgs: z.infer<typeof IdV1EncodeArgs>
IdV1ParseArgs: z.infer<typeof IdV1ParseArgs>
IdV1Parsed: z.infer<typeof IdV1Parsed>

Variables

IdV1: ZodObject<{ envelopeHash: ZodString; hmac: ZodString; hmacKey: ZodString; id: ZodString; prefix: ZodDefault<ZodEnum<["T"]>>; test: ZodDefault<ZodBoolean>; timestamp: ZodNumber; ulid: ZodString; version: ZodDefault<ZodLiteral<1>> }, "strip", ZodTypeAny, { envelopeHash: string; hmac: string; hmacKey: string; id: string; prefix: "T"; test: boolean; timestamp: number; ulid: string; version: 1 }, { envelopeHash: string; hmac: string; hmacKey: string; id: string; prefix: undefined | "T"; test: undefined | boolean; timestamp: number; ulid: string; version: undefined | 1 }> = ...
IdV1Decode: ZodObject<Pick<{ envelopeHash: ZodString; hmac: ZodString; hmacKey: ZodString; id: ZodString; prefix: ZodDefault<ZodEnum<["T"]>>; test: ZodDefault<ZodBoolean>; timestamp: ZodNumber; ulid: ZodString; version: ZodDefault<ZodLiteral<1>> }, "version" | "test" | "ulid" | "timestamp" | "envelopeHash">, "strip", ZodTypeAny, { envelopeHash: string; test: boolean; timestamp: number; ulid: string; version: 1 }, { envelopeHash: string; test: undefined | boolean; timestamp: number; ulid: string; version: undefined | 1 }> = ...

The subset of IdV1 returned from a decoded Id

IdV1DecodeArgs: ZodObject<Pick<{ envelopeHash: ZodString; hmac: ZodString; hmacKey: ZodString; id: ZodString; prefix: ZodDefault<ZodEnum<["T"]>>; test: ZodDefault<ZodBoolean>; timestamp: ZodNumber; ulid: ZodString; version: ZodDefault<ZodLiteral<1>> }, "id" | "envelopeHash" | "hmacKey">, "strip", ZodTypeAny, { envelopeHash: string; hmacKey: string; id: string }, { envelopeHash: string; hmacKey: string; id: string }> = ...

The subset of IdV1 needed to decode a new Id

IdV1DecodeUnsafely: ZodObject<Pick<{ envelopeHash: ZodString; hmac: ZodString; hmacKey: ZodString; id: ZodString; prefix: ZodDefault<ZodEnum<["T"]>>; test: ZodDefault<ZodBoolean>; timestamp: ZodNumber; ulid: ZodString; version: ZodDefault<ZodLiteral<1>> }, "version" | "test" | "ulid" | "timestamp">, "strip", ZodTypeAny, { test: boolean; timestamp: number; ulid: string; version: 1 }, { test: undefined | boolean; timestamp: number; ulid: string; version: undefined | 1 }> = ...

The subset of IdV1 returned from a decoded unsafely Id

IdV1EncodeArgs: ZodObject<Pick<{ envelopeHash: ZodString; hmac: ZodString; hmacKey: ZodString; id: ZodString; prefix: ZodDefault<ZodEnum<["T"]>>; test: ZodDefault<ZodBoolean>; timestamp: ZodNumber; ulid: ZodString; version: ZodDefault<ZodLiteral<1>> }, "version" | "test" | "ulid" | "timestamp" | "envelopeHash" | "hmacKey">, "strip", ZodTypeAny, { envelopeHash: string; hmacKey: string; test: boolean; timestamp: number; ulid: string; version: 1 }, { envelopeHash: string; hmacKey: string; test: undefined | boolean; timestamp: number; ulid: string; version: undefined | 1 }> = ...

The subset of IdV1 needed to encode a new Id

IdV1ParseArgs: ZodObject<Pick<{ envelopeHash: ZodString; hmac: ZodString; hmacKey: ZodString; id: ZodString; prefix: ZodDefault<ZodEnum<["T"]>>; test: ZodDefault<ZodBoolean>; timestamp: ZodNumber; ulid: ZodString; version: ZodDefault<ZodLiteral<1>> }, "id">, "strip", ZodTypeAny, { id: string }, { id: string }> = ...
IdV1Parsed: ZodObject<Pick<{ envelopeHash: ZodString; hmac: ZodString; hmacKey: ZodString; id: ZodString; prefix: ZodDefault<ZodEnum<["T"]>>; test: ZodDefault<ZodBoolean>; timestamp: ZodNumber; ulid: ZodString; version: ZodDefault<ZodLiteral<1>> }, "prefix" | "version" | "test" | "ulid" | "timestamp" | "hmac">, "strip", ZodTypeAny, { hmac: string; prefix: "T"; test: boolean; timestamp: number; ulid: string; version: 1 }, { hmac: string; prefix: undefined | "T"; test: undefined | boolean; timestamp: number; ulid: string; version: undefined | 1 }> = ...

The subset of IdV1 parsed from a decoded Id

Functions

  • decode(args: { envelopeHash: string; hmacKey: string; id: string }): { envelopeHash: string; test: boolean; timestamp: number; ulid: string; version: 1 }
  • Decodes a Truestamp Id string into an Id object with HMAC-SHA256 verification. Throws an error if the ID is invalid.

    Parameters

    • args: { envelopeHash: string; hmacKey: string; id: string }
      • envelopeHash: string

        The top-level hash in the Item Envelope that this Id commits to with an HMAC-SHA256.

      • hmacKey: string

        The secret key used to verify the HMAC-SHA256.

      • id: string

        A Truestamp Id string.

    Returns { envelopeHash: string; test: boolean; timestamp: number; ulid: string; version: 1 }

    • A decoded Id object.
    • envelopeHash: string
    • test: boolean
    • timestamp: number
    • ulid: string
    • version: 1
  • decodeUnsafely(__namedParameters: { id: string }): { test: boolean; timestamp: number; ulid: string; version: 1 }
  • Validates and decodes a Truestamp Id string unsafely with NO HMAC verification. Not recommended for normal use. Indicates only that the Id has a valid structure. Throws an 'Error' if the Id has an invalid structure.

    Parameters

    • __namedParameters: { id: string }
      • id: string

    Returns { test: boolean; timestamp: number; ulid: string; version: 1 }

    • Id Object with no HMAC verification.
    • test: boolean
    • timestamp: number
    • ulid: string
    • version: 1
  • encode(args: { envelopeHash: string; hmacKey: string; test: boolean; timestamp: number; ulid: string; version: 1 }): string
  • Encodes args into a string Truestamp Id. Throws an error if any of the args are invalid.

    Parameters

    • args: { envelopeHash: string; hmacKey: string; test: boolean; timestamp: number; ulid: string; version: 1 }
      • envelopeHash: string

        The hash of the envelope

      • hmacKey: string

        The HMAC key

      • test: boolean

        Whether the Id is a test Id

      • timestamp: number

        The timestamp of the Id

      • ulid: string

        The ULID of the Id

      • version: 1

        The Id version

    Returns string

    • A Truestamp Id string.
  • isValid(args: { envelopeHash: string; hmacKey: string; id: string }): boolean
  • Validates a Truestamp Id string with HMAC verification. Does not indicate if the content pointed to by the Id exists, only that it has a valid structure and HMAC. Returns false if the Id is invalid (does not throw).

    Parameters

    • args: { envelopeHash: string; hmacKey: string; id: string }
      • envelopeHash: string

        The top-level hash in the Item Envelope that this Id commits to with an HMAC-SHA256.

      • hmacKey: string

        A Hex key used to verify the HMAC-SHA256.

      • id: string

        A Truestamp Id string.

    Returns boolean

    • Is the Truestamp Id structure valid?
  • isValidUnsafely(__namedParameters: { id: string }): boolean
  • Validates a Truestamp Id string unsafely with NO HMAC verification. Not recommended for normal use. Indicates only that the Id has a valid structure. Returns false if the Id is invalid (does not throw).

    Parameters

    • __namedParameters: { id: string }
      • id: string

    Returns boolean

    • Is the Truestamp Id structure valid?