Skip to content

Commit

Permalink
Merge pull request #2253 from ChainSafe/dev
Browse files Browse the repository at this point in the history
Release - 2022-10-11
  • Loading branch information
FSM1 committed Oct 11, 2022
2 parents 86a1584 + 7765312 commit 6258a10
Show file tree
Hide file tree
Showing 18 changed files with 1,025 additions and 471 deletions.
4 changes: 2 additions & 2 deletions packages/common-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"dependencies": {
"@material-ui/styles": "^4.11.2",
"@types/react-scroll": "^1.8.2",
"@types/react-select": "^3.0.27",
"@types/react-select": "3.0.27",
"a11y-react-emoji": "^1.1.2",
"clsx": "^1.1.1",
"normalize.css": "^8.0.1",
Expand All @@ -27,7 +27,7 @@
"react-dropzone": "^11.2.4",
"react-router-dom": "^5.2.0",
"react-scroll": "^1.8.1",
"react-select": "^3.1.1",
"react-select": "3.1.1",
"react-spinners": "^0.9.0",
"reset-css": "^5.0.1",
"rollup-plugin-babel": "^4.4.0"
Expand Down
8 changes: 6 additions & 2 deletions packages/files-ui/cypress/support/utils/apiTestHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,12 @@ export const apiTestHelper = {
throw new Error("Something wrong happened when creating a folder")
}

navigationMenu.binNavButton().click()
navigationMenu.homeNavButton().click()
cy.intercept("POST", "**/bucket/*/ls").as("refresh").then(() => {
navigationMenu.binNavButton().click()
cy.wait("@refresh")
navigationMenu.homeNavButton().click()
cy.wait("@refresh")
})

const firstFolderName = folderPath.split("/")[1]
homePage.fileItemName().contains(firstFolderName)
Expand Down
1 change: 1 addition & 0 deletions packages/files-ui/cypress/tests/search.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe("Search", () => {
cy.web3Login({ clearCSFBucket: true, clearTrashBucket: true })
apiTestHelper.createFolder(folderPath)
homePage.searchInput().type(`${folderName}{enter}`)
cy.url().should("contain", `/search/${folderName}`)

// view contents via menu option
searchPage.fileItemKebabButton().click()
Expand Down
10 changes: 5 additions & 5 deletions packages/files-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"@sentry/react": "^5.28.0",
"@stripe/react-stripe-js": "^1.4.1",
"@stripe/stripe-js": "^1.18.0",
"@tkey/default": "5.1.0",
"@tkey/security-questions": "5.1.0",
"@tkey/web-storage": "5.1.0",
"@toruslabs/customauth": "7.0.2",
"@tkey/default": "7.0.0",
"@tkey/security-questions": "7.0.0",
"@tkey/web-storage": "7.0.0",
"@toruslabs/customauth": "11.0.0",
"@types/filesystem": "^0.0.32",
"@types/uuid": "^8.3.0",
"axios": "0.26.1",
Expand Down Expand Up @@ -106,4 +106,4 @@
"last 1 safari version"
]
}
}
}
10 changes: 5 additions & 5 deletions packages/files-ui/src/Components/Layouts/AppHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ const AppHeader = ({ navOpen, setNavOpen }: IAppHeader) => {
window.open(ROUTE_LINKS.DiscordInvite, "_blank")
}, [])

const onJoinBetaClick = useCallback(() => {
setIsBetaModalOpen(true)
}, [])
// const onJoinBetaClick = useCallback(() => {
// setIsBetaModalOpen(true)
// }, [])

const onUpgradeClick = useCallback(() => {
redirect(ROUTE_LINKS.SettingsPath("plan"))
Expand Down Expand Up @@ -197,14 +197,14 @@ const AppHeader = ({ navOpen, setNavOpen }: IAppHeader) => {
>
<Trans>Report a bug</Trans>
</Button>
{!isBillingEnabled && <Button
{/* {!isBillingEnabled && <Button
data-posthog="Join-beta"
variant="tertiary"
size="small"
onClick={onJoinBetaClick}
>
<Trans>Need more storage?</Trans>
</Button>}
</Button>} */}
{isBillingEnabled && <Button
data-posthog="Upgrade"
variant="tertiary"
Expand Down
76 changes: 39 additions & 37 deletions packages/files-ui/src/Contexts/ThresholdKeyContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const TKEY_STORE_KEY = "csf.tkeyStore"
const TORUS_USERINFO_KEY = "csf.userInfo"
const PASSWORD_QUESTION = "What is your password?"

export type ThresholdKeyContextStatus = "initializing"|"initialized"|"awaiting confirmation"|"logging in"|"done"
export type ThresholdKeyContextStatus = "initializing" | "initialized" | "awaiting confirmation" | "logging in" | "done"
export type BrowserShare = {
shareIndex: string
module: string
Expand All @@ -48,7 +48,7 @@ export type TThresholdKeyContext = {
hasPasswordShare: boolean
shouldInitializeAccount: boolean
pendingShareTransferRequests: ShareTransferRequest[]
login(loginType: IdentityProvider, tokenInfo?: {token: string; email: string}): Promise<void>
login(loginType: IdentityProvider, tokenInfo?: { token: string; email: string }): Promise<void>
resetIsNewDevice(): void
resetShouldInitialize(): void
addPasswordShare(password: string): Promise<void>
Expand Down Expand Up @@ -92,31 +92,31 @@ export type ShareTransferRequest = {
const ThresholdKeyContext = React.createContext<TThresholdKeyContext | undefined>(undefined)
const maintenanceMode = process.env.REACT_APP_MAINTENANCE_MODE === "true"

const getProviderSpecificParams = (loginType: LOGIN_TYPE):
{typeOfLogin: LOGIN_TYPE; clientId: string; verifier: string; jwtParams?: any} => {
switch (loginType) {
case "google": {
return {
typeOfLogin: loginType,
clientId: process.env.REACT_APP_GOOGLE_CLIENT_ID || "",
verifier: "chainsafe-uuid-testnet"
const getProviderSpecificParams =
(loginType: LOGIN_TYPE): { typeOfLogin: LOGIN_TYPE; clientId: string; verifier: string; jwtParams?: any } => {
switch (loginType) {
case "google": {
return {
typeOfLogin: loginType,
clientId: process.env.REACT_APP_GOOGLE_CLIENT_ID || "",
verifier: "chainsafe-uuid-testnet"
}
}
}
case "github":{
return {
typeOfLogin: loginType,
clientId: process.env.REACT_APP_AUTH0_CLIENT_ID || "",
verifier: "chainsafe-uuid-testnet",
jwtParams: {
domain: process.env.REACT_APP_AUTH0_DOMAIN || ""
case "github": {
return {
typeOfLogin: loginType,
clientId: process.env.REACT_APP_AUTH0_CLIENT_ID || "",
verifier: "chainsafe-uuid-testnet",
jwtParams: {
domain: process.env.REACT_APP_AUTH0_DOMAIN || ""
}
}
}
}
default:{
throw new Error(`${loginType} is unsupported`)
default: {
throw new Error(`${loginType} is unsupported`)
}
}
}
}

const ThresholdKeyProvider = ({ children, network = "mainnet", enableLogging = false, apiKey }: ThresholdKeyProviderProps) => {
const { filesApiClient, thresholdKeyLogin, logout } = useFilesApi()
Expand Down Expand Up @@ -208,9 +208,10 @@ const ThresholdKeyProvider = ({ children, network = "mainnet", enableLogging = f
// The user will be required to log in to the respective service
tkey = new ThresholdKey({
modules,
directParams: {
customAuthArgs: {
baseUrl: `${window.location.origin}/serviceworker`,
network: network,
networkUrl: network === "testnet" ? "https://nd-598-268-537.p2pify.com/9a34d9de132b22e6b71b52d3fde80ff1" : undefined,
enableLogging: enableLogging,
apiKey: apiKey
},
Expand Down Expand Up @@ -286,7 +287,7 @@ const ThresholdKeyProvider = ({ children, network = "mainnet", enableLogging = f
useEffect(() => {
const loginWithThresholdKey = async () => {
if (!userInfo) return
const decodedIdToken = jwtDecode<{exp: number}>(userInfo.userInfo.idToken || "")
const decodedIdToken = jwtDecode<{ exp: number }>(userInfo.userInfo.idToken || "")
if (privateKey && dayjs.unix(decodedIdToken.exp).isAfter(dayjs())) {
const pubKey = EthCrypto.publicKeyByPrivateKey(privateKey)
setPublicKey(pubKey)
Expand All @@ -308,7 +309,7 @@ const ThresholdKeyProvider = ({ children, network = "mainnet", enableLogging = f
console.log("logging in using tkey")
loginWithThresholdKey()
}
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [privateKey])

// Share Transfer poller
Expand All @@ -333,7 +334,7 @@ const ThresholdKeyProvider = ({ children, network = "mainnet", enableLogging = f
[]
)

if(pendingShareTransferRequests.length !== pendingRequests.length){
if (pendingShareTransferRequests.length !== pendingRequests.length) {
setPendingShareTransferRequests(pendingRequests)
}
}
Expand Down Expand Up @@ -404,7 +405,7 @@ const ThresholdKeyProvider = ({ children, network = "mainnet", enableLogging = f

const createJWT = useCallback((bucketId: string, nonceId: string, permission: NonceResponsePermission) => {

if(!privateKey) {
if (!privateKey) {
console.error("no private key found")
return
}
Expand All @@ -415,7 +416,7 @@ const ThresholdKeyProvider = ({ children, network = "mainnet", enableLogging = f
const payload = {
type: "link_sharing",
permission,
iat: KJUR.jws.IntDate.get("now"),
iat: KJUR.jws.IntDate.get("now"),
bucket_id: bucketId,
nonce_id: nonceId
}
Expand All @@ -427,7 +428,7 @@ const ThresholdKeyProvider = ({ children, network = "mainnet", enableLogging = f
return sJWT
}, [privateKey])

const login = async (loginType: IdentityProvider, tokenInfo?: {token: string; email: string}) => {
const login = async (loginType: IdentityProvider, tokenInfo?: { token: string; email: string }) => {
if (!TKeySdk || maintenanceMode) return
try {
setStatus("awaiting confirmation")
Expand Down Expand Up @@ -456,7 +457,7 @@ const ThresholdKeyProvider = ({ children, network = "mainnet", enableLogging = f
verifierId: (loginType === "web3") ? address || "" : decodedToken.uuid,
typeOfLogin: loginType !== "web3" && loginType !== "email" ? loginType : "jwt",
accessToken: userInfo?.accessToken,
state: { }
state: {}
}
}
setUserInfo(loginResponse)
Expand All @@ -468,11 +469,11 @@ const ThresholdKeyProvider = ({ children, network = "mainnet", enableLogging = f
sessionStorage.setItem(TORUS_POSTBOX_KEY, TKeySdk.serviceProvider.postboxKey.toString("hex"))
setStatus("logging in")
try {
const metadata = await TKeySdk.storageLayer.getMetadata<ShareStore | {message: string}>({
const metadata = await TKeySdk.storageLayer.getMetadata<ShareStore | { message: string }>({
privKey: TKeySdk.serviceProvider.postboxKey
})
console.log("metadata", metadata)
const keyNotFound = (metadata as {message: string}).message === "KEY_NOT_FOUND"
const keyNotFound = (metadata as { message: string }).message === "KEY_NOT_FOUND"
if (keyNotFound) {
console.log("New key")
setIsNewKey(true)
Expand Down Expand Up @@ -509,8 +510,8 @@ const ThresholdKeyProvider = ({ children, network = "mainnet", enableLogging = f

const getIdentityToken = async (
loginType: IdentityProvider,
tokenInfo?: {token: string; email: string}
): Promise<{identityToken: IdentityToken; userInfo: any}> => {
tokenInfo?: { token: string; email: string }
): Promise<{ identityToken: IdentityToken; userInfo: any }> => {
if (loginType === "email") {
const uuidToken = await filesApiClient.generateServiceIdentityToken({
identity_provider: loginType,
Expand All @@ -525,7 +526,7 @@ const ThresholdKeyProvider = ({ children, network = "mainnet", enableLogging = f

let addressToUse = address

if (!isReady || !provider) {
if (!isReady || !provider) {
const connected = await checkIsReady()

if (!connected || !provider) throw new Error("Unable to connect to wallet.")
Expand All @@ -534,7 +535,7 @@ const ThresholdKeyProvider = ({ children, network = "mainnet", enableLogging = f
const signer = provider.getSigner()
if (!signer) throw new Error("Signer undefined")

if(!addressToUse){
if (!addressToUse) {
// checkIsReady above doesn't make sure that the address is defined
// we pull the address here to have it defined for sure
addressToUse = await signer.getAddress()
Expand Down Expand Up @@ -791,9 +792,10 @@ const ThresholdKeyProvider = ({ children, network = "mainnet", enableLogging = f
[WEB_STORAGE_MODULE_NAME]: new WebStorageModule(true),
[SHARE_TRANSFER_MODULE_NAME]: new ShareTransferModule()
},
directParams: {
customAuthArgs: {
baseUrl: `${window.location.origin}/serviceworker`,
network: network,
networkUrl: network === "testnet" ? "https://nd-598-268-537.p2pify.com/9a34d9de132b22e6b71b52d3fde80ff1" : undefined,
enableLogging: enableLogging,
apiKey: apiKey
},
Expand Down
14 changes: 7 additions & 7 deletions packages/files-ui/src/locales/de/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-04-20 00:28+0200\n"
"PO-Revision-Date: 2021-09-29 19:36+0000\n"
"Last-Translator: J. Lavoie <j.lavoie@net-c.ca>\n"
"PO-Revision-Date: 2022-08-25 08:15+0000\n"
"Last-Translator: Hugel <qihu@nfschina.com>\n"
"Language-Team: German <https://hosted.weblate.org/projects/chainsafe-files/chainsafe-files-user-interface/de/>\n"
"Language: de\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.9-dev\n"
"X-Generator: Weblate 4.14-dev\n"
"Mime-Version: 1.0\n"

msgid "(Awaiting payment)"
msgstr ""
msgstr "(Warten auf Zahlung)"

msgid "({0}) items selected"
msgstr ""
Expand All @@ -23,7 +23,7 @@ msgid "/month"
msgstr ""

msgid "/year"
msgstr ""
msgstr "/Jahr"

msgid "<0>{currentStorage}</0> of storage"
msgstr ""
Expand Down Expand Up @@ -56,10 +56,10 @@ msgid "Account visibility"
msgstr ""

msgid "Add Card"
msgstr ""
msgstr "Karte hinzufügen"

msgid "Add a credit card"
msgstr ""
msgstr "Fügen Sie eine Kreditkarte hinzu"

msgid "Add a username"
msgstr "Einen Benutzernamen hinzufügen"
Expand Down
8 changes: 7 additions & 1 deletion packages/storage-ui/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface Web3LoginOptions {
deleteFpsBuckets?: boolean
withNewSession?: boolean
createFpsBuckets?: { name: string; type: FileSystemType }[]
deleteApiKeys?: boolean
}

Cypress.Commands.add("clearPins", apiTestHelper.clearPins)
Expand All @@ -61,7 +62,8 @@ Cypress.Commands.add(
withNewUser = true,
deleteFpsBuckets = false,
withNewSession = false,
createFpsBuckets
createFpsBuckets,
deleteApiKeys = false
}: Web3LoginOptions = {}) => {

cy.on("window:before:load", (win) => {
Expand Down Expand Up @@ -117,6 +119,10 @@ Cypress.Commands.add(
apiTestHelper.createBucket(bucket.name, bucket.type)
})
}

if(deleteApiKeys) {
apiTestHelper.deleteApiKeys()
}
}
)

Expand Down
21 changes: 21 additions & 0 deletions packages/storage-ui/cypress/support/page-objects/apiKeysPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Only add things here that could be applicable to the api keys page

import { basePage } from "./basePage"

export const apiKeysPage = {
...basePage,

// main api keys elements
apiKeysHeaderLabel: () => cy.get("[data-cy=header-api-keys]", { timeout: 20000 }),
addApiKeyButton: () => cy.get("[data-cy=button-add-api-key]"),
addS3KeyButton: () => cy.get("[data-cy=button-add-s3-key]"),

// api keys table row elements
apiKeyIdCell: () => cy.get("[data-cy=cell-api-keys-id]"),
apiKeyTypeCell: () => cy.get("[data-cy=cell-api-keys-type]"),
apiKeyStatusCell: () => cy.get("[data-cy=cell-api-keys-status]"),
apiKeyRowKebabButton: () => cy.get("[data-testid=dropdown-title-api-keys-kebab]"),

// kebab menu elements
deleteMenuOption: () => cy.get("[data-cy=menu-delete]")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const newKeyModal = {
keyIdLabel: () => cy.get("[data-cy=label-new-key-modal-key-id]"),
secretLabel: () => cy.get("[data-cy=label-new-key-modal-secret]"),
closeButton: () => cy.get("[data-cy=button-new-key-modal-close]")
}
Loading

0 comments on commit 6258a10

Please sign in to comment.