@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.
- package/.eslintrc.js +1 -86
- package/.gitlab-ci.yml +0 -1
- package/.vscode/settings.json +0 -4
- package/CHANGELOG.md +11 -0
- package/README.md +5 -2
- package/dist/index.d.ts +5 -5
- package/dist/index.js +15 -15
- package/dist/lib/api/calendar.d.ts +3 -3
- package/dist/lib/api/calendar.js +13 -13
- package/dist/lib/api/shared.d.ts +23 -23
- package/dist/lib/api/shared.js +26 -23
- package/dist/lib/api/shared.js.map +1 -1
- package/dist/lib/api/youtube.d.ts +3 -3
- package/dist/lib/api/youtube.js +13 -13
- package/dist/lib/auth.d.ts +10 -10
- package/dist/lib/auth.js +34 -34
- package/dist/lib/auth.js.map +1 -1
- package/dist/lib/paths.d.ts +12 -16
- package/dist/lib/paths.js +28 -45
- package/dist/lib/paths.js.map +1 -1
- package/dist/lib/profiles.d.ts +11 -10
- package/dist/lib/profiles.js +33 -33
- package/dist/lib/profiles.js.map +1 -1
- package/dist/lib/secrets.d.ts +26 -22
- package/dist/lib/secrets.js +152 -146
- package/dist/lib/secrets.js.map +1 -1
- package/dist/types/common.d.ts +3 -3
- package/dist/types/common.js +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +18 -18
- package/dist/types/secrets.d.ts +15 -15
- package/dist/types/secrets.js +2 -2
- package/package.json +18 -15
- package/src/lib/__tests__/auth.test.ts +23 -23
- package/src/lib/__tests__/paths.test.ts +1 -63
- package/src/lib/__tests__/profiles.test.ts +25 -21
- package/src/lib/__tests__/secrets.test.ts +100 -94
- package/src/lib/api/__tests__/calendar.test.ts +3 -3
- package/src/lib/api/__tests__/shared.test.ts +12 -14
- package/src/lib/api/__tests__/youtube.test.ts +3 -3
- package/src/lib/api/shared.ts +2 -2
- package/src/lib/auth.ts +1 -1
- package/src/lib/paths.ts +2 -20
- package/src/lib/profiles.ts +5 -5
- package/src/lib/secrets.ts +24 -17
- package/dist/lib/jsonLib.d.ts +0 -14
- package/dist/lib/jsonLib.js +0 -56
- package/dist/lib/jsonLib.js.map +0 -1
- package/dist/lib/logger.d.ts +0 -12
- package/dist/lib/logger.js +0 -46
- package/dist/lib/logger.js.map +0 -1
- package/dist/lib/sleep.d.ts +0 -6
- package/dist/lib/sleep.js +0 -11
- package/dist/lib/sleep.js.map +0 -1
- package/src/lib/__tests__/jsonLib.test.ts +0 -253
- package/src/lib/__tests__/logger.test.ts +0 -57
- package/src/lib/__tests__/sleep.test.ts +0 -17
- package/src/lib/jsonLib.ts +0 -57
- package/src/lib/logger.ts +0 -21
- package/src/lib/sleep.ts +0 -8
package/dist/lib/profiles.js
CHANGED
|
@@ -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
|
|
8
|
-
|
|
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
|
|
15
|
-
}
|
|
16
|
-
exports.getProfiles = getProfiles;
|
|
17
|
-
function setProfiles(profiles) {
|
|
18
|
-
const profilesFile = (0, paths_1.getProfilesFile)();
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
exports.setProfiles = setProfiles;
|
|
22
|
-
function createProfile(profile) {
|
|
23
|
-
if (!profile) {
|
|
24
|
-
|
|
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
|
package/dist/lib/profiles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.js","sourceRoot":"","sources":["../../src/lib/profiles.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"profiles.js","sourceRoot":"","sources":["../../src/lib/profiles.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,+BAA6B;AAC7B,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,YAAE,CAAC,OAAO,CAAC,YAAY,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;AAC3C,CAAC;AANQ,kCAAW;AAQpB,SAAS,WAAW,CAAC,QAAkB;IACtC,MAAM,YAAY,GAAG,IAAA,uBAAe,GAAE,CAAC;IACvC,YAAE,CAAC,SAAS,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;AACtC,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"}
|
package/dist/lib/secrets.d.ts
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import type GoogleApis from 'googleapis';
|
|
2
|
-
import type { Secrets, AuthOptions } from '../types';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
declare function
|
|
17
|
-
declare function
|
|
18
|
-
declare function
|
|
19
|
-
declare function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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;
|
package/dist/lib/secrets.js
CHANGED
|
@@ -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
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const logger_1 = require("
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
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
|
-
if (!credentials.
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
if (!credentials.
|
|
54
|
-
return
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (!
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
'
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
function
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
function
|
|
112
|
-
return [
|
|
113
|
-
`File ${
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
'
|
|
121
|
-
'\
|
|
122
|
-
'\t\
|
|
123
|
-
'\t\tClick "
|
|
124
|
-
'\
|
|
125
|
-
'\t\
|
|
126
|
-
'\t\
|
|
127
|
-
'\t\t\
|
|
128
|
-
'\t\t\
|
|
129
|
-
'\t\
|
|
130
|
-
'\t\t\tClick "
|
|
131
|
-
|
|
132
|
-
'\t\t\t\tClick "
|
|
133
|
-
'\t\t\
|
|
134
|
-
'\t\t\t\
|
|
135
|
-
'\t\t\t\tClick "Save and continue"',
|
|
136
|
-
'\t\t\tClick "
|
|
137
|
-
|
|
138
|
-
'\t\t\tClick "
|
|
139
|
-
'\t\t\
|
|
140
|
-
'\t\t\t\
|
|
141
|
-
|
|
142
|
-
'\t\t\
|
|
143
|
-
|
|
144
|
-
'
|
|
145
|
-
|
|
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
|
package/dist/lib/secrets.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../src/lib/secrets.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,oEAA2C;AAC3C,gDAAwB;
|
|
1
|
+
{"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../src/lib/secrets.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,oEAA2C;AAC3C,gDAAwB;AAExB,4CAAuC;AAEvC,+BAA6B;AAC7B,mCAA4E;AAE5E,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,YAAE,CAAC,OAAO,CAAW,UAAU,EAAE,GAAG,EAAE;QACxD,MAAM,iBAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IAC1C,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AACf,CAAC;AAED,SAAS,UAAU,CAAC,OAAe;IAClC,MAAM,WAAW,GAAK,IAAA,sBAAc,EAAC,OAAO,CAAC,CAAC;IAC9C,MAAM,aAAa,GAAG,YAAE,CAAC,OAAO,CAAU,WAAW,EAAE,GAAG,EAAE;QAC3D,MAAM,iBAAO,CAAC,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IACH,iBAAO,CAAC,YAAY,CAAC,OAA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AAe,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"}
|
package/dist/types/common.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export interface CommonOptions {
|
|
2
|
-
hideProgress?: boolean;
|
|
3
|
-
}
|
|
1
|
+
export interface CommonOptions {
|
|
2
|
+
hideProgress?: boolean;
|
|
3
|
+
}
|
package/dist/types/common.js
CHANGED
|
@@ -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
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './common';
|
|
2
|
-
export * from './secrets';
|
|
1
|
+
export * from './common';
|
|
2
|
+
export * from './secrets';
|
package/dist/types/index.js
CHANGED
|
@@ -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
|
package/dist/types/secrets.d.ts
CHANGED
|
@@ -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
|
+
}
|
package/dist/types/secrets.js
CHANGED
|
@@ -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": "
|
|
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
|
-
"
|
|
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": "^
|
|
36
|
+
"googleapis": "^118.0.0",
|
|
35
37
|
"open": "^8.4.2",
|
|
36
38
|
"server-destroy": "^1.0.1"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
39
|
-
"@
|
|
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.
|
|
42
|
-
"@typescript-eslint/parser": "^5.
|
|
43
|
-
"eslint": "^8.
|
|
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.
|
|
46
|
-
"eslint-plugin-jest": "^
|
|
47
|
-
"jest": "^
|
|
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": "^
|
|
50
|
-
"ts-jest": "^
|
|
51
|
-
"typescript": "^
|
|
52
|
+
"rimraf": "^5.0.0",
|
|
53
|
+
"ts-jest": "^29.1.0",
|
|
54
|
+
"typescript": "^5.0.4"
|
|
52
55
|
}
|
|
53
56
|
}
|