diff --git a/src/onepassword/lib/aarch64/libop_uniffi_core.dylib b/src/onepassword/lib/aarch64/libop_uniffi_core.dylib index c8e3796..3dc273d 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 8eff2c2..367490e 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 3509fb5..25b7a5f 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 c8c569a..9414afb 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 5e6739d..56a58b6 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 580ca88..50503bd 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 bea42a4..a0d1038 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"