diff --git a/src/onepassword/build_number.py b/src/onepassword/build_number.py index 619d0b48..253a7b57 100644 --- a/src/onepassword/build_number.py +++ b/src/onepassword/build_number.py @@ -1 +1 @@ -SDK_BUILD_NUMBER = "0010401" +SDK_BUILD_NUMBER = "0010500" diff --git a/src/onepassword/lib/aarch64/libop_uniffi_core.dylib b/src/onepassword/lib/aarch64/libop_uniffi_core.dylib index c8e37960..a9ca5b88 100755 Binary files a/src/onepassword/lib/aarch64/libop_uniffi_core.dylib and b/src/onepassword/lib/aarch64/libop_uniffi_core.dylib differ diff --git a/src/onepassword/lib/aarch64/libop_uniffi_core.so b/src/onepassword/lib/aarch64/libop_uniffi_core.so index 8eff2c25..b79a4a15 100755 Binary files a/src/onepassword/lib/aarch64/libop_uniffi_core.so and b/src/onepassword/lib/aarch64/libop_uniffi_core.so differ diff --git a/src/onepassword/lib/x86_64/libop_uniffi_core.dylib b/src/onepassword/lib/x86_64/libop_uniffi_core.dylib index 3509fb5e..c1511ad1 100755 Binary files a/src/onepassword/lib/x86_64/libop_uniffi_core.dylib and b/src/onepassword/lib/x86_64/libop_uniffi_core.dylib differ diff --git a/src/onepassword/lib/x86_64/libop_uniffi_core.so b/src/onepassword/lib/x86_64/libop_uniffi_core.so index c8c569ae..0710c986 100755 Binary files a/src/onepassword/lib/x86_64/libop_uniffi_core.so and b/src/onepassword/lib/x86_64/libop_uniffi_core.so differ diff --git a/src/onepassword/lib/x86_64/op_uniffi_core.dll b/src/onepassword/lib/x86_64/op_uniffi_core.dll index 5e6739db..dc15b3e0 100644 Binary files a/src/onepassword/lib/x86_64/op_uniffi_core.dll and b/src/onepassword/lib/x86_64/op_uniffi_core.dll differ diff --git a/src/onepassword/secrets.py b/src/onepassword/secrets.py index 580ca888..50503bd7 100644 --- a/src/onepassword/secrets.py +++ b/src/onepassword/secrets.py @@ -3,6 +3,7 @@ from .core import _invoke, _invoke_sync from json import loads from .iterator import SDKIterator +from .types import GeneratePasswordResponse class Secrets: @@ -46,3 +47,17 @@ def validate_secret_reference(secret_reference): } } ) + + @staticmethod + def generate_password(recipe): + response = _invoke_sync( + { + "invocation": { + "parameters": { + "name": "GeneratePassword", + "parameters": {"recipe": recipe.model_dump(by_alias=True)}, + } + } + } + ) + return GeneratePasswordResponse.model_validate_json(response) diff --git a/src/onepassword/types.py b/src/onepassword/types.py index bea42a4f..a0d10380 100644 --- a/src/onepassword/types.py +++ b/src/onepassword/types.py @@ -6,7 +6,19 @@ from enum import Enum from pydantic import BaseModel, ConfigDict, Field -from typing import List, Literal, Optional +from typing import List, Literal, Optional, Union + + +class GeneratePasswordResponse(BaseModel): + """ + For future use, if we want to return more information about the generated password. + Currently, it only returns the password itself. + """ + + password: str + """ + The generated password. + """ class ItemCategory(str, Enum): @@ -40,6 +52,7 @@ class ItemFieldType(str, Enum): TEXT = "Text" CONCEALED = "Concealed" CREDITCARDTYPE = "CreditCardType" + CREDITCARDNUMBER = "CreditCardNumber" PHONE = "Phone" URL = "Url" TOTP = "Totp" @@ -273,3 +286,100 @@ class VaultOverview(BaseModel): """ The vault's title """ + + +class PasswordRecipeMemorableInner(BaseModel): + """ + Generated type representing the anonymous struct variant `Memorable` of the `PasswordRecipe` Rust enum + """ + + model_config = ConfigDict(populate_by_name=True) + + separator_type: SeparatorType = Field(alias="separatorType") + """ + The type of separator between chunks. + """ + capitalize: bool + """ + Uppercase one randomly selected chunk. + """ + word_list_type: WordListType = Field(alias="wordListType") + """ + The type of word list used. + """ + word_count: int = Field(alias="wordCount") + """ + The number of "words" (words or syllables). + """ + + +class PasswordRecipePinInner(BaseModel): + """ + Generated type representing the anonymous struct variant `Pin` of the `PasswordRecipe` Rust enum + """ + + length: int + """ + Number of digits in the PIN. + """ + + +class PasswordRecipeRandomInner(BaseModel): + """ + Generated type representing the anonymous struct variant `Random` of the `PasswordRecipe` Rust enum + """ + + model_config = ConfigDict(populate_by_name=True) + + include_digits: bool = Field(alias="includeDigits") + """ + Include at least one digit in the password. + """ + include_symbols: bool = Field(alias="includeSymbols") + """ + Include at least one symbol in the password. + """ + length: int + """ + The length of the password. + """ + + +class PasswordRecipeTypes(str, Enum): + MEMORABLE = "Memorable" + PIN = "Pin" + RANDOM = "Random" + + +class PasswordRecipeMemorable(BaseModel): + type: Literal[PasswordRecipeTypes.MEMORABLE] = PasswordRecipeTypes.MEMORABLE + parameters: PasswordRecipeMemorableInner + + +class PasswordRecipePin(BaseModel): + type: Literal[PasswordRecipeTypes.PIN] = PasswordRecipeTypes.PIN + parameters: PasswordRecipePinInner + + +class PasswordRecipeRandom(BaseModel): + type: Literal[PasswordRecipeTypes.RANDOM] = PasswordRecipeTypes.RANDOM + parameters: PasswordRecipeRandomInner + + +PasswordRecipe = Union[PasswordRecipeMemorable, PasswordRecipePin, PasswordRecipeRandom] + + +class SeparatorType(str, Enum): + DIGITS = "digits" + DIGITSANDSYMBOLS = "digitsAndSymbols" + SPACES = "spaces" + HYPHENS = "hyphens" + UNDERSCORES = "underscores" + PERIODS = "periods" + COMMAS = "commas" + + +class WordListType(str, Enum): + FULLWORDS = "fullWords" + SYLLABLES = "syllables" + THREELETTERS = "threeLetters" diff --git a/src/release/RELEASE-NOTES b/src/release/RELEASE-NOTES index 0f48c2b1..346198b1 100644 --- a/src/release/RELEASE-NOTES +++ b/src/release/RELEASE-NOTES @@ -1,2 +1,3 @@ -The v0.1.4 release of the Python SDK brings: -* Support for validating secret references. You can now check that a secret reference is formatted correctly without having to resolve it or even authenticate, using the 'ValidateSecretReference' function. +The v0.1.5 release of the Python SDK brings: +* Support for Password Generation. You can now generate different type of passwords with `Secrets.GeneratePassword`. +* Support for the credit card number field type. \ No newline at end of file diff --git a/version.py b/version.py index 11e8a1e8..18df7134 100644 --- a/version.py +++ b/version.py @@ -1 +1 @@ -SDK_VERSION = "0.1.4" +SDK_VERSION = "0.1.5"