Skip to content

Commit

Permalink
Update package-lock.json
Browse files Browse the repository at this point in the history
  • Loading branch information
dangtony98 committed Apr 17, 2023
2 parents df83e8c + 8f08c49 commit 338d287
Show file tree
Hide file tree
Showing 22 changed files with 1,904 additions and 873 deletions.
10 changes: 5 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ MONGO_PASSWORD=example
SITE_URL=http://localhost:8080

# Mail/SMTP
SMTP_HOST= # required
SMTP_USERNAME= # required
SMTP_PASSWORD= # required
SMTP_HOST=
SMTP_USERNAME=
SMTP_PASSWORD=
SMTP_PORT=587
SMTP_SECURE=false
SMTP_FROM_ADDRESS= # required
SMTP_FROM_ADDRESS=
SMTP_FROM_NAME=Infisical

# Integration
Expand Down Expand Up @@ -66,4 +66,4 @@ STRIPE_WEBHOOK_SECRET=
STRIPE_PRODUCT_STARTER=
STRIPE_PRODUCT_TEAM=
STRIPE_PRODUCT_PRO=
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=
12 changes: 8 additions & 4 deletions README.md

Large diffs are not rendered by default.

2,069 changes: 1,320 additions & 749 deletions backend/package-lock.json

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"dependencies": {
"@aws-sdk/client-secrets-manager": "^3.287.0",
"@aws-sdk/client-secrets-manager": "^3.294.0",
"@godaddy/terminus": "^4.11.2",
"@octokit/rest": "^19.0.5",
"@sentry/tracing": "^7.41.0",
"@sentry/node": "^7.40.0",
"@sentry/tracing": "^7.39.0",
"@sentry/node": "^7.41.0",
"@types/crypto-js": "^4.1.1",
"@types/libsodium-wrappers": "^0.7.10",
"argon2": "^0.30.3",
"await-to-js": "^3.0.0",
"aws-sdk": "^2.1331.0",
"aws-sdk": "^2.1338.0",
"axios": "^1.1.3",
"axios-retry": "^3.4.0",
"bcrypt": "^5.1.0",
Expand All @@ -32,7 +33,7 @@
"lodash": "^4.17.21",
"mongoose": "^6.10.3",
"nodemailer": "^6.8.0",
"posthog-node": "^2.5.4",
"posthog-node": "^2.6.0",
"query-string": "^7.1.3",
"request-ip": "^3.3.0",
"rimraf": "^3.0.2",
Expand Down
7 changes: 5 additions & 2 deletions backend/src/controllers/v2/serviceTokenDataController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ export const createServiceTokenData = async (req: Request, res: Response) => {
const secret = crypto.randomBytes(16).toString('hex');
const secretHash = await bcrypt.hash(secret, getSaltRounds());

const expiresAt = new Date();
expiresAt.setSeconds(expiresAt.getSeconds() + expiresIn);
let expiresAt;
if (expiresIn) {
expiresAt = new Date()
expiresAt.setSeconds(expiresAt.getSeconds() + expiresIn);
}

let user, serviceAccount;

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/analytics/posthog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ENV, POSTHOG_API_KEY, POSTHOG_HOST } from '../utilities/config';

export const initPostHog = () => {
// @ts-ignore
console.log("Init Infisical")
console.log("Hi there 👋")
try {
if (typeof window !== 'undefined') {
// @ts-ignore
Expand Down
16 changes: 3 additions & 13 deletions frontend/src/components/dashboard/DeleteActionButton.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React, { useState } from 'react'
import React from 'react'
import { useTranslation } from 'react-i18next';
import { faXmark } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

import Button from '../basic/buttons/Button';
import { DeleteEnvVar } from '../basic/dialog/DeleteEnvVar';

type Props = {
onSubmit: () => void;
Expand All @@ -13,7 +12,6 @@ type Props = {

export const DeleteActionButton = ({ onSubmit, isPlain }: Props) => {
const { t } = useTranslation();
const [open, setOpen] = useState(false)

return (
<div className={`${
Expand All @@ -25,25 +23,17 @@ export const DeleteActionButton = ({ onSubmit, isPlain }: Props) => {
onKeyDown={() => null}
role="button"
tabIndex={0}
onClick={() => setOpen(true)}
onClick={onSubmit}
className="invisible group-hover:visible"
>
<FontAwesomeIcon className="text-bunker-300 hover:text-red pl-2 pr-6 text-lg mt-0.5" icon={faXmark} />
</div>
: <Button
text={String(t("Delete"))}
// onButtonPressed={onSubmit}
color="red"
size="md"
onButtonPressed={() => setOpen(true)}
onButtonPressed={onSubmit}
/>}
<DeleteEnvVar
isOpen={open}
onClose={() => {
setOpen(false)
}}
onSubmit={onSubmit}
/>
</div>
)
}
59 changes: 48 additions & 11 deletions frontend/src/components/navigation/NavHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,52 +1,89 @@
import { useRouter } from 'next/router';
import { faAngleRight } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

import { useOrganization, useWorkspace } from '@app/context';

import { Select, SelectItem, Tooltip } from '../v2';

// TODO: make links clickable and clean up

/**
* This is the component at the top of almost every page.
* It shows how to navigate to a certain page.
* It future these links should also be clickable and hoverable
* @param obj
* @param obj.pageName - Name of the page
* @param obj.isProjectRelated - whether or not this page is related to project (determine if it's 2 or 3 navigation steps)
* @param obj.isOrganizationRelated - whether or not this page is related to organization (determine if it's 2 or 3 navigation steps)
* @param {object} obj
* @param {string} obj.pageName - Name of the page
* @param {boolean} obj.isProjectRelated - whether or not this page is related to project (determine if it's 2 or 3 navigation steps)
* @param {boolean} obj.isOrganizationRelated - whether or not this page is related to organization (determine if it's 2 or 3 navigation steps)
* @param {string} obj.currentEnv - current environment inside a project
* @param {string} obj.userAvailableEnvs - environments that are available to a user in this project (used for the dropdown)
* @param {string} obj.onEnvChange - the action that happens when an env is changed
* @returns
*/
export default function NavHeader({
pageName,
isProjectRelated,
isOrganizationRelated
isOrganizationRelated,
currentEnv,
userAvailableEnvs,
onEnvChange
}: {
pageName: string;
isProjectRelated?: boolean;
isOrganizationRelated?: boolean;
currentEnv?: string;
userAvailableEnvs?: any[];
onEnvChange?: (slug: string) => void;
}): JSX.Element {
const { currentWorkspace } = useWorkspace();
const { currentOrg } = useOrganization();
const router = useRouter()

return (
<div className="ml-6 flex flex-row items-center pt-8">
<div className="mr-2 flex h-6 w-6 items-center justify-center rounded-md bg-primary-900 text-mineshaft-100">
{currentOrg?.name?.charAt(0)}
</div>
<div className="text-sm font-semibold text-primary">{currentOrg?.name}</div>
<div className="text-sm font-semibold text-bunker-300">{currentOrg?.name}</div>
{isProjectRelated && (
<>
<FontAwesomeIcon icon={faAngleRight} className="ml-3 mr-3 text-sm text-gray-400" />
<div className="text-sm font-semibold text-primary">{currentWorkspace?.name}</div>
<FontAwesomeIcon icon={faAngleRight} className="ml-3 mr-3 text-xs text-gray-400" />
<div className="text-sm font-semibold text-bunker-300">{currentWorkspace?.name}</div>
</>
)}
{isOrganizationRelated && (
<>
<FontAwesomeIcon icon={faAngleRight} className="ml-3 mr-3 text-sm text-gray-400" />
<div className="text-sm font-semibold text-primary">Organization Settings</div>
<FontAwesomeIcon icon={faAngleRight} className="ml-3 mr-3 text-xs text-gray-400" />
<div className="text-sm font-semibold text-bunker-300">Organization Settings</div>
</>
)}
<FontAwesomeIcon icon={faAngleRight} className="ml-3 mr-3 text-sm text-gray-400" />
<div className="text-sm text-gray-400">{pageName}</div>
{pageName === 'Secrets'
? <a className="text-sm font-semibold text-primary/80 hover:text-primary" href={`${router.asPath.split("?")[0]}`}>{pageName}</a>
: <div className="text-sm text-gray-400">{pageName}</div>}
{currentEnv &&
<>
<FontAwesomeIcon icon={faAngleRight} className="ml-3 mr-1.5 text-xs text-gray-400" />
<div className='pl-3 rounded-md hover:bg-bunker-100/10'>
<Tooltip content="Select environment">
<Select
value={userAvailableEnvs?.filter(uae => uae.name === currentEnv)[0]?.slug}
onValueChange={(value) => {
if (value && onEnvChange) onEnvChange(value);
}}
className="text-sm pl-0 font-medium text-primary/80 hover:text-primary bg-transparent"
dropdownContainerClassName="text-bunker-200 bg-mineshaft-800 border border-mineshaft-600 drop-shadow-2xl"
>
{userAvailableEnvs?.map(({ name, slug }) => (
<SelectItem value={slug} key={slug}>
{name}
</SelectItem>
))}
</Select>
</Tooltip>
</div>
</>}
</div>
);
}
6 changes: 6 additions & 0 deletions frontend/src/components/v2/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const buttonVariants = cva(
outline: ['bg-transparent', 'border-2', 'border-solid'],
plain: '',
selected: '',
outline_bg: '',
// a constant color not in use on hover or click goes colorSchema color
star: 'text-bunker-200 bg-mineshaft-500'
},
Expand Down Expand Up @@ -67,6 +68,11 @@ const buttonVariants = cva(
variant: 'selected',
className: 'bg-primary/10 border border-primary/50 text-bunker-200'
},
{
colorSchema: 'primary',
variant: 'outline_bg',
className: 'bg-mineshaft-800 border border-mineshaft-600 hover:bg-primary/[0.15] hover:border-primary/60 text-bunker-200'
},
{
colorSchema: 'secondary',
variant: 'star',
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/v2/Select/Select.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { forwardRef, ReactNode } from 'react';
import { IconProp } from '@fortawesome/fontawesome-svg-core';
import { faCheck, faChevronDown, faChevronUp } from '@fortawesome/free-solid-svg-icons';
import { faCaretDown, faCheck, faChevronUp } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import * as SelectPrimitive from '@radix-ui/react-select';
import { twMerge } from 'tailwind-merge';
Expand Down Expand Up @@ -49,7 +49,7 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(
</SelectPrimitive.Value>
{!isDisabled && (
<SelectPrimitive.Icon className="ml-3">
<FontAwesomeIcon icon={faChevronDown} size="sm" />
<FontAwesomeIcon icon={faCaretDown} size="sm" />
</SelectPrimitive.Icon>
)}
</SelectPrimitive.Trigger>
Expand All @@ -76,7 +76,7 @@ export const Select = forwardRef<HTMLButtonElement, SelectProps>(
)}
</SelectPrimitive.Viewport>
<SelectPrimitive.ScrollDownButton>
<FontAwesomeIcon icon={faChevronDown} size="sm" />
<FontAwesomeIcon icon={faCaretDown} size="xs" />
</SelectPrimitive.ScrollDownButton>
</SelectPrimitive.Content>
</SelectPrimitive.Portal>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/ee/components/SecretVersionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const SecretVersionList = ({ secretId }: { secretId: string }) => {
}, [secretId]);

return (
<div className="w-full min-w-40 h-[12.4rem] px-4 mt-4 text-sm text-bunker-300 overflow-x-none">
<div className="w-full min-w-40 h-[12.4rem] px-4 mt-4 text-sm text-bunker-300 overflow-x-none dark">
<p className="">{t('dashboard:sidebar.version-history')}</p>
<div className="pl-1 py-0.5 rounded-md bg-bunker-800 border border-mineshaft-500 overflow-x-none h-full">
{isLoading ? (
Expand All @@ -102,7 +102,7 @@ const SecretVersionList = ({ secretId }: { secretId: string }) => {
<div className="w-0 h-full border-l border-bunker-300 mt-1" />
</div>
<div className="flex flex-col w-full max-w-[calc(100%-2.3rem)]">
<div className="pr-2 pt-1 text-bunker-300/90">
<div className="pr-2 text-bunker-300/90">
{new Date(version.createdAt).toLocaleDateString('en-US', {
year: 'numeric',
month: '2-digit',
Expand Down
48 changes: 36 additions & 12 deletions frontend/src/hooks/api/secrets/queries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,42 @@ import {

export const secretKeys = {
// this is also used in secretSnapshot part
getProjectSecret: (workspaceId: string, env: string) => [{ workspaceId, env }, 'secrets'],
getProjectSecret: (workspaceId: string, env: string | string[]) => [{ workspaceId, env }, 'secrets'],
getSecretVersion: (secretId: string) => [{ secretId }, 'secret-versions']
};

const fetchProjectEncryptedSecrets = async (workspaceId: string, env: string) => {
const { data } = await apiRequest.get<{ secrets: EncryptedSecret[] }>('/api/v2/secrets', {
params: {
environment: env,
workspaceId
const fetchProjectEncryptedSecrets = async (workspaceId: string, env: string | string[]) => {
if (typeof env === 'string') {
const { data } = await apiRequest.get<{ secrets: EncryptedSecret[] }>('/api/v2/secrets', {
params: {
environment: env,
workspaceId
}
});
return data.secrets;
}

if (typeof env === 'object') {
let allEnvData: any = [];

// eslint-disable-next-line no-restricted-syntax
for (const envPoint of env) {
// eslint-disable-next-line no-await-in-loop
const { data } = await apiRequest.get<{ secrets: EncryptedSecret[] }>('/api/v2/secrets', {
params: {
environment: envPoint,
workspaceId
}
});
allEnvData = allEnvData.concat(data.secrets);
}
});
return data.secrets;

return allEnvData;
// eslint-disable-next-line no-else-return
} else {
return null;
}

};

export const useGetProjectSecrets = ({
Expand Down Expand Up @@ -59,7 +83,7 @@ export const useGetProjectSecrets = ({
// this used for add-only mode in dashboard
// type won't be there thus only one key is shown
const duplicateSecretKey: Record<string, boolean> = {};
data.forEach((encSecret) => {
data.forEach((encSecret: EncryptedSecret) => {
const secretKey = decryptSymmetric({
ciphertext: encSecret.secretKeyCiphertext,
iv: encSecret.secretKeyIV,
Expand Down Expand Up @@ -93,12 +117,12 @@ export const useGetProjectSecrets = ({
};

if (encSecret.type === 'personal') {
personalSecrets[decryptedSecret.key] = { id: encSecret._id, value: secretValue };
personalSecrets[`${decryptedSecret.key}-${decryptedSecret.env}`] = { id: encSecret._id, value: secretValue };
} else {
if (!duplicateSecretKey?.[decryptedSecret.key]) {
if (!duplicateSecretKey?.[`${decryptedSecret.key}-${decryptedSecret.env}`]) {
sharedSecrets.push(decryptedSecret);
}
duplicateSecretKey[decryptedSecret.key] = true;
duplicateSecretKey[`${decryptedSecret.key}-${decryptedSecret.env}`] = true;
}
});
sharedSecrets.forEach((val) => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/hooks/api/secrets/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export type BatchSecretDTO = {

export type GetProjectSecretsDTO = {
workspaceId: string;
env: string;
env: string | string[];
decryptFileKey: UserWsKeyPair;
isPaused?: boolean;
onSuccess?: (data: DecryptedSecret[]) => void;
Expand Down
Loading

0 comments on commit 338d287

Please sign in to comment.