diff --git a/packages/rocketchat-tokenpass/client/index.js b/packages/rocketchat-tokenpass/client/index.js new file mode 100644 index 0000000000000..471878739c60e --- /dev/null +++ b/packages/rocketchat-tokenpass/client/index.js @@ -0,0 +1,10 @@ +import '../lib/common'; +import './login-button.css'; +import './channelSettings.css'; +import './styles.css'; +import './startup'; +import './roomType'; +import './tokenChannelsList.html'; +import './tokenChannelsList'; +import './tokenpassChannelSettings.html'; +import './tokenpassChannelSettings'; diff --git a/packages/rocketchat-tokenpass/client/roomType.js b/packages/rocketchat-tokenpass/client/roomType.js index 314401959b428..5d635e8b71840 100644 --- a/packages/rocketchat-tokenpass/client/roomType.js +++ b/packages/rocketchat-tokenpass/client/roomType.js @@ -1,5 +1,6 @@ import { Meteor } from 'meteor/meteor'; import { RoomTypeConfig } from 'meteor/rocketchat:lib'; +import { RocketChat } from 'meteor/rocketchat:lib'; class TokenPassRoomType extends RoomTypeConfig { constructor() { diff --git a/packages/rocketchat-tokenpass/client/startup.js b/packages/rocketchat-tokenpass/client/startup.js index 8416a26634ed2..a622a2262d2a5 100644 --- a/packages/rocketchat-tokenpass/client/startup.js +++ b/packages/rocketchat-tokenpass/client/startup.js @@ -1,4 +1,5 @@ import { Meteor } from 'meteor/meteor'; +import { RocketChat } from 'meteor/rocketchat:lib'; Meteor.startup(function() { RocketChat.ChannelSettings.addOption({ diff --git a/packages/rocketchat-tokenpass/client/tokenChannelsList.js b/packages/rocketchat-tokenpass/client/tokenChannelsList.js index 63e7306c4e224..cc4b8a9635237 100644 --- a/packages/rocketchat-tokenpass/client/tokenChannelsList.js +++ b/packages/rocketchat-tokenpass/client/tokenChannelsList.js @@ -2,6 +2,7 @@ import { Meteor } from 'meteor/meteor'; import { ReactiveVar } from 'meteor/reactive-var'; import { Tracker } from 'meteor/tracker'; import { Template } from 'meteor/templating'; +import { RocketChat } from 'meteor/rocketchat:lib'; Template.tokenChannelsList.helpers({ rooms() { diff --git a/packages/rocketchat-tokenpass/client/tokenpassChannelSettings.js b/packages/rocketchat-tokenpass/client/tokenpassChannelSettings.js index 07696dbbfa466..9fcd715b3df05 100644 --- a/packages/rocketchat-tokenpass/client/tokenpassChannelSettings.js +++ b/packages/rocketchat-tokenpass/client/tokenpassChannelSettings.js @@ -2,6 +2,9 @@ import { Meteor } from 'meteor/meteor'; import { ReactiveVar } from 'meteor/reactive-var'; import { Template } from 'meteor/templating'; import { TAPi18n } from 'meteor/tap:i18n'; +import { handleError } from 'meteor/rocketchat:lib'; +import { t, ChatRoom } from 'meteor/rocketchat:ui'; +import toastr from 'toastr'; Template.channelSettings__tokenpass.helpers({ addDisabled() { diff --git a/packages/rocketchat-tokenpass/common.js b/packages/rocketchat-tokenpass/lib/common.js similarity index 89% rename from packages/rocketchat-tokenpass/common.js rename to packages/rocketchat-tokenpass/lib/common.js index ecc3d6ddc3191..d44b7c1e7bd78 100644 --- a/packages/rocketchat-tokenpass/common.js +++ b/packages/rocketchat-tokenpass/lib/common.js @@ -1,6 +1,7 @@ -/* global CustomOAuth */ import { Meteor } from 'meteor/meteor'; import { Tracker } from 'meteor/tracker'; +import { RocketChat } from 'meteor/rocketchat:lib'; +import { CustomOAuth } from 'meteor/rocketchat:custom-oauth'; const config = { serverURL: '', diff --git a/packages/rocketchat-tokenpass/package.js b/packages/rocketchat-tokenpass/package.js index 6b71537a71ba8..2b396a5032e74 100644 --- a/packages/rocketchat-tokenpass/package.js +++ b/packages/rocketchat-tokenpass/package.js @@ -6,46 +6,17 @@ Package.describe({ Package.onUse(function(api) { api.versionsFrom('1.0'); - api.use('accounts-base'); - api.use('ecmascript'); - api.use('service-configuration'); - api.use('templating', 'client'); - api.use('littledata:synced-cron'); - api.use('rocketchat:lib'); - api.use('rocketchat:authorization'); - api.use('rocketchat:custom-oauth'); - api.use('rocketchat:channel-settings'); - - api.addFiles('common.js'); - - api.addFiles('client/login-button.css', 'client'); - api.addFiles('client/channelSettings.css', 'client'); - api.addFiles('client/styles.css', 'client'); - - api.addFiles('client/startup.js', 'client'); - api.addFiles('client/roomType.js', 'client'); - api.addFiles('client/tokenChannelsList.html', 'client'); - api.addFiles('client/tokenChannelsList.js', 'client'); - api.addFiles('client/tokenpassChannelSettings.html', 'client'); - api.addFiles('client/tokenpassChannelSettings.js', 'client'); - - api.addFiles('server/startup.js', 'server'); - - api.addFiles('server/functions/getProtectedTokenpassBalances.js', 'server'); - api.addFiles('server/functions/getPublicTokenpassBalances.js', 'server'); - api.addFiles('server/functions/saveRoomTokens.js', 'server'); - api.addFiles('server/functions/saveRoomTokensMinimumBalance.js', 'server'); - api.addFiles('server/functions/updateUserTokenpassBalances.js', 'server'); - - api.addFiles('server/models/indexes.js', 'server'); - api.addFiles('server/models/Rooms.js', 'server'); - api.addFiles('server/models/Subscriptions.js', 'server'); - api.addFiles('server/models/Users.js', 'server'); - - api.addFiles('server/methods/findTokenChannels.js', 'server'); - api.addFiles('server/methods/getChannelTokenpass.js', 'server'); - - api.addFiles('server/cronRemoveUsers.js', 'server'); - - api.addFiles('server/Tokenpass.js', 'server'); + api.use([ + 'ecmascript', + 'accounts-base', + 'service-configuration', + 'templating', + 'littledata:synced-cron', + 'rocketchat:lib', + 'rocketchat:authorization', + 'rocketchat:custom-oauth', + 'rocketchat:channel-settings', + ]); + api.mainModule('client/index.js', 'client'); + api.mainModule('server/index.js', 'server'); }); diff --git a/packages/rocketchat-tokenpass/server/Tokenpass.js b/packages/rocketchat-tokenpass/server/Tokenpass.js index 24e82f2efdeb7..b312b8842782a 100644 --- a/packages/rocketchat-tokenpass/server/Tokenpass.js +++ b/packages/rocketchat-tokenpass/server/Tokenpass.js @@ -1,3 +1,5 @@ +import { RocketChat } from 'meteor/rocketchat:lib'; + RocketChat.Tokenpass = { validateAccess(tokenpass, balances) { const compFunc = tokenpass.require === 'any' ? 'some' : 'every'; diff --git a/packages/rocketchat-tokenpass/server/cronRemoveUsers.js b/packages/rocketchat-tokenpass/server/cronRemoveUsers.js index f941025069447..4adfb2b894503 100644 --- a/packages/rocketchat-tokenpass/server/cronRemoveUsers.js +++ b/packages/rocketchat-tokenpass/server/cronRemoveUsers.js @@ -1,5 +1,6 @@ -/* globals SyncedCron */ import { Meteor } from 'meteor/meteor'; +import { RocketChat } from 'meteor/rocketchat:lib'; +import { SyncedCron } from 'meteor/littledata:synced-cron'; function removeUsersFromTokenChannels() { const rooms = {}; diff --git a/packages/rocketchat-tokenpass/server/functions/getProtectedTokenpassBalances.js b/packages/rocketchat-tokenpass/server/functions/getProtectedTokenpassBalances.js index 6b1bc586f597b..9cff964a6abbc 100644 --- a/packages/rocketchat-tokenpass/server/functions/getProtectedTokenpassBalances.js +++ b/packages/rocketchat-tokenpass/server/functions/getProtectedTokenpassBalances.js @@ -1,5 +1,6 @@ import { Meteor } from 'meteor/meteor'; import { HTTP } from 'meteor/http'; +import { RocketChat } from 'meteor/rocketchat:lib'; let userAgent = 'Meteor'; if (Meteor.release) { userAgent += `/${ Meteor.release }`; } diff --git a/packages/rocketchat-tokenpass/server/functions/getPublicTokenpassBalances.js b/packages/rocketchat-tokenpass/server/functions/getPublicTokenpassBalances.js index 0083676c1b737..bd721175c7fe5 100644 --- a/packages/rocketchat-tokenpass/server/functions/getPublicTokenpassBalances.js +++ b/packages/rocketchat-tokenpass/server/functions/getPublicTokenpassBalances.js @@ -1,5 +1,6 @@ import { Meteor } from 'meteor/meteor'; import { HTTP } from 'meteor/http'; +import { RocketChat } from 'meteor/rocketchat:lib'; let userAgent = 'Meteor'; if (Meteor.release) { userAgent += `/${ Meteor.release }`; } diff --git a/packages/rocketchat-tokenpass/server/functions/saveRoomTokens.js b/packages/rocketchat-tokenpass/server/functions/saveRoomTokens.js index c591baefb7c7d..8347954d1bbbe 100644 --- a/packages/rocketchat-tokenpass/server/functions/saveRoomTokens.js +++ b/packages/rocketchat-tokenpass/server/functions/saveRoomTokens.js @@ -1,5 +1,6 @@ import { Meteor } from 'meteor/meteor'; import { Match } from 'meteor/check'; +import { RocketChat } from 'meteor/rocketchat:lib'; RocketChat.saveRoomTokenpass = function(rid, tokenpass) { if (!Match.test(rid, String)) { diff --git a/packages/rocketchat-tokenpass/server/functions/saveRoomTokensMinimumBalance.js b/packages/rocketchat-tokenpass/server/functions/saveRoomTokensMinimumBalance.js index 00f1eb809dbe3..8d10039966d15 100644 --- a/packages/rocketchat-tokenpass/server/functions/saveRoomTokensMinimumBalance.js +++ b/packages/rocketchat-tokenpass/server/functions/saveRoomTokensMinimumBalance.js @@ -1,5 +1,6 @@ import { Meteor } from 'meteor/meteor'; import { Match } from 'meteor/check'; +import { RocketChat } from 'meteor/rocketchat:lib'; import s from 'underscore.string'; RocketChat.saveRoomTokensMinimumBalance = function(rid, roomTokensMinimumBalance) { diff --git a/packages/rocketchat-tokenpass/server/functions/updateUserTokenpassBalances.js b/packages/rocketchat-tokenpass/server/functions/updateUserTokenpassBalances.js index 8eb841d7d9a99..50698464156db 100644 --- a/packages/rocketchat-tokenpass/server/functions/updateUserTokenpassBalances.js +++ b/packages/rocketchat-tokenpass/server/functions/updateUserTokenpassBalances.js @@ -1,3 +1,4 @@ +import { RocketChat } from 'meteor/rocketchat:lib'; import _ from 'underscore'; RocketChat.updateUserTokenpassBalances = function(user) { diff --git a/packages/rocketchat-tokenpass/server/index.js b/packages/rocketchat-tokenpass/server/index.js new file mode 100644 index 0000000000000..a66961b4bdf9d --- /dev/null +++ b/packages/rocketchat-tokenpass/server/index.js @@ -0,0 +1,15 @@ +import '../lib/common'; +import './startup'; +import './functions/getProtectedTokenpassBalances'; +import './functions/getPublicTokenpassBalances'; +import './functions/saveRoomTokens'; +import './functions/saveRoomTokensMinimumBalance'; +import './functions/updateUserTokenpassBalances'; +import './models/indexes'; +import './models/Rooms'; +import './models/Subscriptions'; +import './models/Users'; +import './methods/findTokenChannels'; +import './methods/getChannelTokenpass'; +import './cronRemoveUsers'; +import './Tokenpass'; diff --git a/packages/rocketchat-tokenpass/server/methods/findTokenChannels.js b/packages/rocketchat-tokenpass/server/methods/findTokenChannels.js index 926c80715b27c..90ae938c7ec3b 100644 --- a/packages/rocketchat-tokenpass/server/methods/findTokenChannels.js +++ b/packages/rocketchat-tokenpass/server/methods/findTokenChannels.js @@ -1,4 +1,5 @@ import { Meteor } from 'meteor/meteor'; +import { RocketChat } from 'meteor/rocketchat:lib'; Meteor.methods({ findTokenChannels() { diff --git a/packages/rocketchat-tokenpass/server/methods/getChannelTokenpass.js b/packages/rocketchat-tokenpass/server/methods/getChannelTokenpass.js index 0f39a5684b2af..1dad36c891229 100644 --- a/packages/rocketchat-tokenpass/server/methods/getChannelTokenpass.js +++ b/packages/rocketchat-tokenpass/server/methods/getChannelTokenpass.js @@ -1,5 +1,6 @@ import { Meteor } from 'meteor/meteor'; import { check } from 'meteor/check'; +import { RocketChat } from 'meteor/rocketchat:lib'; Meteor.methods({ getChannelTokenpass(rid) { diff --git a/packages/rocketchat-tokenpass/server/models/Rooms.js b/packages/rocketchat-tokenpass/server/models/Rooms.js index 0a601e610d79e..0919943d7b860 100644 --- a/packages/rocketchat-tokenpass/server/models/Rooms.js +++ b/packages/rocketchat-tokenpass/server/models/Rooms.js @@ -1,3 +1,5 @@ +import { RocketChat } from 'meteor/rocketchat:lib'; + RocketChat.models.Rooms.findByTokenpass = function(tokens) { const query = { 'tokenpass.tokens.token': { diff --git a/packages/rocketchat-tokenpass/server/models/Subscriptions.js b/packages/rocketchat-tokenpass/server/models/Subscriptions.js index 0d0f321a82b27..be94296fd8b3d 100644 --- a/packages/rocketchat-tokenpass/server/models/Subscriptions.js +++ b/packages/rocketchat-tokenpass/server/models/Subscriptions.js @@ -1,3 +1,5 @@ +import { RocketChat } from 'meteor/rocketchat:lib'; + RocketChat.models.Subscriptions.findByRoomIds = function(roomIds) { const query = { rid: { diff --git a/packages/rocketchat-tokenpass/server/models/Users.js b/packages/rocketchat-tokenpass/server/models/Users.js index 670ea3e1f723d..6f762ead3cb63 100644 --- a/packages/rocketchat-tokenpass/server/models/Users.js +++ b/packages/rocketchat-tokenpass/server/models/Users.js @@ -1,3 +1,5 @@ +import { RocketChat } from 'meteor/rocketchat:lib'; + RocketChat.models.Users.setTokenpassTcaBalances = function(_id, tcaBalances) { const update = { $set: { diff --git a/packages/rocketchat-tokenpass/server/models/indexes.js b/packages/rocketchat-tokenpass/server/models/indexes.js index 63feff4a12a86..b56905ad50d62 100644 --- a/packages/rocketchat-tokenpass/server/models/indexes.js +++ b/packages/rocketchat-tokenpass/server/models/indexes.js @@ -1,4 +1,5 @@ import { Meteor } from 'meteor/meteor'; +import { RocketChat } from 'meteor/rocketchat:lib'; Meteor.startup(function() { RocketChat.models.Rooms.tryEnsureIndex({ 'tokenpass.tokens.token': 1 }); diff --git a/packages/rocketchat-tokenpass/server/startup.js b/packages/rocketchat-tokenpass/server/startup.js index 883f2424062e0..24499014cd78b 100644 --- a/packages/rocketchat-tokenpass/server/startup.js +++ b/packages/rocketchat-tokenpass/server/startup.js @@ -1,5 +1,6 @@ import { Meteor } from 'meteor/meteor'; import { Accounts } from 'meteor/accounts-base'; +import { RocketChat } from 'meteor/rocketchat:lib'; RocketChat.settings.addGroup('OAuth', function() { this.section('Tokenpass', function() {