@anmiles/google-api-wrapper 7.0.6 → 7.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/.eslintrc.js +1 -86
  2. package/.gitlab-ci.yml +0 -1
  3. package/.vscode/settings.json +0 -4
  4. package/CHANGELOG.md +7 -0
  5. package/README.md +5 -2
  6. package/dist/index.d.ts +5 -5
  7. package/dist/index.js +15 -15
  8. package/dist/lib/api/calendar.d.ts +3 -3
  9. package/dist/lib/api/calendar.js +13 -13
  10. package/dist/lib/api/shared.d.ts +23 -23
  11. package/dist/lib/api/shared.js +23 -23
  12. package/dist/lib/api/shared.js.map +1 -1
  13. package/dist/lib/api/youtube.d.ts +3 -3
  14. package/dist/lib/api/youtube.js +13 -13
  15. package/dist/lib/auth.d.ts +10 -10
  16. package/dist/lib/auth.js +34 -34
  17. package/dist/lib/auth.js.map +1 -1
  18. package/dist/lib/jsonLib.d.ts +14 -14
  19. package/dist/lib/jsonLib.js +54 -55
  20. package/dist/lib/jsonLib.js.map +1 -1
  21. package/dist/lib/paths.d.ts +16 -16
  22. package/dist/lib/paths.js +45 -45
  23. package/dist/lib/profiles.d.ts +10 -10
  24. package/dist/lib/profiles.js +32 -33
  25. package/dist/lib/profiles.js.map +1 -1
  26. package/dist/lib/secrets.d.ts +22 -22
  27. package/dist/lib/secrets.js +150 -146
  28. package/dist/lib/secrets.js.map +1 -1
  29. package/dist/lib/sleep.d.ts +6 -6
  30. package/dist/lib/sleep.js +10 -10
  31. package/dist/types/common.d.ts +3 -3
  32. package/dist/types/common.js +2 -2
  33. package/dist/types/index.d.ts +2 -2
  34. package/dist/types/index.js +18 -18
  35. package/dist/types/secrets.d.ts +15 -15
  36. package/dist/types/secrets.js +2 -2
  37. package/package.json +16 -15
  38. package/src/lib/__tests__/auth.test.ts +23 -23
  39. package/src/lib/__tests__/jsonLib.test.ts +33 -41
  40. package/src/lib/__tests__/paths.test.ts +5 -5
  41. package/src/lib/__tests__/profiles.test.ts +10 -13
  42. package/src/lib/__tests__/secrets.test.ts +40 -48
  43. package/src/lib/api/__tests__/calendar.test.ts +3 -3
  44. package/src/lib/api/__tests__/shared.test.ts +10 -10
  45. package/src/lib/api/__tests__/youtube.test.ts +3 -3
  46. package/src/lib/api/shared.ts +1 -1
  47. package/src/lib/auth.ts +1 -1
  48. package/src/lib/jsonLib.ts +2 -2
  49. package/src/lib/profiles.ts +1 -2
  50. package/src/lib/secrets.ts +8 -4
  51. package/dist/lib/logger.d.ts +0 -12
  52. package/dist/lib/logger.js +0 -46
  53. package/dist/lib/logger.js.map +0 -1
  54. package/src/lib/__tests__/logger.test.ts +0 -57
  55. package/src/lib/logger.ts +0 -21
@@ -1,16 +1,16 @@
1
- export { ensureDir, ensureFile, getProfilesFile, getScopesFile, getSecretsFile, getCredentialsFile };
2
- declare const _default: {
3
- ensureDir: typeof ensureDir;
4
- ensureFile: typeof ensureFile;
5
- getProfilesFile: typeof getProfilesFile;
6
- getScopesFile: typeof getScopesFile;
7
- getSecretsFile: typeof getSecretsFile;
8
- getCredentialsFile: typeof getCredentialsFile;
9
- };
10
- export default _default;
11
- declare function ensureDir(dirPath: string): string;
12
- declare function ensureFile(filePath: string): string;
13
- declare function getProfilesFile(): string;
14
- declare function getScopesFile(): string;
15
- declare function getSecretsFile(profile: string): string;
16
- declare function getCredentialsFile(profile: string): string;
1
+ export { ensureDir, ensureFile, getProfilesFile, getScopesFile, getSecretsFile, getCredentialsFile };
2
+ declare const _default: {
3
+ ensureDir: typeof ensureDir;
4
+ ensureFile: typeof ensureFile;
5
+ getProfilesFile: typeof getProfilesFile;
6
+ getScopesFile: typeof getScopesFile;
7
+ getSecretsFile: typeof getSecretsFile;
8
+ getCredentialsFile: typeof getCredentialsFile;
9
+ };
10
+ export default _default;
11
+ declare function ensureDir(dirPath: string): string;
12
+ declare function ensureFile(filePath: string): string;
13
+ declare function getProfilesFile(): string;
14
+ declare function getScopesFile(): string;
15
+ declare function getSecretsFile(profile: string): string;
16
+ declare function getCredentialsFile(profile: string): string;
package/dist/lib/paths.js CHANGED
@@ -1,46 +1,46 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getCredentialsFile = exports.getSecretsFile = exports.getScopesFile = exports.getProfilesFile = exports.ensureFile = exports.ensureDir = void 0;
7
- const fs_1 = __importDefault(require("fs"));
8
- const path_1 = __importDefault(require("path"));
9
- const paths_1 = __importDefault(require("./paths"));
10
- exports.default = { ensureDir, ensureFile, getProfilesFile, getScopesFile, getSecretsFile, getCredentialsFile };
11
- const dirPaths = {
12
- input: 'input',
13
- secrets: 'secrets',
14
- };
15
- function ensureDir(dirPath) {
16
- if (!fs_1.default.existsSync(dirPath)) {
17
- fs_1.default.mkdirSync(dirPath, { recursive: true });
18
- }
19
- return dirPath;
20
- }
21
- exports.ensureDir = ensureDir;
22
- function ensureFile(filePath) {
23
- paths_1.default.ensureDir(path_1.default.dirname(filePath));
24
- if (!fs_1.default.existsSync(filePath)) {
25
- fs_1.default.writeFileSync(filePath, '');
26
- }
27
- return filePath;
28
- }
29
- exports.ensureFile = ensureFile;
30
- function getProfilesFile() {
31
- return path_1.default.join(dirPaths.input, 'profiles.json');
32
- }
33
- exports.getProfilesFile = getProfilesFile;
34
- function getScopesFile() {
35
- return 'scopes.json';
36
- }
37
- exports.getScopesFile = getScopesFile;
38
- function getSecretsFile(profile) {
39
- return path_1.default.join(dirPaths.secrets, `${profile}.json`);
40
- }
41
- exports.getSecretsFile = getSecretsFile;
42
- function getCredentialsFile(profile) {
43
- return path_1.default.join(dirPaths.secrets, `${profile}.credentials.json`);
44
- }
45
- exports.getCredentialsFile = getCredentialsFile;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getCredentialsFile = exports.getSecretsFile = exports.getScopesFile = exports.getProfilesFile = exports.ensureFile = exports.ensureDir = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const paths_1 = __importDefault(require("./paths"));
10
+ exports.default = { ensureDir, ensureFile, getProfilesFile, getScopesFile, getSecretsFile, getCredentialsFile };
11
+ const dirPaths = {
12
+ input: 'input',
13
+ secrets: 'secrets',
14
+ };
15
+ function ensureDir(dirPath) {
16
+ if (!fs_1.default.existsSync(dirPath)) {
17
+ fs_1.default.mkdirSync(dirPath, { recursive: true });
18
+ }
19
+ return dirPath;
20
+ }
21
+ exports.ensureDir = ensureDir;
22
+ function ensureFile(filePath) {
23
+ paths_1.default.ensureDir(path_1.default.dirname(filePath));
24
+ if (!fs_1.default.existsSync(filePath)) {
25
+ fs_1.default.writeFileSync(filePath, '');
26
+ }
27
+ return filePath;
28
+ }
29
+ exports.ensureFile = ensureFile;
30
+ function getProfilesFile() {
31
+ return path_1.default.join(dirPaths.input, 'profiles.json');
32
+ }
33
+ exports.getProfilesFile = getProfilesFile;
34
+ function getScopesFile() {
35
+ return 'scopes.json';
36
+ }
37
+ exports.getScopesFile = getScopesFile;
38
+ function getSecretsFile(profile) {
39
+ return path_1.default.join(dirPaths.secrets, `${profile}.json`);
40
+ }
41
+ exports.getSecretsFile = getSecretsFile;
42
+ function getCredentialsFile(profile) {
43
+ return path_1.default.join(dirPaths.secrets, `${profile}.credentials.json`);
44
+ }
45
+ exports.getCredentialsFile = getCredentialsFile;
46
46
  //# sourceMappingURL=paths.js.map
@@ -1,10 +1,10 @@
1
- export { getProfiles, setProfiles, createProfile };
2
- declare const _default: {
3
- getProfiles: typeof getProfiles;
4
- setProfiles: typeof setProfiles;
5
- createProfile: typeof createProfile;
6
- };
7
- export default _default;
8
- declare function getProfiles(): string[];
9
- declare function setProfiles(profiles: string[]): void;
10
- declare function createProfile(profile: string): void;
1
+ export { getProfiles, setProfiles, createProfile };
2
+ declare const _default: {
3
+ getProfiles: typeof getProfiles;
4
+ setProfiles: typeof setProfiles;
5
+ createProfile: typeof createProfile;
6
+ };
7
+ export default _default;
8
+ declare function getProfiles(): string[];
9
+ declare function setProfiles(profiles: string[]): void;
10
+ declare function createProfile(profile: string): void;
@@ -1,34 +1,33 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createProfile = exports.setProfiles = exports.getProfiles = void 0;
7
- const jsonLib_1 = require("./jsonLib");
8
- const logger_1 = require("./logger");
9
- const paths_1 = require("./paths");
10
- const profiles_1 = __importDefault(require("./profiles"));
11
- exports.default = { getProfiles, setProfiles, createProfile };
12
- function getProfiles() {
13
- const profilesFile = (0, paths_1.getProfilesFile)();
14
- return (0, jsonLib_1.getJSON)(profilesFile, () => []);
15
- }
16
- exports.getProfiles = getProfiles;
17
- function setProfiles(profiles) {
18
- const profilesFile = (0, paths_1.getProfilesFile)();
19
- (0, jsonLib_1.writeJSON)(profilesFile, profiles);
20
- }
21
- exports.setProfiles = setProfiles;
22
- function createProfile(profile) {
23
- if (!profile) {
24
- (0, logger_1.error)('Usage: `npm run create <profile>` where `profile` - is any profile name you want');
25
- }
26
- const existingProfiles = profiles_1.default.getProfiles();
27
- if (existingProfiles.includes(profile)) {
28
- return;
29
- }
30
- existingProfiles.push(profile);
31
- profiles_1.default.setProfiles(existingProfiles);
32
- }
33
- exports.createProfile = createProfile;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createProfile = exports.setProfiles = exports.getProfiles = void 0;
7
+ const jsonLib_1 = require("./jsonLib");
8
+ const paths_1 = require("./paths");
9
+ const profiles_1 = __importDefault(require("./profiles"));
10
+ exports.default = { getProfiles, setProfiles, createProfile };
11
+ function getProfiles() {
12
+ const profilesFile = (0, paths_1.getProfilesFile)();
13
+ return (0, jsonLib_1.getJSON)(profilesFile, () => []);
14
+ }
15
+ exports.getProfiles = getProfiles;
16
+ function setProfiles(profiles) {
17
+ const profilesFile = (0, paths_1.getProfilesFile)();
18
+ (0, jsonLib_1.writeJSON)(profilesFile, profiles);
19
+ }
20
+ exports.setProfiles = setProfiles;
21
+ function createProfile(profile) {
22
+ if (!profile) {
23
+ throw 'Usage: `npm run create <profile>` where `profile` - is any profile name you want';
24
+ }
25
+ const existingProfiles = profiles_1.default.getProfiles();
26
+ if (existingProfiles.includes(profile)) {
27
+ return;
28
+ }
29
+ existingProfiles.push(profile);
30
+ profiles_1.default.setProfiles(existingProfiles);
31
+ }
32
+ exports.createProfile = createProfile;
34
33
  //# sourceMappingURL=profiles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"profiles.js","sourceRoot":"","sources":["../../src/lib/profiles.ts"],"names":[],"mappings":";;;;;;AAAA,uCAA+C;AAC/C,qCAAiC;AACjC,mCAA0C;AAE1C,0DAAkC;AAGlC,kBAAe,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC;AAE3D,SAAS,WAAW;IACnB,MAAM,YAAY,GAAG,IAAA,uBAAe,GAAE,CAAC;IACvC,OAAO,IAAA,iBAAO,EAAC,YAAY,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;AACxC,CAAC;AANQ,kCAAW;AAQpB,SAAS,WAAW,CAAC,QAAkB;IACtC,MAAM,YAAY,GAAG,IAAA,uBAAe,GAAE,CAAC;IACvC,IAAA,mBAAS,EAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;AACnC,CAAC;AAXqB,kCAAW;AAajC,SAAS,aAAa,CAAC,OAAe;IACrC,IAAI,CAAC,OAAO,EAAE;QACb,IAAA,cAAK,EAAC,kFAAkF,CAAC,CAAC;KAC1F;IAED,MAAM,gBAAgB,GAAG,kBAAQ,CAAC,WAAW,EAAE,CAAC;IAEhD,IAAI,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;QACvC,OAAO;KACP;IAED,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/B,kBAAQ,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;AACxC,CAAC;AA1BkC,sCAAa"}
1
+ {"version":3,"file":"profiles.js","sourceRoot":"","sources":["../../src/lib/profiles.ts"],"names":[],"mappings":";;;;;;AAAA,uCAA+C;AAC/C,mCAA0C;AAE1C,0DAAkC;AAGlC,kBAAe,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC;AAE3D,SAAS,WAAW;IACnB,MAAM,YAAY,GAAG,IAAA,uBAAe,GAAE,CAAC;IACvC,OAAO,IAAA,iBAAO,EAAC,YAAY,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;AACxC,CAAC;AANQ,kCAAW;AAQpB,SAAS,WAAW,CAAC,QAAkB;IACtC,MAAM,YAAY,GAAG,IAAA,uBAAe,GAAE,CAAC;IACvC,IAAA,mBAAS,EAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;AACnC,CAAC;AAXqB,kCAAW;AAajC,SAAS,aAAa,CAAC,OAAe;IACrC,IAAI,CAAC,OAAO,EAAE;QACb,MAAM,kFAAkF,CAAC;KACzF;IAED,MAAM,gBAAgB,GAAG,kBAAQ,CAAC,WAAW,EAAE,CAAC;IAEhD,IAAI,gBAAgB,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;QACvC,OAAO;KACP;IAED,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/B,kBAAQ,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;AACxC,CAAC;AA1BkC,sCAAa"}
@@ -1,22 +1,22 @@
1
- import type GoogleApis from 'googleapis';
2
- import type { Secrets, AuthOptions } from '../types';
3
- export { getSecrets, getCredentials };
4
- declare const _default: {
5
- getScopes: typeof getScopes;
6
- getSecrets: typeof getSecrets;
7
- getCredentials: typeof getCredentials;
8
- validateCredentials: typeof validateCredentials;
9
- createCredentials: typeof createCredentials;
10
- checkSecrets: typeof checkSecrets;
11
- getSecretsError: typeof getSecretsError;
12
- getScopesError: typeof getScopesError;
13
- };
14
- export default _default;
15
- declare function getScopes(): string[];
16
- declare function getSecrets(profile: string): Secrets;
17
- declare function getCredentials(profile: string, auth: GoogleApis.Common.OAuth2Client, options?: AuthOptions): Promise<GoogleApis.Auth.Credentials>;
18
- declare function validateCredentials(credentials: GoogleApis.Auth.Credentials): Promise<boolean>;
19
- declare function createCredentials(profile: string, auth: GoogleApis.Auth.OAuth2Client, options?: AuthOptions, prompt?: GoogleApis.Auth.GenerateAuthUrlOpts['prompt']): Promise<GoogleApis.Auth.Credentials>;
20
- declare function checkSecrets(profile: string, secretsObject: Secrets, secretsFile: string): true | void;
21
- declare function getScopesError(scopesFile: string): string;
22
- declare function getSecretsError(profile: string, secretsFile: string): string;
1
+ import type GoogleApis from 'googleapis';
2
+ import type { Secrets, AuthOptions } from '../types';
3
+ export { getSecrets, getCredentials };
4
+ declare const _default: {
5
+ getScopes: typeof getScopes;
6
+ getSecrets: typeof getSecrets;
7
+ getCredentials: typeof getCredentials;
8
+ validateCredentials: typeof validateCredentials;
9
+ createCredentials: typeof createCredentials;
10
+ checkSecrets: typeof checkSecrets;
11
+ getSecretsError: typeof getSecretsError;
12
+ getScopesError: typeof getScopesError;
13
+ };
14
+ export default _default;
15
+ declare function getScopes(): string[];
16
+ declare function getSecrets(profile: string): Secrets;
17
+ declare function getCredentials(profile: string, auth: GoogleApis.Common.OAuth2Client, options?: AuthOptions): Promise<GoogleApis.Auth.Credentials>;
18
+ declare function validateCredentials(credentials: GoogleApis.Auth.Credentials): Promise<boolean>;
19
+ declare function createCredentials(profile: string, auth: GoogleApis.Auth.OAuth2Client, options?: AuthOptions, prompt?: GoogleApis.Auth.GenerateAuthUrlOpts['prompt']): Promise<GoogleApis.Auth.Credentials>;
20
+ declare function checkSecrets(profile: string, secretsObject: Secrets, secretsFile: string): true | void;
21
+ declare function getScopesError(scopesFile: string): string;
22
+ declare function getSecretsError(profile: string, secretsFile: string): string;
@@ -1,147 +1,151 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getCredentials = exports.getSecrets = void 0;
7
- const http_1 = __importDefault(require("http"));
8
- const server_destroy_1 = __importDefault(require("server-destroy"));
9
- const open_1 = __importDefault(require("open"));
10
- const jsonLib_1 = require("./jsonLib");
11
- const logger_1 = require("./logger");
12
- const paths_1 = require("./paths");
13
- const secrets_1 = __importDefault(require("./secrets"));
14
- exports.default = { getScopes, getSecrets, getCredentials, validateCredentials, createCredentials, checkSecrets, getSecretsError, getScopesError };
15
- const callbackPort = 6006;
16
- const startURI = `http://localhost:${callbackPort}/`;
17
- const callbackURI = `http://localhost:${callbackPort}/oauthcallback`;
18
- const tokenExpiration = 7 * 24 * 60 * 60 * 1000;
19
- function getScopes() {
20
- const scopesFile = (0, paths_1.getScopesFile)();
21
- const scopes = (0, jsonLib_1.getJSON)(scopesFile, () => (0, logger_1.error)(secrets_1.default.getScopesError(scopesFile)));
22
- return scopes;
23
- }
24
- function getSecrets(profile) {
25
- const secretsFile = (0, paths_1.getSecretsFile)(profile);
26
- const secretsObject = (0, jsonLib_1.getJSON)(secretsFile, () => (0, logger_1.error)(secrets_1.default.getSecretsError(profile, secretsFile)));
27
- secrets_1.default.checkSecrets(profile, secretsObject, secretsFile);
28
- return secretsObject;
29
- }
30
- exports.getSecrets = getSecrets;
31
- async function getCredentials(profile, auth, options) {
32
- const credentialsFile = (0, paths_1.getCredentialsFile)(profile);
33
- if (options === null || options === void 0 ? void 0 : options.temporary) {
34
- return secrets_1.default.createCredentials(profile, auth, options);
35
- }
36
- return (0, jsonLib_1.getJSONAsync)(credentialsFile, async () => {
37
- // eslint-disable-next-line camelcase
38
- const refresh_token = (0, paths_1.ensureFile)(credentialsFile) ? (0, jsonLib_1.readJSON)(credentialsFile).refresh_token : undefined;
39
- // eslint-disable-next-line camelcase
40
- const credentials = await secrets_1.default.createCredentials(profile, auth, options, refresh_token ? undefined : 'consent');
41
- // eslint-disable-next-line camelcase
42
- return { refresh_token, ...credentials };
43
- }, secrets_1.default.validateCredentials);
44
- }
45
- exports.getCredentials = getCredentials;
46
- async function validateCredentials(credentials) {
47
- if (!credentials.access_token) {
48
- return false;
49
- }
50
- if (!credentials.refresh_token) {
51
- return false;
52
- }
53
- if (!credentials.expiry_date) {
54
- return true;
55
- }
56
- return new Date().getTime() - credentials.expiry_date < tokenExpiration;
57
- }
58
- async function createCredentials(profile, auth, options, prompt) {
59
- const scope = (options === null || options === void 0 ? void 0 : options.scopes) || secrets_1.default.getScopes();
60
- return new Promise((resolve) => {
61
- const authUrl = auth.generateAuthUrl({
62
- // eslint-disable-next-line camelcase
63
- access_type: 'offline',
64
- prompt,
65
- scope,
66
- });
67
- const server = http_1.default.createServer(async (request, response) => {
68
- if (!request.url) {
69
- response.end('');
70
- return;
71
- }
72
- const url = new URL(`http://${request.headers.host}${request.url}`);
73
- const code = url.searchParams.get('code');
74
- if (!code) {
75
- const scopesList = scope.map((s) => `<li>${s}</li>`).join('');
76
- response.end(formatMessage(`<p>Please open <a href="${authUrl}">auth page</a> using <strong>${profile}</strong> google profile</p>\n<p>Required scopes:</p>\n<ul>${scopesList}</ul>`));
77
- return;
78
- }
79
- response.end(formatMessage('<p>Please close this page and return to application</p>'));
80
- server.destroy();
81
- const { tokens } = await auth.getToken(code);
82
- resolve(tokens);
83
- });
84
- (0, server_destroy_1.default)(server);
85
- server.listen(callbackPort);
86
- (0, logger_1.warn)('Please check your browser for further actions');
87
- (0, open_1.default)(startURI);
88
- });
89
- }
90
- function formatMessage(message) {
91
- return [
92
- '<div style="width: 100%;height: 100%;display: flex;align-items: start;justify-content: center">',
93
- '<div style="padding: 0 1em;border: 1px solid black;font-family: Arial, sans-serif;margin: 1em;">',
94
- message,
95
- '</div>',
96
- '</div>',
97
- ].join('\n');
98
- }
99
- function checkSecrets(profile, secretsObject, secretsFile) {
100
- if (secretsObject.web.redirect_uris[0] === callbackURI) {
101
- return true;
102
- }
103
- (0, logger_1.error)(`Error in credentials file: redirect URI should be ${callbackURI}.\n${secrets_1.default.getSecretsError(profile, secretsFile)}`);
104
- }
105
- function getScopesError(scopesFile) {
106
- return [
107
- `File ${scopesFile} not found!`,
108
- `This application had to have pre-defined file ${scopesFile} that will declare needed scopes`,
109
- ].join('\n');
110
- }
111
- function getSecretsError(profile, secretsFile) {
112
- return [
113
- `File ${secretsFile} not found!`,
114
- 'Here is how to obtain it:',
115
- '\tGo to https://console.cloud.google.com/projectcreate',
116
- '\t\tChoose project name',
117
- '\t\tClick "CREATE" and wait for project to become created',
118
- '\tGo to https://console.cloud.google.com/apis/dashboard',
119
- '\t\tSelect just created project in the top left dropdown list',
120
- '\t\tClick "ENABLE APIS AND SERVICES"',
121
- '\t\t\tClick API you need',
122
- '\t\t\tClick "ENABLE" and wait for API to become enabled',
123
- '\t\tClick "Credentials" tab on the left sidebar',
124
- '\t\t\tClick "CONFIGURE CONSENT SCREEN" on the right',
125
- '\t\t\t\tChoose "External"',
126
- '\t\t\t\tClick "CREATE"',
127
- '\t\t\t\tChoose app name, i.e. "NodeJS"',
128
- '\t\t\t\tSpecify your email as user support email and as developer contact information on the very bottom',
129
- '\t\t\t\tClick "Save and continue"',
130
- '\t\t\tClick "Add or remove scopes"',
131
- `\t\t\t\tAdd scopes: ${secrets_1.default.getScopes().join(',')}`,
132
- '\t\t\t\tClick "Save and continue"',
133
- '\t\t\tClick "Add users"',
134
- '\t\t\t\tAdd your email',
135
- '\t\t\t\tClick "Save and continue"',
136
- '\t\t\tClick "Back to dashboard" on the very bottom',
137
- '\t\tClick "Credentials" on the left sidebar',
138
- '\t\t\tClick "CREATE CREDENTIALS" and choose "OAuth client ID"',
139
- '\t\t\t\tSelect application type "Web application"',
140
- '\t\t\t\tSpecify app name, i.e. "NodeJS"',
141
- `\t\t\t\tAdd authorized redirect URI: ${callbackURI}`,
142
- '\t\t\t\tClick "CREATE"',
143
- `\t\t\t\tClick "DOWNLOAD JSON" and download credentials to ./secrets/${profile}.json`,
144
- 'Then start this script again',
145
- ].join('\n');
146
- }
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getCredentials = exports.getSecrets = void 0;
7
+ const http_1 = __importDefault(require("http"));
8
+ const server_destroy_1 = __importDefault(require("server-destroy"));
9
+ const open_1 = __importDefault(require("open"));
10
+ const logger_1 = require("@anmiles/logger");
11
+ const jsonLib_1 = require("./jsonLib");
12
+ const paths_1 = require("./paths");
13
+ const secrets_1 = __importDefault(require("./secrets"));
14
+ exports.default = { getScopes, getSecrets, getCredentials, validateCredentials, createCredentials, checkSecrets, getSecretsError, getScopesError };
15
+ const callbackPort = 6006;
16
+ const startURI = `http://localhost:${callbackPort}/`;
17
+ const callbackURI = `http://localhost:${callbackPort}/oauthcallback`;
18
+ const tokenExpiration = 7 * 24 * 60 * 60 * 1000;
19
+ function getScopes() {
20
+ const scopesFile = (0, paths_1.getScopesFile)();
21
+ const scopes = (0, jsonLib_1.getJSON)(scopesFile, () => {
22
+ throw secrets_1.default.getScopesError(scopesFile);
23
+ });
24
+ return scopes;
25
+ }
26
+ function getSecrets(profile) {
27
+ const secretsFile = (0, paths_1.getSecretsFile)(profile);
28
+ const secretsObject = (0, jsonLib_1.getJSON)(secretsFile, () => {
29
+ throw secrets_1.default.getSecretsError(profile, secretsFile);
30
+ });
31
+ secrets_1.default.checkSecrets(profile, secretsObject, secretsFile);
32
+ return secretsObject;
33
+ }
34
+ exports.getSecrets = getSecrets;
35
+ async function getCredentials(profile, auth, options) {
36
+ const credentialsFile = (0, paths_1.getCredentialsFile)(profile);
37
+ if (options === null || options === void 0 ? void 0 : options.temporary) {
38
+ return secrets_1.default.createCredentials(profile, auth, options);
39
+ }
40
+ return (0, jsonLib_1.getJSONAsync)(credentialsFile, async () => {
41
+ // eslint-disable-next-line camelcase
42
+ const refresh_token = (0, paths_1.ensureFile)(credentialsFile) ? (0, jsonLib_1.readJSON)(credentialsFile).refresh_token : undefined;
43
+ // eslint-disable-next-line camelcase
44
+ const credentials = await secrets_1.default.createCredentials(profile, auth, options, refresh_token ? undefined : 'consent');
45
+ // eslint-disable-next-line camelcase
46
+ return { refresh_token, ...credentials };
47
+ }, secrets_1.default.validateCredentials);
48
+ }
49
+ exports.getCredentials = getCredentials;
50
+ async function validateCredentials(credentials) {
51
+ if (!credentials.access_token) {
52
+ return false;
53
+ }
54
+ if (!credentials.refresh_token) {
55
+ return false;
56
+ }
57
+ if (!credentials.expiry_date) {
58
+ return true;
59
+ }
60
+ return new Date().getTime() - credentials.expiry_date < tokenExpiration;
61
+ }
62
+ async function createCredentials(profile, auth, options, prompt) {
63
+ const scope = (options === null || options === void 0 ? void 0 : options.scopes) || secrets_1.default.getScopes();
64
+ return new Promise((resolve) => {
65
+ const authUrl = auth.generateAuthUrl({
66
+ // eslint-disable-next-line camelcase
67
+ access_type: 'offline',
68
+ prompt,
69
+ scope,
70
+ });
71
+ const server = http_1.default.createServer(async (request, response) => {
72
+ if (!request.url) {
73
+ response.end('');
74
+ return;
75
+ }
76
+ const url = new URL(`http://${request.headers.host}${request.url}`);
77
+ const code = url.searchParams.get('code');
78
+ if (!code) {
79
+ const scopesList = scope.map((s) => `<li>${s}</li>`).join('');
80
+ response.end(formatMessage(`<p>Please open <a href="${authUrl}">auth page</a> using <strong>${profile}</strong> google profile</p>\n<p>Required scopes:</p>\n<ul>${scopesList}</ul>`));
81
+ return;
82
+ }
83
+ response.end(formatMessage('<p>Please close this page and return to application</p>'));
84
+ server.destroy();
85
+ const { tokens } = await auth.getToken(code);
86
+ resolve(tokens);
87
+ });
88
+ (0, server_destroy_1.default)(server);
89
+ server.listen(callbackPort);
90
+ (0, logger_1.warn)('Please check your browser for further actions');
91
+ (0, open_1.default)(startURI);
92
+ });
93
+ }
94
+ function formatMessage(message) {
95
+ return [
96
+ '<div style="width: 100%;height: 100%;display: flex;align-items: start;justify-content: center">',
97
+ '<div style="padding: 0 1em;border: 1px solid black;font-family: Arial, sans-serif;margin: 1em;">',
98
+ message,
99
+ '</div>',
100
+ '</div>',
101
+ ].join('\n');
102
+ }
103
+ function checkSecrets(profile, secretsObject, secretsFile) {
104
+ if (secretsObject.web.redirect_uris[0] === callbackURI) {
105
+ return true;
106
+ }
107
+ throw `Error in credentials file: redirect URI should be ${callbackURI}.\n${secrets_1.default.getSecretsError(profile, secretsFile)}`;
108
+ }
109
+ function getScopesError(scopesFile) {
110
+ return [
111
+ `File ${scopesFile} not found!`,
112
+ `This application had to have pre-defined file ${scopesFile} that will declare needed scopes`,
113
+ ].join('\n');
114
+ }
115
+ function getSecretsError(profile, secretsFile) {
116
+ return [
117
+ `File ${secretsFile} not found!`,
118
+ 'Here is how to obtain it:',
119
+ '\tGo to https://console.cloud.google.com/projectcreate',
120
+ '\t\tChoose project name',
121
+ '\t\tClick "CREATE" and wait for project to become created',
122
+ '\tGo to https://console.cloud.google.com/apis/dashboard',
123
+ '\t\tSelect just created project in the top left dropdown list',
124
+ '\t\tClick "ENABLE APIS AND SERVICES"',
125
+ '\t\t\tClick API you need',
126
+ '\t\t\tClick "ENABLE" and wait for API to become enabled',
127
+ '\t\tClick "Credentials" tab on the left sidebar',
128
+ '\t\t\tClick "CONFIGURE CONSENT SCREEN" on the right',
129
+ '\t\t\t\tChoose "External"',
130
+ '\t\t\t\tClick "CREATE"',
131
+ '\t\t\t\tChoose app name, i.e. "NodeJS"',
132
+ '\t\t\t\tSpecify your email as user support email and as developer contact information on the very bottom',
133
+ '\t\t\t\tClick "Save and continue"',
134
+ '\t\t\tClick "Add or remove scopes"',
135
+ `\t\t\t\tAdd scopes: ${secrets_1.default.getScopes().join(',')}`,
136
+ '\t\t\t\tClick "Save and continue"',
137
+ '\t\t\tClick "Add users"',
138
+ '\t\t\t\tAdd your email',
139
+ '\t\t\t\tClick "Save and continue"',
140
+ '\t\t\tClick "Back to dashboard" on the very bottom',
141
+ '\t\tClick "Credentials" on the left sidebar',
142
+ '\t\t\tClick "CREATE CREDENTIALS" and choose "OAuth client ID"',
143
+ '\t\t\t\tSelect application type "Web application"',
144
+ '\t\t\t\tSpecify app name, i.e. "NodeJS"',
145
+ `\t\t\t\tAdd authorized redirect URI: ${callbackURI}`,
146
+ '\t\t\t\tClick "CREATE"',
147
+ `\t\t\t\tClick "DOWNLOAD JSON" and download credentials to ./secrets/${profile}.json`,
148
+ 'Then start this script again',
149
+ ].join('\n');
150
+ }
147
151
  //# sourceMappingURL=secrets.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../src/lib/secrets.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,oEAA2C;AAC3C,gDAAwB;AAGxB,uCAA4D;AAC5D,qCAAuC;AACvC,mCAAwF;AAExF,wDAAgC;AAGhC,kBAAe,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC;AAEhJ,MAAM,YAAY,GAAM,IAAI,CAAC;AAC7B,MAAM,QAAQ,GAAU,oBAAoB,YAAY,GAAG,CAAC;AAC5D,MAAM,WAAW,GAAO,oBAAoB,YAAY,gBAAgB,CAAC;AACzE,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEhD,SAAS,SAAS;IACjB,MAAM,UAAU,GAAG,IAAA,qBAAa,GAAE,CAAC;IACnC,MAAM,MAAM,GAAO,IAAA,iBAAO,EAAW,UAAU,EAAE,GAAG,E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,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,WAAW,EAAE;QACvD,OAAO,IAAI,CAAC;KACZ;IACD,MAAM,qDAAqD,WAAW,MAAM,iBAAO,CAAC,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC,EAAE,CAAC;AAC7H,CAAC;AAED,SAAS,cAAc,CAAC,UAAkB;IACzC,OAAO;QACN,QAAQ,UAAU,aAAa;QAC/B,iDAAiD,UAAU,kCAAkC;KAC7F,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC;AAED,SAAS,eAAe,CAAC,OAAe,EAAE,WAAmB;IAC5D,OAAO;QACN,QAAQ,WAAW,aAAa;QAChC,2BAA2B;QAC3B,wDAAwD;QACxD,yBAAyB;QACzB,2DAA2D;QAC3D,yDAAyD;QACzD,+DAA+D;QAC/D,sCAAsC;QACtC,0BAA0B;QAC1B,yDAAyD;QACzD,iDAAiD;QACjD,qDAAqD;QACrD,2BAA2B;QAC3B,wBAAwB;QACxB,wCAAwC;QACxC,0GAA0G;QAC1G,mCAAmC;QACnC,oCAAoC;QACpC,uBAAuB,iBAAO,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QACtD,mCAAmC;QACnC,yBAAyB;QACzB,wBAAwB;QACxB,mCAAmC;QACnC,oDAAoD;QACpD,6CAA6C;QAC7C,+DAA+D;QAC/D,mDAAmD;QACnD,yCAAyC;QACzC,wCAAwC,WAAW,EAAE;QACrD,wBAAwB;QACxB,uEAAuE,OAAO,OAAO;QACrF,8BAA8B;KAC9B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACd,CAAC"}
@@ -1,6 +1,6 @@
1
- export { sleep };
2
- declare const _default: {
3
- sleep: typeof sleep;
4
- };
5
- export default _default;
6
- declare function sleep(milliSeconds: number): Promise<unknown>;
1
+ export { sleep };
2
+ declare const _default: {
3
+ sleep: typeof sleep;
4
+ };
5
+ export default _default;
6
+ declare function sleep(milliSeconds: number): Promise<unknown>;