tangled
alpha
login
or
join now
yoginth.com
/
hey
1
fork
atom
Hey is a decentralized and permissionless social media app built with Lens Protocol 🌿
1
fork
atom
overview
issues
pulls
pipelines
Remove use of identityToken
yoginth.com
10 months ago
7e7763fb
b693dba1
verified
This commit was signed with the committer's
known signature
.
yoginth.com
SSH Key Fingerprint:
SHA256:SLCGp+xtY+FtXnVKtpl4bpmTttAxnxJ3DBCeikAHlG4=
+43
-50
13 changed files
expand all
collapse all
unified
split
apps
api
src
context
authContext.ts
middlewares
cors.ts
web
src
components
Settings
Developer
Tokens.tsx
Shared
Account
SwitchAccounts.tsx
Auth
Login.tsx
Signup
Success.tsx
helpers
authLink.ts
fetcher.ts
store
persisted
useAuthStore.ts
packages
indexer
documents
mutations
auth
Authenticate.graphql
Refresh.graphql
SwitchAccount.graphql
generated.ts
+1
-1
apps/api/src/context/authContext.ts
···
2
2
import type { Context, Next } from "hono";
3
3
4
4
const authContext = async (ctx: Context, next: Next) => {
5
5
-
const token = ctx.req.raw.headers.get("x-id-token");
5
5
+
const token = ctx.req.raw.headers.get("X-Access-Token");
6
6
const payload = parseJwt(token as string);
7
7
8
8
if (!payload.act.sub) {
+1
-1
apps/api/src/middlewares/cors.ts
···
10
10
11
11
export const cors = corsMiddleware({
12
12
origin: allowedOrigins,
13
13
-
allowHeaders: ["Content-Type", "X-Id-Token"],
13
13
+
allowHeaders: ["Content-Type", "X-Access-Token"],
14
14
allowMethods: ["GET", "POST", "OPTIONS"],
15
15
credentials: true
16
16
});
+1
-15
apps/web/src/components/Settings/Developer/Tokens.tsx
···
11
11
import { useAccount, useSignMessage } from "wagmi";
12
12
13
13
const Tokens = () => {
14
14
-
const { accessToken, idToken, refreshToken } = hydrateAuthTokens();
14
14
+
const { accessToken, refreshToken } = hydrateAuthTokens();
15
15
const [builderToken, setBuilderToken] = useState<string | null>(null);
16
16
const [isSubmitting, setIsSubmitting] = useState(false);
17
17
···
94
94
type="button"
95
95
>
96
96
<H6>{refreshToken}</H6>
97
97
-
</button>
98
98
-
</div>
99
99
-
<div className="flex flex-col gap-y-3">
100
100
-
<b>Your temporary ID token</b>
101
101
-
<button
102
102
-
className="cursor-pointer break-all rounded-md bg-gray-300 p-2 px-3 text-left dark:bg-gray-600"
103
103
-
type="button"
104
104
-
onClick={() => {
105
105
-
trackEvent("copy_id_token");
106
106
-
toast.success("Copied to clipboard");
107
107
-
navigator.clipboard.writeText(idToken as string);
108
108
-
}}
109
109
-
>
110
110
-
<H6>{idToken}</H6>
111
97
</button>
112
98
</div>
113
99
<div className="flex flex-col gap-y-3">
+1
-2
apps/web/src/components/Shared/Account/SwitchAccounts.tsx
···
52
52
if (auth.data?.switchAccount.__typename === "AuthenticationTokens") {
53
53
const accessToken = auth.data?.switchAccount.accessToken;
54
54
const refreshToken = auth.data?.switchAccount.refreshToken;
55
55
-
const idToken = auth.data?.switchAccount.idToken;
56
55
signOut();
57
57
-
signIn({ accessToken, idToken, refreshToken });
56
56
+
signIn({ accessToken, refreshToken });
58
57
trackEvent("switch_account");
59
58
return location.reload();
60
59
}
+1
-2
apps/web/src/components/Shared/Auth/Login.tsx
···
110
110
if (auth.data?.authenticate.__typename === "AuthenticationTokens") {
111
111
const accessToken = auth.data?.authenticate.accessToken;
112
112
const refreshToken = auth.data?.authenticate.refreshToken;
113
113
-
const idToken = auth.data?.authenticate.idToken;
114
114
-
signIn({ accessToken, idToken, refreshToken });
113
113
+
signIn({ accessToken, refreshToken });
115
114
trackEvent("login");
116
115
return location.reload();
117
116
}
+1
-2
apps/web/src/components/Shared/Auth/Signup/Success.tsx
···
26
26
if (auth.data?.switchAccount.__typename === "AuthenticationTokens") {
27
27
const accessToken = auth.data?.switchAccount.accessToken;
28
28
const refreshToken = auth.data?.switchAccount.refreshToken;
29
29
-
const idToken = auth.data?.switchAccount.idToken;
30
30
-
signIn({ accessToken, idToken, refreshToken });
29
29
+
signIn({ accessToken, refreshToken });
31
30
return location.reload();
32
31
}
33
32
+2
-7
apps/web/src/helpers/authLink.ts
···
14
14
... on AuthenticationTokens {
15
15
accessToken
16
16
refreshToken
17
17
-
idToken
18
17
}
19
18
__typename
20
19
}
···
54
53
const { __typename } = refreshResult;
55
54
56
55
if (__typename === "AuthenticationTokens") {
57
57
-
const {
58
58
-
accessToken: newAccessToken,
59
59
-
refreshToken: newRefreshToken,
60
60
-
idToken: newIdToken
61
61
-
} = refreshResult;
56
56
+
const { accessToken: newAccessToken, refreshToken: newRefreshToken } =
57
57
+
refreshResult;
62
58
63
59
if (!newAccessToken || !newRefreshToken) {
64
60
throw new Error("Missing tokens in refresh response");
···
66
62
67
63
signIn({
68
64
accessToken: newAccessToken,
69
69
-
idToken: newIdToken,
70
65
refreshToken: newRefreshToken
71
66
});
72
67
+1
-1
apps/web/src/helpers/fetcher.ts
···
25
25
...options,
26
26
credentials: "include",
27
27
headers: {
28
28
-
...{ "x-id-token": hydrateAuthTokens().accessToken || "" },
28
28
+
...{ "X-Access-Token": hydrateAuthTokens().accessToken || "" },
29
29
...config.headers
30
30
}
31
31
});
+4
-9
apps/web/src/store/persisted/useAuthStore.ts
···
4
4
5
5
interface Tokens {
6
6
accessToken: null | string;
7
7
-
idToken: null | string;
8
7
refreshToken: null | string;
9
8
}
10
9
11
10
interface State {
12
11
accessToken: Tokens["accessToken"];
13
12
hydrateAuthTokens: () => Tokens;
14
14
-
idToken: Tokens["idToken"];
15
13
refreshToken: Tokens["refreshToken"];
16
14
signIn: (tokens: {
17
15
accessToken: string;
18
18
-
idToken: string;
19
16
refreshToken: string;
20
17
}) => void;
21
18
signOut: () => void;
···
26
23
(set, get) => ({
27
24
accessToken: null,
28
25
hydrateAuthTokens: () => {
29
29
-
const { accessToken, idToken, refreshToken } = get();
30
30
-
return { accessToken, idToken, refreshToken };
26
26
+
const { accessToken, refreshToken } = get();
27
27
+
return { accessToken, refreshToken };
31
28
},
32
32
-
idToken: null,
33
29
refreshToken: null,
34
34
-
signIn: ({ accessToken, idToken, refreshToken }) =>
35
35
-
set({ accessToken, idToken, refreshToken }),
30
30
+
signIn: ({ accessToken, refreshToken }) =>
31
31
+
set({ accessToken, refreshToken }),
36
32
signOut: async () => {
37
33
// Clear Localstorage
38
34
const allLocalstorageStores = Object.values(Localstorage).filter(
···
49
45
50
46
export const signIn = (tokens: {
51
47
accessToken: string;
52
52
-
idToken: string;
53
48
refreshToken: string;
54
49
}) => store.getState().signIn(tokens);
55
50
export const signOut = () => store.getState().signOut();
-1
packages/indexer/documents/mutations/auth/Authenticate.graphql
···
3
3
... on AuthenticationTokens {
4
4
accessToken
5
5
refreshToken
6
6
-
idToken
7
6
}
8
7
... on ForbiddenError {
9
8
reason
-1
packages/indexer/documents/mutations/auth/Refresh.graphql
···
3
3
... on AuthenticationTokens {
4
4
accessToken
5
5
refreshToken
6
6
-
idToken
7
6
}
8
7
... on ForbiddenError {
9
8
reason
-1
packages/indexer/documents/mutations/auth/SwitchAccount.graphql
···
3
3
... on AuthenticationTokens {
4
4
accessToken
5
5
refreshToken
6
6
-
idToken
7
6
}
8
7
}
9
8
}
+30
-7
packages/indexer/generated.ts
···
2684
2684
tags?: Maybe<Array<Scalars['Tag']['output']>>;
2685
2685
};
2686
2686
2687
2687
+
export type MlinternalAccountRecommendationsRequest = {
2688
2688
+
account?: InputMaybe<Scalars['EvmAddress']['input']>;
2689
2689
+
secret: Scalars['String']['input'];
2690
2690
+
};
2691
2691
+
2687
2692
export type MlinternalForYouRequest = {
2688
2693
account?: InputMaybe<Scalars['EvmAddress']['input']>;
2689
2694
secret: Scalars['String']['input'];
···
2736
2741
joinGroup: JoinGroupResult;
2737
2742
leaveGroup: LeaveGroupResult;
2738
2743
legacyRolloverRefresh: RefreshResult;
2744
2744
+
mlAccountRecommendationsInternal: Scalars['Void']['output'];
2739
2745
mlDismissRecommendedAccounts: Scalars['Void']['output'];
2740
2746
mlForYouInternal: Scalars['Void']['output'];
2741
2747
mute: Scalars['Void']['output'];
···
3020
3026
3021
3027
export type MutationLegacyRolloverRefreshArgs = {
3022
3028
request: RolloverRefreshRequest;
3029
3029
+
};
3030
3030
+
3031
3031
+
3032
3032
+
export type MutationMlAccountRecommendationsInternalArgs = {
3033
3033
+
request: MlinternalAccountRecommendationsRequest;
3023
3034
};
3024
3035
3025
3036
···
4298
4309
usernameNamespace?: InputMaybe<Scalars['EvmAddress']['input']>;
4299
4310
};
4300
4311
4312
4312
+
export enum PrimitiveMetadataSchema {
4313
4313
+
Account = 'ACCOUNT',
4314
4314
+
Action = 'ACTION',
4315
4315
+
App = 'APP',
4316
4316
+
Feed = 'FEED',
4317
4317
+
Graph = 'GRAPH',
4318
4318
+
Group = 'GROUP',
4319
4319
+
Rule = 'RULE',
4320
4320
+
Sponsorship = 'SPONSORSHIP',
4321
4321
+
Username = 'USERNAME'
4322
4322
+
}
4323
4323
+
4301
4324
export type Query = {
4302
4325
__typename?: 'Query';
4303
4326
_service: _Service;
···
6531
6554
featuredImage?: Maybe<Scalars['URI']['output']>;
6532
6555
image?: Maybe<Scalars['URI']['output']>;
6533
6556
name: Scalars['String']['output'];
6534
6534
-
schema: Scalars['String']['output'];
6557
6557
+
schema: PrimitiveMetadataSchema;
6535
6558
symbol?: Maybe<Scalars['String']['output']>;
6536
6559
};
6537
6560
···
7709
7732
}>;
7710
7733
7711
7734
7712
7712
-
export type AuthenticateMutation = { __typename?: 'Mutation', authenticate: { __typename?: 'AuthenticationTokens', accessToken: any, refreshToken: any, idToken: any } | { __typename?: 'ExpiredChallengeError' } | { __typename?: 'ForbiddenError', reason: string } | { __typename?: 'WrongSignerError' } };
7735
7735
+
export type AuthenticateMutation = { __typename?: 'Mutation', authenticate: { __typename?: 'AuthenticationTokens', accessToken: any, refreshToken: any } | { __typename?: 'ExpiredChallengeError' } | { __typename?: 'ForbiddenError', reason: string } | { __typename?: 'WrongSignerError' } };
7713
7736
7714
7737
export type ChallengeMutationVariables = Exact<{
7715
7738
request: ChallengeRequest;
···
7723
7746
}>;
7724
7747
7725
7748
7726
7726
-
export type RefreshMutation = { __typename?: 'Mutation', refresh: { __typename?: 'AuthenticationTokens', accessToken: any, refreshToken: any, idToken: any } | { __typename?: 'ForbiddenError', reason: string } };
7749
7749
+
export type RefreshMutation = { __typename?: 'Mutation', refresh: { __typename?: 'AuthenticationTokens', accessToken: any, refreshToken: any } | { __typename?: 'ForbiddenError', reason: string } };
7727
7750
7728
7751
export type SwitchAccountMutationVariables = Exact<{
7729
7752
request: SwitchAccountRequest;
7730
7753
}>;
7731
7754
7732
7755
7733
7733
-
export type SwitchAccountMutation = { __typename?: 'Mutation', switchAccount: { __typename?: 'AuthenticationTokens', accessToken: any, refreshToken: any, idToken: any } | { __typename?: 'ForbiddenError' } };
7756
7756
+
export type SwitchAccountMutation = { __typename?: 'Mutation', switchAccount: { __typename?: 'AuthenticationTokens', accessToken: any, refreshToken: any } | { __typename?: 'ForbiddenError' } };
7734
7757
7735
7758
export type CreateGroupMutationVariables = Exact<{
7736
7759
request: CreateGroupRequest;
···
8626
8649
return Apollo.useMutation<WrapTokensMutation, WrapTokensMutationVariables>(WrapTokensDocument, options);
8627
8650
}
8628
8651
export type WrapTokensMutationHookResult = ReturnType<typeof useWrapTokensMutation>;
8629
8629
-
export const AuthenticateDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"Authenticate"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"request"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"SignedAuthChallenge"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"authenticate"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"request"},"value":{"kind":"Variable","name":{"kind":"Name","value":"request"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"AuthenticationTokens"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accessToken"}},{"kind":"Field","name":{"kind":"Name","value":"refreshToken"}},{"kind":"Field","name":{"kind":"Name","value":"idToken"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ForbiddenError"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"reason"}}]}}]}}]}}]} as unknown as DocumentNode;
8652
8652
+
export const AuthenticateDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"Authenticate"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"request"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"SignedAuthChallenge"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"authenticate"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"request"},"value":{"kind":"Variable","name":{"kind":"Name","value":"request"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"AuthenticationTokens"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accessToken"}},{"kind":"Field","name":{"kind":"Name","value":"refreshToken"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ForbiddenError"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"reason"}}]}}]}}]}}]} as unknown as DocumentNode;
8630
8653
export function useAuthenticateMutation(baseOptions?: Apollo.MutationHookOptions<AuthenticateMutation, AuthenticateMutationVariables>) {
8631
8654
const options = {...defaultOptions, ...baseOptions}
8632
8655
return Apollo.useMutation<AuthenticateMutation, AuthenticateMutationVariables>(AuthenticateDocument, options);
···
8638
8661
return Apollo.useMutation<ChallengeMutation, ChallengeMutationVariables>(ChallengeDocument, options);
8639
8662
}
8640
8663
export type ChallengeMutationHookResult = ReturnType<typeof useChallengeMutation>;
8641
8641
-
export const RefreshDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"Refresh"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"request"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"RefreshRequest"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"refresh"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"request"},"value":{"kind":"Variable","name":{"kind":"Name","value":"request"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"AuthenticationTokens"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accessToken"}},{"kind":"Field","name":{"kind":"Name","value":"refreshToken"}},{"kind":"Field","name":{"kind":"Name","value":"idToken"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ForbiddenError"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"reason"}}]}}]}}]}}]} as unknown as DocumentNode;
8664
8664
+
export const RefreshDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"Refresh"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"request"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"RefreshRequest"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"refresh"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"request"},"value":{"kind":"Variable","name":{"kind":"Name","value":"request"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"AuthenticationTokens"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accessToken"}},{"kind":"Field","name":{"kind":"Name","value":"refreshToken"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ForbiddenError"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"reason"}}]}}]}}]}}]} as unknown as DocumentNode;
8642
8665
export function useRefreshMutation(baseOptions?: Apollo.MutationHookOptions<RefreshMutation, RefreshMutationVariables>) {
8643
8666
const options = {...defaultOptions, ...baseOptions}
8644
8667
return Apollo.useMutation<RefreshMutation, RefreshMutationVariables>(RefreshDocument, options);
8645
8668
}
8646
8669
export type RefreshMutationHookResult = ReturnType<typeof useRefreshMutation>;
8647
8647
-
export const SwitchAccountDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"SwitchAccount"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"request"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"SwitchAccountRequest"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"switchAccount"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"request"},"value":{"kind":"Variable","name":{"kind":"Name","value":"request"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"AuthenticationTokens"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accessToken"}},{"kind":"Field","name":{"kind":"Name","value":"refreshToken"}},{"kind":"Field","name":{"kind":"Name","value":"idToken"}}]}}]}}]}}]} as unknown as DocumentNode;
8670
8670
+
export const SwitchAccountDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"SwitchAccount"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"request"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"SwitchAccountRequest"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"switchAccount"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"request"},"value":{"kind":"Variable","name":{"kind":"Name","value":"request"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"AuthenticationTokens"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"accessToken"}},{"kind":"Field","name":{"kind":"Name","value":"refreshToken"}}]}}]}}]}}]} as unknown as DocumentNode;
8648
8671
export function useSwitchAccountMutation(baseOptions?: Apollo.MutationHookOptions<SwitchAccountMutation, SwitchAccountMutationVariables>) {
8649
8672
const options = {...defaultOptions, ...baseOptions}
8650
8673
return Apollo.useMutation<SwitchAccountMutation, SwitchAccountMutationVariables>(SwitchAccountDocument, options);