@agimon-ai/po-identity 0.0.2-alpha.7 → 0.0.2-alpha.70
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.
|
@@ -25,6 +25,10 @@ var IdentityRefusal = class extends Error {
|
|
|
25
25
|
this.status = status;
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
+
/** Applies `rule` (or Better Auth's default for the path) only when Cloudflare names the client. */
|
|
29
|
+
function perClientLimit(rule) {
|
|
30
|
+
return (request, current) => request.headers.get("cf-connecting-ip") ? rule ?? current : false;
|
|
31
|
+
}
|
|
28
32
|
async function createIdentityHome(config, ports) {
|
|
29
33
|
if (config.jwtKeyWrap.length < 32) throw new Error("Identity key-wrap secret must contain at least 32 characters");
|
|
30
34
|
const now = ports.now ?? Date.now;
|
|
@@ -42,9 +46,27 @@ async function createIdentityHome(config, ports) {
|
|
|
42
46
|
disabledPaths: [
|
|
43
47
|
"/token",
|
|
44
48
|
"/delete-user",
|
|
45
|
-
"/delete-user/callback"
|
|
49
|
+
"/delete-user/callback",
|
|
50
|
+
"/organization/invite-member",
|
|
51
|
+
"/organization/accept-invitation"
|
|
46
52
|
],
|
|
47
53
|
trustedOrigins: [config.issuer, "po://"],
|
|
54
|
+
rateLimit: {
|
|
55
|
+
enabled: true,
|
|
56
|
+
storage: "database",
|
|
57
|
+
customRules: {
|
|
58
|
+
"/email-otp/send-verification-otp": perClientLimit({
|
|
59
|
+
window: 60,
|
|
60
|
+
max: 3
|
|
61
|
+
}),
|
|
62
|
+
"/sign-in/email-otp": perClientLimit({
|
|
63
|
+
window: 60,
|
|
64
|
+
max: 3
|
|
65
|
+
}),
|
|
66
|
+
"/**": perClientLimit()
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
advanced: { ipAddress: { ipAddressHeaders: ["cf-connecting-ip"] } },
|
|
48
70
|
logger: { disabled: true },
|
|
49
71
|
account: {
|
|
50
72
|
encryptOAuthTokens: true,
|
|
@@ -53,6 +75,8 @@ async function createIdentityHome(config, ports) {
|
|
|
53
75
|
socialProviders,
|
|
54
76
|
plugins: [
|
|
55
77
|
(0, better_auth_plugins.organization)({
|
|
78
|
+
allowUserToCreateOrganization: false,
|
|
79
|
+
invitationLimit: 0,
|
|
56
80
|
ac,
|
|
57
81
|
roles: {
|
|
58
82
|
owner: ac.newRole(better_auth_plugins_organization_access.ownerAc.statements),
|
|
@@ -69,13 +93,17 @@ async function createIdentityHome(config, ports) {
|
|
|
69
93
|
jwt: { issuer: config.issuer }
|
|
70
94
|
}),
|
|
71
95
|
(0, _better_auth_expo.expo)(),
|
|
72
|
-
(0, better_auth_plugins.emailOTP)({
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
96
|
+
(0, better_auth_plugins.emailOTP)({
|
|
97
|
+
expiresIn: 300,
|
|
98
|
+
allowedAttempts: 3,
|
|
99
|
+
async sendVerificationOTP({ email, otp }) {
|
|
100
|
+
await ports.email.send({
|
|
101
|
+
to: email,
|
|
102
|
+
subject: "Your Po code",
|
|
103
|
+
text: otp
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}),
|
|
79
107
|
(0, better_auth_plugins.magicLink)({ async sendMagicLink({ email, url }) {
|
|
80
108
|
await ports.email.send({
|
|
81
109
|
to: email,
|
|
@@ -187,6 +215,10 @@ async function createIdentityHome(config, ports) {
|
|
|
187
215
|
"ALTER TABLE identity_approval ADD COLUMN requestedAt INTEGER",
|
|
188
216
|
"ALTER TABLE identity_approval ADD COLUMN rejected INTEGER NOT NULL DEFAULT 0"
|
|
189
217
|
]
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
version: 9,
|
|
221
|
+
statements: ["CREATE TABLE IF NOT EXISTS \"rateLimit\" (\"id\" TEXT PRIMARY KEY, \"key\" TEXT NOT NULL UNIQUE, \"count\" INTEGER NOT NULL, \"lastRequest\" INTEGER NOT NULL)"]
|
|
190
222
|
}
|
|
191
223
|
], { table: "identity_registry_migrations" });
|
|
192
224
|
const auth = (0, better_auth.betterAuth)({
|
|
@@ -25,6 +25,10 @@ var IdentityRefusal = class extends Error {
|
|
|
25
25
|
this.status = status;
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
+
/** Applies `rule` (or Better Auth's default for the path) only when Cloudflare names the client. */
|
|
29
|
+
function perClientLimit(rule) {
|
|
30
|
+
return (request, current) => request.headers.get("cf-connecting-ip") ? rule ?? current : false;
|
|
31
|
+
}
|
|
28
32
|
async function createIdentityHome(config, ports) {
|
|
29
33
|
if (config.jwtKeyWrap.length < 32) throw new Error("Identity key-wrap secret must contain at least 32 characters");
|
|
30
34
|
const now = ports.now ?? Date.now;
|
|
@@ -42,9 +46,27 @@ async function createIdentityHome(config, ports) {
|
|
|
42
46
|
disabledPaths: [
|
|
43
47
|
"/token",
|
|
44
48
|
"/delete-user",
|
|
45
|
-
"/delete-user/callback"
|
|
49
|
+
"/delete-user/callback",
|
|
50
|
+
"/organization/invite-member",
|
|
51
|
+
"/organization/accept-invitation"
|
|
46
52
|
],
|
|
47
53
|
trustedOrigins: [config.issuer, "po://"],
|
|
54
|
+
rateLimit: {
|
|
55
|
+
enabled: true,
|
|
56
|
+
storage: "database",
|
|
57
|
+
customRules: {
|
|
58
|
+
"/email-otp/send-verification-otp": perClientLimit({
|
|
59
|
+
window: 60,
|
|
60
|
+
max: 3
|
|
61
|
+
}),
|
|
62
|
+
"/sign-in/email-otp": perClientLimit({
|
|
63
|
+
window: 60,
|
|
64
|
+
max: 3
|
|
65
|
+
}),
|
|
66
|
+
"/**": perClientLimit()
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
advanced: { ipAddress: { ipAddressHeaders: ["cf-connecting-ip"] } },
|
|
48
70
|
logger: { disabled: true },
|
|
49
71
|
account: {
|
|
50
72
|
encryptOAuthTokens: true,
|
|
@@ -53,6 +75,8 @@ async function createIdentityHome(config, ports) {
|
|
|
53
75
|
socialProviders,
|
|
54
76
|
plugins: [
|
|
55
77
|
organization({
|
|
78
|
+
allowUserToCreateOrganization: false,
|
|
79
|
+
invitationLimit: 0,
|
|
56
80
|
ac,
|
|
57
81
|
roles: {
|
|
58
82
|
owner: ac.newRole(ownerAc.statements),
|
|
@@ -69,13 +93,17 @@ async function createIdentityHome(config, ports) {
|
|
|
69
93
|
jwt: { issuer: config.issuer }
|
|
70
94
|
}),
|
|
71
95
|
expo(),
|
|
72
|
-
emailOTP({
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
96
|
+
emailOTP({
|
|
97
|
+
expiresIn: 300,
|
|
98
|
+
allowedAttempts: 3,
|
|
99
|
+
async sendVerificationOTP({ email, otp }) {
|
|
100
|
+
await ports.email.send({
|
|
101
|
+
to: email,
|
|
102
|
+
subject: "Your Po code",
|
|
103
|
+
text: otp
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}),
|
|
79
107
|
magicLink({ async sendMagicLink({ email, url }) {
|
|
80
108
|
await ports.email.send({
|
|
81
109
|
to: email,
|
|
@@ -187,6 +215,10 @@ async function createIdentityHome(config, ports) {
|
|
|
187
215
|
"ALTER TABLE identity_approval ADD COLUMN requestedAt INTEGER",
|
|
188
216
|
"ALTER TABLE identity_approval ADD COLUMN rejected INTEGER NOT NULL DEFAULT 0"
|
|
189
217
|
]
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
version: 9,
|
|
221
|
+
statements: ["CREATE TABLE IF NOT EXISTS \"rateLimit\" (\"id\" TEXT PRIMARY KEY, \"key\" TEXT NOT NULL UNIQUE, \"count\" INTEGER NOT NULL, \"lastRequest\" INTEGER NOT NULL)"]
|
|
190
222
|
}
|
|
191
223
|
], { table: "identity_registry_migrations" });
|
|
192
224
|
const auth = betterAuth({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/po-identity",
|
|
3
|
-
"version": "0.0.2-alpha.
|
|
3
|
+
"version": "0.0.2-alpha.70",
|
|
4
4
|
"description": "Portable identity home for Po",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -47,19 +47,19 @@
|
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@agimon-ai/po-core": "0.0.0-alpha.
|
|
51
|
-
"@agimon-ai/po-web-security": "0.0.0-alpha.
|
|
50
|
+
"@agimon-ai/po-core": "0.0.0-alpha.123",
|
|
51
|
+
"@agimon-ai/po-web-security": "0.0.0-alpha.123",
|
|
52
52
|
"@better-auth/expo": "1.7.12",
|
|
53
53
|
"@better-auth/passkey": "1.7.12",
|
|
54
54
|
"@better-auth/sso": "1.7.12",
|
|
55
|
-
"@earendil-works/chord": "1.
|
|
56
|
-
"@earendil-works/pi-durable": "1.
|
|
55
|
+
"@earendil-works/chord": "1.5.0",
|
|
56
|
+
"@earendil-works/pi-durable": "1.5.0",
|
|
57
57
|
"better-auth": "1.7.12",
|
|
58
58
|
"jose": "6.2.2"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@agimon-ai/po-network": "0.0.2-alpha.
|
|
62
|
-
"@agimon-ai/vibe-lint-plugin-po-core": "0.0.0-alpha.
|
|
61
|
+
"@agimon-ai/po-network": "0.0.2-alpha.70",
|
|
62
|
+
"@agimon-ai/vibe-lint-plugin-po-core": "0.0.0-alpha.123",
|
|
63
63
|
"@types/node": "26.4.1",
|
|
64
64
|
"tsdown": "0.23.0",
|
|
65
65
|
"typescript": "7.0.2",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
},
|
|
82
82
|
"scripts": {
|
|
83
83
|
"build": "tsdown",
|
|
84
|
-
"typecheck": "
|
|
84
|
+
"typecheck": "tsrs --noEmit",
|
|
85
85
|
"lint": "oxlint . && oxfmt . --check",
|
|
86
86
|
"test": "vitest run"
|
|
87
87
|
}
|