@learncard/helpers 1.2.9 → 1.2.11
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/helpers.cjs.development.js +143 -4
- package/dist/helpers.cjs.development.js.map +3 -3
- package/dist/helpers.cjs.production.min.js +5 -5
- package/dist/helpers.cjs.production.min.js.map +4 -4
- package/dist/helpers.d.ts +61 -0
- package/dist/helpers.esm.js +143 -4
- package/dist/helpers.esm.js.map +3 -3
- package/package.json +2 -2
|
@@ -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,9 @@ 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
|
+
"APP_LISTING_WITHDRAWN",
|
|
14603
|
+
"DEVICE_LINK_REQUEST"
|
|
14597
14604
|
]);
|
|
14598
14605
|
var LCNNotificationMessageValidator = external_exports.object({
|
|
14599
14606
|
title: external_exports.string().optional(),
|
|
@@ -14732,6 +14739,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14732
14739
|
webhookUrl: external_exports.string().optional(),
|
|
14733
14740
|
boostUri: external_exports.string().optional(),
|
|
14734
14741
|
activityId: external_exports.string().optional(),
|
|
14742
|
+
integrationId: external_exports.string().optional(),
|
|
14735
14743
|
signingAuthority: external_exports.object({
|
|
14736
14744
|
endpoint: external_exports.string().optional(),
|
|
14737
14745
|
name: external_exports.string().optional()
|
|
@@ -14833,8 +14841,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
14833
14841
|
claimUrl: external_exports.string().url().optional(),
|
|
14834
14842
|
recipientDid: external_exports.string().optional()
|
|
14835
14843
|
});
|
|
14844
|
+
var CredentialNameRefValidator = external_exports.object({ name: external_exports.string() }).passthrough();
|
|
14836
14845
|
var ClaimInboxCredentialValidator = external_exports.object({
|
|
14837
|
-
credential: VCValidator.or(VPValidator).or(UnsignedVCValidator).describe("The credential to issue."),
|
|
14846
|
+
credential: VCValidator.or(VPValidator).or(UnsignedVCValidator).or(CredentialNameRefValidator).describe("The credential to issue, or a { name } reference to resolve a boost template."),
|
|
14838
14847
|
configuration: external_exports.object({
|
|
14839
14848
|
publishableKey: external_exports.string(),
|
|
14840
14849
|
signingAuthorityName: external_exports.string().optional(),
|
|
@@ -15167,9 +15176,39 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
15167
15176
|
var SendCredentialEventValidator = external_exports.object({
|
|
15168
15177
|
type: external_exports.literal("send-credential"),
|
|
15169
15178
|
templateAlias: external_exports.string(),
|
|
15170
|
-
templateData: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
15179
|
+
templateData: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
15180
|
+
preventDuplicateClaim: external_exports.boolean().optional()
|
|
15181
|
+
});
|
|
15182
|
+
var CheckCredentialEventValidator = external_exports.object({
|
|
15183
|
+
type: external_exports.literal("check-credential"),
|
|
15184
|
+
templateAlias: external_exports.string().optional(),
|
|
15185
|
+
boostUri: external_exports.string().optional()
|
|
15186
|
+
}).refine((input) => Boolean(input.templateAlias) !== Boolean(input.boostUri), {
|
|
15187
|
+
message: "Exactly one of templateAlias or boostUri is required"
|
|
15188
|
+
});
|
|
15189
|
+
var CheckIssuanceStatusEventValidator = external_exports.object({
|
|
15190
|
+
type: external_exports.literal("check-issuance-status"),
|
|
15191
|
+
templateAlias: external_exports.string().optional(),
|
|
15192
|
+
boostUri: external_exports.string().optional(),
|
|
15193
|
+
recipient: external_exports.string()
|
|
15194
|
+
}).refine((input) => Boolean(input.templateAlias) !== Boolean(input.boostUri), {
|
|
15195
|
+
message: "Exactly one of templateAlias or boostUri is required"
|
|
15171
15196
|
});
|
|
15172
|
-
var
|
|
15197
|
+
var GetTemplateRecipientsEventValidator = external_exports.object({
|
|
15198
|
+
type: external_exports.literal("get-template-recipients"),
|
|
15199
|
+
templateAlias: external_exports.string().optional(),
|
|
15200
|
+
boostUri: external_exports.string().optional(),
|
|
15201
|
+
limit: external_exports.number().optional(),
|
|
15202
|
+
cursor: external_exports.string().optional()
|
|
15203
|
+
}).refine((input) => Boolean(input.templateAlias) !== Boolean(input.boostUri), {
|
|
15204
|
+
message: "Exactly one of templateAlias or boostUri is required"
|
|
15205
|
+
});
|
|
15206
|
+
var AppEventValidator = external_exports.discriminatedUnion("type", [
|
|
15207
|
+
SendCredentialEventValidator,
|
|
15208
|
+
CheckCredentialEventValidator,
|
|
15209
|
+
CheckIssuanceStatusEventValidator,
|
|
15210
|
+
GetTemplateRecipientsEventValidator
|
|
15211
|
+
]);
|
|
15173
15212
|
var AppEventInputValidator = external_exports.object({
|
|
15174
15213
|
listingId: external_exports.string(),
|
|
15175
15214
|
event: AppEventValidator
|
|
@@ -15232,6 +15271,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
15232
15271
|
failed: external_exports.number(),
|
|
15233
15272
|
claimRate: external_exports.number()
|
|
15234
15273
|
});
|
|
15274
|
+
var AuthSessionError = class extends Error {
|
|
15275
|
+
static {
|
|
15276
|
+
__name(this, "AuthSessionError");
|
|
15277
|
+
}
|
|
15278
|
+
constructor(message, reason) {
|
|
15279
|
+
super(message);
|
|
15280
|
+
this.reason = reason;
|
|
15281
|
+
this.name = "AuthSessionError";
|
|
15282
|
+
}
|
|
15283
|
+
static {
|
|
15284
|
+
__name2(this, "AuthSessionError");
|
|
15285
|
+
}
|
|
15286
|
+
};
|
|
15235
15287
|
}
|
|
15236
15288
|
});
|
|
15237
15289
|
|
|
@@ -15250,13 +15302,16 @@ var require_dist = __commonJS({
|
|
|
15250
15302
|
// src/index.ts
|
|
15251
15303
|
var index_exports = {};
|
|
15252
15304
|
__export(index_exports, {
|
|
15305
|
+
AGE_RATING_TO_MIN_AGE: () => AGE_RATING_TO_MIN_AGE,
|
|
15253
15306
|
DEFAULT_RESOLUTIONS: () => DEFAULT_RESOLUTIONS,
|
|
15254
15307
|
ImageResizingValidator: () => ImageResizingValidator,
|
|
15255
15308
|
ImageUploadingValidator: () => ImageUploadingValidator,
|
|
15256
15309
|
ImageWithLoadingStateValdator: () => ImageWithLoadingStateValdator,
|
|
15257
15310
|
RegExpTransformer: () => RegExpTransformer,
|
|
15311
|
+
calculateAgeFromDob: () => calculateAgeFromDob,
|
|
15258
15312
|
capitalizeFirstLetter: () => capitalizeFirstLetter,
|
|
15259
15313
|
changeQuality: () => changeQuality4,
|
|
15314
|
+
checkAppInstallEligibility: () => checkAppInstallEligibility,
|
|
15260
15315
|
curriedArraySlice: () => curriedArraySlice,
|
|
15261
15316
|
curriedInnerImmerOuterImmer: () => curriedInnerImmerOuterImmer,
|
|
15262
15317
|
curriedInnerImmerOuterReact: () => curriedInnerImmerOuterReact,
|
|
@@ -16100,6 +16155,90 @@ var ImageWithLoadingStateValdator = import_zod.z.object({
|
|
|
16100
16155
|
var isNotUndefined = /* @__PURE__ */ __name((value) => Boolean(value), "isNotUndefined");
|
|
16101
16156
|
var filterUndefined = /* @__PURE__ */ __name((arr) => arr.filter(isNotUndefined), "filterUndefined");
|
|
16102
16157
|
|
|
16158
|
+
// src/app-install/index.ts
|
|
16159
|
+
var checkAppInstallEligibility = /* @__PURE__ */ __name((input) => {
|
|
16160
|
+
const {
|
|
16161
|
+
isChildProfile,
|
|
16162
|
+
userAge,
|
|
16163
|
+
minAge,
|
|
16164
|
+
ageRating,
|
|
16165
|
+
hasContract,
|
|
16166
|
+
hasGuardianApproval = false
|
|
16167
|
+
} = input;
|
|
16168
|
+
const ageRatingMinAge = getAgeRatingMinAge(ageRating);
|
|
16169
|
+
const isHardBlocked = userAge !== null && minAge !== void 0 && minAge > 0 && userAge < minAge;
|
|
16170
|
+
if (isHardBlocked) {
|
|
16171
|
+
return {
|
|
16172
|
+
action: "hard_blocked",
|
|
16173
|
+
reason: `User does not meet the minimum age requirement of ${minAge}`
|
|
16174
|
+
};
|
|
16175
|
+
}
|
|
16176
|
+
if (isChildProfile) {
|
|
16177
|
+
const noAgeRating = ageRatingMinAge === 0;
|
|
16178
|
+
const childAgeUnknown = userAge === null;
|
|
16179
|
+
const childTooYoung = userAge !== null && userAge < ageRatingMinAge;
|
|
16180
|
+
if (childAgeUnknown) {
|
|
16181
|
+
if (hasGuardianApproval) {
|
|
16182
|
+
return { action: "proceed" };
|
|
16183
|
+
}
|
|
16184
|
+
return {
|
|
16185
|
+
action: "require_dob",
|
|
16186
|
+
reason: "Child profile age is unknown and must be verified by guardian"
|
|
16187
|
+
};
|
|
16188
|
+
}
|
|
16189
|
+
if (noAgeRating) {
|
|
16190
|
+
if (hasGuardianApproval) {
|
|
16191
|
+
return { action: "proceed" };
|
|
16192
|
+
}
|
|
16193
|
+
return {
|
|
16194
|
+
action: "require_guardian_approval",
|
|
16195
|
+
reason: "App has no age rating; guardian approval required for child profiles"
|
|
16196
|
+
};
|
|
16197
|
+
}
|
|
16198
|
+
if (childTooYoung) {
|
|
16199
|
+
if (hasGuardianApproval) {
|
|
16200
|
+
return { action: "proceed" };
|
|
16201
|
+
}
|
|
16202
|
+
return {
|
|
16203
|
+
action: "require_guardian_approval",
|
|
16204
|
+
reason: `Child is under the age rating of ${ageRatingMinAge}+; guardian approval required`
|
|
16205
|
+
};
|
|
16206
|
+
}
|
|
16207
|
+
if (hasContract) {
|
|
16208
|
+
if (hasGuardianApproval) {
|
|
16209
|
+
return { action: "proceed" };
|
|
16210
|
+
}
|
|
16211
|
+
return {
|
|
16212
|
+
action: "require_guardian_approval",
|
|
16213
|
+
reason: "App requires consent to a contract; guardian approval required for child profiles"
|
|
16214
|
+
};
|
|
16215
|
+
}
|
|
16216
|
+
}
|
|
16217
|
+
return { action: "proceed" };
|
|
16218
|
+
}, "checkAppInstallEligibility");
|
|
16219
|
+
var AGE_RATING_TO_MIN_AGE = {
|
|
16220
|
+
"4+": 4,
|
|
16221
|
+
"9+": 9,
|
|
16222
|
+
"12+": 12,
|
|
16223
|
+
"17+": 17
|
|
16224
|
+
};
|
|
16225
|
+
var getAgeRatingMinAge = /* @__PURE__ */ __name((ageRating) => {
|
|
16226
|
+
if (!ageRating) return 0;
|
|
16227
|
+
return AGE_RATING_TO_MIN_AGE[ageRating] ?? 0;
|
|
16228
|
+
}, "getAgeRatingMinAge");
|
|
16229
|
+
var calculateAgeFromDob = /* @__PURE__ */ __name((dob) => {
|
|
16230
|
+
if (!dob) return null;
|
|
16231
|
+
const birthDate = new Date(dob);
|
|
16232
|
+
if (isNaN(birthDate.getTime())) return null;
|
|
16233
|
+
const today = /* @__PURE__ */ new Date();
|
|
16234
|
+
let age = today.getFullYear() - birthDate.getFullYear();
|
|
16235
|
+
const monthDiff = today.getMonth() - birthDate.getMonth();
|
|
16236
|
+
if (monthDiff < 0 || monthDiff === 0 && today.getDate() < birthDate.getDate()) {
|
|
16237
|
+
age--;
|
|
16238
|
+
}
|
|
16239
|
+
return age;
|
|
16240
|
+
}, "calculateAgeFromDob");
|
|
16241
|
+
|
|
16103
16242
|
// src/index.ts
|
|
16104
16243
|
var isHex = /* @__PURE__ */ __name((str) => /^[0-9a-f]+$/i.test(str), "isHex");
|
|
16105
16244
|
var isEncrypted = /* @__PURE__ */ __name((item) => {
|