PageSourceSearch

https://elastos-wiki.netlify.app/assets/js/5baffbeb.44084ad4.js

js elastos-wiki.netlify.app collected 2026-10-03 10:43:22 UTC 6,044 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[4620],{3905:(e,t,n)=>{n.d(t,{Zo:()=>p,kt:()=>h});var o=n(7294);function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function i(e,t){if(null==e)return{};var n,o,r=function(e,t){if(null==e)return{};var n,o,r={},a=Object.keys(e);for(o=0;o<a.length;o++)n=a[o],t.indexOf(n)>=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)n=a[o],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}var s=o.createContext({}),l=function(e){var t=o.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):c(c({},t),e)),n},p=function(e){var t=l(e.components);return o.createElement(s.Provider,{value:t},e.children)},u="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return o.createElement(o.Fragment,{},t)}},v=o.forwardRef((function(e,t){var n=e.components,r=e.mdxType,a=e.originalType,s=e.parentName,p=i(e,["components","mdxType","originalType","parentName"]),u=l(n),v=r,h=u["".concat(s,".").concat(v)]||u[v]||d[v]||a;return n?o.createElement(h,c(c({ref:t},p),{},{components:n})):o.createElement(h,c({ref:t},p))}));function h(e,t){var n=arguments,r=t&&t.mdxType;if("string"==typeof e||r){var a=n.length,c=new Array(a);c[0]=v;var i={};for(var s in t)hasOwnProperty.call(t,s)&&(i[s]=t[s]);i.originalType=e,i[u]="string"==typeof e?e:r,c[1]=i;for(var l=2;l<a;l++)c[l]=n[l];return o.createElement.apply(null,c)}return o.createElement.apply(null,n)}v.displayName="MDXCreateElement"},9906:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>p,contentTitle:()=>s,default:()=>h,frontMatter:()=>i,metadata:()=>l,toc:()=>u});var o=n(7462),r=n(3366),a=(n(7294),n(3905)),c=["components"],i={title:"Manage Connectors"},s=void 0,l={unversionedId:"sdk/general/connectivity/guides/manage-connectors",id:"sdk/general/connectivity/guides/manage-connectors",title:"Manage Connectors",description:"The Connectivity SDK can support several connectors inside the same application so that users can choose the service they want to use. So far, only 2 connectors are available: the local identity connector, and the Elastos Essentials connector.",source:"@site/../docs/7.sdk/general/connectivity/guides/manage-connectors.md",sourceDirName:"7.sdk/general/connectivity/guides",slug:"/sdk/general/connectivity/guides/manage-connectors",permalink:"/sdk/general/connectivity/guides/manage-connectors",draft:!1,editUrl:"https://github.com/elastos/Elastos.Wiki/edit/master/website/../docs/7.sdk/general/connectivity/guides/manage-connectors.md",tags:[],version:"current",lastUpdatedBy:"racollette",lastUpdatedAt:1676425989,formattedLastUpdatedAt:"Feb 15, 2023",frontMatter:{title:"Manage Connectors"},sidebar:"sdkSidebar",previous:{title:"Customization",permalink:"/sdk/general/connectivity/guides/customization"},next:{title:"The Built-in Connector Standard",permalink:"/sdk/general/connectivity/connectors/standard"}},p={},u=[{value:"Register a Connector",id:"register-a-connector",level:2},{value:"Force the Active Connector",id:"force-the-active-connector",level:2},{value:"Get the Active Connector",id:"get-the-active-connector",level:2}],d={toc:u},v="wrapper";function h(e){var t=e.components,n=(0,r.Z)(e,c);return(0,a.kt)(v,(0,o.Z)({},d,n,{components:t,mdxType:"MDXLayout"}),(0,a.kt)("p",null,"The Connectivity SDK can support several connectors inside the same application so that users can choose the service they want to use. So far, only 2 connectors are available: the ",(0,a.kt)("strong",{parentName:"p"},"local identity connector"),", and the ",(0,a.kt)("strong",{parentName:"p"},"Elastos Essentials connector.")),(0,a.kt)("blockquote",null,(0,a.kt)("p",{parentName:"blockquote"},"At least one connector must be provided for each dApp, otherwise connectivity operations cannot be ran. Web dApp usually don't need the local identity connector, while native mobile apps may need it in order to pass the app store review team validation (i.e. iTunes), as app stores do not accept applications that force users to install another application (a wallet) to access the features.")),(0,a.kt)("h2",{id:"register-a-connector"},"Register a Connector"),(0,a.kt)("p",null,"As seen on the setup page, a connector can be registered like this:"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-ts"},'import { connectivity } from "@elastosfoundation/elastos-connectivity-sdk-js";\n\nlet essentialsConnector = new EssentialsConnector();\nconnectivity.registerConnector(essentialsConnector);\n')),(0,a.kt)("h2",{id:"force-the-active-connector"},"Force the Active Connector"),(0,a.kt)("p",null,"By default, if multiple connectors are registered, when a user initiates a first connectivity operation, he gets a prompt and needs to choose which connector he wants to use. This is the way to let users choose their wallet or service."),(0,a.kt)("p",null,"Though, this behavior can be enforced by the dApp by manually setting the active connector like this:"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-ts"},"// Set the active connector by its name\nconnectivity.setActiveConnector(essentialsConnector.name);\n")),(0,a.kt)("h2",{id:"get-the-active-connector"},"Get the Active Connector"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-ts"},"connectivity.getActiveConnector();\n")))}h.isMDXComponent=!0}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.