@agnostack/verifyd 2.5.0-alpha.4 → 2.5.0-beta.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.
Files changed (73) hide show
  1. package/dist/esm/lib/index.js +3 -3
  2. package/dist/esm/lib/utils/index.js +1 -1
  3. package/dist/esm/lib/utils/rawbody.js +1 -1
  4. package/dist/esm/lib/verification.js +6 -6
  5. package/dist/esm/react/hooks/index.js +1 -1
  6. package/dist/esm/react/hooks/useVerification.js +1 -1
  7. package/dist/esm/react/index.js +2 -2
  8. package/dist/esm/shared/WebCrypto.js +26 -8
  9. package/dist/esm/shared/authorization.js +2 -2
  10. package/dist/esm/shared/index.js +5 -5
  11. package/dist/esm/shared/request.js +1 -1
  12. package/dist/esm/shared/verification.js +4 -4
  13. package/dist/lib/index.d.ts +3 -3
  14. package/dist/lib/index.d.ts.map +1 -1
  15. package/dist/lib/index.js +3 -3
  16. package/dist/lib/index.js.map +1 -1
  17. package/dist/lib/types.d.ts +2 -2
  18. package/dist/lib/types.d.ts.map +1 -1
  19. package/dist/lib/utils/index.d.ts +1 -1
  20. package/dist/lib/utils/index.js +1 -1
  21. package/dist/lib/utils/index.js.map +1 -1
  22. package/dist/lib/utils/rawbody.js +2 -2
  23. package/dist/lib/utils/rawbody.js.map +1 -1
  24. package/dist/lib/verification.d.ts +2 -2
  25. package/dist/lib/verification.d.ts.map +1 -1
  26. package/dist/lib/verification.js +20 -20
  27. package/dist/lib/verification.js.map +1 -1
  28. package/dist/react/hooks/index.d.ts +1 -1
  29. package/dist/react/hooks/index.js +1 -1
  30. package/dist/react/hooks/index.js.map +1 -1
  31. package/dist/react/hooks/useVerification.js +4 -4
  32. package/dist/react/hooks/useVerification.js.map +1 -1
  33. package/dist/react/index.d.ts +2 -2
  34. package/dist/react/index.d.ts.map +1 -1
  35. package/dist/react/index.js +2 -2
  36. package/dist/react/index.js.map +1 -1
  37. package/dist/shared/WebCrypto.d.ts +55 -59
  38. package/dist/shared/WebCrypto.d.ts.map +1 -1
  39. package/dist/shared/WebCrypto.js +32 -14
  40. package/dist/shared/WebCrypto.js.map +1 -1
  41. package/dist/shared/authorization.d.ts +2 -2
  42. package/dist/shared/authorization.js +4 -4
  43. package/dist/shared/authorization.js.map +1 -1
  44. package/dist/shared/index.d.ts +5 -5
  45. package/dist/shared/index.d.ts.map +1 -1
  46. package/dist/shared/index.js +5 -5
  47. package/dist/shared/index.js.map +1 -1
  48. package/dist/shared/request.js +5 -5
  49. package/dist/shared/request.js.map +1 -1
  50. package/dist/shared/verification.d.ts +3 -6
  51. package/dist/shared/verification.d.ts.map +1 -1
  52. package/dist/shared/verification.js +19 -19
  53. package/dist/shared/verification.js.map +1 -1
  54. package/dist/umd/index.js +406 -471
  55. package/dist/umd/index.js.map +1 -1
  56. package/dist/umd/lib/index.d.ts +3 -3
  57. package/dist/umd/lib/index.d.ts.map +1 -1
  58. package/dist/umd/lib/types.d.ts +2 -2
  59. package/dist/umd/lib/types.d.ts.map +1 -1
  60. package/dist/umd/lib/utils/index.d.ts +1 -1
  61. package/dist/umd/lib/verification.d.ts +2 -2
  62. package/dist/umd/lib/verification.d.ts.map +1 -1
  63. package/dist/umd/react/hooks/index.d.ts +1 -1
  64. package/dist/umd/react/index.d.ts +2 -2
  65. package/dist/umd/react/index.d.ts.map +1 -1
  66. package/dist/umd/shared/WebCrypto.d.ts +55 -59
  67. package/dist/umd/shared/WebCrypto.d.ts.map +1 -1
  68. package/dist/umd/shared/authorization.d.ts +2 -2
  69. package/dist/umd/shared/index.d.ts +5 -5
  70. package/dist/umd/shared/index.d.ts.map +1 -1
  71. package/dist/umd/shared/verification.d.ts +3 -6
  72. package/dist/umd/shared/verification.d.ts.map +1 -1
  73. package/package.json +1 -1
@@ -1,3 +1,3 @@
1
- export * from '../shared';
2
- export * from './utils';
3
- export * from './verification';
1
+ export * from '../shared/index.js';
2
+ export * from './utils/index.js';
3
+ export * from './verification.js';
@@ -1 +1 @@
1
- export * from './rawbody';
1
+ export * from './rawbody.js';
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { lowercase } from '../../shared/display';
10
+ import { lowercase } from '../../shared/display.js';
11
11
  const getChunkedRawBody = (req) => __awaiter(void 0, void 0, void 0, function* () {
12
12
  if (req === null || req === void 0 ? void 0 : req.rawBody) {
13
13
  return req.rawBody;
@@ -7,11 +7,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { objectToSortedString, ensureString, safeParse, isTrue, } from '../shared/display';
11
- import { normalizeURIParts, getRequestMethod, VERIFYD_HEADERS, } from '../shared/request';
12
- import { VerificationError } from '../shared/errors';
13
- import { WebCrypto } from '../shared/WebCrypto';
14
- import { ensureRawBody } from './utils';
10
+ import { objectToSortedString, ensureString, safeParse, isTrue, } from '../shared/display.js';
11
+ import { normalizeURIParts, getRequestMethod, VERIFYD_HEADERS, } from '../shared/request.js';
12
+ import { VerificationError } from '../shared/errors.js';
13
+ import { WebCrypto } from '../shared/WebCrypto.js';
14
+ import { ensureRawBody } from './utils/index.js';
15
15
  export const generateStorableKeyPairs = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* ({ crypto: _crypto, util: _util } = {}) {
16
16
  const webCrypto = new WebCrypto({ crypto: _crypto, util: _util });
17
17
  const sharedKeyPair = yield webCrypto.generateKeyPair();
@@ -56,7 +56,7 @@ export const getVerificationHelpers = ({ keyPairs, util: _util, crypto: _crypto,
56
56
  publicKey: ephemeralPublicKey,
57
57
  privateKey: keyPairs.shared.privateKey,
58
58
  });
59
- if (!verificationKeys) {
59
+ if (!(verificationKeys === null || verificationKeys === void 0 ? void 0 : verificationKeys.derivedHMACKey) || !verificationKeys.derivedSecretKey) {
60
60
  throw new VerificationError('Invalid or missing verification', { code: 412 });
61
61
  }
62
62
  const verificationPayload = objectToSortedString(Object.assign({ method: getRequestMethod(rawBody, req.method), timestamp: customAuthTimestamp, body: requestBody }, normalizeURIParts(uri)));
@@ -1 +1 @@
1
- export * from './useVerification';
1
+ export * from './useVerification.js';
@@ -19,7 +19,7 @@ var __rest = (this && this.__rest) || function (s, e) {
19
19
  return t;
20
20
  };
21
21
  import { useState } from 'react';
22
- import { getVerificationKeysData, prepareVerificationRequest, processVerificationResponse, } from '../../shared/verification';
22
+ import { getVerificationKeysData, prepareVerificationRequest, processVerificationResponse, } from '../../shared/verification.js';
23
23
  export const useVerification = (_a = {}) => {
24
24
  var { publicKey, disableRecryption } = _a, params = __rest(_a, ["publicKey", "disableRecryption"]);
25
25
  const [keysData, setKeysData] = useState();
@@ -1,2 +1,2 @@
1
- export * from '../shared/request'; // HMMMM: why cant we export WebCrypto class??
2
- export * from './hooks';
1
+ export * from '../shared/request.js'; // HMMMM: why cant we export WebCrypto class??
2
+ export * from './hooks/index.js';
@@ -7,17 +7,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { isString, objectEmpty, ensureString, ensureArray, } from './display';
11
- import { CryptoError } from './errors';
10
+ import { isString, objectEmpty, ensureString, ensureArray, } from './display.js';
11
+ import { CryptoError } from './errors.js';
12
12
  export class WebCrypto {
13
- constructor({ crypto: _crypto, util: _util } = {}) {
13
+ constructor({ crypto: _crypto, util: _util, encoding } = {}) {
14
14
  this._crypto = _crypto !== null && _crypto !== void 0 ? _crypto : {};
15
15
  this._util = _util !== null && _util !== void 0 ? _util : {};
16
+ this._encoding = encoding;
16
17
  }
17
18
  get subtle() {
18
19
  var _a;
19
20
  return (_a = this._crypto) === null || _a === void 0 ? void 0 : _a.subtle;
20
21
  }
22
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
23
  getWebCrypto() {
22
24
  return __awaiter(this, void 0, void 0, function* () {
23
25
  var _a, _b, _c, _d;
@@ -124,13 +126,14 @@ export class WebCrypto {
124
126
  return (Array.from(ensureString(stringValue), (char) => (char.charCodeAt(0).toString(16).padStart(2, '0'))).join(''));
125
127
  }
126
128
  hexToString(hexValue) {
129
+ var _a;
127
130
  if (!isString(hexValue)) {
128
131
  throw new CryptoError('hexValue must be a string');
129
132
  }
130
133
  if (!/^(?:[0-9a-f]{2})+$/.test(hexValue)) {
131
134
  throw new CryptoError('hexValue must be a valid hex string');
132
135
  }
133
- return ensureArray(hexValue.match(/.{1,2}/g))
136
+ return ensureArray((_a = hexValue.match(/.{1,2}/g)) !== null && _a !== void 0 ? _a : [])
134
137
  .map((byte) => String.fromCharCode(parseInt(byte, 16)))
135
138
  .join('');
136
139
  }
@@ -142,7 +145,12 @@ export class WebCrypto {
142
145
  });
143
146
  }
144
147
  arrayToArrayBuffer(array) {
145
- return ((ArrayBuffer.from != undefined)
148
+ // Defensive `ArrayBuffer.from` check is vestigial (no such standard method),
149
+ // but preserved to keep this conversion behavior-identical to the .js source.
150
+ return (
151
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
152
+ (ArrayBuffer.from != undefined)
153
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
146
154
  ? ArrayBuffer.from(array)
147
155
  : new Uint8Array(array).buffer);
148
156
  }
@@ -224,7 +232,7 @@ export class WebCrypto {
224
232
  const crypto = yield this.getWebCrypto();
225
233
  const Encoder = yield this.getTextEncoder();
226
234
  const signature = yield crypto.subtle.sign('HMAC', derivedKey, new Encoder().encode(message));
227
- return this.stringToHex(this.arrayBufferToString(signature));
235
+ return this.stringToHex(yield this.arrayBufferToString(signature));
228
236
  });
229
237
  }
230
238
  verifyHMAC(message, derivedKey, verifiableHMAC) {
@@ -375,6 +383,12 @@ export class WebCrypto {
375
383
  ...iv,
376
384
  ...new Uint8Array(ciphertext)
377
385
  ]);
386
+ if (this._encoding === 'base64') {
387
+ // btoa is universal in browsers + Node 16+; no polyfill needed.
388
+ // String.fromCharCode + spread is safe for the small payloads we produce
389
+ // (IV + ciphertext + tag — typically < 100KB even for large messages).
390
+ return btoa(String.fromCharCode(...encryptedMessage));
391
+ }
378
392
  return Array.from(encryptedMessage);
379
393
  });
380
394
  }
@@ -384,8 +398,12 @@ export class WebCrypto {
384
398
  return undefined;
385
399
  }
386
400
  const crypto = yield this.getWebCrypto();
387
- // NOTE: this presumed an array or arrayBuffer coming in as encryptedMessage (will fail w/ IV error if its a string)
388
- const encryptedArrayBuffer = this.ensureArrayBuffer(encryptedMessage);
401
+ // When encoding === 'base64', the input is a base64 string from a matching
402
+ // encryptMessage call on a peer instance with the same option. Otherwise,
403
+ // accept number[] / ArrayBuffer (existing behavior).
404
+ const encryptedArrayBuffer = (this._encoding === 'base64')
405
+ ? Uint8Array.from(atob(encryptedMessage), (c) => c.charCodeAt(0)).buffer
406
+ : this.ensureArrayBuffer(encryptedMessage);
389
407
  const iv = encryptedArrayBuffer.slice(0, 12);
390
408
  const ciphertext = encryptedArrayBuffer.slice(12);
391
409
  const decryptedArrayBuffer = yield crypto.subtle.decrypt({
@@ -7,8 +7,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { stringEmpty } from './display';
11
- import { WebCrypto } from './WebCrypto';
10
+ import { stringEmpty } from './display.js';
11
+ import { WebCrypto } from './WebCrypto.js';
12
12
  export const getAuthorizationHelpers = (sharedSecret_1, ...args_1) => __awaiter(void 0, [sharedSecret_1, ...args_1], void 0, function* (sharedSecret, { crypto: _crypto, util: _util } = {}) {
13
13
  if (stringEmpty(sharedSecret)) {
14
14
  return undefined;
@@ -1,6 +1,6 @@
1
1
  // export * from './constants' // HMMMM???
2
- export * from './errors';
3
- export * from './authorization';
4
- export * from './request';
5
- export * from './verification';
6
- export * from './WebCrypto';
2
+ export * from './errors.js';
3
+ export * from './authorization.js';
4
+ export * from './request.js';
5
+ export * from './verification.js';
6
+ export * from './WebCrypto.js';
@@ -9,7 +9,7 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
- import { ensureLeadingSlash, stringEmpty, uppercase, safeParse, } from './display';
12
+ import { ensureLeadingSlash, stringEmpty, uppercase, safeParse, } from './display.js';
13
13
  const TEMP_HOSTNAME = 'xyz.com';
14
14
  const REMOVABLE_KEYS = ['shop', 'host'];
15
15
  export const VERIFYD_HEADERS = {
@@ -18,10 +18,10 @@ var __rest = (this && this.__rest) || function (s, e) {
18
18
  }
19
19
  return t;
20
20
  };
21
- import { VerificationError } from './errors';
22
- import { normalizeURIParts, prepareRequestOptions, getRequestMethod, } from './request';
23
- import { isTrue, safeParse, stringEmpty, objectToSortedString, } from './display';
24
- import { WebCrypto } from './WebCrypto';
21
+ import { VerificationError } from './errors.js';
22
+ import { normalizeURIParts, prepareRequestOptions, getRequestMethod, } from './request.js';
23
+ import { isTrue, safeParse, stringEmpty, objectToSortedString, } from './display.js';
24
+ import { WebCrypto } from './WebCrypto.js';
25
25
  const getUnixString = () => {
26
26
  const currentDate = new Date();
27
27
  const unixTimestamp = currentDate.getTime();
@@ -1,4 +1,4 @@
1
- export * from '../shared';
2
- export * from './utils';
3
- export * from './verification';
1
+ export * from '../shared/index.js';
2
+ export * from './utils/index.js';
3
+ export * from './verification.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA;AAChC,cAAc,mBAAmB,CAAA"}
package/dist/lib/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("../shared"), exports);
18
- __exportStar(require("./utils"), exports);
19
- __exportStar(require("./verification"), exports);
17
+ __exportStar(require("../shared/index.js"), exports);
18
+ __exportStar(require("./utils/index.js"), exports);
19
+ __exportStar(require("./verification.js"), exports);
20
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB;AACzB,0CAAuB;AACvB,iDAA8B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAkC;AAClC,mDAAgC;AAChC,oDAAiC"}
@@ -5,8 +5,8 @@ export interface KeyPairs {
5
5
  };
6
6
  }
7
7
  export interface VerificationKeys {
8
- derivedHMACKey: string;
9
- derivedSecretKey: string;
8
+ derivedHMACKey?: CryptoKey;
9
+ derivedSecretKey?: CryptoKey;
10
10
  }
11
11
  export interface RequestParams {
12
12
  uri?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE;QACN,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE;QACN,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,CAAC,EAAE,SAAS,CAAC;IAC3B,gBAAgB,CAAC,EAAE,SAAS,CAAC;CAC9B;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B"}
@@ -1,2 +1,2 @@
1
- export * from "./rawbody";
1
+ export * from "./rawbody.js";
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./rawbody"), exports);
17
+ __exportStar(require("./rawbody.js"), exports);
18
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/utils/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAAyB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/utils/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA4B"}
@@ -33,7 +33,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
33
33
  };
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
35
  exports.ensureRawBody = void 0;
36
- const display_1 = require("../../shared/display");
36
+ const display_js_1 = require("../../shared/display.js");
37
37
  const getChunkedRawBody = (req) => __awaiter(void 0, void 0, void 0, function* () {
38
38
  if (req === null || req === void 0 ? void 0 : req.rawBody) {
39
39
  return req.rawBody;
@@ -44,7 +44,7 @@ const getChunkedRawBody = (req) => __awaiter(void 0, void 0, void 0, function* (
44
44
  const rawBodyModule = 'raw-body';
45
45
  try {
46
46
  const _getRawBody = (yield Promise.resolve(`${rawBodyModule}`).then(s => __importStar(require(s)))).default;
47
- if (!req.method || ((0, display_1.lowercase)(req.method) === 'get')) {
47
+ if (!req.method || ((0, display_js_1.lowercase)(req.method) === 'get')) {
48
48
  return undefined;
49
49
  }
50
50
  return _getRawBody(req).then((_rawBody) => _rawBody === null || _rawBody === void 0 ? void 0 : _rawBody.toString());
@@ -1 +1 @@
1
- {"version":3,"file":"rawbody.js","sourceRoot":"","sources":["../../../src/lib/utils/rawbody.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAgD;AAEhD,MAAM,iBAAiB,GAAG,CAAO,GAAG,EAAE,EAAE;IACtC,IAAI,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,EAAE,CAAC;QACjB,OAAO,GAAG,CAAC,OAAO,CAAA;IACpB,CAAC;IAED,gGAAgG;IAChG,sFAAsF;IACtF,yEAAyE;IACzE,MAAM,aAAa,GAAG,UAAU,CAAA;IAChC,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,CAAC,yBAAa,aAAa,uCAAC,CAAC,CAAC,OAAO,CAAA;QAEzD,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,IAAA,mBAAS,EAAC,GAAG,CAAC,MAAM,CAAC,KAAK,KAAK,CAAC,EAAE,CAAC;YACrD,OAAO,SAAS,CAAA;QAClB,CAAC;QAED,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,QAAQ,EAAE,CAAC,CAAA;IAClE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,wEAAwE,CAAC,CAAA;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f,OAAO,CAAC,KAAK,CAAC,wEAAwE,CAAC,CAAA;QACvF,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC,CAAA,CAAA;AAED,yEAAyE;AAClE,MAAM,aAAa,GAAG,CAAO,GAAG,EAAE,EAAE;IAAC,OAAA,CAC1C,iBAAiB,CAAC,GAAG,CAAC;SACnB,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QACf,OAAO,CAAC,KAAK,CAAC,+BAA+B,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,GAAG,GAAG,EAAE,KAAK,CAAC,CAAA;QAChE,MAAM,KAAK,CAAA;IACf,CAAC,CAAC,CACH,CAAA;EAAA,CAAA;AANY,QAAA,aAAa,iBAMzB"}
@@ -1,8 +1,8 @@
1
- import { KeyPairs, RequestParams } from './types';
1
+ import { KeyPairs, RequestParams } from './types.js';
2
2
  export declare const generateStorableKeyPairs: ({ crypto: _crypto, util: _util }?: {
3
3
  crypto?: unknown;
4
4
  util?: unknown;
5
- }) => Promise<{}>;
5
+ }) => Promise<Record<string, string>>;
6
6
  export declare const getVerificationHelpers: ({ keyPairs, util: _util, crypto: _crypto, DISABLE_RECRYPTION, }?: {
7
7
  keyPairs: KeyPairs;
8
8
  crypto?: unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"verification.d.ts","sourceRoot":"","sources":["../../src/lib/verification.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAoB,MAAM,SAAS,CAAA;AAEnE,eAAO,MAAM,wBAAwB,sCAA4C;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,gBAQpH,CAAA;AAED,eAAO,MAAM,sBAAsB;cAMvB,QAAQ;aACT,OAAO;WACT,OAAO;;YAKK;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,WAAW,aAAa;;;iCAuFlF,OAAO;EAkBtD,CAAA"}
1
+ {"version":3,"file":"verification.d.ts","sourceRoot":"","sources":["../../src/lib/verification.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAoB,MAAM,YAAY,CAAA;AAEtE,eAAO,MAAM,wBAAwB,sCAA4C;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,oCAQpH,CAAA;AAED,eAAO,MAAM,sBAAsB;cAMvB,QAAQ;aACT,OAAO;WACT,OAAO;;YAKK;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,WAAW,aAAa;;;iCAuFlF,OAAO;EAkBtD,CAAA"}
@@ -10,13 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.getVerificationHelpers = exports.generateStorableKeyPairs = void 0;
13
- const display_1 = require("../shared/display");
14
- const request_1 = require("../shared/request");
15
- const errors_1 = require("../shared/errors");
16
- const WebCrypto_1 = require("../shared/WebCrypto");
17
- const utils_1 = require("./utils");
13
+ const display_js_1 = require("../shared/display.js");
14
+ const request_js_1 = require("../shared/request.js");
15
+ const errors_js_1 = require("../shared/errors.js");
16
+ const WebCrypto_js_1 = require("../shared/WebCrypto.js");
17
+ const index_js_1 = require("./utils/index.js");
18
18
  const generateStorableKeyPairs = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* ({ crypto: _crypto, util: _util } = {}) {
19
- const webCrypto = new WebCrypto_1.WebCrypto({ crypto: _crypto, util: _util });
19
+ const webCrypto = new WebCrypto_js_1.WebCrypto({ crypto: _crypto, util: _util });
20
20
  const sharedKeyPair = yield webCrypto.generateKeyPair();
21
21
  return webCrypto.getStorableKeyPair({
22
22
  publicKey: sharedKeyPair.publicKey,
@@ -25,26 +25,26 @@ const generateStorableKeyPairs = (...args_1) => __awaiter(void 0, [...args_1], v
25
25
  });
26
26
  exports.generateStorableKeyPairs = generateStorableKeyPairs;
27
27
  const getVerificationHelpers = ({ keyPairs, util: _util, crypto: _crypto, DISABLE_RECRYPTION, } = { keyPairs: {} }) => {
28
- const webCrypto = new WebCrypto_1.WebCrypto({ crypto: _crypto, util: _util });
28
+ const webCrypto = new WebCrypto_js_1.WebCrypto({ crypto: _crypto, util: _util });
29
29
  return (req, params) => __awaiter(void 0, void 0, void 0, function* () {
30
30
  var _a;
31
- const { [request_1.VERIFYD_HEADERS.PUBLIC_KEY]: _apiKey, [request_1.VERIFYD_HEADERS.PUBLIC_KEY.toLowerCase()]: apiKey = _apiKey, [request_1.VERIFYD_HEADERS.EPHEMERAL_KEY]: _ephemeralPublicKey, [request_1.VERIFYD_HEADERS.EPHEMERAL_KEY.toLowerCase()]: ephemeralPublicKey = _ephemeralPublicKey, [request_1.VERIFYD_HEADERS.AUTHORIZATION_TIMESTAMP]: _customAuthTimestamp, [request_1.VERIFYD_HEADERS.AUTHORIZATION_TIMESTAMP.toLowerCase()]: customAuthTimestamp = _customAuthTimestamp, [request_1.VERIFYD_HEADERS.AUTHORIZATION]: _customAuth, [request_1.VERIFYD_HEADERS.AUTHORIZATION.toLowerCase()]: customAuth = _customAuth, } = (_a = req.headers) !== null && _a !== void 0 ? _a : {};
31
+ const { [request_js_1.VERIFYD_HEADERS.PUBLIC_KEY]: _apiKey, [request_js_1.VERIFYD_HEADERS.PUBLIC_KEY.toLowerCase()]: apiKey = _apiKey, [request_js_1.VERIFYD_HEADERS.EPHEMERAL_KEY]: _ephemeralPublicKey, [request_js_1.VERIFYD_HEADERS.EPHEMERAL_KEY.toLowerCase()]: ephemeralPublicKey = _ephemeralPublicKey, [request_js_1.VERIFYD_HEADERS.AUTHORIZATION_TIMESTAMP]: _customAuthTimestamp, [request_js_1.VERIFYD_HEADERS.AUTHORIZATION_TIMESTAMP.toLowerCase()]: customAuthTimestamp = _customAuthTimestamp, [request_js_1.VERIFYD_HEADERS.AUTHORIZATION]: _customAuth, [request_js_1.VERIFYD_HEADERS.AUTHORIZATION.toLowerCase()]: customAuth = _customAuth, } = (_a = req.headers) !== null && _a !== void 0 ? _a : {};
32
32
  const { uri: _uri, disableRecryption: _disableRecryption } = params !== null && params !== void 0 ? params : {};
33
33
  const uri = _uri !== null && _uri !== void 0 ? _uri : req.url;
34
- const disableRecryption = (0, display_1.isTrue)(DISABLE_RECRYPTION) || (0, display_1.isTrue)(_disableRecryption);
34
+ const disableRecryption = (0, display_js_1.isTrue)(DISABLE_RECRYPTION) || (0, display_js_1.isTrue)(_disableRecryption);
35
35
  let isVerifiable = false;
36
36
  try {
37
- const [authProtocol, authSignature] = (0, display_1.ensureString)(customAuth).split(' ');
38
- isVerifiable = (0, display_1.isTrue)(apiKey &&
37
+ const [authProtocol, authSignature] = (0, display_js_1.ensureString)(customAuth).split(' ');
38
+ isVerifiable = (0, display_js_1.isTrue)(apiKey &&
39
39
  ephemeralPublicKey &&
40
40
  customAuthTimestamp &&
41
41
  authSignature &&
42
42
  (authProtocol === 'HMAC-SHA256') &&
43
43
  (keyPairs === null || keyPairs === void 0 ? void 0 : keyPairs.shared));
44
44
  let verificationKeys;
45
- const rawBody = yield (0, utils_1.ensureRawBody)(req);
45
+ const rawBody = yield (0, index_js_1.ensureRawBody)(req);
46
46
  // NOTE: requestBody should be wind up decrypted when isVerifiable (unless disableRecryption, then will pass through)
47
- let requestBody = (0, display_1.safeParse)(rawBody);
47
+ let requestBody = (0, display_js_1.safeParse)(rawBody);
48
48
  // TEMP!!! remove isVerifiable check once web widget moved to react
49
49
  if (isVerifiable) {
50
50
  if (!apiKey ||
@@ -54,27 +54,27 @@ const getVerificationHelpers = ({ keyPairs, util: _util, crypto: _crypto, DISABL
54
54
  (authProtocol !== 'HMAC-SHA256') ||
55
55
  !(keyPairs === null || keyPairs === void 0 ? void 0 : keyPairs.shared) ||
56
56
  (apiKey !== keyPairs.shared.publicKey)) {
57
- throw new errors_1.VerificationError('Invalid or missing authorization', { code: 401 });
57
+ throw new errors_js_1.VerificationError('Invalid or missing authorization', { code: 401 });
58
58
  }
59
59
  verificationKeys = yield webCrypto.getVerificationKeys({
60
60
  publicKey: ephemeralPublicKey,
61
61
  privateKey: keyPairs.shared.privateKey,
62
62
  });
63
- if (!verificationKeys) {
64
- throw new errors_1.VerificationError('Invalid or missing verification', { code: 412 });
63
+ if (!(verificationKeys === null || verificationKeys === void 0 ? void 0 : verificationKeys.derivedHMACKey) || !verificationKeys.derivedSecretKey) {
64
+ throw new errors_js_1.VerificationError('Invalid or missing verification', { code: 412 });
65
65
  }
66
- const verificationPayload = (0, display_1.objectToSortedString)(Object.assign({ method: (0, request_1.getRequestMethod)(rawBody, req.method), timestamp: customAuthTimestamp, body: requestBody }, (0, request_1.normalizeURIParts)(uri)));
66
+ const verificationPayload = (0, display_js_1.objectToSortedString)(Object.assign({ method: (0, request_js_1.getRequestMethod)(rawBody, req.method), timestamp: customAuthTimestamp, body: requestBody }, (0, request_js_1.normalizeURIParts)(uri)));
67
67
  const isValid = yield webCrypto.verifyHMAC(verificationPayload, verificationKeys.derivedHMACKey, authSignature);
68
68
  if (!isValid) {
69
- throw new errors_1.VerificationError('Invalid or missing verification', { code: 403 });
69
+ throw new errors_js_1.VerificationError('Invalid or missing verification', { code: 403 });
70
70
  }
71
71
  if (!disableRecryption && requestBody) {
72
72
  try {
73
73
  const decryptedMessage = yield webCrypto.decryptMessage(requestBody, verificationKeys.derivedSecretKey);
74
- requestBody = (0, display_1.safeParse)(decryptedMessage);
74
+ requestBody = (0, display_js_1.safeParse)(decryptedMessage);
75
75
  }
76
76
  catch (_b) {
77
- throw new errors_1.VerificationError('Error decrypting request', { code: 400 });
77
+ throw new errors_js_1.VerificationError('Error decrypting request', { code: 400 });
78
78
  }
79
79
  }
80
80
  }
@@ -1 +1 @@
1
- {"version":3,"file":"verification.js","sourceRoot":"","sources":["../../src/lib/verification.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAK0B;AAC1B,+CAI0B;AAC1B,6CAAoD;AACpD,mDAA+C;AAC/C,mCAAuC;AAGhC,MAAM,wBAAwB,GAAG,YAAoF,EAAE,mDAA/E,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,KAA2C,EAAE;IACxH,MAAM,SAAS,GAAG,IAAI,qBAAS,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IACjE,MAAM,aAAa,GAAG,MAAM,SAAS,CAAC,eAAe,EAAE,CAAA;IAEvD,OAAO,SAAS,CAAC,kBAAkB,CAAC;QAClC,SAAS,EAAE,aAAa,CAAC,SAAS;QAClC,UAAU,EAAE,aAAa,CAAC,UAAU;KACrC,CAAC,CAAA;AACJ,CAAC,CAAA,CAAA;AARY,QAAA,wBAAwB,4BAQpC;AAEM,MAAM,sBAAsB,GAAG,CAAC,EACrC,QAAQ,EACR,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,OAAO,EACf,kBAAkB,MAMhB,EAAE,QAAQ,EAAE,EAAc,EAAE,EAAE,EAAE;IAClC,MAAM,SAAS,GAAG,IAAI,qBAAS,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;IAEjE,OAAO,CAAO,GAA0F,EAAE,MAAsB,EAAE,EAAE;;QAClI,MAAM,EACJ,CAAC,yBAAe,CAAC,UAAU,CAAC,EAAE,OAAO,EACrC,CAAC,yBAAe,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,EAAE,MAAM,GAAG,OAAiB,EACtE,CAAC,yBAAe,CAAC,aAAa,CAAC,EAAE,mBAAmB,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D,WAAW,GAAG,IAAA,sBAAS,EAAC,gBAAgB,CAAC,CAAA;oBAC3C,CAAC;oBAAC,WAAM,CAAC;wBACP,MAAM,IAAI,6BAAiB,CAAC,0BAA0B,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAA;oBACxE,CAAC;gBACH,CAAC;YACH,CAAC;YAED,MAAM,eAAe,GAAG,CAAO,QAAkB,EAAE,EAAE;gBACnD,IAAI,iBAAiB,IAAI,CAAC,QAAQ,IAAI,CAAC,YAAY,IAAI,CAAC,CAAA,gBAAgB,aAAhB,gBAAgB,uBAAhB,gBAAgB,CAAE,gBAAgB,CAAA,EAAE,CAAC;oBAC3F,OAAO,QAAQ,CAAA;gBACjB,CAAC;gBAED,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,CAAA;YAC9F,CAAC,CAAA,CAAA;YAED,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,CAAA;QAClD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,4CAA4C,GAAG,GAAG,EAAE;gBAChE,KAAK;gBACL,YAAY;gBACZ,iBAAiB;aAClB,CAAC,CAAA;YACF,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC,CAAA,CAAA;AACH,CAAC,CAAA;AAtHY,QAAA,sBAAsB,0BAsHlC"}
@@ -1,2 +1,2 @@
1
- export * from "./useVerification";
1
+ export * from "./useVerification.js";
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./useVerification"), exports);
17
+ __exportStar(require("./useVerification.js"), exports);
18
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/hooks/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/hooks/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAoC"}
@@ -22,12 +22,12 @@ var __rest = (this && this.__rest) || function (s, e) {
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.useVerification = void 0;
24
24
  const react_1 = require("react");
25
- const verification_1 = require("../../shared/verification");
25
+ const verification_js_1 = require("../../shared/verification.js");
26
26
  const useVerification = (_a = {}) => {
27
27
  var { publicKey, disableRecryption } = _a, params = __rest(_a, ["publicKey", "disableRecryption"]);
28
28
  const [keysData, setKeysData] = (0, react_1.useState)();
29
29
  const ensureKeysData = () => __awaiter(void 0, void 0, void 0, function* () {
30
- const _keysData = keysData !== null && keysData !== void 0 ? keysData : (yield (0, verification_1.getVerificationKeysData)(publicKey, params));
30
+ const _keysData = keysData !== null && keysData !== void 0 ? keysData : (yield (0, verification_js_1.getVerificationKeysData)(publicKey, params));
31
31
  if (_keysData && !keysData) {
32
32
  setKeysData(_keysData);
33
33
  }
@@ -35,12 +35,12 @@ const useVerification = (_a = {}) => {
35
35
  });
36
36
  const prepareVerification = (requestPath, requestOptions) => __awaiter(void 0, void 0, void 0, function* () {
37
37
  const _keysData = yield ensureKeysData();
38
- const _prepareVerification = (0, verification_1.prepareVerificationRequest)({ disableRecryption, keysData: _keysData });
38
+ const _prepareVerification = (0, verification_js_1.prepareVerificationRequest)({ disableRecryption, keysData: _keysData });
39
39
  return _prepareVerification(requestPath, requestOptions);
40
40
  });
41
41
  const processResponse = (encryptedResponse, derivedSecretKey) => __awaiter(void 0, void 0, void 0, function* () {
42
42
  const _keysData = yield ensureKeysData();
43
- const _processResponse = (0, verification_1.processVerificationResponse)({ disableRecryption, keysData: _keysData });
43
+ const _processResponse = (0, verification_js_1.processVerificationResponse)({ disableRecryption, keysData: _keysData });
44
44
  return _processResponse(encryptedResponse, derivedSecretKey);
45
45
  });
46
46
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"useVerification.js","sourceRoot":"","sources":["../../../src/react/hooks/useVerification.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAgC;AAEhC,4DAIkC;AAE3B,MAAM,eAAe,GAAG,CAAC,KAA8C,EAAE,EAAE,EAAE;QAApD,EAAE,SAAS,EAAE,iBAAiB,OAAkB,EAAb,MAAM,cAAzC,kCAA2C,CAAF;IACvE,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,GAAE,CAAA;IAE1C,MAAM,cAAc,GAAG,GAAS,EAAE;QAChC,MAAM,SAAS,GAAG,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,CAAC,MAAM,IAAA,sCAAuB,EAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAA;QAChF,IAAI,SAAS,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC3B,WAAW,CAAC,SAAS,CAAC,CAAA;QACxB,CAAC;QAED,OAAO,SAAS,CAAA;IAClB,CAAC,CAAA,CAAA;IAED,MAAM,mBAAmB,GAAG,CAAO,WAAW,EAAE,cAAc,EAAE,EAAE;QAChE,MAAM,SAAS,GAAG,MAAM,cAAc,EAAE,CAAA;QACxC,MAAM,oBAAoB,GAAG,IAAA,yCAA0B,EAAC,EAAE,iBAAiB,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAA;QAEnG,OAAO,oBAAoB,CAAC,WAAW,EAAE,cAAc,CAAC,CAAA;IAC1D,CAAC,CAAA,CAAA;IAED,MAAM,eAAe,GAAG,CAAO,iBAAiB,EAAE,gBAAgB,EAAE,EAAE;QACpE,MAAM,SAAS,GAAG,MAAM,cAAc,EAAE,CAAA;QACxC,MAAM,gBAAgB,GAAG,IAAA,0CAA2B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AAiB,EAAE,gBAAgB,EAAE,EAAE;QACpE,MAAM,SAAS,GAAG,MAAM,cAAc,EAAE,CAAA;QACxC,MAAM,gBAAgB,GAAG,IAAA,6CAA2B,EAAC,EAAE,iBAAiB,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAA;QAEhG,OAAO,gBAAgB,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAA;IAC9D,CAAC,CAAA,CAAA;IAED,OAAO;QACL,mBAAmB;QACnB,eAAe;KAChB,CAAA;AACH,CAAC,CAAA;AA9BY,QAAA,eAAe,mBA8B3B"}
@@ -1,3 +1,3 @@
1
- export * from '../shared/request';
2
- export * from './hooks';
1
+ export * from '../shared/request.js';
2
+ export * from './hooks/index.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA"}
@@ -14,6 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("../shared/request"), exports); // HMMMM: why cant we export WebCrypto class??
18
- __exportStar(require("./hooks"), exports);
17
+ __exportStar(require("../shared/request.js"), exports); // HMMMM: why cant we export WebCrypto class??
18
+ __exportStar(require("./hooks/index.js"), exports);
19
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC,CAAC,8CAA8C;AAChF,0CAAuB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAoC,CAAC,8CAA8C;AACnF,mDAAgC"}