@elevasis/core 0.11.2 → 0.12.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/index.d.ts +2 -1
- package/dist/index.js +8 -1
- package/dist/organization-model/index.d.ts +2 -1
- package/dist/organization-model/index.js +8 -1
- package/dist/test-utils/index.d.ts +10 -3
- package/dist/test-utils/index.js +6 -0
- package/package.json +1 -1
- package/src/_gen/__tests__/__snapshots__/contracts.md.snap +27 -270
- package/src/auth/multi-tenancy/credentials/server/encryption.ts +83 -39
- package/src/auth/multi-tenancy/credentials/server/kek-loader.ts +47 -0
- package/src/auth/multi-tenancy/index.ts +3 -0
- package/src/auth/multi-tenancy/invitations/api-schemas.ts +104 -107
- package/src/auth/multi-tenancy/memberships/api-schemas.ts +6 -5
- package/src/auth/multi-tenancy/memberships/membership.ts +130 -138
- package/src/auth/multi-tenancy/role-management/api-schemas.ts +78 -0
- package/src/auth/multi-tenancy/role-management/index.ts +16 -0
- package/src/execution/engine/tools/integration/server/adapters/apify/__tests__/apify-run-actor.integration.test.ts +299 -293
- package/src/execution/engine/tools/integration/service.test.ts +214 -0
- package/src/execution/engine/tools/integration/service.ts +169 -161
- package/src/integrations/credentials/__tests__/api-schemas.test.ts +420 -496
- package/src/integrations/credentials/api-schemas.ts +127 -143
- package/src/integrations/webhook-endpoints/__tests__/api-schemas.test.ts +327 -318
- package/src/integrations/webhook-endpoints/api-schemas.ts +103 -102
- package/src/integrations/webhook-endpoints/types.ts +58 -51
- package/src/operations/activities/api-schemas.ts +80 -79
- package/src/operations/activities/types.ts +64 -63
- package/src/organization-model/contracts.ts +1 -0
- package/src/organization-model/defaults.ts +6 -0
- package/src/organization-model/domains/navigation.ts +37 -23
- package/src/organization-model/published.ts +2 -1
- package/src/platform/constants/versions.ts +1 -1
- package/src/reference/_generated/contracts.md +27 -270
- package/src/scaffold-registry/__tests__/index.test.ts +72 -7
- package/src/scaffold-registry/index.ts +159 -26
- package/src/server.ts +281 -272
- package/src/supabase/database.types.ts +7 -3
|
@@ -1,143 +1,127 @@
|
|
|
1
|
-
import { z } from 'zod'
|
|
2
|
-
import { UuidSchema, CredentialNameSchema } from '../../platform/utils/validation'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Credential API Validation Schemas
|
|
6
|
-
*
|
|
7
|
-
* Separate from credential configuration schemas (schemas.ts).
|
|
8
|
-
* - schemas.ts: Credential field definitions and type registry
|
|
9
|
-
* - api-schemas.ts: HTTP request/response validation
|
|
10
|
-
*
|
|
11
|
-
* Design: Input Validation Standardization
|
|
12
|
-
* @see apps/docs/content/docs/in-progress/active-development/security/active/credentials-integrations-validation-implementation.mdx
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Credential type validation
|
|
17
|
-
* These are the actual `type` values stored in the database:
|
|
18
|
-
* - 'oauth': All OAuth providers (notion, google-sheets) store this type
|
|
19
|
-
* - 'api-key': Generic single-field API key credentials
|
|
20
|
-
* - 'webhook-secret': Webhook signing secrets for signature validation
|
|
21
|
-
*
|
|
22
|
-
* Note: Provider-specific identifiers (notion, google-sheets) are CREDENTIAL_SCHEMAS
|
|
23
|
-
* keys used for UI lookup, NOT stored type values. OAuth credentials store type='oauth'.
|
|
24
|
-
*/
|
|
25
|
-
export const CredentialTypeSchema = z.enum(['oauth', 'api-key', 'webhook-secret', 'api-key-secret'])
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Credential value validation
|
|
29
|
-
* - Must be a non-empty object
|
|
30
|
-
* - Keys are strings, values can be any JSON type
|
|
31
|
-
* - Max 50 keys (prevents DoS)
|
|
32
|
-
* - Individual string values max 10KB (prevents DoS)
|
|
33
|
-
*
|
|
34
|
-
* SECURITY:
|
|
35
|
-
* - Prevents DoS via massive credential payloads
|
|
36
|
-
* - Enforces reasonable limits for credential storage
|
|
37
|
-
*/
|
|
38
|
-
const CredentialValueSchema = z
|
|
39
|
-
.record(z.string(), z.unknown())
|
|
40
|
-
.refine((val) => Object.keys(val).length > 0, { message: 'Credential value must not be empty' })
|
|
41
|
-
.refine((val) => Object.keys(val).length <= 50, { message: 'Credential value has too many keys (max 50)' })
|
|
42
|
-
.refine(
|
|
43
|
-
(val) => {
|
|
44
|
-
// Check individual string values for size
|
|
45
|
-
for (const v of Object.values(val)) {
|
|
46
|
-
if (typeof v === 'string' && v.length > 10240) {
|
|
47
|
-
return false
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return true
|
|
51
|
-
},
|
|
52
|
-
{ message: 'Individual credential values too large (max 10KB per string)' }
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* POST /api/credentials - Create credential
|
|
57
|
-
*/
|
|
58
|
-
export const CreateCredentialRequestSchema = z
|
|
59
|
-
.object({
|
|
60
|
-
name: CredentialNameSchema,
|
|
61
|
-
type: CredentialTypeSchema,
|
|
62
|
-
value: CredentialValueSchema,
|
|
63
|
-
provider: z.string().optional() // OAuth provider ID ('dropbox', 'notion', 'google-sheets')
|
|
64
|
-
})
|
|
65
|
-
.strict() // Reject unknown fields (prevents mass assignment)
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Response for credential creation
|
|
69
|
-
*/
|
|
70
|
-
export const CreateCredentialResponseSchema = z.object({
|
|
71
|
-
id: UuidSchema,
|
|
72
|
-
name: z.string()
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* GET /api/credentials - List credentials
|
|
77
|
-
*/
|
|
78
|
-
export const ListCredentialsResponseSchema = z.object({
|
|
79
|
-
credentials: z.array(
|
|
80
|
-
z.object({
|
|
81
|
-
id: UuidSchema,
|
|
82
|
-
name: z.string(),
|
|
83
|
-
type: z.string(),
|
|
84
|
-
provider: z.string().nullable(), // OAuth provider or null for non-OAuth
|
|
85
|
-
createdAt: z.string().datetime()
|
|
86
|
-
})
|
|
87
|
-
)
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
/** API response type for a single credential list item */
|
|
91
|
-
export type CredentialListItem = z.infer<typeof ListCredentialsResponseSchema>['credentials'][number]
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* PATCH /api/credentials/:credentialId - Update credential
|
|
95
|
-
*/
|
|
96
|
-
export const UpdateCredentialParamsSchema = z.object({
|
|
97
|
-
credentialId: UuidSchema
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
export const UpdateCredentialRequestSchema = z
|
|
101
|
-
.object({
|
|
102
|
-
value: CredentialValueSchema.optional(),
|
|
103
|
-
name: CredentialNameSchema.optional()
|
|
104
|
-
})
|
|
105
|
-
.strict()
|
|
106
|
-
.refine((data) => data.value !== undefined || data.name !== undefined, {
|
|
107
|
-
message: 'At least one field (value or name) must be provided'
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* DELETE /api/credentials/:credentialId - Delete credential
|
|
112
|
-
*/
|
|
113
|
-
export const DeleteCredentialParamsSchema = z.object({
|
|
114
|
-
credentialId: UuidSchema
|
|
115
|
-
})
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
*
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
value: z.record(z.string(), z.unknown())
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Export all schemas for use in routes
|
|
133
|
-
*/
|
|
134
|
-
export const CredentialSchemas = {
|
|
135
|
-
CreateRequest: CreateCredentialRequestSchema,
|
|
136
|
-
CreateResponse: CreateCredentialResponseSchema,
|
|
137
|
-
ListResponse: ListCredentialsResponseSchema,
|
|
138
|
-
UpdateParams: UpdateCredentialParamsSchema,
|
|
139
|
-
UpdateRequest: UpdateCredentialRequestSchema,
|
|
140
|
-
DeleteParams: DeleteCredentialParamsSchema,
|
|
141
|
-
DecryptParams: DecryptCredentialParamsSchema,
|
|
142
|
-
DecryptResponse: DecryptCredentialResponseSchema
|
|
143
|
-
}
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import { UuidSchema, CredentialNameSchema } from '../../platform/utils/validation'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Credential API Validation Schemas
|
|
6
|
+
*
|
|
7
|
+
* Separate from credential configuration schemas (schemas.ts).
|
|
8
|
+
* - schemas.ts: Credential field definitions and type registry
|
|
9
|
+
* - api-schemas.ts: HTTP request/response validation
|
|
10
|
+
*
|
|
11
|
+
* Design: Input Validation Standardization
|
|
12
|
+
* @see apps/docs/content/docs/in-progress/active-development/security/active/credentials-integrations-validation-implementation.mdx
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Credential type validation
|
|
17
|
+
* These are the actual `type` values stored in the database:
|
|
18
|
+
* - 'oauth': All OAuth providers (notion, google-sheets) store this type
|
|
19
|
+
* - 'api-key': Generic single-field API key credentials
|
|
20
|
+
* - 'webhook-secret': Webhook signing secrets for signature validation
|
|
21
|
+
*
|
|
22
|
+
* Note: Provider-specific identifiers (notion, google-sheets) are CREDENTIAL_SCHEMAS
|
|
23
|
+
* keys used for UI lookup, NOT stored type values. OAuth credentials store type='oauth'.
|
|
24
|
+
*/
|
|
25
|
+
export const CredentialTypeSchema = z.enum(['oauth', 'api-key', 'webhook-secret', 'api-key-secret'])
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Credential value validation
|
|
29
|
+
* - Must be a non-empty object
|
|
30
|
+
* - Keys are strings, values can be any JSON type
|
|
31
|
+
* - Max 50 keys (prevents DoS)
|
|
32
|
+
* - Individual string values max 10KB (prevents DoS)
|
|
33
|
+
*
|
|
34
|
+
* SECURITY:
|
|
35
|
+
* - Prevents DoS via massive credential payloads
|
|
36
|
+
* - Enforces reasonable limits for credential storage
|
|
37
|
+
*/
|
|
38
|
+
const CredentialValueSchema = z
|
|
39
|
+
.record(z.string(), z.unknown())
|
|
40
|
+
.refine((val) => Object.keys(val).length > 0, { message: 'Credential value must not be empty' })
|
|
41
|
+
.refine((val) => Object.keys(val).length <= 50, { message: 'Credential value has too many keys (max 50)' })
|
|
42
|
+
.refine(
|
|
43
|
+
(val) => {
|
|
44
|
+
// Check individual string values for size
|
|
45
|
+
for (const v of Object.values(val)) {
|
|
46
|
+
if (typeof v === 'string' && v.length > 10240) {
|
|
47
|
+
return false
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return true
|
|
51
|
+
},
|
|
52
|
+
{ message: 'Individual credential values too large (max 10KB per string)' }
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* POST /api/credentials - Create credential
|
|
57
|
+
*/
|
|
58
|
+
export const CreateCredentialRequestSchema = z
|
|
59
|
+
.object({
|
|
60
|
+
name: CredentialNameSchema,
|
|
61
|
+
type: CredentialTypeSchema,
|
|
62
|
+
value: CredentialValueSchema,
|
|
63
|
+
provider: z.string().optional() // OAuth provider ID ('dropbox', 'notion', 'google-sheets')
|
|
64
|
+
})
|
|
65
|
+
.strict() // Reject unknown fields (prevents mass assignment)
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Response for credential creation
|
|
69
|
+
*/
|
|
70
|
+
export const CreateCredentialResponseSchema = z.object({
|
|
71
|
+
id: UuidSchema,
|
|
72
|
+
name: z.string()
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* GET /api/credentials - List credentials
|
|
77
|
+
*/
|
|
78
|
+
export const ListCredentialsResponseSchema = z.object({
|
|
79
|
+
credentials: z.array(
|
|
80
|
+
z.object({
|
|
81
|
+
id: UuidSchema,
|
|
82
|
+
name: z.string(),
|
|
83
|
+
type: z.string(),
|
|
84
|
+
provider: z.string().nullable(), // OAuth provider or null for non-OAuth
|
|
85
|
+
createdAt: z.string().datetime()
|
|
86
|
+
})
|
|
87
|
+
)
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
/** API response type for a single credential list item */
|
|
91
|
+
export type CredentialListItem = z.infer<typeof ListCredentialsResponseSchema>['credentials'][number]
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* PATCH /api/credentials/:credentialId - Update credential
|
|
95
|
+
*/
|
|
96
|
+
export const UpdateCredentialParamsSchema = z.object({
|
|
97
|
+
credentialId: UuidSchema
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
export const UpdateCredentialRequestSchema = z
|
|
101
|
+
.object({
|
|
102
|
+
value: CredentialValueSchema.optional(),
|
|
103
|
+
name: CredentialNameSchema.optional()
|
|
104
|
+
})
|
|
105
|
+
.strict()
|
|
106
|
+
.refine((data) => data.value !== undefined || data.name !== undefined, {
|
|
107
|
+
message: 'At least one field (value or name) must be provided'
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* DELETE /api/credentials/:credentialId - Delete credential
|
|
112
|
+
*/
|
|
113
|
+
export const DeleteCredentialParamsSchema = z.object({
|
|
114
|
+
credentialId: UuidSchema
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Export all schemas for use in routes
|
|
119
|
+
*/
|
|
120
|
+
export const CredentialSchemas = {
|
|
121
|
+
CreateRequest: CreateCredentialRequestSchema,
|
|
122
|
+
CreateResponse: CreateCredentialResponseSchema,
|
|
123
|
+
ListResponse: ListCredentialsResponseSchema,
|
|
124
|
+
UpdateParams: UpdateCredentialParamsSchema,
|
|
125
|
+
UpdateRequest: UpdateCredentialRequestSchema,
|
|
126
|
+
DeleteParams: DeleteCredentialParamsSchema
|
|
127
|
+
}
|