@learncard/network-brain-client 2.5.20 → 2.5.24

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/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # @learncard/network-brain-client
2
2
 
3
+ ## 2.5.24
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`359a64bc190505255cf49b9317a7853b8fc71226`](https://github.com/learningeconomy/LearnCard/commit/359a64bc190505255cf49b9317a7853b8fc71226), [`00976e097128d18c25c8016a75be9580cd3a7050`](https://github.com/learningeconomy/LearnCard/commit/00976e097128d18c25c8016a75be9580cd3a7050), [`bba1f735e107d9cc86880e9f869413bc7072bff8`](https://github.com/learningeconomy/LearnCard/commit/bba1f735e107d9cc86880e9f869413bc7072bff8), [`fce9d2fd32898cfc64c59b88ca644dea3b53d1a5`](https://github.com/learningeconomy/LearnCard/commit/fce9d2fd32898cfc64c59b88ca644dea3b53d1a5), [`a702862957303a3e25c21bdc7f0998b3ee3e64a3`](https://github.com/learningeconomy/LearnCard/commit/a702862957303a3e25c21bdc7f0998b3ee3e64a3)]:
8
+ - @learncard/network-brain-service@3.13.2
9
+
10
+ ## 2.5.23
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [[`e8c886eac8907e127805e760c9622118c80c7bf5`](https://github.com/learningeconomy/LearnCard/commit/e8c886eac8907e127805e760c9622118c80c7bf5), [`c83e3de987c11a6d95deec31c1fdb2401a990db2`](https://github.com/learningeconomy/LearnCard/commit/c83e3de987c11a6d95deec31c1fdb2401a990db2), [`fe4a1a265132271860460b8121e28ec0eacf4cb0`](https://github.com/learningeconomy/LearnCard/commit/fe4a1a265132271860460b8121e28ec0eacf4cb0), [`6a1e0096ab35d0c98a51c6e06aea347f2a3e89c2`](https://github.com/learningeconomy/LearnCard/commit/6a1e0096ab35d0c98a51c6e06aea347f2a3e89c2)]:
15
+ - @learncard/network-brain-service@3.13.1
16
+
17
+ ## 2.5.22
18
+
19
+ ### Patch Changes
20
+
21
+ - [#1075](https://github.com/learningeconomy/LearnCard/pull/1075) [`50fa611b714ae47fa3d6d56e7751ba59b5b71322`](https://github.com/learningeconomy/LearnCard/commit/50fa611b714ae47fa3d6d56e7751ba59b5b71322) Thanks [@smurflo2](https://github.com/smurflo2)! - Add guardianGatedRoute so backend has access to isChildProfile and hasGuardianApproval
22
+
23
+ - Updated dependencies [[`3935a7c28ded7270133496f30562bad54a14f200`](https://github.com/learningeconomy/LearnCard/commit/3935a7c28ded7270133496f30562bad54a14f200), [`01a12c4353c28196a6e49ea6996656717faa246a`](https://github.com/learningeconomy/LearnCard/commit/01a12c4353c28196a6e49ea6996656717faa246a), [`50fa611b714ae47fa3d6d56e7751ba59b5b71322`](https://github.com/learningeconomy/LearnCard/commit/50fa611b714ae47fa3d6d56e7751ba59b5b71322), [`b8f9581422406f78d3738c4c3a6d9f335725b745`](https://github.com/learningeconomy/LearnCard/commit/b8f9581422406f78d3738c4c3a6d9f335725b745), [`34ced8d1c933ca7015dd1d3bd37b6b2ff847de3c`](https://github.com/learningeconomy/LearnCard/commit/34ced8d1c933ca7015dd1d3bd37b6b2ff847de3c)]:
24
+ - @learncard/network-brain-service@3.13.0
25
+
26
+ ## 2.5.21
27
+
28
+ ### Patch Changes
29
+
30
+ - Updated dependencies [[`5cc18a955913e1384d2107e9ba08cd876f2419c0`](https://github.com/learningeconomy/LearnCard/commit/5cc18a955913e1384d2107e9ba08cd876f2419c0), [`0fd14a6d66f05dc10ba2443ab99b1ca3dd7a6fa0`](https://github.com/learningeconomy/LearnCard/commit/0fd14a6d66f05dc10ba2443ab99b1ca3dd7a6fa0)]:
31
+ - @learncard/network-brain-service@3.12.5
32
+
3
33
  ## 2.5.20
4
34
 
5
35
  ### Patch Changes
@@ -106,11 +106,13 @@ var require_helpers_cjs_development = __commonJS({
106
106
  AppEventValidator: /* @__PURE__ */ __name2(() => AppEventValidator, "AppEventValidator"),
107
107
  AppListingStatusValidator: /* @__PURE__ */ __name2(() => AppListingStatusValidator, "AppListingStatusValidator"),
108
108
  AppStoreListingCreateValidator: /* @__PURE__ */ __name2(() => AppStoreListingCreateValidator, "AppStoreListingCreateValidator"),
109
+ AppStoreListingSubmitterValidator: /* @__PURE__ */ __name2(() => AppStoreListingSubmitterValidator, "AppStoreListingSubmitterValidator"),
109
110
  AppStoreListingUpdateValidator: /* @__PURE__ */ __name2(() => AppStoreListingUpdateValidator, "AppStoreListingUpdateValidator"),
110
111
  AppStoreListingValidator: /* @__PURE__ */ __name2(() => AppStoreListingValidator, "AppStoreListingValidator"),
111
112
  AuthGrantQueryValidator: /* @__PURE__ */ __name2(() => AuthGrantQueryValidator, "AuthGrantQueryValidator"),
112
113
  AuthGrantStatusValidator: /* @__PURE__ */ __name2(() => AuthGrantStatusValidator, "AuthGrantStatusValidator"),
113
114
  AuthGrantValidator: /* @__PURE__ */ __name2(() => AuthGrantValidator, "AuthGrantValidator"),
115
+ AuthSessionError: /* @__PURE__ */ __name2(() => AuthSessionError, "AuthSessionError"),
114
116
  AutoBoostConfigValidator: /* @__PURE__ */ __name2(() => AutoBoostConfigValidator, "AutoBoostConfigValidator"),
115
117
  BoostPermissionsQueryValidator: /* @__PURE__ */ __name2(() => BoostPermissionsQueryValidator, "BoostPermissionsQueryValidator"),
116
118
  BoostPermissionsValidator: /* @__PURE__ */ __name2(() => BoostPermissionsValidator, "BoostPermissionsValidator"),
@@ -118,6 +120,8 @@ var require_helpers_cjs_development = __commonJS({
118
120
  BoostRecipientValidator: /* @__PURE__ */ __name2(() => BoostRecipientValidator, "BoostRecipientValidator"),
119
121
  BoostRecipientWithChildrenValidator: /* @__PURE__ */ __name2(() => BoostRecipientWithChildrenValidator, "BoostRecipientWithChildrenValidator"),
120
122
  BoostValidator: /* @__PURE__ */ __name2(() => BoostValidator, "BoostValidator"),
123
+ CheckCredentialEventValidator: /* @__PURE__ */ __name2(() => CheckCredentialEventValidator, "CheckCredentialEventValidator"),
124
+ CheckIssuanceStatusEventValidator: /* @__PURE__ */ __name2(() => CheckIssuanceStatusEventValidator, "CheckIssuanceStatusEventValidator"),
121
125
  ClaimHookQueryValidator: /* @__PURE__ */ __name2(() => ClaimHookQueryValidator, "ClaimHookQueryValidator"),
122
126
  ClaimHookTypeValidator: /* @__PURE__ */ __name2(() => ClaimHookTypeValidator, "ClaimHookTypeValidator"),
123
127
  ClaimHookValidator: /* @__PURE__ */ __name2(() => ClaimHookValidator, "ClaimHookValidator"),
@@ -127,6 +131,10 @@ var require_helpers_cjs_development = __commonJS({
127
131
  ConsentFlowContractDataValidator: /* @__PURE__ */ __name2(() => ConsentFlowContractDataValidator, "ConsentFlowContractDataValidator"),
128
132
  ConsentFlowContractDetailsValidator: /* @__PURE__ */ __name2(() => ConsentFlowContractDetailsValidator, "ConsentFlowContractDetailsValidator"),
129
133
  ConsentFlowContractQueryValidator: /* @__PURE__ */ __name2(() => ConsentFlowContractQueryValidator, "ConsentFlowContractQueryValidator"),
134
+ ConsentFlowContractRequestForProfileListValidator: /* @__PURE__ */ __name2(() => ConsentFlowContractRequestForProfileListValidator, "ConsentFlowContractRequestForProfileListValidator"),
135
+ ConsentFlowContractRequestForProfileValidator: /* @__PURE__ */ __name2(() => ConsentFlowContractRequestForProfileValidator, "ConsentFlowContractRequestForProfileValidator"),
136
+ ConsentFlowContractRequestReadStatusValidator: /* @__PURE__ */ __name2(() => ConsentFlowContractRequestReadStatusValidator, "ConsentFlowContractRequestReadStatusValidator"),
137
+ ConsentFlowContractRequestStatusValidator: /* @__PURE__ */ __name2(() => ConsentFlowContractRequestStatusValidator, "ConsentFlowContractRequestStatusValidator"),
130
138
  ConsentFlowContractValidator: /* @__PURE__ */ __name2(() => ConsentFlowContractValidator, "ConsentFlowContractValidator"),
131
139
  ConsentFlowDataForDidQueryValidator: /* @__PURE__ */ __name2(() => ConsentFlowDataForDidQueryValidator, "ConsentFlowDataForDidQueryValidator"),
132
140
  ConsentFlowDataQueryValidator: /* @__PURE__ */ __name2(() => ConsentFlowDataQueryValidator, "ConsentFlowDataQueryValidator"),
@@ -159,6 +167,7 @@ var require_helpers_cjs_development = __commonJS({
159
167
  CredentialActivityValidator: /* @__PURE__ */ __name2(() => CredentialActivityValidator, "CredentialActivityValidator"),
160
168
  CredentialActivityWithDetailsValidator: /* @__PURE__ */ __name2(() => CredentialActivityWithDetailsValidator, "CredentialActivityWithDetailsValidator"),
161
169
  CredentialInfoValidator: /* @__PURE__ */ __name2(() => CredentialInfoValidator, "CredentialInfoValidator"),
170
+ CredentialNameRefValidator: /* @__PURE__ */ __name2(() => CredentialNameRefValidator, "CredentialNameRefValidator"),
162
171
  CredentialRecordValidator: /* @__PURE__ */ __name2(() => CredentialRecordValidator, "CredentialRecordValidator"),
163
172
  CredentialSchemaValidator: /* @__PURE__ */ __name2(() => CredentialSchemaValidator, "CredentialSchemaValidator"),
164
173
  CredentialStatusValidator: /* @__PURE__ */ __name2(() => CredentialStatusValidator, "CredentialStatusValidator"),
@@ -180,6 +189,7 @@ var require_helpers_cjs_development = __commonJS({
180
189
  GetFullSkillTreeResultValidator: /* @__PURE__ */ __name2(() => GetFullSkillTreeResultValidator, "GetFullSkillTreeResultValidator"),
181
190
  GetSkillPathInputValidator: /* @__PURE__ */ __name2(() => GetSkillPathInputValidator, "GetSkillPathInputValidator"),
182
191
  GetSkillPathResultValidator: /* @__PURE__ */ __name2(() => GetSkillPathResultValidator, "GetSkillPathResultValidator"),
192
+ GetTemplateRecipientsEventValidator: /* @__PURE__ */ __name2(() => GetTemplateRecipientsEventValidator, "GetTemplateRecipientsEventValidator"),
183
193
  IdentifierEntryValidator: /* @__PURE__ */ __name2(() => IdentifierEntryValidator, "IdentifierEntryValidator"),
184
194
  IdentifierTypeValidator: /* @__PURE__ */ __name2(() => IdentifierTypeValidator, "IdentifierTypeValidator"),
185
195
  IdentityObjectValidator: /* @__PURE__ */ __name2(() => IdentityObjectValidator, "IdentityObjectValidator"),
@@ -14889,6 +14899,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14889
14899
  autoBoosts: external_exports.string().array().optional(),
14890
14900
  writers: external_exports.array(LCNProfileValidator).optional()
14891
14901
  });
14902
+ var ConsentFlowContractRequestStatusValidator = external_exports.enum(["pending", "accepted", "denied"]).nullable();
14903
+ var ConsentFlowContractRequestReadStatusValidator = external_exports.enum(["unseen", "seen"]).nullable();
14904
+ var ConsentFlowContractRequestForProfileValidator = external_exports.object({
14905
+ profile: LCNProfileValidator,
14906
+ status: ConsentFlowContractRequestStatusValidator,
14907
+ readStatus: ConsentFlowContractRequestReadStatusValidator.optional()
14908
+ });
14909
+ var ConsentFlowContractRequestForProfileListValidator = external_exports.array(
14910
+ ConsentFlowContractRequestForProfileValidator
14911
+ );
14892
14912
  var PaginatedConsentFlowContractsValidator = PaginationResponseValidator.extend({
14893
14913
  records: ConsentFlowContractDetailsValidator.omit({ owner: true }).array()
14894
14914
  });
@@ -15049,7 +15069,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15049
15069
  "PROFILE_PARENT_APPROVED",
15050
15070
  "APP_LISTING_SUBMITTED",
15051
15071
  "APP_LISTING_APPROVED",
15052
- "APP_LISTING_REJECTED"
15072
+ "APP_LISTING_REJECTED",
15073
+ "APP_LISTING_WITHDRAWN",
15074
+ "DEVICE_LINK_REQUEST"
15053
15075
  ]);
15054
15076
  var LCNNotificationMessageValidator = external_exports.object({
15055
15077
  title: external_exports.string().optional(),
@@ -15188,6 +15210,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15188
15210
  webhookUrl: external_exports.string().optional(),
15189
15211
  boostUri: external_exports.string().optional(),
15190
15212
  activityId: external_exports.string().optional(),
15213
+ integrationId: external_exports.string().optional(),
15191
15214
  signingAuthority: external_exports.object({
15192
15215
  endpoint: external_exports.string().optional(),
15193
15216
  name: external_exports.string().optional()
@@ -15289,8 +15312,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15289
15312
  claimUrl: external_exports.string().url().optional(),
15290
15313
  recipientDid: external_exports.string().optional()
15291
15314
  });
15315
+ var CredentialNameRefValidator = external_exports.object({ name: external_exports.string() }).passthrough();
15292
15316
  var ClaimInboxCredentialValidator = external_exports.object({
15293
- credential: VCValidator.or(VPValidator).or(UnsignedVCValidator).describe("The credential to issue."),
15317
+ credential: VCValidator.or(VPValidator).or(UnsignedVCValidator).or(CredentialNameRefValidator).describe("The credential to issue, or a { name } reference to resolve a boost template."),
15294
15318
  configuration: external_exports.object({
15295
15319
  publishableKey: external_exports.string(),
15296
15320
  signingAuthorityName: external_exports.string().optional(),
@@ -15574,6 +15598,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15574
15598
  "DEMOTED"
15575
15599
  ]);
15576
15600
  var AgeRatingValidator = external_exports.enum(["4+", "9+", "12+", "17+"]);
15601
+ var AppStoreListingSubmitterValidator = external_exports.object({
15602
+ profileId: external_exports.string(),
15603
+ displayName: external_exports.string(),
15604
+ email: external_exports.string().optional()
15605
+ });
15577
15606
  var AppStoreListingValidator = external_exports.object({
15578
15607
  listing_id: external_exports.string(),
15579
15608
  slug: external_exports.string().optional(),
@@ -15595,7 +15624,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15595
15624
  screenshots: external_exports.array(external_exports.string()).optional(),
15596
15625
  hero_background_color: external_exports.string().optional(),
15597
15626
  min_age: external_exports.number().int().min(0).max(18).optional(),
15598
- age_rating: AgeRatingValidator.optional()
15627
+ age_rating: AgeRatingValidator.optional(),
15628
+ submitted_at: external_exports.string().optional(),
15629
+ submitter: AppStoreListingSubmitterValidator.optional(),
15630
+ contact_email: external_exports.string().email().optional()
15599
15631
  });
15600
15632
  var AppStoreListingCreateValidator = AppStoreListingValidator.omit({
15601
15633
  listing_id: true,
@@ -15623,9 +15655,39 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15623
15655
  var SendCredentialEventValidator = external_exports.object({
15624
15656
  type: external_exports.literal("send-credential"),
15625
15657
  templateAlias: external_exports.string(),
15626
- templateData: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
15658
+ templateData: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
15659
+ preventDuplicateClaim: external_exports.boolean().optional()
15660
+ });
15661
+ var CheckCredentialEventValidator = external_exports.object({
15662
+ type: external_exports.literal("check-credential"),
15663
+ templateAlias: external_exports.string().optional(),
15664
+ boostUri: external_exports.string().optional()
15665
+ }).refine((input) => Boolean(input.templateAlias) !== Boolean(input.boostUri), {
15666
+ message: "Exactly one of templateAlias or boostUri is required"
15667
+ });
15668
+ var CheckIssuanceStatusEventValidator = external_exports.object({
15669
+ type: external_exports.literal("check-issuance-status"),
15670
+ templateAlias: external_exports.string().optional(),
15671
+ boostUri: external_exports.string().optional(),
15672
+ recipient: external_exports.string()
15673
+ }).refine((input) => Boolean(input.templateAlias) !== Boolean(input.boostUri), {
15674
+ message: "Exactly one of templateAlias or boostUri is required"
15627
15675
  });
15628
- var AppEventValidator = external_exports.discriminatedUnion("type", [SendCredentialEventValidator]);
15676
+ var GetTemplateRecipientsEventValidator = external_exports.object({
15677
+ type: external_exports.literal("get-template-recipients"),
15678
+ templateAlias: external_exports.string().optional(),
15679
+ boostUri: external_exports.string().optional(),
15680
+ limit: external_exports.number().optional(),
15681
+ cursor: external_exports.string().optional()
15682
+ }).refine((input) => Boolean(input.templateAlias) !== Boolean(input.boostUri), {
15683
+ message: "Exactly one of templateAlias or boostUri is required"
15684
+ });
15685
+ var AppEventValidator = external_exports.discriminatedUnion("type", [
15686
+ SendCredentialEventValidator,
15687
+ CheckCredentialEventValidator,
15688
+ CheckIssuanceStatusEventValidator,
15689
+ GetTemplateRecipientsEventValidator
15690
+ ]);
15629
15691
  var AppEventInputValidator = external_exports.object({
15630
15692
  listingId: external_exports.string(),
15631
15693
  event: AppEventValidator
@@ -15688,6 +15750,22 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15688
15750
  failed: external_exports.number(),
15689
15751
  claimRate: external_exports.number()
15690
15752
  });
15753
+ var AuthSessionError = class extends Error {
15754
+ static {
15755
+ __name(this, "AuthSessionError");
15756
+ }
15757
+ static {
15758
+ __name2(this, "AuthSessionError");
15759
+ }
15760
+ constructor(message, reason) {
15761
+ super(message);
15762
+ this.reason = reason;
15763
+ this.name = "AuthSessionError";
15764
+ }
15765
+ static {
15766
+ __name22(this, "AuthSessionError");
15767
+ }
15768
+ };
15691
15769
  }
15692
15770
  });
15693
15771
  var require_dist2 = __commonJS2({
@@ -15702,13 +15780,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15702
15780
  });
15703
15781
  var index_exports2 = {};
15704
15782
  __export2(index_exports2, {
15783
+ AGE_RATING_TO_MIN_AGE: /* @__PURE__ */ __name(() => AGE_RATING_TO_MIN_AGE, "AGE_RATING_TO_MIN_AGE"),
15705
15784
  DEFAULT_RESOLUTIONS: /* @__PURE__ */ __name(() => DEFAULT_RESOLUTIONS, "DEFAULT_RESOLUTIONS"),
15706
15785
  ImageResizingValidator: /* @__PURE__ */ __name(() => ImageResizingValidator, "ImageResizingValidator"),
15707
15786
  ImageUploadingValidator: /* @__PURE__ */ __name(() => ImageUploadingValidator, "ImageUploadingValidator"),
15708
15787
  ImageWithLoadingStateValdator: /* @__PURE__ */ __name(() => ImageWithLoadingStateValdator, "ImageWithLoadingStateValdator"),
15709
15788
  RegExpTransformer: /* @__PURE__ */ __name(() => RegExpTransformer2, "RegExpTransformer"),
15789
+ calculateAgeFromDob: /* @__PURE__ */ __name(() => calculateAgeFromDob, "calculateAgeFromDob"),
15710
15790
  capitalizeFirstLetter: /* @__PURE__ */ __name(() => capitalizeFirstLetter, "capitalizeFirstLetter"),
15711
15791
  changeQuality: /* @__PURE__ */ __name(() => changeQuality4, "changeQuality"),
15792
+ checkAppInstallEligibility: /* @__PURE__ */ __name(() => checkAppInstallEligibility, "checkAppInstallEligibility"),
15712
15793
  curriedArraySlice: /* @__PURE__ */ __name(() => curriedArraySlice, "curriedArraySlice"),
15713
15794
  curriedInnerImmerOuterImmer: /* @__PURE__ */ __name(() => curriedInnerImmerOuterImmer, "curriedInnerImmerOuterImmer"),
15714
15795
  curriedInnerImmerOuterReact: /* @__PURE__ */ __name(() => curriedInnerImmerOuterReact, "curriedInnerImmerOuterReact"),
@@ -16544,6 +16625,88 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16544
16625
  });
16545
16626
  var isNotUndefined = /* @__PURE__ */ __name2((value) => Boolean(value), "isNotUndefined");
16546
16627
  var filterUndefined = /* @__PURE__ */ __name2((arr) => arr.filter(isNotUndefined), "filterUndefined");
16628
+ var checkAppInstallEligibility = /* @__PURE__ */ __name2((input) => {
16629
+ const {
16630
+ isChildProfile,
16631
+ userAge,
16632
+ minAge,
16633
+ ageRating,
16634
+ hasContract,
16635
+ hasGuardianApproval = false
16636
+ } = input;
16637
+ const ageRatingMinAge = getAgeRatingMinAge(ageRating);
16638
+ const isHardBlocked = userAge !== null && minAge !== void 0 && minAge > 0 && userAge < minAge;
16639
+ if (isHardBlocked) {
16640
+ return {
16641
+ action: "hard_blocked",
16642
+ reason: `User does not meet the minimum age requirement of ${minAge}`
16643
+ };
16644
+ }
16645
+ if (isChildProfile) {
16646
+ const noAgeRating = ageRatingMinAge === 0;
16647
+ const childAgeUnknown = userAge === null;
16648
+ const childTooYoung = userAge !== null && userAge < ageRatingMinAge;
16649
+ if (childAgeUnknown) {
16650
+ if (hasGuardianApproval) {
16651
+ return { action: "proceed" };
16652
+ }
16653
+ return {
16654
+ action: "require_dob",
16655
+ reason: "Child profile age is unknown and must be verified by guardian"
16656
+ };
16657
+ }
16658
+ if (noAgeRating) {
16659
+ if (hasGuardianApproval) {
16660
+ return { action: "proceed" };
16661
+ }
16662
+ return {
16663
+ action: "require_guardian_approval",
16664
+ reason: "App has no age rating; guardian approval required for child profiles"
16665
+ };
16666
+ }
16667
+ if (childTooYoung) {
16668
+ if (hasGuardianApproval) {
16669
+ return { action: "proceed" };
16670
+ }
16671
+ return {
16672
+ action: "require_guardian_approval",
16673
+ reason: `Child is under the age rating of ${ageRatingMinAge}+; guardian approval required`
16674
+ };
16675
+ }
16676
+ if (hasContract) {
16677
+ if (hasGuardianApproval) {
16678
+ return { action: "proceed" };
16679
+ }
16680
+ return {
16681
+ action: "require_guardian_approval",
16682
+ reason: "App requires consent to a contract; guardian approval required for child profiles"
16683
+ };
16684
+ }
16685
+ }
16686
+ return { action: "proceed" };
16687
+ }, "checkAppInstallEligibility");
16688
+ var AGE_RATING_TO_MIN_AGE = {
16689
+ "4+": 4,
16690
+ "9+": 9,
16691
+ "12+": 12,
16692
+ "17+": 17
16693
+ };
16694
+ var getAgeRatingMinAge = /* @__PURE__ */ __name2((ageRating) => {
16695
+ if (!ageRating) return 0;
16696
+ return AGE_RATING_TO_MIN_AGE[ageRating] ?? 0;
16697
+ }, "getAgeRatingMinAge");
16698
+ var calculateAgeFromDob = /* @__PURE__ */ __name2((dob) => {
16699
+ if (!dob) return null;
16700
+ const birthDate = new Date(dob);
16701
+ if (isNaN(birthDate.getTime())) return null;
16702
+ const today = /* @__PURE__ */ new Date();
16703
+ let age = today.getFullYear() - birthDate.getFullYear();
16704
+ const monthDiff = today.getMonth() - birthDate.getMonth();
16705
+ if (monthDiff < 0 || monthDiff === 0 && today.getDate() < birthDate.getDate()) {
16706
+ age--;
16707
+ }
16708
+ return age;
16709
+ }, "calculateAgeFromDob");
16547
16710
  var isHex = /* @__PURE__ */ __name2((str) => /^[0-9a-f]+$/i.test(str), "isHex");
16548
16711
  var isEncrypted = /* @__PURE__ */ __name2((item) => {
16549
16712
  return import_types.JWEValidator.safeParse(item).success;
@@ -16654,7 +16817,7 @@ var callbackLink = /* @__PURE__ */ __name((callback) => {
16654
16817
  }, "callbackLink");
16655
16818
 
16656
16819
  // src/index.ts
16657
- var getClient = /* @__PURE__ */ __name(async (url, didAuthFunction) => {
16820
+ var getClient = /* @__PURE__ */ __name(async (url, didAuthFunction, guardianApprovalGetter) => {
16658
16821
  let challenges = [];
16659
16822
  const challengeRequester = (0, import_client.createTRPCClient)({
16660
16823
  links: [
@@ -16685,7 +16848,11 @@ var getClient = /* @__PURE__ */ __name(async (url, didAuthFunction) => {
16685
16848
  url,
16686
16849
  headers: /* @__PURE__ */ __name(async () => {
16687
16850
  if (challenges.length === 0) challenges.push(...await getChallenges());
16688
- return { Authorization: `Bearer ${await didAuthFunction(challenges.pop())}` };
16851
+ const guardianApproval = guardianApprovalGetter ? await guardianApprovalGetter() : void 0;
16852
+ return {
16853
+ Authorization: `Bearer ${await didAuthFunction(challenges.pop())}`,
16854
+ ...guardianApproval ? { "x-guardian-approval": guardianApproval } : {}
16855
+ };
16689
16856
  }, "headers"),
16690
16857
  transformer: {
16691
16858
  input: import_helpers.RegExpTransformer,
@@ -16696,14 +16863,20 @@ var getClient = /* @__PURE__ */ __name(async (url, didAuthFunction) => {
16696
16863
  });
16697
16864
  return trpc;
16698
16865
  }, "getClient");
16699
- var getApiTokenClient = /* @__PURE__ */ __name(async (url, apiToken) => {
16866
+ var getApiTokenClient = /* @__PURE__ */ __name(async (url, apiToken, guardianApprovalGetter) => {
16700
16867
  const trpc = (0, import_client.createTRPCClient)({
16701
16868
  links: [
16702
16869
  (0, import_client.httpBatchLink)({
16703
16870
  methodOverride: "POST",
16704
16871
  url,
16705
16872
  maxURLLength: 3072,
16706
- headers: { Authorization: `Bearer ${apiToken}` },
16873
+ headers: /* @__PURE__ */ __name(async () => {
16874
+ const guardianApproval = guardianApprovalGetter ? await guardianApprovalGetter() : void 0;
16875
+ return {
16876
+ Authorization: `Bearer ${apiToken}`,
16877
+ ...guardianApproval ? { "x-guardian-approval": guardianApproval } : {}
16878
+ };
16879
+ }, "headers"),
16707
16880
  transformer: {
16708
16881
  input: import_helpers.RegExpTransformer,
16709
16882
  output: { serialize: /* @__PURE__ */ __name((o) => o, "serialize"), deserialize: /* @__PURE__ */ __name((o) => o, "deserialize") }