Code Monkey home page Code Monkey logo

Comments (4)

npmccallum avatar npmccallum commented on August 25, 2024

This might get tricky around the compact conversion functions. I definitely want:

import jose
jose.to_compact(...)
jose.from_compact(...)

from pyjose.

tiran avatar tiran commented on August 25, 2024

There are multiple ways to accomplish your goal. The simplest way is to rename the C extension _jose and then introduce a jose package and modules:

jose/__init__.py
jose/_jose.so
jose/jwk.py

Each module imports the function it is interested in:

# jwk.py
from ._jose import jwk_generate as generate

or wraps the functions:

# jwk.py
from . import _jose

def generate(jwk):
    return _jose.jwk_generate(jwk)

from pyjose.

npmccallum avatar npmccallum commented on August 25, 2024

Regarding module layout, I'm thinking:

jose.jwk.generate()
jose.jwk.clean()
jose.jwk.allowed()
jose.jwk.thumbprint()
jose.jwk.exchange()

jose.jws.sign()
jose.jws.verify()
jose.jws.merge_header()

jose.jwe.wrap()
jose.jwe.encrypt()
jose.jwe.unwrap()
jose.jwe.decrypt()
jose.jwe.merge_header()

jose.compact.dumps()
jose.compact.loads()

The main change here is that jose_to_compact() and jose_from_compact() become just serialization functions for a JWS/JWE object. This mimics the json module. The base jose module would be empty.

I think this layout should be easy to make. Something like:

jose/__init__.py
jose/jwk.so
jose/jws.so
jose/jwe.so
jose/compact.so

Thoughts?

from pyjose.

tiran avatar tiran commented on August 25, 2024

I advice against multiple shared libraries. It's a common practice to have an internal C module and do the rest in Python -- one internal shared library and a couple of Python modules as facade.

It's easier, faster and simpler for development, too.In Python 2 a C extension does not have the ability to support sub-namespaces in packages. You can't easily share data between C extensions, e.g. exception types. Cython makes it a bit easier but it is still hacky.

Layout

jose/__init__.py
jose/_jose.so
jose/jwk.py
jose/jws.py
jose/jwe.py
jose/compact.py

from pyjose.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.