summaryrefslogtreecommitdiffstats
path: root/docusaurus/static/ajax/libs/wolfree/23.7.8/js/AppID.js
blob: 070e4e1f064f05bffd7f908bd1637b7421a7f391 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
 * @license
 * SPDX-License-Identifier: AGPL-3.0-or-later
 * This file is part of Wolfree.
 * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 */

// @ts-check

// To generate a new AppID:
//  1. Open Tor Browser and go to: https://products.wolframalpha.com/api/
//  2. Click the orangish "Get API Access" button. You will go to: https://account.wolfram.com/login/oauth2/sign-in
//  3. Click the reddish "Create one" hyperlink to create a new Wolfram ID. You will go to: https://account.wolfram.com/login/create
//  4. Fill out the form using random alphanumeric characters.
//  5. Click the reddish "Create Wolfram ID" button. You will go to: https://developer.wolframalpha.com/portal/myapps/index.html
//  6. Click the orangish "Sign up to get your first AppID" button.
//  7. Fill out the form using random alphanumeric characters.
//  8. Click the orangish "Sign up" button.
//  9. Click the orangish "Get an AppID" button.
// 10. Fill out the form using random alphanumeric characters.
// 11. Click the orangish "Get AppID" button.

export default class AppID {
  appIDArray = Array();

  constructor(
    appIDArray = ["H9V325-HTALUWHKGK", "AKJTJT-LR5LL8WTG6", "LKY83U-XW6ATU9URU"]
  ) {
    (this.appIDArray = appIDArray),
      Array.from(this.appIDArray).forEach(
        (appID) => (
          console.assert(17 === appID.length),
          console.assert(/[0-9A-Z]{6}-[0-9A-Z]{10}/.test(appID))
        )
      );
  }

  getAppID = ({
    appID = this.appIDArray[this.getRandomInt() % this.appIDArray.length],
  } = {}) => {
    try {
      return appID;
    } catch (error) {
      return console.error({ error }), String();
    }
  };

  getRandomInt = ({
    randomInt = crypto.getRandomValues(new Uint32Array(1))[0],
  } = {}) => {
    try {
      return randomInt;
    } catch (error) {
      return console.error({ error }), Number();
    }
  };
}