bundle.d.ts 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import type { Bundle as ProtoBundle, InclusionProof as ProtoInclusionProof, MessageSignature as ProtoMessageSignature, TransparencyLogEntry as ProtoTransparencyLogEntry, VerificationMaterial as ProtoVerificationMaterial } from '@sigstore/protobuf-specs';
  2. import type { WithRequired } from './utility';
  3. export declare const BUNDLE_V01_MEDIA_TYPE = "application/vnd.dev.sigstore.bundle+json;version=0.1";
  4. export declare const BUNDLE_V02_MEDIA_TYPE = "application/vnd.dev.sigstore.bundle+json;version=0.2";
  5. export declare const BUNDLE_V03_LEGACY_MEDIA_TYPE = "application/vnd.dev.sigstore.bundle+json;version=0.3";
  6. export declare const BUNDLE_V03_MEDIA_TYPE = "application/vnd.dev.sigstore.bundle.v0.3+json";
  7. type DsseEnvelopeContent = Extract<ProtoBundle['content'], {
  8. $case: 'dsseEnvelope';
  9. }>;
  10. type MessageSignatureContent = Extract<ProtoBundle['content'], {
  11. $case: 'messageSignature';
  12. }>;
  13. export type MessageSignature = WithRequired<ProtoMessageSignature, 'messageDigest'>;
  14. export type VerificationMaterial = WithRequired<ProtoVerificationMaterial, 'content'>;
  15. export type TransparencyLogEntry = WithRequired<ProtoTransparencyLogEntry, 'logId' | 'kindVersion'>;
  16. export type InclusionProof = WithRequired<ProtoInclusionProof, 'checkpoint'>;
  17. export type TLogEntryWithInclusionPromise = WithRequired<TransparencyLogEntry, 'inclusionPromise'>;
  18. export type TLogEntryWithInclusionProof = TransparencyLogEntry & {
  19. inclusionProof: InclusionProof;
  20. };
  21. export type Bundle = ProtoBundle & {
  22. verificationMaterial: VerificationMaterial & {
  23. tlogEntries: TransparencyLogEntry[];
  24. };
  25. content: (MessageSignatureContent & {
  26. messageSignature: MessageSignature;
  27. }) | DsseEnvelopeContent;
  28. };
  29. export type BundleV01 = Bundle & {
  30. verificationMaterial: Bundle['verificationMaterial'] & {
  31. tlogEntries: TLogEntryWithInclusionPromise[];
  32. };
  33. };
  34. export type BundleLatest = Bundle & {
  35. verificationMaterial: Bundle['verificationMaterial'] & {
  36. tlogEntries: TLogEntryWithInclusionProof[];
  37. };
  38. };
  39. export type BundleWithCertificateChain = Bundle & {
  40. verificationMaterial: Bundle['verificationMaterial'] & {
  41. content: Extract<VerificationMaterial['content'], {
  42. $case: 'x509CertificateChain';
  43. }>;
  44. };
  45. };
  46. export type BundleWithSingleCertificate = Bundle & {
  47. verificationMaterial: Bundle['verificationMaterial'] & {
  48. content: Extract<VerificationMaterial['content'], {
  49. $case: 'certificate';
  50. }>;
  51. };
  52. };
  53. export type BundleWithPublicKey = Bundle & {
  54. verificationMaterial: Bundle['verificationMaterial'] & {
  55. content: Extract<VerificationMaterial['content'], {
  56. $case: 'publicKey';
  57. }>;
  58. };
  59. };
  60. export type BundleWithMessageSignature = Bundle & {
  61. content: Extract<Bundle['content'], {
  62. $case: 'messageSignature';
  63. }>;
  64. };
  65. export type BundleWithDsseEnvelope = Bundle & {
  66. content: Extract<Bundle['content'], {
  67. $case: 'dsseEnvelope';
  68. }>;
  69. };
  70. export declare function isBundleWithCertificateChain(b: Bundle): b is BundleWithCertificateChain;
  71. export declare function isBundleWithPublicKey(b: Bundle): b is BundleWithPublicKey;
  72. export declare function isBundleWithMessageSignature(b: Bundle): b is BundleWithMessageSignature;
  73. export declare function isBundleWithDsseEnvelope(b: Bundle): b is BundleWithDsseEnvelope;
  74. export {};