effect-inngest 0.3.0-beta.2 → 0.3.0-beta.3
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/Group.d.ts
CHANGED
|
@@ -127,7 +127,7 @@ declare const make: <Fns extends ReadonlyArray<InngestFunction.Any>>(...fns: Fns
|
|
|
127
127
|
* )
|
|
128
128
|
* ```
|
|
129
129
|
*/
|
|
130
|
-
declare const toHttpApp: (group: InngestGroup.Any) => Effect.Effect<_$effect_unstable_http_HttpServerResponse0.HttpServerResponse, never, InngestClient | _$effect_unstable_http_HttpServerRequest0.HttpServerRequest
|
|
130
|
+
declare const toHttpApp: (group: InngestGroup.Any) => Effect.Effect<_$effect_unstable_http_HttpServerResponse0.HttpServerResponse, never, InngestClient | HttpClient.HttpClient | _$effect_unstable_http_HttpServerRequest0.HttpServerRequest>;
|
|
131
131
|
/**
|
|
132
132
|
* Create a standalone web handler from an InngestGroup.
|
|
133
133
|
*
|
package/dist/HttpApi.d.ts
CHANGED
|
@@ -49,13 +49,13 @@ declare const InngestApiGroup_base: HttpApiGroup.HttpApiGroup<"inngest", HttpApi
|
|
|
49
49
|
readonly authentication_succeeded: Schema.optional<Schema.Union<readonly [Schema.Literal<false>, Schema.Null]>>;
|
|
50
50
|
readonly capabilities: Schema.optional<Schema.$Record<Schema.String, Schema.String>>;
|
|
51
51
|
readonly functions: Schema.optionalKey<Schema.$Array<Schema.Unknown>>;
|
|
52
|
-
}>]>>, HttpApiEndpoint.Json<typeof
|
|
52
|
+
}>]>>, HttpApiEndpoint.Json<typeof FunctionNotFoundError | typeof InvalidRequestError | typeof SignatureError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"register", "PUT", "/", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Struct<{
|
|
53
53
|
readonly message: Schema.String;
|
|
54
54
|
readonly modified: Schema.Boolean;
|
|
55
|
-
}>>, HttpApiEndpoint.Json<typeof
|
|
55
|
+
}>>, HttpApiEndpoint.Json<typeof FunctionNotFoundError | typeof InvalidRequestError | typeof SignatureError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"execute", "POST", "/", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<Schema.Struct<{
|
|
56
56
|
readonly fnId: Schema.String;
|
|
57
57
|
readonly stepId: Schema.optional<Schema.String>;
|
|
58
|
-
}>>, HttpApiEndpoint.Json<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Unknown>, HttpApiEndpoint.Json<typeof
|
|
58
|
+
}>>, HttpApiEndpoint.Json<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<Schema.Unknown>, HttpApiEndpoint.Json<typeof FunctionNotFoundError | typeof InvalidRequestError | typeof SignatureError>, never, never>, false>;
|
|
59
59
|
/**
|
|
60
60
|
* @since 0.1.0
|
|
61
61
|
* @category api
|
|
@@ -70,13 +70,13 @@ const SignatureParams = Schema.Struct({
|
|
|
70
70
|
});
|
|
71
71
|
const hashSigningKey = (signingKey) => Encoding.encodeHex(NodeCrypto.createHash("sha256").update(signingKey.replace(/^signkey-\w+-/, "")).digest());
|
|
72
72
|
var Signature = class extends Context.Service()("effect-inngest/Signature", { make: (config) => Effect.gen(function* () {
|
|
73
|
-
const signingKey = config.signingKey.pipe(Option.flatMap(PreparedSigningKey.decode));
|
|
74
|
-
const fallbackSigningKey = config.signingKeyFallback.pipe(Option.flatMap(PreparedSigningKey.decode));
|
|
75
|
-
if (Option.isSome(config.signingKey) && Option.isNone(signingKey)) return yield* SignatureError.make({
|
|
73
|
+
const signingKey = config.verification === "disabled" ? Option.none() : config.signingKey.pipe(Option.flatMap(PreparedSigningKey.decode));
|
|
74
|
+
const fallbackSigningKey = config.verification === "disabled" ? Option.none() : config.signingKeyFallback.pipe(Option.flatMap(PreparedSigningKey.decode));
|
|
75
|
+
if (config.verification === "required" && Option.isSome(config.signingKey) && Option.isNone(signingKey)) return yield* SignatureError.make({
|
|
76
76
|
reason: "invalid_format",
|
|
77
77
|
message: "Invalid signing key"
|
|
78
78
|
});
|
|
79
|
-
if (Option.isSome(config.signingKeyFallback) && Option.isNone(fallbackSigningKey)) return yield* SignatureError.make({
|
|
79
|
+
if (config.verification === "required" && Option.isSome(config.signingKeyFallback) && Option.isNone(fallbackSigningKey)) return yield* SignatureError.make({
|
|
80
80
|
reason: "invalid_format",
|
|
81
81
|
message: "Invalid signing key"
|
|
82
82
|
});
|
|
@@ -96,12 +96,15 @@ var Signature = class extends Context.Service()("effect-inngest/Signature", { ma
|
|
|
96
96
|
});
|
|
97
97
|
}),
|
|
98
98
|
sign: Effect.fn("effect-inngest/Signature/sign")(function* (body) {
|
|
99
|
-
const key = yield* Option.match(signingKey, {
|
|
99
|
+
const key = yield* Option.match(config.signingKey, {
|
|
100
100
|
onNone: () => SignatureError.make({
|
|
101
101
|
reason: "missing_signing_key",
|
|
102
102
|
message: "No signing key configured for signing"
|
|
103
103
|
}),
|
|
104
|
-
onSome: Effect.
|
|
104
|
+
onSome: (key) => Effect.fromOption(PreparedSigningKey.decode(key)).pipe(Effect.mapError(() => SignatureError.make({
|
|
105
|
+
reason: "invalid_format",
|
|
106
|
+
message: "Invalid signing key"
|
|
107
|
+
})))
|
|
105
108
|
});
|
|
106
109
|
const now = yield* DateTime.now;
|
|
107
110
|
const timestampSeconds = Math.floor(now.epochMilliseconds / 1e3);
|
package/package.json
CHANGED
|
@@ -100,13 +100,23 @@ export const hashSigningKey = (signingKey: string): string =>
|
|
|
100
100
|
export class Signature extends Context.Service<Signature, SignatureService>()("effect-inngest/Signature", {
|
|
101
101
|
make: (config: SignatureConfig) =>
|
|
102
102
|
Effect.gen(function* () {
|
|
103
|
-
const signingKey =
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
const signingKey =
|
|
104
|
+
config.verification === "disabled"
|
|
105
|
+
? Option.none<PreparedSigningKey>()
|
|
106
|
+
: config.signingKey.pipe(Option.flatMap(PreparedSigningKey.decode));
|
|
107
|
+
const fallbackSigningKey =
|
|
108
|
+
config.verification === "disabled"
|
|
109
|
+
? Option.none<PreparedSigningKey>()
|
|
110
|
+
: config.signingKeyFallback.pipe(Option.flatMap(PreparedSigningKey.decode));
|
|
111
|
+
|
|
112
|
+
if (config.verification === "required" && Option.isSome(config.signingKey) && Option.isNone(signingKey)) {
|
|
107
113
|
return yield* SignatureError.make({ reason: "invalid_format", message: "Invalid signing key" });
|
|
108
114
|
}
|
|
109
|
-
if (
|
|
115
|
+
if (
|
|
116
|
+
config.verification === "required" &&
|
|
117
|
+
Option.isSome(config.signingKeyFallback) &&
|
|
118
|
+
Option.isNone(fallbackSigningKey)
|
|
119
|
+
) {
|
|
110
120
|
return yield* SignatureError.make({ reason: "invalid_format", message: "Invalid signing key" });
|
|
111
121
|
}
|
|
112
122
|
|
|
@@ -134,13 +144,16 @@ export class Signature extends Context.Service<Signature, SignatureService>()("e
|
|
|
134
144
|
});
|
|
135
145
|
|
|
136
146
|
const sign = Effect.fn("effect-inngest/Signature/sign")(function* (body: Uint8Array) {
|
|
137
|
-
const key = yield* Option.match(signingKey, {
|
|
147
|
+
const key = yield* Option.match(config.signingKey, {
|
|
138
148
|
onNone: () =>
|
|
139
149
|
SignatureError.make({
|
|
140
150
|
reason: "missing_signing_key",
|
|
141
151
|
message: "No signing key configured for signing",
|
|
142
152
|
}),
|
|
143
|
-
onSome:
|
|
153
|
+
onSome: (key) =>
|
|
154
|
+
Effect.fromOption(PreparedSigningKey.decode(key)).pipe(
|
|
155
|
+
Effect.mapError(() => SignatureError.make({ reason: "invalid_format", message: "Invalid signing key" })),
|
|
156
|
+
),
|
|
144
157
|
});
|
|
145
158
|
|
|
146
159
|
const now = yield* DateTime.now;
|