@pezkuwi/extension-dapp 0.62.14 → 0.62.17

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.
Files changed (59) hide show
  1. package/build/README.md +3 -0
  2. package/build/bundle.js +232 -0
  3. package/build/cjs/bundle.d.ts +61 -0
  4. package/build/cjs/bundle.js +246 -0
  5. package/build/cjs/index.js +4 -0
  6. package/build/cjs/packageInfo.js +4 -0
  7. package/build/cjs/util.js +13 -0
  8. package/build/cjs/wrapBytes.js +10 -0
  9. package/build/index.d.ts +1 -0
  10. package/build/index.js +1 -0
  11. package/build/package.json +142 -0
  12. package/build/packageDetect.d.ts +1 -0
  13. package/build/packageDetect.js +4 -0
  14. package/build/packageInfo.d.ts +6 -0
  15. package/build/packageInfo.js +1 -0
  16. package/build/util.d.ts +1 -0
  17. package/build/util.js +10 -0
  18. package/build/wrapBytes.d.ts +7 -0
  19. package/build/wrapBytes.js +7 -0
  20. package/build-tsc-cjs/packageDetect.js +6 -0
  21. package/{cjs → build-tsc-cjs}/packageInfo.js +1 -1
  22. package/{packageInfo.js → build-tsc-esm/packageInfo.js} +1 -1
  23. package/package.json +10 -115
  24. package/src/bundle.ts +319 -0
  25. package/src/index.ts +7 -0
  26. package/src/packageDetect.ts +12 -0
  27. package/src/packageInfo.ts +6 -0
  28. package/src/util.ts +12 -0
  29. package/src/wrapBytes.spec.ts +137 -0
  30. package/src/wrapBytes.ts +12 -0
  31. package/tsconfig.build.json +14 -0
  32. package/tsconfig.build.tsbuildinfo +1 -0
  33. package/tsconfig.spec.json +16 -0
  34. package/tsconfig.spec.tsbuildinfo +1 -0
  35. package/bundle-pezkuwi-extension-dapp.js +0 -205
  36. /package/{LICENSE → build/LICENSE} +0 -0
  37. /package/{cjs → build}/bundle.d.ts +0 -0
  38. /package/{index.d.ts → build/cjs/index.d.ts} +0 -0
  39. /package/{cjs → build/cjs}/package.json +0 -0
  40. /package/{packageDetect.d.ts → build/cjs/packageDetect.d.ts} +0 -0
  41. /package/{cjs → build/cjs}/packageDetect.js +0 -0
  42. /package/{packageInfo.d.ts → build/cjs/packageInfo.d.ts} +0 -0
  43. /package/{util.d.ts → build/cjs/util.d.ts} +0 -0
  44. /package/{wrapBytes.d.ts → build/cjs/wrapBytes.d.ts} +0 -0
  45. /package/{bundle.d.ts → build-tsc/bundle.d.ts} +0 -0
  46. /package/{cjs → build-tsc}/index.d.ts +0 -0
  47. /package/{cjs → build-tsc}/packageDetect.d.ts +0 -0
  48. /package/{cjs → build-tsc}/packageInfo.d.ts +0 -0
  49. /package/{cjs → build-tsc}/util.d.ts +0 -0
  50. /package/{cjs → build-tsc}/wrapBytes.d.ts +0 -0
  51. /package/{cjs → build-tsc-cjs}/bundle.js +0 -0
  52. /package/{cjs → build-tsc-cjs}/index.js +0 -0
  53. /package/{cjs → build-tsc-cjs}/util.js +0 -0
  54. /package/{cjs → build-tsc-cjs}/wrapBytes.js +0 -0
  55. /package/{bundle.js → build-tsc-esm/bundle.js} +0 -0
  56. /package/{index.js → build-tsc-esm/index.js} +0 -0
  57. /package/{packageDetect.js → build-tsc-esm/packageDetect.js} +0 -0
  58. /package/{util.js → build-tsc-esm/util.js} +0 -0
  59. /package/{wrapBytes.js → build-tsc-esm/wrapBytes.js} +0 -0
@@ -0,0 +1,12 @@
1
+ // Copyright 2017-2026 @pezkuwi/extension-dapp authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Do not edit, auto-generated by @pezkuwi/dev
5
+ // (packageInfo imports will be kept as-is, user-editable)
6
+
7
+ import { packageInfo as injectInfo } from '@pezkuwi/extension-inject/packageInfo';
8
+ import { detectPackage } from '@pezkuwi/util';
9
+
10
+ import { packageInfo } from './packageInfo.js';
11
+
12
+ detectPackage(packageInfo, null, [injectInfo]);
@@ -0,0 +1,6 @@
1
+ // Copyright 2017-2026 @pezkuwi/extension-dapp authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ // Do not edit, auto-generated by @pezkuwi/dev
5
+
6
+ export const packageInfo = { name: '@pezkuwi/extension-dapp', path: 'auto', type: 'auto', version: '0.62.16' };
package/src/util.ts ADDED
@@ -0,0 +1,12 @@
1
+ // Copyright 2019-2026 @pezkuwi/extension-dapp authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export function documentReadyPromise <T> (creator: () => Promise<T>): Promise<T> {
5
+ return new Promise((resolve): void => {
6
+ if (document.readyState === 'complete') {
7
+ resolve(creator());
8
+ } else {
9
+ window.addEventListener('load', () => resolve(creator()));
10
+ }
11
+ });
12
+ }
@@ -0,0 +1,137 @@
1
+ // Copyright 2019-2026 @pezkuwi/extension authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type * as _ from '@pezkuwi/dev-test/globals.d.ts';
5
+
6
+ import { u8aConcat, u8aEq, u8aToString } from '@pezkuwi/util';
7
+
8
+ import { ETHEREUM, POSTFIX, PREFIX, unwrapBytes, wrapBytes } from './wrapBytes.js';
9
+
10
+ const TEST_DATA = 'this is just some random message that we expect to be wrapped along the way';
11
+ const TEST_ETH = u8aConcat(ETHEREUM, TEST_DATA);
12
+ const TEST_WRAP_EMPTY = `${u8aToString(PREFIX)}${u8aToString(POSTFIX)}`;
13
+ const TEST_WRAP_FULL = `${u8aToString(PREFIX)}${TEST_DATA}${u8aToString(POSTFIX)}`;
14
+ const TEST_WARP_HALF_PRE = `${u8aToString(PREFIX)}${TEST_DATA}`;
15
+ const TEST_WRAP_HALF_POST = `${TEST_DATA}${u8aToString(POSTFIX)}`;
16
+
17
+ describe('wrapBytes', (): void => {
18
+ it('wraps empty bytes', (): void => {
19
+ expect(
20
+ u8aEq(
21
+ wrapBytes(new Uint8Array()),
22
+ u8aConcat(PREFIX, POSTFIX)
23
+ )
24
+ ).toBe(true);
25
+ });
26
+
27
+ it('wraps when no wrapping is detected', (): void => {
28
+ expect(
29
+ u8aToString(
30
+ wrapBytes(TEST_DATA)
31
+ )
32
+ ).toEqual(TEST_WRAP_FULL);
33
+ });
34
+
35
+ it('wraps when only start wrap is detected', (): void => {
36
+ expect(
37
+ u8aToString(
38
+ wrapBytes(TEST_WARP_HALF_PRE)
39
+ )
40
+ ).toEqual(`${u8aToString(PREFIX)}${TEST_WARP_HALF_PRE}${u8aToString(POSTFIX)}`);
41
+ });
42
+
43
+ it('wraps when only end wrap is detected', (): void => {
44
+ expect(
45
+ u8aToString(
46
+ wrapBytes(TEST_WRAP_HALF_POST)
47
+ )
48
+ ).toEqual(`${u8aToString(PREFIX)}${TEST_WRAP_HALF_POST}${u8aToString(POSTFIX)}`);
49
+ });
50
+
51
+ it('does not re-wrap when a wrap is already present', (): void => {
52
+ expect(
53
+ u8aToString(
54
+ wrapBytes(TEST_WRAP_FULL)
55
+ )
56
+ ).toEqual(TEST_WRAP_FULL);
57
+ });
58
+
59
+ it('does not re-wrap when a wrap (empty data) is already present', (): void => {
60
+ expect(
61
+ u8aToString(
62
+ wrapBytes(TEST_WRAP_EMPTY)
63
+ )
64
+ ).toEqual(TEST_WRAP_EMPTY);
65
+ });
66
+ });
67
+
68
+ describe('unwrapBytes', (): void => {
69
+ it('unwraps empty bytes', (): void => {
70
+ expect(
71
+ u8aEq(
72
+ unwrapBytes(new Uint8Array()),
73
+ new Uint8Array()
74
+ )
75
+ ).toBe(true);
76
+ });
77
+
78
+ it('unwraps when no wrapping is detected', (): void => {
79
+ expect(
80
+ u8aToString(
81
+ unwrapBytes(TEST_DATA)
82
+ )
83
+ ).toEqual(TEST_DATA);
84
+ });
85
+
86
+ it('unwraps when no wrapping is detected (only start)', (): void => {
87
+ expect(
88
+ u8aToString(
89
+ unwrapBytes(TEST_WARP_HALF_PRE)
90
+ )
91
+ ).toEqual(TEST_WARP_HALF_PRE);
92
+ });
93
+
94
+ it('unwraps when no wrapping is detected (only end)', (): void => {
95
+ expect(
96
+ u8aToString(
97
+ unwrapBytes(TEST_WRAP_HALF_POST)
98
+ )
99
+ ).toEqual(TEST_WRAP_HALF_POST);
100
+ });
101
+
102
+ it('unwraps when a wrap is present', (): void => {
103
+ expect(
104
+ u8aToString(
105
+ unwrapBytes(TEST_WRAP_FULL)
106
+ )
107
+ ).toEqual(TEST_DATA);
108
+ });
109
+
110
+ it('unwraps when a an empty wrap is present', (): void => {
111
+ expect(
112
+ u8aToString(
113
+ unwrapBytes(TEST_WRAP_EMPTY)
114
+ )
115
+ ).toEqual('');
116
+ });
117
+
118
+ describe('Ethereum-style', (): void => {
119
+ it('does not wrap an Ethereum wrap', (): void => {
120
+ expect(
121
+ u8aEq(
122
+ wrapBytes(TEST_ETH),
123
+ TEST_ETH
124
+ )
125
+ ).toBe(true);
126
+ });
127
+
128
+ it('does not unwrap an Ethereum wrap', (): void => {
129
+ expect(
130
+ u8aEq(
131
+ unwrapBytes(TEST_ETH),
132
+ TEST_ETH
133
+ )
134
+ ).toBe(true);
135
+ });
136
+ });
137
+ });
@@ -0,0 +1,12 @@
1
+ // Copyright 2019-2026 @pezkuwi/extension authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { U8A_WRAP_ETHEREUM, U8A_WRAP_POSTFIX, U8A_WRAP_PREFIX, u8aIsWrapped, u8aUnwrapBytes, u8aWrapBytes } from '@pezkuwi/util';
5
+
6
+ export const ETHEREUM = U8A_WRAP_ETHEREUM;
7
+ export const POSTFIX = U8A_WRAP_POSTFIX;
8
+ export const PREFIX = U8A_WRAP_PREFIX;
9
+
10
+ export const isWrapped = u8aIsWrapped;
11
+ export const unwrapBytes = u8aUnwrapBytes;
12
+ export const wrapBytes = u8aWrapBytes;
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "baseUrl": "..",
5
+ "outDir": "./build",
6
+ "rootDir": "./src"
7
+ },
8
+ "exclude": [
9
+ "**/*.spec.ts"
10
+ ],
11
+ "references": [
12
+ { "path": "../extension-inject/tsconfig.build.json" }
13
+ ]
14
+ }