@borfast/arrispwgen
Advanced tools
| export declare function generate(date: Date, seed?: string): string; | ||
| export declare class InvalidDateRangeError extends Error { | ||
| constructor(); | ||
| } | ||
| export declare function generate_multi(startDate: Date, endDate: Date, seed?: string): { | ||
| date: Date; | ||
| password: string; | ||
| }[]; | ||
| export declare const DEFAULT_SEED = "MPSJKMDHAI"; |
| import { _ALPHANUM, _DEFAULT_SEED } from './constants.js'; | ||
| import { indexers } from './data.js'; | ||
| export function generate(date, seed = _DEFAULT_SEED) { | ||
| const idx = indexers(date, seed); | ||
| const passwordOfTheDay = []; | ||
| const len = idx.length; | ||
| for (let i = 0; i < len; i++) { | ||
| passwordOfTheDay[i] = _ALPHANUM[idx[i]]; | ||
| } | ||
| return passwordOfTheDay.join(''); | ||
| } | ||
| export class InvalidDateRangeError extends Error { | ||
| constructor() { | ||
| super('The start date must precede the end date.'); | ||
| } | ||
| } | ||
| export function generate_multi(startDate, endDate, seed = _DEFAULT_SEED) { | ||
| if (startDate > endDate) { | ||
| throw new InvalidDateRangeError(); | ||
| } | ||
| const days = 1 + | ||
| Math.ceil((endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24)); | ||
| const passwordList = []; | ||
| for (let i = 0; i < days; i++) { | ||
| const date = new Date(new Date(startDate).setDate(startDate.getDate() + i)); | ||
| passwordList.push({ | ||
| date: date, | ||
| password: generate(date, seed), | ||
| }); | ||
| } | ||
| return passwordList; | ||
| } | ||
| export const DEFAULT_SEED = _DEFAULT_SEED; |
| export declare const _DEFAULT_SEED = "MPSJKMDHAI"; | ||
| export declare const _TABLE1: number[][]; | ||
| export declare const _TABLE2: number[][]; | ||
| export declare const _ALPHANUM: string[]; |
| export const _DEFAULT_SEED = 'MPSJKMDHAI'; | ||
| export const _TABLE1 = [ | ||
| [15, 15, 24, 20, 24], | ||
| [13, 14, 27, 32, 10], | ||
| [29, 14, 32, 29, 24], | ||
| [23, 32, 24, 29, 29], | ||
| [14, 29, 10, 21, 29], | ||
| [34, 27, 16, 23, 30], | ||
| [14, 22, 24, 17, 13], | ||
| ]; | ||
| export const _TABLE2 = [ | ||
| [0, 1, 2, 9, 3, 4, 5, 6, 7, 8], | ||
| [1, 4, 3, 9, 0, 7, 8, 2, 5, 6], | ||
| [7, 2, 8, 9, 4, 1, 6, 0, 3, 5], | ||
| [6, 3, 5, 9, 1, 8, 2, 7, 4, 0], | ||
| [4, 7, 0, 9, 5, 2, 3, 1, 8, 6], | ||
| [5, 6, 1, 9, 8, 0, 4, 3, 2, 7], | ||
| ]; | ||
| export const _ALPHANUM = [ | ||
| '0', | ||
| '1', | ||
| '2', | ||
| '3', | ||
| '4', | ||
| '5', | ||
| '6', | ||
| '7', | ||
| '8', | ||
| '9', | ||
| 'A', | ||
| 'B', | ||
| 'C', | ||
| 'D', | ||
| 'E', | ||
| 'F', | ||
| 'G', | ||
| 'H', | ||
| 'I', | ||
| 'J', | ||
| 'K', | ||
| 'L', | ||
| 'M', | ||
| 'N', | ||
| 'O', | ||
| 'P', | ||
| 'Q', | ||
| 'R', | ||
| 'S', | ||
| 'T', | ||
| 'U', | ||
| 'V', | ||
| 'W', | ||
| 'X', | ||
| 'Y', | ||
| 'Z', | ||
| ]; |
| export declare function list1(date: Date): number[]; | ||
| export declare function list2(seed: string): number[]; | ||
| export declare function num8(l3: number[]): number; | ||
| export declare function list3(l1: number[], l2: number[]): number[]; | ||
| export declare function list4(l3: number[]): number[]; | ||
| export declare function list5(seed: string, l4: number[]): number[]; | ||
| export declare function indexers(date: Date, seed: string): number[]; |
+76
| import { _TABLE1, _TABLE2 } from './constants.js'; | ||
| export function list1(date) { | ||
| // Last two digits of the year | ||
| const year = date.getFullYear() % 100; | ||
| // Number of the month. The month in a Date object is zero-indexed, | ||
| // i.e., January == 0, so we add 1 to satisfy the algorithm. | ||
| const month = date.getMonth() + 1; | ||
| const dayOfMonth = date.getDate(); | ||
| // Day of the week. Normally 0 would be Sunday but we need it to be Monday. | ||
| let dayOfWeek = date.getDay() - 1; | ||
| if (dayOfWeek < 0) { | ||
| dayOfWeek = 6; | ||
| } | ||
| const list1Result = []; | ||
| for (let i = 0; i <= 4; i++) { | ||
| list1Result[i] = _TABLE1[dayOfWeek][i]; | ||
| } | ||
| list1Result[5] = dayOfMonth; | ||
| if (year + month - dayOfMonth < 0) { | ||
| list1Result[6] = (year + month - dayOfMonth + 36) % 36; | ||
| } | ||
| else { | ||
| list1Result[6] = (year + month - dayOfMonth) % 36; | ||
| } | ||
| list1Result[7] = (((3 + ((year + month) % 12)) * dayOfMonth) % 37) % 36; | ||
| return list1Result; | ||
| } | ||
| export function list2(seed) { | ||
| const list2Result = []; | ||
| for (let i = 0; i <= 7; i++) { | ||
| list2Result[i] = seed.charCodeAt(i) % 36; | ||
| } | ||
| return list2Result; | ||
| } | ||
| export function num8(l3) { | ||
| return l3[8] % 6; | ||
| } | ||
| export function list3(l1, l2) { | ||
| const list3Result = []; | ||
| for (let i = 0; i <= 7; i++) { | ||
| list3Result[i] = (l1[i] + l2[i]) % 36; | ||
| } | ||
| list3Result[8] = | ||
| (list3Result[0] + | ||
| list3Result[1] + | ||
| list3Result[2] + | ||
| list3Result[3] + | ||
| list3Result[4] + | ||
| list3Result[5] + | ||
| list3Result[6] + | ||
| list3Result[7]) % | ||
| 36; | ||
| list3Result[9] = Math.round(num8(list3Result) ** 2); | ||
| return list3Result; | ||
| } | ||
| export function list4(l3) { | ||
| const list4Result = []; | ||
| for (let i = 0; i <= 9; i++) { | ||
| list4Result[i] = l3[_TABLE2[num8(l3)][i]]; | ||
| } | ||
| return list4Result; | ||
| } | ||
| export function list5(seed, l4) { | ||
| const list5Result = []; | ||
| for (let i = 0; i <= 9; i++) { | ||
| list5Result[i] = (seed.charCodeAt(i) + l4[i]) % 36; | ||
| } | ||
| return list5Result; | ||
| } | ||
| export function indexers(date, seed) { | ||
| const l1 = list1(date); | ||
| const l2 = list2(seed); | ||
| const l3 = list3(l1, l2); | ||
| const l4 = list4(l3); | ||
| return list5(seed, l4); | ||
| } |
+50
-48
| { | ||
| "name": "@borfast/arrispwgen", | ||
| "version": "5.0.1", | ||
| "description": "Arris Password of the Day Generator reusable library", | ||
| "keywords": [ | ||
| "arris", | ||
| "arrispwd", | ||
| "arrispwgen", | ||
| "password-of-the-day", | ||
| "password of the day" | ||
| ], | ||
| "homepage": "https://arrispwgen.borfast.com", | ||
| "bugs": { | ||
| "url": "https://github.com/borfast/arrispwgen/issues" | ||
| }, | ||
| "license": "MIT", | ||
| "author": "Raúl Santos (https://www.borfast.com)", | ||
| "main": "./lib/arrispwgen.js", | ||
| "type": "module", | ||
| "files": [ | ||
| "/lib", | ||
| "./lib/arrispwgen.d.ts" | ||
| ], | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/borfast/arrispwgen.git" | ||
| }, | ||
| "scripts": { | ||
| "build": "ttsc --project tsconfig.json", | ||
| "prepublishOnly": "npm run build", | ||
| "lint": "eslint -c .eslintrc.cjs 'src/**/*.{ts,tsx}' '__tests__/**/*.{ts,tsx}'", | ||
| "pretest": "npm run lint", | ||
| "test": "jest" | ||
| }, | ||
| "devDependencies": { | ||
| "@jest/globals": "^25.5.2", | ||
| "@types/jest": "^25.2.1", | ||
| "@typescript-eslint/parser": "^2.31.0", | ||
| "@zoltu/typescript-transformer-append-js-extension": "^1.0.1", | ||
| "eslint": "^6.8.0", | ||
| "jest": "^26.0.1", | ||
| "ts-jest": "^25.4.0", | ||
| "ttypescript": "^1.5.10", | ||
| "typescript": "^3.8.3" | ||
| }, | ||
| "engines": { | ||
| "node": ">=13.2.0", | ||
| "npm": ">=6" | ||
| } | ||
| "name": "@borfast/arrispwgen", | ||
| "version": "6.0.0", | ||
| "description": "Arris Password of the Day Generator reusable library", | ||
| "keywords": [ | ||
| "arris", | ||
| "arrispwd", | ||
| "arrispwgen", | ||
| "password-of-the-day", | ||
| "password of the day" | ||
| ], | ||
| "homepage": "https://arrispwgen.borfast.com", | ||
| "bugs": { | ||
| "url": "https://github.com/borfast/arrispwgen/issues" | ||
| }, | ||
| "license": "MIT", | ||
| "author": "Raúl Santos (https://www.borfast.com)", | ||
| "type": "module", | ||
| "main": "./dist/arrispwgen.js", | ||
| "types": "./dist/arrispwgen.d.ts", | ||
| "exports": { | ||
| ".": { | ||
| "types": "./dist/arrispwgen.d.ts", | ||
| "default": "./dist/arrispwgen.js" | ||
| } | ||
| }, | ||
| "sideEffects": false, | ||
| "files": [ | ||
| "dist" | ||
| ], | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/borfast/arrispwgen.git" | ||
| }, | ||
| "scripts": { | ||
| "build": "tsc --project tsconfig.build.json", | ||
| "prepublishOnly": "npm run build", | ||
| "lint": "biome check .", | ||
| "format": "biome check --write .", | ||
| "typecheck": "tsc --noEmit", | ||
| "pretest": "npm run lint && npm run typecheck", | ||
| "test": "vitest run" | ||
| }, | ||
| "devDependencies": { | ||
| "@biomejs/biome": "^2.5.3", | ||
| "typescript": "^7.0.2", | ||
| "vitest": "^4.1.10" | ||
| }, | ||
| "engines": { | ||
| "node": ">=24.18.0" | ||
| } | ||
| } |
+1
-2
@@ -15,4 +15,3 @@ # Arris Password of the Day Generator | ||
|  | ||
| [](https://travis-ci.org/borfast/arrispwgen) | ||
| [](https://scrutinizer-ci.com/g/borfast/arrispwgen/?branch=master) | ||
| [](https://github.com/borfast/arrispwgen/actions/workflows/ci.yml) | ||
| [](https://ko-fi.com/B0B61NQ8A) | ||
@@ -19,0 +18,0 @@ |
| export declare function generate(date: Date, seed?: string): string; | ||
| export declare class InvalidDateRangeError extends Error { | ||
| constructor(); | ||
| } | ||
| export declare function generate_multi(startDate: Date, endDate: Date, seed?: string): { | ||
| date: Date; | ||
| password: string; | ||
| }[]; | ||
| export declare const DEFAULT_SEED = "MPSJKMDHAI"; |
| import { _ALPHANUM, _DEFAULT_SEED } from "./constants.js"; | ||
| import { indexers } from "./data.js"; | ||
| export function generate(date, seed = _DEFAULT_SEED) { | ||
| const idx = indexers(date, seed); | ||
| const passwordOfTheDay = []; | ||
| const len = idx.length; | ||
| for (let i = 0; i < len; i++) { | ||
| passwordOfTheDay[i] = _ALPHANUM[idx[i]]; | ||
| } | ||
| return passwordOfTheDay.join(''); | ||
| } | ||
| export class InvalidDateRangeError extends Error { | ||
| constructor() { | ||
| super('The start date must precede the end date.'); | ||
| } | ||
| } | ||
| export function generate_multi(startDate, endDate, seed = _DEFAULT_SEED) { | ||
| if (startDate > endDate) { | ||
| throw new InvalidDateRangeError(); | ||
| } | ||
| const days = 1 + Math.ceil((endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60 * 24)); | ||
| const passwordList = []; | ||
| for (let i = 0; i < days; i++) { | ||
| const date = new Date(new Date(startDate).setDate(startDate.getDate() + i)); | ||
| passwordList.push({ | ||
| 'date': date, | ||
| 'password': generate(date, seed) | ||
| }); | ||
| } | ||
| return passwordList; | ||
| } | ||
| export const DEFAULT_SEED = _DEFAULT_SEED; |
| export declare const _DEFAULT_SEED = "MPSJKMDHAI"; | ||
| export declare const _TABLE1: number[][]; | ||
| export declare const _TABLE2: number[][]; | ||
| export declare const _ALPHANUM: string[]; |
| export const _DEFAULT_SEED = 'MPSJKMDHAI'; | ||
| export const _TABLE1 = [ | ||
| [15, 15, 24, 20, 24], | ||
| [13, 14, 27, 32, 10], | ||
| [29, 14, 32, 29, 24], | ||
| [23, 32, 24, 29, 29], | ||
| [14, 29, 10, 21, 29], | ||
| [34, 27, 16, 23, 30], | ||
| [14, 22, 24, 17, 13] | ||
| ]; | ||
| export const _TABLE2 = [ | ||
| [0, 1, 2, 9, 3, 4, 5, 6, 7, 8], | ||
| [1, 4, 3, 9, 0, 7, 8, 2, 5, 6], | ||
| [7, 2, 8, 9, 4, 1, 6, 0, 3, 5], | ||
| [6, 3, 5, 9, 1, 8, 2, 7, 4, 0], | ||
| [4, 7, 0, 9, 5, 2, 3, 1, 8, 6], | ||
| [5, 6, 1, 9, 8, 0, 4, 3, 2, 7] | ||
| ]; | ||
| export const _ALPHANUM = [ | ||
| '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', | ||
| 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', | ||
| 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' | ||
| ]; |
| export declare function list1(date: Date): number[]; | ||
| export declare function list2(seed: string): number[]; | ||
| export declare function num8(l3: number[]): number; | ||
| export declare function list3(l1: number[], l2: number[]): number[]; | ||
| export declare function list4(l3: number[]): number[]; | ||
| export declare function list5(seed: string, l4: number[]): number[]; | ||
| export declare function indexers(date: Date, seed: string): number[]; |
-67
| import { _TABLE1, _TABLE2 } from "./constants.js"; | ||
| export function list1(date) { | ||
| // Last two digits of the year | ||
| const year = parseInt(date.getFullYear().toString(10).substr(2, 2), 10); | ||
| // Number of the month. The month in a Date object is zero-indexed, | ||
| // i.e., January == 0, so we add 1 to satisfy the algorithm. | ||
| const month = date.getMonth() + 1; | ||
| const dayOfMonth = date.getDate(); | ||
| // Day of the week. Normally 0 would be Sunday but we need it to be Monday. | ||
| let dayOfWeek = date.getDay() - 1; | ||
| if (dayOfWeek < 0) { | ||
| dayOfWeek = 6; | ||
| } | ||
| const list1Result = []; | ||
| for (let i = 0; i <= 4; i++) { | ||
| list1Result[i] = _TABLE1[dayOfWeek][i]; | ||
| } | ||
| list1Result[5] = dayOfMonth; | ||
| if (((year + month) - dayOfMonth) < 0) { | ||
| list1Result[6] = (((year + month) - dayOfMonth) + 36) % 36; | ||
| } | ||
| else { | ||
| list1Result[6] = ((year + month) - dayOfMonth) % 36; | ||
| } | ||
| list1Result[7] = (((3 + ((year + month) % 12)) * dayOfMonth) % 37) % 36; | ||
| return list1Result; | ||
| } | ||
| export function list2(seed) { | ||
| const list2Result = []; | ||
| for (let i = 0; i <= 7; i++) { | ||
| list2Result[i] = (seed.charCodeAt(i)) % 36; | ||
| } | ||
| return list2Result; | ||
| } | ||
| export function num8(l3) { | ||
| return l3[8] % 6; | ||
| } | ||
| export function list3(l1, l2) { | ||
| const list3Result = []; | ||
| for (let i = 0; i <= 7; i++) { | ||
| list3Result[i] = (((l1[i] + l2[i])) % 36); | ||
| } | ||
| list3Result[8] = (list3Result[0] + list3Result[1] + list3Result[2] + list3Result[3] + list3Result[4] + list3Result[5] + list3Result[6] + list3Result[7]) % 36; | ||
| list3Result[9] = Math.round(Math.pow(num8(list3Result), 2)); | ||
| return list3Result; | ||
| } | ||
| export function list4(l3) { | ||
| const list4Result = []; | ||
| for (let i = 0; i <= 9; i++) { | ||
| list4Result[i] = l3[_TABLE2[num8(l3)][i]]; | ||
| } | ||
| return list4Result; | ||
| } | ||
| export function list5(seed, l4) { | ||
| const list5Result = []; | ||
| for (let i = 0; i <= 9; i++) { | ||
| list5Result[i] = (seed.charCodeAt(i) + l4[i]) % 36; | ||
| } | ||
| return list5Result; | ||
| } | ||
| export function indexers(date, seed) { | ||
| const l1 = list1(date); | ||
| const l2 = list2(seed); | ||
| const l3 = list3(l1, l2); | ||
| const l4 = list4(l3); | ||
| return list5(seed, l4); | ||
| } |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
10627
1.43%3
-66.67%185
30.28%49
-2%1
Infinity%