diff --git a/docs/enrollment_diagram.md b/docs/enrollment_diagram.md
index 304fe77..fef2bd0 100644
--- a/docs/enrollment_diagram.md
+++ b/docs/enrollment_diagram.md
@@ -12,26 +12,26 @@ sequenceDiagram
Server->>Server: Create Signup Session
Note over User,Server: Set nKode
Server-->>-Client: signup_session_id, set_keypad, icons
- Note left of Server: signup_session_id:
d7e50a75-d3ff-482a-b0e7-ce99c3838c1a
- Note left of Server: set_keypad:
Key 0: [12 13 20 21 16]
Key 1: [ 6 1 14 9 4]
Key 2: [ 0 7 26 15 28]
Key 3: [24 19 2 27 10]
Key 4: [18 25 8 3 22]
- Note left of Server: Icons:
[đ,đ,đĨŗ,đ,đ¤
đ,đĨē,đĄ,đą,đ¤¯
đĨ°,đ´,đ¤,đ,đ
đ¤,đŊ,đž,đą,đļ
đĻ,đģ,đ¸,đ,đĻ
đ,âĄ,đĨ,đ,đ]
+ Note left of Server: signup_session_id:
51b187b9-c930-4f5d-81da-c11c082f2c64
+ Note left of Server: set_keypad:
Key 0: [ 9 29 3 49 50 25]
Key 1: [27 2 12 22 14 16]
Key 2: [36 47 21 13 23 7]
Key 3: [45 11 30 4 32 43]
Key 4: [18 20 39 40 41 52]
Key 5: [ 0 38 48 31 5 34]
+ Note left of Server: Icons:
[đ,đ,đ,đ,đ,đ
đ,đ,đ,đ,đĨ,đ
đĨĨ,đĨ,đ
,đ,đĨ,đĨ
đŊ,đĨ,đ ,đĨ,đĨ,đĨ¨
đĨ¯,đĨ,đ§,đ,đ,đĨ
đ,đ,đ,đ,đĨĒ,đŽ
đ¯,đŖ,đ¤,đ,đ,đ
đ˛,đ,đą,đĨ,đĻ,đ§
đ¨,đŠ,đĒ,đ,đ°,đ§]
Client->>Client: Order Icons by keypad
Client->>User: Display Keypad
- Note left of Client: Key 0: ['đ¤' 'đ' 'đĻ' 'đģ' 'đŊ']
Key 1: ['đĨē' 'đ' 'đ' 'đ¤¯' 'đ¤']
Key 2: ['đ' 'đĄ' 'âĄ' 'đ¤' 'đ']
Key 3: ['đĻ' 'đļ' 'đĨŗ' 'đĨ' 'đĨ°']
Key 4: ['đą' 'đ' 'đą' 'đ' 'đ¸']
- Note left of User: User icons: ['đ¤' 'đļ' 'đĻ' 'đŊ']
- User->>Client: Set Key Selection: [1, 3, 3, 0]
- Client->>+Server: Set nKode:
d7e50a75-d3ff-482a-b0e7-ce99c3838c1a
[1, 3, 3, 0]
+ Note left of Client: Key 0: ['đ' 'đĨ' 'đ' 'đŠ' 'đĒ' 'đĨ']
Key 1: ['đ' 'đ' 'đĨĨ' 'đĨ' 'đ
' 'đĨ']
Key 2: ['đ¯' 'đ§' 'đĨ' 'đĨ' 'đĨ¨' 'đ']
Key 3: ['đĨ' 'đ' 'đ' 'đ' 'đ' 'đ']
Key 4: ['đŊ' 'đ ' 'đ' 'đ' 'đ' 'đ°']
Key 5: ['đ' 'đ¤' 'đ¨' 'đ' 'đ' 'đĨĒ']
+ Note left of User: User icons: ['đ¯' 'đ' 'đ°' 'đ']
+ User->>Client: Set Key Selection: [2, 1, 4, 2]
+ Client->>+Server: Set nKode:
51b187b9-c930-4f5d-81da-c11c082f2c64
[2, 1, 4, 2]
Server->>Server: Disperse Set Keypad
Note over User,Server: Confirm nKode
Server-->>-Client: signup_session_id, confirm_keypad, icons
- Note left of Server: signup_session_id:
d7e50a75-d3ff-482a-b0e7-ce99c3838c1a
- Note left of Server: confirm_keypad:
Key 0: [ 6 13 8 15 10]
Key 1: [24 7 14 3 16]
Key 2: [12 25 2 9 28]
Key 3: [ 0 1 20 27 22]
Key 4: [18 19 26 21 4]
+ Note left of Server: signup_session_id:
51b187b9-c930-4f5d-81da-c11c082f2c64
+ Note left of Server: confirm_keypad:
Key 0: [27 47 39 4 5 25]
Key 1: [45 20 48 49 14 7]
Key 2: [ 9 38 12 13 32 52]
Key 3: [36 2 30 40 50 34]
Key 4: [18 11 3 31 23 16]
Key 5: [ 0 29 21 22 41 43]
Client->>Client: Order Icons by keypad
Client->>User: Display Keypad
- Note left of Client: Key 0: ['đĨē' 'đ' 'đą' 'đ¤' 'đĨ°']
Key 1: ['đĻ' 'đĄ' 'đ' 'đ' 'đŊ']
Key 2: ['đ¤' 'đ' 'đĨŗ' 'đ¤¯' 'đ']
Key 3: ['đ' 'đ' 'đĻ' 'đĨ' 'đ¸']
Key 4: ['đą' 'đļ' 'âĄ' 'đģ' 'đ¤']
- Note left of User: User icons: ['đ¤' 'đļ' 'đĻ' 'đŊ']
- User->>Client: Key Selection: [4, 4, 1, 1]
- Client->>+Server: Confirm nKode:
d7e50a75-d3ff-482a-b0e7-ce99c3838c1a
[4, 4, 1, 1]
+ Note left of Client: Key 0: ['đ' 'đ§' 'đ' 'đ' 'đ' 'đĨ']
Key 1: ['đĨ' 'đ ' 'đ¨' 'đŠ' 'đ
' 'đ']
Key 2: ['đ' 'đ¤' 'đĨĨ' 'đĨ' 'đ' 'đ°']
Key 3: ['đ¯' 'đ' 'đ' 'đ' 'đĒ' 'đĨĒ']
Key 4: ['đŊ' 'đ' 'đ' 'đ' 'đĨ¨' 'đĨ']
Key 5: ['đ' 'đĨ' 'đĨ' 'đĨ' 'đ' 'đ']
+ Note left of User: User icons: ['đ¯' 'đ' 'đ°' 'đ']
+ User->>Client: Key Selection: [3, 0, 2, 1]
+ Client->>+Server: Confirm nKode:
51b187b9-c930-4f5d-81da-c11c082f2c64
[3, 0, 2, 1]
Server->>Server: Create User
Server-->>-Client: Success
```
\ No newline at end of file
diff --git a/docs/login_diagram.md b/docs/login_diagram.md
index 1ae4167..bfa0962 100644
--- a/docs/login_diagram.md
+++ b/docs/login_diagram.md
@@ -10,13 +10,13 @@ sequenceDiagram
Note left of User: email: user@example.com
User->>Server: Submit Email
Server->>Client: login_keypad, icons
- Note left of Server: Login Keypad:
Key 0: [12 13 20 21 16 23]
Key 1: [ 6 1 14 9 4 29]
Key 2: [ 0 7 26 15 28 11]
Key 3: [24 19 2 27 10 5]
Key 4: [18 25 8 3 22 17]
- Note left of Server: Icons:
[đ,đ,đĨŗ,đ,đ¤
đ,đĨē,đĄ,đą,đ¤¯
đĨ°,đ´,đ¤,đ,đ
đ¤,đŊ,đž,đą,đļ
đĻ,đģ,đ¸,đ,đĻ
đ,âĄ,đĨ,đ,đ]
+ Note left of Server: Login Keypad:
Key 0: [ 9 1 29 3 49 50 33 25 35]
Key 1: [27 28 2 12 22 14 24 16 17]
Key 2: [36 37 47 21 13 23 42 7 26]
Key 3: [45 19 11 30 4 32 51 43 8]
Key 4: [18 46 20 39 40 41 15 52 44]
Key 5: [ 0 10 38 48 31 5 6 34 53]
+ Note left of Server: Icons:
[đ,đ,đ,đ,đ,đ
đ,đ,đ,đ,đĨ,đ
đĨĨ,đĨ,đ
,đ,đĨ,đĨ
đŊ,đĨ,đ ,đĨ,đĨ,đĨ¨
đĨ¯,đĨ,đ§,đ,đ,đĨ
đ,đ,đ,đ,đĨĒ,đŽ
đ¯,đŖ,đ¤,đ,đ,đ
đ˛,đ,đą,đĨ,đĻ,đ§
đ¨,đŠ,đĒ,đ,đ°,đ§]
Client->>Client: Order Icons
Client->>User: Display Keypad
- Note left of Client: Key 0: ['đ¤' 'đ' 'đĻ' 'đģ' 'đŊ' 'đ']
Key 1: ['đĨē' 'đ' 'đ' 'đ¤¯' 'đ¤' 'đ']
Key 2: ['đ' 'đĄ' 'âĄ' 'đ¤' 'đ' 'đ´']
Key 3: ['đĻ' 'đļ' 'đĨŗ' 'đĨ' 'đĨ°' 'đ']
Key 4: ['đą' 'đ' 'đą' 'đ' 'đ¸' 'đž']
- Note left of User: User passcode icons: ['đ¤' 'đļ' 'đĻ' 'đŊ']
- User->>Client: Selected Keys
[1, 3, 3, 0]
- Client->>Server: Login:
email: user@example.com
selected_keys: [1, 3, 3, 0]
+ Note left of Client: Key 0: ['đ' 'đ' 'đĨ' 'đ' 'đŠ' 'đĒ' 'đ' 'đĨ' 'đŽ']
Key 1: ['đ' 'đ' 'đ' 'đĨĨ' 'đĨ' 'đ
' 'đĨ¯' 'đĨ' 'đĨ']
Key 2: ['đ¯' 'đŖ' 'đ§' 'đĨ' 'đĨ' 'đĨ¨' 'đ˛' 'đ' 'đ§']
Key 3: ['đĨ' 'đĨ' 'đ' 'đ' 'đ' 'đ' 'đ' 'đ' 'đ']
Key 4: ['đŊ' 'đĻ' 'đ ' 'đ' 'đ' 'đ' 'đ' 'đ°' 'đą']
Key 5: ['đ' 'đĨ' 'đ¤' 'đ¨' 'đ' 'đ' 'đ' 'đĨĒ' 'đ§']
+ Note left of User: User passcode icons: ['đ¯' 'đ' 'đ°' 'đ']
+ User->>Client: Selected Keys
[2, 1, 4, 2]
+ Client->>Server: Login:
email: user@example.com
selected_keys: [2, 1, 4, 2]
Server-->>Client: Success
```
\ No newline at end of file
diff --git a/docs/scripts/render_diagrams_md.py b/docs/scripts/render_diagrams_md.py
index ec97b54..09b5281 100644
--- a/docs/scripts/render_diagrams_md.py
+++ b/docs/scripts/render_diagrams_md.py
@@ -1,35 +1,13 @@
-# Render markdown template for nKode enrollment
from pathlib import Path
-
import numpy as np
-from jinja2 import Environment, FileSystemLoader, select_autoescape
from secrets import choice
from string import ascii_lowercase
+from docs.scripts.utils import render_markdown_template, emojis
from src.models import NKodePolicy, KeypadSize
from src.nkode_api import NKodeAPI
from src.utils import select_keys_with_passcode_values
-def render_markdown_template(template_path, output_path, context):
- template_dir = template_path.parent
- template_file = template_path.name
-
- env = Environment(
- loader=FileSystemLoader(template_dir),
- autoescape=select_autoescape(['html', 'xml']),
- trim_blocks=True,
- lstrip_blocks=True
- )
-
- template = env.get_template(template_file)
- rendered = template.render(**context)
-
- with open(output_path, 'w') as f:
- f.write(rendered)
-
- print(f"Template rendered to {output_path}")
-
-
def display_icons(icons_array: np.ndarray, kp: KeypadSize) -> str:
icons = "["
for row in icons_array.reshape(-1, kp.numb_of_keys):
@@ -49,14 +27,7 @@ def display_icons_keypad(icons_array: np.ndarray, props_per_key: int) -> str:
if __name__ == "__main__":
api = NKodeAPI()
- user_icons = np.array([
- "đ", "đ", "đĨŗ", "đ", "đ¤",
- "đ", "đĨē", "đĄ", "đą", "đ¤¯",
- "đĨ°", "đ´", "đ¤", "đ", "đ",
- "đ¤", "đŊ", "đž", "đą", "đļ",
- "đĻ", "đģ", "đ¸", "đ", "đĻ",
- "đ", "âĄ", "đĨ", "đ", "đ"
- ])
+
policy = NKodePolicy(
max_nkode_len=10,
min_nkode_len=4,
@@ -64,12 +35,12 @@ if __name__ == "__main__":
distinct_properties=4,
)
keypad_size = KeypadSize(
- numb_of_keys=5,
- props_per_key=6
+ numb_of_keys=6,
+ props_per_key=9
)
customer_id = api.create_new_customer(keypad_size, policy)
signup_session_id, set_signup_keypad = api.generate_signup_keypad(customer_id)
- ordered_set_icons = user_icons[set_signup_keypad]
+ ordered_set_icons = emojis[set_signup_keypad]
username = "test_username" + "".join([choice(ascii_lowercase) for _ in range(6)])
passcode_len = 4
passcode_property_indices = np.random.choice(set_signup_keypad.reshape(-1), size=passcode_len,
@@ -79,16 +50,16 @@ if __name__ == "__main__":
confirm_keypad = api.set_nkode(username, customer_id, selected_keys_set, signup_session_id)
selected_keys_confirm = select_keys_with_passcode_values(passcode_property_indices, confirm_keypad,
keypad_size.numb_of_keys)
- ordered_confirm_icons = user_icons[confirm_keypad]
+ ordered_confirm_icons = emojis[confirm_keypad]
print(f"Selected Keys\n{selected_keys_confirm}")
success = api.confirm_nkode(username, customer_id, selected_keys_confirm, signup_session_id)
context = {
"email": "user@example.com",
"signup_session_id": signup_session_id,
"set_keypad": display_icons_keypad(set_signup_keypad.reshape(-1, keypad_size.numb_of_keys), keypad_size.numb_of_keys),
- "keypad_icons": display_icons(user_icons, keypad_size),
+ "keypad_icons": display_icons(emojis[:keypad_size.total_props], keypad_size),
"ordered_keypad": display_icons_keypad(ordered_set_icons, keypad_size.numb_of_keys),
- "passcode_user_icons": str(user_icons[passcode_property_indices]),
+ "passcode_user_icons": str(emojis[passcode_property_indices]),
"selected_keys_set": str(selected_keys_set),
"confirm_keypad": display_icons_keypad(confirm_keypad.reshape(-1, keypad_size.numb_of_keys), keypad_size.numb_of_keys),
"confirm_ordered_keypad": display_icons_keypad(ordered_confirm_icons.reshape(-1, keypad_size.numb_of_keys), keypad_size.numb_of_keys),
@@ -98,13 +69,13 @@ if __name__ == "__main__":
login_keypad = api.get_login_keypad(username, customer_id)
selected_keys_login = select_keys_with_passcode_values(passcode_property_indices, login_keypad,
keypad_size.props_per_key)
- ordered_login_keypad = user_icons[login_keypad]
+ ordered_login_keypad = emojis[login_keypad]
context = {
"email": "user@example.com",
- "keypad_icons": display_icons(user_icons, keypad_size),
+ "keypad_icons": display_icons(emojis[:keypad_size.total_props], keypad_size),
"login_keypad": display_icons_keypad(login_keypad.reshape(-1, keypad_size.props_per_key), keypad_size.props_per_key),
"ordered_login_icons": display_icons_keypad(ordered_login_keypad.reshape(-1, keypad_size.props_per_key),keypad_size.props_per_key),
- "passcode_user_icons": str(user_icons[passcode_property_indices]),
+ "passcode_user_icons": str(emojis[passcode_property_indices]),
"selected_keys_login": str(selected_keys_login)
}
api.login(customer_id, username, selected_keys_login)
diff --git a/docs/scripts/utils.py b/docs/scripts/utils.py
new file mode 100644
index 0000000..32531f6
--- /dev/null
+++ b/docs/scripts/utils.py
@@ -0,0 +1,46 @@
+import numpy as np
+from jinja2 import Environment, FileSystemLoader, select_autoescape
+
+
+emojis = np.array([
+ "đ", "đ", "đ", "đ", "đ", "đ", "đ", "đ", "đ", "đ",
+ "đĨ", "đ", "đĨĨ", "đĨ", "đ
", "đ", "đĨ", "đĨ", "đŊ", "đĨ",
+ "đ ", "đĨ", "đĨ", "đĨ¨", "đĨ¯", "đĨ", "đ§", "đ", "đ", "đĨ",
+ "đ", "đ", "đ", "đ", "đĨĒ", "đŽ", "đ¯", "đŖ", "đ¤", "đ",
+ "đ", "đ", "đ˛", "đ", "đą", "đĨ", "đĻ", "đ§", "đ¨", "đŠ",
+ "đĒ", "đ", "đ°", "đ§", "đĢ", "đŦ", "đ", "đŽ", "â", "đĩ",
+ "đĨ¤", "đ§", "đˇ", "đ¸", "đš", "đē", "đĨ", "đĨ", "đļ", "đą",
+ "đ", "đš", "đ°", "đĻ", "đģ", "đŧ", "đ¨", "đ¯", "đĻ", "đŽ",
+ "đˇ", "đŊ", "đ´", "đĻ", "đĻ", "đĻ", "đ", "đĻ", "đĒ", "đĢ",
+ "đ", "đ", "đ", "đ", "đŖ", "đ¤", "đĻ", "đĻ
", "đĻ", "đĻ",
+ "đē", "đ", "đĸ", "đĻ", "đ", "đĻ", "đĻ", "đĻ", "đĄ", "đ ",
+ "đ", "đŦ", "đŗ", "đĻ", "đ", "đ
", "đ", "đž", "đĻ", "đ",
+ "đ", "đ", "đˇī¸", "đ¸ī¸", "đ¸", "đš", "đē", "đģ", "đŧ", "đˇ",
+ "đą", "đ˛", "đŗ", "đ´", "đĩ", "đž", "đŋ", "đ", "đ", "đ",
+ "đ", "â", "đ", "â¨", "âĄī¸", "âī¸", "âī¸", "đ¤ī¸", "â
", "đĨī¸",
+ "âī¸", "đĻī¸", "đ§ī¸", "âī¸", "đŠī¸", "âī¸", "đŦī¸", "đ¨", "đ", "â",
+ "đ§", "đ", "đĨ", "đĨ", "â", "đ", "â°ī¸", "đī¸", "đī¸", "đī¸",
+ "đī¸", "đī¸", "đī¸", "đī¸", "đ ", "đĄ", "đĸ", "đŖ", "đ¤", "đĨ",
+ "đĻ", "đ¨", "đŠ", "đĒ", "đĢ", "đŦ", "đ", "đ¯", "đ°", "âĒ",
+ "âŠī¸", "đ", "đ", "đŋ", "đĄ", "đĸ", "đ ", "đĒ", "đ¨", "đŦ",
+ "đ¤", "đ§", "đŧ", "đš", "đē", "đ¸", "đĨ", "đģ", "đŽ", "đ˛"
+])
+
+def render_markdown_template(template_path, output_path, context: dict):
+ template_dir = template_path.parent
+ template_file = template_path.name
+
+ env = Environment(
+ loader=FileSystemLoader(template_dir),
+ autoescape=select_autoescape(['html', 'xml']),
+ trim_blocks=True,
+ lstrip_blocks=True
+ )
+
+ template = env.get_template(template_file)
+ rendered = template.render(**context)
+
+ with open(output_path, 'w') as f:
+ f.write(rendered)
+
+ print(f"Template rendered to {output_path}")