@fabrika/auth-core 0.7.0 → 0.8.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/package.json +1 -1
- package/src/contract-canonical.ts +1 -0
- package/src/contract.ts +39 -7
package/package.json
CHANGED
|
@@ -51,6 +51,7 @@ export function canonicalizeArtifact(artifact: ContractArtifact): ContractArtifa
|
|
|
51
51
|
...(artifact.csp.frameSrc === undefined ? {} : { frameSrc: sortedSources(artifact.csp.frameSrc) }),
|
|
52
52
|
...(artifact.csp.styleSrc === undefined ? {} : { styleSrc: sortedSources(artifact.csp.styleSrc) }),
|
|
53
53
|
...(artifact.csp.fontSrc === undefined ? {} : { fontSrc: sortedSources(artifact.csp.fontSrc) }),
|
|
54
|
+
...(artifact.csp.workerSrc === undefined ? {} : { workerSrc: sortedSources(artifact.csp.workerSrc) }),
|
|
54
55
|
},
|
|
55
56
|
tables: mapValues(artifact.tables, canonicalTable),
|
|
56
57
|
endpoints: artifact.endpoints.map(canonicalizeEndpoint).sort((a, b) => compare(a.id, b.id)),
|
package/src/contract.ts
CHANGED
|
@@ -152,9 +152,12 @@ export type AnonymousEndpointKind = 'health' | 'form' | 'webhook' | 'link-spa' |
|
|
|
152
152
|
|
|
153
153
|
export type EndpointKind = CredentialedEndpointKind | AnonymousEndpointKind
|
|
154
154
|
|
|
155
|
-
/**
|
|
155
|
+
/**
|
|
156
|
+
* The contract entry that declared an endpoint. A `challenge` row is the framework's own: the endpoint that issues the
|
|
157
|
+
* ALTCHA challenge of the public procedure `name`.
|
|
158
|
+
*/
|
|
156
159
|
export interface EndpointSource {
|
|
157
|
-
readonly kind: 'mount' | 'export' | 'files'
|
|
160
|
+
readonly kind: 'mount' | 'export' | 'files' | 'challenge'
|
|
158
161
|
readonly name: string
|
|
159
162
|
}
|
|
160
163
|
|
|
@@ -547,21 +550,45 @@ export interface FormRate {
|
|
|
547
550
|
readonly bytesPerHour?: number
|
|
548
551
|
}
|
|
549
552
|
|
|
550
|
-
/**
|
|
551
|
-
|
|
553
|
+
/**
|
|
554
|
+
* The closed list of challenge providers. Turnstile is verified at Cloudflare's endpoint and loads its widget from
|
|
555
|
+
* Cloudflare; ALTCHA is issued and verified by the application itself, and its widget is bundled with the page.
|
|
556
|
+
*/
|
|
557
|
+
export type ChallengeProvider = 'turnstile' | 'altcha'
|
|
552
558
|
|
|
559
|
+
/** A 0.4/0.5 form's challenge: Turnstile, the only provider those releases verified. */
|
|
553
560
|
export interface FormChallenge {
|
|
554
|
-
readonly provider:
|
|
561
|
+
readonly provider: 'turnstile'
|
|
555
562
|
/** The application variable holding the provider's secret: a name, never the value. */
|
|
556
563
|
readonly secret: string
|
|
557
564
|
/** The application variable holding the widget's public site key, which every SPA mount's browser config serves. */
|
|
558
565
|
readonly siteKey?: string
|
|
559
566
|
}
|
|
560
567
|
|
|
561
|
-
/** A public procedure's challenge
|
|
562
|
-
export
|
|
568
|
+
/** A public procedure's challenge, by provider. */
|
|
569
|
+
export type ProcedureChallenge = TurnstileChallenge | AltchaChallenge
|
|
570
|
+
|
|
571
|
+
/** Turnstile: a form's challenge, and the widget `action` the verification expects back. */
|
|
572
|
+
export interface TurnstileChallenge extends FormChallenge {
|
|
573
|
+
/** The declared `action`, or the endpoint id with `_` for `.`. */
|
|
574
|
+
readonly action: string
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* ALTCHA: a proof of work the application issues at its endpoint `GET /__fabrika/challenge/<action>` and verifies itself,
|
|
579
|
+
* signed with the HMAC key the application variable `secret` holds. A challenge carries the action and the host it was
|
|
580
|
+
* issued for, and passes for those only, before it expires.
|
|
581
|
+
*/
|
|
582
|
+
export interface AltchaChallenge {
|
|
583
|
+
readonly provider: 'altcha'
|
|
584
|
+
/** The application variable holding the HMAC key: a name, never the value. */
|
|
585
|
+
readonly secret: string
|
|
563
586
|
/** The declared `action`, or the endpoint id with `_` for `.`. */
|
|
564
587
|
readonly action: string
|
|
588
|
+
/** The PBKDF2 iterations of one attempt; a visitor's browser makes several thousand attempts. */
|
|
589
|
+
readonly cost: number
|
|
590
|
+
/** How long an issued challenge may be solved and submitted, in ms; a passed one is recorded as long. */
|
|
591
|
+
readonly maxAgeMs: number
|
|
565
592
|
}
|
|
566
593
|
|
|
567
594
|
export interface WebhookMountArtifact {
|
|
@@ -749,6 +776,11 @@ export interface CspExtensions {
|
|
|
749
776
|
readonly styleSrc?: readonly CspSource[]
|
|
750
777
|
/** Present only when the contract names a font origin. */
|
|
751
778
|
readonly fontSrc?: readonly CspSource[]
|
|
779
|
+
/**
|
|
780
|
+
* Present only when a challenge provider's widget starts its Web Workers from `blob:` URLs (ALTCHA): its one source is
|
|
781
|
+
* `blob:` (`WORKER_BLOB_SOURCE` of `@fabrika/proxy-core/headers`), never an origin, and the contract cannot declare it.
|
|
782
|
+
*/
|
|
783
|
+
readonly workerSrc?: readonly CspSource[]
|
|
752
784
|
}
|
|
753
785
|
|
|
754
786
|
export interface CspSource {
|