Magic.Token (magic_admin v0.6.0) View Source

Provides methods to interact with the DID Token.

Link to this section Summary

Types

A map of claims made by the DID Token

A DID Token generated by a Magic user on the client-side.

Decentralized identifier which encapsulates a unique user ID

Cryptographic public address of the Magic User.

Functions

Parses public_address and extracts issuer

Decodes a DID Token from a Base64 string into a tuple of its individual components: proof and claim. This method allows you decode the DID Token and inspect the token

Parses did_token and extracts issuer

Parses did_token and extracts cryptographic public_address

Validates did_token

Link to this section Types

Specs

claim() :: %{
  add: String.t(),
  aud: String.t(),
  ext: integer(),
  iat: integer(),
  iss: String.t(),
  nbf: integer(),
  sub: String.t(),
  tid: String.t()
}

A map of claims made by the DID Token

Specs

did_token() :: String.t()

A DID Token generated by a Magic user on the client-side.

Specs

issuer() :: String.t()

Decentralized identifier which encapsulates a unique user ID

Specs

public_address() :: String.t()

Cryptographic public address of the Magic User.

Link to this section Functions

Link to this function

construct_issuer_with_public_address(public_address)

View Source

Specs

construct_issuer_with_public_address(public_address()) :: issuer()

Parses public_address and extracts issuer

Returns issuer info

Specs

decode!(did_token()) :: %{
  proof: String.t(),
  claim: claim(),
  message: String.t()
}

Decodes a DID Token from a Base64 string into a tuple of its individual components: proof and claim. This method allows you decode the DID Token and inspect the token

Returns A map containing proof, claim and message or raise an error

Specs

get_issuer(did_token()) :: issuer()

Parses did_token and extracts issuer

Returns issuer info

Link to this function

get_public_address(did_token)

View Source

Specs

get_public_address(did_token()) :: public_address()

Parses did_token and extracts cryptographic public_address

Returns cryptographic public address of the Magic User who generated the supplied DID Token.

Specs

validate!(did_token()) :: true

Validates did_token

Returns true or raises an error