How to use @casual-simulation/aux-vm-node - 7 common examples

To help you get started, we’ve selected a few @casual-simulation/aux-vm-node examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github casual-simulation / aux / src / aux-server / server / modules / SetupChannelModule2.ts View on Github external
private async _setupChannel(event: SetupChannelAction) {
        try {
            const hasChannel = await this._client
                .branchInfo(event.channel)
                .pipe(map(e => e.exists))
                .toPromise();
            if (!hasChannel) {
                console.log(
                    `[SetupChannelModule2] Setting up new channel ${
                        event.channel
                    }`
                );

                // TODO: Rework so that other modules can be used like webhooks.
                const simulation = nodeSimulationForBranch(
                    this._user,
                    this._client,
                    event.channel
                );
                try {
                    await simulation.init();

                    if (event.botOrMod) {
                        console.log(`[SetupChannelModule2] Creating new bot`);
                        const botId = await simulation.helper.createBot(
                            undefined,
                            isBot(event.botOrMod)
                                ? event.botOrMod.tags
                                : event.botOrMod
                        );
                        console.log(
github casual-simulation / aux / src / aux-server / server / modules / SetupChannelModule2.spec.ts View on Github external
expect.assertions(2);

                await simulation.helper.transaction(
                    setupChannel('newChannel', {
                        onCreate: '@setTag(this, "created", true)',
                    })
                );

                await waitAsync();

                const channelInfo = await serverClient
                    .branchInfo('newChannel')
                    .toPromise();
                expect(channelInfo.exists).toBe(true);

                const newChannelSim = nodeSimulationForBranch(
                    processingUser,
                    processingClient,
                    'newChannel'
                );
                await newChannelSim.init();

                const { result } = await newChannelSim.helper.search(
                    `getBot("created", true)`
                );
                expect(result).toEqual(
                    createBot(result.id, {
                        onCreate: '@setTag(this, "created", true)',
                        created: true,
                    })
                );
            });
github casual-simulation / aux / src / aux-server / server / modules / SetupChannelModule2.spec.ts View on Github external
]);

        const server = new CausalRepoServer(
            fixedConnectionServer,
            store,
            stageStore
        );
        server.init();

        serverClient = new CausalRepoClient(serverBridge.clientConnection);
        processingClient = new CausalRepoClient(
            processingBridge.clientConnection
        );
        subject = new SetupChannelModule2(serverUser, serverClient);

        simulation = nodeSimulationForBranch(user, serverClient, 'id');
        await simulation.init();

        sub = await subject.setup(simulation);
    });
github casual-simulation / aux / src / aux-server / server / modules / WebhooksModule2.spec.ts View on Github external
[USERNAME_CLAIM]: 'username',
                [DEVICE_ID_CLAIM]: 'deviceId',
                [SESSION_ID_CLAIM]: 'sessionId',
            },
            roles: [],
        };
        serverDevice = {
            claims: {
                [USERNAME_CLAIM]: 'server',
                [DEVICE_ID_CLAIM]: 'deviceId',
                [SESSION_ID_CLAIM]: 'sessionId',
            },
            roles: [SERVER_ROLE],
        };

        simulation = nodeSimulationWithConfig(user, 'test', config);
        await simulation.init();

        subject = new WebhooksModule2();
        sub = await subject.setup(simulation);
    });
github casual-simulation / aux / src / aux-server / server / modules / BackupModule2.ts View on Github external
(id: string) =>
                                    nodeSimulationForBranch(
                                        this._user,
                                        this._client,
                                        id,
                                        {
                                            readOnly: true,
                                        }
                                    ),
                                this._client
github casual-simulation / aux / src / aux-server / server / AuxSimulationServer.ts View on Github external
server.whileCausalTreeLoaded((tree, info) => {
                const simulation = new NodeSimulation(
                    serverUser,
                    info.id,
                    {
                        isBuilder: false,
                        isPlayer: false,
                    },
                    tree
                );

                return [simulation];
            }),
        ];

@casual-simulation/aux-vm-node

A set of utilities required to security run an AUX in Node.js.

MIT
Latest version published 16 days ago

Package Health Score

70 / 100
Full package analysis