@cosmoops/connect-sdk 0.1.0 → 0.2.0
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/README.md +9 -16
- package/dist/cjs/cli/init.js +5 -11
- package/dist/cjs/client/provider.js +1 -2
- package/dist/cjs/next/index.js +7 -51
- package/dist/esm/cli/init.js +5 -11
- package/dist/esm/client/provider.js +1 -2
- package/dist/esm/next/index.js +7 -50
- package/dist/types/client/provider.d.ts +11 -5
- package/dist/types/next/index.d.ts +0 -34
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -211,25 +211,15 @@ cookie, `/session`, `/entitlements`, `/plans`, `/addons`, `/apps`, `/sessions`,
|
|
|
211
211
|
| --- | --- | --- |
|
|
212
212
|
| `CONNECT_API_KEY` | yes | server-side credential |
|
|
213
213
|
| `CONNECT_CLIENT_ID` | yes | OAuth client id |
|
|
214
|
-
| `NEXT_PUBLIC_CONNECT_CLIENT_ID` | yes | same value, for `<ConnectProvider>` |
|
|
215
214
|
| `CONNECT_APP_URL` | no | non-production Connect instance |
|
|
216
215
|
| `CONNECT_SESSION_COOKIE` | no | session cookie name |
|
|
217
216
|
|
|
218
217
|
Register `{your origin}/api/connect/callback` as a redirect URI in the service's
|
|
219
218
|
Setup tab — the one step this cannot do for you.
|
|
220
219
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
```ts
|
|
225
|
-
import { withConnect } from "@cosmoops/connect-sdk/next";
|
|
226
|
-
export default withConnect({ });
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
That is all it does. It does **not** stand in for the route file — Next has no
|
|
230
|
-
plugin API that contributes a route from a package, so
|
|
231
|
-
`app/api/connect/[...connect]/route.ts` has to exist either way. The two are
|
|
232
|
-
independent; using both is just the default setup.
|
|
220
|
+
No `next.config.ts` changes needed, including `transpilePackages`: `dist/` is
|
|
221
|
+
already ES2022 with `"use client"` hoisted, so Turbopack and webpack both
|
|
222
|
+
consume it as-is.
|
|
233
223
|
|
|
234
224
|
Reading the session server-side — no argument, no `headers()` dance:
|
|
235
225
|
|
|
@@ -280,11 +270,14 @@ Then wrap your app:
|
|
|
280
270
|
```tsx
|
|
281
271
|
import { ConnectProvider } from "@cosmoops/connect-sdk/client";
|
|
282
272
|
|
|
283
|
-
<ConnectProvider
|
|
284
|
-
{children}
|
|
285
|
-
</ConnectProvider>
|
|
273
|
+
<ConnectProvider>{children}</ConnectProvider>
|
|
286
274
|
```
|
|
287
275
|
|
|
276
|
+
No `clientId` prop needed here either: the default sign-in flow bounces the
|
|
277
|
+
browser to your own `/signin` route, which builds the authorize URL
|
|
278
|
+
server-side. Pass `clientId` only if you also pass `redirectUri`, to build
|
|
279
|
+
that URL yourself instead.
|
|
280
|
+
|
|
288
281
|
### Components
|
|
289
282
|
|
|
290
283
|
```tsx
|
package/dist/cjs/cli/init.js
CHANGED
|
@@ -46,8 +46,6 @@ export { ConnectPlansPage as default } from "@cosmoops/connect-sdk/client";
|
|
|
46
46
|
const ENV_TEMPLATE = `# CosmoOps Connect - values come from your service's Setup tab.
|
|
47
47
|
CONNECT_API_KEY=
|
|
48
48
|
CONNECT_CLIENT_ID=
|
|
49
|
-
# Same value as CONNECT_CLIENT_ID. Inlined at build time for <ConnectProvider>.
|
|
50
|
-
NEXT_PUBLIC_CONNECT_CLIENT_ID=
|
|
51
49
|
`;
|
|
52
50
|
const SCAFFOLDS = [
|
|
53
51
|
{
|
|
@@ -112,7 +110,7 @@ function runInit(argv = []) {
|
|
|
112
110
|
console.log(` ${marker} ${(0, node_path_1.relative)(root, target)} - ${scaffold.description}`);
|
|
113
111
|
}
|
|
114
112
|
const env = ensureEnv(root);
|
|
115
|
-
console.log(` ${env === "skipped" ? "exists " : env === "appended" ? "updated" : "created"} .env.local - fill in the
|
|
113
|
+
console.log(` ${env === "skipped" ? "exists " : env === "appended" ? "updated" : "created"} .env.local - fill in the two values from your service's Setup tab`);
|
|
116
114
|
// The two steps a scaffolder must not do for you: editing an existing layout
|
|
117
115
|
// means parsing and rewriting JSX someone else wrote, and the redirect URI
|
|
118
116
|
// lives in Connect, not in this repo.
|
|
@@ -125,7 +123,7 @@ Three things left, all one-time:
|
|
|
125
123
|
|
|
126
124
|
<ConnectProvider>{children}</ConnectProvider>
|
|
127
125
|
|
|
128
|
-
No props
|
|
126
|
+
No props needed.
|
|
129
127
|
|
|
130
128
|
2. Add the theme to your global stylesheet, last of the three - Tailwind
|
|
131
129
|
first, HeroUI's token layer next, so these values win:
|
|
@@ -140,13 +138,9 @@ Three things left, all one-time:
|
|
|
140
138
|
3. Register {your origin}/api/connect/callback as a redirect URI in your
|
|
141
139
|
service's Setup tab in Connect.
|
|
142
140
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
export default withConnect({ });
|
|
147
|
-
|
|
148
|
-
It checks NEXT_PUBLIC_CONNECT_CLIENT_ID at config load - the one variable whose
|
|
149
|
-
absence fails silently in the browser rather than loudly on the server.
|
|
141
|
+
No next.config.ts changes needed - not even transpilePackages: dist/ is
|
|
142
|
+
already ES2022 with "use client" hoisted, so Turbopack and webpack consume it
|
|
143
|
+
as-is.
|
|
150
144
|
|
|
151
145
|
Then <ConnectPlans />, <ConnectSubscriptionGate>, <ConnectFeatureGate> and the
|
|
152
146
|
rest work anywhere below the provider, and getConnectSession() reads the same
|
|
@@ -24,13 +24,12 @@ const ConnectContext = (0, react_1.createContext)(null);
|
|
|
24
24
|
* origin, where `createConnectHandler` holds the credential.
|
|
25
25
|
*
|
|
26
26
|
* ```tsx
|
|
27
|
-
* // Next.js - clientId comes from NEXT_PUBLIC_CONNECT_CLIENT_ID
|
|
28
27
|
* <ConnectProvider>
|
|
29
28
|
* <App />
|
|
30
29
|
* </ConnectProvider>
|
|
31
30
|
* ```
|
|
32
31
|
*/
|
|
33
|
-
function ConnectProvider({ clientId =
|
|
32
|
+
function ConnectProvider({ clientId = "", basePath = "/api/connect", redirectUri, appUrl = exports.CONNECT_APP_URL, fetch: fetchImpl, children, }) {
|
|
34
33
|
// One state cell, not three. `isLoading` is *derived* from "no result yet"
|
|
35
34
|
// rather than set - a `setIsLoading(true)` at the top of an effect is a
|
|
36
35
|
// synchronous setState inside that effect, which cascades an extra render
|
package/dist/cjs/next/index.js
CHANGED
|
@@ -41,7 +41,6 @@ exports.createConnectHandlers = createConnectHandlers;
|
|
|
41
41
|
exports.GET = handle;
|
|
42
42
|
exports.POST = handle;
|
|
43
43
|
exports.getConnectSession = getConnectSession;
|
|
44
|
-
exports.withConnect = withConnect;
|
|
45
44
|
const client_js_1 = require("../server/client.js");
|
|
46
45
|
const handler_js_1 = require("../server/handler.js");
|
|
47
46
|
/**
|
|
@@ -66,27 +65,23 @@ const handler_js_1 = require("../server/handler.js");
|
|
|
66
65
|
* <ConnectProvider>{children}</ConnectProvider>
|
|
67
66
|
* ```
|
|
68
67
|
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* ```ts
|
|
73
|
-
* import { withConnect } from "@cosmoops/connect-sdk/next";
|
|
74
|
-
* export default withConnect({});
|
|
75
|
-
* ```
|
|
76
|
-
*
|
|
77
|
-
* Configuration comes from the environment, so none of those files take
|
|
78
|
-
* arguments:
|
|
68
|
+
* No `next.config.ts` changes needed - configuration comes from the
|
|
69
|
+
* environment, so neither file takes arguments:
|
|
79
70
|
*
|
|
80
71
|
* | Variable | Required | Purpose |
|
|
81
72
|
* | --- | --- | --- |
|
|
82
73
|
* | `CONNECT_API_KEY` | yes | server-side credential |
|
|
83
74
|
* | `CONNECT_CLIENT_ID` | yes | OAuth client id |
|
|
84
|
-
* | `NEXT_PUBLIC_CONNECT_CLIENT_ID` | yes | same value, for `<ConnectProvider>` |
|
|
85
75
|
* | `CONNECT_APP_URL` | no | non-production Connect instance |
|
|
86
76
|
* | `CONNECT_SESSION_COOKIE` | no | session cookie name |
|
|
87
77
|
*
|
|
88
78
|
* Register `{your origin}/api/connect/callback` as a redirect URI in the
|
|
89
79
|
* service's Setup tab. That is the only step this cannot do for you.
|
|
80
|
+
*
|
|
81
|
+
* No `next.config.ts` changes needed either, including `transpilePackages`:
|
|
82
|
+
* `dist/` is already ES2022 with `"use client"` hoisted to the top of every
|
|
83
|
+
* browser file, so Turbopack and webpack both consume it as-is - adding the
|
|
84
|
+
* entry only costs build time.
|
|
90
85
|
*/
|
|
91
86
|
const DEFAULT_COOKIE = "connect_session";
|
|
92
87
|
function requireEnv(name) {
|
|
@@ -266,45 +261,6 @@ async function getConnectSession(request, options = {}) {
|
|
|
266
261
|
return null;
|
|
267
262
|
}
|
|
268
263
|
}
|
|
269
|
-
/**
|
|
270
|
-
* `next.config` wrapper.
|
|
271
|
-
*
|
|
272
|
-
* Asserts, at config load, that the public client id is present - the one
|
|
273
|
-
* variable whose absence fails silently in the browser instead of loudly on
|
|
274
|
-
* the server, because `NEXT_PUBLIC_*` is inlined at build time and an unset
|
|
275
|
-
* one simply becomes `undefined`. That is its whole job.
|
|
276
|
-
*
|
|
277
|
-
* In particular it does **not** replace the bridge route, and cannot: Next has
|
|
278
|
-
* no plugin API that contributes a route from a `node_modules` package - the
|
|
279
|
-
* App Router discovers routes by walking your own `app/` directory and nothing
|
|
280
|
-
* else, and a `next.config` rewrite still needs a real route to point at. So
|
|
281
|
-
* `app/api/connect/[...connect]/route.ts` has to exist whether or not you use
|
|
282
|
-
* this wrapper. It is one line, and `npx @cosmoops/connect-sdk init` writes it:
|
|
283
|
-
*
|
|
284
|
-
* ```ts
|
|
285
|
-
* export { GET, POST } from "@cosmoops/connect-sdk/next";
|
|
286
|
-
* ```
|
|
287
|
-
*
|
|
288
|
-
* The two are independent - the route works with a plain config, and this
|
|
289
|
-
* wrapper is useful with no route at all. Using both is just the default setup.
|
|
290
|
-
*
|
|
291
|
-
* It does **not** add this package to `transpilePackages`, and you should not
|
|
292
|
-
* either. `dist/` is already ES2022 with `"use client"` hoisted to the top of
|
|
293
|
-
* every browser file, so Turbopack and webpack both consume it as-is;
|
|
294
|
-
* transpiling it again only costs build time. An earlier version of this
|
|
295
|
-
* wrapper added the entry, which is why it may still be in your config.
|
|
296
|
-
*
|
|
297
|
-
* ```ts
|
|
298
|
-
* import { withConnect } from "@cosmoops/connect-sdk/next";
|
|
299
|
-
* export default withConnect({ });
|
|
300
|
-
* ```
|
|
301
|
-
*/
|
|
302
|
-
function withConnect(config = {}) {
|
|
303
|
-
if (!process.env.NEXT_PUBLIC_CONNECT_CLIENT_ID && process.env.NODE_ENV !== "test") {
|
|
304
|
-
console.warn("[@cosmoops/connect-sdk] NEXT_PUBLIC_CONNECT_CLIENT_ID is not set - <ConnectProvider> will not be able to start a sign-in.");
|
|
305
|
-
}
|
|
306
|
-
return config;
|
|
307
|
-
}
|
|
308
264
|
var handler_js_2 = require("../server/handler.js");
|
|
309
265
|
Object.defineProperty(exports, "createConnectHandler", { enumerable: true, get: function () { return handler_js_2.createConnectHandler; } });
|
|
310
266
|
var client_js_2 = require("../server/client.js");
|
package/dist/esm/cli/init.js
CHANGED
|
@@ -41,8 +41,6 @@ export { ConnectPlansPage as default } from "@cosmoops/connect-sdk/client";
|
|
|
41
41
|
const ENV_TEMPLATE = `# CosmoOps Connect - values come from your service's Setup tab.
|
|
42
42
|
CONNECT_API_KEY=
|
|
43
43
|
CONNECT_CLIENT_ID=
|
|
44
|
-
# Same value as CONNECT_CLIENT_ID. Inlined at build time for <ConnectProvider>.
|
|
45
|
-
NEXT_PUBLIC_CONNECT_CLIENT_ID=
|
|
46
44
|
`;
|
|
47
45
|
const SCAFFOLDS = [
|
|
48
46
|
{
|
|
@@ -107,7 +105,7 @@ export function runInit(argv = []) {
|
|
|
107
105
|
console.log(` ${marker} ${relative(root, target)} - ${scaffold.description}`);
|
|
108
106
|
}
|
|
109
107
|
const env = ensureEnv(root);
|
|
110
|
-
console.log(` ${env === "skipped" ? "exists " : env === "appended" ? "updated" : "created"} .env.local - fill in the
|
|
108
|
+
console.log(` ${env === "skipped" ? "exists " : env === "appended" ? "updated" : "created"} .env.local - fill in the two values from your service's Setup tab`);
|
|
111
109
|
// The two steps a scaffolder must not do for you: editing an existing layout
|
|
112
110
|
// means parsing and rewriting JSX someone else wrote, and the redirect URI
|
|
113
111
|
// lives in Connect, not in this repo.
|
|
@@ -120,7 +118,7 @@ Three things left, all one-time:
|
|
|
120
118
|
|
|
121
119
|
<ConnectProvider>{children}</ConnectProvider>
|
|
122
120
|
|
|
123
|
-
No props
|
|
121
|
+
No props needed.
|
|
124
122
|
|
|
125
123
|
2. Add the theme to your global stylesheet, last of the three - Tailwind
|
|
126
124
|
first, HeroUI's token layer next, so these values win:
|
|
@@ -135,13 +133,9 @@ Three things left, all one-time:
|
|
|
135
133
|
3. Register {your origin}/api/connect/callback as a redirect URI in your
|
|
136
134
|
service's Setup tab in Connect.
|
|
137
135
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
export default withConnect({ });
|
|
142
|
-
|
|
143
|
-
It checks NEXT_PUBLIC_CONNECT_CLIENT_ID at config load - the one variable whose
|
|
144
|
-
absence fails silently in the browser rather than loudly on the server.
|
|
136
|
+
No next.config.ts changes needed - not even transpilePackages: dist/ is
|
|
137
|
+
already ES2022 with "use client" hoisted, so Turbopack and webpack consume it
|
|
138
|
+
as-is.
|
|
145
139
|
|
|
146
140
|
Then <ConnectPlans />, <ConnectSubscriptionGate>, <ConnectFeatureGate> and the
|
|
147
141
|
rest work anywhere below the provider, and getConnectSession() reads the same
|
|
@@ -12,13 +12,12 @@ const ConnectContext = createContext(null);
|
|
|
12
12
|
* origin, where `createConnectHandler` holds the credential.
|
|
13
13
|
*
|
|
14
14
|
* ```tsx
|
|
15
|
-
* // Next.js - clientId comes from NEXT_PUBLIC_CONNECT_CLIENT_ID
|
|
16
15
|
* <ConnectProvider>
|
|
17
16
|
* <App />
|
|
18
17
|
* </ConnectProvider>
|
|
19
18
|
* ```
|
|
20
19
|
*/
|
|
21
|
-
export function ConnectProvider({ clientId =
|
|
20
|
+
export function ConnectProvider({ clientId = "", basePath = "/api/connect", redirectUri, appUrl = CONNECT_APP_URL, fetch: fetchImpl, children, }) {
|
|
22
21
|
// One state cell, not three. `isLoading` is *derived* from "no result yet"
|
|
23
22
|
// rather than set - a `setIsLoading(true)` at the top of an effect is a
|
|
24
23
|
// synchronous setState inside that effect, which cascades an extra render
|
package/dist/esm/next/index.js
CHANGED
|
@@ -22,27 +22,23 @@ import { createConnectHandler } from "../server/handler.js";
|
|
|
22
22
|
* <ConnectProvider>{children}</ConnectProvider>
|
|
23
23
|
* ```
|
|
24
24
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* ```ts
|
|
29
|
-
* import { withConnect } from "@cosmoops/connect-sdk/next";
|
|
30
|
-
* export default withConnect({});
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
|
-
* Configuration comes from the environment, so none of those files take
|
|
34
|
-
* arguments:
|
|
25
|
+
* No `next.config.ts` changes needed - configuration comes from the
|
|
26
|
+
* environment, so neither file takes arguments:
|
|
35
27
|
*
|
|
36
28
|
* | Variable | Required | Purpose |
|
|
37
29
|
* | --- | --- | --- |
|
|
38
30
|
* | `CONNECT_API_KEY` | yes | server-side credential |
|
|
39
31
|
* | `CONNECT_CLIENT_ID` | yes | OAuth client id |
|
|
40
|
-
* | `NEXT_PUBLIC_CONNECT_CLIENT_ID` | yes | same value, for `<ConnectProvider>` |
|
|
41
32
|
* | `CONNECT_APP_URL` | no | non-production Connect instance |
|
|
42
33
|
* | `CONNECT_SESSION_COOKIE` | no | session cookie name |
|
|
43
34
|
*
|
|
44
35
|
* Register `{your origin}/api/connect/callback` as a redirect URI in the
|
|
45
36
|
* service's Setup tab. That is the only step this cannot do for you.
|
|
37
|
+
*
|
|
38
|
+
* No `next.config.ts` changes needed either, including `transpilePackages`:
|
|
39
|
+
* `dist/` is already ES2022 with `"use client"` hoisted to the top of every
|
|
40
|
+
* browser file, so Turbopack and webpack both consume it as-is - adding the
|
|
41
|
+
* entry only costs build time.
|
|
46
42
|
*/
|
|
47
43
|
const DEFAULT_COOKIE = "connect_session";
|
|
48
44
|
function requireEnv(name) {
|
|
@@ -236,44 +232,5 @@ export async function getConnectSession(request, options = {}) {
|
|
|
236
232
|
return null;
|
|
237
233
|
}
|
|
238
234
|
}
|
|
239
|
-
/**
|
|
240
|
-
* `next.config` wrapper.
|
|
241
|
-
*
|
|
242
|
-
* Asserts, at config load, that the public client id is present - the one
|
|
243
|
-
* variable whose absence fails silently in the browser instead of loudly on
|
|
244
|
-
* the server, because `NEXT_PUBLIC_*` is inlined at build time and an unset
|
|
245
|
-
* one simply becomes `undefined`. That is its whole job.
|
|
246
|
-
*
|
|
247
|
-
* In particular it does **not** replace the bridge route, and cannot: Next has
|
|
248
|
-
* no plugin API that contributes a route from a `node_modules` package - the
|
|
249
|
-
* App Router discovers routes by walking your own `app/` directory and nothing
|
|
250
|
-
* else, and a `next.config` rewrite still needs a real route to point at. So
|
|
251
|
-
* `app/api/connect/[...connect]/route.ts` has to exist whether or not you use
|
|
252
|
-
* this wrapper. It is one line, and `npx @cosmoops/connect-sdk init` writes it:
|
|
253
|
-
*
|
|
254
|
-
* ```ts
|
|
255
|
-
* export { GET, POST } from "@cosmoops/connect-sdk/next";
|
|
256
|
-
* ```
|
|
257
|
-
*
|
|
258
|
-
* The two are independent - the route works with a plain config, and this
|
|
259
|
-
* wrapper is useful with no route at all. Using both is just the default setup.
|
|
260
|
-
*
|
|
261
|
-
* It does **not** add this package to `transpilePackages`, and you should not
|
|
262
|
-
* either. `dist/` is already ES2022 with `"use client"` hoisted to the top of
|
|
263
|
-
* every browser file, so Turbopack and webpack both consume it as-is;
|
|
264
|
-
* transpiling it again only costs build time. An earlier version of this
|
|
265
|
-
* wrapper added the entry, which is why it may still be in your config.
|
|
266
|
-
*
|
|
267
|
-
* ```ts
|
|
268
|
-
* import { withConnect } from "@cosmoops/connect-sdk/next";
|
|
269
|
-
* export default withConnect({ });
|
|
270
|
-
* ```
|
|
271
|
-
*/
|
|
272
|
-
export function withConnect(config = {}) {
|
|
273
|
-
if (!process.env.NEXT_PUBLIC_CONNECT_CLIENT_ID && process.env.NODE_ENV !== "test") {
|
|
274
|
-
console.warn("[@cosmoops/connect-sdk] NEXT_PUBLIC_CONNECT_CLIENT_ID is not set - <ConnectProvider> will not be able to start a sign-in.");
|
|
275
|
-
}
|
|
276
|
-
return config;
|
|
277
|
-
}
|
|
278
235
|
export { createConnectHandler } from "../server/handler.js";
|
|
279
236
|
export { ConnectClient } from "../server/client.js";
|
|
@@ -7,7 +7,12 @@ export interface ConnectSession {
|
|
|
7
7
|
serviceRole: ServiceRole | null;
|
|
8
8
|
}
|
|
9
9
|
export interface ConnectContextValue {
|
|
10
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Public OAuth client id, if `clientId` was passed to `<ConnectProvider>` -
|
|
12
|
+
* empty string otherwise. Safe in a browser regardless: it only ever goes
|
|
13
|
+
* into the authorize URL. Most integrations never read this - it exists for
|
|
14
|
+
* the explicit-`redirectUri` flow, see `ConnectProviderProps.clientId`.
|
|
15
|
+
*/
|
|
11
16
|
clientId: string;
|
|
12
17
|
/** Connect's own origin, for deep links out to Profile, Billing and the catalog. */
|
|
13
18
|
appUrl: string;
|
|
@@ -58,9 +63,11 @@ export interface ConnectProviderProps {
|
|
|
58
63
|
/**
|
|
59
64
|
* This service's public `client_id`, from its Setup tab in Connect.
|
|
60
65
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
66
|
+
* Not needed for the default sign-in flow: `signIn()` with no `redirectUri`
|
|
67
|
+
* bounces the browser to your own `/signin` route, which already knows
|
|
68
|
+
* `client_id` server-side (`CONNECT_CLIENT_ID`) and builds the authorize URL
|
|
69
|
+
* itself - the browser never needs it. Pass this only alongside an explicit
|
|
70
|
+
* `redirectUri`, when you're building that URL yourself instead.
|
|
64
71
|
*/
|
|
65
72
|
clientId?: string;
|
|
66
73
|
/** Where `createConnectHandler` is mounted in your app. Must match its `basePath`. */
|
|
@@ -91,7 +98,6 @@ export interface ConnectProviderProps {
|
|
|
91
98
|
* origin, where `createConnectHandler` holds the credential.
|
|
92
99
|
*
|
|
93
100
|
* ```tsx
|
|
94
|
-
* // Next.js - clientId comes from NEXT_PUBLIC_CONNECT_CLIENT_ID
|
|
95
101
|
* <ConnectProvider>
|
|
96
102
|
* <App />
|
|
97
103
|
* </ConnectProvider>
|
|
@@ -97,40 +97,6 @@ export declare function getConnectSession(request?: Request, options?: {
|
|
|
97
97
|
client?: ConnectClient;
|
|
98
98
|
session?: ConnectSessionStore;
|
|
99
99
|
}): Promise<UserResponse | null>;
|
|
100
|
-
/**
|
|
101
|
-
* `next.config` wrapper.
|
|
102
|
-
*
|
|
103
|
-
* Asserts, at config load, that the public client id is present - the one
|
|
104
|
-
* variable whose absence fails silently in the browser instead of loudly on
|
|
105
|
-
* the server, because `NEXT_PUBLIC_*` is inlined at build time and an unset
|
|
106
|
-
* one simply becomes `undefined`. That is its whole job.
|
|
107
|
-
*
|
|
108
|
-
* In particular it does **not** replace the bridge route, and cannot: Next has
|
|
109
|
-
* no plugin API that contributes a route from a `node_modules` package - the
|
|
110
|
-
* App Router discovers routes by walking your own `app/` directory and nothing
|
|
111
|
-
* else, and a `next.config` rewrite still needs a real route to point at. So
|
|
112
|
-
* `app/api/connect/[...connect]/route.ts` has to exist whether or not you use
|
|
113
|
-
* this wrapper. It is one line, and `npx @cosmoops/connect-sdk init` writes it:
|
|
114
|
-
*
|
|
115
|
-
* ```ts
|
|
116
|
-
* export { GET, POST } from "@cosmoops/connect-sdk/next";
|
|
117
|
-
* ```
|
|
118
|
-
*
|
|
119
|
-
* The two are independent - the route works with a plain config, and this
|
|
120
|
-
* wrapper is useful with no route at all. Using both is just the default setup.
|
|
121
|
-
*
|
|
122
|
-
* It does **not** add this package to `transpilePackages`, and you should not
|
|
123
|
-
* either. `dist/` is already ES2022 with `"use client"` hoisted to the top of
|
|
124
|
-
* every browser file, so Turbopack and webpack both consume it as-is;
|
|
125
|
-
* transpiling it again only costs build time. An earlier version of this
|
|
126
|
-
* wrapper added the entry, which is why it may still be in your config.
|
|
127
|
-
*
|
|
128
|
-
* ```ts
|
|
129
|
-
* import { withConnect } from "@cosmoops/connect-sdk/next";
|
|
130
|
-
* export default withConnect({ });
|
|
131
|
-
* ```
|
|
132
|
-
*/
|
|
133
|
-
export declare function withConnect<T extends object>(config?: T): T;
|
|
134
100
|
export { createConnectHandler } from "../server/handler.js";
|
|
135
101
|
export type { ConnectSessionStore } from "../server/handler.js";
|
|
136
102
|
export { ConnectClient } from "../server/client.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmoops/connect-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Official server-side SDK for the CosmoOps Connect platform API - Login with Connect, entitlements, billing and metering.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "commonjs",
|