()
| 51 | * unsigned. |
| 52 | */ |
| 53 | export function isC2PASigningEnabled(): boolean { |
| 54 | if (process.env.C2PA_SIGNING_ENABLED !== 'true') return false; |
| 55 | const certPresent = |
| 56 | typeof process.env.C2PA_CERT_PEM_B64 === 'string' && process.env.C2PA_CERT_PEM_B64.length > 0; |
| 57 | const keyPresent = |
| 58 | typeof process.env.C2PA_PRIVATE_KEY_PEM_B64 === 'string' && |
| 59 | process.env.C2PA_PRIVATE_KEY_PEM_B64.length > 0; |
| 60 | if ((!certPresent || !keyPresent) && !misconfigWarned) { |
| 61 | misconfigWarned = true; |
| 62 | logger.warn( |
| 63 | { certPresent, keyPresent }, |
| 64 | 'C2PA_SIGNING_ENABLED is true but cert/key secret is missing — signing will be skipped', |
| 65 | ); |
| 66 | } |
| 67 | return certPresent && keyPresent; |
| 68 | } |
| 69 | |
| 70 | function getSigner(): LocalSigner { |
| 71 | if (cachedSigner) return cachedSigner; |
no test coverage detected