Create Extension
This commit is contained in:
commit
f2b025c469
4
.eslintrc.json
Normal file
4
.eslintrc.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"root": true,
|
||||||
|
"extends": ["@raycast"]
|
||||||
|
}
|
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
/node_modules
|
||||||
|
|
||||||
|
# misc
|
||||||
|
.DS_Store
|
4
.prettierrc
Normal file
4
.prettierrc
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"printWidth": 120,
|
||||||
|
"singleQuote": false
|
||||||
|
}
|
3
CHANGELOG.md
Normal file
3
CHANGELOG.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Apple-Like Password Changelog
|
||||||
|
|
||||||
|
## [Initial Version] - 2023-04-24
|
6
README.md
Normal file
6
README.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# Generate Apple-Like Password
|
||||||
|
|
||||||
|
Generates a pronouncable, easy to remember yet still secure password in the style of Apple Keychain
|
||||||
|
|
||||||
|
I did not make this algorithm! I found it in Apple Shortcut form in [this reddit post](https://www.reddit.com/r/shortcuts/comments/caz8kd/generate_apple_keychain_style_password/).
|
||||||
|
Unfortunately, the account behind the post has been deleted, so I could not ask for permission to use, however I (and I'm sure I'm not the only one) really appreciate this being nicer implemented within Raycast.
|
BIN
assets/icon.png
Normal file
BIN
assets/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 101 KiB |
BIN
metadata/screenshot-01.png
Normal file
BIN
metadata/screenshot-01.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 313 KiB |
3399
package-lock.json
generated
Normal file
3399
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
38
package.json
Normal file
38
package.json
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://www.raycast.com/schemas/extension.json",
|
||||||
|
"name": "keychain-password-gen",
|
||||||
|
"title": "Apple-Like Password",
|
||||||
|
"description": "Generate an Apple Keychain-Like Password",
|
||||||
|
"icon": "icon.png",
|
||||||
|
"author": "breadone",
|
||||||
|
"categories": [
|
||||||
|
"Security"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"commands": [
|
||||||
|
{
|
||||||
|
"name": "index",
|
||||||
|
"title": "Generate Password",
|
||||||
|
"description": "Generates a secure password",
|
||||||
|
"mode": "no-view"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"@raycast/api": "^1.48.8"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@raycast/eslint-config": "1.0.5",
|
||||||
|
"@types/node": "18.8.3",
|
||||||
|
"@types/react": "18.0.9",
|
||||||
|
"eslint": "^7.32.0",
|
||||||
|
"prettier": "^2.5.1",
|
||||||
|
"typescript": "^4.4.3"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "ray build -e dist",
|
||||||
|
"dev": "ray develop",
|
||||||
|
"fix-lint": "ray lint --fix",
|
||||||
|
"lint": "ray lint",
|
||||||
|
"publish": "ray publish"
|
||||||
|
}
|
||||||
|
}
|
83
src/index.tsx
Normal file
83
src/index.tsx
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
import { showHUD, Clipboard } from "@raycast/api";
|
||||||
|
import { randomInt } from "crypto";
|
||||||
|
|
||||||
|
export default async function Command() {
|
||||||
|
const pass = generate();
|
||||||
|
await Clipboard.copy(pass);
|
||||||
|
|
||||||
|
await showHUD("Password copied to clipboard");
|
||||||
|
}
|
||||||
|
|
||||||
|
function generate() {
|
||||||
|
const lowerConsonants = "bcdfghjkmnpqrstvwxz".split("");
|
||||||
|
const upperConsonants = "BCDFGHJKLMNPQRSTVWXZ".split("");
|
||||||
|
const lowerVowels = "aeiouy".split("");
|
||||||
|
const upperVowels = "AEUY".split("");
|
||||||
|
|
||||||
|
const numberPositions: {[index: number]: number} = {
|
||||||
|
1: 1,
|
||||||
|
2: 7,
|
||||||
|
3: 13,
|
||||||
|
4: 6,
|
||||||
|
5: 12,
|
||||||
|
6: 18
|
||||||
|
};
|
||||||
|
|
||||||
|
// choose position of number and upper case letter
|
||||||
|
const numPosKey = randomInt(2, 7);
|
||||||
|
const NumberPosition = numberPositions[numPosKey];
|
||||||
|
|
||||||
|
let uppercasePos = randomInt(1, 19);
|
||||||
|
if (uppercasePos === numPosKey) {
|
||||||
|
const rnd = randomInt(1, 10);
|
||||||
|
|
||||||
|
if (uppercasePos > 9) {
|
||||||
|
uppercasePos -= rnd;
|
||||||
|
} else {
|
||||||
|
uppercasePos += rnd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// pick characters
|
||||||
|
let count = 1;
|
||||||
|
let passwordSection = "";
|
||||||
|
for (let i = 1; i < 18; i++) {
|
||||||
|
count += 1;
|
||||||
|
|
||||||
|
if (NumberPosition === i) {
|
||||||
|
if (NumberPosition < 4) {
|
||||||
|
count -= 1;
|
||||||
|
}
|
||||||
|
passwordSection += randomInt(1, 10);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (count % 3 === 0) {
|
||||||
|
// vowel
|
||||||
|
if (uppercasePos === i) {
|
||||||
|
passwordSection += randomFromArray(upperVowels);
|
||||||
|
} else {
|
||||||
|
passwordSection += randomFromArray(lowerVowels);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// consonant
|
||||||
|
if (uppercasePos === i) {
|
||||||
|
passwordSection += randomFromArray(upperConsonants);
|
||||||
|
} else {
|
||||||
|
passwordSection += randomFromArray(lowerConsonants);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// separate characters into sections
|
||||||
|
if (i % 6 === 0) {
|
||||||
|
passwordSection += "-";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return passwordSection;
|
||||||
|
}
|
||||||
|
|
||||||
|
function randomFromArray(array: any[]) {
|
||||||
|
return array[randomInt(1, array.length)];
|
||||||
|
}
|
17
tsconfig.json
Normal file
17
tsconfig.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://json.schemastore.org/tsconfig",
|
||||||
|
"display": "Node 16",
|
||||||
|
"include": ["src/**/*"],
|
||||||
|
"compilerOptions": {
|
||||||
|
"lib": ["es2021"],
|
||||||
|
"module": "commonjs",
|
||||||
|
"target": "es2021",
|
||||||
|
"strict": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"resolveJsonModule": true
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user