Skip to content

Commit

Permalink
renaming suffix of export to Pubkey
Browse files Browse the repository at this point in the history
  • Loading branch information
jowo-io committed Oct 19, 2024
1 parent c47b8da commit ab85b37
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 41 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ This API will handle all of the Lightning auth API requests, such as generating
```typescript
// @/pages/api/pubkey/[...pubkey].ts

import NextAuthLightning, { NextAuthLightningConfig } from "next-auth-pubkey";
import NextAuthPubkey, { NextAuthPubkeyConfig } from "next-auth-pubkey";
import generateQr from "next-auth-pubkey/generators/qr";

const config: NextAuthLightningConfig = {
const config: NextAuthPubkeyConfig = {
baseUrl: process.env.NEXTAUTH_URL,
secret: process.env.NEXTAUTH_SECRET,
storage: {
Expand All @@ -94,7 +94,7 @@ const config: NextAuthLightningConfig = {
generateQr,
};

const { lightningProvider, nostrProvider, handler } = NextAuthLightning(config);
const { lightningProvider, nostrProvider, handler } = NextAuthPubkey(config);

export { lightningProvider, nostrProvider };

Expand Down Expand Up @@ -145,7 +145,7 @@ There are various configurations available to you. Some are required, some are o
###

```typescript
const config: NextAuthLightningConfig = {
const config: NextAuthPubkeyConfig = {
/**
* @param {string} baseUrl
*
Expand Down Expand Up @@ -500,7 +500,7 @@ Data can be stored in a medium of your choice. For example: a database, a docume
```typescript
import { kv } from "@vercel/kv";

const config: NextAuthLightningConfig = {
const config: NextAuthPubkeyConfig = {
// ...
storage: {
async set({ k1, session }) {
Expand Down
7 changes: 3 additions & 4 deletions examples/app-router/utils/nextauth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AuthOptions } from "next-auth";

import NextAuthLightning, { NextAuthLightningConfig } from "next-auth-pubkey";
import NextAuthPubkey, { NextAuthPubkeyConfig } from "next-auth-pubkey";
import generateQr from "next-auth-pubkey/generators/qr";

import { env } from "@/env.mjs";
Expand All @@ -9,7 +9,7 @@ import storage from "node-persist"; // ⚠️ WARNING using node-persist is not

await storage.init();

const config: NextAuthLightningConfig = {
const config: NextAuthPubkeyConfig = {
// required
baseUrl: env.NEXTAUTH_URL,
secret: env.NEXTAUTH_SECRET,
Expand All @@ -32,8 +32,7 @@ const config: NextAuthLightningConfig = {
generateQr,
};

const { lightningProvider, nostrProvider, GET, POST } =
NextAuthLightning(config);
const { lightningProvider, nostrProvider, GET, POST } = NextAuthPubkey(config);

export const authOptions: AuthOptions = {
providers: [lightningProvider, nostrProvider],
Expand Down
6 changes: 3 additions & 3 deletions examples/drizzle/pages/api/pubkey/[...pubkey].ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import NextAuthLightning, { NextAuthLightningConfig } from "next-auth-pubkey";
import NextAuthPubkey, { NextAuthPubkeyConfig } from "next-auth-pubkey";
import generateQr from "next-auth-pubkey/generators/qr";

import { eq } from "drizzle-orm";
Expand All @@ -7,7 +7,7 @@ import { pubkeyTable, PubKey } from "@/schema/db";
import db from "@/utils/db";
import { env } from "@/env.mjs";

const config: NextAuthLightningConfig = {
const config: NextAuthPubkeyConfig = {
// required
baseUrl: env.NEXTAUTH_URL,
secret: env.NEXTAUTH_SECRET,
Expand Down Expand Up @@ -37,7 +37,7 @@ const config: NextAuthLightningConfig = {
generateQr,
};

const { lightningProvider, nostrProvider, handler } = NextAuthLightning(config);
const { lightningProvider, nostrProvider, handler } = NextAuthPubkey(config);

export { lightningProvider, nostrProvider };

Expand Down
6 changes: 3 additions & 3 deletions examples/kv/pages/api/pubkey/[...pubkey].ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import NextAuthLightning, { NextAuthLightningConfig } from "next-auth-pubkey";
import NextAuthPubkey, { NextAuthPubkeyConfig } from "next-auth-pubkey";
import generateQr from "next-auth-pubkey/generators/qr";

import { kv } from "@vercel/kv";

import { env } from "@/env.mjs";

const config: NextAuthLightningConfig = {
const config: NextAuthPubkeyConfig = {
// required
baseUrl: env.NEXTAUTH_URL,
secret: env.NEXTAUTH_SECRET,
Expand All @@ -28,7 +28,7 @@ const config: NextAuthLightningConfig = {
generateQr,
};

const { lightningProvider, nostrProvider, handler } = NextAuthLightning(config);
const { lightningProvider, nostrProvider, handler } = NextAuthPubkey(config);

export { lightningProvider, nostrProvider };

Expand Down
4 changes: 2 additions & 2 deletions examples/plain-js/pages/api/pubkey/[...pubkey].js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import NextAuthLightning from "next-auth-pubkey";
import NextAuthPubkey from "next-auth-pubkey";
import generateQr from "next-auth-pubkey/generators/qr";

import storage from "node-persist"; // ⚠️ WARNING using node-persist is not recommended in lambda or edge environments.
Expand Down Expand Up @@ -28,7 +28,7 @@ const config = {
generateQr,
};

const { lightningProvider, nostrProvider, handler } = NextAuthLightning(config);
const { lightningProvider, nostrProvider, handler } = NextAuthPubkey(config);

export { lightningProvider, nostrProvider };

Expand Down
4 changes: 2 additions & 2 deletions examples/ui-app-router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ export default async function SignIn({
"use client";

import { useLightningPolling } from "next-auth-pubkey/hooks";
import { NextAuthLightningClientSession } from "next-auth-pubkey/server";
import { NextAuthPubkeyClientSession } from "next-auth-pubkey/server";

export default function LightningAuth({
session,
}: {
session: NextAuthLightningClientSession;
session: NextAuthPubkeyClientSession;
}) {
const { lnurl, qr, button } = useLightningPolling(session);

Expand Down
4 changes: 2 additions & 2 deletions examples/ui-app-router/app/components/LightningAuth.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"use client";

import { useLightningPolling } from "next-auth-pubkey/hooks";
import { NextAuthLightningClientSession } from "next-auth-pubkey/server";
import { NextAuthPubkeyClientSession } from "next-auth-pubkey/server";

export default function LightningAuth({
session,
}: {
session: NextAuthLightningClientSession;
session: NextAuthPubkeyClientSession;
}) {
const { lnurl, qr, button } = useLightningPolling(session);

Expand Down
7 changes: 3 additions & 4 deletions examples/ui-app-router/utils/nextauth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AuthOptions } from "next-auth";

import NextAuthLightning, { NextAuthLightningConfig } from "next-auth-pubkey";
import NextAuthPubkey, { NextAuthPubkeyConfig } from "next-auth-pubkey";
import generateQr from "next-auth-pubkey/generators/qr";

import { env } from "@/env.mjs";
Expand All @@ -9,7 +9,7 @@ import storage from "node-persist"; // ⚠️ WARNING using node-persist is not

await storage.init();

const config: NextAuthLightningConfig = {
const config: NextAuthPubkeyConfig = {
// required
baseUrl: env.NEXTAUTH_URL,
secret: env.NEXTAUTH_SECRET,
Expand Down Expand Up @@ -43,8 +43,7 @@ const config: NextAuthLightningConfig = {
},
};

const { lightningProvider, nostrProvider, GET, POST } =
NextAuthLightning(config);
const { lightningProvider, nostrProvider, GET, POST } = NextAuthPubkey(config);

export const authOptions: AuthOptions = {
providers: [lightningProvider, nostrProvider],
Expand Down
6 changes: 3 additions & 3 deletions examples/ui-pages-router/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default function SignIn() {
```tsx
import { GetServerSidePropsContext } from "next";
import {
NextAuthLightningClientSession,
NextAuthPubkeyClientSession,
createLightningAuth,
} from "next-auth-pubkey/server";
import { useLightningPolling } from "next-auth-pubkey/hooks";
Expand All @@ -71,7 +71,7 @@ export const getServerSideProps = async (
};
};

function SignIn({ session }: { session: NextAuthLightningClientSession }) {
function SignIn({ session }: { session: NextAuthPubkeyClientSession }) {
const { lnurl, qr, button } = useLightningPolling(session);

return (
Expand All @@ -92,7 +92,7 @@ export default function SignInPage({
s: session,
e: error,
}: {
s: NextAuthLightningClientSession | null;
s: NextAuthPubkeyClientSession | null;
e: string | null;
}) {
if (error || !session) {
Expand Down
6 changes: 3 additions & 3 deletions examples/ui-pages-router/pages/api/pubkey/[...pubkey].ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import NextAuthLightning, { NextAuthLightningConfig } from "next-auth-pubkey";
import NextAuthPubkey, { NextAuthPubkeyConfig } from "next-auth-pubkey";
import generateQr from "next-auth-pubkey/generators/qr";

import { env } from "@/env.mjs";
Expand All @@ -7,7 +7,7 @@ import storage from "node-persist"; // ⚠️ WARNING using node-persist is not

await storage.init();

const config: NextAuthLightningConfig = {
const config: NextAuthPubkeyConfig = {
// required
baseUrl: env.NEXTAUTH_URL,
secret: env.NEXTAUTH_SECRET,
Expand Down Expand Up @@ -37,7 +37,7 @@ const config: NextAuthLightningConfig = {
},
};

const { lightningProvider, nostrProvider, handler } = NextAuthLightning(config);
const { lightningProvider, nostrProvider, handler } = NextAuthPubkey(config);

export { lightningProvider, nostrProvider };

Expand Down
6 changes: 3 additions & 3 deletions examples/ui-pages-router/pages/lightning-signin-ssr.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { GetServerSidePropsContext } from "next";
import {
NextAuthLightningClientSession,
NextAuthPubkeyClientSession,
createLightningAuth,
} from "next-auth-pubkey/server";
import { useLightningPolling } from "next-auth-pubkey/hooks";
Expand All @@ -23,7 +23,7 @@ export const getServerSideProps = async (
};
};

function SignIn({ session }: { session: NextAuthLightningClientSession }) {
function SignIn({ session }: { session: NextAuthPubkeyClientSession }) {
const { lnurl, qr, button } = useLightningPolling(session);

return (
Expand Down Expand Up @@ -101,7 +101,7 @@ export default function SignInPage({
s: session,
e: error,
}: {
s: NextAuthLightningClientSession | null;
s: NextAuthPubkeyClientSession | null;
e: string | null;
}) {
if (error || !session) {
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useLightningPolling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useEffect } from "react";
import { useRouter } from "next/navigation";

import { hardConfig } from "../main/config/hard";
import { NextAuthLightningClientSession } from "../server";
import { NextAuthPubkeyClientSession } from "../server";
import { formatLightningAuth } from "../utils/lnurl";
import { maxNetworkRequestsFailures } from "./constants";

Expand All @@ -22,7 +22,7 @@ import { maxNetworkRequestsFailures } from "./constants";
* @returns {String} qr - a url pointing the lnurl-auth QR Code image, should be used in the src prop of img tags
* @returns {String} button - a deep-link that will open in Lightning enabled wallets, should be used in the href prop of anchor tags
*/
export function useLightningPolling(session: NextAuthLightningClientSession): {
export function useLightningPolling(session: NextAuthPubkeyClientSession): {
lnurl: string | null;
qr: string;
button: string;
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export type {
StorageSession as NextAuthLightningStorageSession,
UserConfig as NextAuthLightningConfig,
StorageSession as NextAuthPubkeyStorageSession,
UserConfig as NextAuthPubkeyConfig,
} from "./main/config/types";
export type { NextAuthLightningClientSession } from "./server/index";
export type { NextAuthPubkeyClientSession } from "./server/index";

export { default } from "./main/index";
export { HandlerErrorCodes as ErrorCodes } from "./main/utils/handlers";
2 changes: 1 addition & 1 deletion src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export interface PubKeyAuthProfile
* @returns {String} provider - a provider that can be added to the `next-auth` config's providerArray
* @returns {String} handler - an API handler to be exported in the pages/api/pubkey/[...pubkey] folder
*/
export default function NextAuthLightning(userConfig: UserConfig) {
export default function NextAuthPubkey(userConfig: UserConfig) {
const config = formatConfig(userConfig);

const lightningProvider: OAuthConfig<PubKeyAuthProfile> = {
Expand Down
2 changes: 1 addition & 1 deletion src/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type {
LightningClientSession as NextAuthLightningClientSession,
LightningClientSession as NextAuthPubkeyClientSession,
NostrClientSession as NextAuthNostrClientSession,
} from "./types";

Expand Down

0 comments on commit ab85b37

Please sign in to comment.