{"version":3,"file":"KemKeypairRecord.mjs","names":[],"sources":["../../src/repository/KemKeypairRecord.ts"],"sourcesContent":["import type { TagsBase, RecordTags } from '@credo-ts/core'\r\n\r\nimport { BaseRecord, utils } from '@credo-ts/core'\r\n\r\nexport type CustomKemKeypairTags = TagsBase\r\n\r\nexport type DefaultKemKeypairTags = {\r\n  connectionId: string\r\n  kid: string\r\n}\r\n\r\nexport type KemKeypairTags = RecordTags<KemKeypairRecord>\r\n\r\nexport interface KemKeypairRecordProps {\r\n  id?: string\r\n  createdAt?: Date\r\n  tags?: CustomKemKeypairTags\r\n\r\n  connectionId: string\r\n  kid: string\r\n  publicKey: string // base64url-encoded ML-KEM-768 public key\r\n  secretKey: string // base64url-encoded ML-KEM-768 secret key\r\n}\r\n\r\n/**\r\n * Database record for a local ML-KEM keypair\r\n *\r\n * Stores the full keypair (including secret key) for vault decryption.\r\n * Indexed by connectionId and kid for efficient lookups.\r\n */\r\nexport class KemKeypairRecord extends BaseRecord<DefaultKemKeypairTags, CustomKemKeypairTags> {\r\n  /** Connection this keypair is associated with */\r\n  public connectionId!: string\r\n\r\n  /** Key identifier (derived from public key hash) */\r\n  public kid!: string\r\n\r\n  /** Base64url-encoded ML-KEM public key (1184 bytes for ML-KEM-768) */\r\n  public publicKey!: string\r\n\r\n  /** Base64url-encoded ML-KEM secret key (2400 bytes for ML-KEM-768) */\r\n  public secretKey!: string\r\n\r\n  public static readonly type = 'KemKeypairRecord'\r\n  public readonly type = KemKeypairRecord.type\r\n\r\n  public constructor(props: KemKeypairRecordProps) {\r\n    super()\r\n\r\n    if (props) {\r\n      this.id = props.id ?? utils.uuid()\r\n      this.createdAt = props.createdAt ?? new Date()\r\n      this.connectionId = props.connectionId\r\n      this.kid = props.kid\r\n      this.publicKey = props.publicKey\r\n      this.secretKey = props.secretKey\r\n      this._tags = props.tags ?? {}\r\n    }\r\n  }\r\n\r\n  public getTags(): DefaultKemKeypairTags & CustomKemKeypairTags {\r\n    return {\r\n      ...this._tags,\r\n      connectionId: this.connectionId,\r\n      kid: this.kid,\r\n    }\r\n  }\r\n}\r\n"],"mappings":";;;;;;;;;AA8BA,IAAa,mBAAb,MAAa,yBAAyB,WAAwD;CAgB5F,AAAO,YAAY,OAA8B;AAC/C,SAAO;OAHO,OAAO,iBAAiB;AAKtC,MAAI,OAAO;AACT,QAAK,KAAK,MAAM,MAAM,MAAM,MAAM;AAClC,QAAK,YAAY,MAAM,6BAAa,IAAI,MAAM;AAC9C,QAAK,eAAe,MAAM;AAC1B,QAAK,MAAM,MAAM;AACjB,QAAK,YAAY,MAAM;AACvB,QAAK,YAAY,MAAM;AACvB,QAAK,QAAQ,MAAM,QAAQ,EAAE;;;CAIjC,AAAO,UAAwD;AAC7D,SAAO;GACL,GAAG,KAAK;GACR,cAAc,KAAK;GACnB,KAAK,KAAK;GACX;;;iBAtBoB,OAAO"}