backend-manager 3.2.172 → 3.2.174

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 (89) hide show
  1. package/package.json +3 -3
  2. package/src/cli/cli.js +27 -11
  3. package/src/manager/helpers/assistant.js +51 -76
  4. package/src/manager/index.js +22 -1
  5. package/dist/cli/cli.js +0 -1534
  6. package/dist/manager/functions/core/actions/api/admin/backup.js +0 -338
  7. package/dist/manager/functions/core/actions/api/admin/create-post.js +0 -388
  8. package/dist/manager/functions/core/actions/api/admin/cron.js +0 -37
  9. package/dist/manager/functions/core/actions/api/admin/database-read.js +0 -35
  10. package/dist/manager/functions/core/actions/api/admin/database-write.js +0 -39
  11. package/dist/manager/functions/core/actions/api/admin/edit-post.js +0 -158
  12. package/dist/manager/functions/core/actions/api/admin/firestore-query.js +0 -165
  13. package/dist/manager/functions/core/actions/api/admin/firestore-read.js +0 -38
  14. package/dist/manager/functions/core/actions/api/admin/firestore-write.js +0 -54
  15. package/dist/manager/functions/core/actions/api/admin/get-stats.js +0 -269
  16. package/dist/manager/functions/core/actions/api/admin/payment-processor.js +0 -57
  17. package/dist/manager/functions/core/actions/api/admin/run-hook.js +0 -95
  18. package/dist/manager/functions/core/actions/api/admin/send-notification.js +0 -197
  19. package/dist/manager/functions/core/actions/api/admin/sync-users.js +0 -125
  20. package/dist/manager/functions/core/actions/api/admin/templates/post.html +0 -16
  21. package/dist/manager/functions/core/actions/api/firebase/get-providers.js +0 -102
  22. package/dist/manager/functions/core/actions/api/general/emails/general:download-app-link.js +0 -21
  23. package/dist/manager/functions/core/actions/api/general/fetch-post.js +0 -99
  24. package/dist/manager/functions/core/actions/api/general/generate-uuid.js +0 -41
  25. package/dist/manager/functions/core/actions/api/general/send-email.js +0 -112
  26. package/dist/manager/functions/core/actions/api/handler/create-post.js +0 -146
  27. package/dist/manager/functions/core/actions/api/special/setup-electron-manager-client.js +0 -103
  28. package/dist/manager/functions/core/actions/api/template.js +0 -33
  29. package/dist/manager/functions/core/actions/api/test/authenticate.js +0 -22
  30. package/dist/manager/functions/core/actions/api/test/create-test-accounts.js +0 -27
  31. package/dist/manager/functions/core/actions/api/test/lab.js +0 -55
  32. package/dist/manager/functions/core/actions/api/test/redirect.js +0 -26
  33. package/dist/manager/functions/core/actions/api/test/webhook.js +0 -30
  34. package/dist/manager/functions/core/actions/api/user/create-custom-token.js +0 -32
  35. package/dist/manager/functions/core/actions/api/user/delete.js +0 -68
  36. package/dist/manager/functions/core/actions/api/user/get-active-sessions.js +0 -45
  37. package/dist/manager/functions/core/actions/api/user/get-subscription-info.js +0 -49
  38. package/dist/manager/functions/core/actions/api/user/oauth2/discord.js +0 -114
  39. package/dist/manager/functions/core/actions/api/user/oauth2/google.js +0 -99
  40. package/dist/manager/functions/core/actions/api/user/oauth2.js +0 -476
  41. package/dist/manager/functions/core/actions/api/user/regenerate-api-keys.js +0 -54
  42. package/dist/manager/functions/core/actions/api/user/resolve.js +0 -32
  43. package/dist/manager/functions/core/actions/api/user/sign-out-all-sessions.js +0 -118
  44. package/dist/manager/functions/core/actions/api/user/sign-up copy.js +0 -544
  45. package/dist/manager/functions/core/actions/api/user/sign-up.js +0 -99
  46. package/dist/manager/functions/core/actions/api/user/submit-feedback.js +0 -96
  47. package/dist/manager/functions/core/actions/api/user/validate-settings.js +0 -86
  48. package/dist/manager/functions/core/actions/api.js +0 -354
  49. package/dist/manager/functions/core/actions/create-post-handler.js +0 -184
  50. package/dist/manager/functions/core/actions/generate-uuid.js +0 -62
  51. package/dist/manager/functions/core/actions/sign-up-handler.js +0 -205
  52. package/dist/manager/functions/core/admin/create-post.js +0 -206
  53. package/dist/manager/functions/core/admin/firestore-write.js +0 -72
  54. package/dist/manager/functions/core/admin/get-stats.js +0 -218
  55. package/dist/manager/functions/core/admin/query.js +0 -198
  56. package/dist/manager/functions/core/admin/send-notification.js +0 -206
  57. package/dist/manager/functions/core/cron/daily/ghostii-auto-publisher.js +0 -377
  58. package/dist/manager/functions/core/cron/daily/reset-usage.js +0 -197
  59. package/dist/manager/functions/core/cron/daily.js +0 -114
  60. package/dist/manager/functions/core/events/auth/before-create.js +0 -124
  61. package/dist/manager/functions/core/events/auth/before-signin.js +0 -62
  62. package/dist/manager/functions/core/events/auth/on-create copy.js +0 -121
  63. package/dist/manager/functions/core/events/auth/on-create.js +0 -564
  64. package/dist/manager/functions/core/events/auth/on-delete.js +0 -72
  65. package/dist/manager/functions/core/events/firestore/on-subscription.js +0 -107
  66. package/dist/manager/functions/test/authenticate.js +0 -38
  67. package/dist/manager/functions/test/create-test-accounts.js +0 -144
  68. package/dist/manager/functions/test/webhook.js +0 -37
  69. package/dist/manager/functions/wrappers/mailchimp/addToList.js +0 -25
  70. package/dist/manager/helpers/analytics copy.js +0 -217
  71. package/dist/manager/helpers/analytics.js +0 -467
  72. package/dist/manager/helpers/api-manager.js +0 -324
  73. package/dist/manager/helpers/assistant.js +0 -1043
  74. package/dist/manager/helpers/metadata.js +0 -32
  75. package/dist/manager/helpers/middleware.js +0 -154
  76. package/dist/manager/helpers/roles.js +0 -69
  77. package/dist/manager/helpers/settings.js +0 -158
  78. package/dist/manager/helpers/subscription-resolver-new.js +0 -828
  79. package/dist/manager/helpers/subscription-resolver.js +0 -842
  80. package/dist/manager/helpers/usage.js +0 -381
  81. package/dist/manager/helpers/user.js +0 -198
  82. package/dist/manager/helpers/utilities.js +0 -292
  83. package/dist/manager/index.js +0 -1076
  84. package/dist/manager/libraries/openai.js +0 -460
  85. package/dist/manager/routes/restart/index.js +0 -52
  86. package/dist/manager/routes/test/index.js +0 -43
  87. package/dist/manager/schemas/restart.js +0 -13
  88. package/dist/manager/schemas/test.js +0 -13
  89. package/dist/require.js +0 -3
@@ -1,45 +0,0 @@
1
- const _ = require('lodash')
2
-
3
- function Module() {
4
-
5
- }
6
-
7
- Module.prototype.main = function () {
8
- const self = this;
9
- const Manager = self.Manager;
10
- const Api = self.Api;
11
- const assistant = self.assistant;
12
- const payload = self.payload;
13
-
14
- return new Promise(async function(resolve, reject) {
15
-
16
- Api.resolveUser({adminRequired: true})
17
- .then(async (user) => {
18
- const uid = _.get(user, 'auth.uid', null);
19
- const id = _.get(payload.data.payload, 'id', 'app');
20
- const session = `sessions/${id}`;
21
-
22
- assistant.log(`Getting active sessions for ${uid} @ ${session}`)
23
-
24
- await self.libraries.admin.database().ref(session)
25
- .orderByChild('uid')
26
- .equalTo(uid)
27
- .once('value')
28
- .then(async (snap) => {
29
- const data = snap.val() || {};
30
- return resolve({data: data});
31
- })
32
- .catch(e => {
33
- return reject(assistant.errorify(`Session query error: ${e}`, {code: 500}));
34
- })
35
-
36
- })
37
- .catch(e => {
38
- return reject(e);
39
- })
40
- });
41
-
42
- };
43
-
44
-
45
- module.exports = Module;
@@ -1,49 +0,0 @@
1
- const _ = require('lodash')
2
- const powertools = require('node-powertools')
3
-
4
- function Module() {
5
-
6
- }
7
-
8
- Module.prototype.main = function () {
9
- const self = this;
10
- const Manager = self.Manager;
11
- const Api = self.Api;
12
- const assistant = self.assistant;
13
- const payload = self.payload;
14
-
15
- return new Promise(async function(resolve, reject) {
16
- const oldDate = powertools.timestamp(new Date(0), {output: 'string'})
17
- const oldDateUNIX = powertools.timestamp(oldDate, {output: 'unix'});
18
-
19
- Api.resolveUser({adminRequired: false})
20
- .then(async (user) => {
21
- const result = {
22
- plan: {
23
- id: _.get(user, 'plan.id', 'unknown'),
24
- expires: {
25
- timestamp: _.get(user, 'plan.expires.timestamp', oldDate),
26
- timestampUNIX: _.get(user, 'plan.expires.timestampUNIX', oldDateUNIX),
27
- },
28
- trial: {
29
- activated: _.get(user, 'plan.trial.activated', false),
30
- date: {
31
- timestamp: _.get(user, 'plan.trial.date.timestamp', oldDate),
32
- timestampUNIX: _.get(user, 'plan.trial.date.timestampUNIX', oldDateUNIX),
33
- }
34
- },
35
- payment: {
36
- active: _.get(user, 'plan.payment.active', false),
37
- },
38
- }
39
- }
40
- return resolve({data: result});
41
- })
42
- .catch(e => {
43
- return reject(e);
44
- })
45
- });
46
- };
47
-
48
-
49
- module.exports = Module;
@@ -1,114 +0,0 @@
1
- const decode = require('jwt-decode')
2
- const _ = require('lodash')
3
- const fetch = require('wonderful-fetch')
4
-
5
- function OAuth2() {
6
- const self = this;
7
- self.provider = 'discord';
8
- self.name = 'Discord';
9
- self.urls = {
10
- // var oauthURL = 'https://discord.com/api/oauth2/authorize?client_id=701375931918581810&redirect_uri=URL&response_type=code&scope=identify';
11
-
12
- authorize: 'https://discord.com/api/oauth2/authorize',
13
- tokenize: 'https://discord.com/api/oauth2/token',
14
- refresh: 'https://discord.com/api/oauth2/token',
15
- status: '',
16
- removeAccess: 'https://discord.com/channels/@me',
17
- }
18
- }
19
-
20
- OAuth2.prototype.buildUrl = function (state, url) {
21
- const self = this;
22
- const Manager = self.Manager;
23
- const assistant = self.assistant;
24
-
25
- return new Promise(async function(resolve, reject) {
26
- if (state === 'authorize') {
27
- // do something with url
28
- return resolve()
29
- } else {
30
- return resolve()
31
- }
32
- });
33
- };
34
-
35
- OAuth2.prototype.verifyIdentity = function (tokenizeResult) {
36
- const self = this;
37
- const Manager = self.Manager;
38
- const assistant = self.assistant;
39
-
40
- return new Promise(async function(resolve, reject) {
41
-
42
- const identityResponse = await fetch('https://discord.com/api/users/@me', {
43
- timeout: 60000,
44
- response: 'json',
45
- tries: 1,
46
- log: true,
47
- cacheBreaker: false,
48
- headers: {
49
- authorization: `${tokenizeResult.token_type} ${tokenizeResult.access_token}`,
50
- },
51
- })
52
- .then(json => json)
53
- .catch(e => e)
54
-
55
- assistant.log('identityResponse', identityResponse);
56
-
57
- if (identityResponse instanceof Error) {
58
- return reject(identityResponse);
59
- }
60
-
61
- // Check if exists
62
- Manager.libraries.admin.firestore().collection(`users`)
63
- .where(`oauth2.${self.provider}.identity.id`, '==', identityResponse.id)
64
- .get()
65
- .then(async (snap) => {
66
- if (snap.size === 0) {
67
- return resolve(identityResponse);
68
- } else {
69
- return reject(new Error(`This ${self.name} account is already connected to a ${Manager.config.brand.name} account`));
70
- }
71
- })
72
- .catch((e) => {
73
- return reject(e);
74
- });
75
-
76
- });
77
- };
78
-
79
- // OAuth2.prototype.verifyConnection = function (newUrl, token) {
80
- // const self = this;
81
- // const Manager = self.Manager;
82
- // const assistant = self.assistant;
83
- //
84
- // return new Promise(async function(resolve, reject) {
85
- //
86
- // fetch(newUrl, {
87
- // method: 'post',
88
- // timeout: 60000,
89
- // response: 'json',
90
- // tries: 1,
91
- // log: true,
92
- // cacheBreaker: false,
93
- // body: {
94
- // id_token: token,
95
- // }
96
- // })
97
- // .then(json => {
98
- // // console.log('---json', json);
99
- // return resolve('connected');
100
- // })
101
- // .catch(e => {
102
- // try {
103
- // const parsed = JSON.parse(e.message);
104
- // return reject(new Error(`${parsed.error}: ${parsed.error_description}`))
105
- // } catch (e2) {
106
- // return reject(e);
107
- // }
108
- // })
109
- //
110
- // });
111
- // };
112
-
113
-
114
- module.exports = OAuth2;
@@ -1,99 +0,0 @@
1
- const decode = require('jwt-decode')
2
- const _ = require('lodash')
3
- const fetch = require('wonderful-fetch')
4
-
5
- function OAuth2() {
6
- const self = this;
7
- self.provider = 'google';
8
- self.name = 'Google';
9
- self.urls = {
10
- authorize: 'https://accounts.google.com/o/oauth2/v2/auth',
11
- tokenize: 'https://oauth2.googleapis.com/token',
12
- refresh: 'https://oauth2.googleapis.com/token',
13
- // status: 'https://oauth2.googleapis.com/tokeninfo?id_token={token}'
14
- status: 'https://oauth2.googleapis.com/tokeninfo',
15
- removeAccess: 'https://myaccount.google.com/security',
16
- }
17
- }
18
-
19
- OAuth2.prototype.buildUrl = function (state, url) {
20
- const self = this;
21
- const Manager = self.Manager;
22
- const assistant = self.assistant;
23
-
24
- return new Promise(async function(resolve, reject) {
25
- if (state === 'authorize') {
26
- // do something with url
27
- // url.searchParams.set('prompt', typeof payload.data.payload.prompt === 'undefined' ? 'consent' : payload.data.payload.prompt)
28
- // url.searchParams.set('prompt', 'consent')
29
- return resolve()
30
- } else {
31
- return resolve()
32
- }
33
- });
34
- };
35
-
36
- OAuth2.prototype.verifyIdentity = function (tokenizeResult) {
37
- const self = this;
38
- const Manager = self.Manager;
39
- const assistant = self.assistant;
40
-
41
- return new Promise(async function(resolve, reject) {
42
- const decoded = decode(tokenizeResult.id_token);
43
-
44
- // console.log('---decoded', decoded);
45
-
46
- // Check if exists
47
- Manager.libraries.admin.firestore().collection(`users`)
48
- .where(`oauth2.${self.provider}.identity.email`, '==', decoded.email)
49
- .get()
50
- .then(async (snap) => {
51
- if (snap.size === 0) {
52
- return resolve(decoded);
53
- } else {
54
- return reject(new Error(`This ${self.name} account is already connected to a ${Manager.config.brand.name} account`));
55
- }
56
- })
57
- .catch((e) => {
58
- return reject(e);
59
- });
60
-
61
- });
62
- };
63
-
64
- // OAuth2.prototype.verifyConnection = function (newUrl, token) {
65
- // const self = this;
66
- // const Manager = self.Manager;
67
- // const assistant = self.assistant;
68
- //
69
- // return new Promise(async function(resolve, reject) {
70
- //
71
- // fetch(newUrl, {
72
- // method: 'post',
73
- // timeout: 60000,
74
- // response: 'json',
75
- // tries: 1,
76
- // log: true,
77
- // cacheBreaker: false,
78
- // body: {
79
- // id_token: token,
80
- // }
81
- // })
82
- // .then(json => {
83
- // // console.log('---json', json);
84
- // return resolve('connected');
85
- // })
86
- // .catch(e => {
87
- // try {
88
- // const parsed = JSON.parse(e.message);
89
- // return reject(new Error(`${parsed.error}: ${parsed.error_description}`))
90
- // } catch (e2) {
91
- // return reject(e);
92
- // }
93
- // })
94
- //
95
- // });
96
- // };
97
-
98
-
99
- module.exports = OAuth2;