@backstage/plugin-auth-node 0.1.1 → 0.1.2

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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @backstage/plugin-auth-node
2
2
 
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix for the previous release with missing type declarations.
8
+ - Updated dependencies
9
+ - @backstage/backend-common@0.10.9
10
+ - @backstage/catalog-model@0.10.1
11
+ - @backstage/config@0.1.15
12
+ - @backstage/errors@0.2.2
13
+
3
14
  ## 0.1.1
4
15
 
5
16
  ### Patch Changes
@@ -0,0 +1,124 @@
1
+ import { PluginEndpointDiscovery } from '@backstage/backend-common';
2
+ import { Entity } from '@backstage/catalog-model';
3
+
4
+ /**
5
+ * Parses the given authorization header and returns the bearer token, or
6
+ * undefined if no bearer token is given.
7
+ *
8
+ * @remarks
9
+ *
10
+ * This function is explicitly built to tolerate bad inputs safely, so you may
11
+ * call it directly with e.g. the output of `req.header('authorization')`
12
+ * without first checking that it exists.
13
+ *
14
+ * @public
15
+ */
16
+ declare function getBearerTokenFromAuthorizationHeader(authorizationHeader: unknown): string | undefined;
17
+
18
+ /**
19
+ * A representation of a successful Backstage sign-in.
20
+ *
21
+ * Compared to the {@link BackstageIdentityResponse} this type omits
22
+ * the decoded identity information embedded in the token.
23
+ *
24
+ * @public
25
+ */
26
+ interface BackstageSignInResult {
27
+ /**
28
+ * An opaque ID that uniquely identifies the user within Backstage.
29
+ *
30
+ * This is typically the same as the user entity `metadata.name`.
31
+ *
32
+ * @deprecated Use the `identity` field instead
33
+ */
34
+ id: string;
35
+ /**
36
+ * The entity that the user is represented by within Backstage.
37
+ *
38
+ * This entity may or may not exist within the Catalog, and it can be used
39
+ * to read and store additional metadata about the user.
40
+ *
41
+ * @deprecated Use the `identity` field instead.
42
+ */
43
+ entity?: Entity;
44
+ /**
45
+ * The token used to authenticate the user within Backstage.
46
+ */
47
+ token: string;
48
+ }
49
+ /**
50
+ * Response object containing the {@link BackstageUserIdentity} and the token
51
+ * from the authentication provider.
52
+ *
53
+ * @public
54
+ */
55
+ interface BackstageIdentityResponse extends BackstageSignInResult {
56
+ /**
57
+ * A plaintext description of the identity that is encapsulated within the token.
58
+ */
59
+ identity: BackstageUserIdentity;
60
+ }
61
+ /**
62
+ * User identity information within Backstage.
63
+ *
64
+ * @public
65
+ */
66
+ declare type BackstageUserIdentity = {
67
+ /**
68
+ * The type of identity that this structure represents. In the frontend app
69
+ * this will currently always be 'user'.
70
+ */
71
+ type: 'user';
72
+ /**
73
+ * The entityRef of the user in the catalog.
74
+ * For example User:default/sandra
75
+ */
76
+ userEntityRef: string;
77
+ /**
78
+ * The user and group entities that the user claims ownership through
79
+ */
80
+ ownershipEntityRefs: string[];
81
+ };
82
+
83
+ /**
84
+ * An identity client to interact with auth-backend and authenticate Backstage
85
+ * tokens
86
+ *
87
+ * @experimental This is not a stable API yet
88
+ * @public
89
+ */
90
+ declare class IdentityClient {
91
+ private readonly discovery;
92
+ private readonly issuer;
93
+ private keyStore;
94
+ private keyStoreUpdated;
95
+ /**
96
+ * Create a new {@link IdentityClient} instance.
97
+ */
98
+ static create(options: {
99
+ discovery: PluginEndpointDiscovery;
100
+ issuer: string;
101
+ }): IdentityClient;
102
+ private constructor();
103
+ /**
104
+ * Verifies the given backstage identity token
105
+ * Returns a BackstageIdentity (user) matching the token.
106
+ * The method throws an error if verification fails.
107
+ */
108
+ authenticate(token: string | undefined): Promise<BackstageIdentityResponse>;
109
+ /**
110
+ * Returns the public signing key matching the given jwt token,
111
+ * or null if no matching key was found
112
+ */
113
+ private getKey;
114
+ /**
115
+ * Lists public part of keys used to sign Backstage Identity tokens
116
+ */
117
+ private listPublicKeys;
118
+ /**
119
+ * Fetches public keys and caches them locally
120
+ */
121
+ private refreshKeyStore;
122
+ }
123
+
124
+ export { BackstageIdentityResponse, BackstageSignInResult, BackstageUserIdentity, IdentityClient, getBearerTokenFromAuthorizationHeader };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-auth-node",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "main": "dist/index.cjs.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "Apache-2.0",
@@ -23,10 +23,10 @@
23
23
  "start": "backstage-cli package start"
24
24
  },
25
25
  "dependencies": {
26
- "@backstage/backend-common": "^0.10.8",
27
- "@backstage/catalog-model": "^0.10.0",
28
- "@backstage/config": "^0.1.14",
29
- "@backstage/errors": "^0.2.1",
26
+ "@backstage/backend-common": "^0.10.9",
27
+ "@backstage/catalog-model": "^0.10.1",
28
+ "@backstage/config": "^0.1.15",
29
+ "@backstage/errors": "^0.2.2",
30
30
  "jose": "^1.27.1",
31
31
  "node-fetch": "^2.6.7",
32
32
  "winston": "^3.2.1"
@@ -39,5 +39,5 @@
39
39
  "files": [
40
40
  "dist"
41
41
  ],
42
- "gitHead": "4805c3d13ce9bfc369e53c271b1b95e722b3b4dc"
42
+ "gitHead": "e244b348c473700e7d5e5fbcef38bd9f9fd1d0ba"
43
43
  }