[−][src]Struct caelum_diddoc::DidDoc
Methods
impl DidDoc
[src]
pub fn new(context: String, id: String) -> DidDoc
[src]
Web assembly Constructor
DidDoc
's constructor will create an empty DidDoc
object. An empty object
is not a valid DidDoc
.
import { DidDoc } from 'caelum_diddoc';
let d = new DidDoc("my_context", "my_id");
pub fn default() -> DidDoc
[src]
Web assembly Constructor
DidDoc
's constructor will create an empty DidDoc
object. An empty object
is not a valid DidDoc
.
import { DidDoc } from 'caelum_diddoc';
let d = DidDoc.default();
pub fn from_json(json: JsValue) -> DidDoc
[src]
WebAssembly Constructor formJSON
DidDoc
's constructor will create a DidDoc
object from input. Input must be a
JSON object with all properties defined. If no value is wanted for certain property, must
be empty. This is also true for sub properties (properties of properties).
import { DidDoc } from 'caelum_diddoc';
let myDidDoc_json = {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1"
],
"id": "http://example.com/credentials/4643",
"authentication": [
{
"id": "did:example:ebfeb1276e12ec21f712ebc6f1c",
"type": "OpenIdConnectVersion1.0Service",
"owner": "OWNER!",
"PublicKeyBase58": "H3C2AVvLMv6gmMNam3uVAjZpfkcJCwDwnZn6z3wXmqPV"
},
"did:lrn:123412341234#my_id"
],
"publicKey": [{
"id": "did:example:ebfeb1276e12ec21f712ebc6f1c",
"type": "OpenIdConnectVersion1.0Service",
"owner": "OWNER!",
"PublicKeyBase58": "H3C2AVvLMv6gmMNam3uVAjZpfkcJCwDwnZn6z3wXmqPV"
}],
"service": [{
"id": "id",
"type": "type",
"serviceEndpoint": "serviceEndpoint"
}],
"updated": "1982-02-02-00T00:00Z",
"created": "1982-02-02-00T00:00Z",
"proof": {
"type": "RsaSignature2018",
"created": "2018-06-17T10:03:48Z",
"verificationMethod": "did:example:ebfeb1276e12ec21f712ebc6f1c#k1",
"signatureValue": "pY9...Cky6Ed = "
}
};
let myDidDoc = DidDoc.fromJSON(myDidDoc_json);
pub fn set_context(self, c: String) -> DidDoc
[src]
Set context
Specifications describe a @context
as a mandatory field that:
one or more URIs (An identifier as defined by RFC3986.) where the value of the first URI is https://www.w3.org/2019/did/v1. If more than one URI is provided, the URIs MUST be interpreted as an ordered set. It is RECOMMENDED that dereferencing the URIs results in a document containing machine-readable information about the context.
And must follow the following rules:
- A DID Document MUST have exactly one top-level context statement.
- The key for this property MUST be @context.
- The value of this key MUST be the URL for the generic DID context: https://w3id.org/did/v1.
By default context
will be set to
{
@context: [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1"
]
}
To overwrite default context
s use method setContext()
can be used.
import { DidDoc } from 'caelum_diddoc';
let vc = new DidDoc("my_id")
.setContext("new_context");
pub fn set_id(self, id: String) -> DidDoc
[src]
Set Id (Did Subject)
A DID subject goes by the following rules:
- A DID Document MUST have exactly one DID subject.
- The key for this property MUST be id.
- The value of this key MUST be a valid DID.
- When this DID Document is registered with the target Decentralized Identifier Registry, the registered DID MUST match this DID subject value.
Similarly to @context
, in caelum_diddoc
, id
s are created in the DidDoc
constructor. Users can add an id subject using
method add_id()
, and can overwrite them using setter set_id()
. id
s are not array so no adder is implemented,
only a setter and a getter.
By default id
will be set by the constructor.
To overwrite default id
use method setId()
can be used.
import { DidDoc } from 'caelum_diddoc';
let vc = new DidDoc("my_id")
.setId("_id");
pub fn set_authentication(self, a: JsValue) -> DidDoc
[src]
Set DID Authentication
Following w3's documentation:
Authentication is the mechanism by which a DID subject can cryptographically prove that they are associated with a DID.
The rules for Authentication are:
- A DID Document MAY include an
authentication
property. - The value of the
authentication
property should be an array of verification methods. - Each verification method MAY be embedded or referenced. An example of a verification method is a public key.
By default authentication
is set to an empty object with empty properties (type
and
publicKey
).
let d = new DidDoc("my_context", "my_id")
.setAuthentication({
"id": "did:example:ebfeb1276e12ec21f712ebc6f1c",
"type": "OpenIdConnectVersion1.0Service",
"owner": "OWNER!",
"PublicKeyBase58": "H3C2AVvLMv6gmMNam3uVAjZpfkcJCwDwnZn6z3wXmqPV"
});
pub fn set_public_key(self, p: JsValue) -> DidDoc
[src]
Set Public Key
Public keys are used for digital signatures, encryption and other cryptographic operations, which in turn are the basis for purposes such as authentication or establishing secure communication with service endpoints. In addition, public keys may play a role in authorization mechanisms of DID CRUD operations
The rules for public keys are:
- A DID Document MAY include a publicKey property.
- The value of the
publicKey
property MUST be an array of public keys, and every public key property MUST be in the Linked Data Cryptographic Suite Registry. - Each public key MUST include
id
andtype
properties, and exactly one value property. The array of public keys SHOULD NOT contain duplicate entries with the same id and different value properties with different formats. - Each public key MUST include a
controller
property, which identifies the controller of the corresponding private key. - A registry of key types and formats is available in Registries .
When creating a publicKey
the following fields must be included (empty if not needed):
id
owner
type
- A valid key-value (exactly one) encryption method as the key, and the public key corresponding to that encrpytion method, as the value.
let d = new DidDoc("my_context", "my_id")
.setPublicKey({
"id": "did:sov:WRfXPg8dantKVubE3HX8pw#key-1",
"type": "Ed25519VerificationKey2018",
"owner": "NEW_OWNER",
"publicKeyBase58": "~P7F3BNs5VmQ6eVpwkNKJ5D"
});
pub fn set_service(self, s: JsValue) -> DidDoc
[src]
Set Service
As w3's documentation explains:
A service endpoint may represent any type of service the subject wishes to advertise, including decentralized identity management services for further discovery, authentication, authorization, or interaction.
The rules for service endpoints are:
- A DID Document MAY include a service property.
- The value of the service property should be an array of service endpoints.
- Each service endpoint must include id, type, and serviceEndpoint properties, and MAY include additional properties.
- The service endpoint protocol SHOULD be published in an open standard specification.
- The value of the serviceEndpoint property MUST be a JSON-LD object or a valid URI conforming to RFC3986 and normalized according to the rules in section 6 of RFC3986 and to any normalization rules in its applicable URI scheme specification.
let d = new DidDoc("my_context", "my_id")
.setService({
"id": "did:ser:18y34b91c612c4123gwrh45y",
"type": "agent",
"serviceEndpoint": "https://agents.danubeclouds.com/agent/WRfXPg8dantKVubE3HX8pw"
});
pub fn set_proof(self, proof: JsValue) -> DidDoc
[src]
Set Proof
A proof on a DID Document is cryptographic proof of the integrity of the DID Document according to either:
- The subject as defined as a service endpoint, or if not present:
- The delegate as a generic DID parameter.
This proof is NOT proof of the binding between a DID and a DID Document.
The rules for a proof are:
- A DID Document MAY have exactly one property representing a proof.
- The key for this property MUST be proof.
- The value of this key MUST be a valid JSON-LD proof as defined by Linked Data Proofs.
let d = new DidDoc("my_context", "my_id")
.setProof({
"type": "RsaSignature2018",
"created": "2018-06-17T10:03:48Z",
"verificationMethod": "did:example:ebfeb1276e12ec21f712ebc6f1c#k1",
"signatureValue": "pY9...Cky6Ed = "
});
pub fn set_created(self, c: String) -> DidDoc
[src]
Set Created
Standard metadata for identifier records includes a timestamp of the original creation. The rules for including a creation timestamp are:
- A DID Document MUST have zero or one property representing a creation timestamp. It is RECOMMENDED to include this property.
- The key for this property MUST be created.
- The value of this key MUST be a valid XML datetime value as defined in section 3.3.7 of W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes [XMLSCHEMA11-2].
- This datetime value MUST be normalized to UTC 00:00 as indicated by the trailing "Z".
- Method specifications that rely on DLTs SHOULD require time values that are after the known "median time past" (defined in Bitcoin BIP 113), when the DLT supports such a notion.
let d = new DidDoc("my_context", "my_id")
.setCreated("2002-10-10T17:00:00Z");
pub fn set_updated(self, u: String) -> DidDoc
[src]
Set Updated
Standard metadata for identifier records includes a timestamp of the most recent change. The rules for including an updated timestamp are:
- A DID Document MUST have zero or one property representing an updated timestamp. It is RECOMMENDED to include this property.
- The key for this property MUST be updated.
- The value of this key MUST be a valid XML datetime value as defined in section 3.3.7 of W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes [XMLSCHEMA11-2].
- This datetime value MUST be normalized to UTC 00:00 as indicated by the trailing "Z".
- Method specifications that rely on DLTs SHOULD require time values that are after the known "median time past" (defined in Bitcoin BIP 113), when the DLT supports such a notion.
let d = new DidDoc("my_context", "my_id")
.setUpdated("2016-10-17T02:41:00Z");
pub fn get_context(&self) -> JsValue
[src]
Get Context
let dContext = dd.getContext();
pub fn get_id(&self) -> JsValue
[src]
Get DID Identification
let dId = dd.getId();
pub fn get_authentication(&self) -> JsValue
[src]
Get DID Authentication
let dAuthentication = dd.getAuthentication();
pub fn get_public_key(&self) -> JsValue
[src]
Get Public Key
let dPublicKey = dd.getPublicKey();
pub fn get_service(&self) -> JsValue
[src]
Get Services
let dServices = dd.getService();
pub fn get_proof(&self) -> JsValue
[src]
Get Proof
let dProof = dd.getProof();
pub fn get_created(&self) -> JsValue
[src]
Get DID Creation (Created)
let dCreated = dd.getCreated();
pub fn get_updated(&self) -> JsValue
[src]
Get DID last update (Updated)
let dUpdated = dd.getUpdated();
pub fn add_context(self, c: String) -> DidDoc
[src]
Add Context
let d = new DidDoc("my_context", "my_id")
.addContext("my_second_context");
pub fn add_authentication(self, json_auth: JsValue) -> DidDoc
[src]
Add Authentication
let d = new DidDoc("my_context", "my_id")
.addAuthentication({
"id": "did:example:ebfeb1276e12ec21f712ebc6f1c",
"type": "OpenIdConnectVersion1.0Service",
"owner": "OWNER!",
"PublicKeyBase58": "H3C2AVvLMv6gmMNam3uVAjZpfkcJCwDwnZn6z3wXmqPV"
});
pub fn add_public_key(self, json_publickey: JsValue) -> DidDoc
[src]
Add Public Key
let d = new DidDoc("my_context", "my_id")
.addPublicKey({
"id": "did:sov:WRfXPg8dantKVubE3HX8pw#key-1",
"type": "Ed25519VerificationKey2018",
"owner": "", // empty `owner`
"publicKeyBase58": "~P7F3BNs5VmQ6eVpwkNKJ5D"
});
pub fn add_service(self, json_service: JsValue) -> DidDoc
[src]
Add Service
let d = new DidDoc("my_context", "my_id")
.addService({
"id": "did:ser:18y34b91c612c4123gwrh45y",
"type": "agent",
"serviceEndpoint": "https://agents.danubeclouds.com/agent/WRfXPg8dantKVubE3HX8pw"
})
.setService({
"id": "did:ser:18y34b91c612c4123gwrh45y",
"type": "agent",
"serviceEndpoint": "https://agents.danubeclouds.com/agent/WRfXPg8dantKVubE3HX8pw"
});
pub fn to_json(&self) -> JsValue
[src]
Generate JSON from Did Document
let my_json = dd.toJSON();
Trait Implementations
impl From<DidDoc> for JsValue
[src]
impl FromWasmAbi for DidDoc
[src]
type Abi = u32
The wasm ABI type that this converts from when coming back out from the ABI boundary. Read more
unsafe fn from_abi(js: u32) -> Self
[src]
impl IntoWasmAbi for DidDoc
[src]
type Abi = u32
The wasm ABI type that this converts into when crossing the ABI boundary. Read more
fn into_abi(self) -> u32
[src]
impl OptionFromWasmAbi for DidDoc
[src]
impl OptionIntoWasmAbi for DidDoc
[src]
impl RefFromWasmAbi for DidDoc
[src]
type Abi = u32
The wasm ABI type references to Self
are recovered from.
type Anchor = Ref<'static, DidDoc>
The type that holds the reference to Self
for the duration of the invocation of the function that has an &Self
parameter. This is required to ensure that the lifetimes don't persist beyond one function call, and so that they remain anonymous. Read more
unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor
[src]
impl RefMutFromWasmAbi for DidDoc
[src]
type Abi = u32
Same as RefFromWasmAbi::Abi
type Anchor = RefMut<'static, DidDoc>
Same as RefFromWasmAbi::Anchor
unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor
[src]
impl WasmDescribe for DidDoc
[src]
Auto Trait Implementations
impl RefUnwindSafe for DidDoc
impl !Send for DidDoc
impl !Sync for DidDoc
impl Unpin for DidDoc
impl UnwindSafe for DidDoc
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ReturnWasmAbi for T where
T: IntoWasmAbi,
[src]
T: IntoWasmAbi,
type Abi = <T as IntoWasmAbi>::Abi
Same as IntoWasmAbi::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,