Merge pull request #162 from filecoin-project/andrew/update-hub-apis

fix(hub): update hub cli lib and use new crypto ident class
This commit is contained in:
CAKE 2020-08-19 14:03:29 -07:00 committed by GitHub
commit ab3b058d9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 10 deletions

View File

@ -6,8 +6,7 @@ import * as Constants from "~/node_common/constants";
import JWT from "jsonwebtoken";
import BCrypt from "bcrypt";
import { Buckets } from "@textile/hub";
import { Libp2pCryptoIdentity } from "@textile/threads-core";
import { Buckets, PrivateKey } from "@textile/hub";
import { ffsOptions } from "@textile/powergate-client";
const BUCKET_NAME = "data";
@ -68,7 +67,7 @@ export const getBucketAPI = async () => {
// NOTE(jim): Requires @textile/hub
export const getBucketAPIFromUserToken = async (token) => {
const identity = await Libp2pCryptoIdentity.fromString(token);
const identity = await PrivateKey.fromString(token);
const buckets = await Buckets.withKeyInfo(TEXTILE_KEY_INFO);
await buckets.getToken(identity);
const root = await buckets.open(BUCKET_NAME);

View File

@ -43,9 +43,8 @@
"@emotion/css": "11.0.0-next.12",
"@emotion/react": "11.0.0-next.12",
"@emotion/server": "11.0.0-next.12",
"@textile/hub": "^0.5.2",
"@textile/hub": "^0.5.3",
"@textile/powergate-client": "0.2.0",
"@textile/threads-core": "^0.3.0",
"babel-plugin-module-resolver": "^4.0.0",
"bcrypt": "^5.0.0",
"body-parser": "^1.19.0",

View File

@ -9,7 +9,7 @@ import * as Validations from "~/common/validations";
import JWT from "jsonwebtoken";
import BCrypt from "bcrypt";
import { Libp2pCryptoIdentity } from "@textile/threads-core";
import { PrivateKey } from "@textile/hub";
const initCORS = MW.init(MW.CORS);
@ -45,7 +45,7 @@ export default async (req, res) => {
// TODO(jim):
// Single Key Textile Auth.
const identity = await Libp2pCryptoIdentity.fromRandom();
const identity = await PrivateKey.fromRandom();
const api = identity.toString();
// TODO(jim):

View File

@ -3,8 +3,7 @@ import * as MW from "~/node_common/middleware";
import * as Data from "~/node_common/data";
import * as Utilities from "~/node_common/utilities";
import { Buckets } from "@textile/hub";
import { Libp2pCryptoIdentity } from "@textile/threads-core";
import { Buckets, PrivateKey } from "@textile/hub";
import JWT from "jsonwebtoken";
@ -40,7 +39,7 @@ export default async (req, res) => {
await Data.deleteAPIKeysForUserId({ userId: user.id });
await Data.deleteSlatesForUserId({ userId: user.id });
const i = await Libp2pCryptoIdentity.fromString(user.data.tokens.api);
const i = await PrivateKey.fromString(user.data.tokens.api);
const b = await Buckets.withKeyInfo(TEXTILE_KEY_INFO);
const tokenResponse = await b.getToken(i);
const openResponse = await b.open("data");