@learncard/helpers 1.2.9 → 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.
@@ -77,6 +77,7 @@ var require_types_cjs_development = __commonJS({
77
77
  AuthGrantQueryValidator: /* @__PURE__ */ __name(() => AuthGrantQueryValidator, "AuthGrantQueryValidator"),
78
78
  AuthGrantStatusValidator: /* @__PURE__ */ __name(() => AuthGrantStatusValidator, "AuthGrantStatusValidator"),
79
79
  AuthGrantValidator: /* @__PURE__ */ __name(() => AuthGrantValidator, "AuthGrantValidator"),
80
+ AuthSessionError: /* @__PURE__ */ __name(() => AuthSessionError, "AuthSessionError"),
80
81
  AutoBoostConfigValidator: /* @__PURE__ */ __name(() => AutoBoostConfigValidator, "AutoBoostConfigValidator"),
81
82
  BoostPermissionsQueryValidator: /* @__PURE__ */ __name(() => BoostPermissionsQueryValidator, "BoostPermissionsQueryValidator"),
82
83
  BoostPermissionsValidator: /* @__PURE__ */ __name(() => BoostPermissionsValidator, "BoostPermissionsValidator"),
@@ -84,6 +85,8 @@ var require_types_cjs_development = __commonJS({
84
85
  BoostRecipientValidator: /* @__PURE__ */ __name(() => BoostRecipientValidator, "BoostRecipientValidator"),
85
86
  BoostRecipientWithChildrenValidator: /* @__PURE__ */ __name(() => BoostRecipientWithChildrenValidator, "BoostRecipientWithChildrenValidator"),
86
87
  BoostValidator: /* @__PURE__ */ __name(() => BoostValidator, "BoostValidator"),
88
+ CheckCredentialEventValidator: /* @__PURE__ */ __name(() => CheckCredentialEventValidator, "CheckCredentialEventValidator"),
89
+ CheckIssuanceStatusEventValidator: /* @__PURE__ */ __name(() => CheckIssuanceStatusEventValidator, "CheckIssuanceStatusEventValidator"),
87
90
  ClaimHookQueryValidator: /* @__PURE__ */ __name(() => ClaimHookQueryValidator, "ClaimHookQueryValidator"),
88
91
  ClaimHookTypeValidator: /* @__PURE__ */ __name(() => ClaimHookTypeValidator, "ClaimHookTypeValidator"),
89
92
  ClaimHookValidator: /* @__PURE__ */ __name(() => ClaimHookValidator, "ClaimHookValidator"),
@@ -125,6 +128,7 @@ var require_types_cjs_development = __commonJS({
125
128
  CredentialActivityValidator: /* @__PURE__ */ __name(() => CredentialActivityValidator, "CredentialActivityValidator"),
126
129
  CredentialActivityWithDetailsValidator: /* @__PURE__ */ __name(() => CredentialActivityWithDetailsValidator, "CredentialActivityWithDetailsValidator"),
127
130
  CredentialInfoValidator: /* @__PURE__ */ __name(() => CredentialInfoValidator, "CredentialInfoValidator"),
131
+ CredentialNameRefValidator: /* @__PURE__ */ __name(() => CredentialNameRefValidator, "CredentialNameRefValidator"),
128
132
  CredentialRecordValidator: /* @__PURE__ */ __name(() => CredentialRecordValidator, "CredentialRecordValidator"),
129
133
  CredentialSchemaValidator: /* @__PURE__ */ __name(() => CredentialSchemaValidator, "CredentialSchemaValidator"),
130
134
  CredentialStatusValidator: /* @__PURE__ */ __name(() => CredentialStatusValidator, "CredentialStatusValidator"),
@@ -146,6 +150,7 @@ var require_types_cjs_development = __commonJS({
146
150
  GetFullSkillTreeResultValidator: /* @__PURE__ */ __name(() => GetFullSkillTreeResultValidator, "GetFullSkillTreeResultValidator"),
147
151
  GetSkillPathInputValidator: /* @__PURE__ */ __name(() => GetSkillPathInputValidator, "GetSkillPathInputValidator"),
148
152
  GetSkillPathResultValidator: /* @__PURE__ */ __name(() => GetSkillPathResultValidator, "GetSkillPathResultValidator"),
153
+ GetTemplateRecipientsEventValidator: /* @__PURE__ */ __name(() => GetTemplateRecipientsEventValidator, "GetTemplateRecipientsEventValidator"),
149
154
  IdentifierEntryValidator: /* @__PURE__ */ __name(() => IdentifierEntryValidator, "IdentifierEntryValidator"),
150
155
  IdentifierTypeValidator: /* @__PURE__ */ __name(() => IdentifierTypeValidator, "IdentifierTypeValidator"),
151
156
  IdentityObjectValidator: /* @__PURE__ */ __name(() => IdentityObjectValidator, "IdentityObjectValidator"),
@@ -14593,7 +14598,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14593
14598
  "PROFILE_PARENT_APPROVED",
14594
14599
  "APP_LISTING_SUBMITTED",
14595
14600
  "APP_LISTING_APPROVED",
14596
- "APP_LISTING_REJECTED"
14601
+ "APP_LISTING_REJECTED",
14602
+ "DEVICE_LINK_REQUEST"
14597
14603
  ]);
14598
14604
  var LCNNotificationMessageValidator = external_exports.object({
14599
14605
  title: external_exports.string().optional(),
@@ -14732,6 +14738,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14732
14738
  webhookUrl: external_exports.string().optional(),
14733
14739
  boostUri: external_exports.string().optional(),
14734
14740
  activityId: external_exports.string().optional(),
14741
+ integrationId: external_exports.string().optional(),
14735
14742
  signingAuthority: external_exports.object({
14736
14743
  endpoint: external_exports.string().optional(),
14737
14744
  name: external_exports.string().optional()
@@ -14833,8 +14840,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
14833
14840
  claimUrl: external_exports.string().url().optional(),
14834
14841
  recipientDid: external_exports.string().optional()
14835
14842
  });
14843
+ var CredentialNameRefValidator = external_exports.object({ name: external_exports.string() }).passthrough();
14836
14844
  var ClaimInboxCredentialValidator = external_exports.object({
14837
- 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."),
14838
14846
  configuration: external_exports.object({
14839
14847
  publishableKey: external_exports.string(),
14840
14848
  signingAuthorityName: external_exports.string().optional(),
@@ -15167,9 +15175,39 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15167
15175
  var SendCredentialEventValidator = external_exports.object({
15168
15176
  type: external_exports.literal("send-credential"),
15169
15177
  templateAlias: external_exports.string(),
15170
- 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"
15171
15195
  });
15172
- 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
+ ]);
15173
15211
  var AppEventInputValidator = external_exports.object({
15174
15212
  listingId: external_exports.string(),
15175
15213
  event: AppEventValidator
@@ -15232,6 +15270,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15232
15270
  failed: external_exports.number(),
15233
15271
  claimRate: external_exports.number()
15234
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
+ };
15235
15286
  }
15236
15287
  });
15237
15288
 
@@ -15250,13 +15301,16 @@ var require_dist = __commonJS({
15250
15301
  // src/index.ts
15251
15302
  var index_exports = {};
15252
15303
  __export(index_exports, {
15304
+ AGE_RATING_TO_MIN_AGE: () => AGE_RATING_TO_MIN_AGE,
15253
15305
  DEFAULT_RESOLUTIONS: () => DEFAULT_RESOLUTIONS,
15254
15306
  ImageResizingValidator: () => ImageResizingValidator,
15255
15307
  ImageUploadingValidator: () => ImageUploadingValidator,
15256
15308
  ImageWithLoadingStateValdator: () => ImageWithLoadingStateValdator,
15257
15309
  RegExpTransformer: () => RegExpTransformer,
15310
+ calculateAgeFromDob: () => calculateAgeFromDob,
15258
15311
  capitalizeFirstLetter: () => capitalizeFirstLetter,
15259
15312
  changeQuality: () => changeQuality4,
15313
+ checkAppInstallEligibility: () => checkAppInstallEligibility,
15260
15314
  curriedArraySlice: () => curriedArraySlice,
15261
15315
  curriedInnerImmerOuterImmer: () => curriedInnerImmerOuterImmer,
15262
15316
  curriedInnerImmerOuterReact: () => curriedInnerImmerOuterReact,
@@ -16100,6 +16154,90 @@ var ImageWithLoadingStateValdator = import_zod.z.object({
16100
16154
  var isNotUndefined = /* @__PURE__ */ __name((value) => Boolean(value), "isNotUndefined");
16101
16155
  var filterUndefined = /* @__PURE__ */ __name((arr) => arr.filter(isNotUndefined), "filterUndefined");
16102
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
+
16103
16241
  // src/index.ts
16104
16242
  var isHex = /* @__PURE__ */ __name((str) => /^[0-9a-f]+$/i.test(str), "isHex");
16105
16243
  var isEncrypted = /* @__PURE__ */ __name((item) => {