@spfn/auth 0.3.0-beta.3 → 0.3.0-beta.4
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/README.md +33 -2
- package/dist/client-proof.d.ts +23 -4
- package/dist/client-proof.js +57 -2
- package/dist/client-proof.js.map +1 -1
- package/dist/server.js +57 -2
- package/dist/server.js.map +1 -1
- package/package.json +2 -2
package/dist/server.js
CHANGED
|
@@ -11675,6 +11675,10 @@ function contractViolation(message) {
|
|
|
11675
11675
|
|
|
11676
11676
|
// src/server/client-proof/contract-bundle.ts
|
|
11677
11677
|
import { createHash as createHash7 } from "crypto";
|
|
11678
|
+
import {
|
|
11679
|
+
CORE_TIME_OPERATION_ID as CORE_TIME_OPERATION_ID2,
|
|
11680
|
+
ServerTimeResponseSchema
|
|
11681
|
+
} from "@spfn/core/server";
|
|
11678
11682
|
init_types();
|
|
11679
11683
|
|
|
11680
11684
|
// src/server/client-proof/proof.ts
|
|
@@ -11805,17 +11809,68 @@ function isRequestContentType(value) {
|
|
|
11805
11809
|
return value.split(";")[0].trim().toLowerCase() === CLIENT_PROOF_CONTENT_TYPE;
|
|
11806
11810
|
}
|
|
11807
11811
|
|
|
11812
|
+
// src/server/client-proof/contract-types.ts
|
|
11813
|
+
import {
|
|
11814
|
+
CORE_TIME_OPERATION_ID,
|
|
11815
|
+
CORE_TIME_ROUTE
|
|
11816
|
+
} from "@spfn/core/server";
|
|
11817
|
+
function importCoreTimeContract() {
|
|
11818
|
+
const { method, path, contract } = CORE_TIME_ROUTE;
|
|
11819
|
+
if (method !== "GET" || typeof path !== "string" || contract?.auth !== "none" || contract.requiresSession !== false || typeof contract.since !== "string") {
|
|
11820
|
+
throw new Error("core.time does not match the clientProofV1 synchronization prerequisite");
|
|
11821
|
+
}
|
|
11822
|
+
return {
|
|
11823
|
+
id: CORE_TIME_OPERATION_ID,
|
|
11824
|
+
method,
|
|
11825
|
+
path,
|
|
11826
|
+
authProfile: contract.auth,
|
|
11827
|
+
requiresSession: contract.requiresSession,
|
|
11828
|
+
sourceSince: contract.since
|
|
11829
|
+
};
|
|
11830
|
+
}
|
|
11831
|
+
var IMPORTED_CORE_TIME_CONTRACT = importCoreTimeContract();
|
|
11832
|
+
var CORE_PREREQUISITE_OPERATIONS = [
|
|
11833
|
+
{
|
|
11834
|
+
id: IMPORTED_CORE_TIME_CONTRACT.id,
|
|
11835
|
+
method: IMPORTED_CORE_TIME_CONTRACT.method,
|
|
11836
|
+
path: IMPORTED_CORE_TIME_CONTRACT.path,
|
|
11837
|
+
authProfile: IMPORTED_CORE_TIME_CONTRACT.authProfile,
|
|
11838
|
+
requiresSession: IMPORTED_CORE_TIME_CONTRACT.requiresSession,
|
|
11839
|
+
responseType: "ServerTimeResponse",
|
|
11840
|
+
summary: "Returns the server epoch used to timestamp clientProofV1 proofs.",
|
|
11841
|
+
since: "0.9.0"
|
|
11842
|
+
}
|
|
11843
|
+
];
|
|
11844
|
+
|
|
11808
11845
|
// src/server/client-proof/contract-bundle.ts
|
|
11809
11846
|
init_wire_headers();
|
|
11810
|
-
var CONTRACT_VERSION = "0.
|
|
11811
|
-
var CONTRACT_SUPPORTED_RANGE = ">=0.
|
|
11847
|
+
var CONTRACT_VERSION = "0.9.0";
|
|
11848
|
+
var CONTRACT_SUPPORTED_RANGE = ">=0.9.0 <0.10.0";
|
|
11812
11849
|
function required(name, type) {
|
|
11813
11850
|
return { name, type, optional: false };
|
|
11814
11851
|
}
|
|
11815
11852
|
function optional(name, type) {
|
|
11816
11853
|
return { name, type, optional: true };
|
|
11817
11854
|
}
|
|
11855
|
+
function coreTimeResponseDeclaration() {
|
|
11856
|
+
if (ServerTimeResponseSchema.type !== "object" || ServerTimeResponseSchema.additionalProperties !== false) {
|
|
11857
|
+
throw new Error("core.time response must remain a closed object");
|
|
11858
|
+
}
|
|
11859
|
+
const requiredFields = new Set(ServerTimeResponseSchema.required);
|
|
11860
|
+
const fields = Object.entries(ServerTimeResponseSchema.properties).map(([name, schema]) => {
|
|
11861
|
+
if (schema.type !== "integer") {
|
|
11862
|
+
throw new Error(`core.time response field ${name} is outside the mobile type grammar`);
|
|
11863
|
+
}
|
|
11864
|
+
return {
|
|
11865
|
+
name,
|
|
11866
|
+
type: "integer",
|
|
11867
|
+
optional: !requiredFields.has(name)
|
|
11868
|
+
};
|
|
11869
|
+
});
|
|
11870
|
+
return { name: "ServerTimeResponse", fields };
|
|
11871
|
+
}
|
|
11818
11872
|
var CONTRACT_TYPES = [
|
|
11873
|
+
coreTimeResponseDeclaration(),
|
|
11819
11874
|
{
|
|
11820
11875
|
name: "HandshakeRequest",
|
|
11821
11876
|
fields: [
|