[
  {
    "path": ".eslintrc.cjs",
    "content": "module.exports = {\n    \"env\": {\n        \"browser\": true,\n        \"node\": true,\n        \"jest\": true,\n        \"commonjs\": false,\n        \"es6\": true,\n        \"es2017\": true,\n        \"es2020\": true\n    },\n    \"extends\": \"eslint:recommended\",\n    \"parser\": \"@typescript-eslint/parser\",\n    \"parserOptions\": {\n        \"ecmaVersion\": 11,\n        \"sourceType\": \"module\",\n        \"ecmaFeatures\": {\n            \"impliedStrict\": true\n        }\n    },\n    \"rules\": {\n        \"indent\": [\n            \"error\",\n            4\n        ],\n        \"linebreak-style\": [\n            \"error\",\n            \"unix\"\n        ],\n        \"quotes\": [\n            \"error\",\n            \"single\"\n        ],\n        \"semi\": [\n            \"error\",\n            \"always\"\n        ]\n    }\n};\n"
  },
  {
    "path": ".gitignore",
    "content": "lib\nnode_modules\ncoverage\nothers\n.idea\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: node_js\nnode_js:\n  - \"13\""
  },
  {
    "path": "LICENSE.txt",
    "content": "MIT License\n\nCopyright (c) 2017 Raúl Pedro Fernandes Santos\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE."
  },
  {
    "path": "README.md",
    "content": "# Arris Password of the Day Generator\n\n-----------------------------------\n\n**PLEASE READ THIS!**\n\n1 - In the past few years, some internet service providers have been changing their modem configurations in ways that prevent this tool from working. If it doesn't work with your modem even though it is in the supported modems list, I'm afraid there's nothing I can do about it.\n\n2 - I am not Spanish or from Latin America. Please don't assume I can speak Spanish or that I have to reply to you in Spanish.\n\n-----------------------------------\n\n[![NPM Version](https://img.shields.io/npm/v/@borfast/arrispwgen.svg?style=flat)](https://npmjs.org/package/@borfast/arrispwgen)\n![License](https://img.shields.io/github/license/borfast/arrispwgen)\n[![Build Status](https://travis-ci.org/borfast/arrispwgen.svg?branch=master)](https://travis-ci.org/borfast/arrispwgen)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/borfast/arrispwgen/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/borfast/arrispwgen/?branch=master)\n[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/B0B61NQ8A)\n\nDo you need an Arris modem password? Are you stuck with your Arris modem, in a message that says \"in order to access advanced features you must enter the password of the day\"? Then you came to the right place!\n\n## Description\n\nThis is the _library_ that implements the [Arris password of the day generator](https://arrispwgen.borfast.com) for various Arris cable modems.\n\nUnless you want to help with the code or use it in your own project, you are probably just interested in the [online generator](https://arrispwgen.borfast.com). You may also want to check the [CLI](https://github.com/borfast/arrispwgen-cli) or the [Android app](https://play.google.com/store/apps/details?id=com.grounduphq.arrispwgen) (which is also [open source](https://github.com/borfast/arrispwgen-android)).\n\nFor a list of supported modems, troubleshooting options and more information, please visit the [help page](https://arrispwgen.borfast.com/help).\n\n\n## How to use\n\nInstall with `npm install @borfast/arrispwgen`.\n\nThe API consists of only two functions: `generate()`, to generate a single password for a given date, and `generate_multi()`, to generate multiple passwords for a range of dates.\n\n`generate()` has one required parameter and one optional parameter:\n\n* `date` (required): a `Date` object representing the date for which a password should be generated;\n* `seed` (optional): a string to be used as the seed for the password generator.\n\nIt returns a string which is the password for the given date.\n\n`generate_multi()` has two required parameters and one optional parameter:\n\n* `startdate` (required): a `Date` object representing the _first_ date for which a password should be generated;\n* `enddate` (required): a `Date` object representing the _last_ date for which a password should be generated;\n* `seed` (optional): a string to be used as the seed for the password generator.\n\nIt returns an array of objects with two fields: `date`, a `Date` object, and `password`, the password for the corresponding date.\n"
  },
  {
    "path": "__tests__/arrispwgen.test.ts",
    "content": "import {customSeed, customSeedPotds, defaultSeedPotds, testDates} from './helper_data';\nimport * as a from '../src/arrispwgen';\nimport {expect, test} from '@jest/globals';\n\n\ntest.each([\n    [defaultSeedPotds],\n    [customSeedPotds, customSeed]\n])('Should 22222 generate the correct password for the given days with the given seed', (potd: string[], seed: string|undefined = undefined) => {\n    testDates.forEach( (date, i) => {\n        const password = a.generate(new Date(date), seed);\n        expect(password).toBe(potd[i]);\n    });\n});\n\n\ntest('Should throw an exception if start date is after end date', () => {\n    const fn = () => {\n        const d1 = new Date(2016, 1, 10);\n        const d2 = new Date(2016, 1, 5);\n        a.generate_multi(d1, d2);\n    };\n\n    expect(fn).toThrow(a.InvalidDateRangeError);\n});\n\n\ntest('Should generate a single password if the date interval is just one day', () => {\n    const d1 = new Date(2016, 1, 5);\n    const d2 = new Date(2016, 1, 5);\n    const potd = a.generate_multi(d1, d2);\n\n    expect(potd.length).toBe(1);\n});\n\n\ntest.each([\n    [defaultSeedPotds, 0, 3],\n    [defaultSeedPotds, 4, 6],\n    [customSeedPotds, 0, 3, customSeed],\n    [customSeedPotds, 4, 6, customSeed]\n])('Should generate the correct passwords for the given date interval', (potdList: string[], startIndex: number, endIndex: number, seed: string|undefined = undefined) => {\n    const count = endIndex - startIndex + 1;\n    const startDate = new Date(testDates[startIndex]);\n    const endDate = new Date(testDates[endIndex]);\n    const potd = a.generate_multi(startDate, endDate, seed);\n\n    expect(potd.length).toBe(count);\n    for (let i = startIndex; i <= endIndex; i++) {\n        const date = potd[i - startIndex].date;\n        const password = potd[i - startIndex].password;\n        expect(date).toEqual(new Date(testDates[i]));\n        expect(password).toBe(potdList[i]);\n    }\n});\n"
  },
  {
    "path": "__tests__/data.test.ts",
    "content": "import {\n    customSeed,\n    testDates,\n    testList1,\n    testList2UsingCustomSeed,\n    testList2UsingDefaultSeed,\n    testList3UsingCustomSeed,\n    testList3UsingDefaultSeed,\n    testList4UsingCustomSeed,\n    testList4UsingDefaultSeed,\n    testList5UsingCustomSeed,\n    testList5UsingDefaultSeed,\n    testNum8UsingCustomSeed,\n    testNum8UsingDefaultSeed\n} from './helper_data';\nimport {indexers, list1, list2, list3, list4, list5, num8} from '../src/data';\nimport {_DEFAULT_SEED} from '../src/constants';\nimport {expect, test} from '@jest/globals';\n\n\ntest('Should generate the correct \"list1\" for the given dates', () => {\n    testDates.forEach((date: number, idx: number) => {\n        const d = new Date(date);\n        const l1 = list1(d);\n        expect(l1).toEqual(expect.arrayContaining(testList1[idx]));\n    });\n});\n\n\ntest.each([\n    [_DEFAULT_SEED, testList2UsingDefaultSeed],\n    [customSeed, testList2UsingCustomSeed]\n])('Should generate the correct \"list2\"', (seed: string, expected: string[]) => {\n    const l2 = list2(seed);\n    expect(l2).toEqual(expect.arrayContaining(expected));\n});\n\n\ntest.each([\n    [_DEFAULT_SEED, testList3UsingDefaultSeed],\n    [customSeed, testList3UsingCustomSeed]\n])('Should generate the correct \"list3\"', (seed: string, expected: number[][]) => {\n    testDates.forEach( (date: number, idx: number) => {\n        const d = new Date(date);\n        const l1 = list1(d);\n        const l2 = list2(seed);\n        const l3 = list3(l1, l2);\n        expect(l3).toEqual(expect.arrayContaining(expected[idx]));\n    });\n});\n\n\ntest.each([\n    [_DEFAULT_SEED, testList4UsingDefaultSeed],\n    [customSeed, testList4UsingCustomSeed]\n])('Should generate the correct \"list4\"', (seed: string, expected: number[][]) => {\n    testDates.forEach( (date: number, idx: number) => {\n        const d = new Date(date);\n        const l1 = list1(d);\n        const l2 = list2(seed);\n        const l3 = list3(l1, l2);\n        const l4 = list4(l3);\n        expect(l4).toEqual(expect.arrayContaining(expected[idx]));\n    });\n});\n\n\ntest.each([\n    [_DEFAULT_SEED, testList5UsingDefaultSeed],\n    [customSeed, testList5UsingCustomSeed]\n])('Should generate the correct \"list5\"', (seed: string, expected: number[][]) => {\n    testDates.forEach( (date: number, idx: number) => {\n        const d = new Date(date);\n        const l1 = list1(d);\n        const l2 = list2(seed);\n        const l3 = list3(l1, l2);\n        const l4 = list4(l3);\n        const l5 = list5(seed, l4);\n        expect(l5).toEqual(expect.arrayContaining(expected[idx]));\n    });\n});\n\n\ntest.each([\n    [_DEFAULT_SEED, testNum8UsingDefaultSeed],\n    [customSeed, testNum8UsingCustomSeed]\n])('Should generate the correct \"num8\"', (seed: string, expected: number[][]) => {\n    testDates.forEach( (date: number, idx: number) => {\n        const d = new Date(date);\n        const l1 = list1(d);\n        const l2 = list2(seed);\n        const l3 = list3(l1, l2);\n        const n8 = num8(l3);\n        expect(n8).toBe(expected[idx]);\n    });\n});\n\n\ntest.each([\n    [_DEFAULT_SEED, testList5UsingDefaultSeed],\n    [customSeed, testList5UsingCustomSeed]\n])('Should generate the correct \"indexers\"', (seed: string, expected: number[][]) => {\n    testDates.forEach( (date, i) => {\n        const d = new Date(date);\n        const index = indexers(d, seed);\n        expect(index).toEqual(expect.arrayContaining(expected[i]));\n    });\n});\n"
  },
  {
    "path": "__tests__/helper_data.ts",
    "content": "// Note: the month in a Date object is 0-indexed, i.e. new Date(2016, 11, 20)\n// is the 20th of December, 2016. Unfortunately, new Date(2016, 12, 20) will\n// not produce an error and will happily and *silently* (yes...) give you a\n// Date object representing the 20th of *January*, 2016. Nice, right?... :(\n// These dates are stored as timestamps so they can be used to index\nexport const testDates: number[] = [\n    (new Date(2016, 9, 19)).getTime(),\n    (new Date(2016, 9, 20)).getTime(),\n    (new Date(2016, 9, 21)).getTime(),\n    (new Date(2016, 9, 22)).getTime(),\n    (new Date(2016, 10, 1)).getTime(),\n    (new Date(2016, 10, 2)).getTime(),\n    (new Date(2016, 10, 3)).getTime()\n];\n\nexport const defaultSeedPotds: string[] = [\n    'RZ631QL7H4',\n    '730B78VQPT',\n    '13UITQJ132',\n    '8722S2N0T7',\n    'R6HBPKY66J',\n    'CTXRK3NV0D',\n    'N776Z9GSO9'\n];\n\nexport const customSeed: string = 'ABCDEFGHIJ';\n\nexport const customSeedPotds: string[] = [\n    'ZJC551QLMO',\n    'BZLLEEPPKS',\n    '0H0WEOI4WQ',\n    'T5F0OJ2RKM',\n    'SJ3LQ46SN8',\n    '1FKXJAUR1Q',\n    'JCBCYHOQBP'\n];\n\n// \"list\" values\n\n/**\n * list 1 is always the same for both default and custom seeds\n * because it only depends on the date.\n */\nexport const testList1: number[][] = [\n    [ 29, 14, 32, 29, 24, 19, 7, 21 ],\n    [ 23, 32, 24, 29, 29, 20, 6, 26 ],\n    [ 14, 29, 10, 21, 29, 21, 5, 31 ],\n    [ 34, 27, 16, 23, 30, 22, 4, 0 ],\n    [ 13, 14, 27, 32, 10, 1, 26, 6 ],\n    [ 29, 14, 32, 29, 24, 2, 25, 12 ],\n    [ 23, 32, 24, 29, 29, 3, 24, 18 ]\n];\n\n// \"list\" values using default seed.\n\nexport const testList2UsingDefaultSeed: number[] = [ 5, 8, 11, 2, 3, 5, 32, 0 ];\n\nexport const testList3UsingDefaultSeed: number[][] = [\n    [ 34, 22, 7, 31, 27, 24, 3, 21, 25, 1 ],\n    [ 28, 4, 35, 31, 32, 25, 2, 26, 3, 9 ],\n    [ 19, 1, 21, 23, 32, 26, 1, 31, 10, 16 ],\n    [ 3, 35, 27, 25, 33, 27, 0, 0, 6, 0 ],\n    [ 18, 22, 2, 34, 13, 6, 22, 6, 15, 9 ],\n    [ 34, 22, 7, 31, 27, 7, 21, 12, 17, 25 ],\n    [ 28, 4, 35, 31, 32, 8, 20, 18, 32, 4 ]\n];\n\nexport const testList4UsingDefaultSeed: number[][] = [\n    [ 22, 27, 31, 1, 34, 21, 25, 7, 24, 3 ],\n    [ 2, 31, 25, 9, 4, 3, 35, 26, 32, 28 ],\n    [ 32, 31, 19, 16, 26, 21, 23, 1, 10, 1 ],\n    [ 3, 35, 27, 0, 25, 33, 27, 0, 0, 6 ],\n    [ 22, 34, 6, 9, 22, 15, 2, 6, 13, 18 ],\n    [ 7, 21, 22, 25, 17, 34, 27, 31, 7, 12 ],\n    [ 18, 35, 32, 4, 32, 4, 20, 28, 31, 8 ]\n];\n\nexport const testList5UsingDefaultSeed: number[][] = [\n    [ 27, 35, 6, 3, 1, 26, 21, 7, 17, 4 ],\n    [ 7, 3, 0, 11, 7, 8, 31, 26, 25, 29 ],\n    [ 1, 3, 30, 18, 29, 26, 19, 1, 3, 2 ],\n    [ 8, 7, 2, 2, 28, 2, 23, 0, 29, 7 ],\n    [ 27, 6, 17, 11, 25, 20, 34, 6, 6, 19 ],\n    [ 12, 29, 33, 27, 20, 3, 23, 31, 0, 13 ],\n    [ 23, 7, 7, 6, 35, 9, 16, 28, 24, 9 ]\n];\n\nexport const testNum8UsingDefaultSeed: number[] = [1, 3, 4, 0, 3, 5, 2];\n\n// \"list\" values using custom seed.\nexport const testList2UsingCustomSeed: number[] = [ 29, 30, 31, 32, 33, 34, 35, 0 ];\n\nexport const testList3UsingCustomSeed: number[][] = [\n    [ 22, 8, 27, 25, 21, 17, 6, 21, 3, 9 ],\n    [ 16, 26, 19, 25, 26, 18, 5, 26, 17, 25 ],\n    [ 7, 23, 5, 17, 26, 19, 4, 31, 24, 0 ],\n    [ 27, 21, 11, 19, 27, 20, 3, 0, 20, 4 ],\n    [ 6, 8, 22, 28, 7, 35, 25, 6, 29, 25 ],\n    [ 22, 8, 27, 25, 21, 0, 24, 12, 31, 1 ],\n    [ 16, 26, 19, 25, 26, 1, 23, 18, 10, 16 ]\n];\n\nexport const testList4UsingCustomSeed: number[][] = [\n    [ 6, 25, 17, 9, 8, 3, 27, 21, 21, 22 ],\n    [ 18, 5, 26, 25, 17, 16, 26, 25, 19, 26 ],\n    [ 7, 23, 5, 0, 17, 26, 19, 4, 31, 24 ],\n    [ 0, 11, 20, 4, 27, 21, 3, 27, 19, 20 ],\n    [ 35, 25, 8, 25, 29, 6, 7, 28, 22, 6 ],\n    [ 8, 21, 25, 1, 22, 12, 31, 27, 0, 24 ],\n    [ 26, 18, 16, 16, 1, 19, 25, 26, 10, 23 ]\n];\n\nexport const testList5UsingCustomSeed: number[][] = [\n    [ 35, 19, 12, 5, 5, 1, 26, 21, 22, 24 ],\n    [ 11, 35, 21, 21, 14, 14, 25, 25, 20, 28 ],\n    [ 0, 17, 0, 32, 14, 24, 18, 4, 32, 26 ],\n    [ 29, 5, 15, 0, 24, 19, 2, 27, 20, 22 ],\n    [ 28, 19, 3, 21, 26, 4, 6, 28, 23, 8 ],\n    [ 1, 15, 20, 33, 19, 10, 30, 27, 1, 26 ],\n    [ 19, 12, 11, 12, 34, 17, 24, 26, 11, 25 ]\n];\n\nexport const testNum8UsingCustomSeed: number[] = [3, 5, 0, 2, 5, 1, 4];\n"
  },
  {
    "path": "jest.config.mjs",
    "content": "// For a detailed explanation regarding each configuration property, visit:\n// https://jestjs.io/docs/en/configuration.html\n\nexport default {\n    // All imported modules in your tests should be mocked automatically\n    // automock: false,\n\n    // Stop running tests after `n` failures\n    // bail: 0,\n\n    // Respect \"browser\" field in package.json when resolving modules\n    // browser: false,\n\n    // The directory where Jest should store its cached dependency information\n    // cacheDirectory: \"/tmp/jest_rs\",\n\n    // Automatically clear mock calls and instances between every test\n    // clearMocks: false,\n\n    // Indicates whether the coverage information should be collected while executing the test\n    // collectCoverage: false,\n\n    // An array of glob patterns indicating a set of files for which coverage information should be collected\n    // collectCoverageFrom: undefined,\n\n    // The directory where Jest should output its coverage files\n    coverageDirectory: 'coverage',\n\n    // An array of regexp pattern strings used to skip coverage collection\n    coveragePathIgnorePatterns: [\n        '/node_modules/'\n    ],\n\n    // A list of reporter names that Jest uses when writing coverage reports\n    // coverageReporters: [\n    //   \"json\",\n    //   \"text\",\n    //   \"lcov\",\n    //   \"clover\"\n    // ],\n\n    // An object that configures minimum threshold enforcement for coverage results\n    // coverageThreshold: undefined,\n\n    // A path to a custom dependency extractor\n    // dependencyExtractor: undefined,\n\n    // Make calling deprecated APIs throw helpful error messages\n    // errorOnDeprecated: false,\n\n    // Force coverage collection from ignored files using an array of glob patterns\n    // forceCoverageMatch: [],\n\n    // A path to a module which exports an async function that is triggered once before all test suites\n    // globalSetup: undefined,\n\n    // A path to a module which exports an async function that is triggered once after all test suites\n    // globalTeardown: undefined,\n\n    // A set of global variables that need to be available in all test environments\n    // globals: {},\n\n    // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.\n    // maxWorkers: \"50%\",\n\n    // An array of directory names to be searched recursively up from the requiring module's location\n    // moduleDirectories: [\n    //   \"node_modules\"\n    // ],\n\n    // An array of file extensions your modules use\n    moduleFileExtensions: [\n        'js',\n        'ts'\n    ],\n\n    // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module\n    // moduleNameMapper: {},\n\n    // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader\n    // modulePathIgnorePatterns: [],\n\n    // Activates notifications for test results\n    // notify: false,\n\n    // An enum that specifies notification mode. Requires { notify: true }\n    // notifyMode: \"failure-change\",\n\n    // A preset that is used as a base for Jest's configuration\n    preset: 'ts-jest',\n\n    // Run tests from one or more projects\n    // projects: undefined,\n\n    // Use this configuration option to add custom reporters to Jest\n    // reporters: undefined,\n\n    // Automatically reset mock state between every test\n    // resetMocks: false,\n\n    // Reset the module registry before running each individual test\n    // resetModules: false,\n\n    // A path to a custom resolver\n    // resolver: undefined,\n\n    // Automatically restore mock state between every test\n    // restoreMocks: false,\n\n    // The root directory that Jest should scan for tests and modules within\n    // rootDir: undefined,\n\n    // A list of paths to directories that Jest should use to search for files in\n    // roots: [\n    //   \"<rootDir>\"\n    // ],\n\n    // Allows you to use a custom runner instead of Jest's default test runner\n    // runner: \"jest-runner\",\n\n    // The paths to modules that run some code to configure or set up the testing environment before each test\n    // setupFiles: [],\n\n    // A list of paths to modules that run some code to configure or set up the testing framework before each test\n    // setupFilesAfterEnv: [],\n\n    // A list of paths to snapshot serializer modules Jest should use for snapshot testing\n    // snapshotSerializers: [],\n\n    // The test environment that will be used for testing\n    testEnvironment: 'node',\n\n    // Options that will be passed to the testEnvironment\n    // testEnvironmentOptions: {},\n\n    // Adds a location field to test results\n    // testLocationInResults: false,\n\n    // The glob patterns Jest uses to detect test files\n    // testMatch: [\n    //   \"**/__tests__/**/*.[jt]s?(x)\",\n    //   \"**/?(*.)+(spec|test).[tj]s?(x)\"\n    // ],\n\n    // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped\n    testPathIgnorePatterns: [\n        '/node_modules/'\n    ],\n\n    // The regexp pattern or array of patterns that Jest uses to detect test files\n    'testRegex': '/__tests__/.*\\\\.test\\\\.(ts|tsx|js)$',\n\n    // This option allows the use of a custom results processor\n    // testResultsProcessor: undefined,\n\n    // This option allows use of a custom test runner\n    // testRunner: \"jasmine2\",\n\n    // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href\n    // testURL: \"http://localhost\",\n\n    // Setting this value to \"fake\" allows the use of fake timers for functions such as \"setTimeout\"\n    // timers: \"real\",\n\n    // A map from regular expressions to paths to transformers\n    'transform': {\n        '\\\\.(ts|tsx)$': 'ts-jest'\n    },\n\n    // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation\n    // transformIgnorePatterns: [\n    //   \"/node_modules/\"\n    // ],\n\n    // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them\n    // unmockedModulePathPatterns: undefined,\n\n    // Indicates whether each individual test should be reported during the run\n    // verbose: undefined,\n\n    // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode\n    // watchPathIgnorePatterns: [],\n\n    // Whether to use watchman for file crawling\n    // watchman: true,\n};\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"@borfast/arrispwgen\",\n  \"version\": \"5.0.1\",\n  \"description\": \"Arris Password of the Day Generator reusable library\",\n  \"keywords\": [\n    \"arris\",\n    \"arrispwd\",\n    \"arrispwgen\",\n    \"password-of-the-day\",\n    \"password of the day\"\n  ],\n  \"homepage\": \"https://arrispwgen.borfast.com\",\n  \"bugs\": {\n    \"url\": \"https://github.com/borfast/arrispwgen/issues\"\n  },\n  \"license\": \"MIT\",\n  \"author\": \"Raúl Santos (https://www.borfast.com)\",\n  \"main\": \"./lib/arrispwgen.js\",\n  \"type\": \"module\",\n  \"files\": [\n    \"/lib\",\n    \"./lib/arrispwgen.d.ts\"\n  ],\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git+https://github.com/borfast/arrispwgen.git\"\n  },\n  \"scripts\": {\n    \"build\": \"ttsc --project tsconfig.json\",\n    \"prepublishOnly\": \"npm run build\",\n    \"lint\": \"eslint -c .eslintrc.cjs 'src/**/*.{ts,tsx}' '__tests__/**/*.{ts,tsx}'\",\n    \"pretest\": \"npm run lint\",\n    \"test\": \"jest\"\n  },\n  \"devDependencies\": {\n    \"@jest/globals\": \"^25.5.2\",\n    \"@types/jest\": \"^25.2.3\",\n    \"@typescript-eslint/parser\": \"^2.34.0\",\n    \"@zoltu/typescript-transformer-append-js-extension\": \"^1.0.1\",\n    \"eslint\": \"^9.32.0\",\n    \"jest\": \"^29.7.0\",\n    \"ts-jest\": \"^25.5.1\",\n    \"ttypescript\": \"^1.5.12\",\n    \"typescript\": \"^3.9.7\"\n  },\n  \"engines\": {\n    \"node\": \">=13.2.0\",\n    \"npm\": \">=6\"\n  }\n}\n"
  },
  {
    "path": "src/arrispwgen.ts",
    "content": "import {_ALPHANUM, _DEFAULT_SEED} from './constants';\nimport {indexers} from './data';\n\n\nexport function generate(date: Date, seed: string = _DEFAULT_SEED) {\n    const idx = indexers(date, seed);\n\n    const passwordOfTheDay = [];\n\n    const len = idx.length;\n\n    for (let i = 0; i < len; i++) {\n        passwordOfTheDay[i] = _ALPHANUM[idx[i]];\n    }\n\n    return passwordOfTheDay.join('');\n}\n\nexport class InvalidDateRangeError extends Error {\n    constructor() {\n        super('The start date must precede the end date.');\n    }\n}\n\nexport function generate_multi(startDate: Date, endDate: Date, seed: string = _DEFAULT_SEED) {\n    if (startDate > endDate) {\n        throw new InvalidDateRangeError();\n    }\n\n    const days = 1 + Math.ceil((endDate.getTime() - startDate.getTime()) / (1000*60*60*24));\n\n    const passwordList = [];\n    for (let i = 0; i < days; i++) {\n        const date = new Date(new Date(startDate).setDate(startDate.getDate() + i));\n        passwordList.push({\n            'date': date,\n            'password': generate(date, seed)\n        });\n    }\n\n    return passwordList;\n}\n\nexport const DEFAULT_SEED = _DEFAULT_SEED;\n"
  },
  {
    "path": "src/constants.ts",
    "content": "export const _DEFAULT_SEED = 'MPSJKMDHAI';\n\nexport const _TABLE1 = [\n    [15, 15, 24, 20, 24],\n    [13, 14, 27, 32, 10],\n    [29, 14, 32, 29, 24],\n    [23, 32, 24, 29, 29],\n    [14, 29, 10, 21, 29],\n    [34, 27, 16, 23, 30],\n    [14, 22, 24, 17, 13]\n];\n\nexport const _TABLE2 = [\n    [0, 1, 2, 9, 3, 4, 5, 6, 7, 8],\n    [1, 4, 3, 9, 0, 7, 8, 2, 5, 6],\n    [7, 2, 8, 9, 4, 1, 6, 0, 3, 5],\n    [6, 3, 5, 9, 1, 8, 2, 7, 4, 0],\n    [4, 7, 0, 9, 5, 2, 3, 1, 8, 6],\n    [5, 6, 1, 9, 8, 0, 4, 3, 2, 7]\n];\n\nexport const _ALPHANUM = [\n    '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D',\n    'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',\n    'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'\n];\n"
  },
  {
    "path": "src/data.ts",
    "content": "import {_TABLE1, _TABLE2} from './constants';\n\n\nexport function list1(date: Date): number[] {\n    // Last two digits of the year\n    const year = parseInt(date.getFullYear().toString(10).substr(2, 2), 10);\n\n    // Number of the month. The month in a Date object is zero-indexed,\n    // i.e., January == 0, so we add 1 to satisfy the algorithm.\n    const month = date.getMonth() + 1;\n\n    const dayOfMonth = date.getDate();\n\n    // Day of the week. Normally 0 would be Sunday but we need it to be Monday.\n    let dayOfWeek = date.getDay() - 1;\n    if (dayOfWeek < 0) {\n        dayOfWeek = 6;\n    }\n\n    const list1Result = [];\n\n    for (let i = 0; i <= 4; i++) {\n        list1Result[i] = _TABLE1[dayOfWeek][i];\n    }\n\n    list1Result[5] = dayOfMonth;\n\n    if (((year + month) - dayOfMonth) < 0) {\n        list1Result[6] = (((year + month) - dayOfMonth) + 36) % 36;\n    } else {\n        list1Result[6] = ((year + month) - dayOfMonth) % 36;\n    }\n\n    list1Result[7] = (((3 + ((year + month) % 12)) * dayOfMonth) % 37) % 36;\n\n    return list1Result;\n}\n\nexport function list2(seed: string): number[] {\n    const list2Result = [];\n\n    for (let i = 0; i <= 7; i++) {\n        list2Result[i] = (seed.charCodeAt(i)) % 36;\n    }\n\n    return list2Result;\n}\n\nexport function num8(l3: number[]): number {\n    return l3[8] % 6;\n}\n\nexport function list3(l1: number[], l2: number[]): number[] {\n    const list3Result = [];\n\n    for (let i = 0; i <= 7; i++) {\n        list3Result[i] = (((l1[i] + l2[i])) % 36);\n    }\n\n    list3Result[8] = (list3Result[0] + list3Result[1] + list3Result[2] + list3Result[3] + list3Result[4] + list3Result[5] + list3Result[6] + list3Result[7]) % 36;\n\n    list3Result[9] = Math.round(Math.pow(num8(list3Result), 2));\n\n    return list3Result;\n}\n\nexport function list4(l3: number[]): number[] {\n    const list4Result = [];\n\n    for (let i = 0; i <= 9; i++) {\n        list4Result[i] = l3[_TABLE2[num8(l3)][i]];\n    }\n\n    return list4Result;\n}\n\nexport function list5(seed: string, l4: number[]): number[] {\n    const list5Result = [];\n\n    for (let i = 0; i <= 9; i++) {\n        list5Result[i] = (seed.charCodeAt(i) + l4[i]) % 36;\n    }\n\n    return list5Result;\n}\n\nexport function indexers(date: Date, seed: string): number[] {\n    const l1 = list1(date);\n    const l2 = list2(seed);\n    const l3 = list3(l1, l2);\n    const l4 = list4(l3);\n\n    return list5(seed, l4);\n}\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"outDir\": \"./lib\",\n    \"target\": \"ESNext\",\n    \"module\": \"ESNext\",\n    \"alwaysStrict\": true,\n    \"strict\": true,\n    \"types\": [\"node\"],\n    \"declaration\": true,\n    \"plugins\": [\n      {\n        \"transform\": \"@zoltu/typescript-transformer-append-js-extension/output/index.js\",\n        \"after\": true\n      }\n    ]\n  },\n  \"include\": [\n    \"./src/**/*\"\n  ]\n}\n"
  }
]