@learncard/helpers 1.3.12 → 1.4.0
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/Utilities.d.ts +59 -0
- package/dist/Utilities.d.ts.map +1 -0
- package/dist/app-install/index.d.ts +62 -0
- package/dist/app-install/index.d.ts.map +1 -0
- package/dist/arrays/index.d.ts +3 -0
- package/dist/arrays/index.d.ts.map +1 -0
- package/dist/bitstring-status-list/index.d.ts +8 -0
- package/dist/bitstring-status-list/index.d.ts.map +1 -0
- package/dist/credential-format.d.ts +96 -0
- package/dist/credential-format.d.ts.map +1 -0
- package/dist/did.d.ts +3 -0
- package/dist/did.d.ts.map +1 -0
- package/dist/environment.d.ts +32 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/helpers.cjs.development.cjs +1648 -1540
- package/dist/helpers.cjs.development.cjs.map +4 -4
- package/dist/helpers.cjs.production.min.cjs +15 -11
- package/dist/helpers.cjs.production.min.cjs.map +4 -4
- package/dist/helpers.esm.js +172 -80
- package/dist/helpers.esm.js.map +4 -4
- package/dist/images/discord.helpers.d.ts +65 -0
- package/dist/images/discord.helpers.d.ts.map +1 -0
- package/dist/images/filestack.helpers.d.ts +92 -0
- package/dist/images/filestack.helpers.d.ts.map +1 -0
- package/dist/images/images.helpers.d.ts +32 -0
- package/dist/images/images.helpers.d.ts.map +1 -0
- package/dist/images/index.d.ts +2 -0
- package/dist/images/index.d.ts.map +1 -0
- package/dist/images/unsplash.helpers.d.ts +64 -0
- package/dist/images/unsplash.helpers.d.ts.map +1 -0
- package/dist/images/url.helpers.d.ts +14 -0
- package/dist/images/url.helpers.d.ts.map +1 -0
- package/dist/index.d.cts +43 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/numbers/index.d.ts +5 -0
- package/dist/numbers/index.d.ts.map +1 -0
- package/dist/state.d.ts +130 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/strings/index.d.ts +2 -0
- package/dist/strings/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +12 -17
- package/src/credential-format.ts +5 -4
- package/src/environment.ts +75 -0
- package/src/index.ts +11 -10
- package/dist/helpers.d.cts +0 -979
- package/dist/helpers.d.ts +0 -979
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ImageResizingValidator: z.ZodObject<{
|
|
3
|
+
type: z.ZodLiteral<"resizing">;
|
|
4
|
+
}, z.core.$strip>;
|
|
5
|
+
export type ImageResizing = z.infer<typeof ImageResizingValidator>;
|
|
6
|
+
export declare const ImageUploadingValidator: z.ZodObject<{
|
|
7
|
+
type: z.ZodLiteral<"uploading">;
|
|
8
|
+
progress: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
export type ImageUploading = z.infer<typeof ImageUploadingValidator>;
|
|
11
|
+
export declare const ImageWithLoadingStateValdator: z.ZodObject<{
|
|
12
|
+
image: z.ZodString;
|
|
13
|
+
loading: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
14
|
+
type: z.ZodLiteral<"resizing">;
|
|
15
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
16
|
+
type: z.ZodLiteral<"uploading">;
|
|
17
|
+
progress: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
}, z.core.$strip>]>>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export type ImageWithLoadingState = z.infer<typeof ImageWithLoadingStateValdator>;
|
|
21
|
+
export type FilestackImage = {
|
|
22
|
+
filename: string;
|
|
23
|
+
handle: string;
|
|
24
|
+
mimetype: string;
|
|
25
|
+
originalFile: {
|
|
26
|
+
name: string;
|
|
27
|
+
size: number;
|
|
28
|
+
type: string;
|
|
29
|
+
};
|
|
30
|
+
originalPath: string;
|
|
31
|
+
size: number;
|
|
32
|
+
source: string;
|
|
33
|
+
status: string;
|
|
34
|
+
uploadId: string;
|
|
35
|
+
url: string;
|
|
36
|
+
};
|
|
37
|
+
export type Simplify<T> = {
|
|
38
|
+
[KeyType in keyof T]: T[KeyType];
|
|
39
|
+
};
|
|
40
|
+
export type Maybify<T> = Simplify<{
|
|
41
|
+
[P in keyof T]?: Maybify<T[P]> | null;
|
|
42
|
+
}>;
|
|
43
|
+
/** If Maybify gives you an exceeds maximum length error, try this one! */
|
|
44
|
+
export type PerformantMaybify<T> = {
|
|
45
|
+
[P in keyof T]?: PerformantMaybify<T[P]> | null;
|
|
46
|
+
};
|
|
47
|
+
export type DeepValues<ObjectType extends object> = {
|
|
48
|
+
[Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object ? DeepValues<ObjectType[Key]> : ObjectType[Key];
|
|
49
|
+
}[keyof ObjectType & (string | number)];
|
|
50
|
+
export interface Nothing {
|
|
51
|
+
}
|
|
52
|
+
export type Other<T> = T & Nothing;
|
|
53
|
+
export type SuggestString<Literals extends string> = Literals | Other<string>;
|
|
54
|
+
export type DeepPartial<T> = T extends Date ? T : T extends object ? {
|
|
55
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
56
|
+
} : T;
|
|
57
|
+
export declare const isNotUndefined: <T>(value: T | null | undefined) => value is T;
|
|
58
|
+
export declare const filterUndefined: <T>(arr: (T | null | undefined)[]) => T[];
|
|
59
|
+
//# sourceMappingURL=Utilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Utilities.d.ts","sourceRoot":"","sources":["../src/Utilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,sBAAsB;;iBAA4C,CAAC;AAChF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEnE,eAAO,MAAM,uBAAuB;;;iBAGlC,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KA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,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAC3B,UAAU,CAAC,GAAG,CAAC;CACxB,CAAC,MAAM,UAAU,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;AAExC,MAAM,WAAW,OAAO;CAAG;AAC3B,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;AAEnC,MAAM,MAAM,aAAa,CAAC,QAAQ,SAAS,MAAM,IAAI,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;AAE9E,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,IAAI,GACrC,CAAC,GACD,CAAC,SAAS,MAAM,GAChB;KACK,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CACrC,GACD,CAAC,CAAC;AAER,eAAO,MAAM,cAAc,GAAI,CAAC,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,KAAG,KAAK,IAAI,CAAmB,CAAC;AAE7F,eAAO,MAAM,eAAe,GAAI,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,QAA+B,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App installation age restriction logic shared between frontend and backend.
|
|
3
|
+
*
|
|
4
|
+
* This helper evaluates whether a user can install an app based on:
|
|
5
|
+
* - Hard age blocks (min_age) - always blocks, even with guardian approval
|
|
6
|
+
* - Soft age restrictions (age_rating) - can be approved by guardian for child profiles
|
|
7
|
+
* - Contract requirements - require guardian approval for child profiles
|
|
8
|
+
*/
|
|
9
|
+
export type AppInstallCheckResult = {
|
|
10
|
+
action: 'proceed';
|
|
11
|
+
} | {
|
|
12
|
+
action: 'hard_blocked';
|
|
13
|
+
reason: string;
|
|
14
|
+
} | {
|
|
15
|
+
action: 'require_dob';
|
|
16
|
+
reason: string;
|
|
17
|
+
} | {
|
|
18
|
+
action: 'require_guardian_approval';
|
|
19
|
+
reason: string;
|
|
20
|
+
};
|
|
21
|
+
export type AppInstallCheckInput = {
|
|
22
|
+
/** Whether the user is a child profile (managed account) */
|
|
23
|
+
isChildProfile: boolean;
|
|
24
|
+
/** User's age calculated from DOB, null if DOB is unknown */
|
|
25
|
+
userAge: number | null;
|
|
26
|
+
/** Hard minimum age requirement (blocks completely, no guardian override) */
|
|
27
|
+
minAge?: number;
|
|
28
|
+
/** Soft age rating string (e.g., '4+', '9+', '12+', '17+') */
|
|
29
|
+
ageRating?: string;
|
|
30
|
+
/** Whether the app has an associated consent contract */
|
|
31
|
+
hasContract: boolean;
|
|
32
|
+
/** Whether guardian approval has already been obtained (for backend validation) */
|
|
33
|
+
hasGuardianApproval?: boolean;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Evaluates whether a user can install an app based on age restrictions and profile type.
|
|
37
|
+
*
|
|
38
|
+
* Cases:
|
|
39
|
+
* 1. Hard block: min_age violation (blocks completely, cannot be overridden)
|
|
40
|
+
* 2. Child profile scenarios:
|
|
41
|
+
* 2a. Child age unknown → require DOB entry (with guardian approval)
|
|
42
|
+
* 2b. No age rating specified → require guardian approval
|
|
43
|
+
* 2c. Child too young for age rating → require guardian approval
|
|
44
|
+
* 2d. App has a contract → require guardian approval
|
|
45
|
+
* 2e. Child old enough, no contract → proceed without guardian
|
|
46
|
+
* 3. Adult user old enough → proceed
|
|
47
|
+
*
|
|
48
|
+
* @param input - The check parameters
|
|
49
|
+
* @returns The action to take and reason if blocked/requires approval
|
|
50
|
+
*/
|
|
51
|
+
export declare const checkAppInstallEligibility: (input: AppInstallCheckInput) => AppInstallCheckResult;
|
|
52
|
+
/**
|
|
53
|
+
* Map age_rating strings to numeric minimum ages.
|
|
54
|
+
*/
|
|
55
|
+
export declare const AGE_RATING_TO_MIN_AGE: Record<string, number>;
|
|
56
|
+
/**
|
|
57
|
+
* Calculate age in years from a date of birth string.
|
|
58
|
+
* @param dob - Date of birth as ISO string or parseable date string
|
|
59
|
+
* @returns Age in years, or null if the date is invalid
|
|
60
|
+
*/
|
|
61
|
+
export declare const calculateAgeFromDob: (dob?: string | null) => number | null;
|
|
62
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/app-install/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,qBAAqB,GAC3B;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IAAE,MAAM,EAAE,cAAc,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC1C;IAAE,MAAM,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACzC;IAAE,MAAM,EAAE,2BAA2B,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,oBAAoB,GAAG;IAC/B,4DAA4D;IAC5D,cAAc,EAAE,OAAO,CAAC;IACxB,6DAA6D;IAC7D,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,WAAW,EAAE,OAAO,CAAC;IACrB,mFAAmF;IACnF,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,0BAA0B,GAAI,OAAO,oBAAoB,KAAG,qBAgFxE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAKxD,CAAC;AAWF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,MAAM,MAAM,GAAG,IAAI,KAAG,MAAM,GAAG,IAelE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/arrays/index.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,EAAE,OAAO,MAAM,EAAE,WAkB3D,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BitstringStatusListEntry, BitstringStatusPurpose } from '@learncard/types';
|
|
2
|
+
export declare const getCredentialStatusArray: (credential: unknown) => Record<string, unknown>[];
|
|
3
|
+
export declare const isBitstringStatusListEntry: (status: unknown) => status is BitstringStatusListEntry;
|
|
4
|
+
export declare const getBitstringStatusListEntries: (credential: unknown) => BitstringStatusListEntry[];
|
|
5
|
+
export declare const getBitstringStatusListEntryForPurpose: (credential: unknown, statusPurpose: BitstringStatusPurpose) => BitstringStatusListEntry | undefined;
|
|
6
|
+
export declare const getBitstringStatusListBit: (bitstring: Uint8Array, index: number) => boolean;
|
|
7
|
+
export declare const setBitstringStatusListBit: (bitstring: Uint8Array, index: number, value: boolean) => void;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bitstring-status-list/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAEzF,eAAO,MAAM,wBAAwB,GAAI,YAAY,OAAO,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EASrF,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,QAAQ,OAAO,KAAG,MAAM,IAAI,wBAetE,CAAC;AAEF,eAAO,MAAM,6BAA6B,GAAI,YAAY,OAAO,KAAG,wBAAwB,EAU3F,CAAC;AAEF,eAAO,MAAM,qCAAqC,GAC9C,YAAY,OAAO,EACnB,eAAe,sBAAsB,KACtC,wBAAwB,GAAG,SACoE,CAAC;AAEnG,eAAO,MAAM,yBAAyB,GAAI,WAAW,UAAU,EAAE,OAAO,MAAM,KAAG,OAQhF,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAClC,WAAW,UAAU,EACrB,OAAO,MAAM,EACb,OAAO,OAAO,KACf,IAUF,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { CredentialRecord, StoredCredential, StoredCredentialEnvelope, VC, VP } from '@learncard/types';
|
|
2
|
+
/**
|
|
3
|
+
* Project a `CredentialRecord` into a format-discriminated read view.
|
|
4
|
+
*
|
|
5
|
+
* Two paths into the same output:
|
|
6
|
+
*
|
|
7
|
+
* 1. **Explicit format**: if the record carries an explicit `format`
|
|
8
|
+
* discriminator (and `rawWireForm` where required), the projector
|
|
9
|
+
* trusts it. This is the path new format-aware writers take.
|
|
10
|
+
*
|
|
11
|
+
* 2. **Inferred from shape** (legacy fallback): for records that
|
|
12
|
+
* pre-date format-tagging, the projector inspects `record.vc` and
|
|
13
|
+
* infers the format. W3C VCs → `w3c-vc-2.0` / `w3c-vc-1.1` based
|
|
14
|
+
* on `@context`; transitional SD-JWT wrappers (which never shipped
|
|
15
|
+
* but exist on branch `lc-1796-3`) → `dc+sd-jwt` with the compact
|
|
16
|
+
* extracted from `proof.jwt`; legacy JWT-VC envelopes → `jwt-vc-json`.
|
|
17
|
+
*
|
|
18
|
+
* Returns a `StoredCredential` for every conceivable record. Never
|
|
19
|
+
* throws — credentials with unrecognizable shape fall back to
|
|
20
|
+
* `w3c-vc-1.1` with `data = record.vc` so legacy consumers keep
|
|
21
|
+
* something they can read.
|
|
22
|
+
*
|
|
23
|
+
* This projector is the SAFETY NET that makes the format-tagging
|
|
24
|
+
* migration non-breaking: writers can adopt format-tagging at their
|
|
25
|
+
* own pace; readers using this projector see the right discriminator
|
|
26
|
+
* either way.
|
|
27
|
+
*/
|
|
28
|
+
export declare const toStoredCredential: (record: CredentialRecord) => StoredCredential;
|
|
29
|
+
/**
|
|
30
|
+
* Extract the meaningful identifying segment from an SD-JWT-VC `vct` claim
|
|
31
|
+
* so it can be projected onto the W3C-VC `type` array and `name` field.
|
|
32
|
+
*
|
|
33
|
+
* Returns `undefined` for vct values where no meaningful name can be
|
|
34
|
+
* derived (numeric-only URN tails, empty string). Shared between the
|
|
35
|
+
* receipt-time wrapper synthesizer and the read-time display projector
|
|
36
|
+
* so SD-JWT credentials produce the same wrapper shape on both paths.
|
|
37
|
+
*/
|
|
38
|
+
export declare const extractVctSegment: (vct: string) => string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* PascalCase identifier suitable for the W3C-VC `type` array. Picks acronyms
|
|
41
|
+
* for short single-word lowercase segments ("pid" → "PID") and otherwise
|
|
42
|
+
* concatenates capitalized words ("playground-credential" → "PlaygroundCredential").
|
|
43
|
+
*/
|
|
44
|
+
export declare const deriveTypeFromVct: (vct: string | undefined) => string | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Human-readable display name for the `name` field. Same input handling
|
|
47
|
+
* as {@link deriveTypeFromVct} but keeps spaces between words so it reads
|
|
48
|
+
* naturally in UIs ("Playground Credential" not "PlaygroundCredential").
|
|
49
|
+
*/
|
|
50
|
+
export declare const deriveNameFromVct: (vct: string | undefined) => string | undefined;
|
|
51
|
+
export declare const stripSdJwtReservedClaims: (claims: Record<string, unknown>) => Record<string, unknown>;
|
|
52
|
+
export declare const synthesizeDidJwk: (jwk: Record<string, unknown>) => string | undefined;
|
|
53
|
+
export declare const deriveSdJwtIssuedAtIso: (options: {
|
|
54
|
+
issuedAt?: Date;
|
|
55
|
+
notBefore?: Date;
|
|
56
|
+
iat?: number;
|
|
57
|
+
nbf?: number;
|
|
58
|
+
}) => string;
|
|
59
|
+
/**
|
|
60
|
+
* Read-path shim: when a storage plugin returns a `StoredCredentialEnvelope` (because we
|
|
61
|
+
* wrote a native non-W3C format like SD-JWT-VC), legacy UI components
|
|
62
|
+
* that read `.credentialSubject` / `.issuer` / `.proof` need a VC-shaped
|
|
63
|
+
* object. This projector synthesizes a minimal display-only VC from the
|
|
64
|
+
* envelope so existing consumers keep working without per-component
|
|
65
|
+
* format awareness.
|
|
66
|
+
*
|
|
67
|
+
* For SD-JWT-VC: decodes the unsigned JWS payload (signature is NOT
|
|
68
|
+
* verified here — verification belongs to the dedicated verify chain),
|
|
69
|
+
* surfaces the disclosed claims under `credentialSubject`, preserves
|
|
70
|
+
* the compact form under `proof.jwt` and `proof.type = 'SdJwtCompactProof'`
|
|
71
|
+
* so anything that already understands the SD-JWT-Compact-Proof shape
|
|
72
|
+
* keeps working.
|
|
73
|
+
*
|
|
74
|
+
* For JWT-VC: decodes the JWS payload, returns its `vc` claim.
|
|
75
|
+
*
|
|
76
|
+
* For mDoc / unknown formats: returns `undefined` — the caller MUST
|
|
77
|
+
* branch on format (`record.format === 'mso_mdoc'`) and use a
|
|
78
|
+
* format-specific display path. We don't fabricate a fake VC for
|
|
79
|
+
* binary credentials.
|
|
80
|
+
*
|
|
81
|
+
* This projector is intentionally LOSSY for SD-JWT — it produces a
|
|
82
|
+
* display-only view, NOT a re-issuable credential. Egress paths
|
|
83
|
+
* (sharing, presenting, re-uploading) MUST go through
|
|
84
|
+
* `serializeForWire(stored)` (Phase 3) to recover the canonical
|
|
85
|
+
* compact form from `envelope.data`. NEVER re-serialize from the
|
|
86
|
+
* projected VC.
|
|
87
|
+
*/
|
|
88
|
+
export declare const projectEnvelopeToDisplayVc: (envelope: StoredCredentialEnvelope) => VC | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* Convenience: detect an envelope on the wire and return a legacy VC
|
|
91
|
+
* shape suitable for downstream W3C-only consumers. Returns the input
|
|
92
|
+
* unchanged if it's not an envelope (so callers can wrap any
|
|
93
|
+
* `read.get` result without branching themselves).
|
|
94
|
+
*/
|
|
95
|
+
export declare const resolveStorageReadResult: (value: VC | VP | StoredCredentialEnvelope | undefined) => VC | VP | StoredCredentialEnvelope | undefined;
|
|
96
|
+
//# sourceMappingURL=credential-format.d.ts.map
|
|
@@ -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AAO,EAAE,GAAG,EAAE,GAAG,wBAAwB,GAAG,SAAS,KACtD,EAAE,GAAG,EAAE,GAAG,wBAAwB,GAAG,SAKvC,CAAC"}
|
package/dist/did.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"did.d.ts","sourceRoot":"","sources":["../src/did.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,EAAE,WAAW,MAAM,KAAG,MAU7D,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export type EnvironmentSource = {
|
|
3
|
+
project: string;
|
|
4
|
+
source: string;
|
|
5
|
+
examplePath: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class EnvironmentConfigurationError extends Error {
|
|
8
|
+
constructor(message: string);
|
|
9
|
+
}
|
|
10
|
+
export declare const requiredEnvironmentString: z.ZodString;
|
|
11
|
+
export declare const optionalEnvironmentString: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
|
|
12
|
+
export declare const optionalEnvironmentUrl: z.ZodPreprocess<z.ZodOptional<z.ZodURL>>;
|
|
13
|
+
/**
|
|
14
|
+
* Deployment manifests historically use both true/false and 1/0. These are the complete
|
|
15
|
+
* accepted spellings; every other value fails validation.
|
|
16
|
+
*/
|
|
17
|
+
export declare const environmentBoolean: z.ZodPipe<z.ZodEnum<{
|
|
18
|
+
0: "0";
|
|
19
|
+
1: "1";
|
|
20
|
+
true: "true";
|
|
21
|
+
false: "false";
|
|
22
|
+
}>, z.ZodTransform<boolean, "0" | "1" | "true" | "false">>;
|
|
23
|
+
export declare const optionalEnvironmentBoolean: z.ZodPreprocess<z.ZodOptional<z.ZodPipe<z.ZodEnum<{
|
|
24
|
+
0: "0";
|
|
25
|
+
1: "1";
|
|
26
|
+
true: "true";
|
|
27
|
+
false: "false";
|
|
28
|
+
}>, z.ZodTransform<boolean, "0" | "1" | "true" | "false">>>>;
|
|
29
|
+
export declare const environmentPort: z.ZodCoercedNumber<unknown>;
|
|
30
|
+
export declare const optionalEnvironmentPort: z.ZodPreprocess<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
31
|
+
export declare const parseEnvironment: <Schema extends z.ZodType>(schema: Schema, raw: Record<string, unknown>, context: EnvironmentSource) => z.output<Schema>;
|
|
32
|
+
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,MAAM,iBAAiB,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,qBAAa,6BAA8B,SAAQ,KAAK;gBACxC,OAAO,EAAE,MAAM;CAI9B;AAED,eAAO,MAAM,yBAAyB,aAAmD,CAAC;AAE1F,eAAO,MAAM,yBAAyB,6CAGrC,CAAC;AAEF,eAAO,MAAM,sBAAsB,0CAGlC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;0DAE2B,CAAC;AAE3D,eAAO,MAAM,0BAA0B;;;;;4DAGtC,CAAC;AAEF,eAAO,MAAM,eAAe,6BAA6C,CAAC;AAE1E,eAAO,MAAM,uBAAuB,6DAGnC,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,MAAM,SAAS,CAAC,CAAC,OAAO,EACrD,QAAQ,MAAM,EACd,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,SAAS,iBAAiB,KAC3B,CAAC,CAAC,MAAM,CAAC,MAAM,CAuBjB,CAAC"}
|