@d4l/collect-lib 1.43.0 → 1.44.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.
package/dist/index.js CHANGED
@@ -40,6 +40,7 @@ function toDeviceConfig(devices) {
40
40
  case "FITBIT":
41
41
  case "GOOGLE_HEALTH":
42
42
  case "OURA":
43
+ case "GARMIN":
43
44
  return {
44
45
  type: "api",
45
46
  device: device.type,
@@ -87,6 +88,7 @@ var DEVICE_KEY_TO_NAME = {
87
88
  FITBIT: { shortName: "fitbit", fullName: "fitbit" },
88
89
  GOOGLE_HEALTH: { shortName: "Google Health", fullName: "Google Health" },
89
90
  OURA: { shortName: "Oura", fullName: "Oura Ring" },
91
+ GARMIN: { shortName: "Garmin", fullName: "Garmin" },
90
92
  DEXCOM: { shortName: "Dexcom", fullName: "Dexcom" },
91
93
  dexcom_g4: { shortName: "Dexcom G4", fullName: "Dexcom G4" },
92
94
  dexcom_g5: { shortName: "Dexcom G5", fullName: "Dexcom G5" },
@@ -424,6 +426,19 @@ var OURA_SIGNAL_TYPE_ANNOTATIONS = {
424
426
  batteryLevel: OURA_BATTERY_LEVEL_ANNOTATION
425
427
  };
426
428
 
429
+ // src/devices/annotations/garmin.ts
430
+ var GARMIN_SIGNAL_TYPE_ANNOTATIONS = {
431
+ heartRate: FITBIT_HEART_RATE_ANNOTATION,
432
+ hrv: FITBIT_HEART_RATE_VARIABILITY_ANNOTATION,
433
+ spo2: FITBIT_SPO2_ANNOTATION,
434
+ sleep: FITBIT_SLEEP_ANNOTATION,
435
+ steps: FITBIT_STEPS_ANNOTATION,
436
+ calories: FITBIT_CALORIES_ANNOTATION,
437
+ respiratoryRate: FITBIT_BREATHING_RATE_ANNOTATION,
438
+ skinTemperature: FITBIT_SKIN_TEMPERATURE_ANNOTATION,
439
+ stress: OURA_STRESS_ANNOTATION
440
+ };
441
+
427
442
  // src/devices/annotations/movella.ts
428
443
  var DEVICE_MOVELLA_ANNOTATION_ITEM_TIMESTAMP = {
429
444
  type: "timestamp",
@@ -2119,6 +2134,9 @@ var MonthFuncs = class extends TimeFuncs {
2119
2134
  }
2120
2135
  };
2121
2136
 
2137
+ // src/collector/sdk.ts
2138
+
2139
+
2122
2140
  // src/donation/keyHandler.ts
2123
2141
  var _utils = require('@noble/curves/abstract/utils'); var secpUtils = _interopRequireWildcard(_utils);
2124
2142
  var _secp256k1 = require('@noble/curves/secp256k1');
@@ -2126,97 +2144,6 @@ var _bip39 = require('@scure/bip39'); var bip39 = _interopRequireWildcard(_bip39
2126
2144
 
2127
2145
  var _nodeforge = require('node-forge'); var forge = _interopRequireWildcard(_nodeforge); var forge2 = _interopRequireWildcard(_nodeforge);
2128
2146
 
2129
- // src/helper/converter.ts
2130
-
2131
- var binaryStringToUint8Array = (binaryString) => {
2132
- return new Uint8Array(binaryString.split("").map((c) => c.charCodeAt(0)));
2133
- };
2134
- var uint8ArrayToBinaryString = (array) => {
2135
- return String.fromCharCode.apply(null, array);
2136
- };
2137
- var utf8ToUint8Array = (string) => {
2138
- const result = [];
2139
- const size = string.length;
2140
- for (let index = 0; index < size; index++) {
2141
- let point = string.charCodeAt(index);
2142
- if (point >= 55296 && point <= 56319 && size > index + 1) {
2143
- const second = string.charCodeAt(index + 1);
2144
- if (second >= 56320 && second <= 57343) {
2145
- point = (point - 55296) * 1024 + second - 56320 + 65536;
2146
- index += 1;
2147
- }
2148
- }
2149
- if (point < 128) {
2150
- result.push(point);
2151
- continue;
2152
- }
2153
- if (point < 2048) {
2154
- result.push(point >> 6 | 192);
2155
- result.push(point & 63 | 128);
2156
- continue;
2157
- }
2158
- if (point < 55296 || point >= 57344 && point < 65536) {
2159
- result.push(point >> 12 | 224);
2160
- result.push(point >> 6 & 63 | 128);
2161
- result.push(point & 63 | 128);
2162
- continue;
2163
- }
2164
- if (point >= 65536 && point <= 1114111) {
2165
- result.push(point >> 18 | 240);
2166
- result.push(point >> 12 & 63 | 128);
2167
- result.push(point >> 6 & 63 | 128);
2168
- result.push(point & 63 | 128);
2169
- continue;
2170
- }
2171
- result.push(239, 191, 189);
2172
- }
2173
- return new Uint8Array(result);
2174
- };
2175
- var WebConverter = class {
2176
- constructor() {
2177
- this.arrayBufferToBase64 = (buffer) => {
2178
- let binary = "";
2179
- const bytes = new Uint8Array(buffer);
2180
- const len = bytes.byteLength;
2181
- for (let i = 0; i < len; i++) {
2182
- binary += String.fromCharCode(bytes[i]);
2183
- }
2184
- return btoa(binary);
2185
- };
2186
- this.base64ToArrayBuffer = (string) => {
2187
- const base64 = atob(string);
2188
- const buffer = new ArrayBuffer(base64.length);
2189
- const bufferView = new Uint8Array(buffer);
2190
- for (let i = 0, base64Len = base64.length; i < base64Len; i++) {
2191
- bufferView[i] = base64.charCodeAt(i);
2192
- }
2193
- return buffer;
2194
- };
2195
- // convert Uint8Array to base64 string
2196
- this.uint8ArrayToBase64 = (array) => {
2197
- return btoa(String.fromCharCode(...array));
2198
- };
2199
- /**
2200
- * Convert a base64 encoded string into Uint8Array
2201
- * @param string The string that needs to be converted into an Uint8Array
2202
- * @returns A Uint8Array
2203
- */
2204
- this.base64ToUint8Array = (string) => new Uint8Array(this.base64ToArrayBuffer(string));
2205
- /**
2206
- * Convert a base64 encoded Uint8Array into a UTF-8 encoded string
2207
- * @param uint The base64 encoded Uint8Array
2208
- * @returns The UTF-8 encoded string
2209
- */
2210
- this.uint8ArrayToUTF8 = (uint) => {
2211
- const decoder = new TextDecoder();
2212
- const str = decoder.decode(uint);
2213
- return _2.Buffer.from(str, "base64").toString("utf8");
2214
- };
2215
- this.base64ToHex = (base64String) => _2.Buffer.from(base64String, "base64").toString("hex");
2216
- this.hexToBase64 = (hexString) => _2.Buffer.from(hexString, "hex").toString("base64");
2217
- }
2218
- };
2219
-
2220
2147
  // src/helper/wordlists.ts
2221
2148
  var _english = require('@scure/bip39/wordlists/english');
2222
2149
  var german = [
@@ -4381,8 +4308,8 @@ var KeyHandler = class {
4381
4308
  */
4382
4309
  this.sign = async (message, priv) => {
4383
4310
  try {
4384
- const sha256 = this.hash(message);
4385
- return _secp256k1.secp256k1.sign(sha256, secpUtils.hexToBytes(this.converter.base64ToHex(priv))).toCompactRawBytes();
4311
+ const sha2563 = this.hash(message);
4312
+ return _secp256k1.secp256k1.sign(sha2563, secpUtils.hexToBytes(this.converter.base64ToHex(priv))).toCompactRawBytes();
4386
4313
  } catch (e) {
4387
4314
  console.error(e);
4388
4315
  throw new Error("could_not_sign" /* COULD_NOT_SIGN */);
@@ -4396,13 +4323,30 @@ var KeyHandler = class {
4396
4323
  * @returns True, if the signature is valid. Otherwise, false.
4397
4324
  */
4398
4325
  this.verify = async (message, signature, pub) => {
4399
- const sha256 = this.hash(message);
4326
+ const sha2563 = this.hash(message);
4400
4327
  return _secp256k1.secp256k1.verify(
4401
4328
  signature,
4402
- binaryStringToUint8Array(sha256),
4403
- this.converter.base64ToUint8Array(pub)
4329
+ secpUtils.hexToBytes(sha2563),
4330
+ this.rawPublicKey(this.converter.base64ToUint8Array(pub))
4404
4331
  );
4405
4332
  };
4333
+ /**
4334
+ * Reduce a donor public key to the raw uncompressed point noble expects — the inverse
4335
+ * of extendPublicKey. The SPKI wrapper ends with the 0x04 point prefix, so the raw key
4336
+ * is simply its last 65 bytes. Already-raw keys are passed through.
4337
+ * @param publicKey SPKI-wrapped (as produced by extendPublicKey) or raw uncompressed key
4338
+ * @returns The 65-byte uncompressed point (0x04 || X || Y)
4339
+ */
4340
+ this.rawPublicKey = (publicKey) => {
4341
+ const UNCOMPRESSED_LENGTH = 65;
4342
+ if (publicKey.length === UNCOMPRESSED_LENGTH) {
4343
+ return publicKey;
4344
+ }
4345
+ if (publicKey.length < UNCOMPRESSED_LENGTH) {
4346
+ throw new Error(`Invalid public key length: ${publicKey.length}`);
4347
+ }
4348
+ return publicKey.subarray(publicKey.length - UNCOMPRESSED_LENGTH);
4349
+ };
4406
4350
  this.converter = converter;
4407
4351
  this.crypto = crypto;
4408
4352
  }
@@ -4417,7 +4361,7 @@ var KeyHandler = class {
4417
4361
  */
4418
4362
  async deriveProgramKeys(recoveryKey, programName) {
4419
4363
  let privateProgramKey = await this.crypto.deriveEncryptionKey(recoveryKey, programName);
4420
- while (!_secp256k1.secp256k1.utils.isValidPrivateKey(privateProgramKey)) {
4364
+ while (!_secp256k1.secp256k1.utils.isValidSecretKey(privateProgramKey)) {
4421
4365
  privateProgramKey = await this.crypto.deriveEncryptionKey(privateProgramKey, programName);
4422
4366
  }
4423
4367
  const publicProgramKey = this.extendPublicKey(_secp256k1.secp256k1.getPublicKey(privateProgramKey, false));
@@ -4428,11 +4372,31 @@ var KeyHandler = class {
4428
4372
  recovery: this.converter.uint8ArrayToBase64(recoveryKey32)
4429
4373
  };
4430
4374
  }
4375
+ /**
4376
+ * Derive the dedicated encryption keypair (secp256k1) as a hierarchical child of the
4377
+ * donor identity, reusing the same one-way KDF as the program key. The public key is
4378
+ * shared with the data-collector (SPKI), which ECIES-encrypts buffered payloads to it;
4379
+ * the private key feeds HybridEncrypter.decryptV4. Deterministic, so it survives reinstall.
4380
+ * @param programPrivateKey The donor identity's base64-encoded program private key (keys.priv)
4381
+ * @returns publicKey (SPKI, base64) and privateKey (secp256k1 scalar, base64 — the same
4382
+ * encoding as the program private key)
4383
+ */
4384
+ async deriveEncryptionKeypair(programPrivateKey) {
4385
+ const seed = secpUtils.hexToBytes(this.converter.base64ToHex(programPrivateKey));
4386
+ let encryptionPrivateKey = await this.crypto.deriveEncryptionKey(seed, "encryption");
4387
+ while (!_secp256k1.secp256k1.utils.isValidSecretKey(encryptionPrivateKey)) {
4388
+ encryptionPrivateKey = await this.crypto.deriveEncryptionKey(encryptionPrivateKey, "encryption");
4389
+ }
4390
+ const encryptionPublicKey = this.extendPublicKey(
4391
+ _secp256k1.secp256k1.getPublicKey(encryptionPrivateKey, false)
4392
+ );
4393
+ return {
4394
+ publicKey: encryptionPublicKey,
4395
+ privateKey: this.converter.uint8ArrayToBase64(encryptionPrivateKey)
4396
+ };
4397
+ }
4431
4398
  };
4432
4399
 
4433
- // src/donation/sdk.ts
4434
-
4435
-
4436
4400
  // src/helper/requester.ts
4437
4401
  var defaultAccessToken = () => Promise.resolve("");
4438
4402
  var Requester = class {
@@ -4531,152 +4495,689 @@ var Requester = class {
4531
4495
  };
4532
4496
  var requester_default = Requester;
4533
4497
 
4534
- // src/donation/blurring.ts
4535
-
4536
- var blurDocument = (document, anonymization) => {
4537
- if (!anonymization || !document) {
4538
- return document;
4498
+ // src/collector/sdk.ts
4499
+ var buildSelfSignedAuthToken = async (keyHandler, converter, pub, priv, token, selfSignSecret) => {
4500
+ const message = JSON.stringify({ token, donorID: pub });
4501
+ const signature = await keyHandler.sign(message + selfSignSecret, priv);
4502
+ const signedMessage = JSON.stringify({
4503
+ messageJSON: message,
4504
+ signature: converter.uint8ArrayToBase64(signature)
4505
+ });
4506
+ return _2.Buffer.from(signedMessage).toString("base64");
4507
+ };
4508
+ var CollectorClient = class {
4509
+ /**
4510
+ * @param selfSignSecret SELF_SIGN_SECRET shared with the collector (and the dispatcher)
4511
+ * @param collectorURL Base URL including the API prefix, e.g. https://collect.dev.d4l-dev.de/api/collector/v1
4512
+ */
4513
+ constructor(selfSignSecret, collectorURL, converter, crypto) {
4514
+ this.selfSignSecret = selfSignSecret;
4515
+ this.api = new requester_default(collectorURL, () => Promise.resolve(""), false);
4516
+ this.keyHandler = new KeyHandler(converter, crypto);
4517
+ this.converter = converter;
4539
4518
  }
4540
- const blurredDocument = __spreadValues({}, document);
4541
- if (isQuestionnaireResponse(blurredDocument)) {
4542
- return blurQuestionnaireResponse(blurredDocument, anonymization);
4519
+ async authenticatedApi(donorIdentity) {
4520
+ const getAuthToken = async () => {
4521
+ const [token] = await this.api.get({ uri: "/token" });
4522
+ return buildSelfSignedAuthToken(
4523
+ this.keyHandler,
4524
+ this.converter,
4525
+ donorIdentity.keys.pub,
4526
+ donorIdentity.keys.priv,
4527
+ token,
4528
+ this.selfSignSecret
4529
+ );
4530
+ };
4531
+ return new requester_default(this.api.baseUrl, getAuthToken, true);
4543
4532
  }
4544
- if (isResearchSubject(blurredDocument)) {
4545
- return blurResearchSubject(blurredDocument, anonymization);
4533
+ /**
4534
+ * The collector's donor endpoints are study-scoped in the URL (mirroring the
4535
+ * data-dispatcher); the study id is the identity's scope (the program name).
4536
+ */
4537
+ studySegment(donorIdentity) {
4538
+ if (!donorIdentity.scope) {
4539
+ throw new Error("donor identity has no study scope; cannot address the collector");
4540
+ }
4541
+ return encodeURIComponent(donorIdentity.scope);
4542
+ }
4543
+ /** Register the donor's Garmin connection and start ingestion. */
4544
+ async connect(donorIdentity, params) {
4545
+ const api = await this.authenticatedApi(donorIdentity);
4546
+ const [response] = await api.put({
4547
+ uri: `/connect/${this.studySegment(donorIdentity)}`,
4548
+ body: JSON.stringify(params)
4549
+ });
4550
+ return response;
4546
4551
  }
4547
- return __spreadValues({}, blurredDocument);
4548
- };
4549
- var blurQuestionnaireResponse = (document, anonymization) => {
4550
- const blur = anonymization == null ? void 0 : anonymization.blur;
4551
- if (blur) {
4552
- return __spreadValues(__spreadValues({}, document), document.authored && {
4553
- authored: blurAuthored(document.authored, blur.authored)
4552
+ /** Pull buffered (encrypted) items with sequence number greater than `since`. */
4553
+ async sync(donorIdentity, since = 0) {
4554
+ const api = await this.authenticatedApi(donorIdentity);
4555
+ const [response] = await api.get({
4556
+ uri: `/sync/${this.studySegment(donorIdentity)}?since=${since}`
4557
+ });
4558
+ return response;
4559
+ }
4560
+ /** Acknowledge items up to (and including) `cursor`; the collector prunes them. */
4561
+ async ack(donorIdentity, cursor) {
4562
+ const api = await this.authenticatedApi(donorIdentity);
4563
+ await api.post({
4564
+ uri: `/sync/${this.studySegment(donorIdentity)}/ack`,
4565
+ body: JSON.stringify({ cursor })
4554
4566
  });
4555
4567
  }
4556
- return document;
4557
- };
4558
- var blurResearchSubject = (document, anonymization) => {
4559
- const programBlur = anonymization == null ? void 0 : anonymization.blur;
4560
- if (programBlur && programBlur.researchSubject) {
4561
- const blurredPeriod = blurPeriod(document.period, programBlur.researchSubject);
4562
- return __spreadValues(__spreadValues({}, document), blurredPeriod && { period: blurredPeriod });
4568
+ /** Revoke the Garmin authorization and purge the donor's token + buffer. */
4569
+ async disconnect(donorIdentity) {
4570
+ const api = await this.authenticatedApi(donorIdentity);
4571
+ await api.post({ uri: `/disconnect/${this.studySegment(donorIdentity)}` });
4563
4572
  }
4564
- return document;
4565
4573
  };
4566
- var blurAuthored = (authored, blurFn) => {
4567
- if (!blurFn) {
4568
- return authored;
4574
+
4575
+ // src/donation/hybridEncryption.ts
4576
+
4577
+
4578
+ // node_modules/@noble/hashes/esm/utils.js
4579
+ function isBytes(a) {
4580
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
4581
+ }
4582
+ function anumber(n) {
4583
+ if (!Number.isSafeInteger(n) || n < 0)
4584
+ throw new Error("positive integer expected, got " + n);
4585
+ }
4586
+ function abytes(b, ...lengths) {
4587
+ if (!isBytes(b))
4588
+ throw new Error("Uint8Array expected");
4589
+ if (lengths.length > 0 && !lengths.includes(b.length))
4590
+ throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
4591
+ }
4592
+ function ahash(h) {
4593
+ if (typeof h !== "function" || typeof h.create !== "function")
4594
+ throw new Error("Hash should be wrapped by utils.createHasher");
4595
+ anumber(h.outputLen);
4596
+ anumber(h.blockLen);
4597
+ }
4598
+ function aexists(instance, checkFinished = true) {
4599
+ if (instance.destroyed)
4600
+ throw new Error("Hash instance has been destroyed");
4601
+ if (checkFinished && instance.finished)
4602
+ throw new Error("Hash#digest() has already been called");
4603
+ }
4604
+ function aoutput(out, instance) {
4605
+ abytes(out);
4606
+ const min = instance.outputLen;
4607
+ if (out.length < min) {
4608
+ throw new Error("digestInto() expects output buffer of length at least " + min);
4569
4609
  }
4570
- const authoredDate = _luxon.DateTime.fromISO(authored);
4571
- if (!authoredDate || !authoredDate.isValid) {
4572
- return authored;
4610
+ }
4611
+ function clean(...arrays) {
4612
+ for (let i = 0; i < arrays.length; i++) {
4613
+ arrays[i].fill(0);
4573
4614
  }
4574
- return blurDate(authoredDate, blurFn).toString();
4575
- };
4576
- var blurPeriod = (period, blurFn) => {
4577
- if (!period) {
4578
- return void 0;
4615
+ }
4616
+ function createView(arr) {
4617
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
4618
+ }
4619
+ function rotr(word, shift) {
4620
+ return word << 32 - shift | word >>> shift;
4621
+ }
4622
+ function utf8ToBytes(str) {
4623
+ if (typeof str !== "string")
4624
+ throw new Error("string expected");
4625
+ return new Uint8Array(new TextEncoder().encode(str));
4626
+ }
4627
+ function toBytes(data) {
4628
+ if (typeof data === "string")
4629
+ data = utf8ToBytes(data);
4630
+ abytes(data);
4631
+ return data;
4632
+ }
4633
+ var Hash = class {
4634
+ };
4635
+ function createHasher(hashCons) {
4636
+ const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
4637
+ const tmp = hashCons();
4638
+ hashC.outputLen = tmp.outputLen;
4639
+ hashC.blockLen = tmp.blockLen;
4640
+ hashC.create = () => hashCons();
4641
+ return hashC;
4642
+ }
4643
+
4644
+ // node_modules/@noble/hashes/esm/hmac.js
4645
+ var HMAC = class extends Hash {
4646
+ constructor(hash, _key) {
4647
+ super();
4648
+ this.finished = false;
4649
+ this.destroyed = false;
4650
+ ahash(hash);
4651
+ const key = toBytes(_key);
4652
+ this.iHash = hash.create();
4653
+ if (typeof this.iHash.update !== "function")
4654
+ throw new Error("Expected instance of class which extends utils.Hash");
4655
+ this.blockLen = this.iHash.blockLen;
4656
+ this.outputLen = this.iHash.outputLen;
4657
+ const blockLen = this.blockLen;
4658
+ const pad = new Uint8Array(blockLen);
4659
+ pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);
4660
+ for (let i = 0; i < pad.length; i++)
4661
+ pad[i] ^= 54;
4662
+ this.iHash.update(pad);
4663
+ this.oHash = hash.create();
4664
+ for (let i = 0; i < pad.length; i++)
4665
+ pad[i] ^= 54 ^ 92;
4666
+ this.oHash.update(pad);
4667
+ clean(pad);
4668
+ }
4669
+ update(buf) {
4670
+ aexists(this);
4671
+ this.iHash.update(buf);
4672
+ return this;
4673
+ }
4674
+ digestInto(out) {
4675
+ aexists(this);
4676
+ abytes(out, this.outputLen);
4677
+ this.finished = true;
4678
+ this.iHash.digestInto(out);
4679
+ this.oHash.update(out);
4680
+ this.oHash.digestInto(out);
4681
+ this.destroy();
4682
+ }
4683
+ digest() {
4684
+ const out = new Uint8Array(this.oHash.outputLen);
4685
+ this.digestInto(out);
4686
+ return out;
4687
+ }
4688
+ _cloneInto(to) {
4689
+ to || (to = Object.create(Object.getPrototypeOf(this), {}));
4690
+ const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
4691
+ to = to;
4692
+ to.finished = finished;
4693
+ to.destroyed = destroyed;
4694
+ to.blockLen = blockLen;
4695
+ to.outputLen = outputLen;
4696
+ to.oHash = oHash._cloneInto(to.oHash);
4697
+ to.iHash = iHash._cloneInto(to.iHash);
4698
+ return to;
4699
+ }
4700
+ clone() {
4701
+ return this._cloneInto();
4702
+ }
4703
+ destroy() {
4704
+ this.destroyed = true;
4705
+ this.oHash.destroy();
4706
+ this.iHash.destroy();
4707
+ }
4708
+ };
4709
+ var hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();
4710
+ hmac.create = (hash, key) => new HMAC(hash, key);
4711
+
4712
+ // node_modules/@noble/hashes/esm/hkdf.js
4713
+ function extract(hash, ikm, salt) {
4714
+ ahash(hash);
4715
+ if (salt === void 0)
4716
+ salt = new Uint8Array(hash.outputLen);
4717
+ return hmac(hash, toBytes(salt), toBytes(ikm));
4718
+ }
4719
+ var HKDF_COUNTER = /* @__PURE__ */ Uint8Array.from([0]);
4720
+ var EMPTY_BUFFER = /* @__PURE__ */ Uint8Array.of();
4721
+ function expand(hash, prk, info, length = 32) {
4722
+ ahash(hash);
4723
+ anumber(length);
4724
+ const olen = hash.outputLen;
4725
+ if (length > 255 * olen)
4726
+ throw new Error("Length should be <= 255*HashLen");
4727
+ const blocks = Math.ceil(length / olen);
4728
+ if (info === void 0)
4729
+ info = EMPTY_BUFFER;
4730
+ const okm = new Uint8Array(blocks * olen);
4731
+ const HMAC2 = hmac.create(hash, prk);
4732
+ const HMACTmp = HMAC2._cloneInto();
4733
+ const T = new Uint8Array(HMAC2.outputLen);
4734
+ for (let counter = 0; counter < blocks; counter++) {
4735
+ HKDF_COUNTER[0] = counter + 1;
4736
+ HMACTmp.update(counter === 0 ? EMPTY_BUFFER : T).update(info).update(HKDF_COUNTER).digestInto(T);
4737
+ okm.set(T, olen * counter);
4738
+ HMAC2._cloneInto(HMACTmp);
4739
+ }
4740
+ HMAC2.destroy();
4741
+ HMACTmp.destroy();
4742
+ clean(T, HKDF_COUNTER);
4743
+ return okm.slice(0, length);
4744
+ }
4745
+ var hkdf = (hash, ikm, salt, info, length) => expand(hash, extract(hash, ikm, salt), info, length);
4746
+
4747
+ // node_modules/@noble/hashes/esm/_md.js
4748
+ function setBigUint64(view, byteOffset, value, isLE) {
4749
+ if (typeof view.setBigUint64 === "function")
4750
+ return view.setBigUint64(byteOffset, value, isLE);
4751
+ const _32n = BigInt(32);
4752
+ const _u32_max = BigInt(4294967295);
4753
+ const wh = Number(value >> _32n & _u32_max);
4754
+ const wl = Number(value & _u32_max);
4755
+ const h = isLE ? 4 : 0;
4756
+ const l = isLE ? 0 : 4;
4757
+ view.setUint32(byteOffset + h, wh, isLE);
4758
+ view.setUint32(byteOffset + l, wl, isLE);
4759
+ }
4760
+ function Chi(a, b, c) {
4761
+ return a & b ^ ~a & c;
4762
+ }
4763
+ function Maj(a, b, c) {
4764
+ return a & b ^ a & c ^ b & c;
4765
+ }
4766
+ var HashMD = class extends Hash {
4767
+ constructor(blockLen, outputLen, padOffset, isLE) {
4768
+ super();
4769
+ this.finished = false;
4770
+ this.length = 0;
4771
+ this.pos = 0;
4772
+ this.destroyed = false;
4773
+ this.blockLen = blockLen;
4774
+ this.outputLen = outputLen;
4775
+ this.padOffset = padOffset;
4776
+ this.isLE = isLE;
4777
+ this.buffer = new Uint8Array(blockLen);
4778
+ this.view = createView(this.buffer);
4779
+ }
4780
+ update(data) {
4781
+ aexists(this);
4782
+ data = toBytes(data);
4783
+ abytes(data);
4784
+ const { view, buffer, blockLen } = this;
4785
+ const len = data.length;
4786
+ for (let pos = 0; pos < len; ) {
4787
+ const take = Math.min(blockLen - this.pos, len - pos);
4788
+ if (take === blockLen) {
4789
+ const dataView = createView(data);
4790
+ for (; blockLen <= len - pos; pos += blockLen)
4791
+ this.process(dataView, pos);
4792
+ continue;
4793
+ }
4794
+ buffer.set(data.subarray(pos, pos + take), this.pos);
4795
+ this.pos += take;
4796
+ pos += take;
4797
+ if (this.pos === blockLen) {
4798
+ this.process(view, 0);
4799
+ this.pos = 0;
4800
+ }
4801
+ }
4802
+ this.length += data.length;
4803
+ this.roundClean();
4804
+ return this;
4805
+ }
4806
+ digestInto(out) {
4807
+ aexists(this);
4808
+ aoutput(out, this);
4809
+ this.finished = true;
4810
+ const { buffer, view, blockLen, isLE } = this;
4811
+ let { pos } = this;
4812
+ buffer[pos++] = 128;
4813
+ clean(this.buffer.subarray(pos));
4814
+ if (this.padOffset > blockLen - pos) {
4815
+ this.process(view, 0);
4816
+ pos = 0;
4817
+ }
4818
+ for (let i = pos; i < blockLen; i++)
4819
+ buffer[i] = 0;
4820
+ setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
4821
+ this.process(view, 0);
4822
+ const oview = createView(out);
4823
+ const len = this.outputLen;
4824
+ if (len % 4)
4825
+ throw new Error("_sha2: outputLen should be aligned to 32bit");
4826
+ const outLen = len / 4;
4827
+ const state = this.get();
4828
+ if (outLen > state.length)
4829
+ throw new Error("_sha2: outputLen bigger than state");
4830
+ for (let i = 0; i < outLen; i++)
4831
+ oview.setUint32(4 * i, state[i], isLE);
4832
+ }
4833
+ digest() {
4834
+ const { buffer, outputLen } = this;
4835
+ this.digestInto(buffer);
4836
+ const res = buffer.slice(0, outputLen);
4837
+ this.destroy();
4838
+ return res;
4839
+ }
4840
+ _cloneInto(to) {
4841
+ to || (to = new this.constructor());
4842
+ to.set(...this.get());
4843
+ const { blockLen, buffer, length, finished, destroyed, pos } = this;
4844
+ to.destroyed = destroyed;
4845
+ to.finished = finished;
4846
+ to.length = length;
4847
+ to.pos = pos;
4848
+ if (length % blockLen)
4849
+ to.buffer.set(buffer);
4850
+ return to;
4851
+ }
4852
+ clone() {
4853
+ return this._cloneInto();
4854
+ }
4855
+ };
4856
+ var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
4857
+ 1779033703,
4858
+ 3144134277,
4859
+ 1013904242,
4860
+ 2773480762,
4861
+ 1359893119,
4862
+ 2600822924,
4863
+ 528734635,
4864
+ 1541459225
4865
+ ]);
4866
+
4867
+ // node_modules/@noble/hashes/esm/sha2.js
4868
+ var SHA256_K = /* @__PURE__ */ Uint32Array.from([
4869
+ 1116352408,
4870
+ 1899447441,
4871
+ 3049323471,
4872
+ 3921009573,
4873
+ 961987163,
4874
+ 1508970993,
4875
+ 2453635748,
4876
+ 2870763221,
4877
+ 3624381080,
4878
+ 310598401,
4879
+ 607225278,
4880
+ 1426881987,
4881
+ 1925078388,
4882
+ 2162078206,
4883
+ 2614888103,
4884
+ 3248222580,
4885
+ 3835390401,
4886
+ 4022224774,
4887
+ 264347078,
4888
+ 604807628,
4889
+ 770255983,
4890
+ 1249150122,
4891
+ 1555081692,
4892
+ 1996064986,
4893
+ 2554220882,
4894
+ 2821834349,
4895
+ 2952996808,
4896
+ 3210313671,
4897
+ 3336571891,
4898
+ 3584528711,
4899
+ 113926993,
4900
+ 338241895,
4901
+ 666307205,
4902
+ 773529912,
4903
+ 1294757372,
4904
+ 1396182291,
4905
+ 1695183700,
4906
+ 1986661051,
4907
+ 2177026350,
4908
+ 2456956037,
4909
+ 2730485921,
4910
+ 2820302411,
4911
+ 3259730800,
4912
+ 3345764771,
4913
+ 3516065817,
4914
+ 3600352804,
4915
+ 4094571909,
4916
+ 275423344,
4917
+ 430227734,
4918
+ 506948616,
4919
+ 659060556,
4920
+ 883997877,
4921
+ 958139571,
4922
+ 1322822218,
4923
+ 1537002063,
4924
+ 1747873779,
4925
+ 1955562222,
4926
+ 2024104815,
4927
+ 2227730452,
4928
+ 2361852424,
4929
+ 2428436474,
4930
+ 2756734187,
4931
+ 3204031479,
4932
+ 3329325298
4933
+ ]);
4934
+ var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
4935
+ var SHA256 = class extends HashMD {
4936
+ constructor(outputLen = 32) {
4937
+ super(64, outputLen, 8, false);
4938
+ this.A = SHA256_IV[0] | 0;
4939
+ this.B = SHA256_IV[1] | 0;
4940
+ this.C = SHA256_IV[2] | 0;
4941
+ this.D = SHA256_IV[3] | 0;
4942
+ this.E = SHA256_IV[4] | 0;
4943
+ this.F = SHA256_IV[5] | 0;
4944
+ this.G = SHA256_IV[6] | 0;
4945
+ this.H = SHA256_IV[7] | 0;
4946
+ }
4947
+ get() {
4948
+ const { A, B, C, D, E, F, G, H } = this;
4949
+ return [A, B, C, D, E, F, G, H];
4950
+ }
4951
+ // prettier-ignore
4952
+ set(A, B, C, D, E, F, G, H) {
4953
+ this.A = A | 0;
4954
+ this.B = B | 0;
4955
+ this.C = C | 0;
4956
+ this.D = D | 0;
4957
+ this.E = E | 0;
4958
+ this.F = F | 0;
4959
+ this.G = G | 0;
4960
+ this.H = H | 0;
4961
+ }
4962
+ process(view, offset) {
4963
+ for (let i = 0; i < 16; i++, offset += 4)
4964
+ SHA256_W[i] = view.getUint32(offset, false);
4965
+ for (let i = 16; i < 64; i++) {
4966
+ const W15 = SHA256_W[i - 15];
4967
+ const W2 = SHA256_W[i - 2];
4968
+ const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
4969
+ const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
4970
+ SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
4971
+ }
4972
+ let { A, B, C, D, E, F, G, H } = this;
4973
+ for (let i = 0; i < 64; i++) {
4974
+ const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
4975
+ const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
4976
+ const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
4977
+ const T2 = sigma0 + Maj(A, B, C) | 0;
4978
+ H = G;
4979
+ G = F;
4980
+ F = E;
4981
+ E = D + T1 | 0;
4982
+ D = C;
4983
+ C = B;
4984
+ B = A;
4985
+ A = T1 + T2 | 0;
4986
+ }
4987
+ A = A + this.A | 0;
4988
+ B = B + this.B | 0;
4989
+ C = C + this.C | 0;
4990
+ D = D + this.D | 0;
4991
+ E = E + this.E | 0;
4992
+ F = F + this.F | 0;
4993
+ G = G + this.G | 0;
4994
+ H = H + this.H | 0;
4995
+ this.set(A, B, C, D, E, F, G, H);
4579
4996
  }
4580
- const startDate = period.start ? _luxon.DateTime.fromISO(period.start) : void 0;
4581
- const endDate = period.end ? _luxon.DateTime.fromISO(period.end) : void 0;
4582
- return __spreadValues(__spreadValues({}, period.start && (startDate && startDate.isValid ? { start: blurDate(startDate, blurFn).toString() } : { start: period.start })), period.end && (endDate && endDate.isValid ? { end: blurDate(endDate, blurFn).toString() } : { end: period.end }));
4583
- };
4584
- var blurDate = (date, blurFn) => {
4585
- const [fn, unit] = blurFn.toLowerCase().split("of");
4586
- if (!["day", "week", "month"].includes(unit)) {
4587
- return date;
4997
+ roundClean() {
4998
+ clean(SHA256_W);
4588
4999
  }
4589
- if (fn === "start") {
4590
- return date.startOf(unit);
4591
- } else if (fn === "end") {
4592
- return date.endOf(unit);
5000
+ destroy() {
5001
+ this.set(0, 0, 0, 0, 0, 0, 0, 0);
5002
+ clean(this.buffer);
4593
5003
  }
4594
- return date;
4595
5004
  };
5005
+ var sha256 = /* @__PURE__ */ createHasher(() => new SHA256());
4596
5006
 
4597
- // src/donation/document.ts
4598
- var StudyNameSystem2 = "http://fhir.data4life.care/r5/CodeSystem/study-name";
4599
- var filterRecords = (records, programName, donation) => {
4600
- return records.filter(
4601
- (record) => record.status === "Deleted" || isValidDocument(record.document, programName)
4602
- ).map((record) => {
4603
- const blurredDocument = blurDocument(
4604
- record.document,
4605
- donation.anonymization
4606
- );
4607
- return {
4608
- document: blurredDocument,
4609
- status: record.status,
4610
- id: record.id
4611
- };
4612
- });
5007
+ // node_modules/@noble/hashes/esm/sha256.js
5008
+ var sha2562 = sha256;
5009
+
5010
+ // src/donation/hybridEncryption.ts
5011
+
5012
+
5013
+
5014
+ // src/helper/converter.ts
5015
+
5016
+ var binaryStringToUint8Array = (binaryString) => {
5017
+ return new Uint8Array(binaryString.split("").map((c) => c.charCodeAt(0)));
4613
5018
  };
4614
- var isValidDocument = (document, programName) => {
4615
- if (typeof document !== "object" || document === null) {
4616
- return false;
4617
- }
4618
- if (isQuestionnaireResponse(document)) {
4619
- const questionnaireResponse = document;
4620
- return hasValidItems(questionnaireResponse);
4621
- }
4622
- if (isResearchSubject(document) && programName) {
4623
- return isAllowedResearchSubject(document, programName);
4624
- }
4625
- if (isObservation(document)) {
4626
- return true;
4627
- }
4628
- if (isConsent(document)) {
4629
- return true;
5019
+ var uint8ArrayToBinaryString = (array) => {
5020
+ const CHUNK_SIZE = 16384;
5021
+ if (array.length <= CHUNK_SIZE) {
5022
+ return String.fromCharCode.apply(null, array);
5023
+ }
5024
+ let result = "";
5025
+ for (let offset = 0; offset < array.length; offset += CHUNK_SIZE) {
5026
+ result += String.fromCharCode.apply(
5027
+ null,
5028
+ array.subarray(offset, offset + CHUNK_SIZE)
5029
+ );
4630
5030
  }
4631
- if (isRecording(document)) {
4632
- return true;
4633
- }
4634
- if (isCommunication(document)) {
4635
- return true;
4636
- }
4637
- return false;
5031
+ return result;
4638
5032
  };
4639
- var isQuestionnaireResponse = (document) => document.resourceType === "QuestionnaireResponse";
4640
- var isResearchSubject = (document) => document.resourceType === "ResearchSubject";
4641
- var isObservation = (document) => document.resourceType === "Observation";
4642
- var isConsent = (document) => document.resourceType === "Consent";
4643
- var isRecording = (document) => (document == null ? void 0 : document.resourceType) === "Bundle";
4644
- var isCommunication = (document) => (document == null ? void 0 : document.resourceType) === "Communication";
4645
- var isAllowedResearchSubject = (document, programName) => {
4646
- if (!document.study || !document.subject || !document.study.identifier) {
4647
- return false;
4648
- }
4649
- if (document.study.identifier.system !== StudyNameSystem2) {
4650
- return false;
4651
- }
4652
- if (document.study.identifier.value !== programName) {
4653
- return false;
5033
+ var utf8ToUint8Array = (string) => {
5034
+ const result = [];
5035
+ const size = string.length;
5036
+ for (let index = 0; index < size; index++) {
5037
+ let point = string.charCodeAt(index);
5038
+ if (point >= 55296 && point <= 56319 && size > index + 1) {
5039
+ const second = string.charCodeAt(index + 1);
5040
+ if (second >= 56320 && second <= 57343) {
5041
+ point = (point - 55296) * 1024 + second - 56320 + 65536;
5042
+ index += 1;
5043
+ }
5044
+ }
5045
+ if (point < 128) {
5046
+ result.push(point);
5047
+ continue;
5048
+ }
5049
+ if (point < 2048) {
5050
+ result.push(point >> 6 | 192);
5051
+ result.push(point & 63 | 128);
5052
+ continue;
5053
+ }
5054
+ if (point < 55296 || point >= 57344 && point < 65536) {
5055
+ result.push(point >> 12 | 224);
5056
+ result.push(point >> 6 & 63 | 128);
5057
+ result.push(point & 63 | 128);
5058
+ continue;
5059
+ }
5060
+ if (point >= 65536 && point <= 1114111) {
5061
+ result.push(point >> 18 | 240);
5062
+ result.push(point >> 12 & 63 | 128);
5063
+ result.push(point >> 6 & 63 | 128);
5064
+ result.push(point & 63 | 128);
5065
+ continue;
5066
+ }
5067
+ result.push(239, 191, 189);
4654
5068
  }
4655
- return true;
4656
- };
4657
- var includedResearchSubjects = (records) => {
4658
- return records.filter((record) => isResearchSubject(record.document));
5069
+ return new Uint8Array(result);
4659
5070
  };
4660
- var hasValidItems = (document) => Array.isArray(document.item) && document.item.every((value) => {
4661
- const validKeys = Object.keys(value).every(
4662
- (key) => ["linkId", "text", "answer", "item"].includes(key)
4663
- );
4664
- if (!validKeys) {
4665
- return false;
4666
- }
4667
- if (value.answer || value.item) {
4668
- return Array.isArray(value.answer || value.item);
5071
+ var WebConverter = class {
5072
+ constructor() {
5073
+ this.arrayBufferToBase64 = (buffer) => {
5074
+ let binary = "";
5075
+ const bytes = new Uint8Array(buffer);
5076
+ const len = bytes.byteLength;
5077
+ for (let i = 0; i < len; i++) {
5078
+ binary += String.fromCharCode(bytes[i]);
5079
+ }
5080
+ return btoa(binary);
5081
+ };
5082
+ this.base64ToArrayBuffer = (string) => {
5083
+ const base64 = atob(string);
5084
+ const buffer = new ArrayBuffer(base64.length);
5085
+ const bufferView = new Uint8Array(buffer);
5086
+ for (let i = 0, base64Len = base64.length; i < base64Len; i++) {
5087
+ bufferView[i] = base64.charCodeAt(i);
5088
+ }
5089
+ return buffer;
5090
+ };
5091
+ // convert Uint8Array to base64 string
5092
+ this.uint8ArrayToBase64 = (array) => {
5093
+ return btoa(String.fromCharCode(...array));
5094
+ };
5095
+ /**
5096
+ * Convert a base64 encoded string into Uint8Array
5097
+ * @param string The string that needs to be converted into an Uint8Array
5098
+ * @returns A Uint8Array
5099
+ */
5100
+ this.base64ToUint8Array = (string) => new Uint8Array(this.base64ToArrayBuffer(string));
5101
+ /**
5102
+ * Convert a base64 encoded Uint8Array into a UTF-8 encoded string
5103
+ * @param uint The base64 encoded Uint8Array
5104
+ * @returns The UTF-8 encoded string
5105
+ */
5106
+ this.uint8ArrayToUTF8 = (uint) => {
5107
+ const decoder = new TextDecoder();
5108
+ const str = decoder.decode(uint);
5109
+ return _2.Buffer.from(str, "base64").toString("utf8");
5110
+ };
5111
+ this.base64ToHex = (base64String) => _2.Buffer.from(base64String, "base64").toString("hex");
5112
+ this.hexToBase64 = (hexString) => _2.Buffer.from(hexString, "hex").toString("base64");
4669
5113
  }
4670
- return true;
4671
- });
5114
+ };
4672
5115
 
4673
5116
  // src/donation/hybridEncryption.ts
4674
-
4675
-
4676
5117
  var AES_BLOCKSIZE = 16;
4677
5118
  var TAG_LENGTH = 16;
4678
5119
  var KEY_LENGTH = 32;
4679
5120
  var HYBRID_ENCRYPTION_VERSION_RECOVERY = 3;
5121
+ var HYBRID_ENCRYPTION_VERSION_V4 = 4;
5122
+ var V4_PAYLOAD_ALG_AES_GCM = 0;
5123
+ var V4_DECRYPTER_MOBILE_APP = 0;
5124
+ var V4_DECRYPTER_DATA_RECEIVER = 1;
5125
+ var V4_KEY_ALG_AES_SYM = 0;
5126
+ var V4_KEY_ALG_RSA_OAEP = 1;
5127
+ var V4_KEY_ALG_EC = 2;
5128
+ var V4_UNCOMPRESSED_PUBKEY_LENGTH = 65;
5129
+ var V4_EC_NONCE_LENGTH = 12;
5130
+ var V4_RECOVERY_NONCE_LENGTH = 12;
5131
+ var V4_PAYLOAD_IV_LENGTH = 12;
5132
+ var V4_GCM_TAG_LENGTH = 16;
5133
+ var V4_EC_SALT = utf8ToUint8Array("d4l/hybrid-v4/ec/salt");
5134
+ var V4_EC_INFO = utf8ToUint8Array("d4l/hybrid-v4/ec/secp256k1/aes256gcm");
5135
+ var v4AesSlot = (decrypterId, symmetricKeyBase64) => ({
5136
+ decrypterId,
5137
+ keyAlg: V4_KEY_ALG_AES_SYM,
5138
+ key: symmetricKeyBase64
5139
+ });
5140
+ var v4RsaSlot = (decrypterId, publicKeyPem) => ({
5141
+ decrypterId,
5142
+ keyAlg: V4_KEY_ALG_RSA_OAEP,
5143
+ key: publicKeyPem
5144
+ });
5145
+ var v4EcSlot = (decrypterId, publicKeyBase64) => ({
5146
+ decrypterId,
5147
+ keyAlg: V4_KEY_ALG_EC,
5148
+ key: publicKeyBase64
5149
+ });
5150
+ var v4AesKey = (decrypterId, symmetricKeyBase64) => ({
5151
+ decrypterId,
5152
+ keyAlg: V4_KEY_ALG_AES_SYM,
5153
+ key: symmetricKeyBase64
5154
+ });
5155
+ var v4RsaKey = (decrypterId, privateKeyPem) => ({
5156
+ decrypterId,
5157
+ keyAlg: V4_KEY_ALG_RSA_OAEP,
5158
+ key: privateKeyPem
5159
+ });
5160
+ var v4EcKey = (decrypterId, privateKeyBase64) => ({
5161
+ decrypterId,
5162
+ keyAlg: V4_KEY_ALG_EC,
5163
+ key: privateKeyBase64
5164
+ });
5165
+ var requireV4Bytes = (bytes, offset, length, what) => {
5166
+ if (length < 0 || offset + length > bytes.length) {
5167
+ throw new Error(
5168
+ `Malformed v4 record: ${what} needs ${length} bytes at offset ${offset}, but the record is only ${bytes.length} bytes`
5169
+ );
5170
+ }
5171
+ };
5172
+ var rawEcPublicKey = (publicKey) => {
5173
+ if (publicKey.length === V4_UNCOMPRESSED_PUBKEY_LENGTH) {
5174
+ return publicKey;
5175
+ }
5176
+ if (publicKey.length < V4_UNCOMPRESSED_PUBKEY_LENGTH) {
5177
+ throw new Error(`Invalid secp256k1 public key length: ${publicKey.length}`);
5178
+ }
5179
+ return publicKey.subarray(publicKey.length - V4_UNCOMPRESSED_PUBKEY_LENGTH);
5180
+ };
4680
5181
  var HybridEncrypter = class {
4681
5182
  constructor(converter) {
4682
5183
  /**
@@ -4768,6 +5269,354 @@ var HybridEncrypter = class {
4768
5269
  );
4769
5270
  return _2.Buffer.from(decryptedDonation).toString("utf8");
4770
5271
  };
5272
+ /**
5273
+ * Decrypt a v4 hybrid ciphertext addressed to the mobile app. The normal path is the EC
5274
+ * slot (ECIES over secp256k1) the data-collector encrypts to the phone's derived key.
5275
+ *
5276
+ * The AES-256 recovery key is a durable fallback across formats, so it is consulted for
5277
+ * two kinds of input:
5278
+ * - a v3 ciphertext, delegated to the legacy recovery-key path (`decrypt`); and
5279
+ * - a v4 ciphertext that carries an AES recovery slot (decrypterId = mobile app,
5280
+ * keyAlg = AES symmetric) but no usable EC slot — the same recovery key that could
5281
+ * recover v3 records then recovers v4 records too.
5282
+ * The EC slot is always preferred when present; the recovery key is only needed to fall
5283
+ * back to the AES slot (or a v3 blob).
5284
+ *
5285
+ * Note the legacy branch is v3-only, matching `decrypt`: v1 (AES-CBC) and v2 (AES-GCM)
5286
+ * are single-recipient formats this library never produced — donations have always been
5287
+ * written with a recovery branch — so a v1/v2 blob is rejected rather than decrypted.
5288
+ * @param privateKey The phone's encryption private key (secp256k1 scalar, base64 — as
5289
+ * returned by KeyHandler.deriveEncryptionKeypair)
5290
+ * @param cipherText The base64-encoded ciphertext (v4, or v3 for the legacy fallback)
5291
+ * @param recoveryKey Base64 recovery key; needed only for the AES-recovery or v3 paths
5292
+ * @returns The decrypted UTF-8 string
5293
+ */
5294
+ this.decryptV4 = (privateKey, cipherText, recoveryKey) => {
5295
+ const version = new Uint8Array(this.converter.base64ToArrayBuffer(cipherText))[0];
5296
+ if (version !== HYBRID_ENCRYPTION_VERSION_V4) {
5297
+ if (recoveryKey === void 0) {
5298
+ throw new Error(`Cannot decrypt v${version} ciphertext without a recovery key`);
5299
+ }
5300
+ return this.decrypt(recoveryKey, cipherText);
5301
+ }
5302
+ const keys = [v4EcKey(V4_DECRYPTER_MOBILE_APP, privateKey)];
5303
+ if (recoveryKey !== void 0) {
5304
+ keys.push(v4AesKey(V4_DECRYPTER_MOBILE_APP, recoveryKey));
5305
+ }
5306
+ const record = this.decodeV4(cipherText);
5307
+ const hasRecoverySlot = record.slots.some(
5308
+ (s) => s.decrypterId === V4_DECRYPTER_MOBILE_APP && s.keyAlg === V4_KEY_ALG_AES_SYM
5309
+ );
5310
+ if (recoveryKey === void 0 && hasRecoverySlot) {
5311
+ throw new Error("v4 ciphertext has an AES recovery slot but no recovery key was provided");
5312
+ }
5313
+ return this.openV4Record(record, keys);
5314
+ };
5315
+ /**
5316
+ * Decrypt a v4 record with an explicit keychain — the generic entry point, mirroring
5317
+ * go-crypto's `NewDecrypterFromKeys`. A slot is opened only by a key whose
5318
+ * (decrypterId, keyAlg) match, and every matching key is tried, so a record carrying
5319
+ * several slots for the same recipient (e.g. a rotated recovery key) still opens.
5320
+ * @param cipherText The base64-encoded v4 ciphertext
5321
+ * @param keys Keychain entries, built with v4EcKey / v4AesKey / v4RsaKey
5322
+ * @returns The decrypted UTF-8 string
5323
+ */
5324
+ this.decryptV4WithKeys = (cipherText, keys) => this.openV4Record(this.decodeV4(cipherText), keys);
5325
+ /** Unwrap the data key with the first matching key, then open the payload. */
5326
+ this.openV4Record = (record, keys) => {
5327
+ const dataKey = this.unwrapV4DataKey(record.slots, keys);
5328
+ const plaintext = this.decryptAESGCM(dataKey, record.payloadIv, record.payload);
5329
+ return _2.Buffer.from(plaintext).toString("utf8");
5330
+ };
5331
+ /**
5332
+ * Parse a v4 record into its slots and payload. Every length comes from the record
5333
+ * itself, so each read is bounds-checked first: a truncated or malformed blob fails as a
5334
+ * clear format error instead of a raw RangeError or a silently short slice.
5335
+ * @param cipherText The base64-encoded v4 ciphertext
5336
+ * @returns The decoded slots, payload IV and payload
5337
+ */
5338
+ this.decodeV4 = (cipherText) => {
5339
+ const buffer = this.converter.base64ToArrayBuffer(cipherText);
5340
+ const bytes = new Uint8Array(buffer);
5341
+ const view = new DataView(buffer);
5342
+ let offset = 0;
5343
+ requireV4Bytes(bytes, offset, 3, "header");
5344
+ const version = view.getUint8(offset);
5345
+ offset += 1;
5346
+ if (version !== HYBRID_ENCRYPTION_VERSION_V4) {
5347
+ throw new Error(`Not a v4 record: version ${version}`);
5348
+ }
5349
+ const payloadAlg = view.getUint8(offset);
5350
+ offset += 1;
5351
+ if (payloadAlg !== V4_PAYLOAD_ALG_AES_GCM) {
5352
+ throw new Error("Unsupported v4 payload algorithm");
5353
+ }
5354
+ const slotCount = view.getUint8(offset);
5355
+ offset += 1;
5356
+ const slots = [];
5357
+ for (let i = 0; i < slotCount; i++) {
5358
+ requireV4Bytes(bytes, offset, 4, `slot ${i} header`);
5359
+ const decrypterId = view.getUint8(offset);
5360
+ offset += 1;
5361
+ const keyAlg = view.getUint8(offset);
5362
+ offset += 1;
5363
+ const slotLen = view.getUint16(offset, true);
5364
+ offset += 2;
5365
+ requireV4Bytes(bytes, offset, slotLen, `slot ${i} body`);
5366
+ slots.push({ decrypterId, keyAlg, blob: bytes.slice(offset, offset + slotLen) });
5367
+ offset += slotLen;
5368
+ }
5369
+ requireV4Bytes(bytes, offset, V4_PAYLOAD_IV_LENGTH + 8, "payload header");
5370
+ const payloadIv = bytes.slice(offset, offset + V4_PAYLOAD_IV_LENGTH);
5371
+ offset += V4_PAYLOAD_IV_LENGTH;
5372
+ const payloadLen = view.getUint32(offset, true);
5373
+ const payloadLenHigh = view.getUint32(offset + 4, true);
5374
+ offset += 8;
5375
+ if (payloadLenHigh !== 0) {
5376
+ throw new Error("v4 payload too large");
5377
+ }
5378
+ requireV4Bytes(bytes, offset, payloadLen, "payload");
5379
+ return { slots, payloadIv, payload: bytes.slice(offset, offset + payloadLen) };
5380
+ };
5381
+ /**
5382
+ * Encrypt plaintext once under a random data key and wrap that key into one slot per
5383
+ * recipient (decryptV4 is the inverse). Slot decrypterIds are opaque to this class; callers
5384
+ * assign their meaning. Mirrors go-crypto's EncryptHybridV4.
5385
+ * @param plaintext The data to encrypt
5386
+ * @param slots One slot per party that must recover the data (see v4AesSlot / v4RsaSlot)
5387
+ * @returns The base64-encoded v4 ciphertext
5388
+ */
5389
+ this.encryptV4 = (plaintext, slots) => {
5390
+ if (slots.length === 0) {
5391
+ throw new Error("encryptV4 requires at least one slot");
5392
+ }
5393
+ const dataKey = binaryStringToUint8Array(this.getDataKey());
5394
+ const payloadIv = binaryStringToUint8Array(forge2.random.getBytesSync(V4_PAYLOAD_IV_LENGTH));
5395
+ const payload = this.encryptAESGCM(dataKey, payloadIv, utf8ToUint8Array(plaintext));
5396
+ const wrapped = slots.map((slot) => ({
5397
+ decrypterId: slot.decrypterId,
5398
+ keyAlg: slot.keyAlg,
5399
+ blob: this.wrapV4Slot(slot, dataKey)
5400
+ }));
5401
+ return this.encodeV4(wrapped, payloadIv, payload);
5402
+ };
5403
+ /** wrapV4Slot wraps dataKey for one recipient, dispatching on the slot's key algorithm. */
5404
+ this.wrapV4Slot = (slot, dataKey) => {
5405
+ switch (slot.keyAlg) {
5406
+ case V4_KEY_ALG_AES_SYM:
5407
+ return this.wrapV4RecoveryDataKey(
5408
+ new Uint8Array(this.converter.base64ToArrayBuffer(slot.key)),
5409
+ dataKey
5410
+ );
5411
+ case V4_KEY_ALG_RSA_OAEP:
5412
+ return this.encryptWithTargetKey(slot.key, uint8ArrayToBinaryString(dataKey)).encryptedDataKey;
5413
+ case V4_KEY_ALG_EC:
5414
+ return this.wrapV4EcDataKey(slot.key, dataKey);
5415
+ default:
5416
+ throw new Error(`encryptV4: unsupported key algorithm ${slot.keyAlg}`);
5417
+ }
5418
+ };
5419
+ /**
5420
+ * Wrap the data key to a secp256k1 public key via ECIES — the inverse of
5421
+ * unwrapV4EcDataKey, and byte-compatible with go-crypto's EC slot:
5422
+ * ephemeral ECDH -> HKDF-SHA256 -> AES-256-GCM.
5423
+ * Slot layout: ephPub(65, uncompressed) | nonce(12) | wrappedDataKey||tag(48).
5424
+ * @param publicKeyBase64 The recipient's SPKI (or raw uncompressed) secp256k1 public key
5425
+ * @param dataKey The payload data key to wrap
5426
+ */
5427
+ this.wrapV4EcDataKey = (publicKeyBase64, dataKey) => {
5428
+ const recipient = rawEcPublicKey(this.converter.base64ToUint8Array(publicKeyBase64));
5429
+ let ephemeralPrivate = binaryStringToUint8Array(forge2.random.getBytesSync(32));
5430
+ while (!_secp256k1.secp256k1.utils.isValidSecretKey(ephemeralPrivate)) {
5431
+ ephemeralPrivate = binaryStringToUint8Array(forge2.random.getBytesSync(32));
5432
+ }
5433
+ const ephemeralPublic = _secp256k1.secp256k1.getPublicKey(ephemeralPrivate, false);
5434
+ const sharedPoint = _secp256k1.secp256k1.getSharedSecret(ephemeralPrivate, recipient);
5435
+ const sharedX = sharedPoint.slice(1, 33);
5436
+ const wrappingKey = hkdf(sha2562, sharedX, V4_EC_SALT, V4_EC_INFO, 32);
5437
+ const nonce = binaryStringToUint8Array(forge2.random.getBytesSync(V4_EC_NONCE_LENGTH));
5438
+ const wrapped = this.encryptAESGCM(wrappingKey, nonce, dataKey);
5439
+ const out = new Uint8Array(ephemeralPublic.length + nonce.length + wrapped.length);
5440
+ out.set(ephemeralPublic, 0);
5441
+ out.set(nonce, ephemeralPublic.length);
5442
+ out.set(wrapped, ephemeralPublic.length + nonce.length);
5443
+ return out;
5444
+ };
5445
+ /**
5446
+ * Wrap the data key under a symmetric key with AES-256-GCM — the inverse of
5447
+ * unwrapV4RecoveryDataKey. Layout: nonce(12) | wrappedDataKey||tag.
5448
+ *
5449
+ * This is deliberately the *same* donor recovery key that v3 uses with AES-CBC: one
5450
+ * key the donor can keep, usable across formats. Reusing it under two modes is safe
5451
+ * here — the modes are never mixed within a record, the key is only ever used to wrap
5452
+ * 32-byte data keys, and GCM is an upgrade over v3's unauthenticated CBC. GCM's
5453
+ * requirement is nonce uniqueness, which a fresh 96-bit random nonce per wrap gives
5454
+ * with an enormous margin at donation volumes (birthday bound ≈ 2^32 wraps per key).
5455
+ */
5456
+ this.wrapV4RecoveryDataKey = (symmetricKey, dataKey) => {
5457
+ const nonce = binaryStringToUint8Array(forge2.random.getBytesSync(V4_RECOVERY_NONCE_LENGTH));
5458
+ const wrapped = this.encryptAESGCM(symmetricKey, nonce, dataKey);
5459
+ const out = new Uint8Array(nonce.length + wrapped.length);
5460
+ out.set(nonce, 0);
5461
+ out.set(wrapped, nonce.length);
5462
+ return out;
5463
+ };
5464
+ /** encodeV4 assembles the v4 record: header | slots | payloadIv | payloadLen | payload. */
5465
+ this.encodeV4 = (slots, payloadIv, payload) => {
5466
+ if (slots.length > 255) {
5467
+ throw new Error(`encryptV4: at most 255 slots are supported, got ${slots.length}`);
5468
+ }
5469
+ for (const slot of slots) {
5470
+ if (slot.decrypterId > 255 || slot.decrypterId < 0) {
5471
+ throw new Error(`encryptV4: decrypterId ${slot.decrypterId} does not fit in a byte`);
5472
+ }
5473
+ if (slot.keyAlg > 255 || slot.keyAlg < 0) {
5474
+ throw new Error(`encryptV4: keyAlg ${slot.keyAlg} does not fit in a byte`);
5475
+ }
5476
+ if (slot.blob.length > 65535) {
5477
+ throw new Error(
5478
+ `encryptV4: wrapped key of ${slot.blob.length} bytes exceeds the slot limit`
5479
+ );
5480
+ }
5481
+ }
5482
+ let total = 3;
5483
+ for (const slot of slots) {
5484
+ total += 2 + 2 + slot.blob.length;
5485
+ }
5486
+ total += payloadIv.length + 8 + payload.length;
5487
+ const buffer = new ArrayBuffer(total);
5488
+ const view = new DataView(buffer);
5489
+ const bytes = new Uint8Array(buffer);
5490
+ let offset = 0;
5491
+ view.setUint8(offset, HYBRID_ENCRYPTION_VERSION_V4);
5492
+ offset += 1;
5493
+ view.setUint8(offset, V4_PAYLOAD_ALG_AES_GCM);
5494
+ offset += 1;
5495
+ view.setUint8(offset, slots.length);
5496
+ offset += 1;
5497
+ for (const slot of slots) {
5498
+ view.setUint8(offset, slot.decrypterId);
5499
+ offset += 1;
5500
+ view.setUint8(offset, slot.keyAlg);
5501
+ offset += 1;
5502
+ view.setUint16(offset, slot.blob.length, true);
5503
+ offset += 2;
5504
+ bytes.set(slot.blob, offset);
5505
+ offset += slot.blob.length;
5506
+ }
5507
+ bytes.set(payloadIv, offset);
5508
+ offset += payloadIv.length;
5509
+ view.setUint32(offset, payload.length, true);
5510
+ view.setUint32(offset + 4, 0, true);
5511
+ offset += 8;
5512
+ bytes.set(payload, offset);
5513
+ return this.converter.arrayBufferToBase64(buffer);
5514
+ };
5515
+ /** Encrypt with AES-256-GCM (ciphertext||tag) — the inverse of decryptAESGCM. */
5516
+ this.encryptAESGCM = (key, iv, plaintext) => {
5517
+ const cipher2 = forge2.cipher.createCipher("AES-GCM", uint8ArrayToBinaryString(key));
5518
+ cipher2.start({ iv: uint8ArrayToBinaryString(iv) });
5519
+ cipher2.update(forge2.util.createBuffer(uint8ArrayToBinaryString(plaintext)));
5520
+ cipher2.finish();
5521
+ const ciphertext = binaryStringToUint8Array(cipher2.output.getBytes());
5522
+ const tag = binaryStringToUint8Array(cipher2.mode.tag.getBytes());
5523
+ const out = new Uint8Array(ciphertext.length + tag.length);
5524
+ out.set(ciphertext, 0);
5525
+ out.set(tag, ciphertext.length);
5526
+ return out;
5527
+ };
5528
+ /**
5529
+ * Recover the payload data key: walk the record's slots and, for each, try every key
5530
+ * whose (decrypterId, keyAlg) match. Same semantics as go-crypto — a slot addressed to
5531
+ * another recipient is ignored, and several slots for the same recipient (rotated keys)
5532
+ * are all attempted, so an unusable one never masks a usable one.
5533
+ * @param slots The record's decoded slots
5534
+ * @param keys The caller's keychain
5535
+ * @returns The unwrapped 32-byte data key
5536
+ */
5537
+ this.unwrapV4DataKey = (slots, keys) => {
5538
+ for (const slot of slots) {
5539
+ for (const key of keys) {
5540
+ if (key.decrypterId !== slot.decrypterId || key.keyAlg !== slot.keyAlg) {
5541
+ continue;
5542
+ }
5543
+ try {
5544
+ return this.unwrapV4Slot(slot, key);
5545
+ } catch (e) {
5546
+ }
5547
+ }
5548
+ }
5549
+ throw new Error("No v4 slot could be opened with the given keys");
5550
+ };
5551
+ /** Unwrap one slot with one matching key, dispatching on the key algorithm. */
5552
+ this.unwrapV4Slot = (slot, key) => {
5553
+ switch (key.keyAlg) {
5554
+ case V4_KEY_ALG_EC:
5555
+ return this.unwrapV4EcDataKey(slot.blob, key.key);
5556
+ case V4_KEY_ALG_AES_SYM:
5557
+ return this.unwrapV4RecoveryDataKey(slot.blob, key.key);
5558
+ case V4_KEY_ALG_RSA_OAEP:
5559
+ return this.unwrapV4RsaDataKey(slot.blob, key.key);
5560
+ default:
5561
+ throw new Error(`Unsupported v4 key algorithm ${key.keyAlg}`);
5562
+ }
5563
+ };
5564
+ /**
5565
+ * Unwrap the data key from an RSA-OAEP slot with a PEM private key — the counterpart of
5566
+ * v4RsaSlot, for a receiver-side (non-phone) decrypter.
5567
+ */
5568
+ this.unwrapV4RsaDataKey = (slot, privateKeyPem) => {
5569
+ const privateKey = forge2.pki.privateKeyFromPem(privateKeyPem);
5570
+ const dataKey = privateKey.decrypt(uint8ArrayToBinaryString(slot), "RSA-OAEP", {
5571
+ md: forge2.md.sha256.create()
5572
+ });
5573
+ return binaryStringToUint8Array(dataKey);
5574
+ };
5575
+ /**
5576
+ * Unwrap the data key from an EC slot via ECIES.
5577
+ * Slot layout: ephPub(65, uncompressed) | nonce(12) | wrappedDataKey||tag(48).
5578
+ */
5579
+ this.unwrapV4EcDataKey = (ecSlot, privateKey) => {
5580
+ const ephemeralPublicKey = ecSlot.slice(0, V4_UNCOMPRESSED_PUBKEY_LENGTH);
5581
+ const ecNonce = ecSlot.slice(
5582
+ V4_UNCOMPRESSED_PUBKEY_LENGTH,
5583
+ V4_UNCOMPRESSED_PUBKEY_LENGTH + V4_EC_NONCE_LENGTH
5584
+ );
5585
+ const wrappedDataKey = ecSlot.slice(V4_UNCOMPRESSED_PUBKEY_LENGTH + V4_EC_NONCE_LENGTH);
5586
+ const privateKeyBytes = this.converter.base64ToUint8Array(privateKey);
5587
+ const sharedPoint = _secp256k1.secp256k1.getSharedSecret(privateKeyBytes, ephemeralPublicKey);
5588
+ const sharedX = sharedPoint.slice(1, 33);
5589
+ const wrappingKey = hkdf(sha2562, sharedX, V4_EC_SALT, V4_EC_INFO, 32);
5590
+ return this.decryptAESGCM(wrappingKey, ecNonce, wrappedDataKey);
5591
+ };
5592
+ /**
5593
+ * Unwrap the data key from an AES recovery slot: the data key wrapped directly under the
5594
+ * base64 AES-256 recovery key (the same key the pre-v4 recovery branch uses).
5595
+ * Slot layout: nonce(12) | wrappedDataKey||tag(48).
5596
+ */
5597
+ this.unwrapV4RecoveryDataKey = (recoverySlot, recoveryKey) => {
5598
+ const nonce = recoverySlot.slice(0, V4_RECOVERY_NONCE_LENGTH);
5599
+ const wrappedDataKey = recoverySlot.slice(V4_RECOVERY_NONCE_LENGTH);
5600
+ const key = new Uint8Array(this.converter.base64ToArrayBuffer(recoveryKey));
5601
+ return this.decryptAESGCM(key, nonce, wrappedDataKey);
5602
+ };
5603
+ /**
5604
+ * Decrypt an AES-256-GCM ciphertext (ciphertext||tag) with a 12-byte nonce.
5605
+ */
5606
+ this.decryptAESGCM = (key, iv, ciphertextWithTag) => {
5607
+ const ciphertext = ciphertextWithTag.slice(0, -V4_GCM_TAG_LENGTH);
5608
+ const tag = ciphertextWithTag.slice(-V4_GCM_TAG_LENGTH);
5609
+ const decipher = forge2.cipher.createDecipher("AES-GCM", uint8ArrayToBinaryString(key));
5610
+ decipher.start({
5611
+ iv: uint8ArrayToBinaryString(iv),
5612
+ tag: forge2.util.createBuffer(uint8ArrayToBinaryString(tag))
5613
+ });
5614
+ decipher.update(forge2.util.createBuffer(uint8ArrayToBinaryString(ciphertext)));
5615
+ if (!decipher.finish()) {
5616
+ throw new Error("AES-GCM authentication failed");
5617
+ }
5618
+ return binaryStringToUint8Array(decipher.output.getBytes());
5619
+ };
4771
5620
  this.getDataKey = () => {
4772
5621
  return forge2.random.getBytesSync(KEY_LENGTH);
4773
5622
  };
@@ -4822,25 +5671,20 @@ var HybridEncrypter = class {
4822
5671
  * @returns The encrypted donation, the used initialization vector and the length of the encrypted donation
4823
5672
  */
4824
5673
  this.encryptDonation = (donation, dataKey) => {
4825
- try {
4826
- const iv = forge2.random.getBytesSync(AES_BLOCKSIZE);
4827
- const cipher2 = forge2.cipher.createCipher("AES-GCM", dataKey);
4828
- cipher2.start({ iv });
4829
- cipher2.update(forge2.util.createBuffer(utf8ToUint8Array(donation)));
4830
- cipher2.finish();
4831
- const encrypted = cipher2.output.getBytes();
4832
- const tag = cipher2.mode.tag.getBytes();
4833
- return {
4834
- iv: binaryStringToUint8Array(iv),
4835
- encrypted: _2.Buffer.concat([
4836
- binaryStringToUint8Array(encrypted),
4837
- binaryStringToUint8Array(tag)
4838
- ])
4839
- };
4840
- } catch (error) {
4841
- console.error(`[HybridEncrypter] encrypt: ${error}`);
4842
- return {};
4843
- }
5674
+ const iv = forge2.random.getBytesSync(AES_BLOCKSIZE);
5675
+ const cipher2 = forge2.cipher.createCipher("AES-GCM", dataKey);
5676
+ cipher2.start({ iv });
5677
+ cipher2.update(forge2.util.createBuffer(utf8ToUint8Array(donation)));
5678
+ cipher2.finish();
5679
+ const encrypted = cipher2.output.getBytes();
5680
+ const tag = cipher2.mode.tag.getBytes();
5681
+ return {
5682
+ iv: binaryStringToUint8Array(iv),
5683
+ encrypted: _2.Buffer.concat([
5684
+ binaryStringToUint8Array(encrypted),
5685
+ binaryStringToUint8Array(tag)
5686
+ ])
5687
+ };
4844
5688
  };
4845
5689
  this.decryptDonation = (dataKey, encryptedDonation, iv) => {
4846
5690
  try {
@@ -4871,6 +5715,148 @@ var setUint8Array = (dataView, offset, values) => {
4871
5715
  return [dataView, offset];
4872
5716
  };
4873
5717
 
5718
+ // src/donation/sdk.ts
5719
+
5720
+
5721
+ // src/donation/blurring.ts
5722
+
5723
+ var blurDocument = (document, anonymization) => {
5724
+ if (!anonymization || !document) {
5725
+ return document;
5726
+ }
5727
+ const blurredDocument = __spreadValues({}, document);
5728
+ if (isQuestionnaireResponse(blurredDocument)) {
5729
+ return blurQuestionnaireResponse(blurredDocument, anonymization);
5730
+ }
5731
+ if (isResearchSubject(blurredDocument)) {
5732
+ return blurResearchSubject(blurredDocument, anonymization);
5733
+ }
5734
+ return __spreadValues({}, blurredDocument);
5735
+ };
5736
+ var blurQuestionnaireResponse = (document, anonymization) => {
5737
+ const blur = anonymization == null ? void 0 : anonymization.blur;
5738
+ if (blur) {
5739
+ return __spreadValues(__spreadValues({}, document), document.authored && {
5740
+ authored: blurAuthored(document.authored, blur.authored)
5741
+ });
5742
+ }
5743
+ return document;
5744
+ };
5745
+ var blurResearchSubject = (document, anonymization) => {
5746
+ const programBlur = anonymization == null ? void 0 : anonymization.blur;
5747
+ if (programBlur && programBlur.researchSubject) {
5748
+ const blurredPeriod = blurPeriod(document.period, programBlur.researchSubject);
5749
+ return __spreadValues(__spreadValues({}, document), blurredPeriod && { period: blurredPeriod });
5750
+ }
5751
+ return document;
5752
+ };
5753
+ var blurAuthored = (authored, blurFn) => {
5754
+ if (!blurFn) {
5755
+ return authored;
5756
+ }
5757
+ const authoredDate = _luxon.DateTime.fromISO(authored);
5758
+ if (!authoredDate || !authoredDate.isValid) {
5759
+ return authored;
5760
+ }
5761
+ return blurDate(authoredDate, blurFn).toString();
5762
+ };
5763
+ var blurPeriod = (period, blurFn) => {
5764
+ if (!period) {
5765
+ return void 0;
5766
+ }
5767
+ const startDate = period.start ? _luxon.DateTime.fromISO(period.start) : void 0;
5768
+ const endDate = period.end ? _luxon.DateTime.fromISO(period.end) : void 0;
5769
+ return __spreadValues(__spreadValues({}, period.start && (startDate && startDate.isValid ? { start: blurDate(startDate, blurFn).toString() } : { start: period.start })), period.end && (endDate && endDate.isValid ? { end: blurDate(endDate, blurFn).toString() } : { end: period.end }));
5770
+ };
5771
+ var blurDate = (date, blurFn) => {
5772
+ const [fn, unit] = blurFn.toLowerCase().split("of");
5773
+ if (!["day", "week", "month"].includes(unit)) {
5774
+ return date;
5775
+ }
5776
+ if (fn === "start") {
5777
+ return date.startOf(unit);
5778
+ } else if (fn === "end") {
5779
+ return date.endOf(unit);
5780
+ }
5781
+ return date;
5782
+ };
5783
+
5784
+ // src/donation/document.ts
5785
+ var StudyNameSystem2 = "http://fhir.data4life.care/r5/CodeSystem/study-name";
5786
+ var filterRecords = (records, programName, donation) => {
5787
+ return records.filter(
5788
+ (record) => record.status === "Deleted" || isValidDocument(record.document, programName)
5789
+ ).map((record) => {
5790
+ const blurredDocument = blurDocument(
5791
+ record.document,
5792
+ donation.anonymization
5793
+ );
5794
+ return {
5795
+ document: blurredDocument,
5796
+ status: record.status,
5797
+ id: record.id
5798
+ };
5799
+ });
5800
+ };
5801
+ var isValidDocument = (document, programName) => {
5802
+ if (typeof document !== "object" || document === null) {
5803
+ return false;
5804
+ }
5805
+ if (isQuestionnaireResponse(document)) {
5806
+ const questionnaireResponse = document;
5807
+ return hasValidItems(questionnaireResponse);
5808
+ }
5809
+ if (isResearchSubject(document) && programName) {
5810
+ return isAllowedResearchSubject(document, programName);
5811
+ }
5812
+ if (isObservation(document)) {
5813
+ return true;
5814
+ }
5815
+ if (isConsent(document)) {
5816
+ return true;
5817
+ }
5818
+ if (isRecording(document)) {
5819
+ return true;
5820
+ }
5821
+ if (isCommunication(document)) {
5822
+ return true;
5823
+ }
5824
+ return false;
5825
+ };
5826
+ var isQuestionnaireResponse = (document) => document.resourceType === "QuestionnaireResponse";
5827
+ var isResearchSubject = (document) => document.resourceType === "ResearchSubject";
5828
+ var isObservation = (document) => document.resourceType === "Observation";
5829
+ var isConsent = (document) => document.resourceType === "Consent";
5830
+ var isRecording = (document) => (document == null ? void 0 : document.resourceType) === "Bundle";
5831
+ var isCommunication = (document) => (document == null ? void 0 : document.resourceType) === "Communication";
5832
+ var isAllowedResearchSubject = (document, programName) => {
5833
+ if (!document.study || !document.subject || !document.study.identifier) {
5834
+ return false;
5835
+ }
5836
+ if (document.study.identifier.system !== StudyNameSystem2) {
5837
+ return false;
5838
+ }
5839
+ if (document.study.identifier.value !== programName) {
5840
+ return false;
5841
+ }
5842
+ return true;
5843
+ };
5844
+ var includedResearchSubjects = (records) => {
5845
+ return records.filter((record) => isResearchSubject(record.document));
5846
+ };
5847
+ var hasValidItems = (document) => Array.isArray(document.item) && document.item.every((value) => {
5848
+ const validKeys = Object.keys(value).every(
5849
+ (key) => ["linkId", "text", "answer", "item"].includes(key)
5850
+ );
5851
+ if (!validKeys) {
5852
+ return false;
5853
+ }
5854
+ if (value.answer || value.item) {
5855
+ return Array.isArray(value.answer || value.item);
5856
+ }
5857
+ return true;
5858
+ });
5859
+
4874
5860
  // src/donation/utils.ts
4875
5861
  var DONOR_IDENTITY_VERSION = 2;
4876
5862
  var isPrivateProgram = (program) => {
@@ -5909,12 +6895,27 @@ var API_TARGET_MAP = {
5909
6895
  dataEndpoint: "https://api.ouraring.com"
5910
6896
  },
5911
6897
  sandbox: {
5912
- // Oura's sandbox shares the OAuth endpoints; only the data paths differ
5913
- // (handled in the device via per-endpoint URI prefixing).
6898
+ // No sandbox for Oura — this mirrors prod and is unused (kept only because the
6899
+ // API_TARGET_MAP type requires a `sandbox` entry for every API).
5914
6900
  loginEndpoint: "https://cloud.ouraring.com/oauth/authorize",
5915
6901
  tokenEndpoint: "https://api.ouraring.com/oauth/token",
5916
6902
  dataEndpoint: "https://api.ouraring.com"
5917
6903
  }
6904
+ },
6905
+ GARMIN: {
6906
+ // Garmin Connect OAuth2 + PKCE (endpoints confirmed against Garmin's OAuth2 PKCE
6907
+ // spec). The phone only captures the authorization code at the HTTPS redirect; the
6908
+ // data-collector exchanges it server-side and receives the data via ping callbacks.
6909
+ prod: {
6910
+ loginEndpoint: "https://connect.garmin.com/oauth2Confirm",
6911
+ tokenEndpoint: "https://diauth.garmin.com/di-oauth2-service/oauth/token",
6912
+ dataEndpoint: "https://apis.garmin.com"
6913
+ },
6914
+ sandbox: {
6915
+ loginEndpoint: "https://connect.garmin.com/oauth2Confirm",
6916
+ tokenEndpoint: "https://diauth.garmin.com/di-oauth2-service/oauth/token",
6917
+ dataEndpoint: "https://apis.garmin.com"
6918
+ }
5918
6919
  }
5919
6920
  };
5920
6921
 
@@ -6178,5 +7179,27 @@ var API_TARGET_MAP = {
6178
7179
 
6179
7180
 
6180
7181
 
6181
- exports.ANDROID_SENSORS_CONSTANT_NAMES = ANDROID_SENSORS_CONSTANT_NAMES; exports.API_TARGET_MAP = API_TARGET_MAP; exports.APPLE_HEALTH_ANNOTATION_ACTIVE_ENERGY = APPLE_HEALTH_ANNOTATION_ACTIVE_ENERGY; exports.APPLE_HEALTH_ANNOTATION_HEART_RATE = APPLE_HEALTH_ANNOTATION_HEART_RATE; exports.APPLE_HEALTH_ANNOTATION_HRV = APPLE_HEALTH_ANNOTATION_HRV; exports.APPLE_HEALTH_ANNOTATION_ITEM_ACTIVE_ENERGY = APPLE_HEALTH_ANNOTATION_ITEM_ACTIVE_ENERGY; exports.APPLE_HEALTH_ANNOTATION_ITEM_HEART_RATE = APPLE_HEALTH_ANNOTATION_ITEM_HEART_RATE; exports.APPLE_HEALTH_ANNOTATION_ITEM_HRV = APPLE_HEALTH_ANNOTATION_ITEM_HRV; exports.APPLE_HEALTH_ANNOTATION_ITEM_RESPIRATORY_RATE = APPLE_HEALTH_ANNOTATION_ITEM_RESPIRATORY_RATE; exports.APPLE_HEALTH_ANNOTATION_ITEM_RESTING_HEART_RATE = APPLE_HEALTH_ANNOTATION_ITEM_RESTING_HEART_RATE; exports.APPLE_HEALTH_ANNOTATION_ITEM_SKIN_TEMPERATURE = APPLE_HEALTH_ANNOTATION_ITEM_SKIN_TEMPERATURE; exports.APPLE_HEALTH_ANNOTATION_ITEM_SLEEP_DURATION = APPLE_HEALTH_ANNOTATION_ITEM_SLEEP_DURATION; exports.APPLE_HEALTH_ANNOTATION_ITEM_SLEEP_STATE = APPLE_HEALTH_ANNOTATION_ITEM_SLEEP_STATE; exports.APPLE_HEALTH_ANNOTATION_ITEM_SPO2 = APPLE_HEALTH_ANNOTATION_ITEM_SPO2; exports.APPLE_HEALTH_ANNOTATION_ITEM_STEP_COUNT = APPLE_HEALTH_ANNOTATION_ITEM_STEP_COUNT; exports.APPLE_HEALTH_ANNOTATION_ITEM_WALKING_RUNNING_DISTANCE = APPLE_HEALTH_ANNOTATION_ITEM_WALKING_RUNNING_DISTANCE; exports.APPLE_HEALTH_ANNOTATION_RESPIRATORY_RATE = APPLE_HEALTH_ANNOTATION_RESPIRATORY_RATE; exports.APPLE_HEALTH_ANNOTATION_RESTING_HEART_RATE = APPLE_HEALTH_ANNOTATION_RESTING_HEART_RATE; exports.APPLE_HEALTH_ANNOTATION_SKIN_TEMPERATURE = APPLE_HEALTH_ANNOTATION_SKIN_TEMPERATURE; exports.APPLE_HEALTH_ANNOTATION_SLEEP_ANALYSIS = APPLE_HEALTH_ANNOTATION_SLEEP_ANALYSIS; exports.APPLE_HEALTH_ANNOTATION_SPO2 = APPLE_HEALTH_ANNOTATION_SPO2; exports.APPLE_HEALTH_ANNOTATION_STEP_COUNT = APPLE_HEALTH_ANNOTATION_STEP_COUNT; exports.APPLE_HEALTH_ANNOTATION_WALKING_RUNNING_DISTANCE = APPLE_HEALTH_ANNOTATION_WALKING_RUNNING_DISTANCE; exports.APPLE_HEALTH_DATA_SOURCES = APPLE_HEALTH_DATA_SOURCES; exports.APPLE_HEALTH_SIGNAL_TYPE_ANNOTATIONS = APPLE_HEALTH_SIGNAL_TYPE_ANNOTATIONS; exports.APPLE_HEALTH_SLEEP_STATE_MAP = APPLE_HEALTH_SLEEP_STATE_MAP; exports.ASMSECGMeasurementAnnotation = ASMSECGMeasurementAnnotation; exports.ASMSSpO2MeasurementAnnotation = ASMSSpO2MeasurementAnnotation; exports.AnswerCodeGuard = AnswerCodeGuard; exports.AnswerDateGuard = AnswerDateGuard; exports.AppIDNamingSystem = AppIDNamingSystem; exports.BLE_ASMS_ANNOTATION_ITEM_ECG = BLE_ASMS_ANNOTATION_ITEM_ECG; exports.BLE_ASMS_ANNOTATION_ITEM_SPO2 = BLE_ASMS_ANNOTATION_ITEM_SPO2; exports.BLE_CPMS_ANNOTATION_ITEM_ACTIVITY_TYPE = BLE_CPMS_ANNOTATION_ITEM_ACTIVITY_TYPE; exports.BLE_CPMS_ANNOTATION_ITEM_DAILY_CALORIES = BLE_CPMS_ANNOTATION_ITEM_DAILY_CALORIES; exports.BLE_CPMS_ANNOTATION_ITEM_DAILY_DISTANCE = BLE_CPMS_ANNOTATION_ITEM_DAILY_DISTANCE; exports.BLE_CPMS_ANNOTATION_ITEM_DAILY_ELEVATION_GAIN = BLE_CPMS_ANNOTATION_ITEM_DAILY_ELEVATION_GAIN; exports.BLE_CPMS_ANNOTATION_ITEM_DAILY_FLOORS = BLE_CPMS_ANNOTATION_ITEM_DAILY_FLOORS; exports.BLE_CPMS_ANNOTATION_ITEM_DAILY_STEPS = BLE_CPMS_ANNOTATION_ITEM_DAILY_STEPS; exports.BLE_PAMS_ANNOTATION_ITEM_ABSOLUTE_ELEVATION = BLE_PAMS_ANNOTATION_ITEM_ABSOLUTE_ELEVATION; exports.BLE_PAMS_ANNOTATION_ITEM_AVERAGE_MOTION_CADENCE = BLE_PAMS_ANNOTATION_ITEM_AVERAGE_MOTION_CADENCE; exports.BLE_PAMS_ANNOTATION_ITEM_AVERAGE_SPEED = BLE_PAMS_ANNOTATION_ITEM_AVERAGE_SPEED; exports.BLE_PAMS_ANNOTATION_ITEM_BYTE = BLE_PAMS_ANNOTATION_ITEM_BYTE; exports.BLE_PAMS_ANNOTATION_ITEM_CALORIES_TOTAL = BLE_PAMS_ANNOTATION_ITEM_CALORIES_TOTAL; exports.BLE_PAMS_ANNOTATION_ITEM_DISTANCE_TOTAL = BLE_PAMS_ANNOTATION_ITEM_DISTANCE_TOTAL; exports.BLE_PAMS_ANNOTATION_ITEM_FLAGS_16 = BLE_PAMS_ANNOTATION_ITEM_FLAGS_16; exports.BLE_PAMS_ANNOTATION_ITEM_FLAGS_24 = BLE_PAMS_ANNOTATION_ITEM_FLAGS_24; exports.BLE_PAMS_ANNOTATION_ITEM_FLAGS_32 = BLE_PAMS_ANNOTATION_ITEM_FLAGS_32; exports.BLE_PAMS_ANNOTATION_ITEM_FLAGS_8 = BLE_PAMS_ANNOTATION_ITEM_FLAGS_8; exports.BLE_PAMS_ANNOTATION_ITEM_FLOORS_TOTAL = BLE_PAMS_ANNOTATION_ITEM_FLOORS_TOTAL; exports.BLE_PAMS_ANNOTATION_ITEM_FOUR_BYTES = BLE_PAMS_ANNOTATION_ITEM_FOUR_BYTES; exports.BLE_PAMS_ANNOTATION_ITEM_HEADER = BLE_PAMS_ANNOTATION_ITEM_HEADER; exports.BLE_PAMS_ANNOTATION_ITEM_HEART_RATE = BLE_PAMS_ANNOTATION_ITEM_HEART_RATE; exports.BLE_PAMS_ANNOTATION_ITEM_MAXIMUM_MOTION_CADENCE = BLE_PAMS_ANNOTATION_ITEM_MAXIMUM_MOTION_CADENCE; exports.BLE_PAMS_ANNOTATION_ITEM_MAXIMUM_SPEED = BLE_PAMS_ANNOTATION_ITEM_MAXIMUM_SPEED; exports.BLE_PAMS_ANNOTATION_ITEM_MINIMUM_MOTION_CADENCE = BLE_PAMS_ANNOTATION_ITEM_MINIMUM_MOTION_CADENCE; exports.BLE_PAMS_ANNOTATION_ITEM_MINIMUM_SPEED = BLE_PAMS_ANNOTATION_ITEM_MINIMUM_SPEED; exports.BLE_PAMS_ANNOTATION_ITEM_MOTION_CADENCE = BLE_PAMS_ANNOTATION_ITEM_MOTION_CADENCE; exports.BLE_PAMS_ANNOTATION_ITEM_NEGATIVE_ELEVATION_GAIN = BLE_PAMS_ANNOTATION_ITEM_NEGATIVE_ELEVATION_GAIN; exports.BLE_PAMS_ANNOTATION_ITEM_POSITIVE_ELEVATION_GAIN = BLE_PAMS_ANNOTATION_ITEM_POSITIVE_ELEVATION_GAIN; exports.BLE_PAMS_ANNOTATION_ITEM_RUNNING_STEPS_TOTAL = BLE_PAMS_ANNOTATION_ITEM_RUNNING_STEPS_TOTAL; exports.BLE_PAMS_ANNOTATION_ITEM_SPEED = BLE_PAMS_ANNOTATION_ITEM_SPEED; exports.BLE_PAMS_ANNOTATION_ITEM_STEPS_TOTAL = BLE_PAMS_ANNOTATION_ITEM_STEPS_TOTAL; exports.BLE_PAMS_ANNOTATION_ITEM_THREE_BYTES = BLE_PAMS_ANNOTATION_ITEM_THREE_BYTES; exports.BLE_PAMS_ANNOTATION_ITEM_TWO_BYTES = BLE_PAMS_ANNOTATION_ITEM_TWO_BYTES; exports.BLE_PAMS_ANNOTATION_ITEM_VO2_MAX = BLE_PAMS_ANNOTATION_ITEM_VO2_MAX; exports.BLE_PSMS_ANNOTATION_ITEM_ACCELERATION = BLE_PSMS_ANNOTATION_ITEM_ACCELERATION; exports.BLE_PSMS_ANNOTATION_ITEM_HEART_RATE = BLE_PSMS_ANNOTATION_ITEM_HEART_RATE; exports.BLE_PSMS_ANNOTATION_ITEM_IBI = BLE_PSMS_ANNOTATION_ITEM_IBI; exports.BLE_PSMS_ANNOTATION_ITEM_PPG_GREEN = BLE_PSMS_ANNOTATION_ITEM_PPG_GREEN; exports.BLE_PSMS_ANNOTATION_ITEM_PPG_IR = BLE_PSMS_ANNOTATION_ITEM_PPG_IR; exports.BLE_PSMS_ANNOTATION_ITEM_PPG_RED = BLE_PSMS_ANNOTATION_ITEM_PPG_RED; exports.BLE_PSMS_ANNOTATION_ITEM_SKIN_TEMPERATURE = BLE_PSMS_ANNOTATION_ITEM_SKIN_TEMPERATURE; exports.BoolGuard = BoolGuard; exports.CPMSHealthServicesActivityDetectionAnnotation = CPMSHealthServicesActivityDetectionAnnotation; exports.CPMSHealthServicesPassiveDataAnnotation = CPMSHealthServicesPassiveDataAnnotation; exports.CommunicationTypeSystem = CommunicationTypeSystem; exports.Conjunction = Conjunction; exports.ConsentGuard = ConsentGuard; exports.ConsentNameSystem = ConsentNameSystem; exports.ConsentVersionSystem = ConsentVersionSystem; exports.CountryValueSet = CountryValueSet; exports.CustomExtensionContextValue = CustomExtensionContextValue; exports.CustomExtensionDate = CustomExtensionDate; exports.CustomExtensionStudyName = CustomExtensionStudyName; exports.CustomQuestionSystem = CustomQuestionSystem; exports.DEVICE_ANNOTATION_HEARTRATE = DEVICE_ANNOTATION_HEARTRATE; exports.DEVICE_ANNOTATION_HRV_RMSSD = DEVICE_ANNOTATION_HRV_RMSSD; exports.DEVICE_ANNOTATION_ITEM_ACCELERATION = DEVICE_ANNOTATION_ITEM_ACCELERATION; exports.DEVICE_ANNOTATION_ITEM_ANGULAR_SPEED = DEVICE_ANNOTATION_ITEM_ANGULAR_SPEED; exports.DEVICE_ANNOTATION_ITEM_BEACON_ID = DEVICE_ANNOTATION_ITEM_BEACON_ID; exports.DEVICE_ANNOTATION_ITEM_DATA_SOURCE = DEVICE_ANNOTATION_ITEM_DATA_SOURCE; exports.DEVICE_ANNOTATION_ITEM_DISTANCE = DEVICE_ANNOTATION_ITEM_DISTANCE; exports.DEVICE_ANNOTATION_ITEM_EGVS = DEVICE_ANNOTATION_ITEM_EGVS; exports.DEVICE_ANNOTATION_ITEM_HEARTRATE = DEVICE_ANNOTATION_ITEM_HEARTRATE; exports.DEVICE_ANNOTATION_ITEM_HRV_RMSSD = DEVICE_ANNOTATION_ITEM_HRV_RMSSD; exports.DEVICE_ANNOTATION_ITEM_MAGNETIC_FIELD = DEVICE_ANNOTATION_ITEM_MAGNETIC_FIELD; exports.DEVICE_ANNOTATION_ITEM_REMOTE_DISTANCE = DEVICE_ANNOTATION_ITEM_REMOTE_DISTANCE; exports.DEVICE_ANNOTATION_ITEM_RSSI = DEVICE_ANNOTATION_ITEM_RSSI; exports.DEVICE_ANNOTATION_ITEM_SKIN_TEMPERATURE_DEVIATION = DEVICE_ANNOTATION_ITEM_SKIN_TEMPERATURE_DEVIATION; exports.DEVICE_ANNOTATION_ITEM_UNIX_TIMESTAMP = DEVICE_ANNOTATION_ITEM_UNIX_TIMESTAMP; exports.DEVICE_ANNOTATION_SKIN_TEMPERATURE_DEVIATION = DEVICE_ANNOTATION_SKIN_TEMPERATURE_DEVIATION; exports.DEVICE_ANNOTATION_TIMESTAMP_NOTE = DEVICE_ANNOTATION_TIMESTAMP_NOTE; exports.DEVICE_ANNOTATION_TIMESTAMP_SIZE = DEVICE_ANNOTATION_TIMESTAMP_SIZE; exports.DEVICE_ANNOTATION_TIMESTAMP_UNIT = DEVICE_ANNOTATION_TIMESTAMP_UNIT; exports.DEVICE_D4L_COMPANION_ANNOTATION_ITEM_DATA_TYPES_FLAG = DEVICE_D4L_COMPANION_ANNOTATION_ITEM_DATA_TYPES_FLAG; exports.DEVICE_D4L_COMPANION_ANNOTATION_ITEM_TIMESTAMP = DEVICE_D4L_COMPANION_ANNOTATION_ITEM_TIMESTAMP; exports.DEVICE_DISPLAY_LABEL_CODING = DEVICE_DISPLAY_LABEL_CODING; exports.DEVICE_KEY_TO_NAME = DEVICE_KEY_TO_NAME; exports.DEVICE_LABEL_CODING = DEVICE_LABEL_CODING; exports.DEVICE_OUTPUT_RATE_CODING = DEVICE_OUTPUT_RATE_CODING; exports.DEVICE_SENSOR_DELAY_CODING = DEVICE_SENSOR_DELAY_CODING; exports.DateGuard = DateGuard; exports.DecimalGuard = DecimalGuard; exports.Disjunction = Disjunction; exports.DonationSDK = DonationSDK; exports.ERROR_CODES = ERROR_CODES; exports.ExistsGuard = ExistsGuard; exports.FITBIT_ANNOTATION_ITEM_BREATHING_RATE = FITBIT_ANNOTATION_ITEM_BREATHING_RATE; exports.FITBIT_ANNOTATION_ITEM_CALORIES = FITBIT_ANNOTATION_ITEM_CALORIES; exports.FITBIT_ANNOTATION_ITEM_HEART_RATE = FITBIT_ANNOTATION_ITEM_HEART_RATE; exports.FITBIT_ANNOTATION_ITEM_HEART_RATE_VARIABILITY = FITBIT_ANNOTATION_ITEM_HEART_RATE_VARIABILITY; exports.FITBIT_ANNOTATION_ITEM_SKIN_TEMPERATURE = FITBIT_ANNOTATION_ITEM_SKIN_TEMPERATURE; exports.FITBIT_ANNOTATION_ITEM_SLEEP_LEVEL = FITBIT_ANNOTATION_ITEM_SLEEP_LEVEL; exports.FITBIT_ANNOTATION_ITEM_SLEEP_LEVEL_DURATION = FITBIT_ANNOTATION_ITEM_SLEEP_LEVEL_DURATION; exports.FITBIT_ANNOTATION_ITEM_SPO2 = FITBIT_ANNOTATION_ITEM_SPO2; exports.FITBIT_ANNOTATION_ITEM_STEPS = FITBIT_ANNOTATION_ITEM_STEPS; exports.FITBIT_BREATHING_RATE_ANNOTATION = FITBIT_BREATHING_RATE_ANNOTATION; exports.FITBIT_CALORIES_ANNOTATION = FITBIT_CALORIES_ANNOTATION; exports.FITBIT_HEART_RATE_ANNOTATION = FITBIT_HEART_RATE_ANNOTATION; exports.FITBIT_HEART_RATE_VARIABILITY_ANNOTATION = FITBIT_HEART_RATE_VARIABILITY_ANNOTATION; exports.FITBIT_SIGNAL_TYPE_ANNOTATIONS = FITBIT_SIGNAL_TYPE_ANNOTATIONS; exports.FITBIT_SKIN_TEMPERATURE_ANNOTATION = FITBIT_SKIN_TEMPERATURE_ANNOTATION; exports.FITBIT_SLEEP_ANNOTATION = FITBIT_SLEEP_ANNOTATION; exports.FITBIT_SLEEP_LEVEL_MAP = FITBIT_SLEEP_LEVEL_MAP; exports.FITBIT_SPO2_ANNOTATION = FITBIT_SPO2_ANNOTATION; exports.FITBIT_STEPS_ANNOTATION = FITBIT_STEPS_ANNOTATION; exports.GOOGLE_HEALTH_SIGNAL_TYPE_ANNOTATIONS = GOOGLE_HEALTH_SIGNAL_TYPE_ANNOTATIONS; exports.HEALTH_CONNECT_ANNOTATION_ITEM_SLEEP_DURATION = HEALTH_CONNECT_ANNOTATION_ITEM_SLEEP_DURATION; exports.HEALTH_CONNECT_ANNOTATION_ITEM_SLEEP_STAGE = HEALTH_CONNECT_ANNOTATION_ITEM_SLEEP_STAGE; exports.HEALTH_CONNECT_ANNOTATION_ITEM_STEPS = HEALTH_CONNECT_ANNOTATION_ITEM_STEPS; exports.HEALTH_CONNECT_DATA_SOURCES = HEALTH_CONNECT_DATA_SOURCES; exports.HEALTH_CONNECT_SIGNAL_TYPE_ANNOTATIONS = HEALTH_CONNECT_SIGNAL_TYPE_ANNOTATIONS; exports.HEALTH_CONNECT_SLEEP_ANNOTATION = HEALTH_CONNECT_SLEEP_ANNOTATION; exports.HEALTH_CONNECT_SLEEP_STAGE_MAP = HEALTH_CONNECT_SLEEP_STAGE_MAP; exports.HEALTH_CONNECT_STEPS_ANNOTATION = HEALTH_CONNECT_STEPS_ANNOTATION; exports.IMUAnnotation = IMUAnnotation; exports.ImageExtension = ImageExtension; exports.InternalSensorAnnotationTypes = InternalSensorAnnotationTypes; exports.Iso3166CodeSystem = Iso3166CodeSystem; exports.KeyHandler = KeyHandler; exports.MaxValueExtension = MaxValueExtension; exports.MeasurementTypeSystem = MeasurementTypeSystem; exports.MinLengthExtension = MinLengthExtension; exports.MinValueExtension = MinValueExtension; exports.OTHER_ANSWER_CODE = OTHER_ANSWER_CODE; exports.OURA_ACTIVITY_ANNOTATION = OURA_ACTIVITY_ANNOTATION; exports.OURA_ANNOTATION_ITEM_ACTIVITY_LEVEL = OURA_ANNOTATION_ITEM_ACTIVITY_LEVEL; exports.OURA_ANNOTATION_ITEM_BATTERY_LEVEL = OURA_ANNOTATION_ITEM_BATTERY_LEVEL; exports.OURA_ANNOTATION_ITEM_CARDIOVASCULAR_AGE = OURA_ANNOTATION_ITEM_CARDIOVASCULAR_AGE; exports.OURA_ANNOTATION_ITEM_STRESS = OURA_ANNOTATION_ITEM_STRESS; exports.OURA_ANNOTATION_ITEM_TAG = OURA_ANNOTATION_ITEM_TAG; exports.OURA_ANNOTATION_ITEM_WORKOUT = OURA_ANNOTATION_ITEM_WORKOUT; exports.OURA_BATTERY_LEVEL_ANNOTATION = OURA_BATTERY_LEVEL_ANNOTATION; exports.OURA_CARDIOVASCULAR_AGE_ANNOTATION = OURA_CARDIOVASCULAR_AGE_ANNOTATION; exports.OURA_SIGNAL_TYPE_ANNOTATIONS = OURA_SIGNAL_TYPE_ANNOTATIONS; exports.OURA_STRESS_ANNOTATION = OURA_STRESS_ANNOTATION; exports.OURA_TAG_ANNOTATION = OURA_TAG_ANNOTATION; exports.OURA_WORKOUT_ANNOTATION = OURA_WORKOUT_ANNOTATION; exports.ObservationTypeSystem = ObservationTypeSystem; exports.Offset = Offset; exports.PAMSCardioVascularActivityAnnotation = PAMSCardioVascularActivityAnnotation; exports.PAMSGeneralActivityInstantaneousAnnotation = PAMSGeneralActivityInstantaneousAnnotation; exports.PAMSGeneralActivitySummaryAnnotation = PAMSGeneralActivitySummaryAnnotation; exports.PAMSStepCounterActivitySummaryAnnotation = PAMSStepCounterActivitySummaryAnnotation; exports.PSMSAccelerationAnnotation = PSMSAccelerationAnnotation; exports.PSMSHeartRateAnnotation = PSMSHeartRateAnnotation; exports.PSMSPPGGreenAnnotation = PSMSPPGGreenAnnotation; exports.PSMSPPGIRAnnotation = PSMSPPGIRAnnotation; exports.PSMSPPGRedAnnotation = PSMSPPGRedAnnotation; exports.PSMSSkinTemperatureAnnotation = PSMSSkinTemperatureAnnotation; exports.PostalCodeCountrySourceExtension = PostalCodeCountrySourceExtension; exports.PostalCodeFixedCountryUrl = PostalCodeFixedCountryUrl; exports.PostalCodeFromItemUrl = PostalCodeFromItemUrl; exports.PrepopulateExtension = PrepopulateExtension; exports.QItemControlDefinition = QItemControlDefinition; exports.RECORDING_MODEL_CURRENT_VERSION = RECORDING_MODEL_CURRENT_VERSION; exports.RECORDING_SIGNAL_MODEL_CURRENT_VERSION = RECORDING_SIGNAL_MODEL_CURRENT_VERSION; exports.RelativeMaxValueExtension = RelativeMaxValueExtension; exports.RelativeMinValueExtension = RelativeMinValueExtension; exports.ResponseGuard = ResponseGuard; exports.RoutineGuard = RoutineGuard; exports.RoutineIsPassiveExtension = RoutineIsPassiveExtension; exports.SIGNAL_DURATION_CODING = SIGNAL_DURATION_CODING; exports.SensorIdentifierSystem = SensorIdentifierSystem; exports.SensorSettingsSystem = SensorSettingsSystem; exports.SensorTypeSystem = SensorTypeSystem; exports.SignalIDSystem = SignalIDSystem; exports.SliderInputLabel = SliderInputLabel; exports.SliderMaxLabelExtension = SliderMaxLabelExtension; exports.SliderMinLabelExtension = SliderMinLabelExtension; exports.SliderOrientationExtension = SliderOrientationExtension; exports.SliderStepSizeExtension = SliderStepSizeExtension; exports.StudyNameSystem = StudyNameSystem; exports.SurveyGuard = SurveyGuard; exports.TimeFuncs = TimeFuncs; exports.TokenNamingSystem = TokenNamingSystem; exports.ULID_REGEX = ULID_REGEX; exports.ULIDtoUUID = ULIDtoUUID; exports.UUID_REGEX = UUID_REGEX; exports.UUIDtoULID = UUIDtoULID; exports.WORDLIST_LANGUAGES = WORDLIST_LANGUAGES; exports.WearOS3AnnotationMap = WearOS3AnnotationMap; exports.WebConverter = WebConverter; exports.YearGuard = YearGuard; exports.binaryStringToUint8Array = binaryStringToUint8Array; exports.calculateQuestionnaireScoreRange = calculateQuestionnaireScoreRange; exports.calculateScoreRangeForItem = calculateScoreRangeForItem; exports.capitalizeFirstLetter = capitalizeFirstLetter; exports.dayFormat = dayFormat; exports.encodeDataSource = encodeDataSource; exports.extractWordsFromRecoveryPhrase = extractWordsFromRecoveryPhrase; exports.generateFHIRConsent = generateFHIRConsent; exports.generateFHIRQuestionnaireScore = generateFHIRQuestionnaireScore; exports.generateFHIRRecordingBundle = generateFHIRRecordingBundle; exports.generateFHIRResearchSubject = generateFHIRResearchSubject; exports.generateFHIRResponse = generateFHIRResponse; exports.generateFHIRSeenDisplay = generateFHIRSeenDisplay; exports.generateFHIRSeenMessage = generateFHIRSeenMessage; exports.generateFHIRTag = generateFHIRTag; exports.generateQuestionGuard = generateQuestionGuard; exports.generateStepGuard = generateStepGuard; exports.generateUrn = generateUrn; exports.get = get; exports.getFollowUpQuestionLinkId = getFollowUpQuestionLinkId; exports.getLanguageOfPassPhrase = getLanguageOfPassPhrase; exports.getMovellaAnnotation = getMovellaAnnotation; exports.getText = getText; exports.getTimeFuncs = getTimeFuncs; exports.indexArrayBy = indexArrayBy; exports.isArrayAnswer = isArrayAnswer; exports.isBeforeStartDate = isBeforeStartDate; exports.isFlatAnswer = isFlatAnswer; exports.isGeoLocationAnswer = isGeoLocationAnswer; exports.isMatrixAnswer = isMatrixAnswer; exports.isNotAfterEndDate = isNotAfterEndDate; exports.isNotBeforeStartDate = isNotBeforeStartDate; exports.isScalarAnswer = isScalarAnswer; exports.isScoreEligible = isScoreEligible; exports.isYearString = isYearString; exports.newStepDateGuard = newStepDateGuard; exports.overwriteTime = overwriteTime; exports.stringToDate = stringToDate; exports.stringToYear = stringToYear; exports.timezonelessDate = timezonelessDate; exports.toDeviceConfig = toDeviceConfig; exports.toQuestionnaireResponseItem = toQuestionnaireResponseItem; exports.uint8ArrayToBinaryString = uint8ArrayToBinaryString; exports.utf8ToUint8Array = utf8ToUint8Array; exports.wordlists = wordlists;
7182
+
7183
+
7184
+
7185
+
7186
+
7187
+
7188
+
7189
+
7190
+
7191
+
7192
+
7193
+
7194
+
7195
+
7196
+
7197
+
7198
+
7199
+ exports.AES_BLOCKSIZE = AES_BLOCKSIZE; exports.ANDROID_SENSORS_CONSTANT_NAMES = ANDROID_SENSORS_CONSTANT_NAMES; exports.API_TARGET_MAP = API_TARGET_MAP; exports.APPLE_HEALTH_ANNOTATION_ACTIVE_ENERGY = APPLE_HEALTH_ANNOTATION_ACTIVE_ENERGY; exports.APPLE_HEALTH_ANNOTATION_HEART_RATE = APPLE_HEALTH_ANNOTATION_HEART_RATE; exports.APPLE_HEALTH_ANNOTATION_HRV = APPLE_HEALTH_ANNOTATION_HRV; exports.APPLE_HEALTH_ANNOTATION_ITEM_ACTIVE_ENERGY = APPLE_HEALTH_ANNOTATION_ITEM_ACTIVE_ENERGY; exports.APPLE_HEALTH_ANNOTATION_ITEM_HEART_RATE = APPLE_HEALTH_ANNOTATION_ITEM_HEART_RATE; exports.APPLE_HEALTH_ANNOTATION_ITEM_HRV = APPLE_HEALTH_ANNOTATION_ITEM_HRV; exports.APPLE_HEALTH_ANNOTATION_ITEM_RESPIRATORY_RATE = APPLE_HEALTH_ANNOTATION_ITEM_RESPIRATORY_RATE; exports.APPLE_HEALTH_ANNOTATION_ITEM_RESTING_HEART_RATE = APPLE_HEALTH_ANNOTATION_ITEM_RESTING_HEART_RATE; exports.APPLE_HEALTH_ANNOTATION_ITEM_SKIN_TEMPERATURE = APPLE_HEALTH_ANNOTATION_ITEM_SKIN_TEMPERATURE; exports.APPLE_HEALTH_ANNOTATION_ITEM_SLEEP_DURATION = APPLE_HEALTH_ANNOTATION_ITEM_SLEEP_DURATION; exports.APPLE_HEALTH_ANNOTATION_ITEM_SLEEP_STATE = APPLE_HEALTH_ANNOTATION_ITEM_SLEEP_STATE; exports.APPLE_HEALTH_ANNOTATION_ITEM_SPO2 = APPLE_HEALTH_ANNOTATION_ITEM_SPO2; exports.APPLE_HEALTH_ANNOTATION_ITEM_STEP_COUNT = APPLE_HEALTH_ANNOTATION_ITEM_STEP_COUNT; exports.APPLE_HEALTH_ANNOTATION_ITEM_WALKING_RUNNING_DISTANCE = APPLE_HEALTH_ANNOTATION_ITEM_WALKING_RUNNING_DISTANCE; exports.APPLE_HEALTH_ANNOTATION_RESPIRATORY_RATE = APPLE_HEALTH_ANNOTATION_RESPIRATORY_RATE; exports.APPLE_HEALTH_ANNOTATION_RESTING_HEART_RATE = APPLE_HEALTH_ANNOTATION_RESTING_HEART_RATE; exports.APPLE_HEALTH_ANNOTATION_SKIN_TEMPERATURE = APPLE_HEALTH_ANNOTATION_SKIN_TEMPERATURE; exports.APPLE_HEALTH_ANNOTATION_SLEEP_ANALYSIS = APPLE_HEALTH_ANNOTATION_SLEEP_ANALYSIS; exports.APPLE_HEALTH_ANNOTATION_SPO2 = APPLE_HEALTH_ANNOTATION_SPO2; exports.APPLE_HEALTH_ANNOTATION_STEP_COUNT = APPLE_HEALTH_ANNOTATION_STEP_COUNT; exports.APPLE_HEALTH_ANNOTATION_WALKING_RUNNING_DISTANCE = APPLE_HEALTH_ANNOTATION_WALKING_RUNNING_DISTANCE; exports.APPLE_HEALTH_DATA_SOURCES = APPLE_HEALTH_DATA_SOURCES; exports.APPLE_HEALTH_SIGNAL_TYPE_ANNOTATIONS = APPLE_HEALTH_SIGNAL_TYPE_ANNOTATIONS; exports.APPLE_HEALTH_SLEEP_STATE_MAP = APPLE_HEALTH_SLEEP_STATE_MAP; exports.ASMSECGMeasurementAnnotation = ASMSECGMeasurementAnnotation; exports.ASMSSpO2MeasurementAnnotation = ASMSSpO2MeasurementAnnotation; exports.AnswerCodeGuard = AnswerCodeGuard; exports.AnswerDateGuard = AnswerDateGuard; exports.AppIDNamingSystem = AppIDNamingSystem; exports.BLE_ASMS_ANNOTATION_ITEM_ECG = BLE_ASMS_ANNOTATION_ITEM_ECG; exports.BLE_ASMS_ANNOTATION_ITEM_SPO2 = BLE_ASMS_ANNOTATION_ITEM_SPO2; exports.BLE_CPMS_ANNOTATION_ITEM_ACTIVITY_TYPE = BLE_CPMS_ANNOTATION_ITEM_ACTIVITY_TYPE; exports.BLE_CPMS_ANNOTATION_ITEM_DAILY_CALORIES = BLE_CPMS_ANNOTATION_ITEM_DAILY_CALORIES; exports.BLE_CPMS_ANNOTATION_ITEM_DAILY_DISTANCE = BLE_CPMS_ANNOTATION_ITEM_DAILY_DISTANCE; exports.BLE_CPMS_ANNOTATION_ITEM_DAILY_ELEVATION_GAIN = BLE_CPMS_ANNOTATION_ITEM_DAILY_ELEVATION_GAIN; exports.BLE_CPMS_ANNOTATION_ITEM_DAILY_FLOORS = BLE_CPMS_ANNOTATION_ITEM_DAILY_FLOORS; exports.BLE_CPMS_ANNOTATION_ITEM_DAILY_STEPS = BLE_CPMS_ANNOTATION_ITEM_DAILY_STEPS; exports.BLE_PAMS_ANNOTATION_ITEM_ABSOLUTE_ELEVATION = BLE_PAMS_ANNOTATION_ITEM_ABSOLUTE_ELEVATION; exports.BLE_PAMS_ANNOTATION_ITEM_AVERAGE_MOTION_CADENCE = BLE_PAMS_ANNOTATION_ITEM_AVERAGE_MOTION_CADENCE; exports.BLE_PAMS_ANNOTATION_ITEM_AVERAGE_SPEED = BLE_PAMS_ANNOTATION_ITEM_AVERAGE_SPEED; exports.BLE_PAMS_ANNOTATION_ITEM_BYTE = BLE_PAMS_ANNOTATION_ITEM_BYTE; exports.BLE_PAMS_ANNOTATION_ITEM_CALORIES_TOTAL = BLE_PAMS_ANNOTATION_ITEM_CALORIES_TOTAL; exports.BLE_PAMS_ANNOTATION_ITEM_DISTANCE_TOTAL = BLE_PAMS_ANNOTATION_ITEM_DISTANCE_TOTAL; exports.BLE_PAMS_ANNOTATION_ITEM_FLAGS_16 = BLE_PAMS_ANNOTATION_ITEM_FLAGS_16; exports.BLE_PAMS_ANNOTATION_ITEM_FLAGS_24 = BLE_PAMS_ANNOTATION_ITEM_FLAGS_24; exports.BLE_PAMS_ANNOTATION_ITEM_FLAGS_32 = BLE_PAMS_ANNOTATION_ITEM_FLAGS_32; exports.BLE_PAMS_ANNOTATION_ITEM_FLAGS_8 = BLE_PAMS_ANNOTATION_ITEM_FLAGS_8; exports.BLE_PAMS_ANNOTATION_ITEM_FLOORS_TOTAL = BLE_PAMS_ANNOTATION_ITEM_FLOORS_TOTAL; exports.BLE_PAMS_ANNOTATION_ITEM_FOUR_BYTES = BLE_PAMS_ANNOTATION_ITEM_FOUR_BYTES; exports.BLE_PAMS_ANNOTATION_ITEM_HEADER = BLE_PAMS_ANNOTATION_ITEM_HEADER; exports.BLE_PAMS_ANNOTATION_ITEM_HEART_RATE = BLE_PAMS_ANNOTATION_ITEM_HEART_RATE; exports.BLE_PAMS_ANNOTATION_ITEM_MAXIMUM_MOTION_CADENCE = BLE_PAMS_ANNOTATION_ITEM_MAXIMUM_MOTION_CADENCE; exports.BLE_PAMS_ANNOTATION_ITEM_MAXIMUM_SPEED = BLE_PAMS_ANNOTATION_ITEM_MAXIMUM_SPEED; exports.BLE_PAMS_ANNOTATION_ITEM_MINIMUM_MOTION_CADENCE = BLE_PAMS_ANNOTATION_ITEM_MINIMUM_MOTION_CADENCE; exports.BLE_PAMS_ANNOTATION_ITEM_MINIMUM_SPEED = BLE_PAMS_ANNOTATION_ITEM_MINIMUM_SPEED; exports.BLE_PAMS_ANNOTATION_ITEM_MOTION_CADENCE = BLE_PAMS_ANNOTATION_ITEM_MOTION_CADENCE; exports.BLE_PAMS_ANNOTATION_ITEM_NEGATIVE_ELEVATION_GAIN = BLE_PAMS_ANNOTATION_ITEM_NEGATIVE_ELEVATION_GAIN; exports.BLE_PAMS_ANNOTATION_ITEM_POSITIVE_ELEVATION_GAIN = BLE_PAMS_ANNOTATION_ITEM_POSITIVE_ELEVATION_GAIN; exports.BLE_PAMS_ANNOTATION_ITEM_RUNNING_STEPS_TOTAL = BLE_PAMS_ANNOTATION_ITEM_RUNNING_STEPS_TOTAL; exports.BLE_PAMS_ANNOTATION_ITEM_SPEED = BLE_PAMS_ANNOTATION_ITEM_SPEED; exports.BLE_PAMS_ANNOTATION_ITEM_STEPS_TOTAL = BLE_PAMS_ANNOTATION_ITEM_STEPS_TOTAL; exports.BLE_PAMS_ANNOTATION_ITEM_THREE_BYTES = BLE_PAMS_ANNOTATION_ITEM_THREE_BYTES; exports.BLE_PAMS_ANNOTATION_ITEM_TWO_BYTES = BLE_PAMS_ANNOTATION_ITEM_TWO_BYTES; exports.BLE_PAMS_ANNOTATION_ITEM_VO2_MAX = BLE_PAMS_ANNOTATION_ITEM_VO2_MAX; exports.BLE_PSMS_ANNOTATION_ITEM_ACCELERATION = BLE_PSMS_ANNOTATION_ITEM_ACCELERATION; exports.BLE_PSMS_ANNOTATION_ITEM_HEART_RATE = BLE_PSMS_ANNOTATION_ITEM_HEART_RATE; exports.BLE_PSMS_ANNOTATION_ITEM_IBI = BLE_PSMS_ANNOTATION_ITEM_IBI; exports.BLE_PSMS_ANNOTATION_ITEM_PPG_GREEN = BLE_PSMS_ANNOTATION_ITEM_PPG_GREEN; exports.BLE_PSMS_ANNOTATION_ITEM_PPG_IR = BLE_PSMS_ANNOTATION_ITEM_PPG_IR; exports.BLE_PSMS_ANNOTATION_ITEM_PPG_RED = BLE_PSMS_ANNOTATION_ITEM_PPG_RED; exports.BLE_PSMS_ANNOTATION_ITEM_SKIN_TEMPERATURE = BLE_PSMS_ANNOTATION_ITEM_SKIN_TEMPERATURE; exports.BoolGuard = BoolGuard; exports.CPMSHealthServicesActivityDetectionAnnotation = CPMSHealthServicesActivityDetectionAnnotation; exports.CPMSHealthServicesPassiveDataAnnotation = CPMSHealthServicesPassiveDataAnnotation; exports.CollectorClient = CollectorClient; exports.CommunicationTypeSystem = CommunicationTypeSystem; exports.Conjunction = Conjunction; exports.ConsentGuard = ConsentGuard; exports.ConsentNameSystem = ConsentNameSystem; exports.ConsentVersionSystem = ConsentVersionSystem; exports.CountryValueSet = CountryValueSet; exports.CustomExtensionContextValue = CustomExtensionContextValue; exports.CustomExtensionDate = CustomExtensionDate; exports.CustomExtensionStudyName = CustomExtensionStudyName; exports.CustomQuestionSystem = CustomQuestionSystem; exports.DEVICE_ANNOTATION_HEARTRATE = DEVICE_ANNOTATION_HEARTRATE; exports.DEVICE_ANNOTATION_HRV_RMSSD = DEVICE_ANNOTATION_HRV_RMSSD; exports.DEVICE_ANNOTATION_ITEM_ACCELERATION = DEVICE_ANNOTATION_ITEM_ACCELERATION; exports.DEVICE_ANNOTATION_ITEM_ANGULAR_SPEED = DEVICE_ANNOTATION_ITEM_ANGULAR_SPEED; exports.DEVICE_ANNOTATION_ITEM_BEACON_ID = DEVICE_ANNOTATION_ITEM_BEACON_ID; exports.DEVICE_ANNOTATION_ITEM_DATA_SOURCE = DEVICE_ANNOTATION_ITEM_DATA_SOURCE; exports.DEVICE_ANNOTATION_ITEM_DISTANCE = DEVICE_ANNOTATION_ITEM_DISTANCE; exports.DEVICE_ANNOTATION_ITEM_EGVS = DEVICE_ANNOTATION_ITEM_EGVS; exports.DEVICE_ANNOTATION_ITEM_HEARTRATE = DEVICE_ANNOTATION_ITEM_HEARTRATE; exports.DEVICE_ANNOTATION_ITEM_HRV_RMSSD = DEVICE_ANNOTATION_ITEM_HRV_RMSSD; exports.DEVICE_ANNOTATION_ITEM_MAGNETIC_FIELD = DEVICE_ANNOTATION_ITEM_MAGNETIC_FIELD; exports.DEVICE_ANNOTATION_ITEM_REMOTE_DISTANCE = DEVICE_ANNOTATION_ITEM_REMOTE_DISTANCE; exports.DEVICE_ANNOTATION_ITEM_RSSI = DEVICE_ANNOTATION_ITEM_RSSI; exports.DEVICE_ANNOTATION_ITEM_SKIN_TEMPERATURE_DEVIATION = DEVICE_ANNOTATION_ITEM_SKIN_TEMPERATURE_DEVIATION; exports.DEVICE_ANNOTATION_ITEM_UNIX_TIMESTAMP = DEVICE_ANNOTATION_ITEM_UNIX_TIMESTAMP; exports.DEVICE_ANNOTATION_SKIN_TEMPERATURE_DEVIATION = DEVICE_ANNOTATION_SKIN_TEMPERATURE_DEVIATION; exports.DEVICE_ANNOTATION_TIMESTAMP_NOTE = DEVICE_ANNOTATION_TIMESTAMP_NOTE; exports.DEVICE_ANNOTATION_TIMESTAMP_SIZE = DEVICE_ANNOTATION_TIMESTAMP_SIZE; exports.DEVICE_ANNOTATION_TIMESTAMP_UNIT = DEVICE_ANNOTATION_TIMESTAMP_UNIT; exports.DEVICE_D4L_COMPANION_ANNOTATION_ITEM_DATA_TYPES_FLAG = DEVICE_D4L_COMPANION_ANNOTATION_ITEM_DATA_TYPES_FLAG; exports.DEVICE_D4L_COMPANION_ANNOTATION_ITEM_TIMESTAMP = DEVICE_D4L_COMPANION_ANNOTATION_ITEM_TIMESTAMP; exports.DEVICE_DISPLAY_LABEL_CODING = DEVICE_DISPLAY_LABEL_CODING; exports.DEVICE_KEY_TO_NAME = DEVICE_KEY_TO_NAME; exports.DEVICE_LABEL_CODING = DEVICE_LABEL_CODING; exports.DEVICE_OUTPUT_RATE_CODING = DEVICE_OUTPUT_RATE_CODING; exports.DEVICE_SENSOR_DELAY_CODING = DEVICE_SENSOR_DELAY_CODING; exports.DateGuard = DateGuard; exports.DecimalGuard = DecimalGuard; exports.Disjunction = Disjunction; exports.DonationSDK = DonationSDK; exports.ERROR_CODES = ERROR_CODES; exports.ExistsGuard = ExistsGuard; exports.FITBIT_ANNOTATION_ITEM_BREATHING_RATE = FITBIT_ANNOTATION_ITEM_BREATHING_RATE; exports.FITBIT_ANNOTATION_ITEM_CALORIES = FITBIT_ANNOTATION_ITEM_CALORIES; exports.FITBIT_ANNOTATION_ITEM_HEART_RATE = FITBIT_ANNOTATION_ITEM_HEART_RATE; exports.FITBIT_ANNOTATION_ITEM_HEART_RATE_VARIABILITY = FITBIT_ANNOTATION_ITEM_HEART_RATE_VARIABILITY; exports.FITBIT_ANNOTATION_ITEM_SKIN_TEMPERATURE = FITBIT_ANNOTATION_ITEM_SKIN_TEMPERATURE; exports.FITBIT_ANNOTATION_ITEM_SLEEP_LEVEL = FITBIT_ANNOTATION_ITEM_SLEEP_LEVEL; exports.FITBIT_ANNOTATION_ITEM_SLEEP_LEVEL_DURATION = FITBIT_ANNOTATION_ITEM_SLEEP_LEVEL_DURATION; exports.FITBIT_ANNOTATION_ITEM_SPO2 = FITBIT_ANNOTATION_ITEM_SPO2; exports.FITBIT_ANNOTATION_ITEM_STEPS = FITBIT_ANNOTATION_ITEM_STEPS; exports.FITBIT_BREATHING_RATE_ANNOTATION = FITBIT_BREATHING_RATE_ANNOTATION; exports.FITBIT_CALORIES_ANNOTATION = FITBIT_CALORIES_ANNOTATION; exports.FITBIT_HEART_RATE_ANNOTATION = FITBIT_HEART_RATE_ANNOTATION; exports.FITBIT_HEART_RATE_VARIABILITY_ANNOTATION = FITBIT_HEART_RATE_VARIABILITY_ANNOTATION; exports.FITBIT_SIGNAL_TYPE_ANNOTATIONS = FITBIT_SIGNAL_TYPE_ANNOTATIONS; exports.FITBIT_SKIN_TEMPERATURE_ANNOTATION = FITBIT_SKIN_TEMPERATURE_ANNOTATION; exports.FITBIT_SLEEP_ANNOTATION = FITBIT_SLEEP_ANNOTATION; exports.FITBIT_SLEEP_LEVEL_MAP = FITBIT_SLEEP_LEVEL_MAP; exports.FITBIT_SPO2_ANNOTATION = FITBIT_SPO2_ANNOTATION; exports.FITBIT_STEPS_ANNOTATION = FITBIT_STEPS_ANNOTATION; exports.GARMIN_SIGNAL_TYPE_ANNOTATIONS = GARMIN_SIGNAL_TYPE_ANNOTATIONS; exports.GOOGLE_HEALTH_SIGNAL_TYPE_ANNOTATIONS = GOOGLE_HEALTH_SIGNAL_TYPE_ANNOTATIONS; exports.HEALTH_CONNECT_ANNOTATION_ITEM_SLEEP_DURATION = HEALTH_CONNECT_ANNOTATION_ITEM_SLEEP_DURATION; exports.HEALTH_CONNECT_ANNOTATION_ITEM_SLEEP_STAGE = HEALTH_CONNECT_ANNOTATION_ITEM_SLEEP_STAGE; exports.HEALTH_CONNECT_ANNOTATION_ITEM_STEPS = HEALTH_CONNECT_ANNOTATION_ITEM_STEPS; exports.HEALTH_CONNECT_DATA_SOURCES = HEALTH_CONNECT_DATA_SOURCES; exports.HEALTH_CONNECT_SIGNAL_TYPE_ANNOTATIONS = HEALTH_CONNECT_SIGNAL_TYPE_ANNOTATIONS; exports.HEALTH_CONNECT_SLEEP_ANNOTATION = HEALTH_CONNECT_SLEEP_ANNOTATION; exports.HEALTH_CONNECT_SLEEP_STAGE_MAP = HEALTH_CONNECT_SLEEP_STAGE_MAP; exports.HEALTH_CONNECT_STEPS_ANNOTATION = HEALTH_CONNECT_STEPS_ANNOTATION; exports.HYBRID_ENCRYPTION_VERSION_RECOVERY = HYBRID_ENCRYPTION_VERSION_RECOVERY; exports.HYBRID_ENCRYPTION_VERSION_V4 = HYBRID_ENCRYPTION_VERSION_V4; exports.HybridEncrypter = HybridEncrypter; exports.IMUAnnotation = IMUAnnotation; exports.ImageExtension = ImageExtension; exports.InternalSensorAnnotationTypes = InternalSensorAnnotationTypes; exports.Iso3166CodeSystem = Iso3166CodeSystem; exports.KEY_LENGTH = KEY_LENGTH; exports.KeyHandler = KeyHandler; exports.MaxValueExtension = MaxValueExtension; exports.MeasurementTypeSystem = MeasurementTypeSystem; exports.MinLengthExtension = MinLengthExtension; exports.MinValueExtension = MinValueExtension; exports.OTHER_ANSWER_CODE = OTHER_ANSWER_CODE; exports.OURA_ACTIVITY_ANNOTATION = OURA_ACTIVITY_ANNOTATION; exports.OURA_ANNOTATION_ITEM_ACTIVITY_LEVEL = OURA_ANNOTATION_ITEM_ACTIVITY_LEVEL; exports.OURA_ANNOTATION_ITEM_BATTERY_LEVEL = OURA_ANNOTATION_ITEM_BATTERY_LEVEL; exports.OURA_ANNOTATION_ITEM_CARDIOVASCULAR_AGE = OURA_ANNOTATION_ITEM_CARDIOVASCULAR_AGE; exports.OURA_ANNOTATION_ITEM_STRESS = OURA_ANNOTATION_ITEM_STRESS; exports.OURA_ANNOTATION_ITEM_TAG = OURA_ANNOTATION_ITEM_TAG; exports.OURA_ANNOTATION_ITEM_WORKOUT = OURA_ANNOTATION_ITEM_WORKOUT; exports.OURA_BATTERY_LEVEL_ANNOTATION = OURA_BATTERY_LEVEL_ANNOTATION; exports.OURA_CARDIOVASCULAR_AGE_ANNOTATION = OURA_CARDIOVASCULAR_AGE_ANNOTATION; exports.OURA_SIGNAL_TYPE_ANNOTATIONS = OURA_SIGNAL_TYPE_ANNOTATIONS; exports.OURA_STRESS_ANNOTATION = OURA_STRESS_ANNOTATION; exports.OURA_TAG_ANNOTATION = OURA_TAG_ANNOTATION; exports.OURA_WORKOUT_ANNOTATION = OURA_WORKOUT_ANNOTATION; exports.ObservationTypeSystem = ObservationTypeSystem; exports.Offset = Offset; exports.PAMSCardioVascularActivityAnnotation = PAMSCardioVascularActivityAnnotation; exports.PAMSGeneralActivityInstantaneousAnnotation = PAMSGeneralActivityInstantaneousAnnotation; exports.PAMSGeneralActivitySummaryAnnotation = PAMSGeneralActivitySummaryAnnotation; exports.PAMSStepCounterActivitySummaryAnnotation = PAMSStepCounterActivitySummaryAnnotation; exports.PSMSAccelerationAnnotation = PSMSAccelerationAnnotation; exports.PSMSHeartRateAnnotation = PSMSHeartRateAnnotation; exports.PSMSPPGGreenAnnotation = PSMSPPGGreenAnnotation; exports.PSMSPPGIRAnnotation = PSMSPPGIRAnnotation; exports.PSMSPPGRedAnnotation = PSMSPPGRedAnnotation; exports.PSMSSkinTemperatureAnnotation = PSMSSkinTemperatureAnnotation; exports.PostalCodeCountrySourceExtension = PostalCodeCountrySourceExtension; exports.PostalCodeFixedCountryUrl = PostalCodeFixedCountryUrl; exports.PostalCodeFromItemUrl = PostalCodeFromItemUrl; exports.PrepopulateExtension = PrepopulateExtension; exports.QItemControlDefinition = QItemControlDefinition; exports.RECORDING_MODEL_CURRENT_VERSION = RECORDING_MODEL_CURRENT_VERSION; exports.RECORDING_SIGNAL_MODEL_CURRENT_VERSION = RECORDING_SIGNAL_MODEL_CURRENT_VERSION; exports.RelativeMaxValueExtension = RelativeMaxValueExtension; exports.RelativeMinValueExtension = RelativeMinValueExtension; exports.ResponseGuard = ResponseGuard; exports.RoutineGuard = RoutineGuard; exports.RoutineIsPassiveExtension = RoutineIsPassiveExtension; exports.SIGNAL_DURATION_CODING = SIGNAL_DURATION_CODING; exports.SensorIdentifierSystem = SensorIdentifierSystem; exports.SensorSettingsSystem = SensorSettingsSystem; exports.SensorTypeSystem = SensorTypeSystem; exports.SignalIDSystem = SignalIDSystem; exports.SliderInputLabel = SliderInputLabel; exports.SliderMaxLabelExtension = SliderMaxLabelExtension; exports.SliderMinLabelExtension = SliderMinLabelExtension; exports.SliderOrientationExtension = SliderOrientationExtension; exports.SliderStepSizeExtension = SliderStepSizeExtension; exports.StudyNameSystem = StudyNameSystem; exports.SurveyGuard = SurveyGuard; exports.TAG_LENGTH = TAG_LENGTH; exports.TimeFuncs = TimeFuncs; exports.TokenNamingSystem = TokenNamingSystem; exports.ULID_REGEX = ULID_REGEX; exports.ULIDtoUUID = ULIDtoUUID; exports.UUID_REGEX = UUID_REGEX; exports.UUIDtoULID = UUIDtoULID; exports.V4_DECRYPTER_DATA_RECEIVER = V4_DECRYPTER_DATA_RECEIVER; exports.V4_DECRYPTER_MOBILE_APP = V4_DECRYPTER_MOBILE_APP; exports.WORDLIST_LANGUAGES = WORDLIST_LANGUAGES; exports.WearOS3AnnotationMap = WearOS3AnnotationMap; exports.WebConverter = WebConverter; exports.YearGuard = YearGuard; exports.binaryStringToUint8Array = binaryStringToUint8Array; exports.buildSelfSignedAuthToken = buildSelfSignedAuthToken; exports.calculateQuestionnaireScoreRange = calculateQuestionnaireScoreRange; exports.calculateScoreRangeForItem = calculateScoreRangeForItem; exports.capitalizeFirstLetter = capitalizeFirstLetter; exports.dayFormat = dayFormat; exports.encodeDataSource = encodeDataSource; exports.extractWordsFromRecoveryPhrase = extractWordsFromRecoveryPhrase; exports.generateFHIRConsent = generateFHIRConsent; exports.generateFHIRQuestionnaireScore = generateFHIRQuestionnaireScore; exports.generateFHIRRecordingBundle = generateFHIRRecordingBundle; exports.generateFHIRResearchSubject = generateFHIRResearchSubject; exports.generateFHIRResponse = generateFHIRResponse; exports.generateFHIRSeenDisplay = generateFHIRSeenDisplay; exports.generateFHIRSeenMessage = generateFHIRSeenMessage; exports.generateFHIRTag = generateFHIRTag; exports.generateQuestionGuard = generateQuestionGuard; exports.generateStepGuard = generateStepGuard; exports.generateUrn = generateUrn; exports.get = get; exports.getFollowUpQuestionLinkId = getFollowUpQuestionLinkId; exports.getLanguageOfPassPhrase = getLanguageOfPassPhrase; exports.getMovellaAnnotation = getMovellaAnnotation; exports.getText = getText; exports.getTimeFuncs = getTimeFuncs; exports.indexArrayBy = indexArrayBy; exports.isArrayAnswer = isArrayAnswer; exports.isBeforeStartDate = isBeforeStartDate; exports.isFlatAnswer = isFlatAnswer; exports.isGeoLocationAnswer = isGeoLocationAnswer; exports.isMatrixAnswer = isMatrixAnswer; exports.isNotAfterEndDate = isNotAfterEndDate; exports.isNotBeforeStartDate = isNotBeforeStartDate; exports.isScalarAnswer = isScalarAnswer; exports.isScoreEligible = isScoreEligible; exports.isYearString = isYearString; exports.newStepDateGuard = newStepDateGuard; exports.overwriteTime = overwriteTime; exports.stringToDate = stringToDate; exports.stringToYear = stringToYear; exports.timezonelessDate = timezonelessDate; exports.toDeviceConfig = toDeviceConfig; exports.toQuestionnaireResponseItem = toQuestionnaireResponseItem; exports.uint8ArrayToBinaryString = uint8ArrayToBinaryString; exports.utf8ToUint8Array = utf8ToUint8Array; exports.v4AesKey = v4AesKey; exports.v4AesSlot = v4AesSlot; exports.v4EcKey = v4EcKey; exports.v4EcSlot = v4EcSlot; exports.v4RsaKey = v4RsaKey; exports.v4RsaSlot = v4RsaSlot; exports.wordlists = wordlists;
7200
+ /*! Bundled license information:
7201
+
7202
+ @noble/hashes/esm/utils.js:
7203
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
7204
+ */
6182
7205
  //# sourceMappingURL=index.js.map