@polkadot/extension-inject 0.44.9 → 0.45.2

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.
package/bundle.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import type { Injected, InjectOptions } from './types';
2
- export { packageInfo } from './packageInfo';
1
+ import type { Injected, InjectOptions } from './types.js';
2
+ export { packageInfo } from './packageInfo.js';
3
3
  export declare function injectExtension(enable: (origin: string) => Promise<Injected>, { name, version }: InjectOptions): void;
package/bundle.js CHANGED
@@ -1,51 +1,25 @@
1
- // Copyright 2019-2023 @polkadot/extension-inject authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- import { cyrb53 } from "./cyrb53.js";
5
- export { packageInfo } from "./packageInfo.js";
6
-
7
- // setting for new-style connect (more-secure with no details exposed without
8
- // user acknowledgement, however slightly less-compatible with all dapps, some
9
- // may have not upgraded and don't have access to the latest interfaces)
10
- //
11
- // NOTE: In future versions this will be made the default
1
+ import { cyrb53 } from './cyrb53.js';
2
+ export { packageInfo } from './packageInfo.js';
12
3
  const IS_CONNECT_CAPABLE = false;
13
-
14
- // It is recommended to always use the function below to shield the extension and dapp from
15
- // any future changes. The exposed interface will manage access between the 2 environments,
16
- // be it via window (current), postMessage (under consideration) or any other mechanism
17
- export function injectExtension(enable, {
18
- name,
19
- version
20
- }) {
21
- // small helper with the typescript types, just cast window
22
- const windowInject = window;
23
-
24
- // don't clobber the existing object, we will add it (or create as needed)
25
- windowInject.injectedWeb3 = windowInject.injectedWeb3 || {};
26
- if (IS_CONNECT_CAPABLE) {
27
- // expose our extension on the window object, new-style with connect(origin)
28
- windowInject.injectedWeb3[cyrb53(`${name}/${version}`)] = {
29
- connect: origin => enable(origin).then(({
30
- accounts,
31
- metadata,
32
- provider,
33
- signer
34
- }) => ({
35
- accounts,
36
- metadata,
37
- name,
38
- provider,
39
- signer,
40
- version
41
- })),
42
- enable: () => Promise.reject(new Error('This extension does not have support for enable(...), rather is only supports the new connect(...) variant (no extension name/version metadata without specific user-approval)'))
43
- };
44
- } else {
45
- // expose our extension on the window object, old-style with enable(origin)
46
- windowInject.injectedWeb3[name] = {
47
- enable: origin => enable(origin),
48
- version
49
- };
50
- }
4
+ export function injectExtension(enable, { name, version }) {
5
+ // small helper with the typescript types, just cast window
6
+ const windowInject = window;
7
+ // don't clobber the existing object, we will add it (or create as needed)
8
+ windowInject.injectedWeb3 = windowInject.injectedWeb3 || {};
9
+ if (IS_CONNECT_CAPABLE) {
10
+ // expose our extension on the window object, new-style with connect(origin)
11
+ windowInject.injectedWeb3[cyrb53(`${name}/${version}`)] = {
12
+ connect: (origin) => enable(origin).then(({ accounts, metadata, provider, signer }) => ({
13
+ accounts, metadata, name, provider, signer, version
14
+ })),
15
+ enable: () => Promise.reject(new Error('This extension does not have support for enable(...), rather is only supports the new connect(...) variant (no extension name/version metadata without specific user-approval)'))
16
+ };
17
+ }
18
+ else {
19
+ // expose our extension on the window object, old-style with enable(origin)
20
+ windowInject.injectedWeb3[name] = {
21
+ enable: (origin) => enable(origin),
22
+ version
23
+ };
24
+ }
51
25
  }
package/chrome.js CHANGED
@@ -1,5 +1,2 @@
1
- // Copyright 2019-2023 @polkadot/extension-inject authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
1
  import { extractGlobal, xglobal } from '@polkadot/x-global';
5
2
  export const chrome = extractGlobal('chrome', xglobal.browser);
package/cjs/bundle.js CHANGED
@@ -1,66 +1,30 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.injectExtension = injectExtension;
7
- Object.defineProperty(exports, "packageInfo", {
8
- enumerable: true,
9
- get: function () {
10
- return _packageInfo.packageInfo;
11
- }
12
- });
13
- var _cyrb = require("./cyrb53");
14
- var _packageInfo = require("./packageInfo");
15
- // Copyright 2019-2023 @polkadot/extension-inject authors & contributors
16
- // SPDX-License-Identifier: Apache-2.0
17
-
18
- // setting for new-style connect (more-secure with no details exposed without
19
- // user acknowledgement, however slightly less-compatible with all dapps, some
20
- // may have not upgraded and don't have access to the latest interfaces)
21
- //
22
- // NOTE: In future versions this will be made the default
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.injectExtension = exports.packageInfo = void 0;
4
+ const cyrb53_js_1 = require("./cyrb53.js");
5
+ var packageInfo_js_1 = require("./packageInfo.js");
6
+ Object.defineProperty(exports, "packageInfo", { enumerable: true, get: function () { return packageInfo_js_1.packageInfo; } });
23
7
  const IS_CONNECT_CAPABLE = false;
24
-
25
- // It is recommended to always use the function below to shield the extension and dapp from
26
- // any future changes. The exposed interface will manage access between the 2 environments,
27
- // be it via window (current), postMessage (under consideration) or any other mechanism
28
- function injectExtension(enable, _ref) {
29
- let {
30
- name,
31
- version
32
- } = _ref;
33
- // small helper with the typescript types, just cast window
34
- const windowInject = window;
35
-
36
- // don't clobber the existing object, we will add it (or create as needed)
37
- windowInject.injectedWeb3 = windowInject.injectedWeb3 || {};
38
- if (IS_CONNECT_CAPABLE) {
39
- // expose our extension on the window object, new-style with connect(origin)
40
- windowInject.injectedWeb3[(0, _cyrb.cyrb53)(`${name}/${version}`)] = {
41
- connect: origin => enable(origin).then(_ref2 => {
42
- let {
43
- accounts,
44
- metadata,
45
- provider,
46
- signer
47
- } = _ref2;
48
- return {
49
- accounts,
50
- metadata,
51
- name,
52
- provider,
53
- signer,
54
- version
8
+ function injectExtension(enable, { name, version }) {
9
+ // small helper with the typescript types, just cast window
10
+ const windowInject = window;
11
+ // don't clobber the existing object, we will add it (or create as needed)
12
+ windowInject.injectedWeb3 = windowInject.injectedWeb3 || {};
13
+ if (IS_CONNECT_CAPABLE) {
14
+ // expose our extension on the window object, new-style with connect(origin)
15
+ windowInject.injectedWeb3[(0, cyrb53_js_1.cyrb53)(`${name}/${version}`)] = {
16
+ connect: (origin) => enable(origin).then(({ accounts, metadata, provider, signer }) => ({
17
+ accounts, metadata, name, provider, signer, version
18
+ })),
19
+ enable: () => Promise.reject(new Error('This extension does not have support for enable(...), rather is only supports the new connect(...) variant (no extension name/version metadata without specific user-approval)'))
55
20
  };
56
- }),
57
- enable: () => Promise.reject(new Error('This extension does not have support for enable(...), rather is only supports the new connect(...) variant (no extension name/version metadata without specific user-approval)'))
58
- };
59
- } else {
60
- // expose our extension on the window object, old-style with enable(origin)
61
- windowInject.injectedWeb3[name] = {
62
- enable: origin => enable(origin),
63
- version
64
- };
65
- }
66
- }
21
+ }
22
+ else {
23
+ // expose our extension on the window object, old-style with enable(origin)
24
+ windowInject.injectedWeb3[name] = {
25
+ enable: (origin) => enable(origin),
26
+ version
27
+ };
28
+ }
29
+ }
30
+ exports.injectExtension = injectExtension;
package/cjs/chrome.js CHANGED
@@ -1,12 +1,5 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.chrome = void 0;
7
- var _xGlobal = require("@polkadot/x-global");
8
- // Copyright 2019-2023 @polkadot/extension-inject authors & contributors
9
- // SPDX-License-Identifier: Apache-2.0
10
-
11
- const chrome = (0, _xGlobal.extractGlobal)('chrome', _xGlobal.xglobal.browser);
12
- exports.chrome = chrome;
4
+ const x_global_1 = require("@polkadot/x-global");
5
+ exports.chrome = (0, x_global_1.extractGlobal)('chrome', x_global_1.xglobal.browser);
package/cjs/crossenv.js CHANGED
@@ -1,7 +1,4 @@
1
1
  "use strict";
2
-
3
- var _xGlobal = require("@polkadot/x-global");
4
- // Copyright 2019-2023 @polkadot/extension-inject authors & contributors
5
- // SPDX-License-Identifier: Apache-2.0
6
-
7
- (0, _xGlobal.exposeGlobal)('chrome', _xGlobal.xglobal.browser);
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const x_global_1 = require("@polkadot/x-global");
4
+ (0, x_global_1.exposeGlobal)('chrome', x_global_1.xglobal.browser);
package/cjs/cyrb53.js CHANGED
@@ -1,37 +1,17 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.cyrb53 = cyrb53;
7
- // Copyright 2019-2023 @polkadot/extension-inject authors & contributors
8
- // SPDX-License-Identifier: Apache-2.0
9
-
10
- // cyrb53 (c) 2018 bryc (github.com/bryc)
11
- // A fast and simple hash function with decent collision resistance.
12
- // Largely inspired by MurmurHash2/3, but with a focus on speed/simplicity.
13
- // Public domain. Attribution appreciated.
14
- //
15
- // From https://github.com/bryc/code/blob/fed42df9db547493452e32375c93d7854383e480/jshash/experimental/cyrb53.js
16
- // As shared in https://stackoverflow.com/a/52171480
17
- //
18
- // Small changes made to the code as linked above:
19
- // . - Seed value is required (set as Date.now() in usage, could change)
20
- // - Return value is a hex string (as per comment in SO answer)
21
- // - TS typings added
22
- // - Non-intrusive coding-style variable declaration changes
23
- function cyrb53(input) {
24
- let seed = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Date.now();
25
- let h1 = 0xdeadbeef ^ seed;
26
- let h2 = 0x41c6ce57 ^ seed;
27
- for (let i = 0; i < input.length; i++) {
28
- const ch = input.charCodeAt(i);
29
- h1 = Math.imul(h1 ^ ch, 2654435761);
30
- h2 = Math.imul(h2 ^ ch, 1597334677);
31
- }
32
- h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
33
- h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
34
-
35
- // https://stackoverflow.com/a/52171480
36
- return (h2 >>> 0).toString(16).padStart(8, '0') + (h1 >>> 0).toString(16).padStart(8, '0');
37
- }
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.cyrb53 = void 0;
4
+ function cyrb53(input, seed = Date.now()) {
5
+ let h1 = 0xdeadbeef ^ seed;
6
+ let h2 = 0x41c6ce57 ^ seed;
7
+ for (let i = 0; i < input.length; i++) {
8
+ const ch = input.charCodeAt(i);
9
+ h1 = Math.imul(h1 ^ ch, 2654435761);
10
+ h2 = Math.imul(h2 ^ ch, 1597334677);
11
+ }
12
+ h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
13
+ h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
14
+ // https://stackoverflow.com/a/52171480
15
+ return (h2 >>> 0).toString(16).padStart(8, '0') + (h1 >>> 0).toString(16).padStart(8, '0');
16
+ }
17
+ exports.cyrb53 = cyrb53;
@@ -1,11 +1,3 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- // Copyright 2017-2023 @polkadot/extension-inject authors & contributors
8
- // SPDX-License-Identifier: Apache-2.0
9
- // Empty template, auto-generated by @polkadot/dev
10
- var _default = [];
11
- exports.default = _default;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = [];
@@ -1,12 +1,7 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _util = require("@polkadot/util");
5
- var _detectOther = _interopRequireDefault(require("./detectOther"));
6
- var _packageInfo = require("./packageInfo");
7
- // Copyright 2017-2023 @polkadot/extension-inject authors & contributors
8
- // SPDX-License-Identifier: Apache-2.0
9
-
10
- // Do not edit, auto-generated by @polkadot/dev
11
-
12
- (0, _util.detectPackage)(_packageInfo.packageInfo, null, _detectOther.default);
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const util_1 = require("@polkadot/util");
5
+ const detectOther_js_1 = tslib_1.__importDefault(require("./detectOther.js"));
6
+ const packageInfo_js_1 = require("./packageInfo.js");
7
+ (0, util_1.detectPackage)(packageInfo_js_1.packageInfo, null, detectOther_js_1.default);
package/cjs/index.js CHANGED
@@ -1,16 +1,4 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _bundle = require("./bundle");
7
- Object.keys(_bundle).forEach(function (key) {
8
- if (key === "default" || key === "__esModule") return;
9
- if (key in exports && exports[key] === _bundle[key]) return;
10
- Object.defineProperty(exports, key, {
11
- enumerable: true,
12
- get: function () {
13
- return _bundle[key];
14
- }
15
- });
16
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./bundle.js"), exports);
@@ -1,18 +1,4 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.packageInfo = void 0;
7
- // Copyright 2017-2023 @polkadot/extension-inject authors & contributors
8
- // SPDX-License-Identifier: Apache-2.0
9
-
10
- // Do not edit, auto-generated by @polkadot/dev
11
-
12
- const packageInfo = {
13
- name: '@polkadot/extension-inject',
14
- path: typeof __dirname === 'string' ? __dirname : 'auto',
15
- type: 'cjs',
16
- version: '0.44.9'
17
- };
18
- exports.packageInfo = packageInfo;
4
+ exports.packageInfo = { name: '@polkadot/extension-inject', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '0.45.2' };
package/cjs/types.js CHANGED
@@ -1 +1,2 @@
1
- "use strict";
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/crossenv.js CHANGED
@@ -1,5 +1,2 @@
1
- // Copyright 2019-2023 @polkadot/extension-inject authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
1
  import { exposeGlobal, xglobal } from '@polkadot/x-global';
5
2
  exposeGlobal('chrome', xglobal.browser);
package/cyrb53.js CHANGED
@@ -1,30 +1,13 @@
1
- // Copyright 2019-2023 @polkadot/extension-inject authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- // cyrb53 (c) 2018 bryc (github.com/bryc)
5
- // A fast and simple hash function with decent collision resistance.
6
- // Largely inspired by MurmurHash2/3, but with a focus on speed/simplicity.
7
- // Public domain. Attribution appreciated.
8
- //
9
- // From https://github.com/bryc/code/blob/fed42df9db547493452e32375c93d7854383e480/jshash/experimental/cyrb53.js
10
- // As shared in https://stackoverflow.com/a/52171480
11
- //
12
- // Small changes made to the code as linked above:
13
- // . - Seed value is required (set as Date.now() in usage, could change)
14
- // - Return value is a hex string (as per comment in SO answer)
15
- // - TS typings added
16
- // - Non-intrusive coding-style variable declaration changes
17
1
  export function cyrb53(input, seed = Date.now()) {
18
- let h1 = 0xdeadbeef ^ seed;
19
- let h2 = 0x41c6ce57 ^ seed;
20
- for (let i = 0; i < input.length; i++) {
21
- const ch = input.charCodeAt(i);
22
- h1 = Math.imul(h1 ^ ch, 2654435761);
23
- h2 = Math.imul(h2 ^ ch, 1597334677);
24
- }
25
- h1 = Math.imul(h1 ^ h1 >>> 16, 2246822507) ^ Math.imul(h2 ^ h2 >>> 13, 3266489909);
26
- h2 = Math.imul(h2 ^ h2 >>> 16, 2246822507) ^ Math.imul(h1 ^ h1 >>> 13, 3266489909);
27
-
28
- // https://stackoverflow.com/a/52171480
29
- return (h2 >>> 0).toString(16).padStart(8, '0') + (h1 >>> 0).toString(16).padStart(8, '0');
2
+ let h1 = 0xdeadbeef ^ seed;
3
+ let h2 = 0x41c6ce57 ^ seed;
4
+ for (let i = 0; i < input.length; i++) {
5
+ const ch = input.charCodeAt(i);
6
+ h1 = Math.imul(h1 ^ ch, 2654435761);
7
+ h2 = Math.imul(h2 ^ ch, 1597334677);
8
+ }
9
+ h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507) ^ Math.imul(h2 ^ (h2 >>> 13), 3266489909);
10
+ h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507) ^ Math.imul(h1 ^ (h1 >>> 13), 3266489909);
11
+ // https://stackoverflow.com/a/52171480
12
+ return (h2 >>> 0).toString(16).padStart(8, '0') + (h1 >>> 0).toString(16).padStart(8, '0');
30
13
  }
package/detectOther.js CHANGED
@@ -1,6 +1 @@
1
- // Copyright 2017-2023 @polkadot/extension-inject authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- // Empty template, auto-generated by @polkadot/dev
5
-
6
1
  export default [];
package/detectPackage.js CHANGED
@@ -1,9 +1,4 @@
1
- // Copyright 2017-2023 @polkadot/extension-inject authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- // Do not edit, auto-generated by @polkadot/dev
5
-
6
1
  import { detectPackage } from '@polkadot/util';
7
- import others from "./detectOther.js";
8
- import { packageInfo } from "./packageInfo.js";
2
+ import others from './detectOther.js';
3
+ import { packageInfo } from './packageInfo.js';
9
4
  detectPackage(packageInfo, null, others);
package/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from './bundle';
1
+ export * from './bundle.js';
package/index.js CHANGED
@@ -1,7 +1 @@
1
- // Copyright 2019-2023 @polkadot/extension-inject authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- // Since we inject into pages, we skip this
5
- // import './detectPackage';
6
-
7
- export * from "./bundle.js";
1
+ export * from './bundle.js';
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "sideEffects": true,
16
16
  "type": "module",
17
- "version": "0.44.9",
17
+ "version": "0.45.2",
18
18
  "main": "./cjs/index.js",
19
19
  "module": "./index.js",
20
20
  "types": "./index.d.ts",
@@ -56,7 +56,10 @@
56
56
  "require": "./cjs/detectPackage.js",
57
57
  "default": "./detectPackage.js"
58
58
  },
59
- "./package.json": "./package.json",
59
+ "./package.json": {
60
+ "require": "./cjs/package.json",
61
+ "default": "./package.json"
62
+ },
60
63
  "./packageInfo.js": {
61
64
  "types": "./packageInfo.d.ts",
62
65
  "require": "./cjs/packageInfo.js",
@@ -74,12 +77,12 @@
74
77
  }
75
78
  },
76
79
  "dependencies": {
77
- "@babel/runtime": "^7.20.13",
78
- "@polkadot/rpc-provider": "^9.14.2",
79
- "@polkadot/types": "^9.14.2",
80
- "@polkadot/util": "^10.4.2",
81
- "@polkadot/util-crypto": "^10.4.2",
82
- "@polkadot/x-global": "^10.4.2"
80
+ "@polkadot/rpc-provider": "^10.1.1",
81
+ "@polkadot/types": "^10.1.1",
82
+ "@polkadot/util": "^11.0.2",
83
+ "@polkadot/util-crypto": "^11.0.2",
84
+ "@polkadot/x-global": "^11.0.2",
85
+ "tslib": "^2.5.0"
83
86
  },
84
87
  "peerDependencies": {
85
88
  "@polkadot/api": "*"
package/packageInfo.js CHANGED
@@ -1,11 +1 @@
1
- // Copyright 2017-2023 @polkadot/extension-inject authors & contributors
2
- // SPDX-License-Identifier: Apache-2.0
3
-
4
- // Do not edit, auto-generated by @polkadot/dev
5
-
6
- export const packageInfo = {
7
- name: '@polkadot/extension-inject',
8
- path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
9
- type: 'esm',
10
- version: '0.44.9'
11
- };
1
+ export const packageInfo = { name: '@polkadot/extension-inject', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '0.45.2' };