@prosopo/account 1.0.1 → 2.0.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.
Files changed (39) hide show
  1. package/dist/cjs/common/dist/error.cjs +20 -16
  2. package/dist/cjs/common/dist/hash.cjs +1 -1
  3. package/dist/cjs/common/dist/i18n.cjs +3 -3
  4. package/dist/cjs/common/dist/locales/en.json.cjs +2 -1
  5. package/dist/cjs/common/dist/logger.cjs +23 -11
  6. package/dist/cjs/common/dist/node/UrlConverter.cjs +15 -7
  7. package/dist/cjs/common/dist/utils.cjs +4 -2
  8. package/dist/cjs/detector/src/index.cjs +4586 -0
  9. package/dist/cjs/extension/ExtensionWeb2.cjs +30 -30
  10. package/dist/cjs/extension/ExtensionWeb3.cjs +5 -3
  11. package/dist/cjs/util/dist/at.cjs +25 -0
  12. package/dist/cjs/util/dist/canvas.cjs +52 -46
  13. package/dist/cjs/util/dist/checks.cjs +10 -0
  14. package/dist/cjs/util/dist/choice.cjs +19 -0
  15. package/dist/cjs/util/dist/get.cjs +10 -0
  16. package/dist/cjs/util/dist/hex.cjs +46 -0
  17. package/dist/cjs/util/dist/index.cjs +17 -8
  18. package/dist/cjs/util/dist/merge.cjs +58 -0
  19. package/dist/cjs/util/dist/ofLen.cjs +1 -1
  20. package/dist/cjs/util/dist/permutations.cjs +26 -0
  21. package/dist/cjs/util/dist/table.cjs +2 -2
  22. package/dist/cjs/util/dist/util.cjs +4 -143
  23. package/dist/extension/Extension.d.ts +1 -1
  24. package/dist/extension/Extension.d.ts.map +1 -1
  25. package/dist/extension/Extension.js.map +1 -1
  26. package/dist/extension/ExtensionWeb2.d.ts +4 -5
  27. package/dist/extension/ExtensionWeb2.d.ts.map +1 -1
  28. package/dist/extension/ExtensionWeb2.js +27 -36
  29. package/dist/extension/ExtensionWeb2.js.map +1 -1
  30. package/dist/extension/ExtensionWeb3.d.ts +2 -2
  31. package/dist/extension/ExtensionWeb3.d.ts.map +1 -1
  32. package/dist/extension/ExtensionWeb3.js +8 -6
  33. package/dist/extension/ExtensionWeb3.js.map +1 -1
  34. package/dist/index.d.ts +3 -3
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +3 -3
  37. package/dist/index.js.map +1 -1
  38. package/package.json +53 -58
  39. package/vite.cjs.config.ts +3 -3
@@ -1,161 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const util = require("@polkadot/util");
4
3
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
5
- function* permutations(bins, options) {
6
- if (options?.includeEmpty) {
7
- yield [];
8
- }
9
- if (bins.length === 0) {
10
- return;
11
- }
12
- const arr = Array.from({ length: bins.length }, () => 0);
13
- let i = arr.length - 1;
14
- while (true) {
15
- yield [...arr];
16
- arr[i]++;
17
- while (arr[i] === bins[i]) {
18
- arr[i] = 0;
19
- i--;
20
- if (i < 0) {
21
- return;
22
- }
23
- arr[i]++;
24
- }
25
- i = arr.length - 1;
26
- }
27
- }
28
- function get(obj, key, required = true) {
29
- const value = obj[key];
30
- if (required && value === void 0) {
31
- throw new Error(`Object has no property '${String(key)}': ${JSON.stringify(obj, null, 2)}`);
32
- }
33
- return value;
34
- }
35
- function at(items, index, options) {
36
- if (items.length === 0) {
37
- throw new Error("Array is empty");
38
- }
39
- if (!options?.noWrap) {
40
- if (index > 0) {
41
- index = index % items.length;
42
- } else {
43
- index = Math.ceil(Math.abs(index) / items.length) * items.length + index;
44
- }
45
- }
46
- if (index >= items.length) {
47
- throw new Error(`Index ${index} larger than array length ${items.length}`);
48
- }
49
- if (index < 0) {
50
- throw new Error(`Index ${index} smaller than 0`);
51
- }
52
- return items[index];
53
- }
54
- function choice(items, n, random, options) {
55
- if (n > items.length) {
56
- throw new Error(`Cannot choose ${n} items from array of length ${items.length}`);
57
- }
58
- const result = [];
59
- const indices = [];
60
- for (let i = 0; i < n; i++) {
61
- let index;
62
- do {
63
- index = Math.floor(Math.abs(random()) * items.length) % items.length;
64
- } while (options?.withReplacement === false && indices.includes(index));
65
- indices.push(index);
66
- result.push(items[index]);
67
- }
68
- return result;
69
- }
70
4
  function getCurrentFileDirectory(url) {
71
5
  return new URL(url).pathname.split("/").slice(0, -1).join("/");
72
6
  }
73
- const flattenObj = (obj, prefix = "") => {
7
+ const flatten = (obj, prefix = "") => {
74
8
  const flattenedObj = {};
75
9
  for (const [key, value] of Object.entries(obj)) {
76
10
  if (value instanceof Object) {
77
- Object.assign(flattenedObj, flattenObj(value, prefix + "." + key));
11
+ Object.assign(flattenedObj, flatten(value, `${prefix + key}.`));
78
12
  } else {
79
- flattenedObj[prefix + "." + key] = value;
13
+ flattenedObj[prefix + key] = value;
80
14
  }
81
15
  }
82
16
  return flattenedObj;
83
17
  };
84
18
  const kebabCase = (str) => str.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($, ofs) => (ofs ? "-" : "") + $.toLowerCase());
85
- function merge(dest, src, options) {
86
- const atomicArrays = options?.atomicArrays;
87
- const queue = [
88
- {
89
- src,
90
- dest
91
- }
92
- ];
93
- while (queue.length > 0) {
94
- const task = queue.pop();
95
- if (task === void 0) {
96
- throw new Error("queue is empty");
97
- }
98
- if (isArray(task.dest)) {
99
- const src2 = task.src;
100
- const dest2 = task.dest;
101
- if (atomicArrays) {
102
- while (dest2.length > src2.length) {
103
- dest2.pop();
104
- }
105
- for (let i = 0; i < src2.length; i++) {
106
- dest2[i] = src2[i];
107
- }
108
- } else {
109
- for (let i = 0; i < src2.length; i++) {
110
- if (isArray(dest2[i]) && isArray(src2[i]) || isObject(dest2[i]) && isObject(src2[i])) {
111
- queue.push({
112
- src: src2[i],
113
- dest: dest2[i]
114
- });
115
- } else {
116
- dest2[i] = src2[i];
117
- }
118
- }
119
- }
120
- } else if (isObject(task.dest)) {
121
- const src2 = task.src;
122
- const destAny = task.dest;
123
- for (const [key, value] of Object.entries(src2)) {
124
- if (isArray(value) && isArray(destAny[key]) || isObject(value) && isObject(destAny[key])) {
125
- queue.push({
126
- src: value,
127
- dest: destAny[key]
128
- });
129
- } else {
130
- destAny[key] = value;
131
- }
132
- }
133
- } else {
134
- throw new Error(`cannot handle type in queue: ${typeof task.dest}`);
135
- }
136
- }
137
- return dest;
138
- }
139
- const isArray = (value) => {
140
- return Array.isArray(value);
141
- };
142
- const isObject = (value) => {
143
- return value instanceof Object && !isArray(value);
144
- };
145
- const hashToHex = (hash) => {
146
- if (isArray(hash)) {
147
- return util.u8aToHex(new Uint8Array(hash));
148
- }
149
- return hash.toString();
150
- };
151
- exports.at = at;
152
- exports.flattenObj = flattenObj;
153
- exports.get = get;
19
+ exports.flatten = flatten;
154
20
  exports.getCurrentFileDirectory = getCurrentFileDirectory;
155
- exports.hashToHex = hashToHex;
156
- exports.isArray = isArray;
157
- exports.isObject = isObject;
158
21
  exports.kebabCase = kebabCase;
159
- exports.merge = merge;
160
- exports.permutations = permutations;
161
22
  exports.sleep = sleep;
@@ -1,4 +1,4 @@
1
- import { Account, ProcaptchaClientConfigOutput } from '@prosopo/types';
1
+ import type { Account, ProcaptchaClientConfigOutput } from "@prosopo/types";
2
2
  export declare abstract class Extension {
3
3
  abstract getAccount(config: ProcaptchaClientConfigOutput): Promise<Account>;
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Extension.d.ts","sourceRoot":"","sources":["../../src/extension/Extension.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AAKtE,8BAAsB,SAAS;aAOX,UAAU,CAAC,MAAM,EAAE,4BAA4B,GAAG,OAAO,CAAC,OAAO,CAAC;CACrF"}
1
+ {"version":3,"file":"Extension.d.ts","sourceRoot":"","sources":["../../src/extension/Extension.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAK5E,8BAAsB,SAAS;aAOd,UAAU,CACzB,MAAM,EAAE,4BAA4B,GAClC,OAAO,CAAC,OAAO,CAAC;CACnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"Extension.js","sourceRoot":"","sources":["../../src/extension/Extension.ts"],"names":[],"mappings":"AAkBA,MAAM,OAAgB,SAAS;CAQ9B"}
1
+ {"version":3,"file":"Extension.js","sourceRoot":"","sources":["../../src/extension/Extension.ts"],"names":[],"mappings":"AAkBA,MAAM,OAAgB,SAAS;CAU9B"}
@@ -1,16 +1,15 @@
1
- import { Account, ProcaptchaClientConfigOutput } from '@prosopo/types';
2
- import { Extension } from './Extension.js';
1
+ import type { Account, ProcaptchaClientConfigOutput } from "@prosopo/types";
2
+ import { Extension } from "./Extension.js";
3
3
  export declare class ExtensionWeb2 extends Extension {
4
4
  getAccount(config: ProcaptchaClientConfigOutput): Promise<Account>;
5
5
  private createExtension;
6
6
  private createAccount;
7
- private getFingerprint;
8
7
  getNetwork: (config: ProcaptchaClientConfigOutput) => {
9
- endpoint: string[];
10
8
  contract: {
11
- address: string;
12
9
  name: string;
10
+ address: string;
13
11
  };
12
+ endpoint: string[];
14
13
  pairType: "ed25519" | "sr25519" | "ecdsa" | "ethereum";
15
14
  ss58Format: number;
16
15
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ExtensionWeb2.d.ts","sourceRoot":"","sources":["../../src/extension/ExtensionWeb2.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AAEtE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAsB1C,qBAAa,aAAc,SAAQ,SAAS;IAC3B,UAAU,CAAC,MAAM,EAAE,4BAA4B,GAAG,OAAO,CAAC,OAAO,CAAC;YAajE,eAAe;YAiCf,aAAa;YAgCb,cAAc;IAW5B,UAAU,WAAY,4BAA4B;;;;;;;;MAQjD;CACJ"}
1
+ {"version":3,"file":"ExtensionWeb2.d.ts","sourceRoot":"","sources":["../../src/extension/ExtensionWeb2.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAG5E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAO3C,qBAAa,aAAc,SAAQ,SAAS;IAC9B,UAAU,CACtB,MAAM,EAAE,4BAA4B,GAClC,OAAO,CAAC,OAAO,CAAC;YAUL,eAAe;YAmCf,aAAa;IAwC3B,UAAU,WAAY,4BAA4B;;;;;;;;MAUhD;CACF"}
@@ -1,33 +1,31 @@
1
- import { ApiPromise } from '@polkadot/api/promise/Api';
2
- import { Extension } from './Extension.js';
3
- import { Keyring } from '@polkadot/keyring';
4
- import { ProsopoEnvError, hexHash } from '@prosopo/common';
5
- import { default as Signer } from '@polkadot/extension-base/page/Signer';
6
- import { WsProvider } from '@polkadot/rpc-provider/ws';
7
- import { decodeAddress, encodeAddress } from '@polkadot/util-crypto/address';
8
- import { entropyToMnemonic } from '@polkadot/util-crypto/mnemonic/bip39';
9
- import { hashComponents, load } from '@fingerprintjs/fingerprintjs';
10
- import { picassoCanvas } from '@prosopo/util';
11
- import { stringToU8a } from '@polkadot/util/string';
12
- import { u8aToHex } from '@polkadot/util/u8a';
13
- import { version } from '@prosopo/util';
1
+ import { default as Signer } from "@polkadot/extension-base/page/Signer";
2
+ import { Keyring } from "@polkadot/keyring";
3
+ import { cryptoWaitReady } from "@polkadot/util-crypto";
4
+ import { entropyToMnemonic } from "@polkadot/util-crypto/mnemonic/bip39";
5
+ import { stringToU8a } from "@polkadot/util/string";
6
+ import { u8aToHex } from "@polkadot/util/u8a";
7
+ import { ProsopoEnvError, hexHash } from "@prosopo/common";
8
+ import { getFingerprint } from "@prosopo/detector";
9
+ import { picassoCanvas } from "@prosopo/util";
10
+ import { version } from "@prosopo/util";
11
+ import { Extension } from "./Extension.js";
14
12
  export class ExtensionWeb2 extends Extension {
15
13
  constructor() {
16
14
  super(...arguments);
17
15
  this.getNetwork = (config) => {
18
16
  const network = config.networks[config.defaultNetwork];
19
17
  if (!network) {
20
- throw new ProsopoEnvError('DEVELOPER.NETWORK_NOT_FOUND', {
21
- context: { error: `No network found for environment ${config.defaultEnvironment}` },
18
+ throw new ProsopoEnvError("DEVELOPER.NETWORK_NOT_FOUND", {
19
+ context: {
20
+ error: `No network found for environment ${config.defaultEnvironment}`,
21
+ },
22
22
  });
23
23
  }
24
24
  return network;
25
25
  };
26
26
  }
27
27
  async getAccount(config) {
28
- const network = this.getNetwork(config);
29
- const wsProvider = new WsProvider(network.endpoint);
30
- const account = await this.createAccount(wsProvider);
28
+ const account = await this.createAccount(config);
31
29
  const extension = await this.createExtension(account);
32
30
  return {
33
31
  account,
@@ -56,12 +54,13 @@ export class ExtensionWeb2 extends Extension {
56
54
  };
57
55
  },
58
56
  },
59
- name: 'procaptcha-web2',
57
+ name: "procaptcha-web2",
60
58
  version,
61
59
  signer,
62
60
  };
63
61
  }
64
- async createAccount(wsProvider) {
62
+ async createAccount(config) {
63
+ await cryptoWaitReady();
65
64
  const params = {
66
65
  area: { width: 300, height: 300 },
67
66
  offsetParameter: 2001000001,
@@ -71,31 +70,23 @@ export class ExtensionWeb2 extends Extension {
71
70
  numberOfRounds: 5,
72
71
  seed: 42,
73
72
  };
74
- const browserEntropy = await this.getFingerprint();
73
+ const browserEntropy = await getFingerprint();
75
74
  const canvasEntropy = picassoCanvas(params.numberOfRounds, params.seed, params);
76
- const entropy = hexHash([canvasEntropy, browserEntropy].join(''), 128).slice(2);
75
+ const entropy = hexHash([canvasEntropy, browserEntropy].join(""), 128).slice(2);
77
76
  const u8Entropy = stringToU8a(entropy);
78
77
  const mnemonic = entropyToMnemonic(u8Entropy);
79
- const api = await ApiPromise.create({ provider: wsProvider, initWasm: false, noInitWarn: true });
80
- const type = 'ed25519';
81
- const keyring = new Keyring({ type, ss58Format: api.registry.chainSS58 });
78
+ const type = "sr25519";
79
+ const keyring = new Keyring({
80
+ type,
81
+ ss58Format: config.networks[config.defaultNetwork].ss58Format,
82
+ });
82
83
  const keypair = keyring.addFromMnemonic(mnemonic);
83
- const address = keypair.address.length === 42
84
- ? keypair.address
85
- : encodeAddress(decodeAddress(keypair.address), api.registry.chainSS58);
84
+ const address = keypair.address;
86
85
  return {
87
86
  address,
88
- type,
89
87
  name: address,
90
88
  keypair,
91
89
  };
92
90
  }
93
- async getFingerprint() {
94
- const fpPromise = load();
95
- const fp = await fpPromise;
96
- const result = await fp.get();
97
- const { screenFrame, ...componentsReduced } = result.components;
98
- return hashComponents(componentsReduced);
99
- }
100
91
  }
101
92
  //# sourceMappingURL=ExtensionWeb2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExtensionWeb2.js","sourceRoot":"","sources":["../../src/extension/ExtensionWeb2.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAI1C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAE3C,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,sCAAsC,CAAA;AACxE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAOvC,MAAM,OAAO,aAAc,SAAQ,SAAS;IAA5C;;QA0FI,eAAU,GAAG,C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YACN,OAAO;YACP,IAAI,EAAE,OAAO;YACb,OAAO;SACP,CAAC;IACH,CAAC;CAaD"}
@@ -1,5 +1,5 @@
1
- import { Account, ProcaptchaClientConfigOutput } from '@prosopo/types';
2
- import { Extension } from './Extension.js';
1
+ import type { Account, ProcaptchaClientConfigOutput } from "@prosopo/types";
2
+ import { Extension } from "./Extension.js";
3
3
  export declare class ExtensionWeb3 extends Extension {
4
4
  getAccount(config: ProcaptchaClientConfigOutput): Promise<Account>;
5
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ExtensionWeb3.d.ts","sourceRoot":"","sources":["../../src/extension/ExtensionWeb3.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAA;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAQ1C,qBAAa,aAAc,SAAQ,SAAS;IAC3B,UAAU,CAAC,MAAM,EAAE,4BAA4B,GAAG,OAAO,CAAC,OAAO,CAAC;CA0BlF"}
1
+ {"version":3,"file":"ExtensionWeb3.d.ts","sourceRoot":"","sources":["../../src/extension/ExtensionWeb3.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAK3C,qBAAa,aAAc,SAAQ,SAAS;IAC9B,UAAU,CACtB,MAAM,EAAE,4BAA4B,GAClC,OAAO,CAAC,OAAO,CAAC;CA4BnB"}
@@ -1,15 +1,17 @@
1
- import { Extension } from './Extension.js';
2
- import { ProsopoError } from '@prosopo/common';
3
- import { web3Enable } from '@polkadot/extension-dapp';
1
+ import { web3Enable } from "@polkadot/extension-dapp";
2
+ import { ProsopoError } from "@prosopo/common";
3
+ import { Extension } from "./Extension.js";
4
4
  export class ExtensionWeb3 extends Extension {
5
5
  async getAccount(config) {
6
6
  const { dappName, userAccountAddress: address } = config;
7
7
  if (!address) {
8
- throw new ProsopoError('WIDGET.NO_ACCOUNTS_FOUND', { context: { error: 'No account address provided' } });
8
+ throw new ProsopoError("WIDGET.NO_ACCOUNTS_FOUND", {
9
+ context: { error: "No account address provided" },
10
+ });
9
11
  }
10
12
  const extensions = await web3Enable(dappName);
11
13
  if (extensions.length === 0) {
12
- throw new ProsopoError('WIDGET.NO_EXTENSION_FOUND');
14
+ throw new ProsopoError("WIDGET.NO_EXTENSION_FOUND");
13
15
  }
14
16
  for (const extension of extensions) {
15
17
  const accounts = await extension.accounts.get();
@@ -18,7 +20,7 @@ export class ExtensionWeb3 extends Extension {
18
20
  return { account, extension };
19
21
  }
20
22
  }
21
- throw new ProsopoError('WIDGET.ACCOUNT_NOT_FOUND', {
23
+ throw new ProsopoError("WIDGET.ACCOUNT_NOT_FOUND", {
22
24
  context: { error: `No account found matching ${address}` },
23
25
  });
24
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ExtensionWeb3.js","sourceRoot":"","sources":["../../src/extension/ExtensionWeb3.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAKrD,MAAM,OAAO,aAAc,SAAQ,SAAS;IACjC,KAAK,CAAC,UAAU,CAAC,MAAoC;QACxD,MAAM,EAAE,QAAQ,EAAE,kBAAkB,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;QAExD,IAAI,CAAC,OAAO,EAAE;YACV,MAAM,IAAI,YAAY,CAAC,0BAA0B,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,6BAA6B,EAAE,EAAE,CAAC,CAAA;SAC5G;QAGD,MAAM,UAAU,GAAwB,MAAM,UAAU,CAAC,QAAQ,CAAC,CAAA;QAClE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE;YAC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;QAGD,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;YACnC,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;YAChD,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC;YACxE,IAAI,OAAO,EAAE;gBACZ,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;aAC9B;SACD;QAED,MAAM,IAAI,YAAY,CAAC,0BAA0B,EAAE;YAClD,OAAO,EAAE,EAAE,KAAK,EAAE,6BAA6B,OAAO,EAAE,EAAE;SAC1D,CAAC,CAAC;IACJ,CAAC;CACD"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './extension/Extension.js';
2
- export * from './extension/ExtensionWeb2.js';
3
- export * from './extension/ExtensionWeb3.js';
1
+ export * from "./extension/Extension.js";
2
+ export * from "./extension/ExtensionWeb2.js";
3
+ export * from "./extension/ExtensionWeb3.js";
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,0BAA0B,CAAA;AACxC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,8BAA8B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export * from './extension/Extension.js';
2
- export * from './extension/ExtensionWeb2.js';
3
- export * from './extension/ExtensionWeb3.js';
1
+ export * from "./extension/Extension.js";
2
+ export * from "./extension/ExtensionWeb2.js";
3
+ export * from "./extension/ExtensionWeb3.js";
4
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,0BAA0B,CAAA;AACxC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,8BAA8B,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC"}
package/package.json CHANGED
@@ -1,60 +1,55 @@
1
1
  {
2
- "name": "@prosopo/account",
3
- "version": "1.0.1",
4
- "description": "Services and Utils for Prosopo account gen and management",
5
- "main": "dist/index.js",
6
- "type": "module",
7
- "engines": {
8
- "node": ">=18",
9
- "npm": ">=9"
10
- },
11
- "exports": {
12
- ".": {
13
- "import": "./dist/index.js",
14
- "require": "./dist/cjs/index.cjs"
15
- }
16
- },
17
- "scripts": {
18
- "test": "echo \"No test specified\"",
19
- "clean": "tsc --build --clean",
20
- "build": "tsc --build --verbose tsconfig.json",
21
- "build:cjs": "npx vite --config vite.cjs.config.ts build",
22
- "eslint": "npx eslint . --no-error-on-unmatched-pattern --ignore-path ../../.eslintignore --quiet",
23
- "eslint:fix": "npm run eslint -- --fix",
24
- "prettier": "npx prettier . --check --no-error-on-unmatched-pattern --ignore-path ../../.eslintignore",
25
- "prettier:fix": "npm run prettier -- --write",
26
- "lint": "npm run eslint && npm run prettier",
27
- "lint:fix": "npm run eslint:fix && npm run prettier:fix"
28
- },
29
- "repository": {
30
- "type": "git",
31
- "url": "git+ssh://git@github.com/prosopo/types.git"
32
- },
33
- "author": "Prosopo Limited",
34
- "license": "Apache-2.0",
35
- "bugs": {
36
- "url": "https://github.com/prosopo/captcha/issues"
37
- },
38
- "homepage": "https://github.com/prosopo/captcha#readme",
39
- "dependencies": {
40
- "react": "^18.3.1",
41
- "@fingerprintjs/fingerprintjs": "^3.3.6",
42
- "@polkadot/api": "10.13.1",
43
- "@polkadot/extension-base": "0.46.9",
44
- "@polkadot/extension-dapp": "0.46.9",
45
- "@polkadot/extension-inject": "0.46.9",
46
- "@polkadot/keyring": "12.6.2",
47
- "@polkadot/rpc-provider": "10.13.1",
48
- "@polkadot/util": "12.6.2",
49
- "@polkadot/util-crypto": "12.6.2",
50
- "@prosopo/common": "1.0.1",
51
- "@prosopo/types": "1.0.1",
52
- "@prosopo/util": "1.0.1"
53
- },
54
- "devDependencies": {
55
- "@prosopo/config": "1.0.1",
56
- "tslib": "2.6.2",
57
- "typescript": "5.1.6"
58
- },
59
- "sideEffects": false
2
+ "name": "@prosopo/account",
3
+ "version": "2.0.0",
4
+ "description": "Services and Utils for Prosopo account gen and management",
5
+ "main": "dist/index.js",
6
+ "type": "module",
7
+ "engines": {
8
+ "node": ">=20",
9
+ "npm": ">=9"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/index.js",
14
+ "require": "./dist/cjs/index.cjs"
15
+ }
16
+ },
17
+ "scripts": {
18
+ "test": "echo \"No test specified\"",
19
+ "clean": "tsc --build --clean",
20
+ "build": "tsc --build --verbose",
21
+ "build:cjs": "npx vite --config vite.cjs.config.ts build"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+ssh://git@github.com/prosopo/types.git"
26
+ },
27
+ "author": "Prosopo Limited",
28
+ "license": "Apache-2.0",
29
+ "bugs": {
30
+ "url": "https://github.com/prosopo/captcha/issues"
31
+ },
32
+ "homepage": "https://github.com/prosopo/captcha#readme",
33
+ "dependencies": {
34
+ "react": "^18.3.1",
35
+ "@fingerprintjs/fingerprintjs": "^3.3.6",
36
+ "@polkadot/api": "10.13.1",
37
+ "@polkadot/extension-base": "0.46.9",
38
+ "@polkadot/extension-dapp": "0.46.9",
39
+ "@polkadot/extension-inject": "0.46.9",
40
+ "@polkadot/keyring": "12.6.2",
41
+ "@polkadot/rpc-provider": "10.13.1",
42
+ "@polkadot/util": "12.6.2",
43
+ "@polkadot/util-crypto": "12.6.2",
44
+ "@prosopo/common": "2.0.0",
45
+ "@prosopo/detector": "2.0.0",
46
+ "@prosopo/types": "2.0.0",
47
+ "@prosopo/util": "2.0.0"
48
+ },
49
+ "devDependencies": {
50
+ "@prosopo/config": "2.0.0",
51
+ "tslib": "2.6.2",
52
+ "typescript": "5.1.6"
53
+ },
54
+ "sideEffects": false
60
55
  }
@@ -1,3 +1,4 @@
1
+ import path from "node:path";
1
2
  // Copyright 2021-2024 Prosopo (UK) Ltd.
2
3
  //
3
4
  // Licensed under the Apache License, Version 2.0 (the "License");
@@ -11,9 +12,8 @@
11
12
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
13
  // See the License for the specific language governing permissions and
13
14
  // limitations under the License.
14
- import { ViteCommonJSConfig } from '@prosopo/config'
15
- import path from 'path'
15
+ import { ViteCommonJSConfig } from "@prosopo/config";
16
16
 
17
17
  export default function () {
18
- return ViteCommonJSConfig('util', path.resolve('./tsconfig.cjs.json'))
18
+ return ViteCommonJSConfig("util", path.resolve("./tsconfig.cjs.json"));
19
19
  }