Full Code of borfast/arrispwgen for AI

master e6ab28fba079 cached
14 files
26.3 KB
8.8k tokens
12 symbols
1 requests
Download .txt
Repository: borfast/arrispwgen
Branch: master
Commit: e6ab28fba079
Files: 14
Total size: 26.3 KB

Directory structure:
gitextract_4ktaz8mk/

├── .eslintrc.cjs
├── .gitignore
├── .travis.yml
├── LICENSE.txt
├── README.md
├── __tests__/
│   ├── arrispwgen.test.ts
│   ├── data.test.ts
│   └── helper_data.ts
├── jest.config.mjs
├── package.json
├── src/
│   ├── arrispwgen.ts
│   ├── constants.ts
│   └── data.ts
└── tsconfig.json

================================================
FILE CONTENTS
================================================

================================================
FILE: .eslintrc.cjs
================================================
module.exports = {
    "env": {
        "browser": true,
        "node": true,
        "jest": true,
        "commonjs": false,
        "es6": true,
        "es2017": true,
        "es2020": true
    },
    "extends": "eslint:recommended",
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "ecmaVersion": 11,
        "sourceType": "module",
        "ecmaFeatures": {
            "impliedStrict": true
        }
    },
    "rules": {
        "indent": [
            "error",
            4
        ],
        "linebreak-style": [
            "error",
            "unix"
        ],
        "quotes": [
            "error",
            "single"
        ],
        "semi": [
            "error",
            "always"
        ]
    }
};


================================================
FILE: .gitignore
================================================
lib
node_modules
coverage
others
.idea


================================================
FILE: .travis.yml
================================================
language: node_js
node_js:
  - "13"

================================================
FILE: LICENSE.txt
================================================
MIT License

Copyright (c) 2017 Raúl Pedro Fernandes Santos

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

================================================
FILE: README.md
================================================
# Arris Password of the Day Generator

-----------------------------------

**PLEASE READ THIS!**

1 - 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.

2 - 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.

-----------------------------------

[![NPM Version](https://img.shields.io/npm/v/@borfast/arrispwgen.svg?style=flat)](https://npmjs.org/package/@borfast/arrispwgen)
![License](https://img.shields.io/github/license/borfast/arrispwgen)
[![Build Status](https://travis-ci.org/borfast/arrispwgen.svg?branch=master)](https://travis-ci.org/borfast/arrispwgen)
[![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)
[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/B0B61NQ8A)

Do 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!

## Description

This is the _library_ that implements the [Arris password of the day generator](https://arrispwgen.borfast.com) for various Arris cable modems.

Unless 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)).

For a list of supported modems, troubleshooting options and more information, please visit the [help page](https://arrispwgen.borfast.com/help).


## How to use

Install with `npm install @borfast/arrispwgen`.

The 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.

`generate()` has one required parameter and one optional parameter:

* `date` (required): a `Date` object representing the date for which a password should be generated;
* `seed` (optional): a string to be used as the seed for the password generator.

It returns a string which is the password for the given date.

`generate_multi()` has two required parameters and one optional parameter:

* `startdate` (required): a `Date` object representing the _first_ date for which a password should be generated;
* `enddate` (required): a `Date` object representing the _last_ date for which a password should be generated;
* `seed` (optional): a string to be used as the seed for the password generator.

It returns an array of objects with two fields: `date`, a `Date` object, and `password`, the password for the corresponding date.


================================================
FILE: __tests__/arrispwgen.test.ts
================================================
import {customSeed, customSeedPotds, defaultSeedPotds, testDates} from './helper_data';
import * as a from '../src/arrispwgen';
import {expect, test} from '@jest/globals';


test.each([
    [defaultSeedPotds],
    [customSeedPotds, customSeed]
])('Should 22222 generate the correct password for the given days with the given seed', (potd: string[], seed: string|undefined = undefined) => {
    testDates.forEach( (date, i) => {
        const password = a.generate(new Date(date), seed);
        expect(password).toBe(potd[i]);
    });
});


test('Should throw an exception if start date is after end date', () => {
    const fn = () => {
        const d1 = new Date(2016, 1, 10);
        const d2 = new Date(2016, 1, 5);
        a.generate_multi(d1, d2);
    };

    expect(fn).toThrow(a.InvalidDateRangeError);
});


test('Should generate a single password if the date interval is just one day', () => {
    const d1 = new Date(2016, 1, 5);
    const d2 = new Date(2016, 1, 5);
    const potd = a.generate_multi(d1, d2);

    expect(potd.length).toBe(1);
});


test.each([
    [defaultSeedPotds, 0, 3],
    [defaultSeedPotds, 4, 6],
    [customSeedPotds, 0, 3, customSeed],
    [customSeedPotds, 4, 6, customSeed]
])('Should generate the correct passwords for the given date interval', (potdList: string[], startIndex: number, endIndex: number, seed: string|undefined = undefined) => {
    const count = endIndex - startIndex + 1;
    const startDate = new Date(testDates[startIndex]);
    const endDate = new Date(testDates[endIndex]);
    const potd = a.generate_multi(startDate, endDate, seed);

    expect(potd.length).toBe(count);
    for (let i = startIndex; i <= endIndex; i++) {
        const date = potd[i - startIndex].date;
        const password = potd[i - startIndex].password;
        expect(date).toEqual(new Date(testDates[i]));
        expect(password).toBe(potdList[i]);
    }
});


================================================
FILE: __tests__/data.test.ts
================================================
import {
    customSeed,
    testDates,
    testList1,
    testList2UsingCustomSeed,
    testList2UsingDefaultSeed,
    testList3UsingCustomSeed,
    testList3UsingDefaultSeed,
    testList4UsingCustomSeed,
    testList4UsingDefaultSeed,
    testList5UsingCustomSeed,
    testList5UsingDefaultSeed,
    testNum8UsingCustomSeed,
    testNum8UsingDefaultSeed
} from './helper_data';
import {indexers, list1, list2, list3, list4, list5, num8} from '../src/data';
import {_DEFAULT_SEED} from '../src/constants';
import {expect, test} from '@jest/globals';


test('Should generate the correct "list1" for the given dates', () => {
    testDates.forEach((date: number, idx: number) => {
        const d = new Date(date);
        const l1 = list1(d);
        expect(l1).toEqual(expect.arrayContaining(testList1[idx]));
    });
});


test.each([
    [_DEFAULT_SEED, testList2UsingDefaultSeed],
    [customSeed, testList2UsingCustomSeed]
])('Should generate the correct "list2"', (seed: string, expected: string[]) => {
    const l2 = list2(seed);
    expect(l2).toEqual(expect.arrayContaining(expected));
});


test.each([
    [_DEFAULT_SEED, testList3UsingDefaultSeed],
    [customSeed, testList3UsingCustomSeed]
])('Should generate the correct "list3"', (seed: string, expected: number[][]) => {
    testDates.forEach( (date: number, idx: number) => {
        const d = new Date(date);
        const l1 = list1(d);
        const l2 = list2(seed);
        const l3 = list3(l1, l2);
        expect(l3).toEqual(expect.arrayContaining(expected[idx]));
    });
});


test.each([
    [_DEFAULT_SEED, testList4UsingDefaultSeed],
    [customSeed, testList4UsingCustomSeed]
])('Should generate the correct "list4"', (seed: string, expected: number[][]) => {
    testDates.forEach( (date: number, idx: number) => {
        const d = new Date(date);
        const l1 = list1(d);
        const l2 = list2(seed);
        const l3 = list3(l1, l2);
        const l4 = list4(l3);
        expect(l4).toEqual(expect.arrayContaining(expected[idx]));
    });
});


test.each([
    [_DEFAULT_SEED, testList5UsingDefaultSeed],
    [customSeed, testList5UsingCustomSeed]
])('Should generate the correct "list5"', (seed: string, expected: number[][]) => {
    testDates.forEach( (date: number, idx: number) => {
        const d = new Date(date);
        const l1 = list1(d);
        const l2 = list2(seed);
        const l3 = list3(l1, l2);
        const l4 = list4(l3);
        const l5 = list5(seed, l4);
        expect(l5).toEqual(expect.arrayContaining(expected[idx]));
    });
});


test.each([
    [_DEFAULT_SEED, testNum8UsingDefaultSeed],
    [customSeed, testNum8UsingCustomSeed]
])('Should generate the correct "num8"', (seed: string, expected: number[][]) => {
    testDates.forEach( (date: number, idx: number) => {
        const d = new Date(date);
        const l1 = list1(d);
        const l2 = list2(seed);
        const l3 = list3(l1, l2);
        const n8 = num8(l3);
        expect(n8).toBe(expected[idx]);
    });
});


test.each([
    [_DEFAULT_SEED, testList5UsingDefaultSeed],
    [customSeed, testList5UsingCustomSeed]
])('Should generate the correct "indexers"', (seed: string, expected: number[][]) => {
    testDates.forEach( (date, i) => {
        const d = new Date(date);
        const index = indexers(d, seed);
        expect(index).toEqual(expect.arrayContaining(expected[i]));
    });
});


================================================
FILE: __tests__/helper_data.ts
================================================
// Note: the month in a Date object is 0-indexed, i.e. new Date(2016, 11, 20)
// is the 20th of December, 2016. Unfortunately, new Date(2016, 12, 20) will
// not produce an error and will happily and *silently* (yes...) give you a
// Date object representing the 20th of *January*, 2016. Nice, right?... :(
// These dates are stored as timestamps so they can be used to index
export const testDates: number[] = [
    (new Date(2016, 9, 19)).getTime(),
    (new Date(2016, 9, 20)).getTime(),
    (new Date(2016, 9, 21)).getTime(),
    (new Date(2016, 9, 22)).getTime(),
    (new Date(2016, 10, 1)).getTime(),
    (new Date(2016, 10, 2)).getTime(),
    (new Date(2016, 10, 3)).getTime()
];

export const defaultSeedPotds: string[] = [
    'RZ631QL7H4',
    '730B78VQPT',
    '13UITQJ132',
    '8722S2N0T7',
    'R6HBPKY66J',
    'CTXRK3NV0D',
    'N776Z9GSO9'
];

export const customSeed: string = 'ABCDEFGHIJ';

export const customSeedPotds: string[] = [
    'ZJC551QLMO',
    'BZLLEEPPKS',
    '0H0WEOI4WQ',
    'T5F0OJ2RKM',
    'SJ3LQ46SN8',
    '1FKXJAUR1Q',
    'JCBCYHOQBP'
];

// "list" values

/**
 * list 1 is always the same for both default and custom seeds
 * because it only depends on the date.
 */
export const testList1: number[][] = [
    [ 29, 14, 32, 29, 24, 19, 7, 21 ],
    [ 23, 32, 24, 29, 29, 20, 6, 26 ],
    [ 14, 29, 10, 21, 29, 21, 5, 31 ],
    [ 34, 27, 16, 23, 30, 22, 4, 0 ],
    [ 13, 14, 27, 32, 10, 1, 26, 6 ],
    [ 29, 14, 32, 29, 24, 2, 25, 12 ],
    [ 23, 32, 24, 29, 29, 3, 24, 18 ]
];

// "list" values using default seed.

export const testList2UsingDefaultSeed: number[] = [ 5, 8, 11, 2, 3, 5, 32, 0 ];

export const testList3UsingDefaultSeed: number[][] = [
    [ 34, 22, 7, 31, 27, 24, 3, 21, 25, 1 ],
    [ 28, 4, 35, 31, 32, 25, 2, 26, 3, 9 ],
    [ 19, 1, 21, 23, 32, 26, 1, 31, 10, 16 ],
    [ 3, 35, 27, 25, 33, 27, 0, 0, 6, 0 ],
    [ 18, 22, 2, 34, 13, 6, 22, 6, 15, 9 ],
    [ 34, 22, 7, 31, 27, 7, 21, 12, 17, 25 ],
    [ 28, 4, 35, 31, 32, 8, 20, 18, 32, 4 ]
];

export const testList4UsingDefaultSeed: number[][] = [
    [ 22, 27, 31, 1, 34, 21, 25, 7, 24, 3 ],
    [ 2, 31, 25, 9, 4, 3, 35, 26, 32, 28 ],
    [ 32, 31, 19, 16, 26, 21, 23, 1, 10, 1 ],
    [ 3, 35, 27, 0, 25, 33, 27, 0, 0, 6 ],
    [ 22, 34, 6, 9, 22, 15, 2, 6, 13, 18 ],
    [ 7, 21, 22, 25, 17, 34, 27, 31, 7, 12 ],
    [ 18, 35, 32, 4, 32, 4, 20, 28, 31, 8 ]
];

export const testList5UsingDefaultSeed: number[][] = [
    [ 27, 35, 6, 3, 1, 26, 21, 7, 17, 4 ],
    [ 7, 3, 0, 11, 7, 8, 31, 26, 25, 29 ],
    [ 1, 3, 30, 18, 29, 26, 19, 1, 3, 2 ],
    [ 8, 7, 2, 2, 28, 2, 23, 0, 29, 7 ],
    [ 27, 6, 17, 11, 25, 20, 34, 6, 6, 19 ],
    [ 12, 29, 33, 27, 20, 3, 23, 31, 0, 13 ],
    [ 23, 7, 7, 6, 35, 9, 16, 28, 24, 9 ]
];

export const testNum8UsingDefaultSeed: number[] = [1, 3, 4, 0, 3, 5, 2];

// "list" values using custom seed.
export const testList2UsingCustomSeed: number[] = [ 29, 30, 31, 32, 33, 34, 35, 0 ];

export const testList3UsingCustomSeed: number[][] = [
    [ 22, 8, 27, 25, 21, 17, 6, 21, 3, 9 ],
    [ 16, 26, 19, 25, 26, 18, 5, 26, 17, 25 ],
    [ 7, 23, 5, 17, 26, 19, 4, 31, 24, 0 ],
    [ 27, 21, 11, 19, 27, 20, 3, 0, 20, 4 ],
    [ 6, 8, 22, 28, 7, 35, 25, 6, 29, 25 ],
    [ 22, 8, 27, 25, 21, 0, 24, 12, 31, 1 ],
    [ 16, 26, 19, 25, 26, 1, 23, 18, 10, 16 ]
];

export const testList4UsingCustomSeed: number[][] = [
    [ 6, 25, 17, 9, 8, 3, 27, 21, 21, 22 ],
    [ 18, 5, 26, 25, 17, 16, 26, 25, 19, 26 ],
    [ 7, 23, 5, 0, 17, 26, 19, 4, 31, 24 ],
    [ 0, 11, 20, 4, 27, 21, 3, 27, 19, 20 ],
    [ 35, 25, 8, 25, 29, 6, 7, 28, 22, 6 ],
    [ 8, 21, 25, 1, 22, 12, 31, 27, 0, 24 ],
    [ 26, 18, 16, 16, 1, 19, 25, 26, 10, 23 ]
];

export const testList5UsingCustomSeed: number[][] = [
    [ 35, 19, 12, 5, 5, 1, 26, 21, 22, 24 ],
    [ 11, 35, 21, 21, 14, 14, 25, 25, 20, 28 ],
    [ 0, 17, 0, 32, 14, 24, 18, 4, 32, 26 ],
    [ 29, 5, 15, 0, 24, 19, 2, 27, 20, 22 ],
    [ 28, 19, 3, 21, 26, 4, 6, 28, 23, 8 ],
    [ 1, 15, 20, 33, 19, 10, 30, 27, 1, 26 ],
    [ 19, 12, 11, 12, 34, 17, 24, 26, 11, 25 ]
];

export const testNum8UsingCustomSeed: number[] = [3, 5, 0, 2, 5, 1, 4];


================================================
FILE: jest.config.mjs
================================================
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html

export default {
    // All imported modules in your tests should be mocked automatically
    // automock: false,

    // Stop running tests after `n` failures
    // bail: 0,

    // Respect "browser" field in package.json when resolving modules
    // browser: false,

    // The directory where Jest should store its cached dependency information
    // cacheDirectory: "/tmp/jest_rs",

    // Automatically clear mock calls and instances between every test
    // clearMocks: false,

    // Indicates whether the coverage information should be collected while executing the test
    // collectCoverage: false,

    // An array of glob patterns indicating a set of files for which coverage information should be collected
    // collectCoverageFrom: undefined,

    // The directory where Jest should output its coverage files
    coverageDirectory: 'coverage',

    // An array of regexp pattern strings used to skip coverage collection
    coveragePathIgnorePatterns: [
        '/node_modules/'
    ],

    // A list of reporter names that Jest uses when writing coverage reports
    // coverageReporters: [
    //   "json",
    //   "text",
    //   "lcov",
    //   "clover"
    // ],

    // An object that configures minimum threshold enforcement for coverage results
    // coverageThreshold: undefined,

    // A path to a custom dependency extractor
    // dependencyExtractor: undefined,

    // Make calling deprecated APIs throw helpful error messages
    // errorOnDeprecated: false,

    // Force coverage collection from ignored files using an array of glob patterns
    // forceCoverageMatch: [],

    // A path to a module which exports an async function that is triggered once before all test suites
    // globalSetup: undefined,

    // A path to a module which exports an async function that is triggered once after all test suites
    // globalTeardown: undefined,

    // A set of global variables that need to be available in all test environments
    // globals: {},

    // 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.
    // maxWorkers: "50%",

    // An array of directory names to be searched recursively up from the requiring module's location
    // moduleDirectories: [
    //   "node_modules"
    // ],

    // An array of file extensions your modules use
    moduleFileExtensions: [
        'js',
        'ts'
    ],

    // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
    // moduleNameMapper: {},

    // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
    // modulePathIgnorePatterns: [],

    // Activates notifications for test results
    // notify: false,

    // An enum that specifies notification mode. Requires { notify: true }
    // notifyMode: "failure-change",

    // A preset that is used as a base for Jest's configuration
    preset: 'ts-jest',

    // Run tests from one or more projects
    // projects: undefined,

    // Use this configuration option to add custom reporters to Jest
    // reporters: undefined,

    // Automatically reset mock state between every test
    // resetMocks: false,

    // Reset the module registry before running each individual test
    // resetModules: false,

    // A path to a custom resolver
    // resolver: undefined,

    // Automatically restore mock state between every test
    // restoreMocks: false,

    // The root directory that Jest should scan for tests and modules within
    // rootDir: undefined,

    // A list of paths to directories that Jest should use to search for files in
    // roots: [
    //   "<rootDir>"
    // ],

    // Allows you to use a custom runner instead of Jest's default test runner
    // runner: "jest-runner",

    // The paths to modules that run some code to configure or set up the testing environment before each test
    // setupFiles: [],

    // A list of paths to modules that run some code to configure or set up the testing framework before each test
    // setupFilesAfterEnv: [],

    // A list of paths to snapshot serializer modules Jest should use for snapshot testing
    // snapshotSerializers: [],

    // The test environment that will be used for testing
    testEnvironment: 'node',

    // Options that will be passed to the testEnvironment
    // testEnvironmentOptions: {},

    // Adds a location field to test results
    // testLocationInResults: false,

    // The glob patterns Jest uses to detect test files
    // testMatch: [
    //   "**/__tests__/**/*.[jt]s?(x)",
    //   "**/?(*.)+(spec|test).[tj]s?(x)"
    // ],

    // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
    testPathIgnorePatterns: [
        '/node_modules/'
    ],

    // The regexp pattern or array of patterns that Jest uses to detect test files
    'testRegex': '/__tests__/.*\\.test\\.(ts|tsx|js)$',

    // This option allows the use of a custom results processor
    // testResultsProcessor: undefined,

    // This option allows use of a custom test runner
    // testRunner: "jasmine2",

    // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
    // testURL: "http://localhost",

    // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
    // timers: "real",

    // A map from regular expressions to paths to transformers
    'transform': {
        '\\.(ts|tsx)$': 'ts-jest'
    },

    // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
    // transformIgnorePatterns: [
    //   "/node_modules/"
    // ],

    // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
    // unmockedModulePathPatterns: undefined,

    // Indicates whether each individual test should be reported during the run
    // verbose: undefined,

    // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
    // watchPathIgnorePatterns: [],

    // Whether to use watchman for file crawling
    // watchman: true,
};


================================================
FILE: package.json
================================================
{
  "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.3",
    "@typescript-eslint/parser": "^2.34.0",
    "@zoltu/typescript-transformer-append-js-extension": "^1.0.1",
    "eslint": "^9.32.0",
    "jest": "^29.7.0",
    "ts-jest": "^25.5.1",
    "ttypescript": "^1.5.12",
    "typescript": "^3.9.7"
  },
  "engines": {
    "node": ">=13.2.0",
    "npm": ">=6"
  }
}


================================================
FILE: src/arrispwgen.ts
================================================
import {_ALPHANUM, _DEFAULT_SEED} from './constants';
import {indexers} from './data';


export function generate(date: Date, seed: string = _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: Date, endDate: Date, seed: string = _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;


================================================
FILE: src/constants.ts
================================================
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'
];


================================================
FILE: src/data.ts
================================================
import {_TABLE1, _TABLE2} from './constants';


export function list1(date: Date): number[] {
    // 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: string): number[] {
    const list2Result = [];

    for (let i = 0; i <= 7; i++) {
        list2Result[i] = (seed.charCodeAt(i)) % 36;
    }

    return list2Result;
}

export function num8(l3: number[]): number {
    return l3[8] % 6;
}

export function list3(l1: number[], l2: number[]): number[] {
    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: number[]): number[] {
    const list4Result = [];

    for (let i = 0; i <= 9; i++) {
        list4Result[i] = l3[_TABLE2[num8(l3)][i]];
    }

    return list4Result;
}

export function list5(seed: string, l4: number[]): number[] {
    const list5Result = [];

    for (let i = 0; i <= 9; i++) {
        list5Result[i] = (seed.charCodeAt(i) + l4[i]) % 36;
    }

    return list5Result;
}

export function indexers(date: Date, seed: string): number[] {
    const l1 = list1(date);
    const l2 = list2(seed);
    const l3 = list3(l1, l2);
    const l4 = list4(l3);

    return list5(seed, l4);
}


================================================
FILE: tsconfig.json
================================================
{
  "compilerOptions": {
    "outDir": "./lib",
    "target": "ESNext",
    "module": "ESNext",
    "alwaysStrict": true,
    "strict": true,
    "types": ["node"],
    "declaration": true,
    "plugins": [
      {
        "transform": "@zoltu/typescript-transformer-append-js-extension/output/index.js",
        "after": true
      }
    ]
  },
  "include": [
    "./src/**/*"
  ]
}
Download .txt
gitextract_4ktaz8mk/

├── .eslintrc.cjs
├── .gitignore
├── .travis.yml
├── LICENSE.txt
├── README.md
├── __tests__/
│   ├── arrispwgen.test.ts
│   ├── data.test.ts
│   └── helper_data.ts
├── jest.config.mjs
├── package.json
├── src/
│   ├── arrispwgen.ts
│   ├── constants.ts
│   └── data.ts
└── tsconfig.json
Download .txt
SYMBOL INDEX (12 symbols across 2 files)

FILE: src/arrispwgen.ts
  function generate (line 5) | function generate(date: Date, seed: string = _DEFAULT_SEED) {
  class InvalidDateRangeError (line 19) | class InvalidDateRangeError extends Error {
    method constructor (line 20) | constructor() {
  function generate_multi (line 25) | function generate_multi(startDate: Date, endDate: Date, seed: string = _...
  constant DEFAULT_SEED (line 44) | const DEFAULT_SEED = _DEFAULT_SEED;

FILE: src/data.ts
  function list1 (line 4) | function list1(date: Date): number[] {
  function list2 (line 39) | function list2(seed: string): number[] {
  function num8 (line 49) | function num8(l3: number[]): number {
  function list3 (line 53) | function list3(l1: number[], l2: number[]): number[] {
  function list4 (line 67) | function list4(l3: number[]): number[] {
  function list5 (line 77) | function list5(seed: string, l4: number[]): number[] {
  function indexers (line 87) | function indexers(date: Date, seed: string): number[] {
Condensed preview — 14 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (29K chars).
[
  {
    "path": ".eslintrc.cjs",
    "chars": 755,
    "preview": "module.exports = {\n    \"env\": {\n        \"browser\": true,\n        \"node\": true,\n        \"jest\": true,\n        \"commonjs\":"
  },
  {
    "path": ".gitignore",
    "chars": 39,
    "preview": "lib\nnode_modules\ncoverage\nothers\n.idea\n"
  },
  {
    "path": ".travis.yml",
    "chars": 35,
    "preview": "language: node_js\nnode_js:\n  - \"13\""
  },
  {
    "path": "LICENSE.txt",
    "chars": 1083,
    "preview": "MIT License\n\nCopyright (c) 2017 Raúl Pedro Fernandes Santos\n\nPermission is hereby granted, free of charge, to any person"
  },
  {
    "path": "README.md",
    "chars": 3132,
    "preview": "# Arris Password of the Day Generator\n\n-----------------------------------\n\n**PLEASE READ THIS!**\n\n1 - In the past few y"
  },
  {
    "path": "__tests__/arrispwgen.test.ts",
    "chars": 1900,
    "preview": "import {customSeed, customSeedPotds, defaultSeedPotds, testDates} from './helper_data';\nimport * as a from '../src/arris"
  },
  {
    "path": "__tests__/data.test.ts",
    "chars": 3393,
    "preview": "import {\n    customSeed,\n    testDates,\n    testList1,\n    testList2UsingCustomSeed,\n    testList2UsingDefaultSeed,\n    "
  },
  {
    "path": "__tests__/helper_data.ts",
    "chars": 4141,
    "preview": "// Note: the month in a Date object is 0-indexed, i.e. new Date(2016, 11, 20)\n// is the 20th of December, 2016. Unfortun"
  },
  {
    "path": "jest.config.mjs",
    "chars": 6583,
    "preview": "// For a detailed explanation regarding each configuration property, visit:\n// https://jestjs.io/docs/en/configuration.h"
  },
  {
    "path": "package.json",
    "chars": 1292,
    "preview": "{\n  \"name\": \"@borfast/arrispwgen\",\n  \"version\": \"5.0.1\",\n  \"description\": \"Arris Password of the Day Generator reusable "
  },
  {
    "path": "src/arrispwgen.ts",
    "chars": 1143,
    "preview": "import {_ALPHANUM, _DEFAULT_SEED} from './constants';\nimport {indexers} from './data';\n\n\nexport function generate(date: "
  },
  {
    "path": "src/constants.ts",
    "chars": 719,
    "preview": "export const _DEFAULT_SEED = 'MPSJKMDHAI';\n\nexport const _TABLE1 = [\n    [15, 15, 24, 20, 24],\n    [13, 14, 27, 32, 10],"
  },
  {
    "path": "src/data.ts",
    "chars": 2382,
    "preview": "import {_TABLE1, _TABLE2} from './constants';\n\n\nexport function list1(date: Date): number[] {\n    // Last two digits of "
  },
  {
    "path": "tsconfig.json",
    "chars": 384,
    "preview": "{\n  \"compilerOptions\": {\n    \"outDir\": \"./lib\",\n    \"target\": \"ESNext\",\n    \"module\": \"ESNext\",\n    \"alwaysStrict\": true"
  }
]

About this extraction

This page contains the full source code of the borfast/arrispwgen GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 14 files (26.3 KB), approximately 8.8k tokens, and a symbol index with 12 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!