mirror of
https://github.com/filecoin-project/slate.git
synced 2024-11-30 22:13:47 +03:00
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:
commit
ab3b058d9b
@ -6,8 +6,7 @@ import * as Constants from "~/node_common/constants";
|
|||||||
import JWT from "jsonwebtoken";
|
import JWT from "jsonwebtoken";
|
||||||
import BCrypt from "bcrypt";
|
import BCrypt from "bcrypt";
|
||||||
|
|
||||||
import { Buckets } from "@textile/hub";
|
import { Buckets, PrivateKey } from "@textile/hub";
|
||||||
import { Libp2pCryptoIdentity } from "@textile/threads-core";
|
|
||||||
import { ffsOptions } from "@textile/powergate-client";
|
import { ffsOptions } from "@textile/powergate-client";
|
||||||
|
|
||||||
const BUCKET_NAME = "data";
|
const BUCKET_NAME = "data";
|
||||||
@ -68,7 +67,7 @@ export const getBucketAPI = async () => {
|
|||||||
|
|
||||||
// NOTE(jim): Requires @textile/hub
|
// NOTE(jim): Requires @textile/hub
|
||||||
export const getBucketAPIFromUserToken = async (token) => {
|
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);
|
const buckets = await Buckets.withKeyInfo(TEXTILE_KEY_INFO);
|
||||||
await buckets.getToken(identity);
|
await buckets.getToken(identity);
|
||||||
const root = await buckets.open(BUCKET_NAME);
|
const root = await buckets.open(BUCKET_NAME);
|
||||||
|
@ -43,9 +43,8 @@
|
|||||||
"@emotion/css": "11.0.0-next.12",
|
"@emotion/css": "11.0.0-next.12",
|
||||||
"@emotion/react": "11.0.0-next.12",
|
"@emotion/react": "11.0.0-next.12",
|
||||||
"@emotion/server": "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/powergate-client": "0.2.0",
|
||||||
"@textile/threads-core": "^0.3.0",
|
|
||||||
"babel-plugin-module-resolver": "^4.0.0",
|
"babel-plugin-module-resolver": "^4.0.0",
|
||||||
"bcrypt": "^5.0.0",
|
"bcrypt": "^5.0.0",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
|
@ -9,7 +9,7 @@ import * as Validations from "~/common/validations";
|
|||||||
import JWT from "jsonwebtoken";
|
import JWT from "jsonwebtoken";
|
||||||
import BCrypt from "bcrypt";
|
import BCrypt from "bcrypt";
|
||||||
|
|
||||||
import { Libp2pCryptoIdentity } from "@textile/threads-core";
|
import { PrivateKey } from "@textile/hub";
|
||||||
|
|
||||||
const initCORS = MW.init(MW.CORS);
|
const initCORS = MW.init(MW.CORS);
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ export default async (req, res) => {
|
|||||||
|
|
||||||
// TODO(jim):
|
// TODO(jim):
|
||||||
// Single Key Textile Auth.
|
// Single Key Textile Auth.
|
||||||
const identity = await Libp2pCryptoIdentity.fromRandom();
|
const identity = await PrivateKey.fromRandom();
|
||||||
const api = identity.toString();
|
const api = identity.toString();
|
||||||
|
|
||||||
// TODO(jim):
|
// TODO(jim):
|
||||||
|
@ -3,8 +3,7 @@ import * as MW from "~/node_common/middleware";
|
|||||||
import * as Data from "~/node_common/data";
|
import * as Data from "~/node_common/data";
|
||||||
import * as Utilities from "~/node_common/utilities";
|
import * as Utilities from "~/node_common/utilities";
|
||||||
|
|
||||||
import { Buckets } from "@textile/hub";
|
import { Buckets, PrivateKey } from "@textile/hub";
|
||||||
import { Libp2pCryptoIdentity } from "@textile/threads-core";
|
|
||||||
|
|
||||||
import JWT from "jsonwebtoken";
|
import JWT from "jsonwebtoken";
|
||||||
|
|
||||||
@ -40,7 +39,7 @@ export default async (req, res) => {
|
|||||||
await Data.deleteAPIKeysForUserId({ userId: user.id });
|
await Data.deleteAPIKeysForUserId({ userId: user.id });
|
||||||
await Data.deleteSlatesForUserId({ 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 b = await Buckets.withKeyInfo(TEXTILE_KEY_INFO);
|
||||||
const tokenResponse = await b.getToken(i);
|
const tokenResponse = await b.getToken(i);
|
||||||
const openResponse = await b.open("data");
|
const openResponse = await b.open("data");
|
||||||
|
Loading…
Reference in New Issue
Block a user