@learncard/network-brain-client 2.5.46 → 2.5.48
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/brain-client.cjs.development.cjs +2224 -2054
- package/dist/brain-client.cjs.development.cjs.map +2 -2
- package/dist/brain-client.cjs.production.min.cjs +39 -39
- package/dist/brain-client.cjs.production.min.cjs.map +3 -3
- package/dist/brain-client.esm.js +141 -5
- package/dist/brain-client.esm.js.map +2 -2
- package/dist/index.d.ts.map +1 -1
- package/package.json +9 -6
- package/src/index.ts +30 -3
package/dist/brain-client.esm.js
CHANGED
|
@@ -16055,6 +16055,7 @@ var require_types_cjs_development = __commonJS({
|
|
|
16055
16055
|
DeleteFrameworkInputValidator: /* @__PURE__ */ __name2(() => DeleteFrameworkInputValidator, "DeleteFrameworkInputValidator"),
|
|
16056
16056
|
DeleteSkillInputValidator: /* @__PURE__ */ __name2(() => DeleteSkillInputValidator, "DeleteSkillInputValidator"),
|
|
16057
16057
|
DidDocumentValidator: /* @__PURE__ */ __name2(() => DidDocumentValidator, "DidDocumentValidator"),
|
|
16058
|
+
EMPTY_IN_APP_MESSAGES_FLAG: /* @__PURE__ */ __name2(() => EMPTY_IN_APP_MESSAGES_FLAG, "EMPTY_IN_APP_MESSAGES_FLAG"),
|
|
16058
16059
|
EncryptedCredentialRecordValidator: /* @__PURE__ */ __name2(() => EncryptedCredentialRecordValidator, "EncryptedCredentialRecordValidator"),
|
|
16059
16060
|
EncryptedRecordValidator: /* @__PURE__ */ __name2(() => EncryptedRecordValidator, "EncryptedRecordValidator"),
|
|
16060
16061
|
EndorsementCredentialValidator: /* @__PURE__ */ __name2(() => EndorsementCredentialValidator, "EndorsementCredentialValidator"),
|
|
@@ -16213,7 +16214,28 @@ var require_types_cjs_development = __commonJS({
|
|
|
16213
16214
|
VerificationMethodValidator: /* @__PURE__ */ __name2(() => VerificationMethodValidator, "VerificationMethodValidator"),
|
|
16214
16215
|
VerificationStatusEnum: /* @__PURE__ */ __name2(() => VerificationStatusEnum, "VerificationStatusEnum"),
|
|
16215
16216
|
VerificationStatusValidator: /* @__PURE__ */ __name2(() => VerificationStatusValidator, "VerificationStatusValidator"),
|
|
16216
|
-
|
|
16217
|
+
appStoreActionValidator: /* @__PURE__ */ __name2(() => appStoreActionValidator, "appStoreActionValidator"),
|
|
16218
|
+
capgoUpdateActionValidator: /* @__PURE__ */ __name2(() => capgoUpdateActionValidator, "capgoUpdateActionValidator"),
|
|
16219
|
+
dismissActionValidator: /* @__PURE__ */ __name2(() => dismissActionValidator, "dismissActionValidator"),
|
|
16220
|
+
externalLinkActionValidator: /* @__PURE__ */ __name2(() => externalLinkActionValidator, "externalLinkActionValidator"),
|
|
16221
|
+
inAppMessageActionStyleValidator: /* @__PURE__ */ __name2(() => inAppMessageActionStyleValidator, "inAppMessageActionStyleValidator"),
|
|
16222
|
+
inAppMessageActionTargetValidator: /* @__PURE__ */ __name2(() => inAppMessageActionTargetValidator, "inAppMessageActionTargetValidator"),
|
|
16223
|
+
inAppMessageActionValidator: /* @__PURE__ */ __name2(() => inAppMessageActionValidator, "inAppMessageActionValidator"),
|
|
16224
|
+
inAppMessageFrequencyValidator: /* @__PURE__ */ __name2(() => inAppMessageFrequencyValidator, "inAppMessageFrequencyValidator"),
|
|
16225
|
+
inAppMessageMediaValidator: /* @__PURE__ */ __name2(() => inAppMessageMediaValidator, "inAppMessageMediaValidator"),
|
|
16226
|
+
inAppMessagePlatformValidator: /* @__PURE__ */ __name2(() => inAppMessagePlatformValidator, "inAppMessagePlatformValidator"),
|
|
16227
|
+
inAppMessagePredicateValidator: /* @__PURE__ */ __name2(() => inAppMessagePredicateValidator, "inAppMessagePredicateValidator"),
|
|
16228
|
+
inAppMessagePresentationValidator: /* @__PURE__ */ __name2(() => inAppMessagePresentationValidator, "inAppMessagePresentationValidator"),
|
|
16229
|
+
inAppMessageValidator: /* @__PURE__ */ __name2(() => inAppMessageValidator, "inAppMessageValidator"),
|
|
16230
|
+
inAppMessageVersionOpValidator: /* @__PURE__ */ __name2(() => inAppMessageVersionOpValidator, "inAppMessageVersionOpValidator"),
|
|
16231
|
+
inAppMessageVersionSourceValidator: /* @__PURE__ */ __name2(() => inAppMessageVersionSourceValidator, "inAppMessageVersionSourceValidator"),
|
|
16232
|
+
inAppMessagesFlagValidator: /* @__PURE__ */ __name2(() => inAppMessagesFlagValidator, "inAppMessagesFlagValidator"),
|
|
16233
|
+
internalLinkActionValidator: /* @__PURE__ */ __name2(() => internalLinkActionValidator, "internalLinkActionValidator"),
|
|
16234
|
+
isStoredCredentialEnvelope: /* @__PURE__ */ __name2(() => isStoredCredentialEnvelope2, "isStoredCredentialEnvelope"),
|
|
16235
|
+
parseInAppMessagesFlag: /* @__PURE__ */ __name2(() => parseInAppMessagesFlag, "parseInAppMessagesFlag"),
|
|
16236
|
+
platformPredicateValidator: /* @__PURE__ */ __name2(() => platformPredicateValidator, "platformPredicateValidator"),
|
|
16237
|
+
rolePredicateValidator: /* @__PURE__ */ __name2(() => rolePredicateValidator, "rolePredicateValidator"),
|
|
16238
|
+
versionPredicateValidator: /* @__PURE__ */ __name2(() => versionPredicateValidator, "versionPredicateValidator")
|
|
16217
16239
|
});
|
|
16218
16240
|
module.exports = __toCommonJS(index_exports);
|
|
16219
16241
|
var external_exports2 = {};
|
|
@@ -32538,6 +32560,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
32538
32560
|
role: external_exports2.string().default("").optional().describe('Role of the profile: e.g. "teacher", "student".'),
|
|
32539
32561
|
dob: external_exports2.string().default("").optional().describe('Date of birth of the profile: e.g. "1990-01-01".'),
|
|
32540
32562
|
country: external_exports2.string().optional().describe("Country for the profile."),
|
|
32563
|
+
locale: external_exports2.string().optional().describe(
|
|
32564
|
+
"BCP-47 language tag (e.g. 'es', 'fr', 'ar') \u2014 the user's preferred language for server-sent notifications and emails."
|
|
32565
|
+
),
|
|
32541
32566
|
approved: external_exports2.boolean().optional().describe("Approval status for the profile.")
|
|
32542
32567
|
});
|
|
32543
32568
|
var LCNPublicProfileValidator = LCNProfileValidator.pick({
|
|
@@ -33083,7 +33108,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
33083
33108
|
"GUARDIAN_APPROVAL_PENDING",
|
|
33084
33109
|
"GUARDIAN_APPROVED",
|
|
33085
33110
|
"GUARDIAN_REJECTED",
|
|
33086
|
-
"APP_NOTIFICATION"
|
|
33111
|
+
"APP_NOTIFICATION",
|
|
33112
|
+
"CREDENTIAL_REVOKED",
|
|
33113
|
+
"CREDENTIAL_SUSPENDED",
|
|
33114
|
+
"CREDENTIAL_UNSUSPENDED"
|
|
33087
33115
|
]);
|
|
33088
33116
|
var LCNNotificationMessageValidator = external_exports2.object({
|
|
33089
33117
|
title: external_exports2.string().optional(),
|
|
@@ -33883,6 +33911,97 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
33883
33911
|
statusPurposes: external_exports2.array(BitstringStatusPurposeValidator).optional(),
|
|
33884
33912
|
listSize: external_exports2.number().int().positive().optional()
|
|
33885
33913
|
}).default({});
|
|
33914
|
+
var inAppMessagePlatformValidator = external_exports2.enum(["ios", "android", "web"]);
|
|
33915
|
+
var inAppMessageVersionSourceValidator = external_exports2.enum(["native", "web", "capgo"]);
|
|
33916
|
+
var inAppMessageVersionOpValidator = external_exports2.enum(["lt", "lte", "eq", "gte", "gt"]);
|
|
33917
|
+
var platformPredicateValidator = external_exports2.object({ platform: external_exports2.array(inAppMessagePlatformValidator).nonempty() }).strict();
|
|
33918
|
+
var rolePredicateValidator = external_exports2.object({ role: external_exports2.array(external_exports2.string()).nonempty() }).strict();
|
|
33919
|
+
var versionPredicateValidator = external_exports2.object({
|
|
33920
|
+
version: external_exports2.object({
|
|
33921
|
+
source: inAppMessageVersionSourceValidator,
|
|
33922
|
+
op: inAppMessageVersionOpValidator,
|
|
33923
|
+
value: external_exports2.string()
|
|
33924
|
+
}).strict()
|
|
33925
|
+
}).strict();
|
|
33926
|
+
var inAppMessagePredicateValidator = external_exports2.lazy(
|
|
33927
|
+
() => external_exports2.union([
|
|
33928
|
+
platformPredicateValidator,
|
|
33929
|
+
rolePredicateValidator,
|
|
33930
|
+
versionPredicateValidator,
|
|
33931
|
+
external_exports2.object({ all: external_exports2.array(inAppMessagePredicateValidator) }).strict(),
|
|
33932
|
+
external_exports2.object({ any: external_exports2.array(inAppMessagePredicateValidator) }).strict(),
|
|
33933
|
+
external_exports2.object({ not: inAppMessagePredicateValidator }).strict()
|
|
33934
|
+
])
|
|
33935
|
+
);
|
|
33936
|
+
var inAppMessageActionStyleValidator = external_exports2.enum(["primary", "secondary", "positive", "dismiss"]).default("secondary");
|
|
33937
|
+
var internalLinkActionValidator = external_exports2.object({ type: external_exports2.literal("internalLink"), path: external_exports2.string() }).passthrough();
|
|
33938
|
+
var externalLinkActionValidator = external_exports2.object({ type: external_exports2.literal("externalLink"), url: external_exports2.string() }).passthrough();
|
|
33939
|
+
var appStoreActionValidator = external_exports2.object({
|
|
33940
|
+
type: external_exports2.literal("appStore"),
|
|
33941
|
+
iosUrl: external_exports2.string().optional(),
|
|
33942
|
+
androidUrl: external_exports2.string().optional(),
|
|
33943
|
+
webUrl: external_exports2.string().optional()
|
|
33944
|
+
}).passthrough();
|
|
33945
|
+
var capgoUpdateActionValidator = external_exports2.object({ type: external_exports2.literal("capgoUpdate") }).passthrough();
|
|
33946
|
+
var dismissActionValidator = external_exports2.object({ type: external_exports2.literal("dismiss") }).passthrough();
|
|
33947
|
+
var inAppMessageActionTargetValidator = external_exports2.union([
|
|
33948
|
+
internalLinkActionValidator,
|
|
33949
|
+
externalLinkActionValidator,
|
|
33950
|
+
appStoreActionValidator,
|
|
33951
|
+
capgoUpdateActionValidator,
|
|
33952
|
+
dismissActionValidator
|
|
33953
|
+
]);
|
|
33954
|
+
var inAppMessageActionValidator = external_exports2.object({
|
|
33955
|
+
label: external_exports2.string(),
|
|
33956
|
+
style: inAppMessageActionStyleValidator,
|
|
33957
|
+
action: inAppMessageActionTargetValidator,
|
|
33958
|
+
/** When true, the message closes after this action runs (default true). */
|
|
33959
|
+
closeOnComplete: external_exports2.boolean().default(true)
|
|
33960
|
+
}).passthrough();
|
|
33961
|
+
var inAppMessageMediaValidator = external_exports2.object({
|
|
33962
|
+
type: external_exports2.enum(["youtube", "image", "gif"]),
|
|
33963
|
+
url: external_exports2.string(),
|
|
33964
|
+
/** Aspect ratio hint, e.g. "16:9" or "1:1". Defaults to 16:9. */
|
|
33965
|
+
aspect: external_exports2.string().default("16:9"),
|
|
33966
|
+
/** Alt text for images/gifs (accessibility). */
|
|
33967
|
+
alt: external_exports2.string().optional()
|
|
33968
|
+
}).passthrough();
|
|
33969
|
+
var inAppMessageFrequencyValidator = external_exports2.union([
|
|
33970
|
+
external_exports2.literal("once"),
|
|
33971
|
+
external_exports2.literal("session"),
|
|
33972
|
+
external_exports2.literal("always"),
|
|
33973
|
+
external_exports2.object({ everyDays: external_exports2.number().positive() }).strict()
|
|
33974
|
+
]).default("once");
|
|
33975
|
+
var inAppMessagePresentationValidator = external_exports2.enum(["modal", "banner", "toast"]).default("modal");
|
|
33976
|
+
var inAppMessageValidator = external_exports2.object({
|
|
33977
|
+
/** Stable identifier — used to persist dismissal / frequency state. */
|
|
33978
|
+
id: external_exports2.string(),
|
|
33979
|
+
/** Higher priority wins when multiple messages match. Default 0. */
|
|
33980
|
+
priority: external_exports2.number().default(0),
|
|
33981
|
+
/** When false, the message is required/blocking (no dismiss affordance). */
|
|
33982
|
+
dismissible: external_exports2.boolean().default(true),
|
|
33983
|
+
frequency: inAppMessageFrequencyValidator,
|
|
33984
|
+
presentation: inAppMessagePresentationValidator,
|
|
33985
|
+
media: inAppMessageMediaValidator.optional(),
|
|
33986
|
+
/** Optional emoji hero glyph — rendered only when `media` is not set. */
|
|
33987
|
+
emoji: external_exports2.string().optional(),
|
|
33988
|
+
title: external_exports2.string(),
|
|
33989
|
+
body: external_exports2.string().optional(),
|
|
33990
|
+
actions: external_exports2.array(inAppMessageActionValidator).default([]),
|
|
33991
|
+
/** Targeting predicate tree. Omitted → matches everyone. */
|
|
33992
|
+
targeting: inAppMessagePredicateValidator.optional(),
|
|
33993
|
+
/** Allow disabling a message without removing it from the flag. */
|
|
33994
|
+
enabled: external_exports2.boolean().default(true)
|
|
33995
|
+
}).passthrough();
|
|
33996
|
+
var inAppMessagesFlagValidator = external_exports2.object({
|
|
33997
|
+
version: external_exports2.number().default(1),
|
|
33998
|
+
messages: external_exports2.array(inAppMessageValidator).default([])
|
|
33999
|
+
}).passthrough();
|
|
34000
|
+
var EMPTY_IN_APP_MESSAGES_FLAG = { version: 1, messages: [] };
|
|
34001
|
+
var parseInAppMessagesFlag = /* @__PURE__ */ __name22((raw) => {
|
|
34002
|
+
const result = inAppMessagesFlagValidator.safeParse(raw);
|
|
34003
|
+
return result.success ? result.data : EMPTY_IN_APP_MESSAGES_FLAG;
|
|
34004
|
+
}, "parseInAppMessagesFlag");
|
|
33886
34005
|
}
|
|
33887
34006
|
});
|
|
33888
34007
|
var require_dist = __commonJS({
|
|
@@ -35466,7 +35585,24 @@ var getClient = /* @__PURE__ */ __name(async (url2, didAuthFunction, guardianApp
|
|
|
35466
35585
|
const getChallenges = /* @__PURE__ */ __name(async (amount = 95 + Math.round((Math.random() - 0.5) * 5)) => {
|
|
35467
35586
|
return challengeRequester.utilities.getChallenges.query({ amount });
|
|
35468
35587
|
}, "getChallenges");
|
|
35469
|
-
|
|
35588
|
+
let refillPromise;
|
|
35589
|
+
const refillChallenges = /* @__PURE__ */ __name(() => {
|
|
35590
|
+
refillPromise ??= getChallenges().then((result) => {
|
|
35591
|
+
if (result.length === 0) throw new Error("Challenge refill returned no challenges");
|
|
35592
|
+
challenges.push(...result);
|
|
35593
|
+
}).finally(() => {
|
|
35594
|
+
refillPromise = void 0;
|
|
35595
|
+
});
|
|
35596
|
+
return refillPromise;
|
|
35597
|
+
}, "refillChallenges");
|
|
35598
|
+
const takeChallenge = /* @__PURE__ */ __name(async () => {
|
|
35599
|
+
while (true) {
|
|
35600
|
+
const challenge = challenges.pop();
|
|
35601
|
+
if (challenge !== void 0) return challenge;
|
|
35602
|
+
await refillChallenges();
|
|
35603
|
+
}
|
|
35604
|
+
}, "takeChallenge");
|
|
35605
|
+
void refillChallenges().catch(() => void 0);
|
|
35470
35606
|
const trpc = createTRPCClient({
|
|
35471
35607
|
links: [
|
|
35472
35608
|
callbackLink(async () => {
|
|
@@ -35477,10 +35613,10 @@ var getClient = /* @__PURE__ */ __name(async (url2, didAuthFunction, guardianApp
|
|
|
35477
35613
|
maxURLLength: 3072,
|
|
35478
35614
|
url: url2,
|
|
35479
35615
|
headers: /* @__PURE__ */ __name(async () => {
|
|
35480
|
-
|
|
35616
|
+
const challenge = await takeChallenge();
|
|
35481
35617
|
const guardianApproval = guardianApprovalGetter ? await guardianApprovalGetter() : void 0;
|
|
35482
35618
|
return {
|
|
35483
|
-
Authorization: `Bearer ${await didAuthFunction(
|
|
35619
|
+
Authorization: `Bearer ${await didAuthFunction(challenge)}`,
|
|
35484
35620
|
...guardianApproval ? { "x-guardian-approval": guardianApproval } : {},
|
|
35485
35621
|
...extraHeaders
|
|
35486
35622
|
};
|