Socket
Socket
Sign inDemoInstall

i18next-http-backend

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18next-http-backend - npm Package Compare versions

Comparing version 0.0.1-security to 1.0.0

cjs/index.js

71

package.json
{
"name": "i18next-http-backend",
"version": "0.0.1-security",
"description": "security holding package",
"repository": "npm/security-holder",
"dependencies": {}
"version": "1.0.0",
"private": false,
"type": "module",
"main": "./cjs/index.js",
"exports": {
".": {
"require": "./cjs/index.js",
"default": "./lib/index.js"
}
},
"module": "./lib/index.js",
"dependencies": {
"node-fetch": "2.6.0"
},
"types": "./index.d.ts",
"devDependencies": {
"@babel/cli": "7.8.4",
"@babel/core": "7.9.0",
"@babel/preset-env": "7.9.5",
"babel-plugin-add-module-exports": "1.0.2",
"browserify": "16.5.1",
"eslint": "6.8.0",
"eslint-config-standard": "14.1.1",
"eslint-plugin-import": "2.20.1",
"eslint-plugin-node": "11.0.0",
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-require-path-exists": "1.1.9",
"eslint-plugin-standard": "4.0.1",
"expect.js": "0.3.1",
"i18next": "19.4.1",
"json-server": "0.16.1",
"json5": "2.1.3",
"mocha": "7.1.1",
"uglify-js": "3.8.1",
"xmlhttprequest": "1.8.0"
},
"description": "i18next-http-backend is a backend layer for i18next using in node.js, in the browser and for deno.",
"keywords": [
"i18next",
"i18next-backend",
"i18next-http-backend"
],
"homepage": "https://github.com/i18next/i18next-http-backend",
"repository": {
"type": "git",
"url": "git@github.com:i18next/i18next-http-backend.git"
},
"bugs": {
"url": "https://github.com/i18next/i18next-http-backend/issues"
},
"licenses": [
{
"type": "MIT",
"url": "https://raw.github.com/i18next/i18next-http-backend/master/licence"
}
],
"scripts": {
"lint": "eslint .",
"compile": "rm -rf cjs && mkdir cjs && babel lib -d cjs --presets=@babel/preset-env --plugins=add-module-exports && echo '{\"type\":\"commonjs\"}' > cjs/package.json",
"browser": "browserify --standalone i18nextHttpBackend cjs/index.js -o i18nextHttpBackend.js && uglifyjs i18nextHttpBackend.js --compress --mangle -o i18nextHttpBackend.min.js",
"build": "npm run compile && npm run browser",
"test:xmlhttpreq": "mocha test -R spec --require test/fixtures/xmlHttpRequest.cjs --exit --experimental-modules",
"test:fetch": "mocha test -R spec --exit --experimental-modules",
"test": "npm run lint && npm run build && npm run test:fetch && npm run test:xmlhttpreq",
"preversion": "npm run test && npm run build && git push",
"postversion": "git push && git push --tags"
}
}

@@ -1,9 +0,139 @@

# Security holding package
# Introduction
This package name is not currently in use, but was formerly occupied
by another package. To avoid malicious use, npm is hanging on to the
package name, but loosely, and we'll probably give it to you if you
want it.
[![Travis](https://img.shields.io/travis/i18next/i18next-http-backend/master.svg?style=flat-square)](https://travis-ci.org/i18next/i18next-http-backend)
[![npm version](https://img.shields.io/npm/v/i18next-http-backend.svg?style=flat-square)](https://www.npmjs.com/package/i18next-http-backend)
You may adopt this package by contacting support@npmjs.com and
requesting the name.
This is a simple i18next backend to be used in node.js, in the browser and for deno. It will load resources from a backend server using the XMLHttpRequest or the fetch API.
# Getting started
Source can be loaded via [npm](https://www.npmjs.com/package/i18next-http-backend) or [downloaded](https://github.com/i18next/i18next-http-backend/blob/master/i18nextHttpApiBackend.min.js) from this repo.
```
# npm package
$ npm install i18next-http-backend
```
Wiring up:
```js
import i18next from 'i18next';
import HttpApi from 'i18next-http-backend';
i18next.use(HttpApi).init(i18nextOptions);
```
- As with all modules you can either pass the constructor function (class) to the i18next.use or a concrete instance.
- If you don't use a module loader it will be added to `window.i18nextHttpBackend`
## Backend Options
```js
{
// path where resources get loaded from, or a function
// returning a path:
// function(lngs, namespaces) { return customPath; }
// the returned path will interpolate lng, ns if provided like giving a static path
loadPath: '/locales/{{lng}}/{{ns}}.json',
// path to post missing resources
addPath: 'locales/add/{{lng}}/{{ns}}',
// your backend server supports multiloading
// /locales/resources.json?lng=de+en&ns=ns1+ns2
// Adapter is needed to enable MultiLoading https://github.com/i18next/i18next-multiload-backend-adapter
// Returned JSON structure in this case is
// {
// lang : {
// namespaceA: {},
// namespaceB: {},
// ...etc
// }
// }
allowMultiLoading: false, // set loadPath: '/locales/resources.json?lng={{lng}}&ns={{ns}}' to adapt to multiLoading
// parse data after it has been fetched
// in example use https://www.npmjs.com/package/json5
// here it removes the letter a from the json (bad idea)
parse: function(data) { return data.replace(/a/g, ''); },
//parse data before it has been sent by addPath
parsePayload: function(namespace, key, fallbackValue) { return { key } },
// allow cross domain requests
crossDomain: false,
// allow credentials on cross domain requests
withCredentials: false,
// overrideMimeType sets request.overrideMimeType("application/json")
overrideMimeType: false,
// custom request headers sets request.setRequestHeader(key, value)
customHeaders: {
authorization: 'foo',
// ...
},
requestOptions: { // used for fetch
mode: 'cors',
credentials: 'same-origin',
cache: 'default'
}
// define a custom request function
// can be used to support XDomainRequest in IE 8 and 9
//
// 'url' will be passed the value of 'loadPath'
// 'options' will be this entire options object
// 'callback' is a function that takes two parameters, 'data' and 'HttpApi'.
// 'data' should be the key:value translation pairs for the
// requested language and namespace, or null in case of an error.
// 'HttpApi' should be a status object, e.g. { status: 200 }
// 'payload' will be a key:value object used when saving missing translations
request: function (options, url, payload, callback) {},
// adds parameters to resource URL. 'example.com' -> 'example.com?v=1.3.5'
queryStringParams: { v: '1.3.5' },
reloadInterval: false // can be used to reload resources in a specific interval (useful in server environments)
}
```
Options can be passed in:
**preferred** - by setting options.backend in i18next.init:
```js
import i18next from 'i18next';
import HttpApi from 'i18next-http-backend';
i18next.use(HttpApi).init({
backend: options,
});
```
on construction:
```js
import HttpApi from 'i18next-http-backend';
const HttpApi = new HttpApi(null, options);
```
via calling init:
```js
import HttpApi from 'i18next-http-backend';
const HttpApi = new HttpApi();
HttpApi.init(null, options);
```
---
<h3 align="center">Gold Sponsors</h3>
<p align="center">
<a href="https://locize.com/" target="_blank">
<img src="https://raw.githubusercontent.com/i18next/i18next/master/assets/locize_sponsor_240.gif" width="240px">
</a>
</p>
my-test-package/node_modules/@evatester/foo4/package.json
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc