Skip to content

Commit

Permalink
Release 0.1.5 (#135)
Browse files Browse the repository at this point in the history
* Update core to version 8c6e711a

* Release v0.1.5

* add release notes and password example

* pretty format release notes

* Update example and release notes

* update readme

* fix setup.py missing comma

---------

Co-authored-by: 1PasswordSDKBot <[email protected]>
Co-authored-by: Horia Culea <[email protected]>
  • Loading branch information
3 people authored Dec 3, 2024
1 parent 1256a90 commit 0e75965
Show file tree
Hide file tree
Showing 13 changed files with 170 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Operations:
- [x] [Delete items](https://developer.1password.com/docs/sdks/manage-items#delete-an-item)
- [x] [List items](https://developer.1password.com/docs/sdks/list-vaults-items/)
- [x] Add & update tags on items
- [x] Generate PIN, random and memorable passwords

Field types:
- [x] API Keys
Expand All @@ -103,6 +104,7 @@ Field types:
- [x] Websites (used to suggest and autofill logins)
- [x] Phone numbers
- [x] Credit card types
- [x] Credit card numbers
- [ ] Files attachments and Document items

### Vault management
Expand Down
35 changes: 35 additions & 0 deletions example/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,41 @@ async def main():
# [developer-docs.sdk.python.update-item]-end

print(dict(updated_item))

# [developer-docs.sdk.python.generate-pin-password]-start
pin_password = Secrets.generate_password(
PasswordRecipePin(parameters=PasswordRecipePinInner(length=8))
)
print(pin_password)
# [developer-docs.sdk.python.generate-pin-password]-end

# [developer-docs.sdk.python.generate-memorable-password]-start
memorable_password = Secrets.generate_password(
PasswordRecipeMemorable(
parameters=PasswordRecipeMemorableInner(
separatorType=SeparatorType.UNDERSCORES,
wordListType=WordListType.SYLLABLES,
capitalize=False,
wordCount=3,
)
),
)
print(memorable_password)
# [developer-docs.sdk.python.generate-memorable-password]-end

# [developer-docs.sdk.python.generate-random-password]-start
random_password = Secrets.generate_password(
PasswordRecipeRandom(
parameters=PasswordRecipeRandomInner(
length=10,
includeDigits=False,
includeSymbols=False,
)
),
)
print(random_password)
# [developer-docs.sdk.python.generate-random-password]-end

# [developer-docs.sdk.python.delete-item]-start
# Delete a item from your vault.
await client.items.delete(created_item.vault_id, updated_item.id)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def get_shared_library_data_to_include():
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13"
"Programming Language :: Python :: 3.13",
"License :: OSI Approved :: MIT License",
],
cmdclass={"bdist_wheel": bdist_wheel},
Expand Down
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 = "0010501"
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
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"
6 changes: 4 additions & 2 deletions src/release/RELEASE-NOTES
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
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.
Version 0.1.5 of the 1Password Python SDK brings:
* Support for generating passwords. You can now generate random, PIN, and memorable passwords using the `onepassword.Secrets.generate_password` function.
* Support for item subtitles. Creating and editing an item now sets the subtitle correctly, which is visible in the item preview in all client apps.
* Support for the Credit Card Number field type. You can now retrieve, create, and edit items containing credit card numbers.
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"

0 comments on commit 0e75965

Please sign in to comment.