(str: string)
| 31 | } |
| 32 | |
| 33 | async function unpackObject<T>(str: string): Promise<T | null> { |
| 34 | try { |
| 35 | const bits = str.split('|'); |
| 36 | if (bits.length == 2) { |
| 37 | const json = atob(bits[0]); |
| 38 | const bytes = new TextEncoder().encode(json).buffer; |
| 39 | const signature = base64.decode(bits[1]); |
| 40 | if (await crypto.subtle.verify('HMAC', bridgeKey, signature, bytes)) { |
| 41 | return JSON.parse(json); |
| 42 | } |
| 43 | } |
| 44 | } catch (ex) { |
| 45 | console.error('Failed to unpack signed object', ex); |
| 46 | } |
| 47 | |
| 48 | return null; |
| 49 | } |
| 50 | |
| 51 | /// Data passed in a hidden, signed field when submitting the authorisation form |
| 52 | interface SignInFormData { |
nothing calls this directly
no outgoing calls
no test coverage detected