Fix more build errors
This commit is contained in:
parent
1bdc1e60db
commit
30ce47826f
61 changed files with 1161 additions and 541 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { IncomingMessage } from "http";
|
||||
import { IncomingMessage } from "node:http";
|
||||
|
||||
function absoluteUrl(
|
||||
req?: IncomingMessage,
|
||||
|
|
|
|||
|
|
@ -36,5 +36,5 @@ export const apolloClient = new ApolloClient({
|
|||
fetchPolicy: "no-cache",
|
||||
errorPolicy: "all",
|
||||
},
|
||||
},*/
|
||||
}, */
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { promisify } from "util";
|
||||
import { promisify } from "node:util";
|
||||
import jwt from "jsonwebtoken";
|
||||
import jwksClient from "jwks-rsa";
|
||||
import * as Boom from "@hapi/boom";
|
||||
import * as Wreck from "@hapi/wreck";
|
||||
import Providers from "next-auth/providers";
|
||||
import Credentials from "next-auth/providers/credentials";
|
||||
import type { Adapter } from "next-auth/adapters";
|
||||
import type { IncomingMessage } from "http";
|
||||
import type { IncomingMessage } from "node:http";
|
||||
|
||||
const CF_JWT_HEADER_NAME = "cf-access-jwt-assertion";
|
||||
const CF_JWT_ALGOS = ["RS256"];
|
||||
|
|
@ -30,7 +30,7 @@ export const cfVerifier = (audience: string, domain: string): VerifyFn => {
|
|||
|
||||
return async (token) => {
|
||||
const getKey = (header: any, callback: any) => {
|
||||
client.getSigningKey(header.kid, function (err: any, key: any) {
|
||||
client.getSigningKey(header.kid, (err: any, key: any) => {
|
||||
if (err)
|
||||
throw Boom.serverUnavailable(
|
||||
"failed to fetch cloudflare access jwks"
|
||||
|
|
@ -201,8 +201,8 @@ export const CloudflareAccessProvider = (
|
|||
req: IncomingMessage
|
||||
) => {
|
||||
const verifier = cfVerifier(audience, domain);
|
||||
// @ts-expect-error
|
||||
return Providers.Credentials({
|
||||
|
||||
return Credentials({
|
||||
id: cloudflareAccountProvider,
|
||||
name: "Cloudflare Access",
|
||||
credentials: {},
|
||||
|
|
|
|||
|
|
@ -2,16 +2,14 @@ import pgDataProvider from "ra-postgraphile";
|
|||
import schema from "./graphql-schema.json";
|
||||
|
||||
export const metamigoDataProvider = async (client: any) => {
|
||||
const graphqlDataProvider = await pgDataProvider(
|
||||
const graphqlDataProvider: any = await pgDataProvider(
|
||||
client,
|
||||
// @ts-expect-error: Missing property
|
||||
{},
|
||||
{ introspection: { schema: schema.data.__schema } }
|
||||
);
|
||||
|
||||
const dataProvider = async (type: any, resource: any, params: any) => {
|
||||
return graphqlDataProvider(type, resource, params);
|
||||
};
|
||||
const dataProvider = async (type: any, resource: any, params: any) => graphqlDataProvider(type, resource, params);
|
||||
|
||||
return dataProvider;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export interface Session {
|
|||
|
||||
// from https://github.com/nextauthjs/next-auth/blob/main/src/lib/errors.js
|
||||
class UnknownError extends Error {
|
||||
constructor(message) {
|
||||
constructor(message: any) {
|
||||
super(message);
|
||||
this.name = "UnknownError";
|
||||
this.message = message;
|
||||
|
|
@ -48,14 +48,14 @@ class UnknownError extends Error {
|
|||
}
|
||||
|
||||
class CreateUserError extends UnknownError {
|
||||
constructor(message) {
|
||||
constructor(message: any) {
|
||||
super(message);
|
||||
this.name = "CreateUserError";
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
||||
const basicHeader = (secret) =>
|
||||
const basicHeader = (secret: any) =>
|
||||
"Basic " + Buffer.from(secret + ":", "utf8").toString("base64");
|
||||
|
||||
export const MetamigoAdapter = (config: IAppConfig): Adapter => {
|
||||
|
|
@ -155,7 +155,7 @@ export const MetamigoAdapter = (config: IAppConfig): Adapter => {
|
|||
await wreck.put("linkAccount", {
|
||||
payload,
|
||||
});
|
||||
} catch (error) {
|
||||
} catch {
|
||||
throw new Error("LINK_ACCOUNT_ERROR");
|
||||
}
|
||||
}
|
||||
|
|
@ -208,7 +208,7 @@ export const MetamigoAdapter = (config: IAppConfig): Adapter => {
|
|||
}
|
||||
}
|
||||
|
||||
return Promise.resolve({
|
||||
return {
|
||||
createUser,
|
||||
getUser,
|
||||
getUserByEmail,
|
||||
|
|
@ -222,7 +222,7 @@ export const MetamigoAdapter = (config: IAppConfig): Adapter => {
|
|||
updateSession,
|
||||
deleteSession,
|
||||
// @ts-expect-error: Type error
|
||||
} as AdapterInstance<Profile, User, Session, unknown>);
|
||||
} as AdapterInstance<Profile, User, Session, unknown>;
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -4,14 +4,12 @@ export const E164Regex = /^\+[1-9]\d{1,14}$/;
|
|||
/**
|
||||
* Returns true if the number is a valid E164 number
|
||||
*/
|
||||
export const isValidE164Number = (phoneNumber) => {
|
||||
return E164Regex.test(phoneNumber);
|
||||
};
|
||||
export const isValidE164Number = (phoneNumber: string) => E164Regex.test(phoneNumber);
|
||||
|
||||
/**
|
||||
* Given a phone number approximation, will clean out whitespace and punctuation.
|
||||
*/
|
||||
export const sanitizeE164Number = (phoneNumber) => {
|
||||
export const sanitizeE164Number = (phoneNumber: string) => {
|
||||
if (!phoneNumber) return "";
|
||||
if (!phoneNumber.trim()) return "";
|
||||
const sanitized = phoneNumber
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue