@spacelr/sdk 0.1.9 → 0.1.10
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/index.d.mts +19 -8
- package/dist/index.d.ts +19 -8
- package/dist/index.js +15 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1741,24 +1741,31 @@ var FunctionsModule = class {
|
|
|
1741
1741
|
}
|
|
1742
1742
|
/**
|
|
1743
1743
|
* Invoke a function.
|
|
1744
|
-
* Calls POST
|
|
1744
|
+
* Calls POST `/functions/:projectId/:functionId/invoke`, resolved against
|
|
1745
|
+
* `config.apiUrl` (which already carries the `/api/v1` prefix).
|
|
1745
1746
|
*
|
|
1746
|
-
*
|
|
1747
|
-
*
|
|
1748
|
-
*
|
|
1749
|
-
*
|
|
1747
|
+
* Auth defaults, based on `invokeMode` semantics:
|
|
1748
|
+
* - webhook: pass `secret` → Authorization is NOT attached
|
|
1749
|
+
* - authenticated: pass nothing → Authorization IS attached (from token manager)
|
|
1750
|
+
* - public: pass nothing → Authorization is attached if logged in, else omitted
|
|
1751
|
+
* - hybrid: pass both `secret` and `authenticated: true`
|
|
1752
|
+
*
|
|
1753
|
+
* To force a specific behaviour, set `authenticated` explicitly — it wins
|
|
1754
|
+
* over the `secret`-based default.
|
|
1750
1755
|
*/
|
|
1751
1756
|
async invoke(projectId, functionId, options = {}) {
|
|
1757
|
+
const hasSecret = (options.secret?.length ?? 0) > 0;
|
|
1752
1758
|
const headers = {};
|
|
1753
|
-
if (
|
|
1759
|
+
if (hasSecret) {
|
|
1754
1760
|
headers["X-Webhook-Secret"] = options.secret;
|
|
1755
1761
|
}
|
|
1762
|
+
const authenticated = options.authenticated ?? !hasSecret;
|
|
1756
1763
|
return this.http.request({
|
|
1757
1764
|
method: "POST",
|
|
1758
|
-
path: `/
|
|
1765
|
+
path: `/functions/${encodeURIComponent(projectId)}/${encodeURIComponent(functionId)}/invoke`,
|
|
1759
1766
|
headers,
|
|
1760
1767
|
body: options.payload ?? {},
|
|
1761
|
-
authenticated
|
|
1768
|
+
authenticated
|
|
1762
1769
|
});
|
|
1763
1770
|
}
|
|
1764
1771
|
};
|