Javascript/Typescript library for interacting with Space in web/browser applications via an implementation of the Space API. Build websites or applications that can easily leverage Open Web protocols (IPFS, Textile, GunDB, Ethereum) to enable Web3-ready features like:
The Space SDK is a close friend of the Space Daemon, its desktop-focused counterpart.
You can find the SDK's documentation here:
The Space SDK is modular and protocol agnostic. You can use the APIs and interfaces as is, with Space's default implementations, or replace them with your own custom ones.
Feature | Description | Service/Protocol |
---|---|---|
Users | Key-pair based identity creation, and challenge authentication. | Textile Users API |
Storage | File, directory, and bucket creation/listing. | IPFS / Textile |
Metadata | Secure Bucket/directory schema storage | GunDB |
Sharing | Private and public file sharing | Textile |
@spacehq/sdk
provides a suit of functionality to perform different action on Space.
Install the sdk using this npm command:
npm install @spacehq/sdk
Space SDK provides an interface perform the following actions:
Creating identities
Create files and directories
List files and directories
Creating buckets
Sharing buckets
Full SDK Documentation with examples can be found here
This involves managing users and their identities.
import { Users } from '@spacehq/sdk';
const users = new Users({ endpoint: 'wss://dev.space.storage' });
// createIdentity generate a random keypair identity
const identity = await users.createIdentity();
// the new keypair can be used to authenticate a new user
// `users.authenticate()` generates hub API session tokens for the keypair identity.
const user = await users.authenticate(identity);
// `user` can be used with the storage class to provide identity.
// user's identity can also be backed up with a special recovery phrase
const uuid = 'specify-uuid-representing-user-in-your-system';
const passphrase = 'specify-unique-pass-phrase-related-to-backup-type';
const backupType = VaultBackupType.Google;
await users.backupKeysByPassphrase(uuid, passphrase, backupType, user.identity);
// backed up users identity can also be recovered later
const recoveredUser = await users.recoverKeysByPassphrase(uuid, passphrase, backupType);
// `recoveredUser` has same authentication as `user` above.
Check the User's class for more examples of how to manage userswith the sdk.
This involves operations to create and list files and directories in space storage.
import { UserStorage, AddItemsResultSummary } from '@spacehq/sdk';
const storage = new UserStorage(user);
await storage.createFolder({ bucket: 'personal', path: 'topFolder' });
const result = await storage.listDirectory({ bucket: 'personal', path: '' });
// result contains `topFolder` items
// upload a file
const uploadResponse = await spaceStorage.addItems({
bucket: 'personal',
files: [
{
path: 'file.txt',
content: '',
},
{
path: 'space.png',
content: '',
}
],
});
// uploadresponse is an event listener
uploadResponse.once('done', (data: AddItemsEventData) => {
const summary = data as AddItemsResultSummary;
// returns a summary of all files and their upload status
});
This includes operations to share your storage items with existing user (identities)
import { UserStorage } from '@space/sdk';
const storage = new UserStorage(user);
// you can share privately with existing users via their public key:
await storage.shareViaPublicKey({
publicKeys: [{
id: 'user@email.com', // or any identifier for the user
pk: 'user-pk-hex-or-multibase', // optional, omit if user doesn't exist yet, it would generate temp access key
}],
paths: [{
bucket: 'personal',
path: '/file/path/here'
}],
});
// or you could share the file publicly by generating a link. Generated link references
await spaceStorage.setFilePublicAccess({
bucket: 'personal',
path: '/file.txt',
allowAccess: true, // <- set to false to revoke public access
});
If you are already familiar with the space daemon and its gRPC methods and would like to start using the space-sdkhere are some pointers on how those gRPC methods correspond to functionalities exposed by the space-sdk.
In the sdk the concept of Key Pairs is represented as an Identity
.To create a new Identity similar to the GenerateKeyPair
method, you would do:
import { Users, BrowserStorage } from '@spacehq/sdk';
const users = new Users({ endpoint: 'wss://auth-dev.space.storage' });
// createIdentity generate a random keypair identity
const identity = await users.createIdentity();
identity
represents a keypair and its primary key is accessible via identity.public.toString()
.
In space-daemon the generated keypair is stored in the operating systems keychain but in space-sdk you wouldneed to provide an IdentityStorage to the Users
class when initializing it.For the browser environment there exists a BrowserStorage
implementationyou can use.
import { Users, BrowserStorage } from '@spacehq/sdk';
const users = await Users.withStorage(
new BrowserStorage(),
{ endpoint: 'wss://auth-dev.space.storage' }
);
Users.withStorage
will load and authenticate all identities that exist inside the provided IdentityStorage
.You can access all authenticated users through the Users.list
method.
const spaceUsers = await users.list();
To authenticate a new user identity and get a SpaceUser,you can call the Users.authenticate
method:
const spaceUser = await users.authenticate(identity);
Users.authentication
would do two things:
SpaceUser
.IdentityStorage
, so subsequent initialization of Users.withStorage()
wouldhave the users loaded.NOTE: An existing space user can also be gotten from Users.recoverKeysByPassphrase
.
To delete a user from users lists, you can delete the user by pass the publicKey
of that user to Users.remove
.
await users.remove(spaceUser.identity.public.toString());
If you have the concept of a current active user in your application that uses space-sdk. We recommend that you keep trackof that users public key in your application and use it to filter the listmethod's result to get the authenticated SpaceUser
for that public key.
On logout, you can call the remove method to stop tracking the user.
In space daemon GetAPISessionToken returns the message:
message GetAPISessionTokensResponse {
string hubToken = 1;
string servicesToken = 2;
}
In order to get the servicesToken
and hubToken
for a particular user, you would need to authenticate that user identity:
const spaceUser = await users.authenticate(identity);
The spaceUser.token
value is the servicesToken
, while the spaceUser.storageAuth.token
is the hubToken
.
Also, note that when an existing user is recovered via the Users.recoverKeysByPassphrase
method, the SpaceUser
returns is also authenticated and has the session tokens.
In space daemon GetPublicKey
returned the id of the current keypair in keychain, but since space-sdk returns the identity
object. You can get the public key bytes for a particular identity through identity.public.pubKey
.
Also, an authenticated SpaceUser
identity can be found in the identity
field.
The storage gRPC methods on space daemon can now be performed using the UserStorage
class of the space-sdk.
import { UserStorage, AddItemsResultSummary } from '@spacehq/sdk';
const storage = new UserStorage(user);
await storage.createFolder({ bucket: 'personal', path: 'topFolder' });
const result = await storage.listDirectory({ path: '' });
// result contains `topFolder` items
// upload a file
const uploadResponse = await spaceStorage.addItems({
bucket: 'personal',
files: [
{
path: 'file.txt',
content: 'plain-text-value',
},
{
path: 'space.png',
content: '', // could also be a ReadableStream<Uint8Array> or ArrayBuffer
}
],
});
// uploadresponse is an event listener
uploadResponse.once('done', (data: AddItemsEventData) => {
const summary = data as AddItemsResultSummary;
// returns a summary of all files and their upload status
});
// read content of an uploaded file
const fileResponse = await storage.openFile({ bucket: 'personal', path: '/file.txt'});
const fileContent = await fileResponse.consumeStream();
// new TextDecoder('utf8').decode(actualTxtContent) == 'plain-text-value'
All contributions are welcome. Before getting started, kindly take some time to review our contributing guidelinesand code of conduct.
第一步:npm install vod-js-sdk-v6 写成组件 upload代码片。 // An highlighted block <template> <div style="width: 400px"> <el-upload action="#" :accept="accept" :disabled="disabled" :l
Install OSS PHP SDK If you use the composer to manage project dependencies, run the following command in your project's root directory: composer require aliyuncs/oss-sdk-php You can also declare th
获取小觅MYNT-EYE-SDK 可以从MYNTAI官网下载SDK包,参考链接:https://mynt-eye-d-sdk.readthedocs.io/en/latest/installation/build_linux.html。 make all(make samples)出现错误 显示我并未安装opencv,实际上已经安装了opencv,不过是3.3.0版本,根据以上链接,重新安装ope
在www.android.com下载最新版的android-sdk_r20.0.3-windows之后,点击SDK Manager.exe,发现无法显示Updates/New的内容,因此无法进行更新。 菜单Tools-->options中的Force https://...sources to be fetched using http://...勾选上之后,问题依旧。 最终解决方案: 在C:\W
SDK文档 nxp官方文档中心:https://nxp.sdlproducts.com/LiveContent/web/pub.xql?c=t&action=home&pub=QorIQ_SDK&lang=en-US pdf:https://www.nxp.com/docs/en/release-note/QORIQ-SDK-2-0_RN.pdf 先大概浏览一下,发现P1020rdb支持到SDK1
通过以前文章的配置编译通过的环境基础上写自己的DNG方法,推荐很给力的网址,https://forums.adobe.com/message/2127126?tstart=0,其中的一些参数根据自己的相机配置一下即可写出DNG图片,希望对大家能够提供帮助。至此虽然DNG写出来了,但对DNG整体结构和一些细节概念还是不知道,希望大家有好的文章贴一下。 网址内容: SubIFD1 tag
跟着yahboom的资料 2、开发环境搭建走的,纯小白,遇到问题如下: 1.1 开发板与电脑连接的USB数据线需要检查是否为数据线,不能是充电线; 1.2 在SDKManager中连接到开发板以后,按照步骤VM中下载OS和SDK显示there is not enough disk space ……,确定分配给虚拟机的空间是足够的不用管,直接点继续;参考How do I FIX "not enoug
今天第一次使用微信的SDK来写个盆友圈分享的Demo,记录下学习笔记和遇到的问题。 1.先去微信开发者中心申请一个APPID,需要提交一些应用的信息,然后就是等待审核了。 2.创建一个Demo工程,记得导入从官网下载的libammsdk.jar. 然后就可以开始写代码咯。 Demo使用的布局文件 activity_main.xml <LinearLayout xmlns:android="http
描述 (Description) 合并空间功能通过空间添加属性值。 例子 (Example) 以下示例演示了在LESS文件中使用合并空间功能 - <!doctype html> <head> <title>Merge Space</title> <link rel = "stylesheet" href = "style.css" type = "text/css"
Space函数填充具有特定数量空格的字符串。 语法 (Syntax) space(number) 参数描述 (Parameter Description) Number - 必需参数。 我们要添加到给定字符串的空格数。 例子 (Example) Private Sub Constant_demo_Click() Dim var1 as Variant var1 = "Microsof
描述 (Description) white-space属性用于更改用户代理处理元素中的空格。 可能的值 (Possible Values) normal - 元素中的任何空格序列都将转换为单个空格。 pre - 元素中的所有空格都被尊重,包括多个空格和回车。 nowrap - 元素中的任何空格序列都将转换为单个空格,但禁用自动换行。 适用于 (Applies to) 所有块级元素。 DOM语法
描述 (Description) 字符类\p{Space}匹配任何空格字符。 例子 (Example) 以下示例显示了Posix字符类匹配的用法。 package com.wenjiangs; import java.util.regex.Matcher; import java.util.regex.Pattern; public class PosixCharacterClassDemo {
创建空间 修改空间 删除空间
Space Daemon Space Daemon is a wrapper built in Go around awesome IPFS tools so that you can have start coding a decentralized desktop app as fast as possible. It's built on top of Textile Threads and