@keplr-wallet/common 0.10.12 → 0.10.13-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const index_1 = require("./index");
13
+ describe("Test escapeHTML", () => {
14
+ test("escapeHTML should escape <, >, &", () => __awaiter(void 0, void 0, void 0, function* () {
15
+ expect(index_1.escapeHTML("<, >, &, ' and \"")).toBe(`\\u003c, \\u003e, \\u0026, ' and "`);
16
+ expect(index_1.escapeHTML("<, >, &, ' and \" and <, >, &, ' and \"")).toBe(`\\u003c, \\u003e, \\u0026, ' and " and \\u003c, \\u003e, \\u0026, ' and "`);
17
+ }));
18
+ test("unescapeHTML should escape <, >, &", () => __awaiter(void 0, void 0, void 0, function* () {
19
+ expect(index_1.unescapeHTML(`\\u003c, \\u003e, \\u0026, ' and "`)).toBe("<, >, &, ' and \"");
20
+ expect(index_1.unescapeHTML(`\\u003c, \\u003e, \\u0026, ' and " and \\u003c, \\u003e, \\u0026, ' and "`)).toBe("<, >, &, ' and \" and <, >, &, ' and \"");
21
+ }));
22
+ });
23
+ //# sourceMappingURL=escape.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"escape.spec.js","sourceRoot":"","sources":["../../src/escape/escape.spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,mCAAmD;AAEnD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,IAAI,CAAC,kCAAkC,EAAE,GAAS,EAAE;QAClD,MAAM,CAAC,kBAAU,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAC1C,oCAAoC,CACrC,CAAC;QAEF,MAAM,CAAC,kBAAU,CAAC,yCAAyC,CAAC,CAAC,CAAC,IAAI,CAChE,2EAA2E,CAC5E,CAAC;IACJ,CAAC,CAAA,CAAC,CAAC;IAEH,IAAI,CAAC,oCAAoC,EAAE,GAAS,EAAE;QACpD,MAAM,CAAC,oBAAY,CAAC,oCAAoC,CAAC,CAAC,CAAC,IAAI,CAC7D,mBAAmB,CACpB,CAAC;QAEF,MAAM,CACJ,oBAAY,CACV,2EAA2E,CAC5E,CACF,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAC;IACpD,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Escapes <,>,& in string.
3
+ * Golang's json marshaller escapes <,>,& by default.
4
+ * However, because JS doesn't do that by default, to match the sign doc with cosmos-sdk,
5
+ * we should escape <,>,& in string manually.
6
+ * @param str
7
+ */
8
+ export declare function escapeHTML(str: string): string;
9
+ /**
10
+ * Unescapes \u003c/(<),\u003e(>),\u0026(&) in string.
11
+ * Golang's json marshaller escapes <,>,& by default, whilst for most of the users, such escape characters are unfamiliar.
12
+ * This function can be used to show the escaped characters with more familiar characters.
13
+ * @param str
14
+ */
15
+ export declare function unescapeHTML(str: string): string;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unescapeHTML = exports.escapeHTML = void 0;
4
+ /**
5
+ * Escapes <,>,& in string.
6
+ * Golang's json marshaller escapes <,>,& by default.
7
+ * However, because JS doesn't do that by default, to match the sign doc with cosmos-sdk,
8
+ * we should escape <,>,& in string manually.
9
+ * @param str
10
+ */
11
+ function escapeHTML(str) {
12
+ return str
13
+ .replace(/</g, "\\u003c")
14
+ .replace(/>/g, "\\u003e")
15
+ .replace(/&/g, "\\u0026");
16
+ }
17
+ exports.escapeHTML = escapeHTML;
18
+ /**
19
+ * Unescapes \u003c/(<),\u003e(>),\u0026(&) in string.
20
+ * Golang's json marshaller escapes <,>,& by default, whilst for most of the users, such escape characters are unfamiliar.
21
+ * This function can be used to show the escaped characters with more familiar characters.
22
+ * @param str
23
+ */
24
+ function unescapeHTML(str) {
25
+ return str
26
+ .replace(/\\u003c/g, "<")
27
+ .replace(/\\u003e/g, ">")
28
+ .replace(/\\u0026/g, "&");
29
+ }
30
+ exports.unescapeHTML = unescapeHTML;
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/escape/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,GAAW;IACpC,OAAO,GAAG;SACP,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC;SACxB,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC;SACxB,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;AAC9B,CAAC;AALD,gCAKC;AAED;;;;;GAKG;AACH,SAAgB,YAAY,CAAC,GAAW;IACtC,OAAO,GAAG;SACP,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;SACxB,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;SACxB,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;AAC9B,CAAC;AALD,oCAKC"}
package/build/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export * from "./kv-store";
2
2
  export * from "./denom";
3
3
  export * from "./mobx";
4
4
  export * from "./utils";
5
+ export * from "./escape";
package/build/index.js CHANGED
@@ -14,4 +14,5 @@ __exportStar(require("./kv-store"), exports);
14
14
  __exportStar(require("./denom"), exports);
15
15
  __exportStar(require("./mobx"), exports);
16
16
  __exportStar(require("./utils"), exports);
17
+ __exportStar(require("./escape"), exports);
17
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA2B;AAC3B,0CAAwB;AACxB,yCAAuB;AACvB,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA2B;AAC3B,0CAAwB;AACxB,yCAAuB;AACvB,0CAAwB;AACxB,2CAAyB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keplr-wallet/common",
3
- "version": "0.10.12",
3
+ "version": "0.10.13-rc.0",
4
4
  "main": "build/index.js",
5
5
  "author": "chainapsis",
6
6
  "license": "Apache-2.0",
@@ -17,9 +17,9 @@
17
17
  "lint-fix": "eslint --fix \"src/**/*\" && prettier --write \"src/**/*\""
18
18
  },
19
19
  "dependencies": {
20
- "@keplr-wallet/crypto": "0.10.12",
20
+ "@keplr-wallet/crypto": "0.10.13-rc.0",
21
21
  "buffer": "^6.0.3",
22
22
  "delay": "^4.4.0"
23
23
  },
24
- "gitHead": "d57ab06096011a01477265ca20cb84dd345bc8f4"
24
+ "gitHead": "143e56050f954e25216caa24f74f583136b3d3f4"
25
25
  }
@@ -0,0 +1,25 @@
1
+ import { escapeHTML, unescapeHTML } from "./index";
2
+
3
+ describe("Test escapeHTML", () => {
4
+ test("escapeHTML should escape <, >, &", async () => {
5
+ expect(escapeHTML("<, >, &, ' and \"")).toBe(
6
+ `\\u003c, \\u003e, \\u0026, ' and "`
7
+ );
8
+
9
+ expect(escapeHTML("<, >, &, ' and \" and <, >, &, ' and \"")).toBe(
10
+ `\\u003c, \\u003e, \\u0026, ' and " and \\u003c, \\u003e, \\u0026, ' and "`
11
+ );
12
+ });
13
+
14
+ test("unescapeHTML should escape <, >, &", async () => {
15
+ expect(unescapeHTML(`\\u003c, \\u003e, \\u0026, ' and "`)).toBe(
16
+ "<, >, &, ' and \""
17
+ );
18
+
19
+ expect(
20
+ unescapeHTML(
21
+ `\\u003c, \\u003e, \\u0026, ' and " and \\u003c, \\u003e, \\u0026, ' and "`
22
+ )
23
+ ).toBe("<, >, &, ' and \" and <, >, &, ' and \"");
24
+ });
25
+ });
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Escapes <,>,& in string.
3
+ * Golang's json marshaller escapes <,>,& by default.
4
+ * However, because JS doesn't do that by default, to match the sign doc with cosmos-sdk,
5
+ * we should escape <,>,& in string manually.
6
+ * @param str
7
+ */
8
+ export function escapeHTML(str: string): string {
9
+ return str
10
+ .replace(/</g, "\\u003c")
11
+ .replace(/>/g, "\\u003e")
12
+ .replace(/&/g, "\\u0026");
13
+ }
14
+
15
+ /**
16
+ * Unescapes \u003c/(<),\u003e(>),\u0026(&) in string.
17
+ * Golang's json marshaller escapes <,>,& by default, whilst for most of the users, such escape characters are unfamiliar.
18
+ * This function can be used to show the escaped characters with more familiar characters.
19
+ * @param str
20
+ */
21
+ export function unescapeHTML(str: string): string {
22
+ return str
23
+ .replace(/\\u003c/g, "<")
24
+ .replace(/\\u003e/g, ">")
25
+ .replace(/\\u0026/g, "&");
26
+ }
package/src/index.ts CHANGED
@@ -2,3 +2,4 @@ export * from "./kv-store";
2
2
  export * from "./denom";
3
3
  export * from "./mobx";
4
4
  export * from "./utils";
5
+ export * from "./escape";