diff --git a/packages/client/auth-core/CHANGELOG.md b/packages/client/auth-core/CHANGELOG.md deleted file mode 100644 index 356bf9418..000000000 --- a/packages/client/auth-core/CHANGELOG.md +++ /dev/null @@ -1,143 +0,0 @@ -# @crossmint/client-sdk-auth-core - -## 1.5.0 - -### Minor Changes - -- 04dd600: Change to versioned controller - -## 1.4.1 - -### Patch Changes - -- 2c38b6c: Updates deprecation notice -- 127ccc6: Deprecated in favour of @crossmint/common-sdk-auth - -## 1.4.0 - -### Minor Changes - -- 5387811: Add the user profile - -## 1.3.0 - -### Minor Changes - -- eece432: Updates /refresh route - -## 1.2.0 - -### Minor Changes - -- 584cd20: Adds call to /refresh and handling decoding jwt client side - -### Patch Changes - -- @crossmint/client-sdk-base@1.2.8 - -## 1.1.7 - -### Patch Changes - -- Updated dependencies [08177a6] - - @crossmint/client-sdk-base@1.2.7 - -## 1.1.6 - -### Patch Changes - -- d8bf3d5: Added style to blur auth modal background -- 30f42da: @crossmint/client-sdk-auth-core: - - - Removed CrossmintAuthProvider and all React-related functionality - - @crossmint/client-sdk-react-ui: - - - Added CrossmintAuthProvider - - @crossmint/common-sdk-base: - - - Added helper function for API key validation - - Added helper function for getting base URL - - @crossmint/client-sdk-base: - - - Removed helper function for API key validation - - Removed helper function for getting base URL - -- 910403e: - **@crossmint/client-sdk-smart-wallet**: Fixed an issue where checking if running on the client was done too early, causing issues with Next.js. Moved the check to a function call instead. - - **@crossmint/client-sdk-react-ui**: Updated React version to ^18.3.0. - - **@crossmint/client-sdk-auth-core**: Updated React version to ^18.3.0. Fixed a hydration error when rendering the auth modal. -- Updated dependencies [30f42da] -- Updated dependencies [456daec] - - @crossmint/client-sdk-base@1.2.6 - -## 1.1.5 - -### Patch Changes - -- 3865983: Add `appearance` prop to improve UI customization: - - - `@crossmint/common-sdk-base`: Added two fields to `UIConfigColors`: inputBackground and buttonBackground - - `@crossmint/client-sdk-auth-core`: Implement `appearance` prop functionality - - `@crossmint/client-sdk-react-ui`: Integrate `appearance` prop for UI components - - This change allows for better customization of the UI across all packages that depend on these modules. - -- Updated dependencies [3865983] - - @crossmint/common-sdk-base@0.1.3 - -## 1.1.4 - -### Patch Changes - -- ab9f579: export method to grab jwt - -## 1.1.3 - -### Patch Changes - -- c63fafe: Added close icon button to auth modal - -## 1.1.2 - -### Patch Changes - -- Updated dependencies [2979be2] - - @crossmint/client-sdk-window@0.0.10 - -## 1.1.1 - -### Patch Changes - -- e9060b6: Consolidated exports and improved initial jwt state - -## 1.1.0 - -### Minor Changes - -- dc97a9a: Change query parameter - -## 1.0.2 - -### Patch Changes - -- Updated dependencies [11a9bb8] - - @crossmint/client-sdk-window@0.0.9 - -## 1.0.1 - -### Patch Changes - -- 82e429b: Make the package public - -## 1.0.0 - -### Major Changes - -- e892e09: Release the first version of the auth-core SDK - -### Patch Changes - -- Updated dependencies [dbca75f] - - @crossmint/client-sdk-window@0.0.8 diff --git a/packages/client/auth-core/README.md b/packages/client/auth-core/README.md deleted file mode 100644 index 3bf449232..000000000 --- a/packages/client/auth-core/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# @crossmint/client-sdk-auth-core - -DEPRECATED: This package is deprecated and has been replaced by @crossmint/common-sdk-auth, @crossmint/client-sdk-auth and @crossmint/server-sdk. \ No newline at end of file diff --git a/packages/client/auth-core/client/index.ts b/packages/client/auth-core/client/index.ts deleted file mode 100644 index 33bf82328..000000000 --- a/packages/client/auth-core/client/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from "../src/services"; -export * from "./types"; -export * from "./utils"; diff --git a/packages/client/auth-core/client/types/index.ts b/packages/client/auth-core/client/types/index.ts deleted file mode 100644 index 7616f9e53..000000000 --- a/packages/client/auth-core/client/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./user"; diff --git a/packages/client/auth-core/client/types/user.ts b/packages/client/auth-core/client/types/user.ts deleted file mode 100644 index 2f6b03de4..000000000 --- a/packages/client/auth-core/client/types/user.ts +++ /dev/null @@ -1,16 +0,0 @@ -export type FarcasterMetadata = { - fid: string; - username: string; - bio: string; - displayName: string; - pfpUrl: string; - custody: string; - verifications: string[]; -}; - -export type SDKExternalUser = { - id: string; - email?: string; - phoneNumber?: string; - farcaster?: FarcasterMetadata; -}; diff --git a/packages/client/auth-core/client/utils/index.ts b/packages/client/auth-core/client/utils/index.ts deleted file mode 100644 index 2d17df569..000000000 --- a/packages/client/auth-core/client/utils/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./jwt"; diff --git a/packages/client/auth-core/client/utils/jwt.ts b/packages/client/auth-core/client/utils/jwt.ts deleted file mode 100644 index 9f5755a22..000000000 --- a/packages/client/auth-core/client/utils/jwt.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { jwtDecode } from "jwt-decode"; - -export function getJWTExpiration(token: string) { - const decoded = jwtDecode(token); - return decoded.exp; -} diff --git a/packages/client/auth-core/package.json b/packages/client/auth-core/package.json deleted file mode 100644 index 5bdbd3914..000000000 --- a/packages/client/auth-core/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "@crossmint/client-sdk-auth-core", - "version": "1.5.0", - "repository": "https://github.com/Crossmint/crossmint-sdk", - "license": "Apache-2.0", - "author": "Paella Labs Inc", - "sideEffects": false, - "type": "module", - "main": "./dist/client/index.cjs", - "module": "./dist/client/index.js", - "types": "./dist/client/index.d.ts", - "exports": { - "./server": { - "import": "./dist/server/index.js", - "require": "./dist/server/index.cjs" - }, - "./client": { - "import": "./dist/client/index.js", - "require": "./dist/client/index.cjs" - }, - ".": { - "import": "./dist/client/index.js", - "require": "./dist/client/index.cjs" - } - }, - "files": ["dist", "src", "LICENSE"], - "scripts": { - "build": "tsup server/index.ts client/index.ts --clean --format esm,cjs --outDir ./dist --minify --dts --sourcemap", - "dev": "tsup server/index.ts client/index.ts --clean --format esm,cjs --outDir ./dist --dts --sourcemap --watch", - "test": "jest --passWithNoTests" - }, - "dependencies": { - "@crossmint/client-sdk-base": "workspace:*", - "jsonwebtoken": "9.0.2", - "jwks-rsa": "3.1.0", - "jwt-decode": "4.0.0" - }, - "devDependencies": { - "@types/jsonwebtoken": "9.0.6" - } -} diff --git a/packages/client/auth-core/server/index.ts b/packages/client/auth-core/server/index.ts deleted file mode 100644 index 178cd64f8..000000000 --- a/packages/client/auth-core/server/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./utils"; diff --git a/packages/client/auth-core/server/tsconfig.json b/packages/client/auth-core/server/tsconfig.json deleted file mode 100644 index f0b0081d7..000000000 --- a/packages/client/auth-core/server/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "target": "es5", - "lib": ["dom", "es6"], - "module": "commonjs" - } -} diff --git a/packages/client/auth-core/server/utils/index.ts b/packages/client/auth-core/server/utils/index.ts deleted file mode 100644 index 2d17df569..000000000 --- a/packages/client/auth-core/server/utils/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./jwt"; diff --git a/packages/client/auth-core/server/utils/jwt.ts b/packages/client/auth-core/server/utils/jwt.ts deleted file mode 100644 index cd71ec8ac..000000000 --- a/packages/client/auth-core/server/utils/jwt.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { CrossmintAuthService } from "@/services/CrossmintAuthService"; -import { JsonWebTokenError, TokenExpiredError, verify } from "jsonwebtoken"; - -import { getPublicKey } from "./tokenAuth/publicKey"; - -export async function verifyCrossmintSessionToken(apiKey: string, token: string) { - const crossmintService = new CrossmintAuthService(apiKey); - try { - return await verifyJWTWithPublicKey(crossmintService, token); - } catch (error) { - throw new Error("Invalid token"); - } -} - -function verifyJWT(signingKey: string, token: string) { - try { - const verifiedToken = verify(token, signingKey); - - if (verifiedToken == null || typeof verifiedToken === "string") { - throw new Error("Invalid token"); - } - return verifiedToken; - } catch (err: unknown) { - if (err != null && err instanceof TokenExpiredError) { - throw new Error(`JWT provided expired at timestamp ${err.expiredAt.toISOString()}`); - } - - if ( - err != null && - err instanceof JsonWebTokenError && - (err.message.includes("invalid signature") || err.message.includes("invalid algorithm")) - ) { - throw new Error(err.message); - } - - throw new Error("Invalid token"); - } -} - -async function verifyJWTWithPublicKey(crossmintService: CrossmintAuthService, token: string) { - const publicKey = await getPublicKey(token, crossmintService.getJWKSUri()); - - return verifyJWT(publicKey, token); -} diff --git a/packages/client/auth-core/server/utils/tokenAuth/publicKey.ts b/packages/client/auth-core/server/utils/tokenAuth/publicKey.ts deleted file mode 100644 index fe3eb46ce..000000000 --- a/packages/client/auth-core/server/utils/tokenAuth/publicKey.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { decode } from "jsonwebtoken"; -import { JwksClient } from "jwks-rsa"; - -export async function getPublicKey(token: string, jwksUri: string) { - const decoded = decode(token, { complete: true }); - if (decoded?.header == null) { - throw new Error("Invalid Token: Header Formatted Incorrectly"); - } - - const signingKey = await getSigningKey(jwksUri, decoded.header.kid); - const publicKey = signingKey.getPublicKey(); - - return publicKey; -} - -async function getSigningKey(jwksUri: string, kid?: string) { - const client = new JwksClient({ - jwksUri, - cache: true, - }); - - try { - const signingKey = await client.getSigningKey(kid); - return signingKey; - } catch (error) { - throw new Error("Unable to retrieve signing key"); - } -} diff --git a/packages/client/auth-core/src/index.ts b/packages/client/auth-core/src/index.ts deleted file mode 100644 index d4eedb57c..000000000 --- a/packages/client/auth-core/src/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./services"; -export * from "./utils"; diff --git a/packages/client/auth-core/src/services/CrossmintAuthService.ts b/packages/client/auth-core/src/services/CrossmintAuthService.ts deleted file mode 100644 index 887b8056e..000000000 --- a/packages/client/auth-core/src/services/CrossmintAuthService.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { APIErrorService, BaseCrossmintService } from "@crossmint/client-sdk-base"; - -import { authLogger } from "./logger"; -import { CROSSMINT_API_VERSION } from "../utils/constants"; -export class CrossmintAuthService extends BaseCrossmintService { - protected apiErrorService = new APIErrorService({}); - protected logger = authLogger; - - public getJWKSUri() { - return `${this.crossmintBaseUrl}/.well-known/jwks.json`; - } - - async refreshAuthMaterial(refreshToken: string) { - const result = await this.fetchCrossmintAPI( - `${CROSSMINT_API_VERSION}/session/sdk/auth/refresh`, - { method: "POST", body: JSON.stringify({ refresh: refreshToken }) }, - "Error fetching new refresh and access tokans." - ); - - return { - jwtToken: result.jwt, - refreshToken: result.refresh, - user: result.user, - }; - } - - async getUserFromClient(jwt: string) { - return await this.fetchCrossmintAPI( - `${CROSSMINT_API_VERSION}/sdk/auth/user`, - { method: "GET" }, - "Error fetching user.", - jwt - ); - } -} diff --git a/packages/client/auth-core/src/services/index.ts b/packages/client/auth-core/src/services/index.ts deleted file mode 100644 index 025e03dee..000000000 --- a/packages/client/auth-core/src/services/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./CrossmintAuthService"; -export * from "./logger"; diff --git a/packages/client/auth-core/src/services/logger.ts b/packages/client/auth-core/src/services/logger.ts deleted file mode 100644 index 03084098f..000000000 --- a/packages/client/auth-core/src/services/logger.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { SDKLogger } from "@crossmint/client-sdk-base"; - -import { AUTH_SERVICE } from "../utils/constants"; - -export const authLogger = new SDKLogger(AUTH_SERVICE); diff --git a/packages/client/auth-core/src/utils/constants.ts b/packages/client/auth-core/src/utils/constants.ts deleted file mode 100644 index 7e8452e86..000000000 --- a/packages/client/auth-core/src/utils/constants.ts +++ /dev/null @@ -1,2 +0,0 @@ -export const AUTH_SERVICE = "AUTH_SDK"; -export const CROSSMINT_API_VERSION = "2024-09-26"; diff --git a/packages/client/auth-core/tsconfig.json b/packages/client/auth-core/tsconfig.json deleted file mode 100644 index 60aec1747..000000000 --- a/packages/client/auth-core/tsconfig.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "extends": "../../../tsconfig.base.json", - "compilerOptions": { - "jsx": "react-jsx", - "rootDir": ".", - "baseUrl": ".", - "paths": { - "@/*": ["src/*"] - } - }, - "include": ["src/**/*", "client/**/*", "server/**/*"], - "exclude": ["__tests__"] -}