findmy#

A package providing everything you need to work with Apple’s FindMy network.

Submodules#

Classes#

FindMyAccessory

A findable Find My-accessory using official key rollover.

KeyPair

A private-public keypair for a trackable FindMy accessory.

Package Contents#

class findmy.FindMyAccessory(*, master_key: bytes, skn: bytes, sks: bytes, paired_at: datetime.datetime, name: str | None = None, model: str | None = None, identifier: str | None = None)#

Bases: RollingKeyPairSource, findmy.util.abc.Serializable[FindMyAccessoryMapping]

Inheritance diagram of findmy.FindMyAccessory

A findable Find My-accessory using official key rollover.

property master_key: bytes#

The private master key.

property skn: bytes#

The SKN for the primary key.

property sks: bytes#

The SKS for the secondary key.

property paired_at: datetime.datetime#

Date and time at which this accessory was paired with an Apple account.

property name: str | None#

Name of this accessory.

property model: str | None#

Model string of this accessory, as provided by the manufacturer.

property identifier: str | None#

Internal identifier of this accessory.

property interval: datetime.timedelta#

Official FindMy accessory rollover interval (15 minutes).

keys_at(ind: int | datetime.datetime) set[findmy.keys.KeyPair]#

Get the potential primary and secondary keys active at a certain time or index.

classmethod from_plist(plist: str | pathlib.Path | dict | bytes | IO[bytes], *, name: str | None = None) FindMyAccessory#

Create a FindMyAccessory from a .plist file dumped from the FindMy app.

to_json(path: str | pathlib.Path | None = None, /) FindMyAccessoryMapping#

Export the current state of the object as a JSON-serializable dictionary.

If an argument is provided, the output will also be written to that file.

The output of this method is guaranteed to be JSON-serializable, and passing the return value of this function as an argument to Serializable.from_json() will always result in an exact copy of the internal state as it was when exported.

You are encouraged to save and load object states to and from disk whenever possible, to prevent unnecessary API calls or otherwise unexpected behavior.

classmethod from_json(val: str | pathlib.Path | FindMyAccessoryMapping, /) FindMyAccessory#

Restore state from a previous Closable.to_json() export.

If given a str or Path, it must point to a json file from Serializable.to_json(). Otherwise, it should be the Mapping itself.

See Serializable.to_json() for more information.

class findmy.KeyPair(private_key: bytes, key_type: KeyType = KeyType.UNKNOWN, name: str | None = None)#

Bases: HasPublicKey, findmy.util.abc.Serializable[KeyPairMapping]

Inheritance diagram of findmy.KeyPair

A private-public keypair for a trackable FindMy accessory.

property key_type: KeyType#

Type of this key.

property name: str | None#

Name of this KeyPair.

classmethod new() KeyPair#

Generate a new random KeyPair().

classmethod from_b64(key_b64: str) KeyPair#

Import an existing KeyPair() from its base64-encoded representation.

Same format as returned by KeyPair.private_key_b64().

property private_key_bytes: bytes#

Return the private key as bytes.

property private_key_b64: str#

Return the private key as a base64-encoded string.

Can be re-imported using KeyPair.from_b64().

property adv_key_bytes: bytes#

Return the advertised (public) key as bytes.

to_json(dst: str | pathlib.Path | None = None, /) KeyPairMapping#

Export the current state of the object as a JSON-serializable dictionary.

If an argument is provided, the output will also be written to that file.

The output of this method is guaranteed to be JSON-serializable, and passing the return value of this function as an argument to Serializable.from_json() will always result in an exact copy of the internal state as it was when exported.

You are encouraged to save and load object states to and from disk whenever possible, to prevent unnecessary API calls or otherwise unexpected behavior.

classmethod from_json(val: str | pathlib.Path | KeyPairMapping, /) KeyPair#

Restore state from a previous Closable.to_json() export.

If given a str or Path, it must point to a json file from Serializable.to_json(). Otherwise, it should be the Mapping itself.

See Serializable.to_json() for more information.

dh_exchange(other_pub_key: cryptography.hazmat.primitives.asymmetric.ec.EllipticCurvePublicKey) bytes#

Do a Diffie-Hellman key exchange using another EC public key.

__repr__() str#