1 | var matrixcs = require("./lib/matrix");
|
2 | const request = require('browser-request');
|
3 | const queryString = require('qs');
|
4 |
|
5 | matrixcs.request(function(opts, fn) {
|
6 | // We manually fix the query string for browser-request because
|
7 | // it doesn't correctly handle cases like ?via=one&via=two. Instead
|
8 | // we mimic `request`'s query string interface to make it all work
|
9 | // as expected.
|
10 | // browser-request will happily take the constructed string as the
|
11 | // query string without trying to modify it further.
|
12 | opts.qs = queryString.stringify(opts.qs || {}, opts.qsStringifyOptions);
|
13 | return request(opts, fn);
|
14 | });
|
15 |
|
16 | // just *accessing* indexedDB throws an exception in firefox with
|
17 | // indexeddb disabled.
|
18 | var indexedDB;
|
19 | try {
|
20 | indexedDB = global.indexedDB;
|
21 | } catch(e) {}
|
22 |
|
23 | // if our browser (appears to) support indexeddb, use an indexeddb crypto store.
|
24 | if (indexedDB) {
|
25 | matrixcs.setCryptoStoreFactory(
|
26 | function() {
|
27 | return new matrixcs.IndexedDBCryptoStore(
|
28 | indexedDB, "matrix-js-sdk:crypto"
|
29 | );
|
30 | }
|
31 | );
|
32 | }
|
33 |
|
34 | module.exports = matrixcs; // keep export for browserify package deps
|
35 | global.matrixcs = matrixcs;
|