Skip to content

Commit

Permalink
Update core to version 8c6e711a
Browse files Browse the repository at this point in the history
  • Loading branch information
1PasswordSDKBot committed Dec 3, 2024
1 parent 1256a90 commit a8e66ce
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 1 deletion.
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 @@ -3,6 +3,7 @@
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 @@ 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)
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"

0 comments on commit a8e66ce

Please sign in to comment.