repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
segmentio/analytics.js
analytics.js
formatClassicOptions
function formatClassicOptions(options) { return alias(options, { forumId: 'forum_id', classicMode: 'mode', primaryColor: 'primary_color', tabPosition: 'tab_position', tabColor: 'tab_color', linkColor: 'link_color', defaultMode: 'default_mode', tabLabel: 'tab_label', tabInverted: 't...
javascript
function formatClassicOptions(options) { return alias(options, { forumId: 'forum_id', classicMode: 'mode', primaryColor: 'primary_color', tabPosition: 'tab_position', tabColor: 'tab_color', linkColor: 'link_color', defaultMode: 'default_mode', tabLabel: 'tab_label', tabInverted: 't...
[ "function", "formatClassicOptions", "(", "options", ")", "{", "return", "alias", "(", "options", ",", "{", "forumId", ":", "'forum_id'", ",", "classicMode", ":", "'mode'", ",", "primaryColor", ":", "'primary_color'", ",", "tabPosition", ":", "'tab_position'", ",...
Format the classic options for UserVoice. @api private @param {Object} options @return {Object}
[ "Format", "the", "classic", "options", "for", "UserVoice", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L19737-L19749
train
segmentio/analytics.js
analytics.js
enqueue
function enqueue(fn) { window._vis_opt_queue = window._vis_opt_queue || []; window._vis_opt_queue.push(fn); }
javascript
function enqueue(fn) { window._vis_opt_queue = window._vis_opt_queue || []; window._vis_opt_queue.push(fn); }
[ "function", "enqueue", "(", "fn", ")", "{", "window", ".", "_vis_opt_queue", "=", "window", ".", "_vis_opt_queue", "||", "[", "]", ";", "window", ".", "_vis_opt_queue", ".", "push", "(", "fn", ")", ";", "}" ]
Add a `fn` to the VWO queue, creating one if it doesn't exist. @param {Function} fn
[ "Add", "a", "fn", "to", "the", "VWO", "queue", "creating", "one", "if", "it", "doesn", "t", "exist", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L20060-L20063
train
segmentio/analytics.js
analytics.js
variation
function variation(id) { var experiments = window._vwo_exp; if (!experiments) return null; var experiment = experiments[id]; var variationId = experiment.combination_chosen; return variationId ? experiment.comb_n[variationId] : null; }
javascript
function variation(id) { var experiments = window._vwo_exp; if (!experiments) return null; var experiment = experiments[id]; var variationId = experiment.combination_chosen; return variationId ? experiment.comb_n[variationId] : null; }
[ "function", "variation", "(", "id", ")", "{", "var", "experiments", "=", "window", ".", "_vwo_exp", ";", "if", "(", "!", "experiments", ")", "return", "null", ";", "var", "experiment", "=", "experiments", "[", "id", "]", ";", "var", "variationId", "=", ...
Get the chosen variation's name from an experiment `id`. http://visualwebsiteoptimizer.com/knowledge/integration-of-vwo-with-kissmetrics/ @param {String} id @return {String}
[ "Get", "the", "chosen", "variation", "s", "name", "from", "an", "experiment", "id", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L20074-L20080
train
segmentio/analytics.js
analytics.js
push
function push(callback) { window.yandex_metrika_callbacks = window.yandex_metrika_callbacks || []; window.yandex_metrika_callbacks.push(callback); }
javascript
function push(callback) { window.yandex_metrika_callbacks = window.yandex_metrika_callbacks || []; window.yandex_metrika_callbacks.push(callback); }
[ "function", "push", "(", "callback", ")", "{", "window", ".", "yandex_metrika_callbacks", "=", "window", ".", "yandex_metrika_callbacks", "||", "[", "]", ";", "window", ".", "yandex_metrika_callbacks", ".", "push", "(", "callback", ")", ";", "}" ]
Push a new callback on the global Yandex queue. @api private @param {Function} callback
[ "Push", "a", "new", "callback", "on", "the", "global", "Yandex", "queue", "." ]
077efafa234d0bb4374169adb4e1ff71da39af8f
https://github.com/segmentio/analytics.js/blob/077efafa234d0bb4374169adb4e1ff71da39af8f/analytics.js#L20405-L20408
train
expressjs/compression
index.js
chunkLength
function chunkLength (chunk, encoding) { if (!chunk) { return 0 } return !Buffer.isBuffer(chunk) ? Buffer.byteLength(chunk, encoding) : chunk.length }
javascript
function chunkLength (chunk, encoding) { if (!chunk) { return 0 } return !Buffer.isBuffer(chunk) ? Buffer.byteLength(chunk, encoding) : chunk.length }
[ "function", "chunkLength", "(", "chunk", ",", "encoding", ")", "{", "if", "(", "!", "chunk", ")", "{", "return", "0", "}", "return", "!", "Buffer", ".", "isBuffer", "(", "chunk", ")", "?", "Buffer", ".", "byteLength", "(", "chunk", ",", "encoding", "...
Get the length of a given chunk
[ "Get", "the", "length", "of", "a", "given", "chunk" ]
dd5055dc92fdeacad706972c4fcf3a7ff10066ef
https://github.com/expressjs/compression/blob/dd5055dc92fdeacad706972c4fcf3a7ff10066ef/index.js#L239-L247
train
expressjs/compression
index.js
shouldCompress
function shouldCompress (req, res) { var type = res.getHeader('Content-Type') if (type === undefined || !compressible(type)) { debug('%s not compressible', type) return false } return true }
javascript
function shouldCompress (req, res) { var type = res.getHeader('Content-Type') if (type === undefined || !compressible(type)) { debug('%s not compressible', type) return false } return true }
[ "function", "shouldCompress", "(", "req", ",", "res", ")", "{", "var", "type", "=", "res", ".", "getHeader", "(", "'Content-Type'", ")", "if", "(", "type", "===", "undefined", "||", "!", "compressible", "(", "type", ")", ")", "{", "debug", "(", "'%s no...
Default filter function. @private
[ "Default", "filter", "function", "." ]
dd5055dc92fdeacad706972c4fcf3a7ff10066ef
https://github.com/expressjs/compression/blob/dd5055dc92fdeacad706972c4fcf3a7ff10066ef/index.js#L254-L263
train
expressjs/compression
index.js
shouldTransform
function shouldTransform (req, res) { var cacheControl = res.getHeader('Cache-Control') // Don't compress for Cache-Control: no-transform // https://tools.ietf.org/html/rfc7234#section-5.2.2.4 return !cacheControl || !cacheControlNoTransformRegExp.test(cacheControl) }
javascript
function shouldTransform (req, res) { var cacheControl = res.getHeader('Cache-Control') // Don't compress for Cache-Control: no-transform // https://tools.ietf.org/html/rfc7234#section-5.2.2.4 return !cacheControl || !cacheControlNoTransformRegExp.test(cacheControl) }
[ "function", "shouldTransform", "(", "req", ",", "res", ")", "{", "var", "cacheControl", "=", "res", ".", "getHeader", "(", "'Cache-Control'", ")", "// Don't compress for Cache-Control: no-transform", "// https://tools.ietf.org/html/rfc7234#section-5.2.2.4", "return", "!", "...
Determine if the entity should be transformed. @private
[ "Determine", "if", "the", "entity", "should", "be", "transformed", "." ]
dd5055dc92fdeacad706972c4fcf3a7ff10066ef
https://github.com/expressjs/compression/blob/dd5055dc92fdeacad706972c4fcf3a7ff10066ef/index.js#L270-L277
train
expressjs/compression
index.js
toBuffer
function toBuffer (chunk, encoding) { return !Buffer.isBuffer(chunk) ? Buffer.from(chunk, encoding) : chunk }
javascript
function toBuffer (chunk, encoding) { return !Buffer.isBuffer(chunk) ? Buffer.from(chunk, encoding) : chunk }
[ "function", "toBuffer", "(", "chunk", ",", "encoding", ")", "{", "return", "!", "Buffer", ".", "isBuffer", "(", "chunk", ")", "?", "Buffer", ".", "from", "(", "chunk", ",", "encoding", ")", ":", "chunk", "}" ]
Coerce arguments to Buffer @private
[ "Coerce", "arguments", "to", "Buffer" ]
dd5055dc92fdeacad706972c4fcf3a7ff10066ef
https://github.com/expressjs/compression/blob/dd5055dc92fdeacad706972c4fcf3a7ff10066ef/index.js#L284-L288
train
zeit/styled-jsx
src/lib/style-transform.js
transform
function transform(hash, styles, settings = {}) { generator = settings.generator offset = settings.offset filename = settings.filename splitRules = [] stylis.set({ prefix: typeof settings.vendorPrefixes === 'boolean' ? settings.vendorPrefixes : true }) stylis(hash, styles) i...
javascript
function transform(hash, styles, settings = {}) { generator = settings.generator offset = settings.offset filename = settings.filename splitRules = [] stylis.set({ prefix: typeof settings.vendorPrefixes === 'boolean' ? settings.vendorPrefixes : true }) stylis(hash, styles) i...
[ "function", "transform", "(", "hash", ",", "styles", ",", "settings", "=", "{", "}", ")", "{", "generator", "=", "settings", ".", "generator", "offset", "=", "settings", ".", "offset", "filename", "=", "settings", ".", "filename", "splitRules", "=", "[", ...
Public transform function @param {String} hash @param {String} styles @param {Object} settings @return {string}
[ "Public", "transform", "function" ]
00fcb7bcad9c8af91167056f93c63858d24769ba
https://github.com/zeit/styled-jsx/blob/00fcb7bcad9c8af91167056f93c63858d24769ba/src/lib/style-transform.js#L96-L116
train
HubSpot/vex
src/vex.js
addClasses
function addClasses (el, classStr) { if (typeof classStr !== 'string' || classStr.length === 0) { return } var classes = classStr.split(' ') for (var i = 0; i < classes.length; i++) { var className = classes[i] if (className.length) { el.classList.add(className) } } }
javascript
function addClasses (el, classStr) { if (typeof classStr !== 'string' || classStr.length === 0) { return } var classes = classStr.split(' ') for (var i = 0; i < classes.length; i++) { var className = classes[i] if (className.length) { el.classList.add(className) } } }
[ "function", "addClasses", "(", "el", ",", "classStr", ")", "{", "if", "(", "typeof", "classStr", "!==", "'string'", "||", "classStr", ".", "length", "===", "0", ")", "{", "return", "}", "var", "classes", "=", "classStr", ".", "split", "(", "' '", ")", ...
Utility function to add space-delimited class strings to a DOM element's classList
[ "Utility", "function", "to", "add", "space", "-", "delimited", "class", "strings", "to", "a", "DOM", "element", "s", "classList" ]
0df3f63db5eebee09d284feec0895dc723e95514
https://github.com/HubSpot/vex/blob/0df3f63db5eebee09d284feec0895dc723e95514/src/vex.js#L21-L32
train
HubSpot/vex
src/vex.js
close
function close (vexOrId) { var id if (vexOrId.id) { id = vexOrId.id } else if (typeof vexOrId === 'string') { id = vexOrId } else { throw new TypeError('close requires a vex object or id string') } if (!vexes[id]) { return false } return vexes[id].close() }
javascript
function close (vexOrId) { var id if (vexOrId.id) { id = vexOrId.id } else if (typeof vexOrId === 'string') { id = vexOrId } else { throw new TypeError('close requires a vex object or id string') } if (!vexes[id]) { return false } return vexes[id].close() }
[ "function", "close", "(", "vexOrId", ")", "{", "var", "id", "if", "(", "vexOrId", ".", "id", ")", "{", "id", "=", "vexOrId", ".", "id", "}", "else", "if", "(", "typeof", "vexOrId", "===", "'string'", ")", "{", "id", "=", "vexOrId", "}", "else", "...
A top-level vex.close function to close dialogs by reference or id
[ "A", "top", "-", "level", "vex", ".", "close", "function", "to", "close", "dialogs", "by", "reference", "or", "id" ]
0df3f63db5eebee09d284feec0895dc723e95514
https://github.com/HubSpot/vex/blob/0df3f63db5eebee09d284feec0895dc723e95514/src/vex.js#L253-L266
train
algolia/instantsearch.js
scripts/release/publish.js
rollback
function rollback(newVersion) { if (strategy === 'stable') { // reset master shell.exec('git reset --hard origin/master'); shell.exec('git checkout develop'); } else { // remove last commit shell.exec('git reset --hard HEAD~1'); } // remove local created tag shell.exec(`git tag -d v${newV...
javascript
function rollback(newVersion) { if (strategy === 'stable') { // reset master shell.exec('git reset --hard origin/master'); shell.exec('git checkout develop'); } else { // remove last commit shell.exec('git reset --hard HEAD~1'); } // remove local created tag shell.exec(`git tag -d v${newV...
[ "function", "rollback", "(", "newVersion", ")", "{", "if", "(", "strategy", "===", "'stable'", ")", "{", "// reset master", "shell", ".", "exec", "(", "'git reset --hard origin/master'", ")", ";", "shell", ".", "exec", "(", "'git checkout develop'", ")", ";", ...
called if process aborted before publish, nothing is pushed nor published remove local changes
[ "called", "if", "process", "aborted", "before", "publish", "nothing", "is", "pushed", "nor", "published", "remove", "local", "changes" ]
adf8220064dd46b5b6d6b06ef0e858bf476f219b
https://github.com/algolia/instantsearch.js/blob/adf8220064dd46b5b6d6b06ef0e858bf476f219b/scripts/release/publish.js#L78-L91
train
algolia/instantsearch.js
src/widgets/refinement-list/refinement-list.js
transformTemplates
function transformTemplates(templates) { const allTemplates = { ...templates, submit: templates.searchableSubmit, reset: templates.searchableReset, loadingIndicator: templates.searchableLoadingIndicator, }; const { searchableReset, searchableSubmit, searchableLoadingIndicator, ......
javascript
function transformTemplates(templates) { const allTemplates = { ...templates, submit: templates.searchableSubmit, reset: templates.searchableReset, loadingIndicator: templates.searchableLoadingIndicator, }; const { searchableReset, searchableSubmit, searchableLoadingIndicator, ......
[ "function", "transformTemplates", "(", "templates", ")", "{", "const", "allTemplates", "=", "{", "...", "templates", ",", "submit", ":", "templates", ".", "searchableSubmit", ",", "reset", ":", "templates", ".", "searchableReset", ",", "loadingIndicator", ":", "...
Transforms the searchable templates by removing the `searchable` prefix. This makes them usable in the `SearchBox` component. @param {object} templates The widget templates @returns {object} the formatted templates
[ "Transforms", "the", "searchable", "templates", "by", "removing", "the", "searchable", "prefix", "." ]
adf8220064dd46b5b6d6b06ef0e858bf476f219b
https://github.com/algolia/instantsearch.js/blob/adf8220064dd46b5b6d6b06ef0e858bf476f219b/src/widgets/refinement-list/refinement-list.js#L27-L43
train
algolia/instantsearch.js
src/lib/utils/clearRefinements.js
clearRefinements
function clearRefinements({ helper, attributesToClear = [] }) { let finalState = helper.state; attributesToClear.forEach(attribute => { if (attribute === '_tags') { finalState = finalState.clearTags(); } else { finalState = finalState.clearRefinements(attribute); } }); if (attributesTo...
javascript
function clearRefinements({ helper, attributesToClear = [] }) { let finalState = helper.state; attributesToClear.forEach(attribute => { if (attribute === '_tags') { finalState = finalState.clearTags(); } else { finalState = finalState.clearRefinements(attribute); } }); if (attributesTo...
[ "function", "clearRefinements", "(", "{", "helper", ",", "attributesToClear", "=", "[", "]", "}", ")", "{", "let", "finalState", "=", "helper", ".", "state", ";", "attributesToClear", ".", "forEach", "(", "attribute", "=>", "{", "if", "(", "attribute", "==...
Clears the refinements of a SearchParameters object based on rules provided. The included attributes list is applied before the excluded attributes list. If the list is not provided, this list of all the currently refined attributes is used as included attributes. @param {object} $0 parameters @param {Helper} $0.helper...
[ "Clears", "the", "refinements", "of", "a", "SearchParameters", "object", "based", "on", "rules", "provided", ".", "The", "included", "attributes", "list", "is", "applied", "before", "the", "excluded", "attributes", "list", ".", "If", "the", "list", "is", "not"...
adf8220064dd46b5b6d6b06ef0e858bf476f219b
https://github.com/algolia/instantsearch.js/blob/adf8220064dd46b5b6d6b06ef0e858bf476f219b/src/lib/utils/clearRefinements.js#L10-L26
train
algolia/instantsearch.js
src/lib/utils/prepareTemplateProps.js
prepareTemplateProps
function prepareTemplateProps({ defaultTemplates, templates, templatesConfig, }) { const preparedTemplates = prepareTemplates(defaultTemplates, templates); return { templatesConfig, ...preparedTemplates, }; }
javascript
function prepareTemplateProps({ defaultTemplates, templates, templatesConfig, }) { const preparedTemplates = prepareTemplates(defaultTemplates, templates); return { templatesConfig, ...preparedTemplates, }; }
[ "function", "prepareTemplateProps", "(", "{", "defaultTemplates", ",", "templates", ",", "templatesConfig", ",", "}", ")", "{", "const", "preparedTemplates", "=", "prepareTemplates", "(", "defaultTemplates", ",", "templates", ")", ";", "return", "{", "templatesConfi...
Prepares an object to be passed to the Template widget @param {object} unknownBecauseES6 an object with the following attributes: - defaultTemplate - templates - templatesConfig @return {object} the configuration with the attributes: - defaultTemplate - templates - useCustomCompileOptions
[ "Prepares", "an", "object", "to", "be", "passed", "to", "the", "Template", "widget" ]
adf8220064dd46b5b6d6b06ef0e858bf476f219b
https://github.com/algolia/instantsearch.js/blob/adf8220064dd46b5b6d6b06ef0e858bf476f219b/src/lib/utils/prepareTemplateProps.js#L38-L49
train
lingui/js-lingui
scripts/build/modules.js
getDependencies
function getDependencies(bundleType, entry) { const packageJson = require(path.dirname(require.resolve(entry)) + "/package.json") // Both deps and peerDeps are assumed as accessible. return Array.from( new Set([ ...Object.keys(packageJson.dependencies || {}), ...Object.keys(packageJson.peerDep...
javascript
function getDependencies(bundleType, entry) { const packageJson = require(path.dirname(require.resolve(entry)) + "/package.json") // Both deps and peerDeps are assumed as accessible. return Array.from( new Set([ ...Object.keys(packageJson.dependencies || {}), ...Object.keys(packageJson.peerDep...
[ "function", "getDependencies", "(", "bundleType", ",", "entry", ")", "{", "const", "packageJson", "=", "require", "(", "path", ".", "dirname", "(", "require", ".", "resolve", "(", "entry", ")", ")", "+", "\"/package.json\"", ")", "// Both deps and peerDeps are a...
Determines node_modules packages that are safe to assume will exist.
[ "Determines", "node_modules", "packages", "that", "are", "safe", "to", "assume", "will", "exist", "." ]
c9a4b151f621502349d3ee7ce1fc3e10d88f4a73
https://github.com/lingui/js-lingui/blob/c9a4b151f621502349d3ee7ce1fc3e10d88f4a73/scripts/build/modules.js#L37-L47
train
PolymathNetwork/polymath-core
CLI/commands/investor_portal.js
inputSymbol
async function inputSymbol(symbol) { if (typeof symbol === 'undefined') { STSymbol = readlineSync.question(chalk.yellow(`Enter the symbol of a registered security token or press 'Enter' to exit: `)); } else { STSymbol = symbol; } if (STSymbol == "") process.exit(); STAddress = awai...
javascript
async function inputSymbol(symbol) { if (typeof symbol === 'undefined') { STSymbol = readlineSync.question(chalk.yellow(`Enter the symbol of a registered security token or press 'Enter' to exit: `)); } else { STSymbol = symbol; } if (STSymbol == "") process.exit(); STAddress = awai...
[ "async", "function", "inputSymbol", "(", "symbol", ")", "{", "if", "(", "typeof", "symbol", "===", "'undefined'", ")", "{", "STSymbol", "=", "readlineSync", ".", "question", "(", "chalk", ".", "yellow", "(", "`", "`", ")", ")", ";", "}", "else", "{", ...
Input security token symbol or exit
[ "Input", "security", "token", "symbol", "or", "exit" ]
aa635df01588f733ce95bc13fe319c7d3c858a24
https://github.com/PolymathNetwork/polymath-core/blob/aa635df01588f733ce95bc13fe319c7d3c858a24/CLI/commands/investor_portal.js#L102-L136
train
PolymathNetwork/polymath-core
CLI/commands/token_manager.js
addModule
async function addModule() { let options = ['Permission Manager', 'Transfer Manager', 'Security Token Offering', 'Dividends', 'Burn']; let index = readlineSync.keyInSelect(options, 'What type of module would you like to add?', { cancel: 'Return' }); switch (options[index]) { case 'Permission Manager': c...
javascript
async function addModule() { let options = ['Permission Manager', 'Transfer Manager', 'Security Token Offering', 'Dividends', 'Burn']; let index = readlineSync.keyInSelect(options, 'What type of module would you like to add?', { cancel: 'Return' }); switch (options[index]) { case 'Permission Manager': c...
[ "async", "function", "addModule", "(", ")", "{", "let", "options", "=", "[", "'Permission Manager'", ",", "'Transfer Manager'", ",", "'Security Token Offering'", ",", "'Dividends'", ",", "'Burn'", "]", ";", "let", "index", "=", "readlineSync", ".", "keyInSelect", ...
Modules a actions
[ "Modules", "a", "actions" ]
aa635df01588f733ce95bc13fe319c7d3c858a24
https://github.com/PolymathNetwork/polymath-core/blob/aa635df01588f733ce95bc13fe319c7d3c858a24/CLI/commands/token_manager.js#L456-L485
train
bestiejs/platform.js
platform.js
cleanupOS
function cleanupOS(os, pattern, label) { // Platform tokens are defined at: // http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx // http://web.archive.org/web/20081122053950/http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx var data = { '10.0': '10', '6.4': '10 Technic...
javascript
function cleanupOS(os, pattern, label) { // Platform tokens are defined at: // http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx // http://web.archive.org/web/20081122053950/http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx var data = { '10.0': '10', '6.4': '10 Technic...
[ "function", "cleanupOS", "(", "os", ",", "pattern", ",", "label", ")", "{", "// Platform tokens are defined at:", "// http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx", "// http://web.archive.org/web/20081122053950/http://msdn.microsoft.com/en-us/library/ms537503(VS.85).aspx", ...
A utility function to clean up the OS name. @private @param {string} os The OS name to clean up. @param {string} [pattern] A `RegExp` pattern matching the OS name. @param {string} [label] A label for the OS.
[ "A", "utility", "function", "to", "clean", "up", "the", "OS", "name", "." ]
a8816881779addd8af6d8512e0295f37f8489ec7
https://github.com/bestiejs/platform.js/blob/a8816881779addd8af6d8512e0295f37f8489ec7/platform.js#L78-L125
train
bestiejs/platform.js
platform.js
each
function each(object, callback) { var index = -1, length = object ? object.length : 0; if (typeof length == 'number' && length > -1 && length <= maxSafeInteger) { while (++index < length) { callback(object[index], index, object); } } else { forOwn(object, callback); } ...
javascript
function each(object, callback) { var index = -1, length = object ? object.length : 0; if (typeof length == 'number' && length > -1 && length <= maxSafeInteger) { while (++index < length) { callback(object[index], index, object); } } else { forOwn(object, callback); } ...
[ "function", "each", "(", "object", ",", "callback", ")", "{", "var", "index", "=", "-", "1", ",", "length", "=", "object", "?", "object", ".", "length", ":", "0", ";", "if", "(", "typeof", "length", "==", "'number'", "&&", "length", ">", "-", "1", ...
An iteration utility for arrays and objects. @private @param {Array|Object} object The object to iterate over. @param {Function} callback The function called per iteration.
[ "An", "iteration", "utility", "for", "arrays", "and", "objects", "." ]
a8816881779addd8af6d8512e0295f37f8489ec7
https://github.com/bestiejs/platform.js/blob/a8816881779addd8af6d8512e0295f37f8489ec7/platform.js#L134-L145
train
bestiejs/platform.js
platform.js
format
function format(string) { string = trim(string); return /^(?:webOS|i(?:OS|P))/.test(string) ? string : capitalize(string); }
javascript
function format(string) { string = trim(string); return /^(?:webOS|i(?:OS|P))/.test(string) ? string : capitalize(string); }
[ "function", "format", "(", "string", ")", "{", "string", "=", "trim", "(", "string", ")", ";", "return", "/", "^(?:webOS|i(?:OS|P))", "/", ".", "test", "(", "string", ")", "?", "string", ":", "capitalize", "(", "string", ")", ";", "}" ]
Trim and conditionally capitalize string values. @private @param {string} string The string to format. @returns {string} The formatted string.
[ "Trim", "and", "conditionally", "capitalize", "string", "values", "." ]
a8816881779addd8af6d8512e0295f37f8489ec7
https://github.com/bestiejs/platform.js/blob/a8816881779addd8af6d8512e0295f37f8489ec7/platform.js#L154-L159
train
bestiejs/platform.js
platform.js
forOwn
function forOwn(object, callback) { for (var key in object) { if (hasOwnProperty.call(object, key)) { callback(object[key], key, object); } } }
javascript
function forOwn(object, callback) { for (var key in object) { if (hasOwnProperty.call(object, key)) { callback(object[key], key, object); } } }
[ "function", "forOwn", "(", "object", ",", "callback", ")", "{", "for", "(", "var", "key", "in", "object", ")", "{", "if", "(", "hasOwnProperty", ".", "call", "(", "object", ",", "key", ")", ")", "{", "callback", "(", "object", "[", "key", "]", ",",...
Iterates over an object's own properties, executing the `callback` for each. @private @param {Object} object The object to iterate over. @param {Function} callback The function executed per own property.
[ "Iterates", "over", "an", "object", "s", "own", "properties", "executing", "the", "callback", "for", "each", "." ]
a8816881779addd8af6d8512e0295f37f8489ec7
https://github.com/bestiejs/platform.js/blob/a8816881779addd8af6d8512e0295f37f8489ec7/platform.js#L168-L174
train
bestiejs/platform.js
platform.js
getManufacturer
function getManufacturer(guesses) { return reduce(guesses, function(result, value, key) { // Lookup the manufacturer by product or scan the UA for the manufacturer. return result || ( value[product] || value[/^[a-z]+(?: +[a-z]+\b)*/i.exec(product)] || RegExp('\\b' + q...
javascript
function getManufacturer(guesses) { return reduce(guesses, function(result, value, key) { // Lookup the manufacturer by product or scan the UA for the manufacturer. return result || ( value[product] || value[/^[a-z]+(?: +[a-z]+\b)*/i.exec(product)] || RegExp('\\b' + q...
[ "function", "getManufacturer", "(", "guesses", ")", "{", "return", "reduce", "(", "guesses", ",", "function", "(", "result", ",", "value", ",", "key", ")", "{", "// Lookup the manufacturer by product or scan the UA for the manufacturer.", "return", "result", "||", "("...
Picks the manufacturer from an array of guesses. @private @param {Array} guesses An object of guesses. @returns {null|string} The detected manufacturer.
[ "Picks", "the", "manufacturer", "from", "an", "array", "of", "guesses", "." ]
a8816881779addd8af6d8512e0295f37f8489ec7
https://github.com/bestiejs/platform.js/blob/a8816881779addd8af6d8512e0295f37f8489ec7/platform.js#L514-L523
train
bestiejs/platform.js
platform.js
getOS
function getOS(guesses) { return reduce(guesses, function(result, guess) { var pattern = guess.pattern || qualify(guess); if (!result && (result = RegExp('\\b' + pattern + '(?:/[\\d.]+|[ \\w.]*)', 'i').exec(ua) )) { result = cleanupOS(result, pattern, guess.labe...
javascript
function getOS(guesses) { return reduce(guesses, function(result, guess) { var pattern = guess.pattern || qualify(guess); if (!result && (result = RegExp('\\b' + pattern + '(?:/[\\d.]+|[ \\w.]*)', 'i').exec(ua) )) { result = cleanupOS(result, pattern, guess.labe...
[ "function", "getOS", "(", "guesses", ")", "{", "return", "reduce", "(", "guesses", ",", "function", "(", "result", ",", "guess", ")", "{", "var", "pattern", "=", "guess", ".", "pattern", "||", "qualify", "(", "guess", ")", ";", "if", "(", "!", "resul...
Picks the OS name from an array of guesses. @private @param {Array} guesses An array of guesses. @returns {null|string} The detected OS name.
[ "Picks", "the", "OS", "name", "from", "an", "array", "of", "guesses", "." ]
a8816881779addd8af6d8512e0295f37f8489ec7
https://github.com/bestiejs/platform.js/blob/a8816881779addd8af6d8512e0295f37f8489ec7/platform.js#L547-L557
train
bestiejs/platform.js
platform.js
getProduct
function getProduct(guesses) { return reduce(guesses, function(result, guess) { var pattern = guess.pattern || qualify(guess); if (!result && (result = RegExp('\\b' + pattern + ' *\\d+[.\\w_]*', 'i').exec(ua) || RegExp('\\b' + pattern + ' *\\w+-[\\w]*', 'i').exec(ua) ||...
javascript
function getProduct(guesses) { return reduce(guesses, function(result, guess) { var pattern = guess.pattern || qualify(guess); if (!result && (result = RegExp('\\b' + pattern + ' *\\d+[.\\w_]*', 'i').exec(ua) || RegExp('\\b' + pattern + ' *\\w+-[\\w]*', 'i').exec(ua) ||...
[ "function", "getProduct", "(", "guesses", ")", "{", "return", "reduce", "(", "guesses", ",", "function", "(", "result", ",", "guess", ")", "{", "var", "pattern", "=", "guess", ".", "pattern", "||", "qualify", "(", "guess", ")", ";", "if", "(", "!", "...
Picks the product name from an array of guesses. @private @param {Array} guesses An array of guesses. @returns {null|string} The detected product name.
[ "Picks", "the", "product", "name", "from", "an", "array", "of", "guesses", "." ]
a8816881779addd8af6d8512e0295f37f8489ec7
https://github.com/bestiejs/platform.js/blob/a8816881779addd8af6d8512e0295f37f8489ec7/platform.js#L566-L587
train
bestiejs/platform.js
platform.js
getVersion
function getVersion(patterns) { return reduce(patterns, function(result, pattern) { return result || (RegExp(pattern + '(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)', 'i').exec(ua) || 0)[1] || null; }); }
javascript
function getVersion(patterns) { return reduce(patterns, function(result, pattern) { return result || (RegExp(pattern + '(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)', 'i').exec(ua) || 0)[1] || null; }); }
[ "function", "getVersion", "(", "patterns", ")", "{", "return", "reduce", "(", "patterns", ",", "function", "(", "result", ",", "pattern", ")", "{", "return", "result", "||", "(", "RegExp", "(", "pattern", "+", "'(?:-[\\\\d.]+/|(?: for [\\\\w-]+)?[ /-])([\\\\d.]+[^...
Resolves the version using an array of UA patterns. @private @param {Array} patterns An array of UA patterns. @returns {null|string} The detected version.
[ "Resolves", "the", "version", "using", "an", "array", "of", "UA", "patterns", "." ]
a8816881779addd8af6d8512e0295f37f8489ec7
https://github.com/bestiejs/platform.js/blob/a8816881779addd8af6d8512e0295f37f8489ec7/platform.js#L596-L601
train
KhaosT/HAP-NodeJS
lib/Characteristic.js
Characteristic
function Characteristic(displayName, UUID, props) { this.displayName = displayName; this.UUID = UUID; this.iid = null; // assigned by our containing Service this.value = null; this.status = null; this.eventOnlyCharacteristic = false; this.props = props || { format: null, unit: null, minValue: ...
javascript
function Characteristic(displayName, UUID, props) { this.displayName = displayName; this.UUID = UUID; this.iid = null; // assigned by our containing Service this.value = null; this.status = null; this.eventOnlyCharacteristic = false; this.props = props || { format: null, unit: null, minValue: ...
[ "function", "Characteristic", "(", "displayName", ",", "UUID", ",", "props", ")", "{", "this", ".", "displayName", "=", "displayName", ";", "this", ".", "UUID", "=", "UUID", ";", "this", ".", "iid", "=", "null", ";", "// assigned by our containing Service", ...
Characteristic represents a particular typed variable that can be assigned to a Service. For instance, a "Hue" Characteristic might store a 'float' value of type 'arcdegrees'. You could add the Hue Characteristic to a Service in order to store that value. A particular Characteristic is distinguished from others by its ...
[ "Characteristic", "represents", "a", "particular", "typed", "variable", "that", "can", "be", "assigned", "to", "a", "Service", ".", "For", "instance", "a", "Hue", "Characteristic", "might", "store", "a", "float", "value", "of", "type", "arcdegrees", ".", "You"...
1862f73d495c7f25d3ed812abac4be4c1d2dee34
https://github.com/KhaosT/HAP-NodeJS/blob/1862f73d495c7f25d3ed812abac4be4c1d2dee34/lib/Characteristic.js#L46-L63
train
KhaosT/HAP-NodeJS
lib/model/AccessoryInfo.js
AccessoryInfo
function AccessoryInfo(username) { this.username = username; this.displayName = ""; this.category = ""; this.pincode = ""; this.signSk = bufferShim.alloc(0); this.signPk = bufferShim.alloc(0); this.pairedClients = {}; // pairedClients[clientUsername:string] = clientPublicKey:Buffer this.configVersion = ...
javascript
function AccessoryInfo(username) { this.username = username; this.displayName = ""; this.category = ""; this.pincode = ""; this.signSk = bufferShim.alloc(0); this.signPk = bufferShim.alloc(0); this.pairedClients = {}; // pairedClients[clientUsername:string] = clientPublicKey:Buffer this.configVersion = ...
[ "function", "AccessoryInfo", "(", "username", ")", "{", "this", ".", "username", "=", "username", ";", "this", ".", "displayName", "=", "\"\"", ";", "this", ".", "category", "=", "\"\"", ";", "this", ".", "pincode", "=", "\"\"", ";", "this", ".", "sign...
AccessoryInfo is a model class containing a subset of Accessory data relevant to the internal HAP server, such as encryption keys and username. It is persisted to disk.
[ "AccessoryInfo", "is", "a", "model", "class", "containing", "a", "subset", "of", "Accessory", "data", "relevant", "to", "the", "internal", "HAP", "server", "such", "as", "encryption", "keys", "and", "username", ".", "It", "is", "persisted", "to", "disk", "."...
1862f73d495c7f25d3ed812abac4be4c1d2dee34
https://github.com/KhaosT/HAP-NodeJS/blob/1862f73d495c7f25d3ed812abac4be4c1d2dee34/lib/model/AccessoryInfo.js#L17-L36
train
KhaosT/HAP-NodeJS
lib/util/eventedhttp.js
EventedHTTPServerConnection
function EventedHTTPServerConnection(clientSocket) { this.sessionID = uuid.generate(clientSocket.remoteAddress + ':' + clientSocket.remotePort); this._remoteAddress = clientSocket.remoteAddress; // cache because it becomes undefined in 'onClientSocketClose' this._pendingClientSocketData = bufferShim.alloc(0); //...
javascript
function EventedHTTPServerConnection(clientSocket) { this.sessionID = uuid.generate(clientSocket.remoteAddress + ':' + clientSocket.remotePort); this._remoteAddress = clientSocket.remoteAddress; // cache because it becomes undefined in 'onClientSocketClose' this._pendingClientSocketData = bufferShim.alloc(0); //...
[ "function", "EventedHTTPServerConnection", "(", "clientSocket", ")", "{", "this", ".", "sessionID", "=", "uuid", ".", "generate", "(", "clientSocket", ".", "remoteAddress", "+", "':'", "+", "clientSocket", ".", "remotePort", ")", ";", "this", ".", "_remoteAddres...
Manages a single iOS-initiated HTTP connection during its lifetime. @event 'request' => function(request, response) { } @event 'decrypt' => function(data, {decrypted.data}, session) { } @event 'encrypt' => function(data, {encrypted.data}, session) { } @event 'close' => function() { }
[ "Manages", "a", "single", "iOS", "-", "initiated", "HTTP", "connection", "during", "its", "lifetime", "." ]
1862f73d495c7f25d3ed812abac4be4c1d2dee34
https://github.com/KhaosT/HAP-NodeJS/blob/1862f73d495c7f25d3ed812abac4be4c1d2dee34/lib/util/eventedhttp.js#L113-L150
train
KhaosT/HAP-NodeJS
lib/Service.js
Service
function Service(displayName, UUID, subtype) { if (!UUID) throw new Error("Services must be created with a valid UUID."); this.displayName = displayName; this.UUID = UUID; this.subtype = subtype; this.iid = null; // assigned later by our containing Accessory this.characteristics = []; this.optionalChara...
javascript
function Service(displayName, UUID, subtype) { if (!UUID) throw new Error("Services must be created with a valid UUID."); this.displayName = displayName; this.UUID = UUID; this.subtype = subtype; this.iid = null; // assigned later by our containing Accessory this.characteristics = []; this.optionalChara...
[ "function", "Service", "(", "displayName", ",", "UUID", ",", "subtype", ")", "{", "if", "(", "!", "UUID", ")", "throw", "new", "Error", "(", "\"Services must be created with a valid UUID.\"", ")", ";", "this", ".", "displayName", "=", "displayName", ";", "this...
Service represents a set of grouped values necessary to provide a logical function. For instance, a "Door Lock Mechanism" service might contain two values, one for the "desired lock state" and one for the "current lock state". A particular Service is distinguished from others by its "type", which is a UUID. HomeKit pro...
[ "Service", "represents", "a", "set", "of", "grouped", "values", "necessary", "to", "provide", "a", "logical", "function", ".", "For", "instance", "a", "Door", "Lock", "Mechanism", "service", "might", "contain", "two", "values", "one", "for", "the", "desired", ...
1862f73d495c7f25d3ed812abac4be4c1d2dee34
https://github.com/KhaosT/HAP-NodeJS/blob/1862f73d495c7f25d3ed812abac4be4c1d2dee34/lib/Service.js#L36-L62
train
KhaosT/HAP-NodeJS
lib/util/clone.js
clone
function clone(object, extend) { var cloned = {}; for (var key in object) { cloned[key] = object[key]; } for (var key in extend) { cloned[key] = extend[key]; } return cloned; }
javascript
function clone(object, extend) { var cloned = {}; for (var key in object) { cloned[key] = object[key]; } for (var key in extend) { cloned[key] = extend[key]; } return cloned; }
[ "function", "clone", "(", "object", ",", "extend", ")", "{", "var", "cloned", "=", "{", "}", ";", "for", "(", "var", "key", "in", "object", ")", "{", "cloned", "[", "key", "]", "=", "object", "[", "key", "]", ";", "}", "for", "(", "var", "key",...
A simple clone function that also allows you to pass an "extend" object whose properties will be added to the cloned copy of the original object passed.
[ "A", "simple", "clone", "function", "that", "also", "allows", "you", "to", "pass", "an", "extend", "object", "whose", "properties", "will", "be", "added", "to", "the", "cloned", "copy", "of", "the", "original", "object", "passed", "." ]
1862f73d495c7f25d3ed812abac4be4c1d2dee34
https://github.com/KhaosT/HAP-NodeJS/blob/1862f73d495c7f25d3ed812abac4be4c1d2dee34/lib/util/clone.js#L12-L25
train
KhaosT/HAP-NodeJS
lib/Accessory.js
Accessory
function Accessory(displayName, UUID) { if (!displayName) throw new Error("Accessories must be created with a non-empty displayName."); if (!UUID) throw new Error("Accessories must be created with a valid UUID."); if (!uuid.isValid(UUID)) throw new Error("UUID '" + UUID + "' is not a valid UUID. Try using the pr...
javascript
function Accessory(displayName, UUID) { if (!displayName) throw new Error("Accessories must be created with a non-empty displayName."); if (!UUID) throw new Error("Accessories must be created with a valid UUID."); if (!uuid.isValid(UUID)) throw new Error("UUID '" + UUID + "' is not a valid UUID. Try using the pr...
[ "function", "Accessory", "(", "displayName", ",", "UUID", ")", "{", "if", "(", "!", "displayName", ")", "throw", "new", "Error", "(", "\"Accessories must be created with a non-empty displayName.\"", ")", ";", "if", "(", "!", "UUID", ")", "throw", "new", "Error",...
Accessory is a virtual HomeKit device. It can publish an associated HAP server for iOS devices to communicate with - or it can run behind another "Bridge" Accessory server. Bridged Accessories in this implementation must have a UUID that is unique among all other Accessories that are hosted by the Bridge. This UUID mu...
[ "Accessory", "is", "a", "virtual", "HomeKit", "device", ".", "It", "can", "publish", "an", "associated", "HAP", "server", "for", "iOS", "devices", "to", "communicate", "with", "-", "or", "it", "can", "run", "behind", "another", "Bridge", "Accessory", "server...
1862f73d495c7f25d3ed812abac4be4c1d2dee34
https://github.com/KhaosT/HAP-NodeJS/blob/1862f73d495c7f25d3ed812abac4be4c1d2dee34/lib/Accessory.js#L47-L85
train
KhaosT/HAP-NodeJS
lib/HAPServer.js
HAPServer
function HAPServer(accessoryInfo, relayServer) { this.accessoryInfo = accessoryInfo; this.allowInsecureRequest = false; // internal server that does all the actual communication this._httpServer = new EventedHTTPServer(); this._httpServer.on('listening', this._onListening.bind(this)); this._httpServer.on('...
javascript
function HAPServer(accessoryInfo, relayServer) { this.accessoryInfo = accessoryInfo; this.allowInsecureRequest = false; // internal server that does all the actual communication this._httpServer = new EventedHTTPServer(); this._httpServer.on('listening', this._onListening.bind(this)); this._httpServer.on('...
[ "function", "HAPServer", "(", "accessoryInfo", ",", "relayServer", ")", "{", "this", ".", "accessoryInfo", "=", "accessoryInfo", ";", "this", ".", "allowInsecureRequest", "=", "false", ";", "// internal server that does all the actual communication", "this", ".", "_http...
The actual HAP server that iOS devices talk to. Notes ----- It turns out that the IP-based version of HomeKit's HAP protocol operates over a sort of pseudo-HTTP. Accessories are meant to host a TCP socket server that initially behaves exactly as an HTTP/1.1 server. So iOS devices will open up a long-lived connection t...
[ "The", "actual", "HAP", "server", "that", "iOS", "devices", "talk", "to", "." ]
1862f73d495c7f25d3ed812abac4be4c1d2dee34
https://github.com/KhaosT/HAP-NodeJS/blob/1862f73d495c7f25d3ed812abac4be4c1d2dee34/lib/HAPServer.js#L81-L109
train
KhaosT/HAP-NodeJS
lib/HAPServer.js
HAPEncryption
function HAPEncryption() { // initialize member vars with null-object values this.clientPublicKey = bufferShim.alloc(0); this.secretKey = bufferShim.alloc(0); this.publicKey = bufferShim.alloc(0); this.sharedSec = bufferShim.alloc(0); this.hkdfPairEncKey = bufferShim.alloc(0); this.accessoryToControllerCo...
javascript
function HAPEncryption() { // initialize member vars with null-object values this.clientPublicKey = bufferShim.alloc(0); this.secretKey = bufferShim.alloc(0); this.publicKey = bufferShim.alloc(0); this.sharedSec = bufferShim.alloc(0); this.hkdfPairEncKey = bufferShim.alloc(0); this.accessoryToControllerCo...
[ "function", "HAPEncryption", "(", ")", "{", "// initialize member vars with null-object values", "this", ".", "clientPublicKey", "=", "bufferShim", ".", "alloc", "(", "0", ")", ";", "this", ".", "secretKey", "=", "bufferShim", ".", "alloc", "(", "0", ")", ";", ...
Simple struct to hold vars needed to support HAP encryption.
[ "Simple", "struct", "to", "hold", "vars", "needed", "to", "support", "HAP", "encryption", "." ]
1862f73d495c7f25d3ed812abac4be4c1d2dee34
https://github.com/KhaosT/HAP-NodeJS/blob/1862f73d495c7f25d3ed812abac4be4c1d2dee34/lib/HAPServer.js#L1107-L1119
train
KhaosT/HAP-NodeJS
lib/Advertiser.js
Advertiser
function Advertiser(accessoryInfo, mdnsConfig) { this.accessoryInfo = accessoryInfo; this._bonjourService = bonjour(mdnsConfig); this._advertisement = null; this._setupHash = this._computeSetupHash(); }
javascript
function Advertiser(accessoryInfo, mdnsConfig) { this.accessoryInfo = accessoryInfo; this._bonjourService = bonjour(mdnsConfig); this._advertisement = null; this._setupHash = this._computeSetupHash(); }
[ "function", "Advertiser", "(", "accessoryInfo", ",", "mdnsConfig", ")", "{", "this", ".", "accessoryInfo", "=", "accessoryInfo", ";", "this", ".", "_bonjourService", "=", "bonjour", "(", "mdnsConfig", ")", ";", "this", ".", "_advertisement", "=", "null", ";", ...
Advertiser uses mdns to broadcast the presence of an Accessory to the local network. Note that as of iOS 9, an accessory can only pair with a single client. Instead of pairing your accessories with multiple iOS devices in your home, Apple intends for you to use Home Sharing. To support this requirement, we provide the...
[ "Advertiser", "uses", "mdns", "to", "broadcast", "the", "presence", "of", "an", "Accessory", "to", "the", "local", "network", "." ]
1862f73d495c7f25d3ed812abac4be4c1d2dee34
https://github.com/KhaosT/HAP-NodeJS/blob/1862f73d495c7f25d3ed812abac4be4c1d2dee34/lib/Advertiser.js#L21-L27
train
KhaosT/HAP-NodeJS
lib/AccessoryLoader.js
loadDirectory
function loadDirectory(dir) { // exported accessory objects loaded from this dir var accessories = []; fs.readdirSync(dir).forEach(function(file) { // "Accessories" are modules that export a single accessory. if (file.split('_').pop() === 'accessory.js') { debug('Parsing accessory: %s', file); ...
javascript
function loadDirectory(dir) { // exported accessory objects loaded from this dir var accessories = []; fs.readdirSync(dir).forEach(function(file) { // "Accessories" are modules that export a single accessory. if (file.split('_').pop() === 'accessory.js') { debug('Parsing accessory: %s', file); ...
[ "function", "loadDirectory", "(", "dir", ")", "{", "// exported accessory objects loaded from this dir", "var", "accessories", "=", "[", "]", ";", "fs", ".", "readdirSync", "(", "dir", ")", ".", "forEach", "(", "function", "(", "file", ")", "{", "// \"Accessorie...
Loads all accessories from the given folder. Handles object-literal-style accessories, "accessory factories", and new-API style modules.
[ "Loads", "all", "accessories", "from", "the", "given", "folder", ".", "Handles", "object", "-", "literal", "-", "style", "accessories", "accessory", "factories", "and", "new", "-", "API", "style", "modules", "." ]
1862f73d495c7f25d3ed812abac4be4c1d2dee34
https://github.com/KhaosT/HAP-NodeJS/blob/1862f73d495c7f25d3ed812abac4be4c1d2dee34/lib/AccessoryLoader.js#L23-L56
train
matrix-org/matrix-js-sdk
src/timeline-window.js
TimelineWindow
function TimelineWindow(client, timelineSet, opts) { opts = opts || {}; this._client = client; this._timelineSet = timelineSet; // these will be TimelineIndex objects; they delineate the 'start' and // 'end' of the window. // // _start.index is inclusive; _end.index is exclusive. this._...
javascript
function TimelineWindow(client, timelineSet, opts) { opts = opts || {}; this._client = client; this._timelineSet = timelineSet; // these will be TimelineIndex objects; they delineate the 'start' and // 'end' of the window. // // _start.index is inclusive; _end.index is exclusive. this._...
[ "function", "TimelineWindow", "(", "client", ",", "timelineSet", ",", "opts", ")", "{", "opts", "=", "opts", "||", "{", "}", ";", "this", ".", "_client", "=", "client", ";", "this", ".", "_timelineSet", "=", "timelineSet", ";", "// these will be TimelineInde...
Construct a TimelineWindow. <p>This abstracts the separate timelines in a Matrix {@link module:models/room|Room} into a single iterable thing. It keeps track of the start and endpoints of the window, which can be advanced with the help of pagination requests. <p>Before the window is useful, it must be initialised by ...
[ "Construct", "a", "TimelineWindow", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/timeline-window.js#L69-L83
train
matrix-org/matrix-js-sdk
src/timeline-window.js
function(timeline) { let eventIndex; const events = timeline.getEvents(); if (!initialEventId) { // we were looking for the live timeline: initialise to the end eventIndex = events.length; } else { for (let i = 0; i < events.length; i++) { ...
javascript
function(timeline) { let eventIndex; const events = timeline.getEvents(); if (!initialEventId) { // we were looking for the live timeline: initialise to the end eventIndex = events.length; } else { for (let i = 0; i < events.length; i++) { ...
[ "function", "(", "timeline", ")", "{", "let", "eventIndex", ";", "const", "events", "=", "timeline", ".", "getEvents", "(", ")", ";", "if", "(", "!", "initialEventId", ")", "{", "// we were looking for the live timeline: initialise to the end", "eventIndex", "=", ...
given an EventTimeline, find the event we were looking for, and initialise our fields so that the event in question is in the middle of the window.
[ "given", "an", "EventTimeline", "find", "the", "event", "we", "were", "looking", "for", "and", "initialise", "our", "fields", "so", "that", "the", "event", "in", "question", "is", "in", "the", "middle", "of", "the", "window", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/timeline-window.js#L100-L127
train
matrix-org/matrix-js-sdk
spec/integ/megolm-integ.spec.js
createOlmSession
function createOlmSession(olmAccount, recipientTestClient) { return recipientTestClient.awaitOneTimeKeyUpload().then((keys) => { const otkId = utils.keys(keys)[0]; const otk = keys[otkId]; const session = new global.Olm.Session(); session.create_outbound( olmAccount, rec...
javascript
function createOlmSession(olmAccount, recipientTestClient) { return recipientTestClient.awaitOneTimeKeyUpload().then((keys) => { const otkId = utils.keys(keys)[0]; const otk = keys[otkId]; const session = new global.Olm.Session(); session.create_outbound( olmAccount, rec...
[ "function", "createOlmSession", "(", "olmAccount", ",", "recipientTestClient", ")", "{", "return", "recipientTestClient", ".", "awaitOneTimeKeyUpload", "(", ")", ".", "then", "(", "(", "keys", ")", "=>", "{", "const", "otkId", "=", "utils", ".", "keys", "(", ...
start an Olm session with a given recipient @param {Olm.Account} olmAccount @param {TestClient} recipientTestClient @return {Promise} promise for Olm.Session
[ "start", "an", "Olm", "session", "with", "a", "given", "recipient" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/megolm-integ.spec.js#L36-L47
train
matrix-org/matrix-js-sdk
spec/integ/megolm-integ.spec.js
encryptOlmEvent
function encryptOlmEvent(opts) { expect(opts.senderKey).toBeTruthy(); expect(opts.p2pSession).toBeTruthy(); expect(opts.recipient).toBeTruthy(); const plaintext = { content: opts.plaincontent || {}, recipient: opts.recipient.userId, recipient_keys: { ed25519: opts.re...
javascript
function encryptOlmEvent(opts) { expect(opts.senderKey).toBeTruthy(); expect(opts.p2pSession).toBeTruthy(); expect(opts.recipient).toBeTruthy(); const plaintext = { content: opts.plaincontent || {}, recipient: opts.recipient.userId, recipient_keys: { ed25519: opts.re...
[ "function", "encryptOlmEvent", "(", "opts", ")", "{", "expect", "(", "opts", ".", "senderKey", ")", ".", "toBeTruthy", "(", ")", ";", "expect", "(", "opts", ".", "p2pSession", ")", ".", "toBeTruthy", "(", ")", ";", "expect", "(", "opts", ".", "recipien...
encrypt an event with olm @param {object} opts @param {string=} opts.sender @param {string} opts.senderKey @param {Olm.Session} opts.p2pSession @param {TestClient} opts.recipient @param {object=} opts.plaincontent @param {string=} opts.plaintype @return {object} event
[ "encrypt", "an", "event", "with", "olm" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/megolm-integ.spec.js#L62-L89
train
matrix-org/matrix-js-sdk
spec/integ/megolm-integ.spec.js
encryptMegolmEvent
function encryptMegolmEvent(opts) { expect(opts.senderKey).toBeTruthy(); expect(opts.groupSession).toBeTruthy(); const plaintext = opts.plaintext || {}; if (!plaintext.content) { plaintext.content = { body: '42', msgtype: "m.text", }; } if (!plaintext.typ...
javascript
function encryptMegolmEvent(opts) { expect(opts.senderKey).toBeTruthy(); expect(opts.groupSession).toBeTruthy(); const plaintext = opts.plaintext || {}; if (!plaintext.content) { plaintext.content = { body: '42', msgtype: "m.text", }; } if (!plaintext.typ...
[ "function", "encryptMegolmEvent", "(", "opts", ")", "{", "expect", "(", "opts", ".", "senderKey", ")", ".", "toBeTruthy", "(", ")", ";", "expect", "(", "opts", ".", "groupSession", ")", ".", "toBeTruthy", "(", ")", ";", "const", "plaintext", "=", "opts",...
encrypt an event with megolm @param {object} opts @param {string} opts.senderKey @param {Olm.OutboundGroupSession} opts.groupSession @param {object=} opts.plaintext @param {string=} opts.room_id @return {object} event
[ "encrypt", "an", "event", "with", "megolm" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/megolm-integ.spec.js#L102-L132
train
matrix-org/matrix-js-sdk
spec/integ/megolm-integ.spec.js
encryptGroupSessionKey
function encryptGroupSessionKey(opts) { return encryptOlmEvent({ senderKey: opts.senderKey, recipient: opts.recipient, p2pSession: opts.p2pSession, plaincontent: { algorithm: 'm.megolm.v1.aes-sha2', room_id: opts.room_id, session_id: opts.groupSess...
javascript
function encryptGroupSessionKey(opts) { return encryptOlmEvent({ senderKey: opts.senderKey, recipient: opts.recipient, p2pSession: opts.p2pSession, plaincontent: { algorithm: 'm.megolm.v1.aes-sha2', room_id: opts.room_id, session_id: opts.groupSess...
[ "function", "encryptGroupSessionKey", "(", "opts", ")", "{", "return", "encryptOlmEvent", "(", "{", "senderKey", ":", "opts", ".", "senderKey", ",", "recipient", ":", "opts", ".", "recipient", ",", "p2pSession", ":", "opts", ".", "p2pSession", ",", "plainconte...
build an encrypted room_key event to share a group session @param {object} opts @param {string} opts.senderKey @param {TestClient} opts.recipient @param {Olm.Session} opts.p2pSession @param {Olm.OutboundGroupSession} opts.groupSession @param {string=} opts.room_id @return {object} event
[ "build", "an", "encrypted", "room_key", "event", "to", "share", "a", "group", "session" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/megolm-integ.spec.js#L146-L159
train
matrix-org/matrix-js-sdk
src/store/session/webstorage.js
WebStorageSessionStore
function WebStorageSessionStore(webStore) { this.store = webStore; if (!utils.isFunction(webStore.getItem) || !utils.isFunction(webStore.setItem) || !utils.isFunction(webStore.removeItem) || !utils.isFunction(webStore.key) || typeof(webStore.length) !== 'number' ) { ...
javascript
function WebStorageSessionStore(webStore) { this.store = webStore; if (!utils.isFunction(webStore.getItem) || !utils.isFunction(webStore.setItem) || !utils.isFunction(webStore.removeItem) || !utils.isFunction(webStore.key) || typeof(webStore.length) !== 'number' ) { ...
[ "function", "WebStorageSessionStore", "(", "webStore", ")", "{", "this", ".", "store", "=", "webStore", ";", "if", "(", "!", "utils", ".", "isFunction", "(", "webStore", ".", "getItem", ")", "||", "!", "utils", ".", "isFunction", "(", "webStore", ".", "s...
Construct a web storage session store, capable of storing account keys, session keys and access tokens. @constructor @param {WebStorage} webStore A web storage implementation, e.g. 'window.localStorage' or 'window.sessionStorage' or a custom implementation. @throws if the supplied 'store' does not meet the Storage inte...
[ "Construct", "a", "web", "storage", "session", "store", "capable", "of", "storing", "account", "keys", "session", "keys", "and", "access", "tokens", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/session/webstorage.js#L38-L50
train
matrix-org/matrix-js-sdk
src/store/session/webstorage.js
function() { const prefix = keyEndToEndDevicesForUser(''); const devices = {}; for (let i = 0; i < this.store.length; ++i) { const key = this.store.key(i); const userId = key.substr(prefix.length); if (key.startsWith(prefix)) devices[userId] = getJsonItem(this...
javascript
function() { const prefix = keyEndToEndDevicesForUser(''); const devices = {}; for (let i = 0; i < this.store.length; ++i) { const key = this.store.key(i); const userId = key.substr(prefix.length); if (key.startsWith(prefix)) devices[userId] = getJsonItem(this...
[ "function", "(", ")", "{", "const", "prefix", "=", "keyEndToEndDevicesForUser", "(", "''", ")", ";", "const", "devices", "=", "{", "}", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "this", ".", "store", ".", "length", ";", "++", "i", ")"...
Retrieves the known devices for all users. @return {object} A map from user ID to map of device ID to keys for the device.
[ "Retrieves", "the", "known", "devices", "for", "all", "users", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/session/webstorage.js#L75-L84
train
matrix-org/matrix-js-sdk
src/store/session/webstorage.js
function() { const deviceKeys = getKeysWithPrefix(this.store, keyEndToEndSessions('')); const results = {}; for (const k of deviceKeys) { const unprefixedKey = k.substr(keyEndToEndSessions('').length); results[unprefixedKey] = getJsonItem(this.store, k); } ...
javascript
function() { const deviceKeys = getKeysWithPrefix(this.store, keyEndToEndSessions('')); const results = {}; for (const k of deviceKeys) { const unprefixedKey = k.substr(keyEndToEndSessions('').length); results[unprefixedKey] = getJsonItem(this.store, k); } ...
[ "function", "(", ")", "{", "const", "deviceKeys", "=", "getKeysWithPrefix", "(", "this", ".", "store", ",", "keyEndToEndSessions", "(", "''", ")", ")", ";", "const", "results", "=", "{", "}", ";", "for", "(", "const", "k", "of", "deviceKeys", ")", "{",...
Retrieve all end-to-end sessions between the logged-in user and other devices. @return {object} A map of {deviceKey -> {sessionId -> session pickle}}
[ "Retrieve", "all", "end", "-", "to", "-", "end", "sessions", "between", "the", "logged", "-", "in", "user", "and", "other", "devices", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/session/webstorage.js#L123-L131
train
matrix-org/matrix-js-sdk
src/store/session/webstorage.js
function() { const prefix = E2E_PREFIX + 'inboundgroupsessions/'; const result = []; for (let i = 0; i < this.store.length; i++) { const key = this.store.key(i); if (!key.startsWith(prefix)) { continue; } // we can't use split, as t...
javascript
function() { const prefix = E2E_PREFIX + 'inboundgroupsessions/'; const result = []; for (let i = 0; i < this.store.length; i++) { const key = this.store.key(i); if (!key.startsWith(prefix)) { continue; } // we can't use split, as t...
[ "function", "(", ")", "{", "const", "prefix", "=", "E2E_PREFIX", "+", "'inboundgroupsessions/'", ";", "const", "result", "=", "[", "]", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "this", ".", "store", ".", "length", ";", "i", "++", ")", ...
Retrieve a list of all known inbound group sessions @return {{senderKey: string, sessionId: string}}
[ "Retrieve", "a", "list", "of", "all", "known", "inbound", "group", "sessions" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/session/webstorage.js#L146-L165
train
matrix-org/matrix-js-sdk
src/store/session/webstorage.js
function() { const roomKeys = getKeysWithPrefix(this.store, keyEndToEndRoom('')); const results = {}; for (const k of roomKeys) { const unprefixedKey = k.substr(keyEndToEndRoom('').length); results[unprefixedKey] = getJsonItem(this.store, k); } return resu...
javascript
function() { const roomKeys = getKeysWithPrefix(this.store, keyEndToEndRoom('')); const results = {}; for (const k of roomKeys) { const unprefixedKey = k.substr(keyEndToEndRoom('').length); results[unprefixedKey] = getJsonItem(this.store, k); } return resu...
[ "function", "(", ")", "{", "const", "roomKeys", "=", "getKeysWithPrefix", "(", "this", ".", "store", ",", "keyEndToEndRoom", "(", "''", ")", ")", ";", "const", "results", "=", "{", "}", ";", "for", "(", "const", "k", "of", "roomKeys", ")", "{", "cons...
Get the end-to-end state for all rooms @return {object} roomId -> object with the end-to-end info for the room.
[ "Get", "the", "end", "-", "to", "-", "end", "state", "for", "all", "rooms" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/session/webstorage.js#L180-L188
train
matrix-org/matrix-js-sdk
src/store/indexeddb.js
IndexedDBStore
function IndexedDBStore(opts) { MemoryStore.call(this, opts); if (!opts.indexedDB) { throw new Error('Missing required option: indexedDB'); } if (opts.workerScript) { // try & find a webworker-compatible API let workerApi = opts.workerApi; if (!workerApi) { ...
javascript
function IndexedDBStore(opts) { MemoryStore.call(this, opts); if (!opts.indexedDB) { throw new Error('Missing required option: indexedDB'); } if (opts.workerScript) { // try & find a webworker-compatible API let workerApi = opts.workerApi; if (!workerApi) { ...
[ "function", "IndexedDBStore", "(", "opts", ")", "{", "MemoryStore", ".", "call", "(", "this", ",", "opts", ")", ";", "if", "(", "!", "opts", ".", "indexedDB", ")", "{", "throw", "new", "Error", "(", "'Missing required option: indexedDB'", ")", ";", "}", ...
once every 5 minutes Construct a new Indexed Database store, which extends MemoryStore. This store functions like a MemoryStore except it periodically persists the contents of the store to an IndexedDB backend. All data is still kept in-memory but can be loaded from disk by calling <code>startup()</code>. This can m...
[ "once", "every", "5", "minutes", "Construct", "a", "new", "Indexed", "Database", "store", "which", "extends", "MemoryStore", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/indexeddb.js#L84-L114
train
matrix-org/matrix-js-sdk
src/store/indexeddb.js
degradable
function degradable(func, fallback) { return async function(...args) { try { return await func.call(this, ...args); } catch (e) { console.error("IndexedDBStore failure, degrading to MemoryStore", e); this.emit("degraded", e); try { // W...
javascript
function degradable(func, fallback) { return async function(...args) { try { return await func.call(this, ...args); } catch (e) { console.error("IndexedDBStore failure, degrading to MemoryStore", e); this.emit("degraded", e); try { // W...
[ "function", "degradable", "(", "func", ",", "fallback", ")", "{", "return", "async", "function", "(", "...", "args", ")", "{", "try", "{", "return", "await", "func", ".", "call", "(", "this", ",", "...", "args", ")", ";", "}", "catch", "(", "e", ")...
All member functions of `IndexedDBStore` that access the backend use this wrapper to watch for failures after initial store startup, including `QuotaExceededError` as free disk space changes, etc. When IndexedDB fails via any of these paths, we degrade this back to a `MemoryStore` in place so that the current operatio...
[ "All", "member", "functions", "of", "IndexedDBStore", "that", "access", "the", "backend", "use", "this", "wrapper", "to", "watch", "for", "failures", "after", "initial", "store", "startup", "including", "QuotaExceededError", "as", "free", "disk", "space", "changes...
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/indexeddb.js#L288-L319
train
matrix-org/matrix-js-sdk
src/base-apis.js
MatrixBaseApis
function MatrixBaseApis(opts) { utils.checkObjectHasKeys(opts, ["baseUrl", "request"]); this.baseUrl = opts.baseUrl; this.idBaseUrl = opts.idBaseUrl; const httpOpts = { baseUrl: opts.baseUrl, idBaseUrl: opts.idBaseUrl, accessToken: opts.accessToken, request: opts.reques...
javascript
function MatrixBaseApis(opts) { utils.checkObjectHasKeys(opts, ["baseUrl", "request"]); this.baseUrl = opts.baseUrl; this.idBaseUrl = opts.idBaseUrl; const httpOpts = { baseUrl: opts.baseUrl, idBaseUrl: opts.idBaseUrl, accessToken: opts.accessToken, request: opts.reques...
[ "function", "MatrixBaseApis", "(", "opts", ")", "{", "utils", ".", "checkObjectHasKeys", "(", "opts", ",", "[", "\"baseUrl\"", ",", "\"request\"", "]", ")", ";", "this", ".", "baseUrl", "=", "opts", ".", "baseUrl", ";", "this", ".", "idBaseUrl", "=", "op...
Low-level wrappers for the Matrix APIs @constructor @param {Object} opts Configuration options @param {string} opts.baseUrl Required. The base URL to the client-server HTTP API. @param {string} opts.idBaseUrl Optional. The base identity server URL for identity server requests. @param {Function} opts.request Requir...
[ "Low", "-", "level", "wrappers", "for", "the", "Matrix", "APIs" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/base-apis.js#L60-L80
train
matrix-org/matrix-js-sdk
src/realtime-callbacks.js
_scheduleRealCallback
function _scheduleRealCallback() { if (_realCallbackKey) { global.clearTimeout(_realCallbackKey); } const first = _callbackList[0]; if (!first) { debuglog("_scheduleRealCallback: no more callbacks, not rescheduling"); return; } const now = _now(); const delayMs = M...
javascript
function _scheduleRealCallback() { if (_realCallbackKey) { global.clearTimeout(_realCallbackKey); } const first = _callbackList[0]; if (!first) { debuglog("_scheduleRealCallback: no more callbacks, not rescheduling"); return; } const now = _now(); const delayMs = M...
[ "function", "_scheduleRealCallback", "(", ")", "{", "if", "(", "_realCallbackKey", ")", "{", "global", ".", "clearTimeout", "(", "_realCallbackKey", ")", ";", "}", "const", "first", "=", "_callbackList", "[", "0", "]", ";", "if", "(", "!", "first", ")", ...
use the real global.setTimeout to schedule a callback to _runCallbacks.
[ "use", "the", "real", "global", ".", "setTimeout", "to", "schedule", "a", "callback", "to", "_runCallbacks", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/realtime-callbacks.js#L127-L144
train
matrix-org/matrix-js-sdk
src/models/room.js
Room
function Room(roomId, client, myUserId, opts) { opts = opts || {}; opts.pendingEventOrdering = opts.pendingEventOrdering || "chronological"; this.reEmitter = new ReEmitter(this); if (["chronological", "detached"].indexOf(opts.pendingEventOrdering) === -1) { throw new Error( "opts.p...
javascript
function Room(roomId, client, myUserId, opts) { opts = opts || {}; opts.pendingEventOrdering = opts.pendingEventOrdering || "chronological"; this.reEmitter = new ReEmitter(this); if (["chronological", "detached"].indexOf(opts.pendingEventOrdering) === -1) { throw new Error( "opts.p...
[ "function", "Room", "(", "roomId", ",", "client", ",", "myUserId", ",", "opts", ")", "{", "opts", "=", "opts", "||", "{", "}", ";", "opts", ".", "pendingEventOrdering", "=", "opts", ".", "pendingEventOrdering", "||", "\"chronological\"", ";", "this", ".", ...
Construct a new Room. <p>For a room, we store an ordered sequence of timelines, which may or may not be continuous. Each timeline lists a series of events, as well as tracking the room state at the start and the end of the timeline. It also tracks forward and backward pagination tokens, as well as containing links to ...
[ "Construct", "a", "new", "Room", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/room.js#L118-L198
train
matrix-org/matrix-js-sdk
src/models/room.js
calculateRoomName
function calculateRoomName(room, userId, ignoreRoomNameEvent) { if (!ignoreRoomNameEvent) { // check for an alias, if any. for now, assume first alias is the // official one. const mRoomName = room.currentState.getStateEvents("m.room.name", ""); if (mRoomName && mRoomName.getContent(...
javascript
function calculateRoomName(room, userId, ignoreRoomNameEvent) { if (!ignoreRoomNameEvent) { // check for an alias, if any. for now, assume first alias is the // official one. const mRoomName = room.currentState.getStateEvents("m.room.name", ""); if (mRoomName && mRoomName.getContent(...
[ "function", "calculateRoomName", "(", "room", ",", "userId", ",", "ignoreRoomNameEvent", ")", "{", "if", "(", "!", "ignoreRoomNameEvent", ")", "{", "// check for an alias, if any. for now, assume first alias is the", "// official one.", "const", "mRoomName", "=", "room", ...
This is an internal method. Calculates the name of the room from the current room state. @param {Room} room The matrix room. @param {string} userId The client's user ID. Used to filter room members correctly. @param {bool} ignoreRoomNameEvent Return the implicit room name that we'd see if there was no m.room.name event...
[ "This", "is", "an", "internal", "method", ".", "Calculates", "the", "name", "of", "the", "room", "from", "the", "current", "room", "state", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/room.js#L1658-L1741
train
matrix-org/matrix-js-sdk
src/interactive-auth.js
InteractiveAuth
function InteractiveAuth(opts) { this._matrixClient = opts.matrixClient; this._data = opts.authData || {}; this._requestCallback = opts.doRequest; // startAuthStage included for backwards compat this._stateUpdatedCallback = opts.stateUpdated || opts.startAuthStage; this._completionDeferred = nul...
javascript
function InteractiveAuth(opts) { this._matrixClient = opts.matrixClient; this._data = opts.authData || {}; this._requestCallback = opts.doRequest; // startAuthStage included for backwards compat this._stateUpdatedCallback = opts.stateUpdated || opts.startAuthStage; this._completionDeferred = nul...
[ "function", "InteractiveAuth", "(", "opts", ")", "{", "this", ".", "_matrixClient", "=", "opts", ".", "matrixClient", ";", "this", ".", "_data", "=", "opts", ".", "authData", "||", "{", "}", ";", "this", ".", "_requestCallback", "=", "opts", ".", "doRequ...
Abstracts the logic used to drive the interactive auth process. <p>Components implementing an interactive auth flow should instantiate one of these, passing in the necessary callbacks to the constructor. They should then call attemptAuth, which will return a promise which will resolve or reject when the interactive-au...
[ "Abstracts", "the", "logic", "used", "to", "drive", "the", "interactive", "auth", "process", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/interactive-auth.js#L92-L107
train
matrix-org/matrix-js-sdk
src/interactive-auth.js
function() { this._completionDeferred = Promise.defer(); // wrap in a promise so that if _startNextAuthStage // throws, it rejects the promise in a consistent way return Promise.resolve().then(() => { // if we have no flows, try a request (we'll have // just a se...
javascript
function() { this._completionDeferred = Promise.defer(); // wrap in a promise so that if _startNextAuthStage // throws, it rejects the promise in a consistent way return Promise.resolve().then(() => { // if we have no flows, try a request (we'll have // just a se...
[ "function", "(", ")", "{", "this", ".", "_completionDeferred", "=", "Promise", ".", "defer", "(", ")", ";", "// wrap in a promise so that if _startNextAuthStage", "// throws, it rejects the promise in a consistent way", "return", "Promise", ".", "resolve", "(", ")", ".", ...
begin the authentication process. @return {module:client.Promise} which resolves to the response on success, or rejects with the error on failure. Rejects with NoAuthFlowFoundError if no suitable authentication flow can be found
[ "begin", "the", "authentication", "process", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/interactive-auth.js#L117-L132
train
matrix-org/matrix-js-sdk
src/interactive-auth.js
function() { if (!this._data.session) return; let authDict = {}; if (this._currentStage == EMAIL_STAGE_TYPE) { // The email can be validated out-of-band, but we need to provide the // creds so the HS can go & check it. if (this._emailSid) { co...
javascript
function() { if (!this._data.session) return; let authDict = {}; if (this._currentStage == EMAIL_STAGE_TYPE) { // The email can be validated out-of-band, but we need to provide the // creds so the HS can go & check it. if (this._emailSid) { co...
[ "function", "(", ")", "{", "if", "(", "!", "this", ".", "_data", ".", "session", ")", "return", ";", "let", "authDict", "=", "{", "}", ";", "if", "(", "this", ".", "_currentStage", "==", "EMAIL_STAGE_TYPE", ")", "{", "// The email can be validated out-of-b...
Poll to check if the auth session or current stage has been completed out-of-band. If so, the attemptAuth promise will be resolved.
[ "Poll", "to", "check", "if", "the", "auth", "session", "or", "current", "stage", "has", "been", "completed", "out", "-", "of", "-", "band", ".", "If", "so", "the", "attemptAuth", "promise", "will", "be", "resolved", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/interactive-auth.js#L139-L162
train
matrix-org/matrix-js-sdk
src/interactive-auth.js
function(loginType) { let params = {}; if (this._data && this._data.params) { params = this._data.params; } return params[loginType]; }
javascript
function(loginType) { let params = {}; if (this._data && this._data.params) { params = this._data.params; } return params[loginType]; }
[ "function", "(", "loginType", ")", "{", "let", "params", "=", "{", "}", ";", "if", "(", "this", ".", "_data", "&&", "this", ".", "_data", ".", "params", ")", "{", "params", "=", "this", ".", "_data", ".", "params", ";", "}", "return", "params", "...
get the server params for a given stage @param {string} loginType login type for the stage @return {object?} any parameters from the server for this stage
[ "get", "the", "server", "params", "for", "a", "given", "stage" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/interactive-auth.js#L189-L195
train
matrix-org/matrix-js-sdk
src/interactive-auth.js
function(auth, background) { const self = this; // hackery to make sure that synchronous exceptions end up in the catch // handler (without the additional event loop entailed by q.fcall or an // extra Promise.resolve().then) let prom; try { prom = this._reque...
javascript
function(auth, background) { const self = this; // hackery to make sure that synchronous exceptions end up in the catch // handler (without the additional event loop entailed by q.fcall or an // extra Promise.resolve().then) let prom; try { prom = this._reque...
[ "function", "(", "auth", ",", "background", ")", "{", "const", "self", "=", "this", ";", "// hackery to make sure that synchronous exceptions end up in the catch", "// handler (without the additional event loop entailed by q.fcall or an", "// extra Promise.resolve().then)", "let", "p...
Fire off a request, and either resolve the promise, or call startAuthStage. @private @param {object?} auth new auth dict, including session id @param {bool?} background If true, this request is a background poll, so it failing will not result in the attemptAuth promise being rejected. This can be set to true for reque...
[ "Fire", "off", "a", "request", "and", "either", "resolve", "the", "promise", "or", "call", "startAuthStage", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/interactive-auth.js#L256-L308
train
matrix-org/matrix-js-sdk
src/interactive-auth.js
function() { const nextStage = this._chooseStage(); if (!nextStage) { throw new Error("No incomplete flows from the server"); } this._currentStage = nextStage; if (nextStage == 'm.login.dummy') { this.submitAuthDict({ type: 'm.login.dummy'...
javascript
function() { const nextStage = this._chooseStage(); if (!nextStage) { throw new Error("No incomplete flows from the server"); } this._currentStage = nextStage; if (nextStage == 'm.login.dummy') { this.submitAuthDict({ type: 'm.login.dummy'...
[ "function", "(", ")", "{", "const", "nextStage", "=", "this", ".", "_chooseStage", "(", ")", ";", "if", "(", "!", "nextStage", ")", "{", "throw", "new", "Error", "(", "\"No incomplete flows from the server\"", ")", ";", "}", "this", ".", "_currentStage", "...
Pick the next stage and call the callback @private @throws {NoAuthFlowFoundError} If no suitable authentication flow can be found
[ "Pick", "the", "next", "stage", "and", "call", "the", "callback" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/interactive-auth.js#L316-L343
train
matrix-org/matrix-js-sdk
src/interactive-auth.js
function() { const flow = this._chooseFlow(); console.log("Active flow => %s", JSON.stringify(flow)); const nextStage = this._firstUncompletedStage(flow); console.log("Next stage: %s", nextStage); return nextStage; }
javascript
function() { const flow = this._chooseFlow(); console.log("Active flow => %s", JSON.stringify(flow)); const nextStage = this._firstUncompletedStage(flow); console.log("Next stage: %s", nextStage); return nextStage; }
[ "function", "(", ")", "{", "const", "flow", "=", "this", ".", "_chooseFlow", "(", ")", ";", "console", ".", "log", "(", "\"Active flow => %s\"", ",", "JSON", ".", "stringify", "(", "flow", ")", ")", ";", "const", "nextStage", "=", "this", ".", "_firstU...
Pick the next auth stage @private @return {string?} login type @throws {NoAuthFlowFoundError} If no suitable authentication flow can be found
[ "Pick", "the", "next", "auth", "stage" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/interactive-auth.js#L352-L358
train
matrix-org/matrix-js-sdk
src/interactive-auth.js
function() { const flows = this._data.flows || []; // we've been given an email or we've already done an email part const haveEmail = Boolean(this._inputs.emailAddress) || Boolean(this._emailSid); const haveMsisdn = ( Boolean(this._inputs.phoneCountry) && Boolean...
javascript
function() { const flows = this._data.flows || []; // we've been given an email or we've already done an email part const haveEmail = Boolean(this._inputs.emailAddress) || Boolean(this._emailSid); const haveMsisdn = ( Boolean(this._inputs.phoneCountry) && Boolean...
[ "function", "(", ")", "{", "const", "flows", "=", "this", ".", "_data", ".", "flows", "||", "[", "]", ";", "// we've been given an email or we've already done an email part", "const", "haveEmail", "=", "Boolean", "(", "this", ".", "_inputs", ".", "emailAddress", ...
Pick one of the flows from the returned list If a flow using all of the inputs is found, it will be returned, otherwise, null will be returned. Only flows using all given inputs are chosen because it is likley to be surprising if the user provides a credential and it is not used. For example, for registration, this co...
[ "Pick", "one", "of", "the", "flows", "from", "the", "returned", "list", "If", "a", "flow", "using", "all", "of", "the", "inputs", "is", "found", "it", "will", "be", "returned", "otherwise", "null", "will", "be", "returned", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/interactive-auth.js#L375-L409
train
matrix-org/matrix-js-sdk
src/interactive-auth.js
function(flow) { const completed = (this._data || {}).completed || []; for (let i = 0; i < flow.stages.length; ++i) { const stageType = flow.stages[i]; if (completed.indexOf(stageType) === -1) { return stageType; } } }
javascript
function(flow) { const completed = (this._data || {}).completed || []; for (let i = 0; i < flow.stages.length; ++i) { const stageType = flow.stages[i]; if (completed.indexOf(stageType) === -1) { return stageType; } } }
[ "function", "(", "flow", ")", "{", "const", "completed", "=", "(", "this", ".", "_data", "||", "{", "}", ")", ".", "completed", "||", "[", "]", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "flow", ".", "stages", ".", "length", ";", "...
Get the first uncompleted stage in the given flow @private @param {object} flow @return {string} login type
[ "Get", "the", "first", "uncompleted", "stage", "in", "the", "given", "flow" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/interactive-auth.js#L418-L426
train
matrix-org/matrix-js-sdk
src/models/room-member.js
RoomMember
function RoomMember(roomId, userId) { this.roomId = roomId; this.userId = userId; this.typing = false; this.name = userId; this.rawDisplayName = userId; this.powerLevel = 0; this.powerLevelNorm = 0; this.user = null; this.membership = null; this.events = { member: null, ...
javascript
function RoomMember(roomId, userId) { this.roomId = roomId; this.userId = userId; this.typing = false; this.name = userId; this.rawDisplayName = userId; this.powerLevel = 0; this.powerLevelNorm = 0; this.user = null; this.membership = null; this.events = { member: null, ...
[ "function", "RoomMember", "(", "roomId", ",", "userId", ")", "{", "this", ".", "roomId", "=", "roomId", ";", "this", ".", "userId", "=", "userId", ";", "this", ".", "typing", "=", "false", ";", "this", ".", "name", "=", "userId", ";", "this", ".", ...
Construct a new room member. @constructor @alias module:models/room-member @param {string} roomId The room ID of the member. @param {string} userId The user ID of the member. @prop {string} roomId The room ID for this member. @prop {string} userId The user ID of this member. @prop {boolean} typing True if the room me...
[ "Construct", "a", "new", "room", "member", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/room-member.js#L48-L63
train
matrix-org/matrix-js-sdk
src/models/room-state.js
RoomState
function RoomState(roomId, oobMemberFlags = undefined) { this.roomId = roomId; this.members = { // userId: RoomMember }; this.events = { // eventType: { stateKey: MatrixEvent } }; this.paginationToken = null; this._sentinels = { // userId: RoomMember }; this....
javascript
function RoomState(roomId, oobMemberFlags = undefined) { this.roomId = roomId; this.members = { // userId: RoomMember }; this.events = { // eventType: { stateKey: MatrixEvent } }; this.paginationToken = null; this._sentinels = { // userId: RoomMember }; this....
[ "function", "RoomState", "(", "roomId", ",", "oobMemberFlags", "=", "undefined", ")", "{", "this", ".", "roomId", "=", "roomId", ";", "this", ".", "members", "=", "{", "// userId: RoomMember", "}", ";", "this", ".", "events", "=", "{", "// eventType: { state...
Construct room state. Room State represents the state of the room at a given point. It can be mutated by adding state events to it. There are two types of room member associated with a state event: normal member objects (accessed via getMember/getMembers) which mutate with the state to represent the current state of t...
[ "Construct", "room", "state", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/room-state.js#L64-L100
train
matrix-org/matrix-js-sdk
src/crypto/algorithms/olm.js
OlmEncryption
function OlmEncryption(params) { base.EncryptionAlgorithm.call(this, params); this._sessionPrepared = false; this._prepPromise = null; }
javascript
function OlmEncryption(params) { base.EncryptionAlgorithm.call(this, params); this._sessionPrepared = false; this._prepPromise = null; }
[ "function", "OlmEncryption", "(", "params", ")", "{", "base", ".", "EncryptionAlgorithm", ".", "call", "(", "this", ",", "params", ")", ";", "this", ".", "_sessionPrepared", "=", "false", ";", "this", ".", "_prepPromise", "=", "null", ";", "}" ]
Olm encryption implementation @constructor @extends {module:crypto/algorithms/base.EncryptionAlgorithm} @param {object} params parameters, as per {@link module:crypto/algorithms/base.EncryptionAlgorithm}
[ "Olm", "encryption", "implementation" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/crypto/algorithms/olm.js#L43-L47
train
matrix-org/matrix-js-sdk
spec/integ/matrix-client-crypto.spec.js
expectAliQueryKeys
function expectAliQueryKeys() { // can't query keys before bob has uploaded them expect(bobTestClient.deviceKeys).toBeTruthy(); const bobKeys = {}; bobKeys[bobDeviceId] = bobTestClient.deviceKeys; aliTestClient.httpBackend.when("POST", "/keys/query") .respond(200, function(path, content...
javascript
function expectAliQueryKeys() { // can't query keys before bob has uploaded them expect(bobTestClient.deviceKeys).toBeTruthy(); const bobKeys = {}; bobKeys[bobDeviceId] = bobTestClient.deviceKeys; aliTestClient.httpBackend.when("POST", "/keys/query") .respond(200, function(path, content...
[ "function", "expectAliQueryKeys", "(", ")", "{", "// can't query keys before bob has uploaded them", "expect", "(", "bobTestClient", ".", "deviceKeys", ")", ".", "toBeTruthy", "(", ")", ";", "const", "bobKeys", "=", "{", "}", ";", "bobKeys", "[", "bobDeviceId", "]...
Set an expectation that ali will query bobs keys; then flush the http request. @return {promise} resolves once the http request has completed.
[ "Set", "an", "expectation", "that", "ali", "will", "query", "bobs", "keys", ";", "then", "flush", "the", "http", "request", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/matrix-client-crypto.spec.js#L67-L85
train
matrix-org/matrix-js-sdk
spec/integ/matrix-client-crypto.spec.js
expectBobQueryKeys
function expectBobQueryKeys() { // can't query keys before ali has uploaded them expect(aliTestClient.deviceKeys).toBeTruthy(); const aliKeys = {}; aliKeys[aliDeviceId] = aliTestClient.deviceKeys; console.log("query result will be", aliKeys); bobTestClient.httpBackend.when( "POST", "/k...
javascript
function expectBobQueryKeys() { // can't query keys before ali has uploaded them expect(aliTestClient.deviceKeys).toBeTruthy(); const aliKeys = {}; aliKeys[aliDeviceId] = aliTestClient.deviceKeys; console.log("query result will be", aliKeys); bobTestClient.httpBackend.when( "POST", "/k...
[ "function", "expectBobQueryKeys", "(", ")", "{", "// can't query keys before ali has uploaded them", "expect", "(", "aliTestClient", ".", "deviceKeys", ")", ".", "toBeTruthy", "(", ")", ";", "const", "aliKeys", "=", "{", "}", ";", "aliKeys", "[", "aliDeviceId", "]...
Set an expectation that bob will query alis keys; then flush the http request. @return {promise} which resolves once the http request has completed.
[ "Set", "an", "expectation", "that", "bob", "will", "query", "alis", "keys", ";", "then", "flush", "the", "http", "request", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/matrix-client-crypto.spec.js#L92-L113
train
matrix-org/matrix-js-sdk
spec/integ/matrix-client-crypto.spec.js
expectAliClaimKeys
function expectAliClaimKeys() { return bobTestClient.awaitOneTimeKeyUpload().then((keys) => { aliTestClient.httpBackend.when( "POST", "/keys/claim", ).respond(200, function(path, content) { const claimType = content.one_time_keys[bobUserId][bobDeviceId]; expect(cl...
javascript
function expectAliClaimKeys() { return bobTestClient.awaitOneTimeKeyUpload().then((keys) => { aliTestClient.httpBackend.when( "POST", "/keys/claim", ).respond(200, function(path, content) { const claimType = content.one_time_keys[bobUserId][bobDeviceId]; expect(cl...
[ "function", "expectAliClaimKeys", "(", ")", "{", "return", "bobTestClient", ".", "awaitOneTimeKeyUpload", "(", ")", ".", "then", "(", "(", "keys", ")", "=>", "{", "aliTestClient", ".", "httpBackend", ".", "when", "(", "\"POST\"", ",", "\"/keys/claim\"", ",", ...
Set an expectation that ali will claim one of bob's keys; then flush the http request. @return {promise} resolves once the http request has completed.
[ "Set", "an", "expectation", "that", "ali", "will", "claim", "one", "of", "bob", "s", "keys", ";", "then", "flush", "the", "http", "request", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/matrix-client-crypto.spec.js#L120-L149
train
matrix-org/matrix-js-sdk
spec/integ/matrix-client-crypto.spec.js
aliSendsFirstMessage
function aliSendsFirstMessage() { return Promise.all([ sendMessage(aliTestClient.client), expectAliQueryKeys() .then(expectAliClaimKeys) .then(expectAliSendMessageRequest), ]).spread(function(_, ciphertext) { return ciphertext; }); }
javascript
function aliSendsFirstMessage() { return Promise.all([ sendMessage(aliTestClient.client), expectAliQueryKeys() .then(expectAliClaimKeys) .then(expectAliSendMessageRequest), ]).spread(function(_, ciphertext) { return ciphertext; }); }
[ "function", "aliSendsFirstMessage", "(", ")", "{", "return", "Promise", ".", "all", "(", "[", "sendMessage", "(", "aliTestClient", ".", "client", ")", ",", "expectAliQueryKeys", "(", ")", ".", "then", "(", "expectAliClaimKeys", ")", ".", "then", "(", "expect...
Ali sends a message, first claiming e2e keys. Set the expectations and check the results. @return {promise} which resolves to the ciphertext for Bob's device.
[ "Ali", "sends", "a", "message", "first", "claiming", "e2e", "keys", ".", "Set", "the", "expectations", "and", "check", "the", "results", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/matrix-client-crypto.spec.js#L200-L209
train
matrix-org/matrix-js-sdk
spec/integ/matrix-client-crypto.spec.js
aliSendsMessage
function aliSendsMessage() { return Promise.all([ sendMessage(aliTestClient.client), expectAliSendMessageRequest(), ]).spread(function(_, ciphertext) { return ciphertext; }); }
javascript
function aliSendsMessage() { return Promise.all([ sendMessage(aliTestClient.client), expectAliSendMessageRequest(), ]).spread(function(_, ciphertext) { return ciphertext; }); }
[ "function", "aliSendsMessage", "(", ")", "{", "return", "Promise", ".", "all", "(", "[", "sendMessage", "(", "aliTestClient", ".", "client", ")", ",", "expectAliSendMessageRequest", "(", ")", ",", "]", ")", ".", "spread", "(", "function", "(", "_", ",", ...
Ali sends a message without first claiming e2e keys. Set the expectations and check the results. @return {promise} which resolves to the ciphertext for Bob's device.
[ "Ali", "sends", "a", "message", "without", "first", "claiming", "e2e", "keys", ".", "Set", "the", "expectations", "and", "check", "the", "results", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/matrix-client-crypto.spec.js#L217-L224
train
matrix-org/matrix-js-sdk
spec/integ/matrix-client-crypto.spec.js
expectAliSendMessageRequest
function expectAliSendMessageRequest() { return expectSendMessageRequest(aliTestClient.httpBackend).then(function(content) { aliMessages.push(content); expect(utils.keys(content.ciphertext)).toEqual([bobTestClient.getDeviceKey()]); const ciphertext = content.ciphertext[bobTestClient.getDevic...
javascript
function expectAliSendMessageRequest() { return expectSendMessageRequest(aliTestClient.httpBackend).then(function(content) { aliMessages.push(content); expect(utils.keys(content.ciphertext)).toEqual([bobTestClient.getDeviceKey()]); const ciphertext = content.ciphertext[bobTestClient.getDevic...
[ "function", "expectAliSendMessageRequest", "(", ")", "{", "return", "expectSendMessageRequest", "(", "aliTestClient", ".", "httpBackend", ")", ".", "then", "(", "function", "(", "content", ")", "{", "aliMessages", ".", "push", "(", "content", ")", ";", "expect",...
Set an expectation that Ali will send a message, and flush the request @return {promise} which resolves to the ciphertext for Bob's device.
[ "Set", "an", "expectation", "that", "Ali", "will", "send", "a", "message", "and", "flush", "the", "request" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/matrix-client-crypto.spec.js#L247-L255
train
matrix-org/matrix-js-sdk
spec/integ/matrix-client-crypto.spec.js
expectBobSendMessageRequest
function expectBobSendMessageRequest() { return expectSendMessageRequest(bobTestClient.httpBackend).then(function(content) { bobMessages.push(content); const aliKeyId = "curve25519:" + aliDeviceId; const aliDeviceCurve25519Key = aliTestClient.deviceKeys.keys[aliKeyId]; expect(utils.k...
javascript
function expectBobSendMessageRequest() { return expectSendMessageRequest(bobTestClient.httpBackend).then(function(content) { bobMessages.push(content); const aliKeyId = "curve25519:" + aliDeviceId; const aliDeviceCurve25519Key = aliTestClient.deviceKeys.keys[aliKeyId]; expect(utils.k...
[ "function", "expectBobSendMessageRequest", "(", ")", "{", "return", "expectSendMessageRequest", "(", "bobTestClient", ".", "httpBackend", ")", ".", "then", "(", "function", "(", "content", ")", "{", "bobMessages", ".", "push", "(", "content", ")", ";", "const", ...
Set an expectation that Bob will send a message, and flush the request @return {promise} which resolves to the ciphertext for Bob's device.
[ "Set", "an", "expectation", "that", "Bob", "will", "send", "a", "message", "and", "flush", "the", "request" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/matrix-client-crypto.spec.js#L262-L272
train
matrix-org/matrix-js-sdk
src/crypto/OlmDevice.js
OlmDevice
function OlmDevice(cryptoStore) { this._cryptoStore = cryptoStore; this._pickleKey = "DEFAULT_KEY"; // don't know these until we load the account from storage in init() this.deviceCurve25519Key = null; this.deviceEd25519Key = null; this._maxOneTimeKeys = null; // we don't bother stashing o...
javascript
function OlmDevice(cryptoStore) { this._cryptoStore = cryptoStore; this._pickleKey = "DEFAULT_KEY"; // don't know these until we load the account from storage in init() this.deviceCurve25519Key = null; this.deviceEd25519Key = null; this._maxOneTimeKeys = null; // we don't bother stashing o...
[ "function", "OlmDevice", "(", "cryptoStore", ")", "{", "this", ".", "_cryptoStore", "=", "cryptoStore", ";", "this", ".", "_pickleKey", "=", "\"DEFAULT_KEY\"", ";", "// don't know these until we load the account from storage in init()", "this", ".", "deviceCurve25519Key", ...
The type of object we use for importing and exporting megolm session data. @typedef {Object} module:crypto/OlmDevice.MegolmSessionData @property {String} sender_key Sender's Curve25519 device key @property {String[]} forwarding_curve25519_key_chain Devices which forwarded this session to us (normally empty). @propert...
[ "The", "type", "of", "object", "we", "use", "for", "importing", "and", "exporting", "megolm", "session", "data", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/crypto/OlmDevice.js#L72-L106
train
matrix-org/matrix-js-sdk
src/crypto/algorithms/megolm.js
MegolmEncryption
function MegolmEncryption(params) { base.EncryptionAlgorithm.call(this, params); // the most recent attempt to set up a session. This is used to serialise // the session setups, so that we have a race-free view of which session we // are using, and which devices we have shared the keys with. It resolve...
javascript
function MegolmEncryption(params) { base.EncryptionAlgorithm.call(this, params); // the most recent attempt to set up a session. This is used to serialise // the session setups, so that we have a race-free view of which session we // are using, and which devices we have shared the keys with. It resolve...
[ "function", "MegolmEncryption", "(", "params", ")", "{", "base", ".", "EncryptionAlgorithm", ".", "call", "(", "this", ",", "params", ")", ";", "// the most recent attempt to set up a session. This is used to serialise", "// the session setups, so that we have a race-free view of...
Megolm encryption implementation @constructor @extends {module:crypto/algorithms/base.EncryptionAlgorithm} @param {object} params parameters, as per {@link module:crypto/algorithms/base.EncryptionAlgorithm}
[ "Megolm", "encryption", "implementation" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/crypto/algorithms/megolm.js#L137-L163
train
matrix-org/matrix-js-sdk
src/models/group.js
Group
function Group(groupId) { this.groupId = groupId; this.name = null; this.avatarUrl = null; this.myMembership = null; this.inviter = null; }
javascript
function Group(groupId) { this.groupId = groupId; this.name = null; this.avatarUrl = null; this.myMembership = null; this.inviter = null; }
[ "function", "Group", "(", "groupId", ")", "{", "this", ".", "groupId", "=", "groupId", ";", "this", ".", "name", "=", "null", ";", "this", ".", "avatarUrl", "=", "null", ";", "this", ".", "myMembership", "=", "null", ";", "this", ".", "inviter", "=",...
Construct a new Group. @param {string} groupId The ID of this group. @prop {string} groupId The ID of this group. @prop {string} name The human-readable display name for this group. @prop {string} avatarUrl The mxc URL for this group's avatar. @prop {string} myMembership The logged in user's membership of this group ...
[ "Construct", "a", "new", "Group", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/group.js#L37-L43
train
matrix-org/matrix-js-sdk
src/models/user.js
User
function User(userId) { this.userId = userId; this.presence = "offline"; this.presenceStatusMsg = null; this._unstable_statusMessage = ""; this.displayName = userId; this.rawDisplayName = userId; this.avatarUrl = null; this.lastActiveAgo = 0; this.lastPresenceTs = 0; this.current...
javascript
function User(userId) { this.userId = userId; this.presence = "offline"; this.presenceStatusMsg = null; this._unstable_statusMessage = ""; this.displayName = userId; this.rawDisplayName = userId; this.avatarUrl = null; this.lastActiveAgo = 0; this.lastPresenceTs = 0; this.current...
[ "function", "User", "(", "userId", ")", "{", "this", ".", "userId", "=", "userId", ";", "this", ".", "presence", "=", "\"offline\"", ";", "this", ".", "presenceStatusMsg", "=", "null", ";", "this", ".", "_unstable_statusMessage", "=", "\"\"", ";", "this", ...
Construct a new User. A User must have an ID and can optionally have extra information associated with it. @constructor @param {string} userId Required. The ID of this user. @prop {string} userId The ID of the user. @prop {Object} info The info object supplied in the constructor. @prop {string} displayName The 'display...
[ "Construct", "a", "new", "User", ".", "A", "User", "must", "have", "an", "ID", "and", "can", "optionally", "have", "extra", "information", "associated", "with", "it", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/user.js#L48-L64
train
matrix-org/matrix-js-sdk
src/filter-component.js
FilterComponent
function FilterComponent(filter_json) { this.filter_json = filter_json; this.types = filter_json.types || null; this.not_types = filter_json.not_types || []; this.rooms = filter_json.rooms || null; this.not_rooms = filter_json.not_rooms || []; this.senders = filter_json.senders || null; t...
javascript
function FilterComponent(filter_json) { this.filter_json = filter_json; this.types = filter_json.types || null; this.not_types = filter_json.not_types || []; this.rooms = filter_json.rooms || null; this.not_rooms = filter_json.not_rooms || []; this.senders = filter_json.senders || null; t...
[ "function", "FilterComponent", "(", "filter_json", ")", "{", "this", ".", "filter_json", "=", "filter_json", ";", "this", ".", "types", "=", "filter_json", ".", "types", "||", "null", ";", "this", ".", "not_types", "=", "filter_json", ".", "not_types", "||",...
FilterComponent is a section of a Filter definition which defines the types, rooms, senders filters etc to be applied to a particular type of resource. This is all ported over from synapse's Filter object. N.B. that synapse refers to these as 'Filters', and what js-sdk refers to as 'Filters' are referred to as 'Filter...
[ "FilterComponent", "is", "a", "section", "of", "a", "Filter", "definition", "which", "defines", "the", "types", "rooms", "senders", "filters", "etc", "to", "be", "applied", "to", "a", "particular", "type", "of", "resource", ".", "This", "is", "all", "ported"...
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/filter-component.js#L48-L61
train
matrix-org/matrix-js-sdk
src/http-api.js
function() { const params = { access_token: this.opts.accessToken, }; return { base: this.opts.baseUrl, path: "/_matrix/media/v1/upload", params: params, }; }
javascript
function() { const params = { access_token: this.opts.accessToken, }; return { base: this.opts.baseUrl, path: "/_matrix/media/v1/upload", params: params, }; }
[ "function", "(", ")", "{", "const", "params", "=", "{", "access_token", ":", "this", ".", "opts", ".", "accessToken", ",", "}", ";", "return", "{", "base", ":", "this", ".", "opts", ".", "baseUrl", ",", "path", ":", "\"/_matrix/media/v1/upload\"", ",", ...
Get the content repository url with query parameters. @return {Object} An object with a 'base', 'path' and 'params' for base URL, path and query parameters respectively.
[ "Get", "the", "content", "repository", "url", "with", "query", "parameters", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/http-api.js#L98-L107
train
matrix-org/matrix-js-sdk
src/http-api.js
function(path, queryParams, prefix) { let queryString = ""; if (queryParams) { queryString = "?" + utils.encodeParams(queryParams); } return this.opts.baseUrl + prefix + path + queryString; }
javascript
function(path, queryParams, prefix) { let queryString = ""; if (queryParams) { queryString = "?" + utils.encodeParams(queryParams); } return this.opts.baseUrl + prefix + path + queryString; }
[ "function", "(", "path", ",", "queryParams", ",", "prefix", ")", "{", "let", "queryString", "=", "\"\"", ";", "if", "(", "queryParams", ")", "{", "queryString", "=", "\"?\"", "+", "utils", ".", "encodeParams", "(", "queryParams", ")", ";", "}", "return",...
Form and return a homeserver request URL based on the given path params and prefix. @param {string} path The HTTP path <b>after</b> the supplied prefix e.g. "/createRoom". @param {Object} queryParams A dict of query params (these will NOT be urlencoded). @param {string} prefix The full prefix to use e.g. "/_matrix/clie...
[ "Form", "and", "return", "a", "homeserver", "request", "URL", "based", "on", "the", "given", "path", "params", "and", "prefix", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/http-api.js#L641-L647
train
matrix-org/matrix-js-sdk
src/http-api.js
parseErrorResponse
function parseErrorResponse(response, body) { const httpStatus = response.statusCode; const contentType = getResponseContentType(response); let err; if (contentType) { if (contentType.type === 'application/json') { err = new module.exports.MatrixError(JSON.parse(body)); } el...
javascript
function parseErrorResponse(response, body) { const httpStatus = response.statusCode; const contentType = getResponseContentType(response); let err; if (contentType) { if (contentType.type === 'application/json') { err = new module.exports.MatrixError(JSON.parse(body)); } el...
[ "function", "parseErrorResponse", "(", "response", ",", "body", ")", "{", "const", "httpStatus", "=", "response", ".", "statusCode", ";", "const", "contentType", "=", "getResponseContentType", "(", "response", ")", ";", "let", "err", ";", "if", "(", "contentTy...
Attempt to turn an HTTP error response into a Javascript Error. If it is a JSON response, we will parse it into a MatrixError. Otherwise we return a generic Error. @param {XMLHttpRequest|http.IncomingMessage} response response object @param {String} body raw body of the response @returns {Error}
[ "Attempt", "to", "turn", "an", "HTTP", "error", "response", "into", "a", "Javascript", "Error", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/http-api.js#L866-L884
train
matrix-org/matrix-js-sdk
src/client.js
keysFromRecoverySession
function keysFromRecoverySession(sessions, decryptionKey, roomId) { const keys = []; for (const [sessionId, sessionData] of Object.entries(sessions)) { try { const decrypted = keyFromRecoverySession(sessionData, decryptionKey); decrypted.session_id = sessionId; decryp...
javascript
function keysFromRecoverySession(sessions, decryptionKey, roomId) { const keys = []; for (const [sessionId, sessionData] of Object.entries(sessions)) { try { const decrypted = keyFromRecoverySession(sessionData, decryptionKey); decrypted.session_id = sessionId; decryp...
[ "function", "keysFromRecoverySession", "(", "sessions", ",", "decryptionKey", ",", "roomId", ")", "{", "const", "keys", "=", "[", "]", ";", "for", "(", "const", "[", "sessionId", ",", "sessionData", "]", "of", "Object", ".", "entries", "(", "sessions", ")"...
6 hours - an arbitrary value
[ "6", "hours", "-", "an", "arbitrary", "value" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/client.js#L64-L77
train
matrix-org/matrix-js-sdk
src/client.js
_encryptEventIfNeeded
function _encryptEventIfNeeded(client, event, room) { if (event.isEncrypted()) { // this event has already been encrypted; this happens if the // encryption step succeeded, but the send step failed on the first // attempt. return null; } if (!client.isRoomEncrypted(event.get...
javascript
function _encryptEventIfNeeded(client, event, room) { if (event.isEncrypted()) { // this event has already been encrypted; this happens if the // encryption step succeeded, but the send step failed on the first // attempt. return null; } if (!client.isRoomEncrypted(event.get...
[ "function", "_encryptEventIfNeeded", "(", "client", ",", "event", ",", "room", ")", "{", "if", "(", "event", ".", "isEncrypted", "(", ")", ")", "{", "// this event has already been encrypted; this happens if the", "// encryption step succeeded, but the send step failed on the...
Encrypt an event according to the configuration of the room, if necessary. @param {MatrixClient} client @param {module:models/event.MatrixEvent} event event to be sent @param {module:models/room?} room destination room. Null if the destination is not a room we have seen over the sync pipe. @return {module:client.P...
[ "Encrypt", "an", "event", "according", "to", "the", "configuration", "of", "the", "room", "if", "necessary", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/client.js#L1817-L1838
train
matrix-org/matrix-js-sdk
src/crypto/index.js
_maybeUploadOneTimeKeys
function _maybeUploadOneTimeKeys(crypto) { // frequency with which to check & upload one-time keys const uploadPeriod = 1000 * 60; // one minute // max number of keys to upload at once // Creating keys can be an expensive operation so we limit the // number we generate in one go to avoid blocking t...
javascript
function _maybeUploadOneTimeKeys(crypto) { // frequency with which to check & upload one-time keys const uploadPeriod = 1000 * 60; // one minute // max number of keys to upload at once // Creating keys can be an expensive operation so we limit the // number we generate in one go to avoid blocking t...
[ "function", "_maybeUploadOneTimeKeys", "(", "crypto", ")", "{", "// frequency with which to check & upload one-time keys", "const", "uploadPeriod", "=", "1000", "*", "60", ";", "// one minute", "// max number of keys to upload at once", "// Creating keys can be an expensive operation...
check if it's time to upload one-time keys, and do so if so.
[ "check", "if", "it", "s", "time", "to", "upload", "one", "-", "time", "keys", "and", "do", "so", "if", "so", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/crypto/index.js#L515-L611
train
matrix-org/matrix-js-sdk
src/crypto/index.js
_uploadOneTimeKeys
async function _uploadOneTimeKeys(crypto) { const oneTimeKeys = await crypto._olmDevice.getOneTimeKeys(); const oneTimeJson = {}; const promises = []; for (const keyId in oneTimeKeys.curve25519) { if (oneTimeKeys.curve25519.hasOwnProperty(keyId)) { const k = { key: ...
javascript
async function _uploadOneTimeKeys(crypto) { const oneTimeKeys = await crypto._olmDevice.getOneTimeKeys(); const oneTimeJson = {}; const promises = []; for (const keyId in oneTimeKeys.curve25519) { if (oneTimeKeys.curve25519.hasOwnProperty(keyId)) { const k = { key: ...
[ "async", "function", "_uploadOneTimeKeys", "(", "crypto", ")", "{", "const", "oneTimeKeys", "=", "await", "crypto", ".", "_olmDevice", ".", "getOneTimeKeys", "(", ")", ";", "const", "oneTimeJson", "=", "{", "}", ";", "const", "promises", "=", "[", "]", ";"...
returns a promise which resolves to the response
[ "returns", "a", "promise", "which", "resolves", "to", "the", "response" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/crypto/index.js#L614-L642
train
matrix-org/matrix-js-sdk
src/models/event-timeline-set.js
EventTimelineSet
function EventTimelineSet(room, opts) { this.room = room; this._timelineSupport = Boolean(opts.timelineSupport); this._liveTimeline = new EventTimeline(this); // just a list - *not* ordered. this._timelines = [this._liveTimeline]; this._eventIdToTimeline = {}; this._filter = opts.filter |...
javascript
function EventTimelineSet(room, opts) { this.room = room; this._timelineSupport = Boolean(opts.timelineSupport); this._liveTimeline = new EventTimeline(this); // just a list - *not* ordered. this._timelines = [this._liveTimeline]; this._eventIdToTimeline = {}; this._filter = opts.filter |...
[ "function", "EventTimelineSet", "(", "room", ",", "opts", ")", "{", "this", ".", "room", "=", "room", ";", "this", ".", "_timelineSupport", "=", "Boolean", "(", "opts", ".", "timelineSupport", ")", ";", "this", ".", "_liveTimeline", "=", "new", "EventTimel...
Construct a set of EventTimeline objects, typically on behalf of a given room. A room may have multiple EventTimelineSets for different levels of filtering. The global notification list is also an EventTimelineSet, but lacks a room. <p>This is an ordered sequence of timelines, which may or may not be continuous. Eac...
[ "Construct", "a", "set", "of", "EventTimeline", "objects", "typically", "on", "behalf", "of", "a", "given", "room", ".", "A", "room", "may", "have", "multiple", "EventTimelineSets", "for", "different", "levels", "of", "filtering", ".", "The", "global", "notifi...
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/event-timeline-set.js#L62-L73
train
matrix-org/matrix-js-sdk
src/models/event.js
async function(crypto) { // start with a couple of sanity checks. if (!this.isEncrypted()) { throw new Error("Attempt to decrypt event which isn't encrypted"); } if ( this._clearEvent && this._clearEvent.content && this._clearEvent.content.msgtype...
javascript
async function(crypto) { // start with a couple of sanity checks. if (!this.isEncrypted()) { throw new Error("Attempt to decrypt event which isn't encrypted"); } if ( this._clearEvent && this._clearEvent.content && this._clearEvent.content.msgtype...
[ "async", "function", "(", "crypto", ")", "{", "// start with a couple of sanity checks.", "if", "(", "!", "this", ".", "isEncrypted", "(", ")", ")", "{", "throw", "new", "Error", "(", "\"Attempt to decrypt event which isn't encrypted\"", ")", ";", "}", "if", "(", ...
Start the process of trying to decrypt this event. (This is used within the SDK: it isn't intended for use by applications) @internal @param {module:crypto} crypto crypto module @returns {Promise} promise which resolves (to undefined) when the decryption attempt is completed.
[ "Start", "the", "process", "of", "trying", "to", "decrypt", "this", "event", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/event.js#L347-L379
train
matrix-org/matrix-js-sdk
src/models/event.js
function(crypto, userId) { const wireContent = this.getWireContent(); return crypto.requestRoomKey({ algorithm: wireContent.algorithm, room_id: this.getRoomId(), session_id: wireContent.session_id, sender_key: wireContent.sender_key, }, this.getKey...
javascript
function(crypto, userId) { const wireContent = this.getWireContent(); return crypto.requestRoomKey({ algorithm: wireContent.algorithm, room_id: this.getRoomId(), session_id: wireContent.session_id, sender_key: wireContent.sender_key, }, this.getKey...
[ "function", "(", "crypto", ",", "userId", ")", "{", "const", "wireContent", "=", "this", ".", "getWireContent", "(", ")", ";", "return", "crypto", ".", "requestRoomKey", "(", "{", "algorithm", ":", "wireContent", ".", "algorithm", ",", "room_id", ":", "thi...
Cancel any room key request for this event and resend another. @param {module:crypto} crypto crypto module @param {string} userId the user who received this event @returns {Promise} a promise that resolves when the request is queued
[ "Cancel", "any", "room", "key", "request", "for", "this", "event", "and", "resend", "another", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/event.js#L389-L397
train
matrix-org/matrix-js-sdk
src/models/event.js
function(userId) { // send the request to all of our own devices, and the // original sending device if it wasn't us. const wireContent = this.getWireContent(); const recipients = [{ userId, deviceId: '*', }]; const sender = this.getSender(); if (sende...
javascript
function(userId) { // send the request to all of our own devices, and the // original sending device if it wasn't us. const wireContent = this.getWireContent(); const recipients = [{ userId, deviceId: '*', }]; const sender = this.getSender(); if (sende...
[ "function", "(", "userId", ")", "{", "// send the request to all of our own devices, and the", "// original sending device if it wasn't us.", "const", "wireContent", "=", "this", ".", "getWireContent", "(", ")", ";", "const", "recipients", "=", "[", "{", "userId", ",", ...
Calculate the recipients for keyshare requests. @param {string} userId the user who received this event. @returns {Array} array of recipients
[ "Calculate", "the", "recipients", "for", "keyshare", "requests", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/event.js#L406-L420
train
matrix-org/matrix-js-sdk
src/models/event.js
function(decryptionResult) { this._clearEvent = decryptionResult.clearEvent; this._senderCurve25519Key = decryptionResult.senderCurve25519Key || null; this._claimedEd25519Key = decryptionResult.claimedEd25519Key || null; this._forwardingCurve25519KeyChain = ...
javascript
function(decryptionResult) { this._clearEvent = decryptionResult.clearEvent; this._senderCurve25519Key = decryptionResult.senderCurve25519Key || null; this._claimedEd25519Key = decryptionResult.claimedEd25519Key || null; this._forwardingCurve25519KeyChain = ...
[ "function", "(", "decryptionResult", ")", "{", "this", ".", "_clearEvent", "=", "decryptionResult", ".", "clearEvent", ";", "this", ".", "_senderCurve25519Key", "=", "decryptionResult", ".", "senderCurve25519Key", "||", "null", ";", "this", ".", "_claimedEd25519Key"...
Update the cleartext data on this event. (This is used after decrypting an event; it should not be used by applications). @internal @fires module:models/event.MatrixEvent#"Event.decrypted" @param {module:crypto~EventDecryptionResult} decryptionResult the decryption result, including the plaintext and some key info
[ "Update", "the", "cleartext", "data", "on", "this", "event", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/event.js#L538-L546
train
matrix-org/matrix-js-sdk
src/models/event.js
function(redaction_event) { // quick sanity-check if (!redaction_event.event) { throw new Error("invalid redaction_event in makeRedacted"); } // we attempt to replicate what we would see from the server if // the event had been redacted before we saw it. // ...
javascript
function(redaction_event) { // quick sanity-check if (!redaction_event.event) { throw new Error("invalid redaction_event in makeRedacted"); } // we attempt to replicate what we would see from the server if // the event had been redacted before we saw it. // ...
[ "function", "(", "redaction_event", ")", "{", "// quick sanity-check", "if", "(", "!", "redaction_event", ".", "event", ")", "{", "throw", "new", "Error", "(", "\"invalid redaction_event in makeRedacted\"", ")", ";", "}", "// we attempt to replicate what we would see from...
Update the content of an event in the same way it would be by the server if it were redacted before it was sent to us @param {module:models/event.MatrixEvent} redaction_event event causing the redaction
[ "Update", "the", "content", "of", "an", "event", "in", "the", "same", "way", "it", "would", "be", "by", "the", "server", "if", "it", "were", "redacted", "before", "it", "was", "sent", "to", "us" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/event.js#L647-L684
train
matrix-org/matrix-js-sdk
src/models/event-timeline.js
EventTimeline
function EventTimeline(eventTimelineSet) { this._eventTimelineSet = eventTimelineSet; this._roomId = eventTimelineSet.room ? eventTimelineSet.room.roomId : null; this._events = []; this._baseIndex = 0; this._startState = new RoomState(this._roomId); this._startState.paginationToken = null; t...
javascript
function EventTimeline(eventTimelineSet) { this._eventTimelineSet = eventTimelineSet; this._roomId = eventTimelineSet.room ? eventTimelineSet.room.roomId : null; this._events = []; this._baseIndex = 0; this._startState = new RoomState(this._roomId); this._startState.paginationToken = null; t...
[ "function", "EventTimeline", "(", "eventTimelineSet", ")", "{", "this", ".", "_eventTimelineSet", "=", "eventTimelineSet", ";", "this", ".", "_roomId", "=", "eventTimelineSet", ".", "room", "?", "eventTimelineSet", ".", "room", ".", "roomId", ":", "null", ";", ...
Construct a new EventTimeline <p>An EventTimeline represents a contiguous sequence of events in a room. <p>As well as keeping track of the events themselves, it stores the state of the room at the beginning and end of the timeline, and pagination tokens for going backwards and forwards in the timeline. <p>In order t...
[ "Construct", "a", "new", "EventTimeline" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/models/event-timeline.js#L44-L61
train
matrix-org/matrix-js-sdk
src/content-repo.js
function(baseUrl, mxc, width, height, resizeMethod, allowDirectLinks) { if (typeof mxc !== "string" || !mxc) { return ''; } if (mxc.indexOf("mxc://") !== 0) { if (allowDirectLinks) { return mxc; } else { ...
javascript
function(baseUrl, mxc, width, height, resizeMethod, allowDirectLinks) { if (typeof mxc !== "string" || !mxc) { return ''; } if (mxc.indexOf("mxc://") !== 0) { if (allowDirectLinks) { return mxc; } else { ...
[ "function", "(", "baseUrl", ",", "mxc", ",", "width", ",", "height", ",", "resizeMethod", ",", "allowDirectLinks", ")", "{", "if", "(", "typeof", "mxc", "!==", "\"string\"", "||", "!", "mxc", ")", "{", "return", "''", ";", "}", "if", "(", "mxc", ".",...
Get the HTTP URL for an MXC URI. @param {string} baseUrl The base homeserver url which has a content repo. @param {string} mxc The mxc:// URI. @param {Number} width The desired width of the thumbnail. @param {Number} height The desired height of the thumbnail. @param {string} resizeMethod The thumbnail resize method to...
[ "Get", "the", "HTTP", "URL", "for", "an", "MXC", "URI", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/content-repo.js#L37-L77
train
matrix-org/matrix-js-sdk
src/content-repo.js
function(baseUrl, identiconString, width, height) { if (!identiconString) { return null; } if (!width) { width = 96; } if (!height) { height = 96; } const params = { width: width, height: height, ...
javascript
function(baseUrl, identiconString, width, height) { if (!identiconString) { return null; } if (!width) { width = 96; } if (!height) { height = 96; } const params = { width: width, height: height, ...
[ "function", "(", "baseUrl", ",", "identiconString", ",", "width", ",", "height", ")", "{", "if", "(", "!", "identiconString", ")", "{", "return", "null", ";", "}", "if", "(", "!", "width", ")", "{", "width", "=", "96", ";", "}", "if", "(", "!", "...
Get an identicon URL from an arbitrary string. @param {string} baseUrl The base homeserver url which has a content repo. @param {string} identiconString The string to create an identicon for. @param {Number} width The desired width of the image in pixels. Default: 96. @param {Number} height The desired height of the im...
[ "Get", "an", "identicon", "URL", "from", "an", "arbitrary", "string", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/content-repo.js#L87-L108
train
matrix-org/matrix-js-sdk
src/store/memory.js
function(room) { this.rooms[room.roomId] = room; // add listeners for room member changes so we can keep the room member // map up-to-date. room.currentState.on("RoomState.members", this._onRoomMember.bind(this)); // add existing members const self = this; room.cu...
javascript
function(room) { this.rooms[room.roomId] = room; // add listeners for room member changes so we can keep the room member // map up-to-date. room.currentState.on("RoomState.members", this._onRoomMember.bind(this)); // add existing members const self = this; room.cu...
[ "function", "(", "room", ")", "{", "this", ".", "rooms", "[", "room", ".", "roomId", "]", "=", "room", ";", "// add listeners for room member changes so we can keep the room member", "// map up-to-date.", "room", ".", "currentState", ".", "on", "(", "\"RoomState.membe...
Store the given room. @param {Room} room The room to be stored. All properties must be stored.
[ "Store", "the", "given", "room", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/memory.js#L113-L123
train
matrix-org/matrix-js-sdk
src/store/memory.js
function(event, state, member) { if (member.membership === "invite") { // We do NOT add invited members because people love to typo user IDs // which would then show up in these lists (!) return; } const user = this.users[member.userId] || new User(member.use...
javascript
function(event, state, member) { if (member.membership === "invite") { // We do NOT add invited members because people love to typo user IDs // which would then show up in these lists (!) return; } const user = this.users[member.userId] || new User(member.use...
[ "function", "(", "event", ",", "state", ",", "member", ")", "{", "if", "(", "member", ".", "membership", "===", "\"invite\"", ")", "{", "// We do NOT add invited members because people love to typo user IDs", "// which would then show up in these lists (!)", "return", ";", ...
Called when a room member in a room being tracked by this store has been updated. @param {MatrixEvent} event @param {RoomState} state @param {RoomMember} member
[ "Called", "when", "a", "room", "member", "in", "a", "room", "being", "tracked", "by", "this", "store", "has", "been", "updated", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/memory.js#L132-L152
train
matrix-org/matrix-js-sdk
src/store/memory.js
function(filter) { if (!filter) { return; } if (!this.filters[filter.userId]) { this.filters[filter.userId] = {}; } this.filters[filter.userId][filter.filterId] = filter; }
javascript
function(filter) { if (!filter) { return; } if (!this.filters[filter.userId]) { this.filters[filter.userId] = {}; } this.filters[filter.userId][filter.filterId] = filter; }
[ "function", "(", "filter", ")", "{", "if", "(", "!", "filter", ")", "{", "return", ";", "}", "if", "(", "!", "this", ".", "filters", "[", "filter", ".", "userId", "]", ")", "{", "this", ".", "filters", "[", "filter", ".", "userId", "]", "=", "{...
Store a filter. @param {Filter} filter
[ "Store", "a", "filter", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/memory.js#L243-L251
train
matrix-org/matrix-js-sdk
src/store/memory.js
function(userId, filterId) { if (!this.filters[userId] || !this.filters[userId][filterId]) { return null; } return this.filters[userId][filterId]; }
javascript
function(userId, filterId) { if (!this.filters[userId] || !this.filters[userId][filterId]) { return null; } return this.filters[userId][filterId]; }
[ "function", "(", "userId", ",", "filterId", ")", "{", "if", "(", "!", "this", ".", "filters", "[", "userId", "]", "||", "!", "this", ".", "filters", "[", "userId", "]", "[", "filterId", "]", ")", "{", "return", "null", ";", "}", "return", "this", ...
Retrieve a filter. @param {string} userId @param {string} filterId @return {?Filter} A filter or null.
[ "Retrieve", "a", "filter", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/memory.js#L259-L264
train
matrix-org/matrix-js-sdk
src/store/memory.js
function(events) { const self = this; events.forEach(function(event) { self.accountData[event.getType()] = event; }); }
javascript
function(events) { const self = this; events.forEach(function(event) { self.accountData[event.getType()] = event; }); }
[ "function", "(", "events", ")", "{", "const", "self", "=", "this", ";", "events", ".", "forEach", "(", "function", "(", "event", ")", "{", "self", ".", "accountData", "[", "event", ".", "getType", "(", ")", "]", "=", "event", ";", "}", ")", ";", ...
Store user-scoped account data events. N.B. that account data only allows a single event per type, so multiple events with the same type will replace each other. @param {Array<MatrixEvent>} events The events to store.
[ "Store", "user", "-", "scoped", "account", "data", "events", ".", "N", ".", "B", ".", "that", "account", "data", "only", "allows", "a", "single", "event", "per", "type", "so", "multiple", "events", "with", "the", "same", "type", "will", "replace", "each"...
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/memory.js#L301-L306
train
matrix-org/matrix-js-sdk
spec/integ/matrix-client-event-timeline.spec.js
startClient
function startClient(httpBackend, client) { httpBackend.when("GET", "/pushrules").respond(200, {}); httpBackend.when("POST", "/filter").respond(200, { filter_id: "fid" }); httpBackend.when("GET", "/sync").respond(200, INITIAL_SYNC_DATA); client.startClient(); // set up a promise which will resolve...
javascript
function startClient(httpBackend, client) { httpBackend.when("GET", "/pushrules").respond(200, {}); httpBackend.when("POST", "/filter").respond(200, { filter_id: "fid" }); httpBackend.when("GET", "/sync").respond(200, INITIAL_SYNC_DATA); client.startClient(); // set up a promise which will resolve...
[ "function", "startClient", "(", "httpBackend", ",", "client", ")", "{", "httpBackend", ".", "when", "(", "\"GET\"", ",", "\"/pushrules\"", ")", ".", "respond", "(", "200", ",", "{", "}", ")", ";", "httpBackend", ".", "when", "(", "\"POST\"", ",", "\"/fil...
start the client, and wait for it to initialise
[ "start", "the", "client", "and", "wait", "for", "it", "to", "initialise" ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/spec/integ/matrix-client-event-timeline.spec.js#L77-L98
train
matrix-org/matrix-js-sdk
src/store/indexeddb-local-backend.js
selectQuery
function selectQuery(store, keyRange, resultMapper) { const query = store.openCursor(keyRange); return new Promise((resolve, reject) => { const results = []; query.onerror = (event) => { reject(new Error("Query failed: " + event.target.errorCode)); }; // collect resul...
javascript
function selectQuery(store, keyRange, resultMapper) { const query = store.openCursor(keyRange); return new Promise((resolve, reject) => { const results = []; query.onerror = (event) => { reject(new Error("Query failed: " + event.target.errorCode)); }; // collect resul...
[ "function", "selectQuery", "(", "store", ",", "keyRange", ",", "resultMapper", ")", "{", "const", "query", "=", "store", ".", "openCursor", "(", "keyRange", ")", ";", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "const"...
Helper method to collect results from a Cursor and promiseify it. @param {ObjectStore|Index} store The store to perform openCursor on. @param {IDBKeyRange=} keyRange Optional key range to apply on the cursor. @param {Function} resultMapper A function which is repeatedly called with a Cursor. Return the data you want to...
[ "Helper", "method", "to", "collect", "results", "from", "a", "Cursor", "and", "promiseify", "it", "." ]
ee8a4698a94a4a6bfaded61d6108492a04aa0d4e
https://github.com/matrix-org/matrix-js-sdk/blob/ee8a4698a94a4a6bfaded61d6108492a04aa0d4e/src/store/indexeddb-local-backend.js#L61-L79
train