@learncard/helpers 1.2.8 → 1.2.10

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.
@@ -63,6 +63,7 @@ var require_types_cjs_development = __commonJS({
63
63
  AchievementValidator: /* @__PURE__ */ __name(() => AchievementValidator, "AchievementValidator"),
64
64
  AddTagInputValidator: /* @__PURE__ */ __name(() => AddTagInputValidator, "AddTagInputValidator"),
65
65
  AddressValidator: /* @__PURE__ */ __name(() => AddressValidator, "AddressValidator"),
66
+ AgeRatingValidator: /* @__PURE__ */ __name(() => AgeRatingValidator, "AgeRatingValidator"),
66
67
  AlignmentTargetTypeValidator: /* @__PURE__ */ __name(() => AlignmentTargetTypeValidator, "AlignmentTargetTypeValidator"),
67
68
  AlignmentValidator: /* @__PURE__ */ __name(() => AlignmentValidator, "AlignmentValidator"),
68
69
  AppBoostValidator: /* @__PURE__ */ __name(() => AppBoostValidator, "AppBoostValidator"),
@@ -76,6 +77,7 @@ var require_types_cjs_development = __commonJS({
76
77
  AuthGrantQueryValidator: /* @__PURE__ */ __name(() => AuthGrantQueryValidator, "AuthGrantQueryValidator"),
77
78
  AuthGrantStatusValidator: /* @__PURE__ */ __name(() => AuthGrantStatusValidator, "AuthGrantStatusValidator"),
78
79
  AuthGrantValidator: /* @__PURE__ */ __name(() => AuthGrantValidator, "AuthGrantValidator"),
80
+ AuthSessionError: /* @__PURE__ */ __name(() => AuthSessionError, "AuthSessionError"),
79
81
  AutoBoostConfigValidator: /* @__PURE__ */ __name(() => AutoBoostConfigValidator, "AutoBoostConfigValidator"),
80
82
  BoostPermissionsQueryValidator: /* @__PURE__ */ __name(() => BoostPermissionsQueryValidator, "BoostPermissionsQueryValidator"),
81
83
  BoostPermissionsValidator: /* @__PURE__ */ __name(() => BoostPermissionsValidator, "BoostPermissionsValidator"),
@@ -83,6 +85,8 @@ var require_types_cjs_development = __commonJS({
83
85
  BoostRecipientValidator: /* @__PURE__ */ __name(() => BoostRecipientValidator, "BoostRecipientValidator"),
84
86
  BoostRecipientWithChildrenValidator: /* @__PURE__ */ __name(() => BoostRecipientWithChildrenValidator, "BoostRecipientWithChildrenValidator"),
85
87
  BoostValidator: /* @__PURE__ */ __name(() => BoostValidator, "BoostValidator"),
88
+ CheckCredentialEventValidator: /* @__PURE__ */ __name(() => CheckCredentialEventValidator, "CheckCredentialEventValidator"),
89
+ CheckIssuanceStatusEventValidator: /* @__PURE__ */ __name(() => CheckIssuanceStatusEventValidator, "CheckIssuanceStatusEventValidator"),
86
90
  ClaimHookQueryValidator: /* @__PURE__ */ __name(() => ClaimHookQueryValidator, "ClaimHookQueryValidator"),
87
91
  ClaimHookTypeValidator: /* @__PURE__ */ __name(() => ClaimHookTypeValidator, "ClaimHookTypeValidator"),
88
92
  ClaimHookValidator: /* @__PURE__ */ __name(() => ClaimHookValidator, "ClaimHookValidator"),
@@ -124,6 +128,7 @@ var require_types_cjs_development = __commonJS({
124
128
  CredentialActivityValidator: /* @__PURE__ */ __name(() => CredentialActivityValidator, "CredentialActivityValidator"),
125
129
  CredentialActivityWithDetailsValidator: /* @__PURE__ */ __name(() => CredentialActivityWithDetailsValidator, "CredentialActivityWithDetailsValidator"),
126
130
  CredentialInfoValidator: /* @__PURE__ */ __name(() => CredentialInfoValidator, "CredentialInfoValidator"),
131
+ CredentialNameRefValidator: /* @__PURE__ */ __name(() => CredentialNameRefValidator, "CredentialNameRefValidator"),
127
132
  CredentialRecordValidator: /* @__PURE__ */ __name(() => CredentialRecordValidator, "CredentialRecordValidator"),
128
133
  CredentialSchemaValidator: /* @__PURE__ */ __name(() => CredentialSchemaValidator, "CredentialSchemaValidator"),
129
134
  CredentialStatusValidator: /* @__PURE__ */ __name(() => CredentialStatusValidator, "CredentialStatusValidator"),
@@ -145,6 +150,7 @@ var require_types_cjs_development = __commonJS({
145
150
  GetFullSkillTreeResultValidator: /* @__PURE__ */ __name(() => GetFullSkillTreeResultValidator, "GetFullSkillTreeResultValidator"),
146
151
  GetSkillPathInputValidator: /* @__PURE__ */ __name(() => GetSkillPathInputValidator, "GetSkillPathInputValidator"),
147
152
  GetSkillPathResultValidator: /* @__PURE__ */ __name(() => GetSkillPathResultValidator, "GetSkillPathResultValidator"),
153
+ GetTemplateRecipientsEventValidator: /* @__PURE__ */ __name(() => GetTemplateRecipientsEventValidator, "GetTemplateRecipientsEventValidator"),
148
154
  IdentifierEntryValidator: /* @__PURE__ */ __name(() => IdentifierEntryValidator, "IdentifierEntryValidator"),
149
155
  IdentifierTypeValidator: /* @__PURE__ */ __name(() => IdentifierTypeValidator, "IdentifierTypeValidator"),
150
156
  IdentityObjectValidator: /* @__PURE__ */ __name(() => IdentityObjectValidator, "IdentityObjectValidator"),
@@ -14592,7 +14598,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14592
14598
  "PROFILE_PARENT_APPROVED",
14593
14599
  "APP_LISTING_SUBMITTED",
14594
14600
  "APP_LISTING_APPROVED",
14595
- "APP_LISTING_REJECTED"
14601
+ "APP_LISTING_REJECTED",
14602
+ "DEVICE_LINK_REQUEST"
14596
14603
  ]);
14597
14604
  var LCNNotificationMessageValidator = external_exports.object({
14598
14605
  title: external_exports.string().optional(),
@@ -14731,6 +14738,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14731
14738
  webhookUrl: external_exports.string().optional(),
14732
14739
  boostUri: external_exports.string().optional(),
14733
14740
  activityId: external_exports.string().optional(),
14741
+ integrationId: external_exports.string().optional(),
14734
14742
  signingAuthority: external_exports.object({
14735
14743
  endpoint: external_exports.string().optional(),
14736
14744
  name: external_exports.string().optional()
@@ -14832,8 +14840,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14832
14840
  claimUrl: external_exports.string().url().optional(),
14833
14841
  recipientDid: external_exports.string().optional()
14834
14842
  });
14843
+ var CredentialNameRefValidator = external_exports.object({ name: external_exports.string() }).passthrough();
14835
14844
  var ClaimInboxCredentialValidator = external_exports.object({
14836
- credential: VCValidator.or(VPValidator).or(UnsignedVCValidator).describe("The credential to issue."),
14845
+ credential: VCValidator.or(VPValidator).or(UnsignedVCValidator).or(CredentialNameRefValidator).describe("The credential to issue, or a { name } reference to resolve a boost template."),
14837
14846
  configuration: external_exports.object({
14838
14847
  publishableKey: external_exports.string(),
14839
14848
  signingAuthorityName: external_exports.string().optional(),
@@ -15116,6 +15125,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15116
15125
  "STANDARD",
15117
15126
  "DEMOTED"
15118
15127
  ]);
15128
+ var AgeRatingValidator = external_exports.enum(["4+", "9+", "12+", "17+"]);
15119
15129
  var AppStoreListingValidator = external_exports.object({
15120
15130
  listing_id: external_exports.string(),
15121
15131
  slug: external_exports.string().optional(),
@@ -15135,7 +15145,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15135
15145
  terms_url: external_exports.string().optional(),
15136
15146
  highlights: external_exports.array(external_exports.string()).optional(),
15137
15147
  screenshots: external_exports.array(external_exports.string()).optional(),
15138
- hero_background_color: external_exports.string().optional()
15148
+ hero_background_color: external_exports.string().optional(),
15149
+ min_age: external_exports.number().int().min(0).max(18).optional(),
15150
+ age_rating: AgeRatingValidator.optional()
15139
15151
  });
15140
15152
  var AppStoreListingCreateValidator = AppStoreListingValidator.omit({
15141
15153
  listing_id: true,
@@ -15163,9 +15175,39 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15163
15175
  var SendCredentialEventValidator = external_exports.object({
15164
15176
  type: external_exports.literal("send-credential"),
15165
15177
  templateAlias: external_exports.string(),
15166
- templateData: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
15178
+ templateData: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
15179
+ preventDuplicateClaim: external_exports.boolean().optional()
15180
+ });
15181
+ var CheckCredentialEventValidator = external_exports.object({
15182
+ type: external_exports.literal("check-credential"),
15183
+ templateAlias: external_exports.string().optional(),
15184
+ boostUri: external_exports.string().optional()
15185
+ }).refine((input) => Boolean(input.templateAlias) !== Boolean(input.boostUri), {
15186
+ message: "Exactly one of templateAlias or boostUri is required"
15187
+ });
15188
+ var CheckIssuanceStatusEventValidator = external_exports.object({
15189
+ type: external_exports.literal("check-issuance-status"),
15190
+ templateAlias: external_exports.string().optional(),
15191
+ boostUri: external_exports.string().optional(),
15192
+ recipient: external_exports.string()
15193
+ }).refine((input) => Boolean(input.templateAlias) !== Boolean(input.boostUri), {
15194
+ message: "Exactly one of templateAlias or boostUri is required"
15167
15195
  });
15168
- var AppEventValidator = external_exports.discriminatedUnion("type", [SendCredentialEventValidator]);
15196
+ var GetTemplateRecipientsEventValidator = external_exports.object({
15197
+ type: external_exports.literal("get-template-recipients"),
15198
+ templateAlias: external_exports.string().optional(),
15199
+ boostUri: external_exports.string().optional(),
15200
+ limit: external_exports.number().optional(),
15201
+ cursor: external_exports.string().optional()
15202
+ }).refine((input) => Boolean(input.templateAlias) !== Boolean(input.boostUri), {
15203
+ message: "Exactly one of templateAlias or boostUri is required"
15204
+ });
15205
+ var AppEventValidator = external_exports.discriminatedUnion("type", [
15206
+ SendCredentialEventValidator,
15207
+ CheckCredentialEventValidator,
15208
+ CheckIssuanceStatusEventValidator,
15209
+ GetTemplateRecipientsEventValidator
15210
+ ]);
15169
15211
  var AppEventInputValidator = external_exports.object({
15170
15212
  listingId: external_exports.string(),
15171
15213
  event: AppEventValidator
@@ -15228,6 +15270,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15228
15270
  failed: external_exports.number(),
15229
15271
  claimRate: external_exports.number()
15230
15272
  });
15273
+ var AuthSessionError = class extends Error {
15274
+ static {
15275
+ __name(this, "AuthSessionError");
15276
+ }
15277
+ constructor(message, reason) {
15278
+ super(message);
15279
+ this.reason = reason;
15280
+ this.name = "AuthSessionError";
15281
+ }
15282
+ static {
15283
+ __name2(this, "AuthSessionError");
15284
+ }
15285
+ };
15231
15286
  }
15232
15287
  });
15233
15288
 
@@ -15246,13 +15301,16 @@ var require_dist = __commonJS({
15246
15301
  // src/index.ts
15247
15302
  var index_exports = {};
15248
15303
  __export(index_exports, {
15304
+ AGE_RATING_TO_MIN_AGE: () => AGE_RATING_TO_MIN_AGE,
15249
15305
  DEFAULT_RESOLUTIONS: () => DEFAULT_RESOLUTIONS,
15250
15306
  ImageResizingValidator: () => ImageResizingValidator,
15251
15307
  ImageUploadingValidator: () => ImageUploadingValidator,
15252
15308
  ImageWithLoadingStateValdator: () => ImageWithLoadingStateValdator,
15253
15309
  RegExpTransformer: () => RegExpTransformer,
15310
+ calculateAgeFromDob: () => calculateAgeFromDob,
15254
15311
  capitalizeFirstLetter: () => capitalizeFirstLetter,
15255
15312
  changeQuality: () => changeQuality4,
15313
+ checkAppInstallEligibility: () => checkAppInstallEligibility,
15256
15314
  curriedArraySlice: () => curriedArraySlice,
15257
15315
  curriedInnerImmerOuterImmer: () => curriedInnerImmerOuterImmer,
15258
15316
  curriedInnerImmerOuterReact: () => curriedInnerImmerOuterReact,
@@ -16096,6 +16154,90 @@ var ImageWithLoadingStateValdator = import_zod.z.object({
16096
16154
  var isNotUndefined = /* @__PURE__ */ __name((value) => Boolean(value), "isNotUndefined");
16097
16155
  var filterUndefined = /* @__PURE__ */ __name((arr) => arr.filter(isNotUndefined), "filterUndefined");
16098
16156
 
16157
+ // src/app-install/index.ts
16158
+ var checkAppInstallEligibility = /* @__PURE__ */ __name((input) => {
16159
+ const {
16160
+ isChildProfile,
16161
+ userAge,
16162
+ minAge,
16163
+ ageRating,
16164
+ hasContract,
16165
+ hasGuardianApproval = false
16166
+ } = input;
16167
+ const ageRatingMinAge = getAgeRatingMinAge(ageRating);
16168
+ const isHardBlocked = userAge !== null && minAge !== void 0 && minAge > 0 && userAge < minAge;
16169
+ if (isHardBlocked) {
16170
+ return {
16171
+ action: "hard_blocked",
16172
+ reason: `User does not meet the minimum age requirement of ${minAge}`
16173
+ };
16174
+ }
16175
+ if (isChildProfile) {
16176
+ const noAgeRating = ageRatingMinAge === 0;
16177
+ const childAgeUnknown = userAge === null;
16178
+ const childTooYoung = userAge !== null && userAge < ageRatingMinAge;
16179
+ if (childAgeUnknown) {
16180
+ if (hasGuardianApproval) {
16181
+ return { action: "proceed" };
16182
+ }
16183
+ return {
16184
+ action: "require_dob",
16185
+ reason: "Child profile age is unknown and must be verified by guardian"
16186
+ };
16187
+ }
16188
+ if (noAgeRating) {
16189
+ if (hasGuardianApproval) {
16190
+ return { action: "proceed" };
16191
+ }
16192
+ return {
16193
+ action: "require_guardian_approval",
16194
+ reason: "App has no age rating; guardian approval required for child profiles"
16195
+ };
16196
+ }
16197
+ if (childTooYoung) {
16198
+ if (hasGuardianApproval) {
16199
+ return { action: "proceed" };
16200
+ }
16201
+ return {
16202
+ action: "require_guardian_approval",
16203
+ reason: `Child is under the age rating of ${ageRatingMinAge}+; guardian approval required`
16204
+ };
16205
+ }
16206
+ if (hasContract) {
16207
+ if (hasGuardianApproval) {
16208
+ return { action: "proceed" };
16209
+ }
16210
+ return {
16211
+ action: "require_guardian_approval",
16212
+ reason: "App requires consent to a contract; guardian approval required for child profiles"
16213
+ };
16214
+ }
16215
+ }
16216
+ return { action: "proceed" };
16217
+ }, "checkAppInstallEligibility");
16218
+ var AGE_RATING_TO_MIN_AGE = {
16219
+ "4+": 4,
16220
+ "9+": 9,
16221
+ "12+": 12,
16222
+ "17+": 17
16223
+ };
16224
+ var getAgeRatingMinAge = /* @__PURE__ */ __name((ageRating) => {
16225
+ if (!ageRating) return 0;
16226
+ return AGE_RATING_TO_MIN_AGE[ageRating] ?? 0;
16227
+ }, "getAgeRatingMinAge");
16228
+ var calculateAgeFromDob = /* @__PURE__ */ __name((dob) => {
16229
+ if (!dob) return null;
16230
+ const birthDate = new Date(dob);
16231
+ if (isNaN(birthDate.getTime())) return null;
16232
+ const today = /* @__PURE__ */ new Date();
16233
+ let age = today.getFullYear() - birthDate.getFullYear();
16234
+ const monthDiff = today.getMonth() - birthDate.getMonth();
16235
+ if (monthDiff < 0 || monthDiff === 0 && today.getDate() < birthDate.getDate()) {
16236
+ age--;
16237
+ }
16238
+ return age;
16239
+ }, "calculateAgeFromDob");
16240
+
16099
16241
  // src/index.ts
16100
16242
  var isHex = /* @__PURE__ */ __name((str) => /^[0-9a-f]+$/i.test(str), "isHex");
16101
16243
  var isEncrypted = /* @__PURE__ */ __name((item) => {