Remove Sandstorm support (#13773)
@ -1 +0,0 @@ |
||||
.vagrant |
@ -1 +0,0 @@ |
||||
### FIRST Sandstorm VERSION of Rocket.Chat |
@ -1,14 +0,0 @@ |
||||
# Publish commands |
||||
|
||||
``` |
||||
cd Rocket.Chat |
||||
vagrant-spk vm up && vagrant-spk dev |
||||
^C |
||||
vagrant-spk pack ../rocketchat.spk && vagrant-spk publish ../rocketchat.spk && vagrant-spk vm halt |
||||
``` |
||||
|
||||
# Reset commands |
||||
|
||||
``` |
||||
vagrant-spk vm halt && vagrant-spk vm destroy |
||||
``` |
@ -1,104 +0,0 @@ |
||||
# -*- mode: ruby -*- |
||||
# vi: set ft=ruby : |
||||
|
||||
# Guess at a reasonable name for the VM based on the folder vagrant-spk is |
||||
# run from. The timestamp is there to avoid conflicts if you have multiple |
||||
# folders with the same name. |
||||
VM_NAME = File.basename(File.dirname(File.dirname(__FILE__))) + "_sandstorm_#{Time.now.utc.to_i}" |
||||
|
||||
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing! |
||||
VAGRANTFILE_API_VERSION = "2" |
||||
|
||||
# ugly hack to prevent hashicorp's bitrot. See https://github.com/hashicorp/vagrant/issues/9442 |
||||
# this setting is required for pre-2.0 vagrant, but causes an error as of 2.0.3, |
||||
# remove entirely when confident nobody uses vagrant 1.x for anything. |
||||
unless Vagrant::DEFAULT_SERVER_URL.frozen? |
||||
Vagrant::DEFAULT_SERVER_URL.replace('https://vagrantcloud.com') |
||||
end |
||||
|
||||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| |
||||
# Base on the Sandstorm snapshots of the official Debian 9 (stretch) box with vboxsf support. |
||||
config.vm.box = "debian/contrib-stretch64" |
||||
config.vm.box_version = "9.3.0" |
||||
|
||||
if Vagrant.has_plugin?("vagrant-vbguest") then |
||||
# vagrant-vbguest is a Vagrant plugin that upgrades |
||||
# the version of VirtualBox Guest Additions within each |
||||
# guest. If you have the vagrant-vbguest plugin, then it |
||||
# needs to know how to compile kernel modules, etc., and so |
||||
# we give it this hint about operating system type. |
||||
config.vm.guest = "debian" |
||||
end |
||||
|
||||
# We forward port 6080, the Sandstorm web port, so that developers can |
||||
# visit their sandstorm app from their browser as local.sandstorm.io:6080 |
||||
# (aka 127.0.0.1:6080). |
||||
config.vm.network :forwarded_port, guest: 6080, host: 6080 |
||||
|
||||
# Use a shell script to "provision" the box. This installs Sandstorm using |
||||
# the bundled installer. |
||||
config.vm.provision "shell", inline: "sudo bash /opt/app/.sandstorm/global-setup.sh", keep_color: true |
||||
# Then, do stack-specific and app-specific setup. |
||||
config.vm.provision "shell", inline: "sudo bash /opt/app/.sandstorm/setup.sh", keep_color: true |
||||
|
||||
# Shared folders are configured per-provider since vboxsf can't handle >4096 open files, |
||||
# NFS requires privilege escalation every time you bring a VM up, |
||||
# and 9p is only available on libvirt. |
||||
|
||||
# Calculate the number of CPUs and the amount of RAM the system has, |
||||
# in a platform-dependent way; further logic below. |
||||
cpus = nil |
||||
total_kB_ram = nil |
||||
|
||||
host = RbConfig::CONFIG['host_os'] |
||||
if host =~ /darwin/ |
||||
cpus = `sysctl -n hw.ncpu`.to_i |
||||
total_kB_ram = `sysctl -n hw.memsize`.to_i / 1024 |
||||
elsif host =~ /linux/ |
||||
cpus = `nproc`.to_i |
||||
total_kB_ram = `grep MemTotal /proc/meminfo | awk '{print $2}'`.to_i |
||||
elsif host =~ /mingw/ |
||||
# powershell may not be available on Windows XP and Vista, so wrap this in a rescue block |
||||
begin |
||||
cpus = `powershell -Command "(Get-WmiObject Win32_Processor -Property NumberOfLogicalProcessors | Select-Object -Property NumberOfLogicalProcessors | Measure-Object NumberOfLogicalProcessors -Sum).Sum"`.to_i |
||||
total_kB_ram = `powershell -Command "Get-CimInstance -class cim_physicalmemory | % $_.Capacity}"`.to_i / 1024 |
||||
rescue |
||||
end |
||||
end |
||||
# Use the same number of CPUs within Vagrant as the system, with 1 |
||||
# as a default. |
||||
# |
||||
# Use at least 512MB of RAM, and if the system has more than 2GB of |
||||
# RAM, use 1/4 of the system RAM. This seems a reasonable compromise |
||||
# between having the Vagrant guest operating system not run out of |
||||
# RAM entirely (which it basically would if we went much lower than |
||||
# 512MB) and also allowing it to use up a healthily large amount of |
||||
# RAM so it can run faster on systems that can afford it. |
||||
if cpus.nil? or cpus.zero? |
||||
cpus = 1 |
||||
end |
||||
if total_kB_ram.nil? or total_kB_ram < 2048000 |
||||
assign_ram_mb = 512 |
||||
else |
||||
assign_ram_mb = (total_kB_ram / 1024 / 4) |
||||
end |
||||
# Actually apply these CPU/memory values to the providers. |
||||
config.vm.provider :virtualbox do |vb, override| |
||||
vb.cpus = cpus |
||||
vb.memory = assign_ram_mb |
||||
vb.name = VM_NAME |
||||
|
||||
override.vm.synced_folder "..", "/opt/app" |
||||
override.vm.synced_folder ENV["HOME"] + "/.sandstorm", "/host-dot-sandstorm" |
||||
override.vm.synced_folder "..", "/vagrant", disabled: true |
||||
end |
||||
config.vm.provider :libvirt do |libvirt, override| |
||||
libvirt.cpus = cpus |
||||
libvirt.memory = assign_ram_mb |
||||
libvirt.default_prefix = VM_NAME |
||||
|
||||
override.vm.synced_folder "..", "/opt/app", type: "9p", accessmode: "passthrough" |
||||
override.vm.synced_folder ENV["HOME"] + "/.sandstorm", "/host-dot-sandstorm", type: "9p", accessmode: "passthrough" |
||||
override.vm.synced_folder "..", "/vagrant", type: "9p", accessmode: "passthrough", disabled: true |
||||
end |
||||
end |
@ -1,23 +0,0 @@ |
||||
#!/bin/bash |
||||
set -x |
||||
set -euvo pipefail |
||||
|
||||
# Make meteor bundle |
||||
sudo chown vagrant:vagrant /home/vagrant -R |
||||
cd /opt/app |
||||
meteor npm install capnp |
||||
meteor npm install |
||||
meteor build --directory /home/vagrant/ |
||||
|
||||
export NODE_ENV=production |
||||
# Use npm and node from the Meteor dev bundle to install the bundle's dependencies. |
||||
TOOL_VERSION=$(meteor show --ejson $(<.meteor/release) | grep '^ *"tool":' | |
||||
sed -re 's/^.*"(meteor-tool@[^"]*)".*$/\1/g') |
||||
TOOLDIR=$(echo $TOOL_VERSION | tr @ /) |
||||
PATH=$HOME/.meteor/packages/$TOOLDIR/mt-os.linux.x86_64/dev_bundle/bin:$PATH |
||||
cd /home/vagrant/bundle/programs/server |
||||
npm install --production |
||||
|
||||
# Copy our launcher script into the bundle so the grain can start up. |
||||
mkdir -p /home/vagrant/bundle/opt/app/.sandstorm/ |
||||
cp /opt/app/.sandstorm/launcher.sh /home/vagrant/bundle/opt/app/.sandstorm/ |
@ -1 +0,0 @@ |
||||
The Complete Open Source Chat Solution. Rocket.Chat is a Web Chat Server, developed in JavaScript. It is a great solution for communities and companies wanting to privately host their own chat service or for developers looking forward to build and evolve their own chat platforms. |
@ -1,34 +0,0 @@ |
||||
#!/bin/bash |
||||
set -x |
||||
set -euvo pipefail |
||||
|
||||
echo localhost > /etc/hostname |
||||
hostname localhost |
||||
# Install curl that is needed below. |
||||
apt-get update |
||||
apt-get install -y curl |
||||
curl https://install.sandstorm.io/ > /host-dot-sandstorm/caches/install.sh |
||||
SANDSTORM_CURRENT_VERSION=$(curl -fs "https://install.sandstorm.io/dev?from=0&type=install") |
||||
SANDSTORM_PACKAGE="sandstorm-$SANDSTORM_CURRENT_VERSION.tar.xz" |
||||
if [[ ! -f /host-dot-sandstorm/caches/$SANDSTORM_PACKAGE ]] ; then |
||||
curl --output "/host-dot-sandstorm/caches/$SANDSTORM_PACKAGE.partial" "https://dl.sandstorm.io/$SANDSTORM_PACKAGE" |
||||
mv "/host-dot-sandstorm/caches/$SANDSTORM_PACKAGE.partial" "/host-dot-sandstorm/caches/$SANDSTORM_PACKAGE" |
||||
fi |
||||
bash /host-dot-sandstorm/caches/install.sh -d -e "/host-dot-sandstorm/caches/$SANDSTORM_PACKAGE" |
||||
modprobe ip_tables |
||||
# Make the vagrant user part of the sandstorm group so that commands like |
||||
# `spk dev` work. |
||||
usermod -a -G 'sandstorm' 'vagrant' |
||||
# Bind to all addresses, so the vagrant port-forward works. |
||||
sudo sed --in-place='' --expression='s/^BIND_IP=.*/BIND_IP=0.0.0.0/' /opt/sandstorm/sandstorm.conf |
||||
# TODO: update sandstorm installer script to ask about dev accounts, and |
||||
# specify a value for this option in the default config? |
||||
if ! grep --quiet --no-messages ALLOW_DEV_ACCOUNTS=true /opt/sandstorm/sandstorm.conf ; then |
||||
echo "ALLOW_DEV_ACCOUNTS=true" | sudo tee -a /opt/sandstorm/sandstorm.conf |
||||
sudo service sandstorm restart |
||||
fi |
||||
# Enable apt-cacher-ng proxy to make things faster if one appears to be running on the gateway IP |
||||
GATEWAY_IP=$(ip route | grep ^default | cut -d ' ' -f 3) |
||||
if nc -z "$GATEWAY_IP" 3142 ; then |
||||
echo "Acquire::http::Proxy \"http://$GATEWAY_IP:3142\";" > /etc/apt/apt.conf.d/80httpproxy |
||||
fi |
@ -1,8 +0,0 @@ |
||||
#!/bin/bash |
||||
set -x |
||||
set -euvo pipefail |
||||
|
||||
export METEOR_SETTINGS='{"public": {"sandstorm": true}}' |
||||
export NODE_ENV=production |
||||
export SETTINGS_HIDDEN="Email,Email_Header,Email_Footer,SMTP_Host,SMTP_Port,SMTP_Username,SMTP_Password,From_Email,SMTP_Test_Button,Invitation_Customized,Invitation_Subject,Invitation_HTML,Accounts_Enrollment_Customized,Accounts_Enrollment_Email_Subject,Accounts_Enrollment_Email,Accounts_UserAddedEmail_Customized,Accounts_UserAddedEmailSubject,Accounts_UserAddedEmail,Forgot_Password_Customized,Forgot_Password_Email_Subject,Forgot_Password_Email,Verification_Customized,Verification_Email_Subject,Verification_Email" |
||||
exec node /start.js -p 8000 |
Before Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.7 KiB |
@ -1,115 +0,0 @@ |
||||
@0xbbbe049af795122e; |
||||
|
||||
using Spk = import "/sandstorm/package.capnp"; |
||||
# This imports: |
||||
# $SANDSTORM_HOME/latest/usr/include/sandstorm/package.capnp |
||||
# Check out that file to see the full, documented package definition format. |
||||
|
||||
const pkgdef :Spk.PackageDefinition = ( |
||||
# The package definition. Note that the spk tool looks specifically for the |
||||
# "pkgdef" constant. |
||||
|
||||
id = "vfnwptfn02ty21w715snyyczw0nqxkv3jvawcah10c6z7hj1hnu0", |
||||
# Your app ID is actually its public key. The private key was placed in |
||||
# your keyring. All updates must be signed with the same key. |
||||
|
||||
manifest = ( |
||||
# This manifest is included in your app package to tell Sandstorm |
||||
# about your app. |
||||
|
||||
appTitle = (defaultText = "Rocket.Chat"), |
||||
|
||||
appVersion = 129, # Increment this for every release. |
||||
|
||||
appMarketingVersion = (defaultText = "1.0.0-develop"), |
||||
# Human-readable representation of appVersion. Should match the way you |
||||
# identify versions of your app in documentation and marketing. |
||||
|
||||
actions = [ |
||||
# Define your "new document" handlers here. |
||||
( title = (defaultText = "New Rocket.Chat"), |
||||
command = .myCommand |
||||
# The command to run when starting for the first time. (".myCommand" |
||||
# is just a constant defined at the bottom of the file.) |
||||
) |
||||
], |
||||
|
||||
continueCommand = .myCommand, |
||||
# This is the command called to start your app back up after it has been |
||||
# shut down for inactivity. Here we're using the same command as for |
||||
# starting a new instance, but you could use different commands for each |
||||
# case. |
||||
|
||||
metadata = ( |
||||
icons = ( |
||||
appGrid = (svg = embed "rocket.chat-128.svg"), |
||||
grain = (svg = embed "rocket.chat-24.svg"), |
||||
market = (svg = embed "rocket.chat-150.svg"), |
||||
), |
||||
|
||||
website = "https://rocket.chat", |
||||
codeUrl = "https://github.com/RocketChat/Rocket.Chat", |
||||
license = (openSource = mit), |
||||
categories = [communications, productivity, office, social, developerTools], |
||||
|
||||
author = ( |
||||
contactEmail = "team@rocket.chat", |
||||
pgpSignature = embed "pgp-signature", |
||||
upstreamAuthor = "Rocket.Chat", |
||||
), |
||||
pgpKeyring = embed "pgp-keyring", |
||||
|
||||
description = (defaultText = embed "description.md"), |
||||
shortDescription = (defaultText = "Chat app"), |
||||
|
||||
screenshots = [ |
||||
(width = 1024, height = 696, png = embed "screenshot1.png"), |
||||
(width = 1024, height = 696, png = embed "screenshot2.png"), |
||||
(width = 1024, height = 696, png = embed "screenshot3.png"), |
||||
(width = 1024, height = 696, png = embed "screenshot4.png") |
||||
], |
||||
|
||||
changeLog = (defaultText = embed "CHANGELOG.md"), |
||||
), |
||||
|
||||
), |
||||
|
||||
sourceMap = ( |
||||
# The following directories will be copied into your package. |
||||
searchPath = [ |
||||
( sourcePath = "/home/vagrant/bundle" ), |
||||
( sourcePath = "/opt/meteor-spk/meteor-spk.deps" ) |
||||
] |
||||
), |
||||
|
||||
alwaysInclude = [ "." ], |
||||
# This says that we always want to include all files from the source map. |
||||
# (An alternative is to automatically detect dependencies by watching what |
||||
# the app opens while running in dev mode. To see what that looks like, |
||||
# run `spk init` without the -A option.) |
||||
|
||||
bridgeConfig = ( |
||||
viewInfo = ( |
||||
eventTypes = [ |
||||
(name = "message", verbPhrase = (defaultText = "sent message")), |
||||
(name = "privateMessage", verbPhrase = (defaultText = "sent private message"), requiredPermission = (explicitList = void)), |
||||
] |
||||
), |
||||
saveIdentityCaps = true, |
||||
), |
||||
); |
||||
|
||||
const myCommand :Spk.Manifest.Command = ( |
||||
# Here we define the command used to start up your server. |
||||
argv = ["/sandstorm-http-bridge", "8000", "--", "/opt/app/.sandstorm/launcher.sh"], |
||||
environ = [ |
||||
# Note that this defines the *entire* environment seen by your app. |
||||
(key = "PATH", value = "/usr/local/bin:/usr/bin:/bin"), |
||||
(key = "SANDSTORM", value = "1"), |
||||
(key = "HOME", value = "/var"), |
||||
(key = "Statistics_reporting", value = "false"), |
||||
(key = "Accounts_AllowUserAvatarChange", value = "false"), |
||||
(key = "Accounts_AllowUserProfileChange", value = "false"), |
||||
(key = "BABEL_CACHE_DIR", value = "/var/babel_cache") |
||||
] |
||||
); |
Before Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 215 KiB |
@ -1,66 +0,0 @@ |
||||
#!/bin/bash |
||||
set -x |
||||
set -euvo pipefail |
||||
|
||||
apt-get update |
||||
apt-get install build-essential git -y |
||||
|
||||
cd /opt/ |
||||
|
||||
NODE_ENV=production |
||||
PACKAGE=meteor-spk-0.4.1 |
||||
PACKAGE_FILENAME="$PACKAGE.tar.xz" |
||||
CACHE_TARGET="/host-dot-sandstorm/caches/${PACKAGE_FILENAME}" |
||||
|
||||
# Fetch meteor-spk tarball if not cached |
||||
if [ ! -f "$CACHE_TARGET" ] ; then |
||||
curl https://dl.sandstorm.io/${PACKAGE_FILENAME} > "$CACHE_TARGET" |
||||
fi |
||||
|
||||
# Extract to /opt |
||||
tar xf "$CACHE_TARGET" |
||||
|
||||
# Create symlink so we can rely on the path /opt/meteor-spk |
||||
ln -s "${PACKAGE}" meteor-spk |
||||
|
||||
#This will install capnp, the Cap’n Proto command-line tool. |
||||
#It will also install libcapnp, libcapnpc, and libkj in /usr/local/lib and headers in /usr/local/include/capnp and /usr/local/include/kj. |
||||
curl -O https://capnproto.org/capnproto-c++-0.6.1.tar.gz |
||||
tar zxf capnproto-c++-0.6.1.tar.gz |
||||
cd capnproto-c++-0.6.1 |
||||
./configure |
||||
make -j6 check |
||||
sudo make install |
||||
# inlcude libcapnp and libkj library to dependencies. |
||||
cp .libs/* /opt/meteor-spk/meteor-spk.deps/lib/x86_64-linux-gnu/ |
||||
|
||||
# Add bash, and its dependencies, so they get mapped into the image. |
||||
# Bash runs the launcher script. |
||||
cp -a /bin/bash /opt/meteor-spk/meteor-spk.deps/bin/ |
||||
cp -a /lib/x86_64-linux-gnu/libncurses.so.* /opt/meteor-spk/meteor-spk.deps/lib/x86_64-linux-gnu/ |
||||
cp -a /lib/x86_64-linux-gnu/libtinfo.so.* /opt/meteor-spk/meteor-spk.deps/lib/x86_64-linux-gnu/ |
||||
# for npm in package.json sharp. |
||||
cp -a /lib/x86_64-linux-gnu/libresolv* /opt/meteor-spk/meteor-spk.deps/lib/x86_64-linux-gnu/ |
||||
|
||||
|
||||
# Unfortunately, Meteor does not explicitly make it easy to cache packages, but |
||||
# we know experimentally that the package is mostly directly extractable to a |
||||
# user's $HOME/.meteor directory. |
||||
METEOR_RELEASE=1.6.1.1 |
||||
METEOR_PLATFORM=os.linux.x86_64 |
||||
METEOR_TARBALL_FILENAME="meteor-bootstrap-${METEOR_PLATFORM}.tar.gz" |
||||
METEOR_TARBALL_URL="https://d3sqy0vbqsdhku.cloudfront.net/packages-bootstrap/${METEOR_RELEASE}/${METEOR_TARBALL_FILENAME}" |
||||
METEOR_CACHE_TARGET="/host-dot-sandstorm/caches/${METEOR_TARBALL_FILENAME}" |
||||
|
||||
# Fetch meteor tarball if not cached |
||||
if [ ! -f "$METEOR_CACHE_TARGET" ] ; then |
||||
curl "$METEOR_TARBALL_URL" > "${METEOR_CACHE_TARGET}.partial" |
||||
mv "${METEOR_CACHE_TARGET}"{.partial,} |
||||
fi |
||||
|
||||
# Extract as unprivileged user, which is the usual meteor setup |
||||
cd /home/vagrant/ |
||||
su -c "tar xf '${METEOR_CACHE_TARGET}'" vagrant |
||||
# Link into global PATH |
||||
ln -s /home/vagrant/.meteor/meteor /usr/bin/meteor |
||||
chown vagrant:vagrant /home/vagrant -R |
@ -1 +0,0 @@ |
||||
meteor |
@ -1,37 +0,0 @@ |
||||
#!/bin/bash |
||||
set -x |
||||
set -euvo pipefail |
||||
IFS=$'\n\t' |
||||
|
||||
export SANDSTORM_VERSION=$(curl -f "https://install.sandstorm.io/dev?from=0&type=install") |
||||
export PATH=$PATH:/tmp/sandstorm-$SANDSTORM_VERSION/bin |
||||
|
||||
cd /tmp |
||||
curl https://dl.sandstorm.io/sandstorm-$SANDSTORM_VERSION.tar.xz | tar -xJf - |
||||
|
||||
mkdir -p ~/opt |
||||
cd ~/opt |
||||
curl https://dl.sandstorm.io/meteor-spk-0.1.8.tar.xz | tar -xJf - |
||||
ln -s meteor-spk-0.1.8 meteor-spk |
||||
cp -a /bin/bash ~/opt/meteor-spk/meteor-spk.deps/bin/ |
||||
cp -a /lib/x86_64-linux-gnu/libncurses.so.* ~/opt/meteor-spk/meteor-spk.deps/lib/x86_64-linux-gnu/ |
||||
cp -a /lib/x86_64-linux-gnu/libtinfo.so.* ~/opt/meteor-spk/meteor-spk.deps/lib/x86_64-linux-gnu/ |
||||
ln -s $TRAVIS_BUILD_DIR ~/opt/app |
||||
|
||||
cd /tmp |
||||
spk init -p3000 -- nothing |
||||
export SANDSTORM_ID="$(grep '\sid =' sandstorm-pkgdef.capnp)" |
||||
|
||||
cd $TRAVIS_BUILD_DIR |
||||
export METEOR_WAREHOUSE_DIR="${METEOR_WAREHOUSE_DIR:-$HOME/.meteor}" |
||||
export METEOR_DEV_BUNDLE=$(dirname $(readlink -f "$METEOR_WAREHOUSE_DIR/meteor"))/dev_bundle |
||||
|
||||
mkdir -p ~/vagrant |
||||
tar -zxf /tmp/build/Rocket.Chat.tar.gz --directory ~/vagrant/ |
||||
cd ~/vagrant/bundle/programs/server && "$METEOR_DEV_BUNDLE/bin/npm" install |
||||
cd $TRAVIS_BUILD_DIR/.sandstorm |
||||
sed -i "s/\sid = .*/$SANDSTORM_ID/" sandstorm-pkgdef.capnp |
||||
mkdir -p ~/vagrant/bundle/opt/app/.sandstorm/ |
||||
cp ~/opt/app/.sandstorm/launcher.sh ~/vagrant/bundle/opt/app/.sandstorm/ |
||||
sed -i "s/\spgp/#pgp/g" sandstorm-pkgdef.capnp |
||||
spk pack $ROCKET_DEPLOY_DIR/rocket.chat-$ARTIFACT_NAME.spk |
@ -1,11 +0,0 @@ |
||||
<template name="oembedSandstormGrain"> |
||||
<blockquote class="sandstorm-grain background-transparent-darker-before"> |
||||
<label> |
||||
<button onclick="sandstormOembed(event)" data-token="{{token}}" |
||||
data-descriptor="{{descriptor}}"> |
||||
{{grainTitle}} |
||||
</button> |
||||
<img src="{{appIconUrl}}" /> |
||||
</label> |
||||
</blockquote> |
||||
</template> |
@ -1,28 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
import { Template } from 'meteor/templating'; |
||||
|
||||
Template.oembedSandstormGrain.helpers({ |
||||
token() { |
||||
return this.meta.sandstorm.grain.token; |
||||
}, |
||||
appTitle() { |
||||
return this.meta.sandstorm.grain.appTitle.defaultText; |
||||
}, |
||||
grainTitle() { |
||||
return this.meta.sandstorm.grain.grainTitle; |
||||
}, |
||||
appIconUrl() { |
||||
return this.meta.sandstorm.grain.appIconUrl; |
||||
}, |
||||
descriptor() { |
||||
return this.meta.sandstorm.grain.descriptor; |
||||
}, |
||||
}); |
||||
|
||||
window.sandstormOembed = function(e) { |
||||
e = e || window.event; |
||||
const src = e.target || e.srcElement; |
||||
const token = src.getAttribute('data-token'); |
||||
const descriptor = src.getAttribute('data-descriptor'); |
||||
return Meteor.call('sandstormOffer', token, descriptor); |
||||
}; |
@ -1,6 +0,0 @@ |
||||
import { Sandstorm } from './powerboxListener'; |
||||
import './setPath'; |
||||
|
||||
export { |
||||
Sandstorm, |
||||
}; |
@ -1,30 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
export const Sandstorm = {}; |
||||
|
||||
Sandstorm.request = function() {}; |
||||
if (Meteor.settings.public.sandstorm) { |
||||
const callbackMap = {}; |
||||
|
||||
const messageListener = function(event) { |
||||
if (event.data.rpcId) { |
||||
const cb = callbackMap[event.data.rpcId]; |
||||
|
||||
cb(event.data.error, event.data); |
||||
} |
||||
}; |
||||
window.addEventListener('message', messageListener); |
||||
|
||||
const interfaces = { |
||||
uiView: 'EAZQAQEAABEBF1EEAQH_5-Jn6pjXtNsAAAA', |
||||
}; |
||||
|
||||
Sandstorm.request = function(interfaceName, cb) { |
||||
const rpcId = Math.random().toString(); |
||||
callbackMap[rpcId] = cb; |
||||
window.parent.postMessage({ powerboxRequest: { |
||||
rpcId, |
||||
query: [interfaces[interfaceName]], |
||||
} }, '*'); |
||||
}; |
||||
} |
@ -1,15 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
import { FlowRouter } from 'meteor/kadira:flow-router'; |
||||
|
||||
function updateSandstormMetaData(msg) { |
||||
return window.parent.postMessage(msg, '*'); |
||||
} |
||||
|
||||
if (Meteor.settings.public.sandstorm) { |
||||
// Set the path of the parent frame when the grain's path changes.
|
||||
// See https://docs.sandstorm.io/en/latest/developing/path/
|
||||
|
||||
FlowRouter.triggers.enter([({ path }) => { |
||||
updateSandstormMetaData({ setPath: path }); |
||||
}]); |
||||
} |
@ -1,8 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
if (Meteor.isClient) { |
||||
module.exports = require('./client/index.js'); |
||||
} |
||||
if (Meteor.isServer) { |
||||
module.exports = require('./server/index.js'); |
||||
} |
@ -1,42 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
import { getHttpBridge, waitPromise } from './lib'; |
||||
import { Sandstorm } from './lib'; |
||||
import _ from 'underscore'; |
||||
|
||||
Sandstorm.notify = function() {}; |
||||
|
||||
if (process.env.SANDSTORM === '1') { |
||||
const ACTIVITY_TYPES = { |
||||
message: 0, |
||||
privateMessage: 1, |
||||
}; |
||||
|
||||
Sandstorm.notify = function(message, userIds, caption, type) { |
||||
const sessionId = message.sandstormSessionId; |
||||
if (!sessionId) { |
||||
return; |
||||
} |
||||
const httpBridge = getHttpBridge(); |
||||
const activity = {}; |
||||
|
||||
if (type) { |
||||
activity.type = ACTIVITY_TYPES[type]; |
||||
} |
||||
|
||||
if (caption) { |
||||
activity.notification = { caption: { defaultText: caption } }; |
||||
} |
||||
|
||||
if (userIds) { |
||||
activity.users = _.map(userIds, function(userId) { |
||||
const user = Meteor.users.findOne({ _id: userId }, { fields: { 'services.sandstorm.id': 1 } }); |
||||
return { |
||||
identity: waitPromise(httpBridge.getSavedIdentity(user.services.sandstorm.id)).identity, |
||||
mentioned: true, |
||||
}; |
||||
}); |
||||
} |
||||
|
||||
return waitPromise(httpBridge.getSessionContext(sessionId).context.activity(activity)); |
||||
}; |
||||
} |
@ -1,7 +0,0 @@ |
||||
import { Sandstorm } from './lib'; |
||||
import './events'; |
||||
import './powerbox'; |
||||
|
||||
export { |
||||
Sandstorm, |
||||
}; |
@ -1,39 +0,0 @@ |
||||
import Future from 'fibers/future'; |
||||
import { UploadFS } from 'meteor/jalik:ufs'; |
||||
|
||||
export const Sandstorm = {}; |
||||
|
||||
export let getHttpBridge; |
||||
export let waitPromise; |
||||
|
||||
if (process.env.SANDSTORM === '1') { |
||||
const Capnp = require('capnp'); |
||||
const { SandstormHttpBridge } = Capnp.importSystem('sandstorm/sandstorm-http-bridge.capnp'); |
||||
|
||||
let capnpConnection = null; |
||||
let httpBridge = null; |
||||
|
||||
getHttpBridge = function() { |
||||
if (!httpBridge) { |
||||
capnpConnection = Capnp.connect('unix:/tmp/sandstorm-api'); |
||||
httpBridge = capnpConnection.restore(null, SandstormHttpBridge); |
||||
} |
||||
return httpBridge; |
||||
}; |
||||
|
||||
const promiseToFuture = function(promise) { |
||||
const result = new Future(); |
||||
promise.then(result.return.bind(result), result.throw.bind(result)); |
||||
return result; |
||||
}; |
||||
|
||||
waitPromise = function(promise) { |
||||
return promiseToFuture(promise).wait(); |
||||
}; |
||||
|
||||
// This usual implementation of this method returns an absolute URL that is invalid
|
||||
// under Sandstorm.
|
||||
UploadFS.Store.prototype.getURL = function(path) { |
||||
return this.getRelativeURL(path); |
||||
}; |
||||
} |
@ -1,50 +0,0 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
import { Sandstorm } from './lib'; |
||||
import { getHttpBridge, waitPromise } from './lib'; |
||||
|
||||
Sandstorm.offerUiView = function() {}; |
||||
|
||||
if (process.env.SANDSTORM === '1') { |
||||
const Capnp = require('capnp'); |
||||
const Powerbox = Capnp.importSystem('sandstorm/powerbox.capnp'); |
||||
const Grain = Capnp.importSystem('sandstorm/grain.capnp'); |
||||
|
||||
Sandstorm.offerUiView = function(token, serializedDescriptor, sessionId) { |
||||
const httpBridge = getHttpBridge(); |
||||
const session = httpBridge.getSessionContext(sessionId).context; |
||||
const { api } = httpBridge.getSandstormApi(sessionId); |
||||
const { cap } = waitPromise(api.restore(new Buffer(token, 'base64'))); |
||||
return waitPromise(session.offer(cap, undefined, { tags: [{ |
||||
id: '15831515641881813735', |
||||
value: new Buffer(serializedDescriptor, 'base64'), |
||||
}] })); |
||||
}; |
||||
|
||||
Meteor.methods({ |
||||
sandstormClaimRequest(token, serializedDescriptor) { |
||||
const descriptor = Capnp.parsePacked(Powerbox.PowerboxDescriptor, new Buffer(serializedDescriptor, 'base64')); |
||||
const grainTitle = Capnp.parse(Grain.UiView.PowerboxTag, descriptor.tags[0].value).title; |
||||
const sessionId = this.connection.sandstormSessionId(); |
||||
const httpBridge = getHttpBridge(); |
||||
const session = httpBridge.getSessionContext(sessionId).context; |
||||
const cap = waitPromise(session.claimRequest(token)).cap.castAs(Grain.UiView); |
||||
const { api } = httpBridge.getSandstormApi(sessionId); |
||||
const newToken = waitPromise(api.save(cap)).token.toString('base64'); |
||||
const viewInfo = waitPromise(cap.getViewInfo()); |
||||
const { appTitle } = viewInfo; |
||||
const asset = waitPromise(viewInfo.grainIcon.getUrl()); |
||||
const appIconUrl = `${ asset.protocol }://${ asset.hostPath }`; |
||||
return { |
||||
token: newToken, |
||||
appTitle, |
||||
appIconUrl, |
||||
grainTitle, |
||||
descriptor: descriptor.tags[0].value.toString('base64'), |
||||
}; |
||||
}, |
||||
sandstormOffer(token, serializedDescriptor) { |
||||
Sandstorm.offerUiView(token, serializedDescriptor, |
||||
this.connection.sandstormSessionId()); |
||||
}, |
||||
}); |
||||
} |