sosecrets-core


Namesosecrets-core JSON
Version 1.0.20 PyPI version JSON
download
home_pagehttp://github.com/jymchng/sosecrets-core
SummarySimple Secret Primitive for Python
upload_time2023-05-31 18:16:00
maintainer
docs_urlNone
authorJim Chng
requires_python
licenseMIT
keywords secrets security secrets-management
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # sosecrets-core

![https://img.shields.io/github/actions/workflow/status/jymchng/sosecrets-core/testing.yml](https://img.shields.io/github/actions/workflow/status/jymchng/sosecrets-core/testing.yml) ![https://img.shields.io/pypi/pyversions/sosecrets-core](https://img.shields.io/pypi/pyversions/sosecrets-core) ![https://img.shields.io/pypi/dm/sosecrets-core](https://img.shields.io/pypi/dm/sosecrets-core)

Version: 1.0.20

This Repo is a Cython implementation of a `Secret` class that allows you to hide a value or function behind a layer of security.

The idea is that you can expose the secret value only a limited number of times, and only through a function call that checks the current exposure count against a maximum exposure count.

The `Secret` class has four attributes:

* `inner_secret`: a private attribute that stores the actual secret value or function.
* `expose_count`: a readonly attribute that keeps track of how many times the secret has been exposed.
* `max_expose_count`: a public (read and write) attribute that sets the maximum number of times the secret can be exposed. If set to any negative integers, there is no limit to the number of exposures.
* `apply`: a public method that applies a given function to the exposed secret and returns a new `Secret` object with the result.

## API

### Secret

`Secret[T]` is generic over any type `T`.

A class representing a secret value with controlled exposure.

> `__init__(self, value: Optional[T] = ..., *, func: Optional[Callable[..., T]] = ..., func_args: Tuple[Any, ...] = ..., func_kwargs: Dict[str, Any] = ..., max_expose_count: int = ...) -> Secret[T]`

Initialize a `Secret` object.

Notes:
1. `Secret` is not thread-safe, because `expose_count` is not atomically-mutated.

* value: The initial value of the `Secret` object. If provided, it takes precedence over `func`.
* func: A function used to generate the initial value of the `Secret` object. Ignored if value is provided.
* func_args: Positional arguments to pass to the `func` function.
* func_kwargs: Keyword arguments to pass to the `func` function.
* max_expose_count: The maximum number of times the `Secret` object can be exposed. Initialized to -1 for unlimited.

Raises:

* ValueError: If both `value` and `func` arguments are provided.

### `Secret.expose_secret()`

Exposes the secret value.

> `expose_secret(self) -> T`

Returns:

The inner secret value.

Raises:

* AttributeError: If the `Secret` object has reached the maximum exposure count.

### `Secret.apply(...)`

Apply a function to the inner secret value and return a new `Secret` object.

> `apply(self, func: Callable[[Any, ...], U], *, func_args: Tuple[Any, ...] = ..., func_kwargs: Dict[str, Any] = ...) -> Secret[U]`

* func: The function to apply to the inner secret value.
* func_args: Positional arguments to pass to the `func` function.
* func_kwargs: Keyword arguments to pass to the `func` function.

Returns:

A new `Secret` object with the result of applying the function to the inner secret value.

## License
This code is released under the MIT License.

            

Raw data

            {
    "_id": null,
    "home_page": "http://github.com/jymchng/sosecrets-core",
    "name": "sosecrets-core",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "secrets security secrets-management",
    "author": "Jim Chng",
    "author_email": "jimchng@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/8d/80/c6609e4c3ae3fb208f9fcbf7215e999a09baa69d7fd501e7cefdf8f39c30/sosecrets_core-1.0.20.tar.gz",
    "platform": null,
    "description": "# sosecrets-core\r\n\r\n![https://img.shields.io/github/actions/workflow/status/jymchng/sosecrets-core/testing.yml](https://img.shields.io/github/actions/workflow/status/jymchng/sosecrets-core/testing.yml) ![https://img.shields.io/pypi/pyversions/sosecrets-core](https://img.shields.io/pypi/pyversions/sosecrets-core) ![https://img.shields.io/pypi/dm/sosecrets-core](https://img.shields.io/pypi/dm/sosecrets-core)\r\n\r\nVersion: 1.0.20\r\n\r\nThis Repo is a Cython implementation of a `Secret` class that allows you to hide a value or function behind a layer of security.\r\n\r\nThe idea is that you can expose the secret value only a limited number of times, and only through a function call that checks the current exposure count against a maximum exposure count.\r\n\r\nThe `Secret` class has four attributes:\r\n\r\n* `inner_secret`: a private attribute that stores the actual secret value or function.\r\n* `expose_count`: a readonly attribute that keeps track of how many times the secret has been exposed.\r\n* `max_expose_count`: a public (read and write) attribute that sets the maximum number of times the secret can be exposed. If set to any negative integers, there is no limit to the number of exposures.\r\n* `apply`: a public method that applies a given function to the exposed secret and returns a new `Secret` object with the result.\r\n\r\n## API\r\n\r\n### Secret\r\n\r\n`Secret[T]` is generic over any type `T`.\r\n\r\nA class representing a secret value with controlled exposure.\r\n\r\n> `__init__(self, value: Optional[T] = ..., *, func: Optional[Callable[..., T]] = ..., func_args: Tuple[Any, ...] = ..., func_kwargs: Dict[str, Any] = ..., max_expose_count: int = ...) -> Secret[T]`\r\n\r\nInitialize a `Secret` object.\r\n\r\nNotes:\r\n1. `Secret` is not thread-safe, because `expose_count` is not atomically-mutated.\r\n\r\n* value: The initial value of the `Secret` object. If provided, it takes precedence over `func`.\r\n* func: A function used to generate the initial value of the `Secret` object. Ignored if value is provided.\r\n* func_args: Positional arguments to pass to the `func` function.\r\n* func_kwargs: Keyword arguments to pass to the `func` function.\r\n* max_expose_count: The maximum number of times the `Secret` object can be exposed. Initialized to -1 for unlimited.\r\n\r\nRaises:\r\n\r\n* ValueError: If both `value` and `func` arguments are provided.\r\n\r\n### `Secret.expose_secret()`\r\n\r\nExposes the secret value.\r\n\r\n> `expose_secret(self) -> T`\r\n\r\nReturns:\r\n\r\nThe inner secret value.\r\n\r\nRaises:\r\n\r\n* AttributeError: If the `Secret` object has reached the maximum exposure count.\r\n\r\n### `Secret.apply(...)`\r\n\r\nApply a function to the inner secret value and return a new `Secret` object.\r\n\r\n> `apply(self, func: Callable[[Any, ...], U], *, func_args: Tuple[Any, ...] = ..., func_kwargs: Dict[str, Any] = ...) -> Secret[U]`\r\n\r\n* func: The function to apply to the inner secret value.\r\n* func_args: Positional arguments to pass to the `func` function.\r\n* func_kwargs: Keyword arguments to pass to the `func` function.\r\n\r\nReturns:\r\n\r\nA new `Secret` object with the result of applying the function to the inner secret value.\r\n\r\n## License\r\nThis code is released under the MIT License.\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Simple Secret Primitive for Python",
    "version": "1.0.20",
    "project_urls": {
        "Homepage": "http://github.com/jymchng/sosecrets-core"
    },
    "split_keywords": [
        "secrets",
        "security",
        "secrets-management"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "def45bd6f23995e13bea13468480f106bb35564c0a45495df64a5228f12844b1",
                "md5": "1ca8fd3b81ec21e4e6ec78432022e5e6",
                "sha256": "01d378da2d4edc098497be147b1af313b64d78172de6fbc557ff08087638e677"
            },
            "downloads": -1,
            "filename": "sosecrets_core-1.0.20-cp310-cp310-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "1ca8fd3b81ec21e4e6ec78432022e5e6",
            "packagetype": "bdist_wheel",
            "python_version": "cp310",
            "requires_python": null,
            "size": 63842,
            "upload_time": "2023-05-31T18:15:58",
            "upload_time_iso_8601": "2023-05-31T18:15:58.355719Z",
            "url": "https://files.pythonhosted.org/packages/de/f4/5bd6f23995e13bea13468480f106bb35564c0a45495df64a5228f12844b1/sosecrets_core-1.0.20-cp310-cp310-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8d80c6609e4c3ae3fb208f9fcbf7215e999a09baa69d7fd501e7cefdf8f39c30",
                "md5": "25ee7a9ab03709bff293b35e7f36ede4",
                "sha256": "b0bebf70e2009962117d807f21e8d59cb7546c4c2ddd3d801b1a16a66a1f63dd"
            },
            "downloads": -1,
            "filename": "sosecrets_core-1.0.20.tar.gz",
            "has_sig": false,
            "md5_digest": "25ee7a9ab03709bff293b35e7f36ede4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 46211,
            "upload_time": "2023-05-31T18:16:00",
            "upload_time_iso_8601": "2023-05-31T18:16:00.825364Z",
            "url": "https://files.pythonhosted.org/packages/8d/80/c6609e4c3ae3fb208f9fcbf7215e999a09baa69d7fd501e7cefdf8f39c30/sosecrets_core-1.0.20.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-31 18:16:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "jymchng",
    "github_project": "sosecrets-core",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "sosecrets-core"
}
        
Elapsed time: 0.45766s