@apifuse/provider-sdk 2.2.0-beta.57 → 2.2.0-beta.58
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/CHANGELOG.md +4 -0
- package/README.md +4 -3
- package/SUBMISSION.md +2 -1
- package/dist/cli/templates/provider/README.md.tpl +4 -2
- package/dist/define.d.ts +1 -0
- package/dist/engine.js +2 -0
- package/dist/lint.js +1 -1
- package/dist/types.d.ts +9 -2
- package/package.json +1 -1
- package/src/cli/templates/provider/README.md.tpl +4 -2
- package/src/define.ts +1 -0
- package/src/engine.ts +1 -0
- package/src/lint.ts +1 -1
- package/src/types.ts +6 -3
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -115,9 +115,10 @@ the bad request path; provider/runtime failures include `code`, `message`, and
|
|
|
115
115
|
- **`invalid_request` on `/v1/{operation}`**: confirm the request body includes
|
|
116
116
|
`requestId` and `input`. Omit `connection` for public/no-auth operations;
|
|
117
117
|
never send `connection: null`.
|
|
118
|
-
- **Credential-backed operations**: declare `credential.keys`,
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
- **Credential-backed operations**: declare `credential.keys`, except when
|
|
119
|
+
`auth.mode` is `platform-managed`; that auth declaration implies an unfiltered
|
|
120
|
+
credential capability. Pass local-only values through `connection.secrets` and
|
|
121
|
+
read them with `ctx.credential.get("key")` or `ctx.credential.getAccessToken()`.
|
|
121
122
|
- **Provider env secrets**: declare `secrets[]`, set values in your shell or
|
|
122
123
|
`.env`, and read only those names through `ctx.env.get("NAME")`. The SDK
|
|
123
124
|
enforces presence of `required: true` declarations before handlers and auth
|
package/SUBMISSION.md
CHANGED
|
@@ -46,7 +46,8 @@ Fix all blockers before submitting:
|
|
|
46
46
|
- Missing fixture request or response.
|
|
47
47
|
- Fixture data does not parse against schemas.
|
|
48
48
|
- Missing `healthCheck` or `healthCheckUnsupported` on any Operation.
|
|
49
|
-
-
|
|
49
|
+
- User-managed credential auth mode without declared credential keys
|
|
50
|
+
(`platform-managed` auth instead implies the credential capability and forbids keys).
|
|
50
51
|
- High-confidence secret or token material in source, README, package metadata, or fixtures.
|
|
51
52
|
- SDK-native source blockers: prefixed Provider ids, `vendor/` SDK shims or imports, raw `.describe()` prose instead of `describeKey`, raw global `fetch()` calls, and excessive `as Type` assertions.
|
|
52
53
|
|
|
@@ -109,8 +109,10 @@ Structured errors return an `error` object with `code`, `message`,
|
|
|
109
109
|
|
|
110
110
|
- `invalid_request`: include `requestId` and `input`; omit `connection` for
|
|
111
111
|
public/no-auth operations and never send `connection: null`.
|
|
112
|
-
- Credentials: declare `credential.keys
|
|
113
|
-
|
|
112
|
+
- Credentials: declare `credential.keys` unless `auth.mode` is `platform-managed`;
|
|
113
|
+
that mode implies an unfiltered credential capability and forbids key declarations.
|
|
114
|
+
Pass local-only values through `connection.secrets` and read them with
|
|
115
|
+
`ctx.credential`.
|
|
114
116
|
- Auth flow: call `/auth/start`, then `/auth/continue` with the same `flowId`;
|
|
115
117
|
carry returned `contextPatch` values into the next request's `context`.
|
|
116
118
|
- Stealth/browser runtime: keep access-sensitive operations on `ctx.stealth.fetch()` with
|
package/dist/define.d.ts
CHANGED
|
@@ -78,6 +78,7 @@ export interface ProviderDeclaration {
|
|
|
78
78
|
secrets?: ProviderSecretDeclaration[];
|
|
79
79
|
/** Declares the environment capability binding. A bare object states use without configuration. */
|
|
80
80
|
env?: Record<string, never> | true;
|
|
81
|
+
/** Declares credential keys; platform-managed auth declares this capability without key filtering. */
|
|
81
82
|
credential?: CredentialDeclaration;
|
|
82
83
|
/** Declares provider context metadata; this does not add a `ctx.context` member. */
|
|
83
84
|
context?: ContextDeclaration;
|
package/dist/engine.js
CHANGED
|
@@ -75,6 +75,8 @@ export const PROVIDER_CAPABILITY_KEYS = [
|
|
|
75
75
|
];
|
|
76
76
|
const CAPABILITY_KEY_SET = new Set(PROVIDER_CAPABILITY_KEYS);
|
|
77
77
|
function declaresCapability(provider, capability) {
|
|
78
|
+
if (capability === "credential" && provider.auth?.mode === "platform-managed")
|
|
79
|
+
return true;
|
|
78
80
|
return Object.hasOwn(provider, capability) && provider[capability] !== undefined;
|
|
79
81
|
}
|
|
80
82
|
function attachmentError(provider, capability) {
|
package/dist/lint.js
CHANGED
|
@@ -246,7 +246,7 @@ function lintAuthModel(provider) {
|
|
|
246
246
|
rule: "platform-managed-no-credential-keys",
|
|
247
247
|
level: "error",
|
|
248
248
|
field: "credential.keys",
|
|
249
|
-
message: `${providerLabel} must not declare credential.keys
|
|
249
|
+
message: `${providerLabel} must not declare credential.keys because platform-managed auth mode already implies the unfiltered credential capability.`,
|
|
250
250
|
});
|
|
251
251
|
}
|
|
252
252
|
const authFlowSource = getAuthFlowSource(provider);
|
package/dist/types.d.ts
CHANGED
|
@@ -1860,8 +1860,9 @@ export interface ProviderRuntimeState {
|
|
|
1860
1860
|
/**
|
|
1861
1861
|
* The operation context exposed for one provider declaration. Capability
|
|
1862
1862
|
* bindings are present only when their corresponding declaration is present;
|
|
1863
|
-
*
|
|
1864
|
-
*
|
|
1863
|
+
* platform-managed auth itself declares the credential binding. Trace and
|
|
1864
|
+
* request remain ambient runtime bindings. Omitting the type parameter
|
|
1865
|
+
* preserves the legacy full context shape for existing annotations.
|
|
1865
1866
|
*/
|
|
1866
1867
|
export type ProviderContext<TConfig = Record<string, unknown>> = {
|
|
1867
1868
|
request?: ProviderRequestContext;
|
|
@@ -1870,6 +1871,12 @@ export type ProviderContext<TConfig = Record<string, unknown>> = {
|
|
|
1870
1871
|
env: EnvContext;
|
|
1871
1872
|
} : Record<never, never>) & ("credential" extends keyof TConfig ? {
|
|
1872
1873
|
credential: CredentialContext;
|
|
1874
|
+
} : TConfig extends {
|
|
1875
|
+
auth: {
|
|
1876
|
+
mode: "platform-managed";
|
|
1877
|
+
};
|
|
1878
|
+
} ? {
|
|
1879
|
+
credential: CredentialContext;
|
|
1873
1880
|
} : Record<never, never>) & ("http" extends keyof TConfig ? {
|
|
1874
1881
|
http: HttpClient;
|
|
1875
1882
|
} : Record<never, never>) & ("files" extends keyof TConfig ? string extends keyof TConfig ? {
|
package/package.json
CHANGED
|
@@ -109,8 +109,10 @@ Structured errors return an `error` object with `code`, `message`,
|
|
|
109
109
|
|
|
110
110
|
- `invalid_request`: include `requestId` and `input`; omit `connection` for
|
|
111
111
|
public/no-auth operations and never send `connection: null`.
|
|
112
|
-
- Credentials: declare `credential.keys
|
|
113
|
-
|
|
112
|
+
- Credentials: declare `credential.keys` unless `auth.mode` is `platform-managed`;
|
|
113
|
+
that mode implies an unfiltered credential capability and forbids key declarations.
|
|
114
|
+
Pass local-only values through `connection.secrets` and read them with
|
|
115
|
+
`ctx.credential`.
|
|
114
116
|
- Auth flow: call `/auth/start`, then `/auth/continue` with the same `flowId`;
|
|
115
117
|
carry returned `contextPatch` values into the next request's `context`.
|
|
116
118
|
- Stealth/browser runtime: keep access-sensitive operations on `ctx.stealth.fetch()` with
|
package/src/define.ts
CHANGED
|
@@ -600,6 +600,7 @@ export interface ProviderDeclaration {
|
|
|
600
600
|
secrets?: ProviderSecretDeclaration[];
|
|
601
601
|
/** Declares the environment capability binding. A bare object states use without configuration. */
|
|
602
602
|
env?: Record<string, never> | true;
|
|
603
|
+
/** Declares credential keys; platform-managed auth declares this capability without key filtering. */
|
|
603
604
|
credential?: CredentialDeclaration;
|
|
604
605
|
/** Declares provider context metadata; this does not add a `ctx.context` member. */
|
|
605
606
|
context?: ContextDeclaration;
|
package/src/engine.ts
CHANGED
|
@@ -199,6 +199,7 @@ function declaresCapability(
|
|
|
199
199
|
provider: ProviderDefinition,
|
|
200
200
|
capability: ProviderCapabilityKey,
|
|
201
201
|
): boolean {
|
|
202
|
+
if (capability === "credential" && provider.auth?.mode === "platform-managed") return true;
|
|
202
203
|
return Object.hasOwn(provider, capability) && provider[capability] !== undefined;
|
|
203
204
|
}
|
|
204
205
|
|
package/src/lint.ts
CHANGED
|
@@ -398,7 +398,7 @@ function lintAuthModel(provider: {
|
|
|
398
398
|
rule: "platform-managed-no-credential-keys",
|
|
399
399
|
level: "error",
|
|
400
400
|
field: "credential.keys",
|
|
401
|
-
message: `${providerLabel} must not declare credential.keys
|
|
401
|
+
message: `${providerLabel} must not declare credential.keys because platform-managed auth mode already implies the unfiltered credential capability.`,
|
|
402
402
|
});
|
|
403
403
|
}
|
|
404
404
|
|
package/src/types.ts
CHANGED
|
@@ -2266,8 +2266,9 @@ export interface ProviderRuntimeState {
|
|
|
2266
2266
|
/**
|
|
2267
2267
|
* The operation context exposed for one provider declaration. Capability
|
|
2268
2268
|
* bindings are present only when their corresponding declaration is present;
|
|
2269
|
-
*
|
|
2270
|
-
*
|
|
2269
|
+
* platform-managed auth itself declares the credential binding. Trace and
|
|
2270
|
+
* request remain ambient runtime bindings. Omitting the type parameter
|
|
2271
|
+
* preserves the legacy full context shape for existing annotations.
|
|
2271
2272
|
*/
|
|
2272
2273
|
export type ProviderContext<TConfig = Record<string, unknown>> = {
|
|
2273
2274
|
request?: ProviderRequestContext;
|
|
@@ -2276,7 +2277,9 @@ export type ProviderContext<TConfig = Record<string, unknown>> = {
|
|
|
2276
2277
|
& ("env" extends keyof TConfig ? { env: EnvContext } : Record<never, never>)
|
|
2277
2278
|
& ("credential" extends keyof TConfig
|
|
2278
2279
|
? { credential: CredentialContext }
|
|
2279
|
-
:
|
|
2280
|
+
: TConfig extends { auth: { mode: "platform-managed" } }
|
|
2281
|
+
? { credential: CredentialContext }
|
|
2282
|
+
: Record<never, never>)
|
|
2280
2283
|
& ("http" extends keyof TConfig ? { http: HttpClient } : Record<never, never>)
|
|
2281
2284
|
& ("files" extends keyof TConfig
|
|
2282
2285
|
? string extends keyof TConfig
|