Skip to content

snarfed/self-labeler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

self-labeler

NOT CURRENTLY RUNNING.

A Bluesky/AT Protocol labeler aka mod service that emits custom self-labels (except global labels) that already exist inside records.

bsky.app/profile/self-labeler.snarfed.org did:plc:4wgmwsq4t3tg55ffl3r7ocec

Apart from the global labels built into bsky.app, other custom self-labels are often not displayed or handled by clients. This surfaces those labels and makes them visible.

Background discussion.

License: This project is placed in the public domain. You may also use it under the CC0 License.

Setup

  • Make a new Bluesky account.
  • Convert it to a labeler repo by adding an #atproto_labeler service endpoint and #atproto_label signing key:
    • npm install @skyware/labeler
    • npx @skyware/labeler setup
  • Convert the base64 raw bytes private key that @skyware/labeler setup prints into PEM:
    $ node
    const { fromBytes, toBytes } = await import("@atcute/cbor");
    fromBytes({'$bytes': '[base64 byte string]'})
    Uint8Array(32) [...]
    
    $ python
    privbytes = bytes([...])  # from above
    
    from cryptography.hazmat.primitives.asymmetric import ec
    privkey = ec.derive_private_key(int.from_bytes(privbytes), ec.SECP256K1())
    
    # `EllipticCurvePublicKey.from_encoded_point` is also close, but there's no corresponding `EllipticCurvePrivateKey.from_encoded_point`
    
    # now, sign something and check that it verifies
    signed = arroba.util.sign({'x': 'y'}, privkey)
    did_doc = did.resolve('did:plc:4wgmwsq4t3tg55ffl3r7ocec')  # self-labeler.snarfed.org
    pubkey = did.decode_did_key(did_doc['verificationMethod'][1]['publicKeyMultibase'])
    arroba.util.verify_sig(signed, pubkey)
    # should be True
    
    # PEM-encode private key
    from cryptography.hazmat.primitives import serialization
    with open('privkey.atproto_label.pem', 'wb') as f:
        f.write(privkey.private_bytes(
            encoding=serialization.Encoding.PEM,
            format=serialization.PrivateFormat.PKCS8,
            encryption_algorithm=serialization.NoEncryption(),
        ))
    

Declaration record

The labeler declaration record is at://did:plc:4wgmwsq4t3tg55ffl3r7ocec/app.bsky.labeler.service/self. To add a new label value definition to it, run npx @skyware/labeler add. Docs.

About

A Bluesky/AT Protocol mod service (labeler) that emits custom self-labels

Resources

License

Stars

Watchers

Forks

Languages