mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 16:02:32 +00:00
* refactor(cloud): share PostgreSQL schema startup between services * feat(cloud): add durable native push notification gateway * infra(push): define dedicated gateway resources and operational checks * fix(push): bound cross-host admission and simplify gateway configuration * fix(push): validate deploy configuration and preserve topic-error registrations
10 lines
505 B
TypeScript
10 lines
505 B
TypeScript
// Rejects the many base64 spellings of the same bytes: a non-canonical
|
|
// encoding would change the transcript the host signs without changing the key.
|
|
export function decodeCanonicalBase64(value: string, expectedBytes: number): Buffer | null {
|
|
if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value)) return null
|
|
const decoded = Buffer.from(value, 'base64')
|
|
return decoded.byteLength === expectedBytes && decoded.toString('base64') === value
|
|
? decoded
|
|
: null
|
|
}
|