Skip to content

Commit

Permalink
feat: passing User Agent for backend to parse and save (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
aversini authored Aug 25, 2024
1 parent 810b292 commit 405fdaa
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions packages/auth-provider/src/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,16 @@ export const GRAPHQL_QUERIES = {
$authentication: AuthenticationOptionsInput!,
$nonce: String!,
$domain: String,
$sessionExpiration: String) {
$sessionExpiration: String,
$ua: String) {
verifyPasskeyAuthentication(
clientId: $clientId,
id: $id,
authentication: $authentication,
nonce: $nonce,
domain: $domain,
sessionExpiration: $sessionExpiration) {
sessionExpiration: $sessionExpiration,
ua: $ua) {
status,
idToken,
accessToken,
Expand Down
3 changes: 1 addition & 2 deletions packages/auth-provider/src/common/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export const graphQLCall = async ({
params = {},
}: GraphQLCallProps): Promise<GraphQLCallResponse> => {
try {
const requestData = params;
const authorization = `Bearer ${accessToken}`;
const response = await fetch(
isDev ? `${API_ENDPOINT.dev}/graphql` : `${API_ENDPOINT.prod}/graphql`,
Expand All @@ -69,7 +68,7 @@ export const graphQLCall = async ({
},
body: JSON.stringify({
query: type.schema,
variables: requestData,
variables: params,
}),
},
);
Expand Down
1 change: 1 addition & 0 deletions packages/auth-provider/src/common/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export type AuthenticateUserProps = {
code?: string;
code_verifier?: string;
domain: string;
ua: string;
};

export type AuthenticateUserResponse =
Expand Down
2 changes: 2 additions & 0 deletions packages/auth-provider/src/common/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export const loginUser = async ({
code,
code_verifier,
domain,
ua,
}: AuthenticateUserProps): Promise<AuthenticateUserResponse> => {
try {
const response = await restCall({
Expand All @@ -129,6 +130,7 @@ export const loginUser = async ({
code,
code_verifier,
domain,
ua,
},
});
const jwt = await verifyAndExtractToken(response?.data?.idToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ export const AuthProvider = ({
code: preResponse.data,
code_verifier,
domain,
ua: navigator.userAgent,
});
if (response.status) {
setIdToken(response.idToken);
Expand Down Expand Up @@ -428,6 +429,7 @@ export const AuthProvider = ({
nonce: _nonce,
domain,
sessionExpiration,
ua: navigator.userAgent,
},
});

Expand Down

0 comments on commit 405fdaa

Please sign in to comment.