Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/onepassword/build_number.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SDK_BUILD_NUMBER = "0010401"
SDK_BUILD_NUMBER = "0010500"
Binary file modified src/onepassword/lib/aarch64/libop_uniffi_core.dylib
Binary file not shown.
Binary file modified src/onepassword/lib/aarch64/libop_uniffi_core.so
Binary file not shown.
Binary file modified src/onepassword/lib/x86_64/libop_uniffi_core.dylib
Binary file not shown.
Binary file modified src/onepassword/lib/x86_64/libop_uniffi_core.so
Binary file not shown.
Binary file modified src/onepassword/lib/x86_64/op_uniffi_core.dll
Binary file not shown.
15 changes: 15 additions & 0 deletions src/onepassword/secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

from .core import _invoke, _invoke_sync
from json import loads
from .iterator import SDKIterator

Check failure on line 5 in src/onepassword/secrets.py

View workflow job for this annotation

GitHub Actions / Lint

Ruff (F401)

src/onepassword/secrets.py:5:23: F401 `.iterator.SDKIterator` imported but unused

Check failure on line 5 in src/onepassword/secrets.py

View workflow job for this annotation

GitHub Actions / Lint

Ruff (F401)

src/onepassword/secrets.py:5:23: F401 `.iterator.SDKIterator` imported but unused
from .types import GeneratePasswordResponse


class Secrets:
Expand Down Expand Up @@ -46,3 +47,17 @@
}
}
)

@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)
112 changes: 111 additions & 1 deletion src/onepassword/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -40,6 +52,7 @@ class ItemFieldType(str, Enum):
TEXT = "Text"
CONCEALED = "Concealed"
CREDITCARDTYPE = "CreditCardType"
CREDITCARDNUMBER = "CreditCardNumber"
PHONE = "Phone"
URL = "Url"
TOTP = "Totp"
Expand Down Expand Up @@ -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"
5 changes: 3 additions & 2 deletions src/release/RELEASE-NOTES
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
SDK_VERSION = "0.1.4"
SDK_VERSION = "0.1.5"
Loading