PageSourceSearch

https://elastos-wiki.netlify.app/assets/js/e9329d66.2668aa6d.js

js elastos-wiki.netlify.app collected 2026-10-03 10:45:15 UTC 7,295 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[8919],{3905:(e,t,n)=>{n.d(t,{Zo:()=>u,kt:()=>h});var r=n(7294);function i(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 r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function s(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){i(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 o(e,t){if(null==e)return{};var n,r,i=function(e,t){if(null==e)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var c=r.createContext({}),l=function(e){var t=r.useContext(c),n=t;return e&&(n="function"==typeof e?e(t):s(s({},t),e)),n},u=function(e){var t=l(e.components);return r.createElement(c.Provider,{value:t},e.children)},p="mdxType",d={inlineCode:"code",wrapper:function(e){var t=e.children;return r.createElement(r.Fragment,{},t)}},v=r.forwardRef((function(e,t){var n=e.components,i=e.mdxType,a=e.originalType,c=e.parentName,u=o(e,["components","mdxType","originalType","parentName"]),p=l(n),v=i,h=p["".concat(c,".").concat(v)]||p[v]||d[v]||a;return n?r.createElement(h,s(s({ref:t},u),{},{components:n})):r.createElement(h,s({ref:t},u))}));function h(e,t){var n=arguments,i=t&&t.mdxType;if("string"==typeof e||i){var a=n.length,s=new Array(a);s[0]=v;var o={};for(var c in t)hasOwnProperty.call(t,c)&&(o[c]=t[c]);o.originalType=e,o[p]="string"==typeof e?e:i,s[1]=o;for(var l=2;l<a;l++)s[l]=n[l];return r.createElement.apply(null,s)}return r.createElement.apply(null,n)}v.displayName="MDXCreateElement"},6395:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>u,contentTitle:()=>c,default:()=>h,frontMatter:()=>o,metadata:()=>l,toc:()=>p});var r=n(7462),i=n(3366),a=(n(7294),n(3905)),s=["components"],o={title:"Vault Subscription"},c=void 0,l={unversionedId:"sdk/hive/swift/guides/vault-subscription",id:"sdk/hive/swift/guides/vault-subscription",title:"Vault Subscription",description:"Hive SDK needs to interact with the remote Vault service through the Vault instance. Users subscribe to the trusted Hive Node to create Vault service in advance; then they can access the application data to the corresponding Vault.",source:"@site/../docs/7.sdk/hive/swift/guides/vault-subscription.md",sourceDirName:"7.sdk/hive/swift/guides",slug:"/sdk/hive/swift/guides/vault-subscription",permalink:"/sdk/hive/swift/guides/vault-subscription",draft:!1,editUrl:"https://github.com/elastos/Elastos.Wiki/edit/master/website/../docs/7.sdk/hive/swift/guides/vault-subscription.md",tags:[],version:"current",lastUpdatedBy:"racollette",lastUpdatedAt:1678815391,formattedLastUpdatedAt:"Mar 14, 2023",frontMatter:{title:"Vault Subscription"},sidebar:"sdkSidebar",previous:{title:"Build & Install",permalink:"/sdk/hive/swift/install"},next:{title:"Backup Subscription",permalink:"/sdk/hive/swift/guides/backup-subscription"}},u={},p=[{value:"Example",id:"example",level:2},{value:"Subscription Management",id:"subscription-management",level:2},{value:"Check Subscription",id:"check-subscription",level:3},{value:"Unsubscribe",id:"unsubscribe",level:3}],d={toc:p},v="wrapper";function h(e){var t=e.components,n=(0,i.Z)(e,s);return(0,a.kt)(v,(0,r.Z)({},d,n,{components:t,mdxType:"MDXLayout"}),(0,a.kt)("p",null,"Hive SDK needs to interact with the remote Vault service through the Vault instance. Users subscribe to the trusted Hive Node to create Vault service in advance; then they can access the application data to the corresponding Vault."),(0,a.kt)("p",null,"The VaultSubscription class is used to create a Vault Service by subscription, and the Hive Node service creates a new Vault Service according to the DID identity of the requester. If the Vault Service based on the DID identity already exists, the existing Vault Service metadata will be returned."),(0,a.kt)("h2",{id:"example"},"Example"),(0,a.kt)("p",null,"Use the vaultSubscription instance to create a new Vault service in the trusted Hive Node subscription and return a CompletableFuture object c
1ontaining the metadata information of the subscribed remote Vault Service. The actual sample code is as follows:"),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-js"},'let subscription = try VaultSubscription(testData.appContext, testData.providerAddress)\nsubscription.subscribe()\n.done { vault in\n   print("Registered vault service successfully.")\n\n   print("service DID ==> \\(vaultInfo.serviceDid)")\n   print("storage quota ==> " + vaultInfo.getStorageQuota());\n   print("price plan ==> \\(vaultInfo.pricePlan)")\n}\n.catch { error in\n   print("Failed to register vault service")\n   print(error)\n}\n')),(0,a.kt)("p",null,"Once the subscription is successful, the instantiation object vault can be used to access the application data."),(0,a.kt)("h2",{id:"subscription-management"},"Subscription Management"),(0,a.kt)("h3",{id:"check-subscription"},"Check Subscription"),(0,a.kt)("p",null,"After subscribing to the trusted Hive Node, users can use the vault instance to access the data in the application or view the information of the corresponding Vault Service by using the following interface."),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-js"},'subscription.checkSubscription()\n.done { vault in\n   print("Dump remote vault service:")\n   print("service DID ==> \\(vaultInfo.serviceDid)")\n   print("storage quota ==> \\(vaultInfo.storageQuota)")\n   print("price plan ==> \\(vaultInfo.pricePlan)")\n}\n.catch { error in\n   print("Failed to check vault subscription")\n   print(error)\n}\n')),(0,a.kt)("h3",{id:"unsubscribe"},"Unsubscribe"),(0,a.kt)("p",null,"Users can use the Vault service for a period of time and migrate the already used Vault service to the new Hive Node as needed. After the migration, it's important to stop the Vault service on the original Hive Node and destroy the data within it."),(0,a.kt)("pre",null,(0,a.kt)("code",{parentName:"pre",className:"language-js"},'subscription.unsubscribe()\n.done { success in\n   print("Unsubscribed from the vault service")\n   print("Cleared all data in this vault.")\n}\n.catch { error in\n   print("Failed to unsubscribe to vault service")\n   print(error)\n}\n')),(0,a.kt)("admonition",{title:"Attention",type:"info"},(0,a.kt)("p",{parentName:"admonition"},"After calling this interface to cancel the Vault service, the data held in the vault will be permanently deleted from the corresponding Hive Node, and the Vault service will stop serving as well. Users must ensure that a new Vault service has been migrated before calling this interface to cancel the Vault service that originally needed to be abandoned.")))}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.