pax_global_header 0000666 0000000 0000000 00000000064 14727753210 0014522 g ustar 00root root 0000000 0000000 52 comment=2dec7f81372f917b09b2c1da2fc89aaa573459cf
strophejs-3.1.0/ 0000775 0000000 0000000 00000000000 14727753210 0013544 5 ustar 00root root 0000000 0000000 strophejs-3.1.0/.gitattributes 0000664 0000000 0000000 00000000017 14727753210 0016435 0 ustar 00root root 0000000 0000000 *.min.js binary strophejs-3.1.0/.github/ 0000775 0000000 0000000 00000000000 14727753210 0015104 5 ustar 00root root 0000000 0000000 strophejs-3.1.0/.github/dependabot.yml 0000664 0000000 0000000 00000000175 14727753210 0017737 0 ustar 00root root 0000000 0000000 version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
strophejs-3.1.0/.github/workflows/ 0000775 0000000 0000000 00000000000 14727753210 0017141 5 ustar 00root root 0000000 0000000 strophejs-3.1.0/.github/workflows/karma-tests.yml 0000664 0000000 0000000 00000001647 14727753210 0022127 0 ustar 00root root 0000000 0000000 # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Strophe CI Tests
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
env:
DISPLAY: :99.0
strategy:
matrix:
node-version: [19.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Run Karma tests
uses: GabrielBB/xvfb-action@v1
with:
run: make check ARGS=--single-run
strophejs-3.1.0/.gitignore 0000664 0000000 0000000 00000000240 14727753210 0015530 0 ustar 00root root 0000000 0000000 stamp-npm
stamp-bower
version.txt
node_modules
bower_components
dist
strophejs-*/
ndproj
doc
*.map
.taperc
*.tar.gz
*.zip
*~
.*.sw?
doc-tmp
tags.lock
tags.temp
strophejs-3.1.0/.nvmrc 0000664 0000000 0000000 00000000011 14727753210 0014662 0 ustar 00root root 0000000 0000000 v20.18.0
strophejs-3.1.0/.prettierrc 0000664 0000000 0000000 00000000134 14727753210 0015726 0 ustar 00root root 0000000 0000000 {
"printWidth": 120,
"quoteProps": "preserve",
"singleQuote": true,
"tabWidth": 4
}
strophejs-3.1.0/.travis.yml 0000664 0000000 0000000 00000000173 14727753210 0015656 0 ustar 00root root 0000000 0000000 dist: bionic
language: node_js
addons:
chrome: stable
node_js:
- "13"
before_script: make serve_bg
script: make check
strophejs-3.1.0/CHANGELOG.md 0000664 0000000 0000000 00000032661 14727753210 0015365 0 ustar 00root root 0000000 0000000 # Strophe.js Change Log
## Version 3.1.0 - (2024-12-16)
- **Security Fix**: Escape values passed to the `stx` tagged template literal
- Allow `Stanza` and `Builder` objects to be passed as values the `stx`.
- Avoid inserting commas when nesting array values in `stx` templates.
- Replace [xmldom](https://github.com/xmldom/xmldom) with [jsdom](https://github.com/jsdom/jsdom).
- Remove deprecated `abab` package
- Make sure `ConnectionOptions` type is exportable
- fix: invert default and types exports
## Version 3.0.1 - (2024-08-15)
* Bugfix: `Package path . is not exported from package`
* #708 Properly set exports value in package.json
* #710 Fix types minor errors
* #711 Error with Builder.up depending on context
* #712 fix: export node and default modules
* #715 Fix the error when the attrs field is null
Dependency updates:
* Bump @rollup/plugin-commonjs from 24.1.0 to 26.0.1
* Bump @xmldom/xmldom from 0.8.8 to 0.8.10
* Bump prettier from 2.8.8 to 3.3.3
* Bump sinon from 15.0.4 to 18.0.0
## Version 3.0.0 - (2024-05-07)
* #704 Cannot use with NodeJS
* #706 TypeError when receiving a `stream:error` IQ message
Out of an abundance of caution, making a major version bump, since there was
some internal refactoring of the Strophe files to remove circular
dependencies. So certain deep imports used by integrators might no longer work.
Instead of deep imports, everything should be imported from `strophe.js`.
For example:
```
import { Strophe, $build, stx } from strophe.js;
```
## Version 2.0.0 - (2024-02-21)
* Type checking via TypeScript and JSDoc typing annotations
* Types definitions are now generated and placed in `./dist/types/`.
* Remove the deprecated `matchBare` option for `Strophe.Handler`. Use `matchBareFromJid` instead.
* Add the ability to create stanzas via a tagged template literal (`stx`).
* Bugfix: Ignore unknown SCRAM attributes instead of aborting the connection
## Version 1.6.2 - (2023-06-23)
* #613 TypeError: XHTML.validTag is not a function
* Re-add NodeJS support and add the ability to run tests on NodeJS to avoid regressions
## Version 1.6.1 - (2023-05-15)
* #602 Websocket connection times out instead of being disconnected
## Version 1.6.0 - (2022-10-29)
* #314 Support for SCRAM-SHA-256 and SCRAM-SHA-512 authentication
## Version 1.5.0 - (2022-04-28)
* Add an automatic fallback handler for unhandled IQ "set" and "get" stanzas
that returns an IQ error with `service-unavailable`.
* Update various 3rd party dependencies
* #390 Replace deprecated String.prototype.substr()
* #418 BOSH fix: mark first request dead when second is done
## Version 1.4.4 - (2022-01-21)
* #388 Properly import xmldom
## Version 1.4.3 - (2021-12-16)
* Update xmldom to version 0.7.5
* Add disconnection_timeout setting: an optional timeout in milliseconds before `_doDisconnect` is called.
* Update ws optional dependency to fix security issue https://github.com/websockets/ws/commit/00c425ec77993773d823f018f64a5c44e17023ff
## Version 1.4.2 - (2021-04-28)
* Update optional NodeJS-specific dependency xmldom to version 0.5.0 which includes a security fix.
* #369 Add `clientChallenge` SASL mechanism method to avoid having to monkey patch `onChallenge`,
which prevents reconnection when using SCRAM-SHA1.
## Version 1.4.1 - (2020-12-02)
* #201: NodeJS related fixes: `window` and `WebSocket` are `undefined`
* New method `Strophe.Connection.prototype.setProtocol` which can be used to
determine the protocol used after the connection has been constructed.
## Version 1.4.0 - (2020-09-10)
* #347: Bugfix. Reconnection fails when SessionResultIQ arrives too late
* #354: Strophe.js sends an authzid during PLAIN when not acting on behalf of another entity
* #359: Bugfix: WebSocket connection failed: Data frame received after close
* Add support for running a websocket connection inside a shared worker
## Version 1.3.6 - (2020-06-15)
- #250 Bugfix: OAuth's SASL priority being higher causes problems
- #352 Bugfix: Referencing undefined property
## Version 1.3.5 - (2020-04-29)
* Remove support for obselete SASL DIGEST-MD5 auth
* #329 Varous compatibility fixes to make Strophe.js work in NodeJS
* #344 Properly set Strophe.VERSION
## Version 1.3.4 - (2019-08-08)
* Replace webpack with rollup
* `TypeError: this._changeConnectStatus is not a function`
* Bugfix. Remove handlers on closed socket
* Add new Strophe.Connection option `explicitResourceBinding`.
If is set to true the XMPP client needs to explicitly
call `Strophe.Connection.prototype.bind` once the XMPP
server has advertised the "urn:ietf:params:xml:ns:xmpp-bind" feature.
## Version 1.3.3 - (2019-05-13)
* The dist files are no longer included in the repo, but generated by NPM/Yarn
* Moved some log statements from INFO to DEBUG level
* Don't break when a falsy value is passed to `getResourceFromJid`
## Version 1.3.2 - (2019-03-21)
* #320 Fix error on SCRAM-SHA-1 client nonce generation
## Version 1.3.1 - (2018-11-15)
* #311 Expose `Strophe`, `$build`, `$msg` and `$iq` as globals
## Version 1.3.0 - (2018-10-21)
* Use ES2015 modules
* Drop support for Internet Explorer < 11
## Version 1.2.16 - (2018-09-16)
* #299 'no-auth-mech' error. Server did not offer a supported authentication mechanism
* #306 Fix websocket close handler exception and reporting
## Version 1.2.15 - (2018-05-21)
* #259 XML element should be sent to xmlOutput
* #266 Support Browserify/CommonJS. `require('strophe.js/src/wrapper')`
* #296 Remove error handler from old websocket before closing
* #271 SASL X-OAUTH2 authentication mechanism implemented
* #288 Strophe now logs fatal errors by default.
* Run tests with headless Chromium instead of Phantomjs
## Version 1.2.14 - 2017-06-15
* #231 SASL OAuth Bearer authentication should not require a JID node, when a user identifer
can be retreived from the bearer token.
* #250 Show XHR error message
* #254 Set connection status to CONNFAIL after max retries
* #255 Set CONNFAIL error status when connection fails on Safari 10
## Version 1.2.13 - 2017-02-25
* Use almond to create the build. This means that the build itself is an AMD
module and can be loaded via `require`.
* Remove Grunt as a build tool.
## Version 1.2.12 - 2017-01-15
* Reduce the priority of the SASL-EXTERNAL auth mechanism. OpenFire 4.1.1
advertises support for SASL-EXTERNAL and the vast majority of Strophe.js
installs are not set up to support SASL-EXTERNAl, causing them to fail
logging users in.
## Version 1.2.11 - 2016-12-13
* 189 Strophe never reaches DISCONNECTED status after .connect(..) and
.disconnect(..) calls while offline.
* Add `sendPresence` method, similar to `sendIQ`, i.e. for cases where you expect a
responding presence (e.g. when leaving a MUC room).
## Version 1.2.10 - 2016-11-30
* #172 and #215: Strophe shouldn't require `from` attribute in iq response
* #216 Get inactivity attribute from session creation response
* Enable session restoration for anonymous logins
## Version 1.2.9 - 2016-10-24
* Allow SASL mechanisms to be supported to be passed in as option to `Strophe.Connection` constructor.
* Add new matching option to `Strophe.Handler`, namely `ignoreNamespaceFragment`.
* The `matchBare` matching option for `Strophe.Handler` has been renamed to
`matchBareFromJid`. The old name will still work in this release but is
deprecated and will be removed in a future release.
* #114 Add an error handler for HTTP calls
* #213 "XHR open failed." in BOSH in IE9
* #214 Add function to move Strophe.Builder pointer back to the root node
* #172, #215 Don't compare `to` and `to` values of sent and received IQ stanzas
to determine correctness (we rely on UUIDs for that).
## Version 1.2.8 - 2016-09-16
* #200 Fix for webpack
* #203 Allow custom Content-Type header for requests
* #206 XML stanza attributes: there is no 'quot' escape inside 'serialize' method
* The files in `./src` are now also included in the NPM distribution.
* Add support for SASL-EXTERNAL
## Version 1.2.7 - 2016-06-17
* #193 Move phantomjs dependencies to devDependencies
## Version 1.2.6 - 2016-06-06
* #178 Added new value (CONNTIMEOUT) to Strophe.Status
* #180 bosh: check sessionStorage support before using it
* #182 Adding SASL OAuth Bearer authentication
* #190 Fix .c() to accept both text and numbers as text for the child element
* #192 User requirejs instead of require for node compat
## Version 1.2.5 - 2016-02-09
* Add a new Strophe.Connection option to add cookies
* Add new Strophe.Connection option "withCredentials"
## Version 1.2.4 - 2016-01-28
* #147 Support for UTF-16 encoded usernames (e.g. Chinese)
* #162 allow empty expectedFrom according to W3C DOM 3 Specification
* #171 Improve invalid BOSH URL handling
## Version 1.2.3 - 2015-09-01
* Bugfix. Check if JID is null when restoring a session.
* #127 IE-Fix: error on setting null value with setAttributes
* #138 New stub method nextValidRid
* #144 Change ID generator to generate UUIDs
## Version 1.2.2 - 2015-06-20
* #109 Explicitly define AMD modules to prevent errors with AlmondJS and AngularJS.
* #111 Fixed IE9 compatibility.
* #113 Permit connecting with an alternative authcid.
* #116 tree.attrs() now removes Elements when they are set to undefined
* #119 Provide the 'keepalive' option to keep a BOSH session alive across page loads.
* #121 Ensure that the node names of HTML elements copied into XHTML are lower case.
* #124 Strophe's Builder will swallow elements if given a blank string as a 'text' parameter.
## Version 1.2.1 - 2015-02-22
* Rerelease of 1.2.0 but with a semver tag and proper formatting of bower.json
for usage with Bower.io.
## Version 1.2.0 - 2015-02-21
* Add bower package manager support.
* Add commandline testing support via qunit-phantomjs-runner
* Add integrated testing via TravisCI.
* Fix Websocket connections now use the current XMPP-over-WebSockets RFC
* #25 Item-not-found-error caused by long term request.
* #29 Add support for the Asynchronous Module Definition (AMD) and require.js
* #30 Base64 encoding problem in some older browsers.
* #45 Move xhlr plugin to strophejs-plugins repo.
* #60 Fixed deletion of handlers in websocket connections
* #62 Add `xmlunescape` method.
* #67 Use correct Content-Type in BOSH
* #70 `_onDisconnectTimeout` never tiggers because maxRetries is undefined.
* #71 switched to case sensitive handling of XML elements
* #73 `getElementsByTagName` problem with namespaced elements.
* #76 respect "Invalid SID" message
* #79 connect.pause work correctly again
* #90 The queue data was not reset in .reset() method.
* #104 Websocket connections with MongooseIM work now
## Version 1.1.3 - 2014-01-20
* Fix SCRAM-SHA1 auth now works for multiple connections at the same time
* Fix Connecting to a different server with the same connection after disconnect
* Add Gruntfile so StropheJS can now also be built using grunt
* Fix change in sha1.js that broke the caps plugin
* Fix all warnings from jshint.
## Version 1.1.2 - 2014-01-04
* Add option for synchronous BOSH connections
* moved bower.json to other repository
* Remove unused code in sha1 and md5 modules
## Version 1.1.1 - 2013-12-16
* Fix BOSH attach is working again
## Version 1.1.0 - 2013-12-11
* Add Support for XMPP-over-WebSocket
* Authentication mechanisms are now modular and can be toggled
* Transport protocols are now modular and will be chosen based on the
connection URL. Currently supported protocols are BOSH and WebSocket
* Add Strings to some disconnects that indicate the reason
* Add option to strip
tags before passing to xmlInput/xmlOutput
* Fix Connection status staying at CONNFAIL or CONNECTING in certain
error scenarios
* Add package.json for use with npm
* Add bower.json for use with bower
* Fix handlers not being removed after disconnect
* Fix legacy non-sasl authentication
* Add better tests for BOSH bind
* Fix use of deprecated functions in tests
* Remove some dead code
* Remove deprecated documentation
* Fix Memory leak in IE9
* Add An options object can be passed to a Connection constructor now
* Add "Route" Parameter for BOSH Connections
* Add Maximum number of connection attempts before disconnecting
* Add conflict condition for AUTHFAIL
* Add XHTML message support
* Fix parsing chat messages in IE
* Add SCRAM-SHA-1 SASL mechanism
* Fix escaping of messages
## Version 1.0.2 - 2011-06-19
* Fix security bug where DIGEST-MD5 client nonce was not properly randomized.
* Fix double escaping in copyElement.
* Fix IE errors related to importNode.
* Add ability to pass text into Builder.c().
* Improve performance by skipping debugging callbacks when not
overridden.
* Wrap handler runs in try/catch so they don't affect or remove later
handlers.
* Add ' and " to escaped characters and other escaping fixes.
* Fix _throttledRequestHandler to use proper window size.
* Fix timed handler management.
* Fix flXHR plugin to better deal with errors.
* Fix bind() to be ECMAScript 5 compatible.
* Use bosh.metajack.im in examples so they work out of the box.
* Add simple XHR tests.
* Update basic example to HTML5.
* Move community plugins to their own repository.
* Fix bug causing infinite retries.
* Fix 5xx error handling.
* Store stream:features for later use by plugins.
* Fix to prevent passing stanzas during disconnect.
* Fix handling of disconnect responses.
* Fix getBareJidFromJid to return null on error.
* Fix equality testing in matchers so that string literals and string
objects both match.
* Fix bare matching on missing from attributes.
* Remove use of reserved word self.
* Fix various documentation errors.
## Version 1.0.1 - 2010-01-27
* Fix handling of window, hold, and wait attributes. Bug #75.
## Version 1.0 - 2010-01-01
* First release.
strophejs-3.1.0/LICENSE.txt 0000664 0000000 0000000 00000002047 14727753210 0015372 0 ustar 00root root 0000000 0000000 Copyright (c) 2006-2009 Collecta, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
strophejs-3.1.0/Makefile 0000664 0000000 0000000 00000004354 14727753210 0015212 0 ustar 00root root 0000000 0000000 DOC_DIR = doc
DOC_TEMP = doc-temp
HTTPSERVE ?= ./node_modules/http-server/bin/http-server
HTTPSERVE_PORT ?= 8080
ESLINT ?= ./node_modules/eslint/bin/eslint.js
NDPROJ_DIR = ndproj
SED ?= sed
SHELL ?= /usr/env/bin/bash
SRC_DIR = src
STROPHE = dist/strophe.umd.js
all: doc $(STROPHE)
.PHONY: help
help:
@echo "Please use \`make ' where is one of the following:"
@echo ""
@echo " all Update docs + build strophe"
@echo " doc Update docs"
@echo " dist Build strophe"
@echo " check Build and run the tests"
@echo " eslint Check code quality"
@echo " release Prepare a new release of strophe. E.g. \`make release VERSION=1.2.14\`"
@echo " serve Serve this directory via a webserver on port 8000."
@echo " node_modules Install all dependencies"
@echo ""
@echo "If you are a Mac user:\n 1. Install \`gnu-sed\` (brew install gnu-sed) \n 2. Set \`SED\` to \`gsed\` in all commands. E.g. \`make release SED=gsed VERSION=1.2.14\`"
node_modules: package.json
npm install
.PHONY: doc
doc:
@@echo "Building Strophe documentation..."
npx jsdoc -p -d $(DOC_DIR) -c jsdoc.json src/
@@echo "Documentation built."
@@echo
.PHONY: release
release:
$(SED) -i 's/\"version\":\ \"[0-9]\+\.[0-9]\+\.[0-9]\+\"/\"version\":\ \"$(VERSION)\"/' package.json
$(SED) -i 's/VERSION:\ \"[0-9]\+\.[0-9]\+\.[0-9]\+\"/VERSION:\ \"$(VERSION)\"/' src/index.js
$(SED) -i "s/Unreleased/`date +%Y-%m-%d`/" CHANGELOG.md
make dist
.PHONY: watchjs
watchjs: node_modules
./node_modules/.bin/npx webpack --mode=development --watch
dist/types: src/*
npm run types
.PHONY: dist
dist: $(STROPHE) dist/types
$(STROPHE): src/* rollup.config.js node_modules Makefile
npm run build
.PHONY: eslint
eslint: node_modules
$(ESLINT) src/
.PHONY: prettier
prettier: node_modules
npm run prettier
.PHONY: check
check:: node_modules eslint dist
npm ci && npm run test
.PHONY: serve
serve: node_modules
$(HTTPSERVE) -p $(HTTPSERVE_PORT)
.PHONY: serve_bg
serve_bg: node_modules
$(HTTPSERVE) -p $(HTTPSERVE_PORT) -c-1 -s &
.PHONY: clean
clean:
@@rm -rf node_modules
@@rm -f $(STROPHE)
@@rm -f $(STROPHE_MIN)
@@rm -f $(PLUGIN_FILES_MIN)
@@rm -rf $(NDPROJ_DIR) $(DOC_DIR) $(DOC_TEMP)
@@echo "Done."
@@echo
strophejs-3.1.0/README.md 0000664 0000000 0000000 00000004072 14727753210 0015026 0 ustar 00root root 0000000 0000000 # Strophe.js

Strophe.js is a JavaScript library for speaking XMPP via BOSH
([XEP 124](https://xmpp.org/extensions/xep-0124.html)
and [XEP 206](https://xmpp.org/extensions/xep-0206.html)) and WebSockets
([RFC 7395](http://tools.ietf.org/html/rfc7395)).
It runs in both NodeJS and in web browsers, and its purpose is to enable real-time
XMPP applications.
## Quick Links
* [Homepage](https://strophe.im/strophejs/)
* [Documentation](https://strophe.im/strophejs/doc/2.0.0/files/strophe-umd-js.html)
* [Mailing list](https://groups.google.com/g/strophe)
* [Community Plugins](https://github.com/strophe/strophejs-plugins)
## Support in different environments
### Browsers
Versions <= 1.2.16 have been tested on Firefox, Firefox for Android, IE, Safari,
Mobile Safari, Chrome, Chrome for Android, Opera and the mobile Opera browser.
Since version 1.3.0, support for IE < 11 has been dropped.
### React Native
Since version 1.6.0 the [WebCrypto](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API)
API (included by default in Browsers and NodeJS) is used for crypto primitives
such as hashing and signatures.
Unfortunately this API is not available in React Native, and integrators will
need to look for a 3rd party implementations of this API if they want to use
Strophe there.
## Running tests
You can run `npm run test`, or alternatively if you have [GNU Make](https://www.gnu.org/software/make/) available,
you can run `make check`.
## License
Strophe.js is licensed under the [MIT license](https://github.com/strophe/strophejs/raw/master/LICENSE.txt).
## Author & History
Strophe.js was created by Jack Moffitt. It was originally developed
for Chesspark, an online chess community based on XMPP technology. It has been
cared for and improved over the years and is currently maintained by many
people in the community.
The book [Professional XMPP Programming with JavaScript and jQuery](http://professionalxmpp.com)
covers Strophe in detail in the context of web applications.
strophejs-3.1.0/RELEASE_CHECKLIST.md 0000664 0000000 0000000 00000001567 14727753210 0016550 0 ustar 00root root 0000000 0000000 # Release Checklist
## Note: it's assumed that you have Strophe.js and Strophe.im checked out in sibling directories.
1. Make sure all tests pass (run 'make check')
2. Update CHANGELOG.md
3. Run `make release VERSION=3.0.1` (on Mac, prefix with "SED=gsed" so that GNU-sed is used).
4. Run `make doc`
5. Run `cp -r doc ../strophe.im/strophejs/doc/3.0.1`
5. Update links in `../strophe.im/strophejs/index.markdown` in Strophe.im
6. `cd ../strophe.im && git commit -am "Docs for Strophe.js 3.0.1" && git push`
7. Update link to documentation in README (of strophe.js)
8. `cd ../strophe.js && git commit -am "Release 3.0.1"`
9. `git tag -s v3.0.1 -m "Release 3.0.1"`
10. Run `git push && git push origin v3.0.1`
11. Publish on NPM: `npm publish`
12. Update the release notes on https://github.com/strophe/strophejs/releases
13. Run `npm pack` and upload the tgz file to the releases page.
strophejs-3.1.0/babel.config.json 0000664 0000000 0000000 00000000420 14727753210 0016744 0 ustar 00root root 0000000 0000000 {
"presets": [
["@babel/preset-env", {
"targets": {
"browsers": [">1%", "not dead"]
}
}]
],
"plugins": ["@babel/plugin-proposal-optional-chaining", "@babel/plugin-proposal-nullish-coalescing-operator"]
}
strophejs-3.1.0/eslint.config.mjs 0000664 0000000 0000000 00000020046 14727753210 0017023 0 ustar 00root root 0000000 0000000 import globals from "globals";
import babelParser from "@babel/eslint-parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});
export default [...compat.extends("eslint:recommended"), {
languageOptions: {
globals: {
...globals.browser,
Uint8Array: true,
Promise: true,
define: true,
require: true,
sinon: true,
window: true,
},
parser: babelParser,
ecmaVersion: 2017,
sourceType: "module",
parserOptions: {
allowImportExportEverywhere: true,
},
},
rules: {
"accessor-pairs": "error",
"array-bracket-spacing": "off",
"array-callback-return": "error",
"arrow-body-style": "off",
"arrow-parens": "off",
"arrow-spacing": "error",
"block-scoped-var": "off",
"block-spacing": "off",
"brace-style": "off",
"callback-return": "off",
camelcase: "off",
"capitalized-comments": "off",
"class-methods-use-this": "error",
"comma-dangle": "off",
"comma-spacing": "off",
"comma-style": "off",
complexity: "off",
"computed-property-spacing": ["error", "never"],
"consistent-return": "off",
"consistent-this": "off",
curly: "off",
"default-case": "off",
"dot-location": ["error", "property"],
"dot-notation": ["off", {
allowKeywords: true,
}],
"eol-last": "error",
eqeqeq: "off",
"func-call-spacing": "off",
"no-spaced-func": "off",
"no-redeclare": "off",
"func-name-matching": "error",
"func-names": "off",
"func-style": "off",
"generator-star-spacing": "error",
"global-require": "off",
"guard-for-in": "error",
"handle-callback-err": "error",
"id-blacklist": "error",
"id-length": "off",
"id-match": "error",
indent: "off",
"init-declarations": "off",
"jsx-quotes": "error",
"key-spacing": "off",
"keyword-spacing": "off",
"line-comment-position": "off",
"linebreak-style": ["error", "unix"],
"lines-around-comment": "off",
"lines-around-directive": "off",
"max-depth": "off",
"max-len": "off",
"max-lines": "off",
"max-nested-callbacks": "off",
"max-params": "off",
"max-statements": "off",
"max-statements-per-line": "off",
"multiline-ternary": "off",
"new-parens": "error",
"newline-after-var": "off",
"newline-before-return": "off",
"newline-per-chained-call": "off",
"no-alert": "off",
"no-array-constructor": "error",
"no-await-in-loop": "off",
"no-bitwise": "off",
"no-caller": "error",
"no-console": "off",
"no-catch-shadow": "off",
"no-cond-assign": ["off", "except-parens"],
"no-confusing-arrow": "off",
"no-continue": "off",
"no-div-regex": "error",
"no-duplicate-imports": "error",
"no-else-return": "off",
"no-empty-function": "off",
"no-eq-null": "error",
"no-eval": "error",
"no-extend-native": "off",
"no-extra-bind": "off",
"no-extra-label": "error",
"no-extra-parens": "off",
"no-floating-decimal": "error",
"no-implicit-globals": "off",
"no-implied-eval": "error",
"no-inline-comments": "off",
"no-inner-declarations": ["error", "functions"],
"no-invalid-this": "off",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-lonely-if": "off",
"no-loop-func": "error",
"no-magic-numbers": "off",
"no-mixed-operators": "off",
"no-mixed-requires": "error",
"no-multi-assign": "off",
"no-multi-spaces": "off",
"no-multi-str": "error",
"no-multiple-empty-lines": "error",
"no-native-reassign": "error",
"no-negated-condition": "off",
"no-negated-in-lhs": "error",
"no-nested-ternary": "off",
"no-new": "off",
"no-new-func": "error",
"no-new-object": "error",
"no-new-require": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-param-reassign": "off",
"no-path-concat": "error",
"no-plusplus": "off",
"no-process-env": "off",
"no-process-exit": "error",
"no-proto": "error",
"no-prototype-builtins": "error",
"no-restricted-globals": "error",
"no-restricted-imports": "error",
"no-restricted-modules": "error",
"no-restricted-properties": "error",
"no-restricted-syntax": "error",
"no-return-assign": "error",
"no-return-await": "off",
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow": "off",
"no-shadow-restricted-names": "error",
"no-sync": "error",
"no-tabs": "error",
"no-template-curly-in-string": "error",
"no-ternary": "off",
"no-throw-literal": "error",
"no-trailing-spaces": "off",
"no-undef-init": "error",
"no-undefined": "off",
"no-underscore-dangle": "off",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "off",
"no-unused-vars": "error",
"no-unused-expressions": "off",
"no-use-before-define": "off",
"no-useless-call": "error",
"no-useless-catch": "off",
"no-useless-computed-key": "error",
"no-useless-concat": "off",
"no-useless-constructor": "error",
"no-useless-escape": "off",
"no-useless-rename": "error",
"no-useless-return": "off",
"no-var": "off",
"no-void": "error",
"no-warning-comments": "off",
"no-whitespace-before-property": "error",
"no-with": "error",
"object-curly-newline": "off",
"object-curly-spacing": "off",
"object-property-newline": ["off", {
allowMultiplePropertiesPerLine: true,
}],
"object-shorthand": "off",
"one-var": "off",
"one-var-declaration-per-line": "off",
"operator-assignment": "off",
"operator-linebreak": "off",
"padded-blocks": "off",
"prefer-arrow-callback": "off",
"prefer-const": "error",
"prefer-destructuring": ["error", {
array: false,
object: false,
}],
"prefer-numeric-literals": "error",
"prefer-promise-reject-errors": "off",
"prefer-reflect": "off",
"prefer-rest-params": "off",
"prefer-spread": "off",
"prefer-template": "off",
"quote-props": "off",
quotes: "off",
radix: ["error", "always"],
"require-atomic-updates": "off",
"require-await": "error",
"require-jsdoc": "off",
"rest-spread-spacing": "error",
semi: "off",
"semi-spacing": "off",
"sort-imports": "off",
"sort-keys": "off",
"sort-vars": "off",
"space-before-blocks": "off",
"space-before-function-paren": "off",
"space-in-parens": "off",
"space-infix-ops": "off",
"space-unary-ops": "off",
"spaced-comment": "off",
strict: "off",
"symbol-description": "error",
"template-curly-spacing": "off",
"unicode-bom": ["error", "never"],
"valid-jsdoc": "off",
"vars-on-top": "off",
"wrap-iife": ["error", "any"],
"wrap-regex": "error",
"yield-star-spacing": "error",
yoda: "off",
},
}]; strophejs-3.1.0/examples/ 0000775 0000000 0000000 00000000000 14727753210 0015362 5 ustar 00root root 0000000 0000000 strophejs-3.1.0/examples/amd.html 0000664 0000000 0000000 00000001110 14727753210 0017002 0 ustar 00root root 0000000 0000000
Strophe.js AMD Example
strophejs-3.1.0/examples/attach/ 0000775 0000000 0000000 00000000000 14727753210 0016626 5 ustar 00root root 0000000 0000000 strophejs-3.1.0/examples/attach/README 0000664 0000000 0000000 00000002317 14727753210 0017511 0 ustar 00root root 0000000 0000000 This is an example of Strophe attaching to a pre-existing BOSH session
that is created externally. This example requires a bit more than
HTML and JavaScript. Specifically it contains a very simple Web
application written in Django which creates a BOSH session before
rendering the page.
Requirements:
* Django 1.0 (http://www.djangoproject.com)
* Twisted 8.1.x (http://twistedmatrix.com)
* Punjab 0.3 (http://code.stanziq.com/punjab)
Note that Twisted and Punjab are only used for small functions related
to JID and BOSH parsing.
How It Works:
The Django app contains one view which is tied to the root URL. This
view uses the BOSHClient class to start a BOSH session using the
settings from settings.py.
Once the connection is established, Django passes the JID, SID, and
RID for the BOSH session into the template engine and renders the
page.
The template assigns the JID, SID, and RID to global vars like so:
var BOSH_JID = {{ jid }};
var BOSH_SID = {{ sid }};
var BOSH_RID = {{ rid }};
The connection is attached to Strophe by calling
Strophe.Connection.attach() with this data and a connection callback
handler.
To show that the session is attached and works, a disco info ping is
done to jabber.org.
strophejs-3.1.0/examples/attach/__init__.py 0000664 0000000 0000000 00000000000 14727753210 0020725 0 ustar 00root root 0000000 0000000 strophejs-3.1.0/examples/attach/attacher/ 0000775 0000000 0000000 00000000000 14727753210 0020421 5 ustar 00root root 0000000 0000000 strophejs-3.1.0/examples/attach/attacher/__init__.py 0000664 0000000 0000000 00000000000 14727753210 0022520 0 ustar 00root root 0000000 0000000 strophejs-3.1.0/examples/attach/attacher/views.py 0000664 0000000 0000000 00000000733 14727753210 0022133 0 ustar 00root root 0000000 0000000 from django.http import HttpResponse
from django.template import Context, loader
from attach.settings import BOSH_SERVICE, JABBERID, PASSWORD
from attach.boshclient import BOSHClient
def index(request):
bc = BOSHClient(JABBERID, PASSWORD, BOSH_SERVICE)
bc.startSessionAndAuth()
t = loader.get_template("attacher/index.html")
c = Context({
'jid': bc.jabberid.full(),
'sid': bc.sid,
'rid': bc.rid,
})
return HttpResponse(t.render(c))
strophejs-3.1.0/examples/attach/boshclient.py 0000664 0000000 0000000 00000012266 14727753210 0021341 0 ustar 00root root 0000000 0000000 import sys, os
import httplib, urllib
import random, binascii
from urlparse import urlparse
from punjab.httpb import HttpbParse
from twisted.words.xish import domish
from twisted.words.protocols.jabber import jid
TLS_XMLNS = 'urn:ietf:params:xml:ns:xmpp-tls'
SASL_XMLNS = 'urn:ietf:params:xml:ns:xmpp-sasl'
BIND_XMLNS = 'urn:ietf:params:xml:ns:xmpp-bind'
SESSION_XMLNS = 'urn:ietf:params:xml:ns:xmpp-session'
class BOSHClient:
def __init__(self, jabberid, password, bosh_service):
self.rid = random.randint(0, 10000000)
self.jabberid = jid.internJID(jabberid)
self.password = password
self.authid = None
self.sid = None
self.logged_in = False
self.headers = {"Content-type": "text/xml",
"Accept": "text/xml"}
self.bosh_service = urlparse(bosh_service)
def buildBody(self, child=None):
"""Build a BOSH body.
"""
body = domish.Element(("http://jabber.org/protocol/httpbind", "body"))
body['content'] = 'text/xml; charset=utf-8'
self.rid = self.rid + 1
body['rid'] = str(self.rid)
body['sid'] = str(self.sid)
body['xml:lang'] = 'en'
if child is not None:
body.addChild(child)
return body
def sendBody(self, body):
"""Send the body.
"""
parser = HttpbParse(True)
# start new session
conn = httplib.HTTPConnection(self.bosh_service.netloc)
conn.request("POST", self.bosh_service.path,
body.toXml(), self.headers)
response = conn.getresponse()
data = ''
if response.status == 200:
data = response.read()
conn.close()
return parser.parse(data)
def startSessionAndAuth(self, hold='1', wait='70'):
# Create a session
# create body
body = domish.Element(("http://jabber.org/protocol/httpbind", "body"))
body['content'] = 'text/xml; charset=utf-8'
body['hold'] = hold
body['rid'] = str(self.rid)
body['to'] = self.jabberid.host
body['wait'] = wait
body['window'] = '5'
body['xml:lang'] = 'en'
retb, elems = self.sendBody(body)
if type(retb) != str and retb.hasAttribute('authid') and \
retb.hasAttribute('sid'):
self.authid = retb['authid']
self.sid = retb['sid']
# go ahead and auth
auth = domish.Element((SASL_XMLNS, 'auth'))
auth['mechanism'] = 'PLAIN'
# TODO: add authzid
if auth['mechanism'] == 'PLAIN':
auth_str = ""
auth_str += "\000"
auth_str += self.jabberid.user.encode('utf-8')
auth_str += "\000"
try:
auth_str += self.password.encode('utf-8').strip()
except UnicodeDecodeError:
auth_str += self.password.decode('latin1') \
.encode('utf-8').strip()
auth.addContent(binascii.b2a_base64(auth_str))
retb, elems = self.sendBody(self.buildBody(auth))
if len(elems) == 0:
# poll for data
retb, elems = self.sendBody(self.buildBody())
if len(elems) > 0:
if elems[0].name == 'success':
retb, elems = self.sendBody(self.buildBody())
has_bind = False
for child in elems[0].children:
if child.name == 'bind':
has_bind = True
break
if has_bind:
iq = domish.Element(('jabber:client', 'iq'))
iq['type'] = 'set'
iq.addUniqueId()
iq.addElement('bind')
iq.bind['xmlns'] = BIND_XMLNS
if self.jabberid.resource:
iq.bind.addElement('resource')
iq.bind.resource.addContent(
self.jabberid.resource)
retb, elems = self.sendBody(self.buildBody(iq))
if type(retb) != str and retb.name == 'body':
# send session
iq = domish.Element(('jabber:client', 'iq'))
iq['type'] = 'set'
iq.addUniqueId()
iq.addElement('session')
iq.session['xmlns'] = SESSION_XMLNS
retb, elems = self.sendBody(self.buildBody(iq))
# did not bind, TODO - add a retry?
if type(retb) != str and retb.name == 'body':
self.logged_in = True
# bump up the rid, punjab already
# received self.rid
self.rid += 1
if __name__ == '__main__':
USERNAME = sys.argv[1]
PASSWORD = sys.argv[2]
SERVICE = sys.argv[3]
c = BOSHClient(USERNAME, PASSWORD, SERVICE)
c.startSessionAndAuth()
print c.logged_in
strophejs-3.1.0/examples/attach/manage.py 0000775 0000000 0000000 00000001042 14727753210 0020430 0 ustar 00root root 0000000 0000000 #!/usr/bin/env python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
sys.exit(1)
if __name__ == "__main__":
execute_manager(settings)
strophejs-3.1.0/examples/attach/settings.py 0000664 0000000 0000000 00000005544 14727753210 0021050 0 ustar 00root root 0000000 0000000 # Django settings for attach project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
('Some Body', 'romeo@example.com'),
)
MANAGERS = ADMINS
DATABASE_ENGINE = 'sqlite3' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = '/path/to/attach.db' # Or path to database file if using sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Denver'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = ''
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/'
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'asdf'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)
ROOT_URLCONF = 'attach.urls'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'/path/to/attach/templates',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'attach.attacher',
)
BOSH_SERVICE = 'http://example.com/xmpp-httpbind'
JABBERID = 'romeo@example.com/bosh'
PASSWORD = 'juliet.is.hawt'
strophejs-3.1.0/examples/attach/templates/ 0000775 0000000 0000000 00000000000 14727753210 0020624 5 ustar 00root root 0000000 0000000 strophejs-3.1.0/examples/attach/templates/attacher/ 0000775 0000000 0000000 00000000000 14727753210 0022417 5 ustar 00root root 0000000 0000000 strophejs-3.1.0/examples/attach/templates/attacher/index.html 0000664 0000000 0000000 00000005442 14727753210 0024421 0 ustar 00root root 0000000 0000000
Strophe Attach Example
Strophe Attach Example
This example shows how to attach to an existing BOSH session with
Strophe.
Log