@teamkeel/testing-runtime 0.466.0 → 0.467.1
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/FlowExecutor.mjs +30 -1
- package/src/index.d.ts +3 -0
package/package.json
CHANGED
package/src/FlowExecutor.mjs
CHANGED
|
@@ -66,6 +66,35 @@ export class FlowExecutor {
|
|
|
66
66
|
return headers;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
// signedLinkHeaders builds the headers for a signed-link (share) request. Matching the production
|
|
70
|
+
// SDK, a bare call (no identity/authToken) defaults to a first-party `flows` service token that
|
|
71
|
+
// the runtime trusts, so minting/listing/revoking passes the flow's share permission without a
|
|
72
|
+
// user. An explicit withIdentity()/withAuthToken() opts into user-scoped auth, where the flow's
|
|
73
|
+
// @permission(actions: [share]) rule is enforced.
|
|
74
|
+
signedLinkHeaders() {
|
|
75
|
+
if (this._identity === null && this._authToken === null) {
|
|
76
|
+
const base64pk = process.env.KEEL_PRIVATE_KEY;
|
|
77
|
+
if (base64pk) {
|
|
78
|
+
const privateKey = Buffer.from(base64pk, "base64").toString("utf8");
|
|
79
|
+
return {
|
|
80
|
+
"Content-Type": "application/json",
|
|
81
|
+
Authorization:
|
|
82
|
+
"Bearer " +
|
|
83
|
+
jwt.sign({}, privateKey, {
|
|
84
|
+
algorithm: "RS256",
|
|
85
|
+
expiresIn: 60 * 60 * 24,
|
|
86
|
+
audience: "flows",
|
|
87
|
+
issuer: "https://keel.so",
|
|
88
|
+
}),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
// No signing key available: fall through to an unauthenticated request.
|
|
92
|
+
return { "Content-Type": "application/json" };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return this.headers();
|
|
96
|
+
}
|
|
97
|
+
|
|
69
98
|
async start(inputs) {
|
|
70
99
|
return parseInputs(inputs).then((parsed) => {
|
|
71
100
|
// Use the HTTP JSON API as that returns more friendly errors than
|
|
@@ -89,7 +118,7 @@ export class FlowExecutor {
|
|
|
89
118
|
// generated testing types only expose `signedLinks` on flows declared with @externalAccess.
|
|
90
119
|
get signedLinks() {
|
|
91
120
|
const flowUrl = this._flowUrl;
|
|
92
|
-
const headers = () => this.
|
|
121
|
+
const headers = () => this.signedLinkHeaders();
|
|
93
122
|
|
|
94
123
|
return {
|
|
95
124
|
async create(options = {}) {
|
package/src/index.d.ts
CHANGED
|
@@ -163,6 +163,9 @@ export declare class FlowExecutor<Input = {}> {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
// The signed-link management namespace exposed on a shareable flow's executor as `signedLinks`.
|
|
166
|
+
// By default every operation authenticates with a first-party `flows` service token the runtime
|
|
167
|
+
// trusts, so links can be managed without satisfying the flow's `share` permission. Chaining
|
|
168
|
+
// withIdentity()/withAuthToken() switches to user-scoped auth, where @permission is enforced.
|
|
166
169
|
export interface SignedLinksAPI<Input = {}> {
|
|
167
170
|
// Mint a signed link that lets an external, unauthenticated actor execute this flow.
|
|
168
171
|
create(options?: {
|