(auth?: EventOptions["auth"], authType?: AuthType)
| 152 | } |
| 153 | |
| 154 | constructAuth(auth?: EventOptions["auth"], authType?: AuthType): AuthMode { |
| 155 | if (auth?.admin || auth?.variable) { |
| 156 | return { |
| 157 | admin: auth.admin || false, |
| 158 | variable: auth.variable, |
| 159 | }; // User is providing the wire auth format already. |
| 160 | } |
| 161 | if (authType) { |
| 162 | switch (authType) { |
| 163 | case "USER": |
| 164 | return { |
| 165 | admin: false, |
| 166 | variable: { |
| 167 | uid: auth?.uid ?? "", |
| 168 | token: auth?.token ?? {}, |
| 169 | }, |
| 170 | }; |
| 171 | case "ADMIN": |
| 172 | if (auth?.uid || auth?.token) { |
| 173 | throw new Error("authType and auth are incompatible."); |
| 174 | } |
| 175 | return { admin: true }; |
| 176 | case "UNAUTHENTICATED": |
| 177 | if (auth?.uid || auth?.token) { |
| 178 | throw new Error("authType and auth are incompatible."); |
| 179 | } |
| 180 | return { admin: false }; |
| 181 | default: |
| 182 | throw new Error( |
| 183 | "Unrecognized authType, valid values are: " + "ADMIN, USER, and UNAUTHENTICATED", |
| 184 | ); |
| 185 | } |
| 186 | } |
| 187 | if (auth) { |
| 188 | return { |
| 189 | admin: false, |
| 190 | variable: { |
| 191 | uid: auth.uid ?? "", |
| 192 | token: auth.token || {}, |
| 193 | }, |
| 194 | }; |
| 195 | } |
| 196 | // Default to admin |
| 197 | return { admin: true }; |
| 198 | } |
| 199 | |
| 200 | makeFirestoreValue(input?: unknown) { |
| 201 | if ( |
no outgoing calls
no test coverage detected