Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions packages/fxa-auth-server/lib/redis.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class FxaRedis extends RedisShared {
this.log.error('redis', new Error('invalid ttl on access token'));
return;
}
this.metrics?.increment('redis.setAccessToken');
this.metrics?.increment?.('redis.setAccessToken');
const span = tracer.startSpan('redis.setAccessToken');
const value = JSON.stringify(token);
const result = await this.redis.setAccessToken(
Expand All @@ -62,7 +62,7 @@ class FxaRedis extends RedisShared {
* @returns {Promise<boolean>} done
*/
async removeAccessToken(id) {
this.metrics?.increment('redis.removeAccessToken');
this.metrics?.increment?.('redis.removeAccessToken');
const span = tracer.startSpan('redis.removeAccessToken');
// This does not remove the id from the user's index
// because getAccessTokens cleans up expired/missing tokens
Expand All @@ -76,7 +76,7 @@ class FxaRedis extends RedisShared {
* @param {Buffer | string} uid
*/
async removeAccessTokensForPublicClients(uid) {
this.metrics?.increment('redis.removeAccessTokensForPublicClients');
this.metrics?.increment?.('redis.removeAccessTokensForPublicClients');
const span = tracer.startSpan('redis.removeAccessTokensForPublicClients');
const result = await this.redis.removeAccessTokensForPublicClients(
hex(uid)
Expand All @@ -91,7 +91,7 @@ class FxaRedis extends RedisShared {
* @param {Buffer | string} clientId
*/
async removeAccessTokensForUserAndClient(uid, clientId) {
this.metrics?.increment('redis.removeAccessTokensForUserAndClient');
this.metrics?.increment?.('redis.removeAccessTokensForUserAndClient');
const span = tracer.startSpan('redis.removeAccessTokensForUserAndClient');
const result = await this.redis.removeAccessTokensForUserAndClient(
hex(uid),
Expand All @@ -106,7 +106,7 @@ class FxaRedis extends RedisShared {
* @param {Buffer | string} uid
*/
async removeAccessTokensForUser(uid) {
this.metrics?.increment('redis.removeAccessTokensForUser');
this.metrics?.increment?.('redis.removeAccessTokensForUser');
const span = tracer.startSpan('redis.removeAccessTokensForUser');
const result = await this.redis.removeAccessTokensForUser(hex(uid));
span.end();
Expand All @@ -119,7 +119,7 @@ class FxaRedis extends RedisShared {
* @param {RefreshTokenMetadata} token
*/
async setRefreshToken(uid, tokenId, token) {
this.metrics?.increment('redis.setRefreshToken');
this.metrics?.increment?.('redis.setRefreshToken');
const span = tracer.startSpan('redis.setRefreshToken');
const p1 = this.redis.setRefreshToken(
hex(uid),
Expand All @@ -140,7 +140,7 @@ class FxaRedis extends RedisShared {
* @param {Buffer | string} tokenId
*/
async removeRefreshToken(uid, tokenId) {
this.metrics?.increment('redis.removeRefreshToken');
this.metrics?.increment?.('redis.removeRefreshToken');
const span = await tracer.startSpan('redis.removeRefreshToken');
const p1 = this.redis.hdel(hex(uid), hex(tokenId));
const p2 = this.resolveInMs(p1, this.timeoutMs);
Expand All @@ -154,7 +154,7 @@ class FxaRedis extends RedisShared {
* @param {Buffer | string} uid
*/
async removeRefreshTokensForUser(uid) {
this.metrics?.increment('redis.removeRefreshTokensForUser');
this.metrics?.increment?.('redis.removeRefreshTokensForUser');
const span = tracer.startSpan('redis.removeRefreshTokensForUser');
const p1 = this.redis.unlink(hex(uid));
const p2 = this.resolveInMs(p1, this.timeoutMs);
Expand All @@ -164,13 +164,13 @@ class FxaRedis extends RedisShared {
}

async get(key) {
this.metrics?.increment('redis.get');
this.metrics?.increment?.('redis.get');
const span = tracer.startSpan('redis.get');
const result = await this.redis.get(key);

if (result?.length > 0) {
span.setAttribute('redis.get.size', result.length);
this.metrics?.histogram('redis.get.size', result.length);
this.metrics?.histogram?.('redis.get.size', result.length);
}
span.end();
return result;
Expand Down
7 changes: 3 additions & 4 deletions packages/fxa-settings/src/components/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ const ResetPasswordConfirmedContainer = lazy(
);
const ResetPasswordWithRecoveryKeyVerifiedContainer = lazy(
() =>
import(
'../../pages/ResetPassword/ResetPasswordWithRecoveryKeyVerified/container'
)
import('../../pages/ResetPassword/ResetPasswordWithRecoveryKeyVerified/container')
);
const CompleteSigninContainer = lazy(
() => import('../../pages/Signin/CompleteSignin/container')
Expand Down Expand Up @@ -228,7 +226,8 @@ export const App = ({
integration.data.context || '',
// TODO with React pairing flow, update this if pairing flow
false,
integration.data.service || ''
integration.data.service || '',
integration.data.userContextId
);
}

Expand Down
5 changes: 4 additions & 1 deletion packages/fxa-settings/src/lib/channels/firefox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type FxAStatusRequest = {
service: string; // ex. 'sync'
isPairing: boolean;
context: string; // ex. 'fx_desktop_v3'
userContextId?: string;
};

export type FxAStatusResponse = {
Expand Down Expand Up @@ -382,7 +383,8 @@ export class Firefox extends EventTarget {
async requestSignedInUser(
context: string,
isPairing: boolean,
service: string
service: string,
userContextId?: string
): Promise<undefined | SignedInUser> {
let timeoutId: number;
return Promise.race<undefined | SignedInUser>([
Expand All @@ -406,6 +408,7 @@ export class Firefox extends EventTarget {
context,
isPairing,
service,
userContextId,
});
});
}),
Expand Down
11 changes: 10 additions & 1 deletion packages/fxa-settings/src/models/integrations/data/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ import {
KeyTransforms as T,
ModelDataProvider,
} from '../../../lib/model-data';
import { IsEmailOrEmpty, IsFxaRedirectToUrl, IsFxaRedirectUri } from '../../../lib/validation';
import {
IsEmailOrEmpty,
IsFxaRedirectToUrl,
IsFxaRedirectUri,
} from '../../../lib/validation';

/**
* Base integration class. Fields in this class represents data commonly accessed across many pages and is useful for various flows.
Expand Down Expand Up @@ -115,6 +119,11 @@ export class IntegrationData extends ModelDataProvider {
@IsString()
@bind(T.snakeCase)
flowBeginTime: string | undefined;

@IsOptional()
@IsString()
@bind(T.snakeCase)
userContextId: string | undefined;
}

/**
Expand Down