(bearer: string)
| 32 | /** The org the bearer is scoped to — the Autumn customer id every billing call |
| 33 | * is made against — read from the JWT's public claims. */ |
| 34 | const orgIdOf = (bearer: string): string => { |
| 35 | const claims = JSON.parse(Buffer.from(bearer.split(".")[1] ?? "", "base64url").toString()) as { |
| 36 | readonly org_id?: string; |
| 37 | }; |
| 38 | if (!claims.org_id) throw new Error("orgIdOf: bearer carries no org_id claim"); |
| 39 | return claims.org_id; |
| 40 | }; |
| 41 | |
| 42 | /** A 404 `customer_not_found`, byte-for-byte the shape Autumn answers with for |
| 43 | * an organization it has no customer record for. */ |
no test coverage detected