Skip to content
Merged
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,5 @@ certificates
**/.sf/
**/.sfdx/

.nx/self-healing
.nx/self-healing
.react-email/
1 change: 1 addition & 0 deletions .nxignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
dist/
apps-sfdx/
apps/docs/
.react-email/
4 changes: 0 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ RUN pnpm build:core && \
# installed; the client was already generated above.
RUN pnpm add -w -P cross-env npm-run-all --no-frozen-lockfile --ignore-scripts

# FIXME: figure out why this is not included
# Add missing dependencies
RUN pnpm add -w @react-email/components --ignore-scripts

# Final stage for app image
FROM base

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ type MockRequest = {
get: (name: string) => string | undefined;
log: { info: ReturnType<typeof vi.fn>; warn: ReturnType<typeof vi.fn>; error: ReturnType<typeof vi.fn>; debug: ReturnType<typeof vi.fn> };
ip: string;
ipAddress: string;
};

function makeReq(overrides: Partial<MockRequest> = {}): MockRequest {
Expand All @@ -183,6 +184,7 @@ function makeReq(overrides: Partial<MockRequest> = {}): MockRequest {
get: vi.fn(() => undefined),
log: { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() },
ip: '127.0.0.1',
ipAddress: '127.0.0.1',
...overrides,
};
}
Expand Down Expand Up @@ -226,7 +228,6 @@ describe('auth.controller - placeholder session email suppression', () => {
} as never);
authServerMocks.generateRandomCode.mockReturnValue('123456');
authServerMocks.ensureAuthError.mockImplementation((error: unknown) => error);
authServerMocks.getApiAddressFromReq.mockReturnValue('127.0.0.1');
authServerMocks.validateRedirectUrl.mockImplementation((url: string) => url || 'https://client.test');
emailMocks.sendEmailVerification.mockResolvedValue(undefined);
emailMocks.sendVerificationCode.mockResolvedValue(undefined);
Expand Down Expand Up @@ -558,7 +559,6 @@ describe('auth.controller - SSO callback redirect resolution', () => {
} as never);
authServerMocks.ensureAuthError.mockImplementation((error: unknown) => error);
authServerMocks.validateRedirectUrl.mockImplementation((url: string) => url || 'https://client.test');
authServerMocks.getApiAddressFromReq.mockReturnValue('127.0.0.1');
authServerMocks.handleSsoLogin.mockResolvedValue({ id: 'sso-user-id', email: 'sso@example.com' } as never);
authServerMocks.getTeamLoginConfigWithSso.mockResolvedValue({
loginConfig: {
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ if (ENV.NODE_ENV === 'production' && !ENV.CI && cluster.isPrimary) {
const httpServer = initSocketServer(app, { sessionMiddleware });

if (environment.production) {
app.set('trust proxy', 1); // required for environments such as heroku / {render?}
app.set('trust proxy', 1); // required to resolve correct client ip and secure cookies when behind a proxy (like Render's load balancer)
}

app.use(addContextMiddleware);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ browser.commands.onCommand.addListener(async (command, tab) => {
* User is redirected and authenticated on the Jetstream server
* and tokens are sent back to the extension and stored in chrome storage
*/
browser.runtime.onMessageExternal.addListener(async (message, sender, sendResponse) => {
browser.runtime.onMessageExternal.addListener(async (message: unknown) => {
try {
logger.log('Received message from external extension', message);
const event = eventPayload.parse(message);
Expand All @@ -174,8 +174,7 @@ browser.runtime.onMessageExternal.addListener(async (message, sender, sendRespon
throw new Error('Could not get or initialize extension identifier');
}
logger.info('Extension identifier', result.extIdentifier.id);
sendResponse({ success: true, data: result.extIdentifier.id });
break;
return { success: true, data: result.extIdentifier.id };
}
case 'TOKENS': {
const { exp, userProfile } = jwtDecode<JwtPayload>(event.data.accessToken);
Expand All @@ -189,16 +188,15 @@ browser.runtime.onMessageExternal.addListener(async (message, sender, sendRespon
};
await browser.storage.sync.set({ [storageTypes.authTokens.key]: authState });
storageSyncCache.authTokens = authState;
sendResponse({ success: true });
break;
return { success: true };
}
default: {
sendResponse({ success: false, error: 'Unknown message type' });
return { success: false, error: 'Unknown message type' };
}
}
} catch (ex) {
logger.error('Error handling message', ex);
sendResponse({ success: false, error: 'Error handling message' });
return { success: false, error: 'Error handling message' };
}
});

Expand Down Expand Up @@ -229,7 +227,7 @@ browser.runtime.onMessage.addListener(
request: Message['request'],
sender: browser.Runtime.MessageSender,
sendResponse: (response: MessageResponse) => void,
): true | Promise<unknown> | undefined => {
): true => {
logger.log('[SW EVENT] onMessage', request);
switch (request.message) {
case 'EXT_IDENTIFIER': {
Expand All @@ -253,7 +251,7 @@ browser.runtime.onMessage.addListener(
case 'VERIFY_AUTH': {
if (storageSyncCache.authTokens?.accessToken && !doesAuthNeedToBeChecked(storageSyncCache.authTokens)) {
handleResponse({ hasTokens: true, loggedIn: true }, sendResponse);
return; // handle response synchronously
return true; // handle response synchronously
}
runVerifyAuth(sender)
.then((data) => {
Expand Down Expand Up @@ -290,7 +288,7 @@ browser.runtime.onMessage.addListener(
case 'GET_CURRENT_ORG': {
if ('uniqueId' in request.data) {
handleResponse(getConnection(request.data.uniqueId, sender), sendResponse);
return; // synchronous response
return true; // synchronous response
}
getConnectionFromHost(request.data.sfHost, sender)
.then((data) => handleResponse(data, sendResponse))
Expand All @@ -299,7 +297,8 @@ browser.runtime.onMessage.addListener(
}
default:
logger.warn(`Unknown message`, request);
return;
handleError(sendResponse)(new Error('Unknown message type'));
return true;
}
},
);
Expand Down
2 changes: 1 addition & 1 deletion libs/email/src/lib/components/EmailFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Link, Section, Text } from '@react-email/components';
import * as React from 'react';
import { Link, Section, Text } from 'react-email';
Comment thread
paustint marked this conversation as resolved.

export const EmailFooter = () => {
return (
Expand Down
2 changes: 1 addition & 1 deletion libs/email/src/lib/components/EmailLogo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Img } from '@react-email/components';
import * as React from 'react';
import { Img } from 'react-email';
Comment thread
paustint marked this conversation as resolved.
import { EMAIL_STYLES } from '../shared-styles';

export const EmailLogo = () => {
Expand Down
2 changes: 1 addition & 1 deletion libs/email/src/lib/components/EmailProLogo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Img } from '@react-email/components';
import * as React from 'react';
import { Img } from 'react-email';
Comment thread
paustint marked this conversation as resolved.
import { EMAIL_STYLES } from '../shared-styles';

export const EmailProLogo = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Body, Container, Head, Heading, Html, Preview, Section, Text } from '@react-email/components';
import * as React from 'react';
import { Body, Container, Head, Heading, Html, Preview, Section, Text } from 'react-email';
Comment thread
paustint marked this conversation as resolved.
import { EmailFooter } from '../../components/EmailFooter';
import { EmailLogo } from '../../components/EmailLogo';
import { EMAIL_STYLES } from '../../shared-styles';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Body, Container, Head, Heading, Html, Preview, Row, Section, Text } from '@react-email/components';
import * as React from 'react';
import { Body, Container, Head, Heading, Html, Preview, Row, Section, Text } from 'react-email';
Comment thread
paustint marked this conversation as resolved.
import { EmailFooter } from '../../components/EmailFooter';
import { EmailLogo } from '../../components/EmailLogo';
import { EMAIL_STYLES } from '../../shared-styles';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Body, Container, Head, Heading, Html, Section, Text } from '@react-email/components';
import * as React from 'react';
import { Body, Container, Head, Heading, Html, Section, Text } from 'react-email';
Comment thread
paustint marked this conversation as resolved.
import { EmailFooter } from '../../components/EmailFooter';
import { EmailLogo } from '../../components/EmailLogo';
import { EMAIL_STYLES } from '../../shared-styles';
Expand Down
2 changes: 1 addition & 1 deletion libs/email/src/lib/email-templates/auth/GenericEmail.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Body, Container, Head, Heading, Html, Preview, Section, Text } from '@react-email/components';
import * as React from 'react';
import { Body, Container, Head, Heading, Html, Preview, Section, Text } from 'react-email';
Comment thread
paustint marked this conversation as resolved.
import { EmailFooter } from '../../components/EmailFooter';
import { EmailLogo } from '../../components/EmailLogo';
import { EMAIL_STYLES } from '../../shared-styles';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Body, Container, Head, Heading, Html, Text } from '@react-email/components';
import * as React from 'react';
import { Body, Container, Head, Heading, Html, Text } from 'react-email';
Comment thread
paustint marked this conversation as resolved.
import { EmailFooter } from '../../components/EmailFooter';
import { EmailLogo } from '../../components/EmailLogo';
import { EMAIL_STYLES } from '../../shared-styles';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Body, Button, Container, Head, Heading, Html, Link, Section, Text } from '@react-email/components';
import * as React from 'react';
import { Body, Button, Container, Head, Heading, Html, Link, Section, Text } from 'react-email';
Comment thread
paustint marked this conversation as resolved.
import { EmailFooter } from '../../components/EmailFooter';
import { EmailLogo } from '../../components/EmailLogo';
import { EMAIL_STYLES } from '../../shared-styles';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Body, Button, Container, Head, Heading, Html, Section, Text } from '@react-email/components';
import * as React from 'react';
import { Body, Button, Container, Head, Heading, Html, Section, Text } from 'react-email';
Comment thread
paustint marked this conversation as resolved.
import { EmailFooter } from '../../components/EmailFooter';
import { EmailLogo } from '../../components/EmailLogo';
import { EMAIL_STYLES } from '../../shared-styles';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Body, Container, Head, Heading, Html, Link, Section, Text } from '@react-email/components';
import * as React from 'react';
import { Body, Container, Head, Heading, Html, Link, Section, Text } from 'react-email';
Comment thread
paustint marked this conversation as resolved.
import { EmailFooter } from '../../components/EmailFooter';
import { EmailLogo } from '../../components/EmailLogo';
import { EMAIL_STYLES } from '../../shared-styles';
Expand Down
2 changes: 1 addition & 1 deletion libs/email/src/lib/email-templates/auth/VerifyEmail.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { pluralizeFromNumber } from '@jetstream/shared/utils';
import { Body, Button, Container, Head, Heading, Html, Section, Text } from '@react-email/components';
import * as React from 'react';
import { Body, Button, Container, Head, Heading, Html, Section, Text } from 'react-email';
Comment thread
paustint marked this conversation as resolved.
import { EmailFooter } from '../../components/EmailFooter';
import { EmailLogo } from '../../components/EmailLogo';
import { EMAIL_STYLES } from '../../shared-styles';
Expand Down
2 changes: 1 addition & 1 deletion libs/email/src/lib/email-templates/auth/WelcomeEmail.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Body, Column, Container, Head, Heading, Hr, Html, Img, Link, Preview, Row, Section, Text } from '@react-email/components';
import * as React from 'react';
import { Body, Column, Container, Head, Heading, Hr, Html, Img, Link, Preview, Row, Section, Text } from 'react-email';
Comment thread
paustint marked this conversation as resolved.
import { EmailFooter } from '../../components/EmailFooter';
import { EmailLogo } from '../../components/EmailLogo';
import { EMAIL_STYLES } from '../../shared-styles';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Body, Container, Head, Heading, Hr, Html, Link, Preview, Row, Section, Text } from '@react-email/components';
import * as React from 'react';
import { Body, Container, Head, Heading, Hr, Html, Link, Preview, Row, Section, Text } from 'react-email';
Comment thread
paustint marked this conversation as resolved.
import { EmailFooter } from '../../components/EmailFooter';
import { EmailProLogo } from '../../components/EmailProLogo';
import { EMAIL_STYLES } from '../../shared-styles';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { pluralizeFromNumber } from '@jetstream/shared/utils';
import { Body, Button, Container, Head, Heading, Html, Preview, Section, Text } from '@react-email/components';
import * as React from 'react';
import { Body, Button, Container, Head, Heading, Html, Preview, Section, Text } from 'react-email';
Comment thread
paustint marked this conversation as resolved.
import { EmailFooter } from '../../components/EmailFooter';
import { EmailLogo } from '../../components/EmailLogo';
import { EMAIL_STYLES } from '../../shared-styles';
Expand Down
Loading
Loading