@backstage/plugin-auth-node 0.6.14 → 0.7.0-next.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/CHANGELOG.md +44 -0
- package/dist/index.cjs.js +6 -6
- package/dist/index.d.ts +5 -5
- package/dist/sign-in/createSignInResolverFactory.cjs.js.map +1 -1
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# @backstage/plugin-auth-node
|
|
2
2
|
|
|
3
|
+
## 0.7.0-next.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- fa55078: **BREAKING**: Refactored `SignInResolverFactoryOptions` to use a schema-first generic pattern, following Zod's [recommended approach](https://zod.dev/library-authors?id=how-to-accept-user-defined-schemas#how-to-accept-user-defined-schemas) for writing generic functions. The type parameters changed from `<TAuthResult, TOptionsOutput, TOptionsInput>` to `<TAuthResult, TSchema extends ZodType>`.
|
|
8
|
+
|
|
9
|
+
This fixes "Type instantiation is excessively deep and possibly infinite" errors that occurred when the Zod version in a user's project did not align with the one in Backstage core.
|
|
10
|
+
|
|
11
|
+
If you use `createSignInResolverFactory` without explicit type parameters (the typical usage), no changes are needed:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
// This usage is unchanged
|
|
15
|
+
createSignInResolverFactory({
|
|
16
|
+
optionsSchema: z.object({ domain: z.string() }).optional(),
|
|
17
|
+
create(options = {}) {
|
|
18
|
+
/* ... */
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
If you reference `SignInResolverFactoryOptions` with explicit type parameters, update as follows:
|
|
24
|
+
|
|
25
|
+
```diff
|
|
26
|
+
- SignInResolverFactoryOptions<MyAuthResult, MyOutput, MyInput>
|
|
27
|
+
+ SignInResolverFactoryOptions<MyAuthResult, typeof mySchema>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- Updated dependencies
|
|
33
|
+
- @backstage/backend-plugin-api@1.9.0-next.1
|
|
34
|
+
|
|
35
|
+
## 0.6.15-next.0
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- Updated dependencies
|
|
40
|
+
- @backstage/backend-plugin-api@1.8.1-next.0
|
|
41
|
+
- @backstage/catalog-client@1.14.0
|
|
42
|
+
- @backstage/catalog-model@1.7.7
|
|
43
|
+
- @backstage/config@1.3.6
|
|
44
|
+
- @backstage/errors@1.2.7
|
|
45
|
+
- @backstage/types@1.2.2
|
|
46
|
+
|
|
3
47
|
## 0.6.14
|
|
4
48
|
|
|
5
49
|
### Patch Changes
|
package/dist/index.cjs.js
CHANGED
|
@@ -12,15 +12,15 @@ var PassportOAuthAuthenticatorHelper = require('./oauth/PassportOAuthAuthenticat
|
|
|
12
12
|
var OAuthEnvironmentHandler = require('./oauth/OAuthEnvironmentHandler.cjs.js');
|
|
13
13
|
var createOAuthProviderFactory = require('./oauth/createOAuthProviderFactory.cjs.js');
|
|
14
14
|
var state = require('./oauth/state.cjs.js');
|
|
15
|
-
var types
|
|
15
|
+
var types = require('./oauth/types.cjs.js');
|
|
16
16
|
var PassportHelpers = require('./passport/PassportHelpers.cjs.js');
|
|
17
|
-
var types$
|
|
17
|
+
var types$1 = require('./proxy/types.cjs.js');
|
|
18
18
|
var createProxyAuthProviderFactory = require('./proxy/createProxyAuthProviderFactory.cjs.js');
|
|
19
19
|
var createProxyRouteHandlers = require('./proxy/createProxyRouteHandlers.cjs.js');
|
|
20
20
|
var createSignInResolverFactory = require('./sign-in/createSignInResolverFactory.cjs.js');
|
|
21
21
|
var readDeclarativeSignInResolver = require('./sign-in/readDeclarativeSignInResolver.cjs.js');
|
|
22
22
|
var commonSignInResolvers = require('./sign-in/commonSignInResolvers.cjs.js');
|
|
23
|
-
var types = require('./types.cjs.js');
|
|
23
|
+
var types$2 = require('./types.cjs.js');
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
@@ -37,9 +37,9 @@ exports.OAuthEnvironmentHandler = OAuthEnvironmentHandler.OAuthEnvironmentHandle
|
|
|
37
37
|
exports.createOAuthProviderFactory = createOAuthProviderFactory.createOAuthProviderFactory;
|
|
38
38
|
exports.decodeOAuthState = state.decodeOAuthState;
|
|
39
39
|
exports.encodeOAuthState = state.encodeOAuthState;
|
|
40
|
-
exports.createOAuthAuthenticator = types
|
|
40
|
+
exports.createOAuthAuthenticator = types.createOAuthAuthenticator;
|
|
41
41
|
exports.PassportHelpers = PassportHelpers.PassportHelpers;
|
|
42
|
-
exports.createProxyAuthenticator = types$
|
|
42
|
+
exports.createProxyAuthenticator = types$1.createProxyAuthenticator;
|
|
43
43
|
exports.createProxyAuthProviderFactory = createProxyAuthProviderFactory.createProxyAuthProviderFactory;
|
|
44
44
|
exports.createProxyAuthRouteHandlers = createProxyRouteHandlers.createProxyAuthRouteHandlers;
|
|
45
45
|
exports.createSignInResolverFactory = createSignInResolverFactory.createSignInResolverFactory;
|
|
@@ -48,5 +48,5 @@ Object.defineProperty(exports, "commonSignInResolvers", {
|
|
|
48
48
|
enumerable: true,
|
|
49
49
|
get: function () { return commonSignInResolvers.commonSignInResolvers; }
|
|
50
50
|
});
|
|
51
|
-
exports.tokenTypes = types.tokenTypes;
|
|
51
|
+
exports.tokenTypes = types$2.tokenTypes;
|
|
52
52
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { Config } from '@backstage/config';
|
|
|
6
6
|
import { JsonValue, JsonObject } from '@backstage/types';
|
|
7
7
|
import express, { Request, Response } from 'express';
|
|
8
8
|
import { Profile, Strategy } from 'passport';
|
|
9
|
-
import {
|
|
9
|
+
import { ZodType, z } from 'zod/v3';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* A representation of a successful Backstage sign-in.
|
|
@@ -739,12 +739,12 @@ interface SignInResolverFactory<TAuthResult = any, TOptions = any> {
|
|
|
739
739
|
optionsJsonSchema?: JsonObject;
|
|
740
740
|
}
|
|
741
741
|
/** @public */
|
|
742
|
-
interface SignInResolverFactoryOptions<TAuthResult,
|
|
743
|
-
optionsSchema?:
|
|
744
|
-
create(options:
|
|
742
|
+
interface SignInResolverFactoryOptions<TAuthResult, TSchema extends ZodType = ZodType<unknown>> {
|
|
743
|
+
optionsSchema?: TSchema;
|
|
744
|
+
create(options: z.output<TSchema>): SignInResolver<TAuthResult>;
|
|
745
745
|
}
|
|
746
746
|
/** @public */
|
|
747
|
-
declare function createSignInResolverFactory<TAuthResult,
|
|
747
|
+
declare function createSignInResolverFactory<TAuthResult, TSchema extends ZodType = ZodType<unknown>>(options: SignInResolverFactoryOptions<TAuthResult, TSchema>): SignInResolverFactory<TAuthResult, z.input<TSchema>>;
|
|
748
748
|
|
|
749
749
|
/** @public */
|
|
750
750
|
declare function createOAuthProviderFactory<TProfile>(options: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createSignInResolverFactory.cjs.js","sources":["../../src/sign-in/createSignInResolverFactory.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {
|
|
1
|
+
{"version":3,"file":"createSignInResolverFactory.cjs.js","sources":["../../src/sign-in/createSignInResolverFactory.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { z, ZodType } from 'zod/v3';\nimport { SignInResolver } from '../types';\nimport zodToJsonSchema from 'zod-to-json-schema';\nimport { JsonObject } from '@backstage/types';\nimport { fromError } from 'zod-validation-error/v3';\nimport { InputError } from '@backstage/errors';\n\n/** @public */\nexport interface SignInResolverFactory<TAuthResult = any, TOptions = any> {\n (\n ...options: undefined extends TOptions\n ? [options?: TOptions]\n : [options: TOptions]\n ): SignInResolver<TAuthResult>;\n optionsJsonSchema?: JsonObject;\n}\n\n/** @public */\nexport interface SignInResolverFactoryOptions<\n TAuthResult,\n TSchema extends ZodType = ZodType<unknown>,\n> {\n optionsSchema?: TSchema;\n create(options: z.output<TSchema>): SignInResolver<TAuthResult>;\n}\n\n/** @public */\nexport function createSignInResolverFactory<\n TAuthResult,\n TSchema extends ZodType = ZodType<unknown>,\n>(\n options: SignInResolverFactoryOptions<TAuthResult, TSchema>,\n): SignInResolverFactory<TAuthResult, z.input<TSchema>> {\n const { optionsSchema } = options;\n if (!optionsSchema) {\n return (resolverOptions?: z.input<TSchema>) => {\n if (resolverOptions) {\n throw new InputError('sign-in resolver does not accept options');\n }\n return options.create(undefined);\n };\n }\n const factory = (\n ...[resolverOptions]: undefined extends z.input<TSchema>\n ? [options?: z.input<TSchema>]\n : [options: z.input<TSchema>]\n ) => {\n let parsedOptions;\n try {\n parsedOptions = optionsSchema.parse(resolverOptions);\n } catch (error) {\n throw new InputError(\n `Invalid sign-in resolver options, ${fromError(error)}`,\n );\n }\n return options.create(parsedOptions);\n };\n\n factory.optionsJsonSchema = zodToJsonSchema(optionsSchema) as JsonObject;\n return factory;\n}\n"],"names":["InputError","fromError","zodToJsonSchema"],"mappings":";;;;;;;;;;AA2CO,SAAS,4BAId,OAAA,EACsD;AACtD,EAAA,MAAM,EAAE,eAAc,GAAI,OAAA;AAC1B,EAAA,IAAI,CAAC,aAAA,EAAe;AAClB,IAAA,OAAO,CAAC,eAAA,KAAuC;AAC7C,MAAA,IAAI,eAAA,EAAiB;AACnB,QAAA,MAAM,IAAIA,kBAAW,0CAA0C,CAAA;AAAA,MACjE;AACA,MAAA,OAAO,OAAA,CAAQ,OAAO,MAAS,CAAA;AAAA,IACjC,CAAA;AAAA,EACF;AACA,EAAA,MAAM,OAAA,GAAU,CAAA,GACX,CAAC,eAAe,CAAA,KAGhB;AACH,IAAA,IAAI,aAAA;AACJ,IAAA,IAAI;AACF,MAAA,aAAA,GAAgB,aAAA,CAAc,MAAM,eAAe,CAAA;AAAA,IACrD,SAAS,KAAA,EAAO;AACd,MAAA,MAAM,IAAIA,iBAAA;AAAA,QACR,CAAA,kCAAA,EAAqCC,YAAA,CAAU,KAAK,CAAC,CAAA;AAAA,OACvD;AAAA,IACF;AACA,IAAA,OAAO,OAAA,CAAQ,OAAO,aAAa,CAAA;AAAA,EACrC,CAAA;AAEA,EAAA,OAAA,CAAQ,iBAAA,GAAoBC,iCAAgB,aAAa,CAAA;AACzD,EAAA,OAAO,OAAA;AACT;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-auth-node",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-next.1",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "node-library",
|
|
6
6
|
"pluginId": "auth",
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"test": "backstage-cli package test"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@backstage/backend-plugin-api": "
|
|
42
|
-
"@backstage/catalog-client": "
|
|
43
|
-
"@backstage/catalog-model": "
|
|
44
|
-
"@backstage/config": "
|
|
45
|
-
"@backstage/errors": "
|
|
46
|
-
"@backstage/types": "
|
|
41
|
+
"@backstage/backend-plugin-api": "1.9.0-next.1",
|
|
42
|
+
"@backstage/catalog-client": "1.14.0",
|
|
43
|
+
"@backstage/catalog-model": "1.7.7",
|
|
44
|
+
"@backstage/config": "1.3.6",
|
|
45
|
+
"@backstage/errors": "1.2.7",
|
|
46
|
+
"@backstage/types": "1.2.2",
|
|
47
47
|
"@types/express": "^4.17.6",
|
|
48
48
|
"@types/passport": "^1.0.3",
|
|
49
49
|
"express": "^4.22.0",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"zod-validation-error": "^4.0.2"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@backstage/backend-defaults": "
|
|
59
|
-
"@backstage/backend-test-utils": "
|
|
60
|
-
"@backstage/cli": "
|
|
58
|
+
"@backstage/backend-defaults": "0.16.1-next.1",
|
|
59
|
+
"@backstage/backend-test-utils": "1.11.2-next.1",
|
|
60
|
+
"@backstage/cli": "0.36.1-next.1",
|
|
61
61
|
"cookie-parser": "^1.4.6",
|
|
62
62
|
"express-promise-router": "^4.1.1",
|
|
63
63
|
"lodash": "^4.17.21",
|