@anmiles/google-api-wrapper 7.0.6 → 8.0.0

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 (60) 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 +11 -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 +26 -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/paths.d.ts +12 -16
  19. package/dist/lib/paths.js +28 -45
  20. package/dist/lib/paths.js.map +1 -1
  21. package/dist/lib/profiles.d.ts +11 -10
  22. package/dist/lib/profiles.js +33 -33
  23. package/dist/lib/profiles.js.map +1 -1
  24. package/dist/lib/secrets.d.ts +26 -22
  25. package/dist/lib/secrets.js +152 -146
  26. package/dist/lib/secrets.js.map +1 -1
  27. package/dist/types/common.d.ts +3 -3
  28. package/dist/types/common.js +2 -2
  29. package/dist/types/index.d.ts +2 -2
  30. package/dist/types/index.js +18 -18
  31. package/dist/types/secrets.d.ts +15 -15
  32. package/dist/types/secrets.js +2 -2
  33. package/package.json +18 -15
  34. package/src/lib/__tests__/auth.test.ts +23 -23
  35. package/src/lib/__tests__/paths.test.ts +1 -63
  36. package/src/lib/__tests__/profiles.test.ts +25 -21
  37. package/src/lib/__tests__/secrets.test.ts +100 -94
  38. package/src/lib/api/__tests__/calendar.test.ts +3 -3
  39. package/src/lib/api/__tests__/shared.test.ts +12 -14
  40. package/src/lib/api/__tests__/youtube.test.ts +3 -3
  41. package/src/lib/api/shared.ts +2 -2
  42. package/src/lib/auth.ts +1 -1
  43. package/src/lib/paths.ts +2 -20
  44. package/src/lib/profiles.ts +5 -5
  45. package/src/lib/secrets.ts +24 -17
  46. package/dist/lib/jsonLib.d.ts +0 -14
  47. package/dist/lib/jsonLib.js +0 -56
  48. package/dist/lib/jsonLib.js.map +0 -1
  49. package/dist/lib/logger.d.ts +0 -12
  50. package/dist/lib/logger.js +0 -46
  51. package/dist/lib/logger.js.map +0 -1
  52. package/dist/lib/sleep.d.ts +0 -6
  53. package/dist/lib/sleep.js +0 -11
  54. package/dist/lib/sleep.js.map +0 -1
  55. package/src/lib/__tests__/jsonLib.test.ts +0 -253
  56. package/src/lib/__tests__/logger.test.ts +0 -57
  57. package/src/lib/__tests__/sleep.test.ts +0 -17
  58. package/src/lib/jsonLib.ts +0 -57
  59. package/src/lib/logger.ts +0 -21
  60. package/src/lib/sleep.ts +0 -8
@@ -1,34 +1,34 @@
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 fs_1 = __importDefault(require("fs"));
8
+ require("@anmiles/prototypes");
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 fs_1.default.getJSON(profilesFile, () => []);
15
+ }
16
+ exports.getProfiles = getProfiles;
17
+ function setProfiles(profiles) {
18
+ const profilesFile = (0, paths_1.getProfilesFile)();
19
+ fs_1.default.writeJSON(profilesFile, profiles);
20
+ }
21
+ exports.setProfiles = setProfiles;
22
+ function createProfile(profile) {
23
+ if (!profile) {
24
+ throw '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;
34
34
  //# 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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;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,26 @@
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
+ import '@anmiles/prototypes';
4
+ export { getSecrets, getCredentials };
5
+ declare const _default: {
6
+ getScopes: typeof getScopes;
7
+ getSecrets: typeof getSecrets;
8
+ getCredentials: typeof getCredentials;
9
+ validateCredentials: typeof validateCredentials;
10
+ createCredentials: typeof createCredentials;
11
+ checkSecrets: typeof checkSecrets;
12
+ getSecretsError: typeof getSecretsError;
13
+ getScopesError: typeof getScopesError;
14
+ };
15
+ export default _default;
16
+ declare function getScopes(): string[];
17
+ declare function getSecrets(profile: string): Secrets;
18
+ declare function getCredentials(profile: string, auth: GoogleApis.Common.OAuth2Client, options?: AuthOptions): Promise<GoogleApis.Auth.Credentials>;
19
+ declare function validateCredentials(credentials: GoogleApis.Auth.Credentials): Promise<{
20
+ isValid: boolean;
21
+ validationError?: string;
22
+ }>;
23
+ declare function createCredentials(profile: string, auth: GoogleApis.Auth.OAuth2Client, options?: AuthOptions, prompt?: GoogleApis.Auth.GenerateAuthUrlOpts['prompt']): Promise<GoogleApis.Auth.Credentials>;
24
+ declare function checkSecrets(profile: string, secretsObject: Secrets, secretsFile: string): true | void;
25
+ declare function getScopesError(scopesFile: string): string;
26
+ declare function getSecretsError(profile: string, secretsFile: string): string;
@@ -1,147 +1,153 @@
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 fs_1 = __importDefault(require("fs"));
8
+ const http_1 = __importDefault(require("http"));
9
+ const server_destroy_1 = __importDefault(require("server-destroy"));
10
+ const open_1 = __importDefault(require("open"));
11
+ const logger_1 = require("@anmiles/logger");
12
+ require("@anmiles/prototypes");
13
+ const paths_1 = require("./paths");
14
+ const secrets_1 = __importDefault(require("./secrets"));
15
+ exports.default = { getScopes, getSecrets, getCredentials, validateCredentials, createCredentials, checkSecrets, getSecretsError, getScopesError };
16
+ const callbackPort = 6006;
17
+ const startURI = `http://localhost:${callbackPort}/`;
18
+ const callbackURI = `http://localhost:${callbackPort}/oauthcallback`;
19
+ const tokenExpiration = 7 * 24 * 60 * 60 * 1000;
20
+ function getScopes() {
21
+ const scopesFile = (0, paths_1.getScopesFile)();
22
+ const scopes = fs_1.default.getJSON(scopesFile, () => {
23
+ throw secrets_1.default.getScopesError(scopesFile);
24
+ });
25
+ return scopes;
26
+ }
27
+ function getSecrets(profile) {
28
+ const secretsFile = (0, paths_1.getSecretsFile)(profile);
29
+ const secretsObject = fs_1.default.getJSON(secretsFile, () => {
30
+ throw secrets_1.default.getSecretsError(profile, secretsFile);
31
+ });
32
+ secrets_1.default.checkSecrets(profile, secretsObject, secretsFile);
33
+ return secretsObject;
34
+ }
35
+ exports.getSecrets = getSecrets;
36
+ async function getCredentials(profile, auth, options) {
37
+ const credentialsFile = (0, paths_1.getCredentialsFile)(profile);
38
+ if (options === null || options === void 0 ? void 0 : options.temporary) {
39
+ return secrets_1.default.createCredentials(profile, auth, options);
40
+ }
41
+ return fs_1.default.getJSONAsync(credentialsFile, async () => {
42
+ const refreshToken = fs_1.default.existsSync(credentialsFile) ? fs_1.default.readJSON(credentialsFile).refresh_token : undefined;
43
+ const credentials = await secrets_1.default.createCredentials(profile, auth, options, refreshToken ? undefined : 'consent');
44
+ // eslint-disable-next-line camelcase
45
+ return { refresh_token: refreshToken, ...credentials };
46
+ }, secrets_1.default.validateCredentials);
47
+ }
48
+ exports.getCredentials = getCredentials;
49
+ async function validateCredentials(credentials) {
50
+ if (!credentials.access_token) {
51
+ return { isValid: false, validationError: 'Credentials does not have access_token' };
52
+ }
53
+ if (!credentials.refresh_token) {
54
+ return { isValid: false, validationError: 'Credentials does not have refresh_token' };
55
+ }
56
+ if (!credentials.expiry_date) {
57
+ return { isValid: false, validationError: 'Credentials does not have expiry_date' };
58
+ }
59
+ if (new Date().getTime() - credentials.expiry_date >= tokenExpiration) {
60
+ return { isValid: false, validationError: 'Credentials expired' };
61
+ }
62
+ return { isValid: true };
63
+ }
64
+ async function createCredentials(profile, auth, options, prompt) {
65
+ const scope = (options === null || options === void 0 ? void 0 : options.scopes) || secrets_1.default.getScopes();
66
+ return new Promise((resolve) => {
67
+ const authUrl = auth.generateAuthUrl({
68
+ // eslint-disable-next-line camelcase
69
+ access_type: 'offline',
70
+ prompt,
71
+ scope,
72
+ });
73
+ const server = http_1.default.createServer(async (request, response) => {
74
+ if (!request.url) {
75
+ response.end('');
76
+ return;
77
+ }
78
+ const url = new URL(`http://${request.headers.host}${request.url}`);
79
+ const code = url.searchParams.get('code');
80
+ if (!code) {
81
+ const scopesList = scope.map((s) => `<li>${s}</li>`).join('');
82
+ 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>`));
83
+ return;
84
+ }
85
+ response.end(formatMessage('<p>Please close this page and return to application</p>'));
86
+ server.destroy();
87
+ const { tokens } = await auth.getToken(code);
88
+ resolve(tokens);
89
+ });
90
+ (0, server_destroy_1.default)(server);
91
+ server.listen(callbackPort);
92
+ (0, logger_1.warn)('Please check your browser for further actions');
93
+ (0, open_1.default)(startURI);
94
+ });
95
+ }
96
+ function formatMessage(message) {
97
+ return [
98
+ '<div style="width: 100%;height: 100%;display: flex;align-items: start;justify-content: center">',
99
+ '<div style="padding: 0 1em;border: 1px solid black;font-family: Arial, sans-serif;margin: 1em;">',
100
+ message,
101
+ '</div>',
102
+ '</div>',
103
+ ].join('\n');
104
+ }
105
+ function checkSecrets(profile, secretsObject, secretsFile) {
106
+ if (secretsObject.web.redirect_uris[0] === callbackURI) {
107
+ return true;
108
+ }
109
+ throw `Error in credentials file: redirect URI should be ${callbackURI}.\n${secrets_1.default.getSecretsError(profile, secretsFile)}`;
110
+ }
111
+ function getScopesError(scopesFile) {
112
+ return [
113
+ `File ${scopesFile} not found!`,
114
+ `This application had to have pre-defined file ${scopesFile} that will declare needed scopes`,
115
+ ].join('\n');
116
+ }
117
+ function getSecretsError(profile, secretsFile) {
118
+ return [
119
+ `File ${secretsFile} not found!`,
120
+ 'Here is how to obtain it:',
121
+ '\tGo to https://console.cloud.google.com/projectcreate',
122
+ '\t\tChoose project name',
123
+ '\t\tClick "CREATE" and wait for project to become created',
124
+ '\tGo to https://console.cloud.google.com/apis/dashboard',
125
+ '\t\tSelect just created project in the top left dropdown list',
126
+ '\t\tClick "ENABLE APIS AND SERVICES"',
127
+ '\t\t\tClick API you need',
128
+ '\t\t\tClick "ENABLE" and wait for API to become enabled',
129
+ '\t\tClick "Credentials" tab on the left sidebar',
130
+ '\t\t\tClick "CONFIGURE CONSENT SCREEN" on the right',
131
+ '\t\t\t\tChoose "External"',
132
+ '\t\t\t\tClick "CREATE"',
133
+ '\t\t\t\tChoose app name, i.e. "NodeJS"',
134
+ '\t\t\t\tSpecify your email as user support email and as developer contact information on the very bottom',
135
+ '\t\t\t\tClick "Save and continue"',
136
+ '\t\t\tClick "Add or remove scopes"',
137
+ `\t\t\t\tAdd scopes: ${secrets_1.default.getScopes().join(',')}`,
138
+ '\t\t\t\tClick "Save and continue"',
139
+ '\t\t\tClick "Add users"',
140
+ '\t\t\t\tAdd your email',
141
+ '\t\t\t\tClick "Save and continue"',
142
+ '\t\t\tClick "Back to dashboard" on the very bottom',
143
+ '\t\tClick "Credentials" on the left sidebar',
144
+ '\t\t\tClick "CREATE CREDENTIALS" and choose "OAuth client ID"',
145
+ '\t\t\t\tSelect application type "Web application"',
146
+ '\t\t\t\tSpecify app name, i.e. "NodeJS"',
147
+ `\t\t\t\tAdd authorized redirect URI: ${callbackURI}`,
148
+ '\t\t\t\tClick "CREATE"',
149
+ `\t\t\t\tClick "DOWNLOAD JSON" and download credentials to ./secrets/${profile}.json`,
150
+ 'Then start this script again',
151
+ ].join('\n');
152
+ }
147
153
  //# sourceMappingURL=secrets.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../src/lib/secrets.ts"],"names":[],"mappings":";;;;;;AAAA,gD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AAS,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,3 +1,3 @@
1
- export interface CommonOptions {
2
- hideProgress?: boolean;
3
- }
1
+ export interface CommonOptions {
2
+ hideProgress?: boolean;
3
+ }
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=common.js.map
@@ -1,2 +1,2 @@
1
- export * from './common';
2
- export * from './secrets';
1
+ export * from './common';
2
+ export * from './secrets';
@@ -1,19 +1,19 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./common"), exports);
18
- __exportStar(require("./secrets"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./common"), exports);
18
+ __exportStar(require("./secrets"), exports);
19
19
  //# sourceMappingURL=index.js.map
@@ -1,15 +1,15 @@
1
- export interface Secrets {
2
- web: {
3
- client_id: `${string}.apps.googleusercontent.com`;
4
- project_id: string;
5
- auth_uri: 'https://accounts.google.com/o/oauth2/auth';
6
- token_uri: 'https://oauth2.googleapis.com/token';
7
- auth_provider_x509_cert_url: 'https://www.googleapis.com/oauth2/v1/certs';
8
- client_secret: string;
9
- redirect_uris: string[];
10
- };
11
- }
12
- export interface AuthOptions {
13
- temporary?: boolean;
14
- scopes?: string[];
15
- }
1
+ export interface Secrets {
2
+ web: {
3
+ client_id: `${string}.apps.googleusercontent.com`;
4
+ project_id: string;
5
+ auth_uri: 'https://accounts.google.com/o/oauth2/auth';
6
+ token_uri: 'https://oauth2.googleapis.com/token';
7
+ auth_provider_x509_cert_url: 'https://www.googleapis.com/oauth2/v1/certs';
8
+ client_secret: string;
9
+ redirect_uris: string[];
10
+ };
11
+ }
12
+ export interface AuthOptions {
13
+ temporary?: boolean;
14
+ scopes?: string[];
15
+ }
@@ -1,3 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  //# sourceMappingURL=secrets.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anmiles/google-api-wrapper",
3
- "version": "7.0.6",
3
+ "version": "8.0.0",
4
4
  "description": "Provides quick interface for getting google API data",
5
5
  "keywords": [
6
6
  "google",
@@ -8,8 +8,8 @@
8
8
  "auth"
9
9
  ],
10
10
  "author": "Anatoliy Oblaukhov",
11
- "homepage": "https://gitlab.com/anmiles/google-api-wrapper",
12
- "repository": "gitlab:anmiles/google-api-wrapper",
11
+ "homepage": "https://gitlab.com/anmiles/lib/google-api-wrapper",
12
+ "repository": "gitlab:anmiles/lib/google-api-wrapper",
13
13
  "license": "MIT",
14
14
  "engines": {
15
15
  "node": ">=18.14.2"
@@ -29,25 +29,28 @@
29
29
  "login": "node ./dist/login.js"
30
30
  },
31
31
  "dependencies": {
32
- "colorette": "^2.0.19",
32
+ "@anmiles/logger": "^2.1.2",
33
+ "@anmiles/prototypes": "^2.0.0",
34
+ "@anmiles/sleep": "^1.0.2",
33
35
  "execa": "^5.1.1",
34
- "googleapis": "^104.0.0",
36
+ "googleapis": "^118.0.0",
35
37
  "open": "^8.4.2",
36
38
  "server-destroy": "^1.0.1"
37
39
  },
38
40
  "devDependencies": {
39
- "@types/jest": "^28.1.3",
41
+ "@anmiles/eslint-config": "^1.0.6",
42
+ "@types/jest": "^29.5.1",
40
43
  "@types/server-destroy": "^1.0.1",
41
- "@typescript-eslint/eslint-plugin": "^5.30.0",
42
- "@typescript-eslint/parser": "^5.30.0",
43
- "eslint": "^8.18.0",
44
+ "@typescript-eslint/eslint-plugin": "^5.59.2",
45
+ "@typescript-eslint/parser": "^5.59.2",
46
+ "eslint": "^8.40.0",
44
47
  "eslint-plugin-align-assignments": "^1.1.2",
45
- "eslint-plugin-import": "^2.26.0",
46
- "eslint-plugin-jest": "^26.5.3",
47
- "jest": "^28.1.2",
48
+ "eslint-plugin-import": "^2.27.5",
49
+ "eslint-plugin-jest": "^27.2.1",
50
+ "jest": "^29.5.0",
48
51
  "nyc": "^15.1.0",
49
- "rimraf": "^3.0.2",
50
- "ts-jest": "^28.0.5",
51
- "typescript": "^4.7.4"
52
+ "rimraf": "^5.0.0",
53
+ "ts-jest": "^29.1.0",
54
+ "typescript": "^5.0.4"
52
55
  }
53
56
  }