-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #314 from soberhacker/develop
4.0.0
- Loading branch information
Showing
17 changed files
with
248 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#### PIN Code Bot Token Encryption | ||
|
||
##### What type of encryption does the plugin use? | ||
|
||
The plugin uses AES-256 encryption to store the bot token securely. By default, the token is encrypted and saved locally on your device. However, since the plugin is open-source, the encryption key is embedded in the code, making it theoretically possible for other plugins to access the encrypted token. | ||
|
||
##### What additional protection does the PIN code provide? | ||
|
||
Enabling PIN-based encryption means that the decryption process requires a user-defined PIN, which is not stored. The PIN exists only in the user’s memory, preventing other plugins from accessing it. This extra layer ensures that even if the encryption mechanism is known through the source code, only someone with the correct PIN can decrypt the bot token. | ||
|
||
##### What risks does this encryption help prevent? | ||
|
||
- **Misuse of Bot Token**: Prevents scenarios where a malicious plugin could extract the token and use it for unauthorized actions, such as sending spam or other undesired activities through your bot. | ||
- **Bot Suspension**: Misuse of your bot token could lead to temporary or permanent suspension of your bot, making it unable to create new bots or send messages for a period (e.g., up to a month). | ||
|
||
##### How does it work? | ||
|
||
When this feature is enabled, you will be prompted to enter your PIN each time Obsidian starts. This PIN is used to decrypt the bot token for the session, keeping the token secure while stored on your device. | ||
|
||
##### What to do if you forget your PIN? | ||
|
||
If you forget your PIN, you will need to reset the encryption by re-entering your bot token in unencrypted form: | ||
|
||
1. Open the plugin settings in Obsidian. | ||
2. Enter your bot token without encryption. | ||
3. Re-enable the encryption feature and set a new PIN. | ||
|
||
##### Why is this important? | ||
|
||
Given the open-source nature of the plugin, adding a user-defined PIN helps ensure that your bot token remains under your control, even if other plugins attempt to access it. This feature is crucial for maintaining the integrity of your bot and avoiding unintended suspensions or breaches. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { Modal, Setting } from "obsidian"; | ||
import TelegramSyncPlugin from "src/main"; | ||
import { _5sec } from "src/utils/logUtils"; | ||
|
||
export class PinCodeModal extends Modal { | ||
pinCodeDiv: HTMLDivElement; | ||
saved = false; | ||
constructor( | ||
public plugin: TelegramSyncPlugin, | ||
public decrypt = false, | ||
) { | ||
super(plugin.app); | ||
} | ||
|
||
async display() { | ||
this.addHeader(); | ||
this.addPinCode(); | ||
this.addFooterButtons(); | ||
} | ||
|
||
success = async () => { | ||
this.saved = true; | ||
this.close(); | ||
}; | ||
|
||
addHeader() { | ||
this.contentEl.empty(); | ||
this.pinCodeDiv = this.contentEl.createDiv(); | ||
this.titleEl.setText("Telegram Sync: " + (this.decrypt ? "Decrypting" : "Encrypting") + " bot token"); | ||
} | ||
|
||
addPinCode() { | ||
new Setting(this.pinCodeDiv) | ||
.setName("PIN code") | ||
.setDesc("Enter your PIN code. Numbers and letters only.") | ||
.addText((text) => { | ||
text.setPlaceholder("example: 1234").onChange(async (value: string) => { | ||
if (!value) { | ||
text.inputEl.style.borderColor = "red"; | ||
text.inputEl.style.borderWidth = "2px"; | ||
text.inputEl.style.borderStyle = "solid"; | ||
} | ||
this.plugin.pinCode = value; | ||
}); | ||
text.inputEl.addEventListener("keydown", (event: KeyboardEvent) => { | ||
if (!(event.key === "Enter")) return; | ||
this.success.call(this); | ||
}); | ||
}); | ||
} | ||
|
||
addFooterButtons() { | ||
this.pinCodeDiv.createEl("br"); | ||
const footerButtons = new Setting(this.contentEl.createDiv()); | ||
footerButtons.addButton((b) => { | ||
b.setTooltip("Connect").setIcon("checkmark").onClick(this.success); | ||
return b; | ||
}); | ||
footerButtons.addExtraButton((b) => { | ||
b.setIcon("cross") | ||
.setTooltip("Cancel") | ||
.onClick(async () => { | ||
this.saved = false; | ||
this.plugin.pinCode = undefined; | ||
this.close(); | ||
}); | ||
return b; | ||
}); | ||
} | ||
|
||
onOpen() { | ||
this.display(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.