Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: clerk/t3-turbo-and-clerk
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0.5
Choose a base ref
...
head repository: clerk/t3-turbo-and-clerk
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.0.6
Choose a head ref
  • 5 commits
  • 8 files changed
  • 3 contributors

Commits on Jan 16, 2023

  1. Verified

    This commit was signed with the committer’s verified signature.
    xoxys Robert Kaussow
    Copy the full SHA
    a4ac391 View commit details
  2. Copy the full SHA
    e1060a4 View commit details
  3. Merge pull request #20 from t3dotgg/main

    Clean up mobile clerk integration, fix type errors
    perkinsjr authored Jan 16, 2023
    Copy the full SHA
    624f203 View commit details

Commits on Jan 17, 2023

  1. patch rn

    juliusmarminge committed Jan 17, 2023
    Copy the full SHA
    0faaf20 View commit details
  2. Merge pull request #21 from juliusmarminge/main

    fix: patch rn to make EAS build
    perkinsjr authored Jan 17, 2023
    Copy the full SHA
    e5c563f View commit details
Showing with 512 additions and 702 deletions.
  1. +4 −4 apps/expo/package.json
  2. +2 −4 apps/expo/src/_app.tsx
  3. +28 −28 apps/expo/src/components/SignInWithOAuth.tsx
  4. +17 −0 apps/expo/src/constants.ts
  5. +1 −1 apps/expo/src/utils/trpc.tsx
  6. +7 −1 package.json
  7. +50 −0 patches/react-native@0.70.5.patch
  8. +403 −664 pnpm-lock.yaml
8 changes: 4 additions & 4 deletions apps/expo/package.json
Original file line number Diff line number Diff line change
@@ -20,15 +20,15 @@
"@trpc/client": "^10.1.0",
"@trpc/react-query": "^10.1.0",
"@trpc/server": "^10.1.0",
"expo": "~47.0.6",
"expo": "~47.0.12",
"expo-auth-session": "^3.7.3",
"expo-random": "^13.0.0",
"expo-secure-store": "^12.0.0",
"expo-status-bar": "~1.4.2",
"nativewind": "^2.0.11",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.71.0-rc.0",
"react": "18.1.0",
"react-dom": "18.1.0",
"react-native": "0.70.5",
"react-native-safe-area-context": "4.4.1",
"react-native-web": "~0.18.10"
},
6 changes: 2 additions & 4 deletions apps/expo/src/_app.tsx
Original file line number Diff line number Diff line change
@@ -7,13 +7,11 @@ import { HomeScreen } from "./screens/home";
import { SignInSignUpScreen } from "./screens/signin";
import { ClerkProvider, SignedIn, SignedOut } from "@clerk/clerk-expo";
import { tokenCache } from "./utils/cache";

// Find this in your Dashboard.
const clerk_frontend_api = "YOUR_CLERK_FRONTEND_API";
import { CLERK_FRONTEND_API } from "./constants";

export const App = () => {
return (
<ClerkProvider frontendApi={clerk_frontend_api} tokenCache={tokenCache}>
<ClerkProvider frontendApi={CLERK_FRONTEND_API} tokenCache={tokenCache}>
<SignedIn>
<TRPCProvider>
<SafeAreaProvider>
56 changes: 28 additions & 28 deletions apps/expo/src/components/SignInWithOAuth.tsx
Original file line number Diff line number Diff line change
@@ -24,50 +24,50 @@ const SignInWithOAuth = () => {
firstFactorVerification: { externalVerificationRedirectURL },
} = signIn;

const result = await AuthSession.startAsync({
if (!externalVerificationRedirectURL)
throw "Something went wrong during the OAuth flow. Try again.";

const authResult = await AuthSession.startAsync({
authUrl: externalVerificationRedirectURL.toString(),
returnUrl: redirectUrl,
});

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const { type, params } = result || {};

if (type !== "success") {
if (authResult.type !== "success") {
throw "Something went wrong during the OAuth flow. Try again.";
}

// Get the rotatingTokenNonce from the redirect URL parameters
const { rotating_token_nonce: rotatingTokenNonce } = params;
const { rotating_token_nonce: rotatingTokenNonce } = authResult.params;

await signIn.reload({ rotatingTokenNonce });

const { createdSessionId } = signIn;

if (!createdSessionId) {
if (signIn.firstFactorVerification.status === "transferable") {
console.log("Didn't have an account transferring");

await signUp.create({ transfer: true });

const { rotating_token_nonce: rotatingTokenNonce } = params;

await signUp.reload({ rotatingTokenNonce });

const { createdSessionId } = signUp;
if (!createdSessionId) {
throw "Something went wrong during the Sign up OAuth flow. Please ensure that all sign up requirements are met.";
}
await setSession(createdSessionId);

return;
if (createdSessionId) {
// If we have a createdSessionId, then auth was successful
await setSession(createdSessionId);
} else {
// If we have no createdSessionId, then this is a first time sign-in, so
// we should process this as a signUp instead
// Throw if we're not in the right state for creating a new user
if (
!signUp ||
signIn.firstFactorVerification.status !== "transferable"
) {
throw "Something went wrong during the Sign up OAuth flow. Please ensure that all sign up requirements are met.";
}
throw "Something went wrong during the Sign in OAuth flow. Please ensure that all sign in requirements are met.";
}

await setSession(createdSessionId);
console.log(
"Didn't have an account transferring, following through with new account sign up",
);

return;
// Create user
await signUp.create({ transfer: true });
await signUp.reload({
rotatingTokenNonce: authResult.params.rotating_token_nonce,
});
await setSession(signUp.createdSessionId);
}
} catch (err) {
console.log(JSON.stringify(err, null, 2));
console.log("error signing in", err);
17 changes: 17 additions & 0 deletions apps/expo/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* URL key for the Clerk auth API. You can find this in your Clerk dashboard:
* https://dashboard.clerk.dev
*
* NOTE: we recommend putting the frontend api key here instead of in your .env
* files for two reasons:
* 1. It's okay for this to be "public" (CLERK_API_KEY and CLERK_JWT_KEY should
* NEVER be public)
* 2. Parsing the .env file in Metro/Expo runs the risk of including the
* variables above that we don't want (and it's obnoxious to do right as a
* result)
*/
export const CLERK_FRONTEND_API = "";

if (CLERK_FRONTEND_API === "") {
throw new Error("CLERK_FRONTEND_API is not defined");
}
2 changes: 1 addition & 1 deletion apps/expo/src/utils/trpc.tsx
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ export const TRPCProvider: React.FC<{
async headers() {
const authToken = await getToken();
return {
Authorization: authToken,
Authorization: authToken ?? undefined,
};
},
url: `${getBaseUrl()}/api/trpc`,
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -10,7 +10,8 @@
"db-push": "turbo db-push",
"dev": "turbo dev --parallel",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
"lint": "turbo lint && manypkg check",
"lint": "turbo lint",
"FIXME:lint": "turbo lint && manypkg check",
"type-check": "turbo type-check"
},
"dependencies": {
@@ -22,5 +23,10 @@
"prettier-plugin-tailwindcss": "^0.1.13",
"turbo": "^1.5.5",
"typescript": "^4.9.3"
},
"pnpm": {
"patchedDependencies": {
"react-native@0.70.5": "patches/react-native@0.70.5.patch"
}
}
}
50 changes: 50 additions & 0 deletions patches/react-native@0.70.5.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
diff --git a/scripts/react_native_pods_utils/script_phases.sh b/scripts/react_native_pods_utils/script_phases.sh
index 6c41ce1cbaa2b09d7b59b191b1edfb0c3fb41ea7..25bfcd11d6b88525d589c80ee08c9a8c8ba66d16 100755
--- a/scripts/react_native_pods_utils/script_phases.sh
+++ b/scripts/react_native_pods_utils/script_phases.sh
@@ -13,8 +13,6 @@ GENERATED_SCHEMA_FILE="$GENERATED_SRCS_DIR/schema.json"

cd "$RCT_SCRIPT_RN_DIR"

-CODEGEN_REPO_PATH="$RCT_SCRIPT_RN_DIR/packages/react-native-codegen"
-CODEGEN_NPM_PATH="$RCT_SCRIPT_RN_DIR/../react-native-codegen"
CODEGEN_CLI_PATH=""

error () {
@@ -23,14 +21,12 @@ error () {
exit 1
}

-# Determine path to react-native-codegen
-if [ -d "$CODEGEN_REPO_PATH" ]; then
- CODEGEN_CLI_PATH=$(cd "$CODEGEN_REPO_PATH" && pwd)
-elif [ -d "$CODEGEN_NPM_PATH" ]; then
- CODEGEN_CLI_PATH=$(cd "$CODEGEN_NPM_PATH" && pwd)
-else
- error "error: Could not determine react-native-codegen location in $CODEGEN_REPO_PATH or $CODEGEN_NPM_PATH. Try running 'yarn install' or 'npm install' in your project root."
-fi
+find_codegen () {
+ CODEGEN_CLI_PATH=$("$NODE_BINARY" --print "require('path').dirname(require.resolve('react-native-codegen/package.json'))")
+ if ! [ -d "$CODEGEN_CLI_PATH" ]; then
+ error "error: Could not determine react-native-codegen location, using node module resolution. Try running 'yarn install' or 'npm install' in your project root."
+ fi
+}

find_node () {
NODE_BINARY="${NODE_BINARY:-$(command -v node || true)}"
@@ -116,6 +112,7 @@ moveOutputs () {
withCodgenDiscovery () {
setup_dirs
find_node
+ find_codegen
generateArtifacts
moveOutputs
}
@@ -123,6 +120,7 @@ withCodgenDiscovery () {
noCodegenDiscovery () {
setup_dirs
find_node
+ find_codegen
generateCodegenSchemaFromJavaScript
generateCodegenArtifactsFromSchema
moveOutputs
Loading