How to use the matrix-js-sdk.WebStorageSessionStore function in matrix-js-sdk

To help you get started, we’ve selected a few matrix-js-sdk 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 vector-im / riot-web / src / MatrixClientPeg.js View on Github external
function createClient(hs_url, is_url, user_id, access_token) {
    var opts = {
        baseUrl: hs_url,
        idBaseUrl: is_url,
        accessToken: access_token,
        userId: user_id
    };

    if (localStorage) {
        opts.sessionStore = new Matrix.WebStorageSessionStore(localStorage);
        opts.deviceId = deviceId();
    }

    matrixClient = Matrix.createClient(opts);
}
github stanford-oval / thingengine-core / lib / devices / builtins / matrix / index.js View on Github external
async function makeMatrixClient(userId, deviceId, platform, storage, accessToken, options) {
    const db = sql.db(platform.getSqliteDB(), platform.getSqliteKey());
    const ownerId = userId + '/' + deviceId;

    const store = new SqliteStore({ userId: ownerId, db: db });
    await store.startup();
    const matrixClient = Matrix.createClient({
        baseUrl: options.homeServerURL,
        idBaseUrl: options.identityServerURL,
        store: store,
        sessionStore: new Matrix.WebStorageSessionStore(storage),
        cryptoStore: new CryptoSqliteStore(db, ownerId),
        userId: userId,
        deviceId: deviceId,
        accessToken: accessToken
    });
    if (global.Olm)
        matrixClient.initCrypto();
    return matrixClient;
}
github FabricLabs / fabric / src / utils / createMatrixClient.js View on Github external
export default function createMatrixClient(opts, useIndexedDb) {
    if (useIndexedDb === undefined) useIndexedDb = true;

    const storeOpts = {
        useAuthorizationHeader: true,
    };

    if (localStorage) {
        storeOpts.sessionStore = new Matrix.WebStorageSessionStore(localStorage);
    }

    if (indexedDB && localStorage && useIndexedDb) {
        storeOpts.store = new Matrix.IndexedDBStore({
            indexedDB: indexedDB,
            dbName: "riot-web-sync",
            localStorage: localStorage,
            workerScript: createMatrixClient.indexedDbWorkerScript,
        });
    }

    opts = Object.assign(storeOpts, opts);

    return Matrix.createClient(opts);
}