From 6af315732aafa5e7a0440a1d8765da9c59224105 Mon Sep 17 00:00:00 2001 From: "@wwwjim" Date: Wed, 9 Sep 2020 10:56:35 -0700 Subject: [PATCH 1/2] staging: all textile staging changes --- common/navigation-data.js | 33 +- common/strings.js | 12 +- common/svg.js | 57 ++- components/core/Application.js | 2 +- components/core/ApplicationNavigation.js | 5 +- components/core/DataMeter.js | 3 +- components/core/Section.js | 1 + components/sidebars/SidebarFilecoinArchive.js | 20 +- node_common/constants.js | 2 +- node_common/managers/viewer.js | 84 +++- node_common/utilities.js | 23 +- package.json | 4 +- pages/api/data/archive.js | 14 +- pages/api/network.js | 27 ++ pages/api/users/delete.js | 4 +- pages/api/users/update.js | 22 +- scenes/SceneArchive.js | 133 +++++-- scenes/SceneSentinel.js | 9 +- scenes/SceneSettings.js | 364 ++++++++++-------- scenes/SceneWallet.js | 204 +++++----- 20 files changed, 656 insertions(+), 367 deletions(-) create mode 100644 pages/api/network.js diff --git a/common/navigation-data.js b/common/navigation-data.js index f6a9923f..4ce95fea 100644 --- a/common/navigation-data.js +++ b/common/navigation-data.js @@ -33,15 +33,7 @@ const constructFilesTreeForNavigation = (library) => { return { ...library[0], name: `Data`, - children: [ - { - id: "V1_NAVIGATION_ARCHIVE", - decorator: "ARCHIVE", - name: "Archive", - pageTitle: "Archive on Filecoin", - children: null, - }, - ], + children: [], }; }; @@ -126,14 +118,35 @@ export const generate = ({ library = [], slates = [] }) => [ decorator: "SETTINGS_DEVELOPER", name: "API", pageTitle: "Developer API", + children: [], + }, + { + id: "V1_NAVIGATION_ARCHIVE", + decorator: "FILECOIN", + name: "Filecoin Testnet", + pageTitle: "Archive on Filecoin", children: [ { id: "V1_NAVIGATION_NETWORK", decorator: "NETWORK", - name: "Filecoin Network", + name: "Network API", pageTitle: "The Filecoin Network", children: null, }, + { + id: "V1_NAVIGATION_WALLET", + decorator: "WALLET", + name: "Wallet", + pageTitle: "Your wallet and addresses", + children: [], + }, + { + id: "V1_NAVIGATION_FILECOIN_SETTINGS", + decorator: "SETTINGS", + name: "Deal settings", + pageTitle: "Deal Settings.", + children: null, + }, ], }, { diff --git a/common/strings.js b/common/strings.js index 1f728a5e..92608f83 100644 --- a/common/strings.js +++ b/common/strings.js @@ -68,8 +68,13 @@ export const getCIDFromIPFS = (url) => { return cid; }; +export const formatAsFilecoinConversion = (number) => { + number = number / Math.pow(10, 18); + return `${formatAsFilecoin(number)}`; +}; + export const formatAsFilecoin = (number) => { - return `${number} FIL`; + return `${formatNumber(number)} FIL`; }; export const pluralize = (text, count) => { @@ -200,7 +205,10 @@ export const createSlug = (text, base = "untitled") => { return base; } - text = text.toString().toLowerCase().trim(); + text = text + .toString() + .toLowerCase() + .trim(); const sets = [ { to: "a", from: "[ÀÁÂÃÅÆĀĂĄẠẢẤẦẨẪẬẮẰẲẴẶ]" }, diff --git a/common/svg.js b/common/svg.js index 78fd08c1..c53ca246 100644 --- a/common/svg.js +++ b/common/svg.js @@ -285,37 +285,32 @@ export const ExpandArrow = (props) => ( ); -// export const Wallet = (props) => ( -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// -// ); +export const OldWallet = (props) => ( + + + + + + + + + + + + + +); export const NavigationArrow = (props) => ( diff --git a/components/core/Application.js b/components/core/Application.js index a9e71519..728fcbcf 100644 --- a/components/core/Application.js +++ b/components/core/Application.js @@ -87,7 +87,7 @@ const SCENES = { LOCAL_DATA: , NETWORK: , DIRECTORY: , - ARCHIVE: , + FILECOIN: , }; export default class ApplicationPage extends React.Component { diff --git a/components/core/ApplicationNavigation.js b/components/core/ApplicationNavigation.js index e610ec4c..48ed1846 100644 --- a/components/core/ApplicationNavigation.js +++ b/components/core/ApplicationNavigation.js @@ -12,15 +12,16 @@ const IconMap = { NETWORK: , DIRECTORY: , FOLDER: , - WALLET: , + WALLET: , DEALS: , SLATES: , SLATE: , LOCAL_DATA: , PROFILE_PAGE: , SETTINGS_DEVELOPER: , + SETTINGS: , DIRECTORY: , - ARCHIVE: , + FILECOIN: , }; const STYLES_NAVIGATION = css` diff --git a/components/core/DataMeter.js b/components/core/DataMeter.js index f47dc93f..8e021b9f 100644 --- a/components/core/DataMeter.js +++ b/components/core/DataMeter.js @@ -5,8 +5,7 @@ import * as System from "~/components/system"; import { css } from "@emotion/react"; -// NOTE(jim): 10 GB -const MAX_IN_BYTES = 10737418240; +const MAX_IN_BYTES = 10737418240 * 50; const STYLES_CONTAINER = css` border-radius: 4px; diff --git a/components/core/Section.js b/components/core/Section.js index 8ad698cc..34703db5 100644 --- a/components/core/Section.js +++ b/components/core/Section.js @@ -11,6 +11,7 @@ const STYLES_SECTION = css` border-radius: 4px; font-weight: 400; margin-top: 24px; + white-space: pre-wrap; :first-child { margin-top: 0px; diff --git a/components/sidebars/SidebarFilecoinArchive.js b/components/sidebars/SidebarFilecoinArchive.js index 4fac2eb4..76e80722 100644 --- a/components/sidebars/SidebarFilecoinArchive.js +++ b/components/sidebars/SidebarFilecoinArchive.js @@ -9,17 +9,14 @@ import { css } from "@emotion/react"; import { dispatchCustomEvent } from "~/common/custom-events"; export default class SidebarFilecoinArchive extends React.Component { + state = { response: "" }; + async componentDidMount() {} _handleMakeDeal = async () => { const response = await Actions.archive(); - console.log(response); - dispatchCustomEvent({ - name: "create-alert", - detail: { - alert: { message: "Deal archiving is still under development" }, - }, - }); + + this.setState({ response }); }; _handleSubmit = async (e) => { @@ -29,7 +26,8 @@ export default class SidebarFilecoinArchive extends React.Component { this.props.onSidebarLoading(true); await this._handleMakeDeal(); - await this.props.onSubmit({}); + await this.props.onRehydrate(); + this.props.onSidebarLoading(false); }; _handleCancel = () => { @@ -41,8 +39,6 @@ export default class SidebarFilecoinArchive extends React.Component { }; render() { - console.log(this.props); - return ( Make storage deal + +
+ {JSON.stringify(this.state.response, null, 2)} +
); } diff --git a/node_common/constants.js b/node_common/constants.js index 9bfef430..7882e3a9 100644 --- a/node_common/constants.js +++ b/node_common/constants.js @@ -6,4 +6,4 @@ export const GITHUB_URL = "https://github.com/filecoin-project/slate"; export const ANALYTICS_URL = "https://slate-stats-dev.azurewebsites.net/"; // NOTE(jim): 1 GB from Ignacio -export const TEXTILE_ACCOUNT_BYTE_LIMIT = 1073741824; +export const TEXTILE_ACCOUNT_BYTE_LIMIT = 1073741824 * 50; diff --git a/node_common/managers/viewer.js b/node_common/managers/viewer.js index 7cfb4957..e0cde3ca 100644 --- a/node_common/managers/viewer.js +++ b/node_common/managers/viewer.js @@ -1,3 +1,8 @@ +// TODO(jim): Drop this in the release +import { grpc } from "@improbable-eng/grpc-web"; +import { WebsocketTransport } from "@textile/grpc-transport"; +grpc.setDefaultTransport(WebsocketTransport()); + import * as Utilities from "~/node_common/utilities"; import * as Data from "~/node_common/data"; import * as Constants from "~/node_common/constants"; @@ -73,11 +78,6 @@ export const getById = async ({ id }) => { return { ...Serializers.user(user), type: "VIEWER", - - // NOTE(jim): The only safe viewer fields to expose. - settings: { - deals_auto_approve: user.data.settings_deals_auto_approve, - }, library: user.data.library, // NOTE(jim): Remaining data. @@ -94,3 +94,77 @@ export const getById = async ({ id }) => { pendingTrusted: r4.serializedPendingTrusted, }; }; + +export const getTextileById = async ({ id }) => { + const user = await Data.getUserById({ + id, + }); + + if (!user) { + return null; + } + + if (user.error) { + return null; + } + + let info = {}; + let status = {}; + let errors = []; + let jobs = []; + + const { + buckets, + bucketKey, + bucketName, + bucketRoot, + } = await Utilities.getBucketAPIFromUserToken(user.data.tokens.api); + + const { + power, + powerInfo, + powerHealth, + } = await Utilities.getPowergateAPIFromUserToken(user.data.tokens.api); + + try { + buckets.archiveWatch(bucketRoot.root.key, (job) => { + if (!job) { + return; + } + + job.id = job.id ? job.id : "UNDEFINED"; + jobs.push(job); + }); + } catch (e) { + errors.push({ decorator: "JOB", message: e.message, code: e.code }); + } + + try { + info = await buckets.archiveInfo(bucketRoot.root.key); + } catch (e) { + errors.push({ decorator: "INFO", message: e.message, code: e.code }); + } + + try { + status = await buckets.archiveStatus(bucketRoot.root.key); + } catch (e) { + errors.push({ decorator: "STATUS", message: e.message, code: e.code }); + } + + console.log(jobs); + + return { + type: "VIEWER_FILECOIN", + settings: { + deals_auto_approve: user.data.settings_deals_auto_approve, + }, + powerInfo, + powerHealth, + archive: { + info, + status, + errors, + jobs, + }, + }; +}; diff --git a/node_common/utilities.js b/node_common/utilities.js index 216a13ce..436f3652 100644 --- a/node_common/utilities.js +++ b/node_common/utilities.js @@ -5,7 +5,7 @@ import * as Constants from "~/node_common/constants"; import JWT from "jsonwebtoken"; import BCrypt from "bcrypt"; -import { Buckets, PrivateKey } from "@textile/hub"; +import { Buckets, PrivateKey, Pow } from "@textile/hub"; const BUCKET_NAME = "data"; @@ -79,10 +79,29 @@ export const parseAuthHeader = (value) => { return matches && { scheme: matches[1], value: matches[2] }; }; +// NOTE(jim): Requires @textile/hub +export const getPowergateAPIFromUserToken = async (token) => { + const identity = await PrivateKey.fromString(token); + const power = await Pow.withKeyInfo(TEXTILE_KEY_INFO, { + host: Environment.TEXTILE_HUB_STAGING_HOST, + }); + await power.getToken(identity); + const { info } = await power.info(); + const health = await power.health(); + + return { + power, + powerHealth: health, + powerInfo: info, + }; +}; + // NOTE(jim): Requires @textile/hub export const getBucketAPIFromUserToken = async (token) => { const identity = await PrivateKey.fromString(token); - const buckets = await Buckets.withKeyInfo(TEXTILE_KEY_INFO); + const buckets = await Buckets.withKeyInfo(TEXTILE_KEY_INFO, { + host: Environment.TEXTILE_HUB_STAGING_HOST, + }); await buckets.getToken(identity); const target = await buckets.getOrInit(BUCKET_NAME); diff --git a/package.json b/package.json index f8c8cc26..7f8e31f5 100644 --- a/package.json +++ b/package.json @@ -43,9 +43,11 @@ "@emotion/css": "11.0.0-next.12", "@emotion/react": "11.0.0-next.12", "@emotion/server": "11.0.0-next.12", + "@improbable-eng/grpc-web": "^0.13.0", "@react-hook/window-size": "^3.0.7", "@slack/webhook": "^5.0.3", - "@textile/hub": "^0.6.2", + "@textile/grpc-transport": "0.0.3", + "@textile/hub": "^0.7.1-alpha.1", "babel-plugin-module-resolver": "^4.0.0", "bcrypt": "^5.0.0", "body-parser": "^1.19.0", diff --git a/pages/api/data/archive.js b/pages/api/data/archive.js index 73801210..4c01a6c5 100644 --- a/pages/api/data/archive.js +++ b/pages/api/data/archive.js @@ -34,16 +34,20 @@ export default async (req, res) => { bucketRoot, } = await Utilities.getBucketAPIFromUserToken(user.data.tokens.api); - console.log(bucketRoot.root); - // bucketRoot.root.key // bucketRoot.root.path - const response = await buckets.archive(bucketRoot.root.key); - console.log(response); + let response = {}; + let error = {}; + try { + response = await buckets.archive(bucketRoot.root.key); + } catch (e) { + error.message = e.message; + error.code = e.code; + } return res.status(200).send({ decorator: "SERVER_BUCKET_ARCHIVE_DEAL", - data: {}, + data: { response, error }, }); }; diff --git a/pages/api/network.js b/pages/api/network.js new file mode 100644 index 00000000..cf55b00f --- /dev/null +++ b/pages/api/network.js @@ -0,0 +1,27 @@ +import * as ViewerManager from "~/node_common/managers/viewer"; +import * as Utilities from "~/node_common/utilities"; + +export default async (req, res) => { + const id = Utilities.getIdFromCookie(req); + if (!id) { + return res + .status(500) + .send({ decorator: "SERVER_FILECOIN_NETWORK_FAILURE", error: true }); + } + + const data = await ViewerManager.getTextileById({ id }); + + if (!data) { + return res + .status(500) + .send({ + decorator: "SERVER_FILECOIN_NETWORK_ERROR", + error: true, + data: null, + }); + } + + return res + .status(200) + .send({ decorator: "SERVER_FILECOIN_NETWORK", success: true, data }); +}; diff --git a/pages/api/users/delete.js b/pages/api/users/delete.js index aa7b1471..3ba4b114 100644 --- a/pages/api/users/delete.js +++ b/pages/api/users/delete.js @@ -39,7 +39,9 @@ export default async (req, res) => { await Data.deleteSlatesForUserId({ userId: user.id }); const i = await PrivateKey.fromString(user.data.tokens.api); - const b = await Buckets.withKeyInfo(TEXTILE_KEY_INFO); + const b = await Buckets.withKeyInfo(TEXTILE_KEY_INFO, { + host: Environment.TEXTILE_HUB_STAGING_HOST, + }); const tokenResponse = await b.getToken(i); const openResponse = await b.getOrInit("data"); diff --git a/pages/api/users/update.js b/pages/api/users/update.js index 2632002f..b7135df1 100644 --- a/pages/api/users/update.js +++ b/pages/api/users/update.js @@ -49,8 +49,26 @@ export default async (req, res) => { } } - // TODO(jim): Do not expose how many times you are salting - // in OSS, add a random value as an environment variable. + // TODO(jim): POWERGATE + // Doesn't actually work yet. + if (req.body.type === "SET_DEFAULT_STORAGE_CONFIG") { + const { + power, + powerInfo, + powerHealth, + } = await Utilities.getPowergateAPIFromUserToken(user.data.tokens.api); + + let data; + try { + data = await power.ffs.setDefaultStorageConfig(req.body.config); + } catch (e) { + console.log(e); + return res + .status(500) + .send({ decorator: "SERVER_USER_UPDATE_SETTINGS_CONFIG", error: true }); + } + } + if (req.body.type == "CHANGE_PASSWORD") { if (!Validations.password(req.body.password)) { return res diff --git a/scenes/SceneArchive.js b/scenes/SceneArchive.js index d7a3b5da..2fbb53e1 100644 --- a/scenes/SceneArchive.js +++ b/scenes/SceneArchive.js @@ -1,46 +1,127 @@ import * as React from "react"; import * as System from "~/components/system"; +import * as Constants from "~/common/constants"; import { css } from "@emotion/react"; +import { LoaderSpinner } from "~/components/system/components/Loaders"; import Section from "~/components/core/Section"; import ScenePage from "~/components/core/ScenePage"; import ScenePageHeader from "~/components/core/ScenePageHeader"; +const STYLES_LABEL = css` + font-family: ${Constants.font.semiBold}; + font-size: 16px; + margin-bottom: 16px; +`; + export default class SceneArchive extends React.Component { + state = {}; + + async componentDidMount() { + let networkViewer; + try { + const response = await fetch("/api/network"); + const json = await response.json(); + networkViewer = json.data; + } catch (e) {} + + this.setState({ + networkViewer, + }); + } + render() { return ( - - Slate provides a way to archive your data onto the Filecoin network. - Once your archive is sealed on the Filecoin network, it will be shown - here. + + Filecoin is currently in Testnet phase. You can use this tab to test + and verify Filecoin deals with Testnet FIL. -
- +
+ { + return { + miner, + }; + } + ), + }} + /> +
+ +
-
+ ]} + > +
+
Info
+ {JSON.stringify(this.state.networkViewer.archive.info, null, 2)} + +
+ Status +
+ {JSON.stringify( + this.state.networkViewer.archive.status, + null, + 2 + )} + +
+ Errors +
+ {JSON.stringify( + this.state.networkViewer.archive.errors, + null, + 2 + )} +
+
+ +
+ { + return { + job: job.msg, + }; + }), + }} + /> +
+ + ) : ( + + )}
); } diff --git a/scenes/SceneSentinel.js b/scenes/SceneSentinel.js index 3b5d2e9f..fd47af6f 100644 --- a/scenes/SceneSentinel.js +++ b/scenes/SceneSentinel.js @@ -26,12 +26,13 @@ export default class SceneSentinel extends React.Component { render() { return ( - - Slate provides access to live data on the Filecoin Network through - Sentinel. Each of these API endpoints can be used programatically. + + Slate provides access to live data on the Filecoin Testnet Network + through Sentinel. Each of these API endpoints can be used + programatically. -
+
{ + return { + settings_hot_enabled: config.hot.enabled, + settings_hot_allow_unfreeze: config.hot.allowUnfreeze, + settings_hot_ipfs_add_timeout: config.hot.ipfs.addTimeout, + settings_cold_enabled: config.cold.enabled, + settings_cold_default_address: config.cold.filecoin.addr, + settings_cold_default_duration: config.cold.filecoin.dealMinDuration, + settings_cold_default_replication_factor: config.cold.filecoin.repFactor, + settings_cold_default_excluded_miners: + config.cold.filecoin.excludedMinersList, + settings_cold_default_trusted_miners: + config.cold.filecoin.trustedMinersList, + settings_cold_default_max_price: config.cold.filecoin.maxPrice, + settings_cold_default_auto_renew: config.cold.filecoin.renew.enabled, + settings_cold_default_auto_renew_max_price: + config.cold.filecoin.renew.threshold, + }; +}; + export default class SceneSettings extends React.Component { - state = { ...this.props.viewer }; + state = {}; + + async componentDidMount() { + let networkViewer; + try { + const response = await fetch("/api/network"); + const json = await response.json(); + networkViewer = json.data; + } catch (e) {} + + this.setState({ + networkViewer, + ...createState(networkViewer.powerInfo.defaultStorageConfig), + }); + } _deferredSave = null; _handleSave = async () => { this.setState({ loading: true }); + return alert(`Changing settings is currently disabled.`); + await Actions.updateViewer({ type: "SET_DEFAULT_STORAGE_CONFIG", - data: { - settings_deals_auto_approve: this.state.settings_deals_auto_approve, - }, config: { hot: { enabled: this.state.settings_hot_enabled, @@ -88,179 +124,175 @@ export default class SceneSettings extends React.Component { render() { return ( - Filecoin settings + + Filecoin is currently in Testnet phase. You can use this page to view + the default settings. Once your deal settings can be configured, you + can edit your settings whenever you like. + - Storage defaults + {this.state.networkViewer ? ( + +
+ { + return { + miner, + }; + } + ), + }} + /> +
-
-
- -
-
- -
-
+
+
+ +
+
+ +
+
-
- - Save - -
+ {this.state.settings_cold_enabled ? ( +
+ -
-
- -
-
- -
-
+ - {this.state.settings_cold_enabled ? ( -
- + - + - + + Enable auto renew for Filecoin Network deals. + - + +
+ ) : null} +
+ + Save + +
- - Enable auto renew for Filecoin Network deals. - +
+
+ +
+
+ +
+
- -
- ) : null} -
- - Save - -
+ {this.state.settings_hot_enabled ? ( +
+ + IPFS allow unfreeze setting description. + -
-
- -
-
- -
-
- - {this.state.settings_hot_enabled ? ( -
- - IPFS allow unfreeze setting description. - - - -
- ) : null} -
- - Save - -
+ +
+ ) : null} +
+ + Save + +
+
+ ) : ( + + )}
); } diff --git a/scenes/SceneWallet.js b/scenes/SceneWallet.js index 88e2120c..f8be7528 100644 --- a/scenes/SceneWallet.js +++ b/scenes/SceneWallet.js @@ -6,6 +6,7 @@ import * as System from "~/components/system"; import { css } from "@emotion/react"; import { dispatchCustomEvent } from "~/common/custom-events"; +import { LoaderSpinner } from "~/components/system/components/Loaders"; import Section from "~/components/core/Section"; import ScenePage from "~/components/core/ScenePage"; @@ -85,6 +86,22 @@ const STYLES_ITEM_GROUP = css` `; export default class SceneWallet extends React.Component { + state = {}; + + async componentDidMount() { + let networkViewer; + try { + const response = await fetch("/api/network"); + const json = await response.json(); + networkViewer = json.data; + } catch (e) {} + console.log(networkViewer); + + this.setState({ + networkViewer, + }); + } + state = { table_transaction: null, visible: false }; _handleChange = (e) => { @@ -109,133 +126,128 @@ export default class SceneWallet extends React.Component { }; render() { - let addresses = {}; - let lastAddress; + // TODO(jim): Temporary because of read only Filecoin Addresses + const { networkViewer } = this.state; - this.props.viewer.addresses.forEach((a) => { - addresses[a.address] = a; - lastAddress = a.address; - }); + const addressMap = {}; + const addresses = []; + let selected = null; - const currentAddress = this.props.selected.address - ? addresses[this.props.selected.address] - : addresses[lastAddress]; + if (networkViewer) { + networkViewer.powerInfo.balancesList.forEach((a) => { + addressMap[a.addr.addr] = { ...a.addr, balance: a.balance }; + addresses.push({ ...a.addr, balance: a.balance }); + }); - // TODO(jim): - // Capture this state. - if (!currentAddress) { - return null; - } + if (addresses.length) { + selected = addresses[0]; + } - let transactions = []; - if (currentAddress.transactions) { - transactions = [...currentAddress.transactions]; + let transactions = []; + if (selected.transactions) { + transactions = [...selected.transactions]; + } } return ( - - This scene is currently a work in progress. + + This is your testnet wallet address. It is prefilled by Textile to + help test the Filecoin Testnet. -
-
+ */ + ] + } + > + {/*
-
+
*/} -
-
-
-
- {this.state.visible ? ( - currentAddress.address - ) : ( - Hidden - )} -
-
Filecoin address
-
- -
-
- {currentAddress.name}{" "} - {this.props.viewer.settings_cold_default_address === - currentAddress.address ? ( - (Primary) - ) : null} -
-
Filecoin address alias
-
- -
-
+
+
+
- {Strings.formatNumber(currentAddress.balance)} + {this.state.visible ? ( + selected.addr + ) : ( + Hidden + )}
-
Filecoin
+
Filecoin address
-
-
{currentAddress.type}
-
Address type
+
+
+ {selected.name}{" "} + {networkViewer.settings_cold_default_address === + selected.addr ? ( + (Primary) + ) : null} +
+
Filecoin address alias
+
+ +
+
+
+ {Strings.formatAsFilecoinConversion(selected.balance)} +
+
Filecoin
+
+ +
+
{selected.type}
+
Address type
+
- -
- - this.props.onAction({ - name: "Send Filecoin", - type: "SIDEBAR", - value: "SIDEBAR_WALLET_SEND_FUNDS", - }) - } +
+ - Send Filecoin - + + + this._handleCopy(selected.address)} + > + +
-
- - - - this._handleCopy(currentAddress.address)} - > - - -
-
-
+
+ ) : ( + + )} ); } From a8bc911c807126b3d205fe75fe394ddb944ce71c Mon Sep 17 00:00:00 2001 From: "@wwwjim" Date: Thu, 17 Sep 2020 14:14:34 -0700 Subject: [PATCH 2/2] 0.7.1 --- node_common/managers/viewer.js | 3 ++- node_common/utilities.js | 8 ++------ package.json | 2 +- pages/api/users/delete.js | 4 +--- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/node_common/managers/viewer.js b/node_common/managers/viewer.js index e0cde3ca..ec9ab922 100644 --- a/node_common/managers/viewer.js +++ b/node_common/managers/viewer.js @@ -1,4 +1,5 @@ -// TODO(jim): Drop this in the release +// TODO(jim): The claim is that we can remove this +// and the package.json depdencies at some later time. import { grpc } from "@improbable-eng/grpc-web"; import { WebsocketTransport } from "@textile/grpc-transport"; grpc.setDefaultTransport(WebsocketTransport()); diff --git a/node_common/utilities.js b/node_common/utilities.js index 436f3652..3f8563c7 100644 --- a/node_common/utilities.js +++ b/node_common/utilities.js @@ -82,9 +82,7 @@ export const parseAuthHeader = (value) => { // NOTE(jim): Requires @textile/hub export const getPowergateAPIFromUserToken = async (token) => { const identity = await PrivateKey.fromString(token); - const power = await Pow.withKeyInfo(TEXTILE_KEY_INFO, { - host: Environment.TEXTILE_HUB_STAGING_HOST, - }); + const power = await Pow.withKeyInfo(TEXTILE_KEY_INFO); await power.getToken(identity); const { info } = await power.info(); const health = await power.health(); @@ -99,9 +97,7 @@ export const getPowergateAPIFromUserToken = async (token) => { // NOTE(jim): Requires @textile/hub export const getBucketAPIFromUserToken = async (token) => { const identity = await PrivateKey.fromString(token); - const buckets = await Buckets.withKeyInfo(TEXTILE_KEY_INFO, { - host: Environment.TEXTILE_HUB_STAGING_HOST, - }); + const buckets = await Buckets.withKeyInfo(TEXTILE_KEY_INFO); await buckets.getToken(identity); const target = await buckets.getOrInit(BUCKET_NAME); diff --git a/package.json b/package.json index 7f8e31f5..d80659cb 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "@react-hook/window-size": "^3.0.7", "@slack/webhook": "^5.0.3", "@textile/grpc-transport": "0.0.3", - "@textile/hub": "^0.7.1-alpha.1", + "@textile/hub": "^0.7.1", "babel-plugin-module-resolver": "^4.0.0", "bcrypt": "^5.0.0", "body-parser": "^1.19.0", diff --git a/pages/api/users/delete.js b/pages/api/users/delete.js index 3ba4b114..aa7b1471 100644 --- a/pages/api/users/delete.js +++ b/pages/api/users/delete.js @@ -39,9 +39,7 @@ export default async (req, res) => { await Data.deleteSlatesForUserId({ userId: user.id }); const i = await PrivateKey.fromString(user.data.tokens.api); - const b = await Buckets.withKeyInfo(TEXTILE_KEY_INFO, { - host: Environment.TEXTILE_HUB_STAGING_HOST, - }); + const b = await Buckets.withKeyInfo(TEXTILE_KEY_INFO); const tokenResponse = await b.getToken(i); const openResponse = await b.getOrInit("data");