ZDCShareItem

@interface ZDCShareItem

A ShareItem encapsulates the permissions for a particular resource. Typically this means the permissions for another user.

Recall that ZeroDark.cloud uses cryptography to enforce permissions. In order to read the content of a node, you need to know the node’s encryptionKey. (And every node has a different randomly generated encryptionKey.) Each encryptionKey is wrapped using the publicKey of a resource with read permissions for the node. So each ShareItem includes permissions, and a wrapped key.

  • Creates an empty shareItem.

    You’ll want to add permissions, but you don’t need to worry about setting the key. The framework will handle setting the key for you.

    Declaration

    Objective-C

    - (nonnull instancetype)init;

    Swift

    init()
  • Creates a shareItem by parsing the given dictionary.

    Note

    The use of this method automatically sets the canAddKey property to false.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithDictionary:(nullable NSDictionary *)dictionary;

    Swift

    init(dictionary: [AnyHashable : Any]?)
  • Returns the raw version of the shareList, as it would appear in the cloud.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSDictionary *_Nonnull rawDictionary;

    Swift

    var rawDictionary: [AnyHashable : Any] { get }
  • The permsissions for the resource. Permissions are represented as a string, where each character in the string has a special meaning.

    There are a number of permissions constants:

  • ZDCSharePermission_Read
  • ZDCSharePermission_Write
  • ZDCSharePermission_Share
  • ZDCSharePermission_RecordsOnly
  • ZDCSharePermission_LeafsOnly
  • ZDCSharePermission_UserOnly
  • ZDCSharePermission_WriteOnce
  • ZDCSharePermission_BurnIfSender

  • Declaration

    Objective-C

    @property (readwrite, copy, nonatomic) NSString *_Nonnull permissions;

    Swift

    var permissions: String { get set }
  • key

    The wrapped encryptionKey that’s being used to encrypt the node’s content.

    Note

    You don’t need to worry about setting this property. The framework will automatically generate the key for you. You really only need to worry about setting the permissions.

    The node.encryptionKey is wrapped using the resource’s public key. Thus the corresponding private key is needed to unwrap the node.encryptionKey. And since only the target resource has access to their private key, only the target resource will be able to decrypt this wrapped key.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSData *key;

    Swift

    var key: Data? { get set }
  • Additional security measure to prevent against a possible attack.

    The framework has the ability to automatically create & set the ZDCShareItem.key property. However it will only do so if:

    • the canAddKey property is true
    • the permissions include ZDCSharePermission_Read

    The canAddKey property only gets set to true if you explicitly add read permission. The canAddKey property doesn’t get modified as a result of pulling down information from the cloud.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL canAddKey;

    Swift

    var canAddKey: Bool { get set }
  • Returns YES if the given permission is included in the set of permissions.

    Declaration

    Objective-C

    - (BOOL)hasPermission:(ZDCSharePermission)perm;

    Swift

    func hasPermission(_ perm: ZDCSharePermission) -> Bool
  • Adds the given permission to the set of permissions (if it’s not already included).

    Warning

    Attempting to invoke this method on an immutable instance will result in an exception. Check to see if your node is immutable via inherited property -[ZDCObject isImmutable]. If the node is immutable, you should make a copy of the node, and then modify the copy.

    Declaration

    Objective-C

    - (void)addPermission:(ZDCSharePermission)perm;

    Swift

    func addPermission(_ perm: ZDCSharePermission)
  • Removes the given permission from the set of permissions (if it’s already included).

    Warning

    Attempting to invoke this method on an immutable instance will result in an exception. Check to see if your node is immutable via inherited property -[ZDCObject isImmutable]. If the node is immutable, you should make a copy of the node, and then modify the copy.

    Declaration

    Objective-C

    - (void)removePermission:(ZDCSharePermission)perm;

    Swift

    func removePermission(_ perm: ZDCSharePermission)
  • Returns true if the parameter is of type ZDCShareItem, and all values are the same.

    Declaration

    Objective-C

    - (BOOL)isEqual:(nullable id)another;

    Swift

    func isEqual(_ another: Any?) -> Bool
  • Returns true if all values are the same.

    Declaration

    Objective-C

    - (BOOL)isEqualToShareItem:(nonnull ZDCShareItem *)another;

    Swift

    func isEqual(to another: ZDCShareItem) -> Bool