3id-connect-codingsh 中文文档教程

发布于 4年前 浏览 24 项目主页 更新于 3年前

ceramicnetwork  推特

3ID-Connect

3ID Connect Image

iframe 中的 3ID 用户帐户管理。 访问 did 提供程序的简单方法,特别是浏览器中的 ThreeIdProvider。 它允许用户验证、管理、链接和许可他们的 3ID 密钥到应用程序。 js-3id-did-provider 库处理大部分操作,父窗口(应用程序)与RPC 层上的 iframe 服务。 3id-connect with Ceramic 支持目前仅在 3id-connect@next 和 3idconnect.org 可用。

Use

npm install 3id-connect@next

以太坊提供商和相关身份验证提供商的示例用法。

import { ThreeIdConnect,  EthereumAuthProvider } from '@ceramicstudio/3id-connect'

// assuming ethereum provider available or on window
const addresses = await provider.enable()

const authProvider = new EthereumAuthProvider(provider, addresses[0])
await threeIdConnect.connect(authProvider)

const didProvider = await threeIdConnect.getDidProvider()

// now consume didProvider in ceramic clients, idx, dids libraries, etc

Structure

  • /src - Core logic and consumable interfaces for clients and iframe
  • /threeIdConnect.ts - Application interface (RPC client) to load iframe and return 3ID provider.
  • /connectService.ts - Identity wallet instance and RPC 'server' to handle requests
  • /didProviderProxy.ts - DID provider interface that relays request through RPC layer
  • /authProvider - 3ID connect (client) consumes an auth provider, auth providers can be implemented to support many different blockchain accounts and authentication methods
    • /abstractAuthProvider.ts - Interface used to implement a auth provider
    • /ethereumAuthProvider.ts - Ethereum auth provider, to link and authenticate with ethereum accounts
  • /iframe - all html, css, js, design assets for iframe and flow
  • /public - build assets deployed for iframe

Development

克隆并安装依赖

Run Iframe Locally

$ npm run start

项 iframe 将在本地端口 30001 上提供服务。iframe 服务还需要一个 Ceramic 节点,默认情况下它将查找本地运行的节点。 运行节点的最快方法是使用 Ceramic CLI。

$ npm install -g @ceramicnetwork/cli
& ceramic daemon

您还可以运行 iframe 并连接到远程测试网 Ceramic 节点。

$ npm run start:testnet

最后将 iframe 连接到任何 Ceramic 节点。

$ CERAMIC_API=https://yourceramicnode:port npm run start

Run Demo

Demo 应用程序在端口 30000 上提供服务,并连接到本地运行的 iframe,如上所述。 演示应用程序位于 /example 文件夹中。

$ npm run start:demo

您还可以使用类似的命令将相同的选项传递给本地 iframe。

$ npm run start:demo:testnet
// or 
$ CERAMIC_API=https://yourceramicnode:port npm run start:demo

Build

$ npm run build

Maintainers

@zachferland

ceramicnetwork Twitter

3ID-Connect

3ID Connect Image

3ID user account management in a iframe. An easy way to access a did provider, specifically ThreeIdProvider in the browser. It allows users to authenticate, manage, link and permission their 3ID keys to applications. The library js-3id-did-provider handles most operations and the parent window (application) communicates with the iframe service over an RPC layer. 3id-connect with Ceramic support is only available at 3id-connect@next and 3idconnect.org at the moment.

Use

npm install 3id-connect@next

Example usage with an ethereum provider and related auth provider.

import { ThreeIdConnect,  EthereumAuthProvider } from '@ceramicstudio/3id-connect'

// assuming ethereum provider available or on window
const addresses = await provider.enable()

const authProvider = new EthereumAuthProvider(provider, addresses[0])
await threeIdConnect.connect(authProvider)

const didProvider = await threeIdConnect.getDidProvider()

// now consume didProvider in ceramic clients, idx, dids libraries, etc

Structure

  • /src - Core logic and consumable interfaces for clients and iframe
  • /threeIdConnect.ts - Application interface (RPC client) to load iframe and return 3ID provider.
  • /connectService.ts - Identity wallet instance and RPC 'server' to handle requests
  • /didProviderProxy.ts - DID provider interface that relays request through RPC layer
  • /authProvider - 3ID connect (client) consumes an auth provider, auth providers can be implemented to support many different blockchain accounts and authentication methods
    • /abstractAuthProvider.ts - Interface used to implement a auth provider
    • /ethereumAuthProvider.ts - Ethereum auth provider, to link and authenticate with ethereum accounts
  • /iframe - all html, css, js, design assets for iframe and flow
  • /public - build assets deployed for iframe

Development

Clone and install dependencies

Run Iframe Locally

$ npm run start

The iframe will be served locally on port 30001. The iframe service also requires a Ceramic node, by default it will look for a locally running node. The quickest way to run a node is with the Ceramic CLI.

$ npm install -g @ceramicnetwork/cli
& ceramic daemon

You can also run the iframe and connect to a remote testnet Ceramic node.

$ npm run start:testnet

And lastly connect the iframe to any Ceramic node.

$ CERAMIC_API=https://yourceramicnode:port npm run start

Run Demo

The Demo application is served on port 30000, and connects to a locally running iframe, as described above. Demo application is found in the /example folder.

$ npm run start:demo

You can also pass the same options to the local iframe with similar commands.

$ npm run start:demo:testnet
// or 
$ CERAMIC_API=https://yourceramicnode:port npm run start:demo

Build

$ npm run build

Maintainers

@zachferland

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文