@shubh90/app-runtime 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/dist/auth/index.d.ts +15 -0
- package/dist/auth/index.js +13 -2
- package/package.json +1 -1
package/dist/auth/index.d.ts
CHANGED
|
@@ -30,6 +30,21 @@ export type MiiAuth = {
|
|
|
30
30
|
getAuthMode: typeof getAuthMode;
|
|
31
31
|
loginRoute(request: Request): Promise<Response>;
|
|
32
32
|
logoutRoute(): Promise<Response>;
|
|
33
|
+
/**
|
|
34
|
+
* The proxy's building blocks. An app's middleware is its own (#715 un-owned
|
|
35
|
+
* it: matchers, logos, public paths are per-app), but the pane's silent
|
|
36
|
+
* sign-in — spend a ?mii_code= for an identity, upsert the member, start a
|
|
37
|
+
* session — is platform contract, so the pieces come from here. Returns the
|
|
38
|
+
* cookie to set, or null when the code is spent/stale (send them to /login).
|
|
39
|
+
*/
|
|
40
|
+
redeemPaneCode(code: string): Promise<{
|
|
41
|
+
token: string;
|
|
42
|
+
expiresAt: Date;
|
|
43
|
+
} | null>;
|
|
44
|
+
issueSession(userId: string): Promise<{
|
|
45
|
+
token: string;
|
|
46
|
+
expiresAt: Date;
|
|
47
|
+
}>;
|
|
33
48
|
readonly SESSION_COOKIE: string;
|
|
34
49
|
readonly LOGIN_ACTION: string;
|
|
35
50
|
readonly SIGN_IN_PROBLEMS: typeof SIGN_IN_PROBLEMS;
|
package/dist/auth/index.js
CHANGED
|
@@ -4,8 +4,9 @@ import { safeNext } from "./next-path.js";
|
|
|
4
4
|
import { SIGN_IN_PROBLEMS } from "./problems.js";
|
|
5
5
|
import { loginRoute, logoutRoute, LOGIN_ACTION } from "./routes.js";
|
|
6
6
|
import { createSession, destroySession, getUser, requireUser } from "./session.js";
|
|
7
|
-
import { resolveSession, SESSION_COOKIE } from "./lookup.js";
|
|
8
|
-
import {
|
|
7
|
+
import { issueSession, resolveSession, SESSION_COOKIE } from "./lookup.js";
|
|
8
|
+
import { redeemWithPlaza } from "./plaza.js";
|
|
9
|
+
import { deactivateUser, upsertMemberFromIdentity } from "./users.js";
|
|
9
10
|
import { resolveUsers } from "./users-config.js";
|
|
10
11
|
export { SIGN_IN_PROBLEMS } from "./problems.js";
|
|
11
12
|
export { safeNext } from "./next-path.js";
|
|
@@ -28,6 +29,16 @@ export function createMiiAuth(options = {}) {
|
|
|
28
29
|
getAuthMode,
|
|
29
30
|
loginRoute: (request) => loginRoute(ctx, request),
|
|
30
31
|
logoutRoute: () => logoutRoute(ctx),
|
|
32
|
+
redeemPaneCode: async (code) => {
|
|
33
|
+
const identity = await redeemWithPlaza(code);
|
|
34
|
+
if (identity === null)
|
|
35
|
+
return null;
|
|
36
|
+
const user = await upsertMemberFromIdentity(ctx, identity);
|
|
37
|
+
if (user.status !== "active")
|
|
38
|
+
return null;
|
|
39
|
+
return issueSession(ctx, user.id);
|
|
40
|
+
},
|
|
41
|
+
issueSession: (userId) => issueSession(ctx, userId),
|
|
31
42
|
SESSION_COOKIE,
|
|
32
43
|
LOGIN_ACTION,
|
|
33
44
|
SIGN_IN_PROBLEMS,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shubh90/app-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "The platform contract every mii org app depends on \u2014 sign-in, and the Next.js config an app must not diverge from. A versioned package, not files copied into each repo.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|