@tailor-platform/sdk 1.40.0 → 1.40.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.
@@ -26,14 +26,26 @@ Configure the Built-in IdP using `defineIdp()`:
26
26
  import { defineIdp, defineConfig } from "@tailor-platform/sdk";
27
27
 
28
28
  const idp = defineIdp("my-idp", {
29
- authorization: "loggedIn",
30
29
  clients: ["my-client"],
30
+ permission: {
31
+ create: [{ conditions: [[{ user: "role" }, "=", "ADMIN"]], permit: true }],
32
+ read: [{ conditions: [[{ user: "role" }, "=", "ADMIN"]], permit: true }],
33
+ update: [{ conditions: [[{ user: "role" }, "=", "ADMIN"]], permit: true }],
34
+ delete: [{ conditions: [[{ user: "role" }, "=", "ADMIN"]], permit: true }],
35
+ sendPasswordResetEmail: [{ conditions: [], permit: false }],
36
+ },
31
37
  });
32
38
 
33
39
  // You can define multiple IdPs
34
40
  const anotherIdp = defineIdp("another-idp", {
35
- authorization: "loggedIn",
36
41
  clients: ["another-client"],
42
+ permission: {
43
+ create: [{ conditions: [[{ user: "role" }, "=", "ADMIN"]], permit: true }],
44
+ read: [{ conditions: [[{ user: "role" }, "=", "ADMIN"]], permit: true }],
45
+ update: [{ conditions: [[{ user: "role" }, "=", "ADMIN"]], permit: true }],
46
+ delete: [{ conditions: [[{ user: "role" }, "=", "ADMIN"]], permit: true }],
47
+ sendPasswordResetEmail: [{ conditions: [], permit: false }],
48
+ },
37
49
  });
38
50
 
39
51
  export default defineConfig({
@@ -43,30 +55,60 @@ export default defineConfig({
43
55
 
44
56
  ## Options
45
57
 
46
- ### authorization (optional)
58
+ ### permission
47
59
 
48
- User management permissions. Controls who can manage users in the IdP. This field can be omitted when using `permission` for access control.
60
+ Per-operation permission policies for IdP user management. Controls who can create, read, update, delete users, and send password reset emails.
49
61
 
50
62
  ```typescript
51
63
  defineIdp("my-idp", {
52
- authorization: "loggedIn", // Only logged-in users can manage
64
+ clients: ["my-client"],
65
+ permission: {
66
+ create: [{ conditions: [[{ user: "role" }, "=", "ADMIN"]], permit: true }],
67
+ read: [{ conditions: [[{ user: "role" }, "=", "ADMIN"]], permit: true }],
68
+ update: [
69
+ {
70
+ conditions: [
71
+ [{ user: "role" }, "=", "ADMIN"],
72
+ [{ newIdpUser: "name" }, "!=", { oldIdpUser: "name" }],
73
+ ],
74
+ permit: true,
75
+ },
76
+ ],
77
+ delete: [{ conditions: [[{ user: "role" }, "=", "ADMIN"]], permit: true }],
78
+ sendPasswordResetEmail: [{ conditions: [], permit: false }],
79
+ },
53
80
  });
81
+ ```
54
82
 
55
- defineIdp("my-idp", {
56
- authorization: "insecure", // Anyone can manage (development only)
57
- });
83
+ **Operations:**
84
+
85
+ - `create` - Controls who can create IdP users
86
+ - `read` - Controls who can read IdP users
87
+ - `update` - Controls who can update IdP users
88
+ - `delete` - Controls who can delete IdP users
89
+ - `sendPasswordResetEmail` - Controls who can send password reset emails. The examples above disable this operation; to enable it, use a permission such as `[{ conditions: [[{ user: "role" }, "=", "ADMIN"]], permit: true }]`.
90
+
91
+ **Operands:**
92
+
93
+ - `{ user: "field" }` - Authenticated user's attribute. Built-in fields: `"id"` (user ID), `"_loggedIn"` (boolean, whether the user is authenticated). User-defined attributes (e.g., `"role"`) are also available when configured via `userProfile.attributes` or `machineUserAttributes` in `defineAuth()`
94
+ - `{ idpUser: "field" }` - IdP user field (for create/read/delete). Allowed values: `"id"`, `"name"`, `"disabled"`
95
+ - `{ oldIdpUser: "field" }` - Previous IdP user field value (for update only). Allowed values: `"id"`, `"name"`, `"disabled"`
96
+ - `{ newIdpUser: "field" }` - New IdP user field value (for update only). Allowed values: `"id"`, `"name"`, `"disabled"`
97
+ - Literal values: `string`, `boolean`, `string[]`, `boolean[]`
98
+
99
+ **Operators:** `"="`, `"!="`, `"in"`, `"not in"`
100
+
101
+ **Helper:** `unsafeAllowAllIdPPermission` grants full access without conditions. Intended only for development and testing.
102
+
103
+ ```typescript
104
+ import { unsafeAllowAllIdPPermission } from "@tailor-platform/sdk";
58
105
 
59
106
  defineIdp("my-idp", {
60
- authorization: { cel: "user.role == 'admin'" }, // CEL expression
107
+ clients: ["my-client"],
108
+ permission: unsafeAllowAllIdPPermission,
61
109
  });
62
110
  ```
63
111
 
64
- **Values:**
65
-
66
- - `"insecure"` - No authentication required (use only for development)
67
- - `"loggedIn"` - Requires authenticated user
68
- - `{ cel: "<expression>" }` - Custom authorization logic using CEL
69
-
70
112
  ### clients
71
113
 
72
114
  OAuth client names that can use this IdP:
@@ -77,77 +119,50 @@ defineIdp("my-idp", {
77
119
  });
78
120
  ```
79
121
 
80
- ### emailConfig
122
+ ### authorization (optional, legacy)
81
123
 
82
- Namespace-level email configuration defaults. Per-request values take priority over these defaults.
124
+ Legacy access control field. Use `permission` instead for fine-grained per-operation control. This field is kept for backward compatibility.
83
125
 
84
126
  ```typescript
85
127
  defineIdp("my-idp", {
86
- authorization: "loggedIn",
87
- clients: ["my-client"],
88
- emailConfig: {
89
- fromName: "My App",
90
- passwordResetSubject: "Reset your password",
91
- },
128
+ clients: ["default-client"],
129
+ authorization: "loggedIn", // Only logged-in users can manage
92
130
  });
93
131
  ```
94
132
 
95
- **Fields:**
96
-
97
- - `fromName` - Default sender display name for emails. Empty means use mailer default.
98
- - `passwordResetSubject` - Default subject for password reset emails. Empty means use localized default.
133
+ **Values:**
99
134
 
100
- **Validation:** Each field must be 200 characters or less and must not contain newline characters.
135
+ - `"insecure"` - No authentication required (use only for development)
136
+ - `"loggedIn"` - Requires authenticated user
137
+ - `{ cel: "<expression>" }` - Custom authorization logic using CEL
101
138
 
102
- ### permission
139
+ ### emailConfig
103
140
 
104
- Per-operation permission policies for IdP user management. Controls who can create, read, update, delete users, and send password reset emails.
141
+ Namespace-level email configuration defaults. Per-request values take priority over these defaults.
105
142
 
106
143
  ```typescript
107
144
  defineIdp("my-idp", {
108
- authorization: "loggedIn",
109
145
  clients: ["my-client"],
110
146
  permission: {
111
147
  create: [{ conditions: [[{ user: "role" }, "=", "ADMIN"]], permit: true }],
112
- read: [{ conditions: [[{ user: "_loggedIn" }, "=", true]], permit: true }],
113
- update: [
114
- { conditions: [[{ newIdpUser: "name" }, "!=", { oldIdpUser: "name" }]], permit: true },
115
- ],
148
+ read: [{ conditions: [[{ user: "role" }, "=", "ADMIN"]], permit: true }],
149
+ update: [{ conditions: [[{ user: "role" }, "=", "ADMIN"]], permit: true }],
116
150
  delete: [{ conditions: [[{ user: "role" }, "=", "ADMIN"]], permit: true }],
117
- sendPasswordResetEmail: [{ conditions: [], permit: true }],
151
+ sendPasswordResetEmail: [{ conditions: [], permit: false }],
152
+ },
153
+ emailConfig: {
154
+ fromName: "My App",
155
+ passwordResetSubject: "Reset your password",
118
156
  },
119
157
  });
120
158
  ```
121
159
 
122
- **Operations:**
123
-
124
- - `create` - Controls who can create IdP users
125
- - `read` - Controls who can read IdP users
126
- - `update` - Controls who can update IdP users
127
- - `delete` - Controls who can delete IdP users
128
- - `sendPasswordResetEmail` - Controls who can send password reset emails
129
-
130
- **Operands:**
131
-
132
- - `{ user: "field" }` - Authenticated user's attribute
133
- - `{ idpUser: "field" }` - IdP user field (for create/read/delete). Allowed values: `"id"`, `"name"`, `"disabled"`
134
- - `{ oldIdpUser: "field" }` - Previous IdP user field value (for update only). Allowed values: `"id"`, `"name"`, `"disabled"`
135
- - `{ newIdpUser: "field" }` - New IdP user field value (for update only). Allowed values: `"id"`, `"name"`, `"disabled"`
136
- - Literal values: `string`, `boolean`, `string[]`, `boolean[]`
137
-
138
- **Operators:** `"="`, `"!="`, `"in"`, `"not in"`
139
-
140
- **Helper:** `unsafeAllowAllIdPPermission` grants full access without conditions. Intended only for development and testing.
160
+ **Fields:**
141
161
 
142
- ```typescript
143
- import { unsafeAllowAllIdPPermission } from "@tailor-platform/sdk";
162
+ - `fromName` - Default sender display name for emails. Empty means use mailer default.
163
+ - `passwordResetSubject` - Default subject for password reset emails. Empty means use localized default.
144
164
 
145
- defineIdp("my-idp", {
146
- authorization: "loggedIn",
147
- clients: ["my-client"],
148
- permission: unsafeAllowAllIdPPermission,
149
- });
150
- ```
165
+ **Validation:** Each field must be 200 characters or less and must not contain newline characters.
151
166
 
152
167
  ## Using idp.provider()
153
168
 
@@ -158,8 +173,14 @@ import { defineIdp, defineAuth, defineConfig } from "@tailor-platform/sdk";
158
173
  import { user } from "./tailordb/user";
159
174
 
160
175
  const idp = defineIdp("my-idp", {
161
- authorization: "loggedIn",
162
176
  clients: ["default-client", "mobile-client"],
177
+ permission: {
178
+ create: [{ conditions: [[{ user: "role" }, "=", "ADMIN"]], permit: true }],
179
+ read: [{ conditions: [[{ user: "role" }, "=", "ADMIN"]], permit: true }],
180
+ update: [{ conditions: [[{ user: "role" }, "=", "ADMIN"]], permit: true }],
181
+ delete: [{ conditions: [[{ user: "role" }, "=", "ADMIN"]], permit: true }],
182
+ sendPasswordResetEmail: [{ conditions: [], permit: false }],
183
+ },
163
184
  });
164
185
 
165
186
  const auth = defineAuth("my-auth", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tailor-platform/sdk",
3
- "version": "1.40.0",
3
+ "version": "1.40.1",
4
4
  "description": "Tailor Platform SDK - The SDK to work with Tailor Platform",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -87,16 +87,16 @@
87
87
  "@liam-hq/cli": "0.7.24",
88
88
  "@napi-rs/keyring": "1.2.0",
89
89
  "@opentelemetry/api": "1.9.1",
90
- "@opentelemetry/exporter-trace-otlp-proto": "0.214.0",
91
- "@opentelemetry/resources": "2.6.1",
92
- "@opentelemetry/sdk-trace-node": "2.6.1",
90
+ "@opentelemetry/exporter-trace-otlp-proto": "0.215.0",
91
+ "@opentelemetry/resources": "2.7.0",
92
+ "@opentelemetry/sdk-trace-node": "2.7.0",
93
93
  "@opentelemetry/semantic-conventions": "1.40.0",
94
94
  "@oxc-project/types": "0.126.0",
95
95
  "@standard-schema/spec": "1.1.0",
96
96
  "@tailor-platform/function-kysely-tailordb": "0.1.3",
97
97
  "@tailor-platform/function-types": "0.8.4",
98
98
  "@toiroakr/lines-db": "0.9.1",
99
- "@toiroakr/read-multiline": "0.3.0",
99
+ "@toiroakr/read-multiline": "0.3.1",
100
100
  "@urql/core": "6.0.1",
101
101
  "chalk": "5.6.2",
102
102
  "chokidar": "5.0.0",
@@ -119,7 +119,7 @@
119
119
  "pgsql-ast-parser": "12.0.2",
120
120
  "pkg-types": "2.3.0",
121
121
  "politty": "0.4.14",
122
- "rolldown": "1.0.0-rc.15",
122
+ "rolldown": "1.0.0-rc.16",
123
123
  "semver": "7.7.4",
124
124
  "serve": "14.2.6",
125
125
  "sql-highlight": "6.1.0",
@@ -133,7 +133,7 @@
133
133
  },
134
134
  "devDependencies": {
135
135
  "@eslint/js": "10.0.1",
136
- "@opentelemetry/sdk-trace-base": "2.6.1",
136
+ "@opentelemetry/sdk-trace-base": "2.7.0",
137
137
  "@types/madge": "5.0.3",
138
138
  "@types/mime-types": "3.0.1",
139
139
  "@types/node": "24.12.2",
@@ -147,7 +147,7 @@
147
147
  "oxlint": "1.60.0",
148
148
  "oxlint-tsgolint": "0.20.0",
149
149
  "sonda": "0.11.1",
150
- "tsdown": "0.21.8",
150
+ "tsdown": "0.21.9",
151
151
  "typescript": "5.9.3",
152
152
  "typescript-eslint": "8.58.2",
153
153
  "vitest": "4.1.4",
@@ -1,4 +0,0 @@
1
-
2
- import { n as generatePluginFilesIfNeeded, r as loadApplication, t as defineApplication } from "./application-C_LFXkKJ.mjs";
3
-
4
- export { defineApplication };