torii-backend 0.0.3 → 0.0.5
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.
- checksums.yaml +4 -4
- data/spec/server-v1.json +1 -1
- data/src/torii/backend/client.rb +38 -38
- data/src/torii/backend/generated/lib/torii_backend_generated/api/allowed_origins_api.rb +145 -0
- data/src/torii/backend/generated/lib/{torii-backend-generated → torii_backend_generated}/api/server_sessions_api.rb +6 -6
- data/src/torii/backend/generated/lib/{torii-backend-generated → torii_backend_generated}/api/server_users_api.rb +102 -28
- data/src/torii/backend/generated/lib/{torii-backend-generated → torii_backend_generated}/api_client.rb +4 -3
- data/src/torii/backend/generated/lib/{torii-backend-generated → torii_backend_generated}/api_error.rb +3 -3
- data/src/torii/backend/generated/lib/{torii-backend-generated → torii_backend_generated}/api_model_base.rb +3 -3
- data/src/torii/backend/generated/lib/{torii-backend-generated → torii_backend_generated}/configuration.rb +14 -7
- data/src/torii/backend/generated/lib/torii_backend_generated/models/allowed_origins_response.rb +166 -0
- data/src/torii/backend/generated/lib/{torii-backend-generated → torii_backend_generated}/models/create_user_request.rb +50 -36
- data/src/torii/backend/generated/lib/{torii-backend-generated/models/cursor_page_response_user_response.rb → torii_backend_generated/models/cursor_page_response_server_user_response.rb} +7 -7
- data/src/torii/backend/generated/lib/{torii-backend-generated → torii_backend_generated}/models/problem_detail.rb +3 -3
- data/src/torii/backend/generated/lib/{torii-backend-generated/models/user_response.rb → torii_backend_generated/models/server_user_response.rb} +119 -43
- data/src/torii/backend/generated/lib/{torii-backend-generated → torii_backend_generated}/models/server_user_search_request.rb +3 -3
- data/src/torii/backend/generated/lib/torii_backend_generated/models/set_allowed_origins_request.rb +166 -0
- data/src/torii/backend/generated/lib/torii_backend_generated/models/update_user_metadata_request.rb +175 -0
- data/src/torii/backend/generated/lib/{torii-backend-generated → torii_backend_generated}/models/update_user_request.rb +29 -39
- data/src/torii/backend/generated/lib/{torii-backend-generated → torii_backend_generated}/models/user_session_response.rb +19 -8
- data/src/torii/backend/generated/lib/torii_backend_generated/version.rb +15 -0
- data/src/torii/backend/generated/lib/torii_backend_generated.rb +53 -0
- data/src/torii/backend/generated/spec/api/allowed_origins_api_spec.rb +57 -0
- data/src/torii/backend/generated/spec/api/server_sessions_api_spec.rb +72 -0
- data/src/torii/backend/generated/spec/api/server_users_api_spec.rb +135 -0
- data/src/torii/backend/generated/spec/models/allowed_origins_response_spec.rb +36 -0
- data/src/torii/backend/generated/spec/models/create_user_request_spec.rb +72 -0
- data/src/torii/backend/generated/spec/models/cursor_page_response_server_user_response_spec.rb +48 -0
- data/src/torii/backend/generated/spec/models/problem_detail_spec.rb +66 -0
- data/src/torii/backend/generated/spec/models/server_user_response_spec.rb +128 -0
- data/src/torii/backend/generated/spec/models/server_user_search_request_spec.rb +64 -0
- data/src/torii/backend/generated/spec/models/set_allowed_origins_request_spec.rb +36 -0
- data/src/torii/backend/generated/spec/models/update_user_metadata_request_spec.rb +48 -0
- data/src/torii/backend/generated/spec/models/update_user_request_spec.rb +58 -0
- data/src/torii/backend/generated/spec/models/user_session_response_spec.rb +90 -0
- data/src/torii/backend/generated/spec/spec_helper.rb +111 -0
- data/src/torii/backend/version.rb +1 -1
- data/src/torii-backend-generated.rb +8 -19
- metadata +36 -18
- data/src/torii/backend/generated/lib/torii-backend-generated/version.rb +0 -15
- data/src/torii/backend/generated/lib/torii-backend-generated.rb +0 -49
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9c6886647e9ed2eb2df0e52390b83826d095808d1cb244d2396176c734a3c842
|
|
4
|
+
data.tar.gz: 3eaac288e8d61d3916177c8aa563c6502b74e1f68240dd8bfcb6af4d9ec77aeb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3122cc87ba1fcce90315b8a0520af4203b97556551dc97ffacee3fc002cece54177f08bea88e5b8bf280d7efb179f0978b41f43f68ae8924276f6976550b60bd
|
|
7
|
+
data.tar.gz: 9d68a174436b04dccb613fd9080ead4c48f24249bb8853fdbbef43ce0fe4f82ad98de1bbcf0d5b800ffd4ca38d5b4d81a383bee72deb95054414cb66ccfb37b4
|
data/spec/server-v1.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost:50385","description":"Generated server url"}],"tags":[{"name":"Server Users","description":"Server user management endpoints (secret key auth)"},{"name":"Server Sessions","description":"Server session management endpoints (secret key auth)"}],"paths":{"/api/server/v1/users":{"post":{"tags":["Server Users"],"summary":"Create user","description":"Creates an end-user in your environment. All body fields are optional; supply at minimum an email if you want the user to be able to sign in via email + password.","operationId":"createUser","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateUserRequest"}}},"required":true},"responses":{"201":{"description":"The created user.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"400":{"description":"Invalid body (e.g. weak password, malformed email).","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"409":{"description":"Another user with this email already exists in the environment.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}}}}},"/api/server/v1/users/{userId}/unban":{"post":{"tags":["Server Users"],"summary":"Unban user","description":"Reverses a previous ban. The user can sign in again on next request.","operationId":"unbanUser","parameters":[{"name":"userId","in":"path","description":"Identifier of the user to unban.","required":true,"schema":{"type":"string","format":"uuid"},"example":"01931a73-8b00-7000-8000-000000000000"}],"responses":{"200":{"description":"The (now active) user.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"403":{"description":"User belongs to a different environment.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"404":{"description":"No user with this id.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}}}}},"/api/server/v1/users/{userId}/ban":{"post":{"tags":["Server Users"],"summary":"Ban user","description":"Marks the user as banned and revokes all their active sessions.","operationId":"banUser","parameters":[{"name":"userId","in":"path","description":"Identifier of the user to ban.","required":true,"schema":{"type":"string","format":"uuid"},"example":"01931a73-8b00-7000-8000-000000000000"}],"responses":{"200":{"description":"The (now banned) user.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"403":{"description":"User belongs to a different environment.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"404":{"description":"No user with this id.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}}}}},"/api/server/v1/users/search":{"post":{"tags":["Server Users"],"summary":"Search users","description":"Returns a cursor-paginated page of end-users in the environment matching the optional filters. Filters use the same tri-state PATCH semantics as `UpdateUserRequest`: omit a field to skip that filter, send a value to require it, send null to require null. Uses POST so the filter body can be sent without URL-encoding.","operationId":"searchUsers","parameters":[{"name":"limit","in":"query","description":"Maximum number of items in the returned page (default 20).","required":false,"schema":{"type":"integer","format":"int32","default":20},"example":50},{"name":"cursor","in":"query","description":"Opaque cursor returned by the previous page's `nextCursor`. Omit to fetch the first page.","required":false,"schema":{"type":"string","format":"uuid"},"example":"01931a73-8b00-7000-8000-000000000000"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServerUserSearchRequest"}}}},"responses":{"200":{"description":"Page of matching users.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CursorPageResponseUserResponse"}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}}}}},"/api/server/v1/users/{userId}":{"get":{"tags":["Server Users"],"summary":"Get user","description":"Returns the full profile for one end-user.","operationId":"getUser","parameters":[{"name":"userId","in":"path","description":"Identifier of the user to fetch.","required":true,"schema":{"type":"string","format":"uuid"},"example":"01931a73-8b00-7000-8000-000000000000"}],"responses":{"200":{"description":"The user.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"403":{"description":"User belongs to a different environment.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"404":{"description":"No user with this id.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}}}},"delete":{"tags":["Server Users"],"summary":"Delete user","description":"Soft-deletes the user. Not idempotent at the HTTP layer: the authorization grant for the user is revoked on the first successful delete, so a subsequent DELETE for the same id returns 403 rather than 204. Treat 403 from a retry as a confirmation that the user is already deleted.","operationId":"deleteUser","parameters":[{"name":"userId","in":"path","description":"Identifier of the user to delete.","required":true,"schema":{"type":"string","format":"uuid"},"example":"01931a73-8b00-7000-8000-000000000000"}],"responses":{"204":{"description":"User deleted."},"401":{"description":"Missing or invalid secret key.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"403":{"description":"User belongs to a different environment.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"404":{"description":"No user with this id.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}}}},"patch":{"tags":["Server Users"],"summary":"Update user","description":"Partial update with tri-state PATCH semantics. Every field in `UpdateUserRequest` is tri-state: omit the key to leave the field unchanged, send a non-null value to set it, or send JSON null to clear it.","operationId":"updateUser","parameters":[{"name":"userId","in":"path","description":"Identifier of the user to update.","required":true,"schema":{"type":"string","format":"uuid"},"example":"01931a73-8b00-7000-8000-000000000000"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateUserRequest"}}},"required":true},"responses":{"200":{"description":"The updated user.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UserResponse"}}}},"400":{"description":"Invalid body.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"403":{"description":"User belongs to a different environment.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"404":{"description":"No user with this id.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}}}}},"/api/server/v1/users/{userId}/sessions":{"get":{"tags":["Server Sessions"],"summary":"List user sessions","description":"Returns all active (unexpired, unrevoked) sessions for the user, ordered by most recently used.","operationId":"listSessions","parameters":[{"name":"userId","in":"path","description":"Identifier of the user whose sessions to list.","required":true,"schema":{"type":"string","format":"uuid"},"example":"01931a73-8b00-7000-8000-000000000000"}],"responses":{"200":{"description":"All active sessions for the user.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/UserSessionResponse"}}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"403":{"description":"User belongs to a different environment.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}}}},"delete":{"tags":["Server Sessions"],"summary":"Revoke all sessions","description":"Immediately revokes every active session for the user. Idempotent.","operationId":"revokeAllSessions","parameters":[{"name":"userId","in":"path","description":"Identifier of the user whose sessions to revoke.","required":true,"schema":{"type":"string","format":"uuid"},"example":"01931a73-8b00-7000-8000-000000000000"}],"responses":{"204":{"description":"Sessions revoked."},"401":{"description":"Missing or invalid secret key.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"403":{"description":"User belongs to a different environment.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}}}}},"/api/server/v1/users/{userId}/sessions/{sessionId}":{"delete":{"tags":["Server Sessions"],"summary":"Revoke specific session","description":"Revokes a single session by id. Idempotent: returns 204 even if the session was already revoked or expired.","operationId":"revokeSession","parameters":[{"name":"userId","in":"path","description":"Identifier of the user who owns the session.","required":true,"schema":{"type":"string","format":"uuid"},"example":"01931a73-8b00-7000-8000-000000000000"},{"name":"sessionId","in":"path","description":"Identifier of the session to revoke.","required":true,"schema":{"type":"string","format":"uuid"},"example":"01931a74-1234-7000-8000-000000000000"}],"responses":{"204":{"description":"Session revoked."},"401":{"description":"Missing or invalid secret key.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"403":{"description":"User or session belongs to a different environment.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}}}}}},"components":{"schemas":{"CreateUserRequest":{"type":"object","description":"Request body for creating an end-user in your environment. All fields are optional; supply at minimum an email if you want the user to be able to sign in via email + password.","properties":{"email":{"type":["string","null"],"description":"Primary email for the new user. If omitted, the user is created without a sign-in identity.","example":"ada@example.com"},"password":{"type":["string","null"],"description":"Initial password. Subject to the environment's password policy. Omit to create a passwordless user (e.g. social-only).","example":"correct horse battery staple"},"name":{"type":["string","null"],"description":"Display name to seed on the profile.","example":"Ada Lovelace"},"phone":{"type":["string","null"],"description":"Phone number to seed on the profile.","example":"+15555550100"},"address":{"type":["string","null"],"description":"Postal address to seed on the profile.","example":"221B Baker Street, London"},"dateOfBirth":{"type":["string","null"],"format":"date","description":"Date of birth in ISO-8601 (YYYY-MM-DD).","example":"1815-12-10"}}},"ProblemDetail":{"type":"object","properties":{"type":{"type":"string","format":"uri"},"title":{"type":"string"},"status":{"type":"integer","format":"int32"},"detail":{"type":"string"},"instance":{"type":"string","format":"uri"},"properties":{"type":"object","additionalProperties":{}}}},"UserResponse":{"type":"object","description":"An end-user belonging to one of your environments.","properties":{"id":{"type":"string","format":"uuid","description":"Unique identifier for this user.","example":"01931a73-8b00-7000-8000-000000000000"},"environmentId":{"type":"string","format":"uuid","description":"Identifier of the environment this user belongs to.","example":"01931a72-0000-7000-8000-000000000000"},"name":{"type":["string","null"],"description":"Full name on the profile, if any.","example":"Ada Lovelace"},"phone":{"type":["string","null"],"description":"Phone number on the profile, if any. Not guaranteed to be verified.","example":"+15555550100"},"locale":{"type":["string","null"],"description":"Preferred locale for emails and UI messages.","enum":["en","da"]},"address":{"type":["string","null"],"description":"Free-form address string, if provided.","example":"221B Baker Street, London"},"dateOfBirth":{"type":["string","null"],"format":"date","description":"Date of birth in ISO-8601 (YYYY-MM-DD), if provided.","example":"1815-12-10"},"status":{"type":"string","description":"Lifecycle status of the user (e.g. active, banned).","enum":["active","banned","deleted"]},"createdAt":{"type":"string","format":"date-time","description":"When this user was created (ISO-8601 UTC).","example":"2026-05-16T09:30:00Z"},"updatedAt":{"type":"string","format":"date-time","description":"When this user was last modified (ISO-8601 UTC).","example":"2026-05-16T10:00:00Z"},"email":{"type":["string","null"],"description":"Primary email on the profile, if any. Not guaranteed to be verified.","example":"ada@example.com"},"emailVerifiedAt":{"type":["string","null"],"format":"date-time","description":"When this user's primary email was verified, if it has been verified.","example":"2026-05-16T09:35:00Z"},"deletedAt":{"type":["string","null"],"format":"date-time","description":"When this user was deleted, if soft-deleted. Null for active users.","example":"2026-05-20T12:00:00Z"}},"required":["createdAt","environmentId","id","status","updatedAt"]},"ServerUserSearchRequest":{"type":"object","description":"Optional filter body for `POST /users/search`. Every field is tri-state: omit to skip that filter, send a value to require it. Fields whose inner type is nullable (currently `name`, `email`) additionally accept JSON null to filter for users where that column is null; the non-nullable `statuses` field rejects null.","properties":{"name":{"type":["string","null"],"description":"Filter by name (case-insensitive substring match). Send null to require users with no name.","example":"Ada"},"email":{"type":["string","null"],"description":"Filter by primary email (case-insensitive substring match). Send null to require users with no email.","example":"@example.com"},"statuses":{"type":"array","description":"Filter by user status. Returns users matching any of the supplied statuses.","items":{"type":"string","enum":["active","banned","deleted"]},"uniqueItems":true},"createdAfter":{"type":["string","null"],"format":"date-time","description":"Only return users created at or after this instant (ISO-8601 UTC).","example":"2026-01-01T00:00:00Z"},"createdBefore":{"type":["string","null"],"format":"date-time","description":"Only return users created at or before this instant (ISO-8601 UTC).","example":"2026-12-31T23:59:59Z"}}},"CursorPageResponseUserResponse":{"type":"object","description":"A single page of results in a cursor-paginated list. Pass `nextCursor` as the `cursor` query parameter to fetch the following page.","properties":{"items":{"type":"array","description":"Items in this page, in stable order.","items":{"$ref":"#/components/schemas/UserResponse"}},"nextCursor":{"type":["string","null"],"format":"uuid","description":"Cursor to pass to fetch the next page. Null when this is the last page.","example":"01931a73-8b00-7000-8000-000000000000"},"hasMore":{"type":"boolean","description":"True if more pages are available (equivalent to `nextCursor != null`).","example":true}},"required":["hasMore","items"]},"UpdateUserRequest":{"type":"object","description":"PATCH body for updating an end-user. Every field is tri-state: omit the key entirely to leave the field unchanged, send a non-null value to set it, or send JSON null to clear it.","properties":{"name":{"type":["string","null"],"description":"New display name. Send null to clear; omit to leave unchanged.","example":"Ada Lovelace"},"phone":{"type":["string","null"],"description":"New phone number. Send null to clear; omit to leave unchanged.","example":"+15555550100"},"locale":{"type":["string","null"],"description":"New preferred locale. Send null to clear; omit to leave unchanged.","enum":["en","da"]},"address":{"type":["string","null"],"description":"New postal address. Send null to clear; omit to leave unchanged.","example":"221B Baker Street, London"},"dateOfBirth":{"type":["string","null"],"format":"date","description":"New date of birth (YYYY-MM-DD). Send null to clear; omit to leave unchanged.","example":"1815-12-10"}}},"UserSessionResponse":{"type":"object","description":"An active end-user session in your environment.","properties":{"id":{"type":"string","format":"uuid","description":"Unique identifier for this session.","example":"01931a74-1234-7000-8000-000000000000"},"userId":{"type":"string","format":"uuid","description":"Identifier of the end-user this session belongs to.","example":"01931a73-8b00-7000-8000-000000000000"},"environmentId":{"type":"string","format":"uuid","description":"Identifier of the environment this session belongs to.","example":"01931a72-0000-7000-8000-000000000000"},"userAgent":{"type":["string","null"],"description":"Raw User-Agent string captured when the session was created.","example":"Mozilla/5.0 (Macintosh; Intel Mac OS X 14_6_0) AppleWebKit/537.36"},"ipAddress":{"type":["string","null"],"description":"IP address captured when the session was created.","example":"203.0.113.42"},"createdAt":{"type":"string","format":"date-time","description":"When this session was created (ISO-8601 UTC).","example":"2026-05-16T09:30:00Z"},"expiresAt":{"type":"string","format":"date-time","description":"When this session expires (ISO-8601 UTC).","example":"2026-05-23T09:30:00Z"},"lastUsedAt":{"type":"string","format":"date-time","description":"When this session was last seen by the API (ISO-8601 UTC).","example":"2026-05-16T11:42:00Z"},"activeOrganizationId":{"type":["string","null"],"format":"uuid","description":"Active organization pinned to this session (`org_id` claim on re-mint)."}},"required":["createdAt","environmentId","expiresAt","id","lastUsedAt","userId"]}}}}
|
|
1
|
+
{"openapi":"3.1.0","info":{"title":"Torii Backend API","description":"Server-to-server API (BAPI) for backend SDKs. Authenticated with a secret key (Bearer sk_live_* / sk_test_*).","version":"v1"},"servers":[{"url":"https://api.torii.so","description":"Production backend API"}],"security":[{"bearerAuth":[]}],"tags":[{"name":"Allowed Origins","description":"Escape-hatch origins for non-web stacks (secret key auth)"},{"name":"Server Users","description":"Server user management endpoints (secret key auth)"},{"name":"Server Sessions","description":"Server session management endpoints (secret key auth)"}],"paths":{"/api/server/v1/allowed-origins":{"get":{"tags":["Allowed Origins"],"summary":"List escape-hatch origins for this environment","operationId":"list","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AllowedOriginsResponse"}}}}}},"put":{"tags":["Allowed Origins"],"summary":"Replace the escape-hatch origins for this environment","description":"Full origins incl. non-http schemes (e.g. capacitor://localhost). Replaces the list.","operationId":"set","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SetAllowedOriginsRequest"}}},"required":true},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AllowedOriginsResponse"}}}}}}},"/api/server/v1/users":{"post":{"tags":["Server Users"],"summary":"Create user","description":"Creates an end-user in your environment. All body fields are optional; supply at minimum an email if you want the user to be able to sign in via email + password.","operationId":"createUser","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateUserRequest"}}},"required":true},"responses":{"201":{"description":"The created user.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServerUserResponse"}}}},"400":{"description":"Invalid body (e.g. weak password, malformed email).","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"409":{"description":"Another user with this email already exists in the environment.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}}}}},"/api/server/v1/users/{userId}/unban":{"post":{"tags":["Server Users"],"summary":"Unban user","description":"Reverses a previous ban. The user can sign in again on next request.","operationId":"unbanUser","parameters":[{"name":"userId","in":"path","description":"Identifier of the user to unban.","required":true,"schema":{"type":"string","format":"uuid"},"example":"01931a73-8b00-7000-8000-000000000000"}],"responses":{"200":{"description":"The (now active) user.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServerUserResponse"}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"403":{"description":"User belongs to a different environment.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"404":{"description":"No user with this id.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}}}}},"/api/server/v1/users/{userId}/ban":{"post":{"tags":["Server Users"],"summary":"Ban user","description":"Marks the user as banned and revokes all their active sessions.","operationId":"banUser","parameters":[{"name":"userId","in":"path","description":"Identifier of the user to ban.","required":true,"schema":{"type":"string","format":"uuid"},"example":"01931a73-8b00-7000-8000-000000000000"}],"responses":{"200":{"description":"The (now banned) user.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServerUserResponse"}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"403":{"description":"User belongs to a different environment.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"404":{"description":"No user with this id.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}}}}},"/api/server/v1/users/search":{"post":{"tags":["Server Users"],"summary":"Search users","description":"Returns a cursor-paginated page of end-users in the environment matching the optional filters. Filters use the same tri-state PATCH semantics as `UpdateUserRequest`: omit a field to skip that filter, send a value to require it, send null to require null. Uses POST so the filter body can be sent without URL-encoding.","operationId":"searchUsers","parameters":[{"name":"limit","in":"query","description":"Maximum number of items in the returned page (default 20).","required":false,"schema":{"type":"integer","format":"int32","default":20},"example":50},{"name":"cursor","in":"query","description":"Opaque cursor returned by the previous page's `nextCursor`. Omit to fetch the first page.","required":false,"schema":{"type":"string","format":"uuid"},"example":"01931a73-8b00-7000-8000-000000000000"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServerUserSearchRequest"}}}},"responses":{"200":{"description":"Page of matching users.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CursorPageResponseServerUserResponse"}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}}}}},"/api/server/v1/users/{userId}":{"get":{"tags":["Server Users"],"summary":"Get user","description":"Returns the full profile for one end-user.","operationId":"getUser","parameters":[{"name":"userId","in":"path","description":"Identifier of the user to fetch.","required":true,"schema":{"type":"string","format":"uuid"},"example":"01931a73-8b00-7000-8000-000000000000"}],"responses":{"200":{"description":"The user.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServerUserResponse"}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"403":{"description":"User belongs to a different environment.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"404":{"description":"No user with this id.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}}}},"delete":{"tags":["Server Users"],"summary":"Delete user","description":"Soft-deletes the user. Not idempotent at the HTTP layer: the authorization grant for the user is revoked on the first successful delete, so a subsequent DELETE for the same id returns 403 rather than 204. Treat 403 from a retry as a confirmation that the user is already deleted.","operationId":"deleteUser","parameters":[{"name":"userId","in":"path","description":"Identifier of the user to delete.","required":true,"schema":{"type":"string","format":"uuid"},"example":"01931a73-8b00-7000-8000-000000000000"}],"responses":{"204":{"description":"User deleted."},"401":{"description":"Missing or invalid secret key.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"403":{"description":"User belongs to a different environment.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"404":{"description":"No user with this id.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}}}},"patch":{"tags":["Server Users"],"summary":"Update user","description":"Partial update with tri-state PATCH semantics. Every field in `UpdateUserRequest` is tri-state: omit the key to leave the field unchanged, send a non-null value to set it, or send JSON null to clear it.","operationId":"updateUser","parameters":[{"name":"userId","in":"path","description":"Identifier of the user to update.","required":true,"schema":{"type":"string","format":"uuid"},"example":"01931a73-8b00-7000-8000-000000000000"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateUserRequest"}}},"required":true},"responses":{"200":{"description":"The updated user.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServerUserResponse"}}}},"400":{"description":"Invalid body.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"403":{"description":"User belongs to a different environment.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"404":{"description":"No user with this id.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}}}}},"/api/server/v1/users/{userId}/metadata":{"patch":{"tags":["Server Users"],"summary":"Update user metadata","description":"Deep-merges into any of the three metadata bags. Each bag is tri-state: omit the key to leave the bag unchanged, or send an object to deep-merge into the existing bag (a key set to null removes it). The merged result is capped at 512 bytes for `publicMetadata`/`unsafeMetadata` and 4096 bytes for `privateMetadata`.","operationId":"updateUserMetadata","parameters":[{"name":"userId","in":"path","description":"Identifier of the user to update.","required":true,"schema":{"type":"string","format":"uuid"},"example":"01931a73-8b00-7000-8000-000000000000"}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateUserMetadataRequest"}}},"required":true},"responses":{"200":{"description":"The updated user.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServerUserResponse"}}}},"400":{"description":"A bag exceeds its size limit.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"403":{"description":"User belongs to a different environment.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"404":{"description":"No user with this id.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}}}}},"/api/server/v1/users/{userId}/sessions":{"get":{"tags":["Server Sessions"],"summary":"List user sessions","description":"Returns all active (unexpired, unrevoked) sessions for the user, ordered by most recently used.","operationId":"listSessions","parameters":[{"name":"userId","in":"path","description":"Identifier of the user whose sessions to list.","required":true,"schema":{"type":"string","format":"uuid"},"example":"01931a73-8b00-7000-8000-000000000000"}],"responses":{"200":{"description":"All active sessions for the user.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/UserSessionResponse"}}}}},"401":{"description":"Missing or invalid secret key.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"403":{"description":"User belongs to a different environment.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}}}},"delete":{"tags":["Server Sessions"],"summary":"Revoke all sessions","description":"Immediately revokes every active session for the user. Idempotent.","operationId":"revokeAllSessions","parameters":[{"name":"userId","in":"path","description":"Identifier of the user whose sessions to revoke.","required":true,"schema":{"type":"string","format":"uuid"},"example":"01931a73-8b00-7000-8000-000000000000"}],"responses":{"204":{"description":"Sessions revoked."},"401":{"description":"Missing or invalid secret key.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"403":{"description":"User belongs to a different environment.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}}}}},"/api/server/v1/users/{userId}/sessions/{sessionId}":{"delete":{"tags":["Server Sessions"],"summary":"Revoke specific session","description":"Revokes a single session by id. Idempotent: returns 204 even if the session was already revoked or expired.","operationId":"revokeSession","parameters":[{"name":"userId","in":"path","description":"Identifier of the user who owns the session.","required":true,"schema":{"type":"string","format":"uuid"},"example":"01931a73-8b00-7000-8000-000000000000"},{"name":"sessionId","in":"path","description":"Identifier of the session to revoke.","required":true,"schema":{"type":"string","format":"uuid"},"example":"01931a74-1234-7000-8000-000000000000"}],"responses":{"204":{"description":"Session revoked."},"401":{"description":"Missing or invalid secret key.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}},"403":{"description":"User or session belongs to a different environment.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/ProblemDetail"}}}}}}}},"components":{"schemas":{"SetAllowedOriginsRequest":{"type":"object","properties":{"origins":{"type":"array","items":{"type":"string"}}},"required":["origins"]},"AllowedOriginsResponse":{"type":"object","properties":{"origins":{"type":"array","items":{"type":"string"}}},"required":["origins"]},"CreateUserRequest":{"type":"object","description":"Request body for creating an end-user in your environment. All fields are optional; supply at minimum an email if you want the user to be able to sign in via email + password.","properties":{"email":{"type":["string","null"],"description":"Primary email for the new user. If omitted, the user is created without a sign-in identity.","example":"ada@example.com"},"password":{"type":["string","null"],"description":"Initial password. Subject to the environment's password policy. Omit to create a passwordless user (e.g. social-only).","example":"correct horse battery staple"},"firstName":{"type":["string","null"],"description":"First (given) name to seed on the profile.","example":"Ada"},"lastName":{"type":["string","null"],"description":"Last (family) name to seed on the profile.","example":"Lovelace"},"publicMetadata":{"type":"object","additionalProperties":true,"description":"Initial public metadata (SDK-readable, server-written). Max 512 bytes.","example":{"plan":"free"}},"privateMetadata":{"type":"object","additionalProperties":true,"description":"Initial private metadata (server-only). Max 4096 bytes.","example":{"stripeId":"cus_123"}},"unsafeMetadata":{"type":"object","additionalProperties":true,"description":"Initial unsafe metadata (end-user writable). Max 512 bytes.","example":{"onboardingStep":0}}}},"ProblemDetail":{"type":"object","properties":{"type":{"type":"string","format":"uri"},"title":{"type":"string"},"status":{"type":"integer","format":"int32"},"detail":{"type":"string"},"instance":{"type":"string","format":"uri"},"properties":{"type":"object","additionalProperties":{}}}},"ServerUserResponse":{"type":"object","description":"An end-user, including server-only private metadata. Returned only on the secret-key backend API.","properties":{"id":{"type":"string","format":"uuid","description":"Unique identifier for this user.","example":"01931a73-8b00-7000-8000-000000000000"},"environmentId":{"type":"string","format":"uuid","description":"Identifier of the environment this user belongs to.","example":"01931a72-0000-7000-8000-000000000000"},"name":{"type":["string","null"],"description":"Full name on the profile, if any.","example":"Ada Lovelace"},"firstName":{"type":["string","null"],"description":"First (given) name on the profile, if any.","example":"Ada"},"lastName":{"type":["string","null"],"description":"Last (family) name on the profile, if any.","example":"Lovelace"},"locale":{"type":["string","null"],"description":"Preferred locale for emails and UI messages.","enum":["en","da"]},"status":{"type":"string","description":"Lifecycle status of the user (e.g. active, banned).","enum":["active","banned","deleted"]},"createdAt":{"type":"string","format":"date-time","description":"When this user was created (ISO-8601 UTC).","example":"2026-05-16T09:30:00Z"},"updatedAt":{"type":"string","format":"date-time","description":"When this user was last modified (ISO-8601 UTC).","example":"2026-05-16T10:00:00Z"},"email":{"type":["string","null"],"description":"Primary email on the profile, if any.","example":"ada@example.com"},"emailVerifiedAt":{"type":["string","null"],"format":"date-time","description":"When this user's primary email was verified, if it has been verified.","example":"2026-05-16T09:35:00Z"},"deletedAt":{"type":["string","null"],"format":"date-time","description":"When this user was deleted, if soft-deleted. Null for active users.","example":"2026-05-20T12:00:00Z"},"publicMetadata":{"type":"object","additionalProperties":true,"description":"Public metadata: readable by the SDK, writable only server-side.","example":{"plan":"pro"}},"privateMetadata":{"type":"object","additionalProperties":true,"description":"Private metadata: server-only. Never exposed to the SDK or in a JWT.","example":{"stripeId":"cus_123"}},"unsafeMetadata":{"type":"object","additionalProperties":true,"description":"Unsafe metadata: readable and writable by the end-user via the SDK.","example":{"onboardingStep":2}}},"required":["createdAt","environmentId","id","privateMetadata","publicMetadata","status","unsafeMetadata","updatedAt"]},"ServerUserSearchRequest":{"type":"object","description":"Optional filter body for `POST /users/search`. Every field is tri-state: omit to skip that filter, send a value to require it. Fields whose inner type is nullable (currently `name`, `email`) additionally accept JSON null to filter for users where that column is null; the non-nullable `statuses` field rejects null.","properties":{"name":{"type":["string","null"],"description":"Filter by name (case-insensitive substring match). Send null to require users with no name.","example":"Ada"},"email":{"type":["string","null"],"description":"Filter by primary email (case-insensitive substring match). Send null to require users with no email.","example":"@example.com"},"statuses":{"type":"array","description":"Filter by user status. Returns users matching any of the supplied statuses.","items":{"type":"string","enum":["active","banned","deleted"]},"uniqueItems":true},"createdAfter":{"type":["string","null"],"format":"date-time","description":"Only return users created at or after this instant (ISO-8601 UTC).","example":"2026-01-01T00:00:00Z"},"createdBefore":{"type":["string","null"],"format":"date-time","description":"Only return users created at or before this instant (ISO-8601 UTC).","example":"2026-12-31T23:59:59Z"}}},"CursorPageResponseServerUserResponse":{"type":"object","description":"A single page of results in a cursor-paginated list. Pass `nextCursor` as the `cursor` query parameter to fetch the following page.","properties":{"items":{"type":"array","description":"Items in this page, in stable order.","items":{"$ref":"#/components/schemas/ServerUserResponse"}},"nextCursor":{"type":["string","null"],"format":"uuid","description":"Cursor to pass to fetch the next page. Null when this is the last page.","example":"01931a73-8b00-7000-8000-000000000000"},"hasMore":{"type":"boolean","description":"True if more pages are available (equivalent to `nextCursor != null`).","example":true}},"required":["hasMore","items"]},"UpdateUserRequest":{"type":"object","description":"PATCH body for updating an end-user. Every field is tri-state: omit the key entirely to leave the field unchanged, send a non-null value to set it, or send JSON null to clear it.","properties":{"firstName":{"type":["string","null"],"description":"New first (given) name. Send null to clear; omit to leave unchanged.","example":"Ada"},"lastName":{"type":["string","null"],"description":"New last (family) name. Send null to clear; omit to leave unchanged.","example":"Lovelace"},"locale":{"type":["string","null"],"description":"New preferred locale. Send null to clear; omit to leave unchanged.","enum":["en","da"]},"unsafeMetadata":{"type":"object","additionalProperties":true,"description":"Deep-merges into the user's unsafe metadata (a key set to null removes it); omit to leave unchanged. Merged result max 512 bytes.","example":{"onboardingStep":2}}}},"UpdateUserMetadataRequest":{"type":"object","description":"PATCH body for a user's metadata bags. Each bag is tri-state: omit to leave it unchanged, or send an object value. Whether the object merges into or replaces the bag depends on the endpoint (see its operation description).","properties":{"publicMetadata":{"type":"object","additionalProperties":true,"description":"Public metadata bag: SDK-readable, server-written. Max 512 bytes.","example":{"plan":"pro"}},"privateMetadata":{"type":"object","additionalProperties":true,"description":"Private metadata bag: server-only, never exposed to the SDK or in a JWT. Max 4096 bytes.","example":{"stripeId":"cus_123"}},"unsafeMetadata":{"type":"object","additionalProperties":true,"description":"Unsafe metadata bag: readable and writable by the end-user via the SDK. Max 512 bytes.","example":{"onboardingStep":2}}}},"UserSessionResponse":{"type":"object","description":"An active end-user session in your environment.","properties":{"id":{"type":"string","format":"uuid","description":"Unique identifier for this session.","example":"01931a74-1234-7000-8000-000000000000"},"userId":{"type":"string","format":"uuid","description":"Identifier of the end-user this session belongs to.","example":"01931a73-8b00-7000-8000-000000000000"},"environmentId":{"type":"string","format":"uuid","description":"Identifier of the environment this session belongs to.","example":"01931a72-0000-7000-8000-000000000000"},"userAgent":{"type":["string","null"],"description":"Raw User-Agent string captured when the session was created.","example":"Mozilla/5.0 (Macintosh; Intel Mac OS X 14_6_0) AppleWebKit/537.36"},"ipAddress":{"type":["string","null"],"description":"IP address captured when the session was created.","example":"203.0.113.42"},"createdAt":{"type":"string","format":"date-time","description":"When this session was created (ISO-8601 UTC).","example":"2026-05-16T09:30:00Z"},"expiresAt":{"type":"string","format":"date-time","description":"When this session expires (ISO-8601 UTC).","example":"2026-05-23T09:30:00Z"},"lastUsedAt":{"type":"string","format":"date-time","description":"When this session was last seen by the API (ISO-8601 UTC).","example":"2026-05-16T11:42:00Z"},"activeOrganizationId":{"type":["string","null"],"format":"uuid","description":"Active organization pinned to this session (`org_id` claim on re-mint)."},"impersonatedBy":{"type":["string","null"],"format":"uuid","description":"Platform user behind this session when it was established via impersonation; null for normal sign-ins."}},"required":["createdAt","environmentId","expiresAt","id","lastUsedAt","userId"]}},"securitySchemes":{"bearerAuth":{"type":"http","description":"Backend secret key (`sk_live_*` / `sk_test_*`) sent as `Authorization: Bearer <key>`.","scheme":"bearer"}}}}
|
data/src/torii/backend/client.rb
CHANGED
|
@@ -89,7 +89,7 @@ module Torii
|
|
|
89
89
|
created_after: created_after,
|
|
90
90
|
created_before: created_before,
|
|
91
91
|
)
|
|
92
|
-
opts = { server_user_search_request: body
|
|
92
|
+
opts = { server_user_search_request: body }
|
|
93
93
|
opts[:limit] = limit unless limit.nil?
|
|
94
94
|
opts[:cursor] = cursor unless cursor.nil?
|
|
95
95
|
result = @api.search_users(opts)
|
|
@@ -97,19 +97,29 @@ module Torii
|
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
def get(user_id)
|
|
100
|
-
model_to_hash(@api.get_user(user_id
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
model_to_hash(@api.get_user(user_id))
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Create a user. The metadata bags are optional; omit one to leave it
|
|
104
|
+
# empty — the server defaults absent bags to +{}+ (a brand-new user has
|
|
105
|
+
# no metadata to clobber). The generated model drops unset (nil) bags
|
|
106
|
+
# from the request body.
|
|
107
|
+
def create(email: nil, password: nil, first_name: nil, last_name: nil,
|
|
108
|
+
public_metadata: nil, private_metadata: nil, unsafe_metadata: nil)
|
|
109
|
+
# Forward only the fields the caller set; nil kwargs are dropped so the
|
|
110
|
+
# wire body stays minimal and the server applies its defaults (e.g. {}
|
|
111
|
+
# for absent metadata bags).
|
|
112
|
+
attrs = {
|
|
105
113
|
email: email,
|
|
106
|
-
name: name,
|
|
107
|
-
phone: phone,
|
|
108
114
|
password: password,
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
115
|
+
first_name: first_name,
|
|
116
|
+
last_name: last_name,
|
|
117
|
+
public_metadata: public_metadata,
|
|
118
|
+
private_metadata: private_metadata,
|
|
119
|
+
unsafe_metadata: unsafe_metadata,
|
|
120
|
+
}.compact
|
|
121
|
+
body = ToriiBackendGenerated::CreateUserRequest.new(**attrs)
|
|
122
|
+
model_to_hash(@api.create_user(body))
|
|
113
123
|
end
|
|
114
124
|
|
|
115
125
|
# PATCH a user. Each kwarg must be a {Torii::Backend::Patch}
|
|
@@ -117,12 +127,13 @@ module Torii
|
|
|
117
127
|
# "explicit nil" on their own, so we use a wrapper:
|
|
118
128
|
#
|
|
119
129
|
# client.users.update(user_id,
|
|
120
|
-
#
|
|
121
|
-
#
|
|
130
|
+
# first_name: Torii::Backend::Patch.set("Ada"), # set field
|
|
131
|
+
# last_name: Torii::Backend::Patch.set(nil), # null on the wire (clear)
|
|
122
132
|
# )
|
|
123
133
|
#
|
|
124
|
-
# Omitted kwargs are left untouched on the server.
|
|
125
|
-
#
|
|
134
|
+
# Omitted kwargs are left untouched on the server. Patchable fields:
|
|
135
|
+
# first_name, last_name, locale, unsafe_metadata. Field names map to the
|
|
136
|
+
# JSON keys the server expects (camelCase).
|
|
126
137
|
def update(user_id, **patches)
|
|
127
138
|
body = {}
|
|
128
139
|
patches.each do |field, patch|
|
|
@@ -142,12 +153,12 @@ module Torii
|
|
|
142
153
|
# sending a pre-rendered request body. The generated
|
|
143
154
|
# +UpdateUserRequest+ model strips nil-valued attributes when
|
|
144
155
|
# serialising, which would defeat the +Patch.clear+ case, so we
|
|
145
|
-
# bypass it and ship our hand-built JSON instead.
|
|
156
|
+
# bypass it and ship our hand-built JSON instead. Auth still rides the
|
|
157
|
+
# generated path (bearerAuth + the config access token).
|
|
146
158
|
result = @api.update_user(
|
|
147
159
|
user_id,
|
|
148
160
|
ToriiBackendGenerated::UpdateUserRequest.new,
|
|
149
161
|
debug_body: body.to_json,
|
|
150
|
-
header_params: auth_headers,
|
|
151
162
|
)
|
|
152
163
|
model_to_hash(result)
|
|
153
164
|
end
|
|
@@ -156,32 +167,27 @@ module Torii
|
|
|
156
167
|
# expects on the PATCH body. Centralised so +update+ can validate
|
|
157
168
|
# field names with a single +fetch+.
|
|
158
169
|
PATCH_FIELD_MAP = {
|
|
159
|
-
|
|
160
|
-
|
|
170
|
+
first_name: 'firstName',
|
|
171
|
+
last_name: 'lastName',
|
|
161
172
|
locale: 'locale',
|
|
162
|
-
|
|
163
|
-
date_of_birth: 'dateOfBirth',
|
|
173
|
+
unsafe_metadata: 'unsafeMetadata',
|
|
164
174
|
}.freeze
|
|
165
175
|
|
|
166
176
|
def delete(user_id)
|
|
167
|
-
@api.delete_user(user_id
|
|
177
|
+
@api.delete_user(user_id)
|
|
168
178
|
nil
|
|
169
179
|
end
|
|
170
180
|
|
|
171
181
|
def ban(user_id)
|
|
172
|
-
model_to_hash(@api.ban_user(user_id
|
|
182
|
+
model_to_hash(@api.ban_user(user_id))
|
|
173
183
|
end
|
|
174
184
|
|
|
175
185
|
def unban(user_id)
|
|
176
|
-
model_to_hash(@api.unban_user(user_id
|
|
186
|
+
model_to_hash(@api.unban_user(user_id))
|
|
177
187
|
end
|
|
178
188
|
|
|
179
189
|
private
|
|
180
190
|
|
|
181
|
-
def auth_headers
|
|
182
|
-
{ 'Authorization' => "Bearer #{@api_client.config.access_token}" }
|
|
183
|
-
end
|
|
184
|
-
|
|
185
191
|
def model_to_hash(model)
|
|
186
192
|
return model if model.nil? || model.is_a?(Hash)
|
|
187
193
|
|
|
@@ -208,25 +214,19 @@ module Torii
|
|
|
208
214
|
end
|
|
209
215
|
|
|
210
216
|
def list_for_user(user_id)
|
|
211
|
-
result = @api.list_sessions(user_id
|
|
217
|
+
result = @api.list_sessions(user_id)
|
|
212
218
|
(result || []).map { |s| s.respond_to?(:to_hash) ? s.to_hash : s }
|
|
213
219
|
end
|
|
214
220
|
|
|
215
221
|
def revoke_all_for_user(user_id)
|
|
216
|
-
@api.revoke_all_sessions(user_id
|
|
222
|
+
@api.revoke_all_sessions(user_id)
|
|
217
223
|
nil
|
|
218
224
|
end
|
|
219
225
|
|
|
220
226
|
def revoke(user_id, session_id)
|
|
221
|
-
@api.revoke_session(user_id, session_id
|
|
227
|
+
@api.revoke_session(user_id, session_id)
|
|
222
228
|
nil
|
|
223
229
|
end
|
|
224
|
-
|
|
225
|
-
private
|
|
226
|
-
|
|
227
|
-
def auth_headers
|
|
228
|
-
{ 'Authorization' => "Bearer #{@api_client.config.access_token}" }
|
|
229
|
-
end
|
|
230
230
|
end
|
|
231
231
|
end
|
|
232
232
|
end
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Torii Backend API
|
|
3
|
+
|
|
4
|
+
#Server-to-server API (BAPI) for backend SDKs. Authenticated with a secret key (Bearer sk_live_* / sk_test_*).
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: v1
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.22.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'cgi'
|
|
14
|
+
|
|
15
|
+
module ToriiBackendGenerated
|
|
16
|
+
class AllowedOriginsApi
|
|
17
|
+
attr_accessor :api_client
|
|
18
|
+
|
|
19
|
+
def initialize(api_client = ApiClient.default)
|
|
20
|
+
@api_client = api_client
|
|
21
|
+
end
|
|
22
|
+
# List escape-hatch origins for this environment
|
|
23
|
+
# @param [Hash] opts the optional parameters
|
|
24
|
+
# @return [AllowedOriginsResponse]
|
|
25
|
+
def list(opts = {})
|
|
26
|
+
data, _status_code, _headers = list_with_http_info(opts)
|
|
27
|
+
data
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# List escape-hatch origins for this environment
|
|
31
|
+
# @param [Hash] opts the optional parameters
|
|
32
|
+
# @return [Array<(AllowedOriginsResponse, Integer, Hash)>] AllowedOriginsResponse data, response status code and response headers
|
|
33
|
+
def list_with_http_info(opts = {})
|
|
34
|
+
if @api_client.config.debugging
|
|
35
|
+
@api_client.config.logger.debug 'Calling API: AllowedOriginsApi.list ...'
|
|
36
|
+
end
|
|
37
|
+
# resource path
|
|
38
|
+
local_var_path = '/api/server/v1/allowed-origins'
|
|
39
|
+
|
|
40
|
+
# query parameters
|
|
41
|
+
query_params = opts[:query_params] || {}
|
|
42
|
+
|
|
43
|
+
# header parameters
|
|
44
|
+
header_params = opts[:header_params] || {}
|
|
45
|
+
# HTTP header 'Accept' (if needed)
|
|
46
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
47
|
+
|
|
48
|
+
# form parameters
|
|
49
|
+
form_params = opts[:form_params] || {}
|
|
50
|
+
|
|
51
|
+
# http body (model)
|
|
52
|
+
post_body = opts[:debug_body]
|
|
53
|
+
|
|
54
|
+
# return_type
|
|
55
|
+
return_type = opts[:debug_return_type] || 'AllowedOriginsResponse'
|
|
56
|
+
|
|
57
|
+
# auth_names
|
|
58
|
+
auth_names = opts[:debug_auth_names] || ['bearerAuth']
|
|
59
|
+
|
|
60
|
+
new_options = opts.merge(
|
|
61
|
+
:operation => :"AllowedOriginsApi.list",
|
|
62
|
+
:header_params => header_params,
|
|
63
|
+
:query_params => query_params,
|
|
64
|
+
:form_params => form_params,
|
|
65
|
+
:body => post_body,
|
|
66
|
+
:auth_names => auth_names,
|
|
67
|
+
:return_type => return_type
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
|
71
|
+
if @api_client.config.debugging
|
|
72
|
+
@api_client.config.logger.debug "API called: AllowedOriginsApi#list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
73
|
+
end
|
|
74
|
+
return data, status_code, headers
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Replace the escape-hatch origins for this environment
|
|
78
|
+
# Full origins incl. non-http schemes (e.g. capacitor://localhost). Replaces the list.
|
|
79
|
+
# @param set_allowed_origins_request [SetAllowedOriginsRequest]
|
|
80
|
+
# @param [Hash] opts the optional parameters
|
|
81
|
+
# @return [AllowedOriginsResponse]
|
|
82
|
+
def set(set_allowed_origins_request, opts = {})
|
|
83
|
+
data, _status_code, _headers = set_with_http_info(set_allowed_origins_request, opts)
|
|
84
|
+
data
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# Replace the escape-hatch origins for this environment
|
|
88
|
+
# Full origins incl. non-http schemes (e.g. capacitor://localhost). Replaces the list.
|
|
89
|
+
# @param set_allowed_origins_request [SetAllowedOriginsRequest]
|
|
90
|
+
# @param [Hash] opts the optional parameters
|
|
91
|
+
# @return [Array<(AllowedOriginsResponse, Integer, Hash)>] AllowedOriginsResponse data, response status code and response headers
|
|
92
|
+
def set_with_http_info(set_allowed_origins_request, opts = {})
|
|
93
|
+
if @api_client.config.debugging
|
|
94
|
+
@api_client.config.logger.debug 'Calling API: AllowedOriginsApi.set ...'
|
|
95
|
+
end
|
|
96
|
+
# verify the required parameter 'set_allowed_origins_request' is set
|
|
97
|
+
if @api_client.config.client_side_validation && set_allowed_origins_request.nil?
|
|
98
|
+
fail ArgumentError, "Missing the required parameter 'set_allowed_origins_request' when calling AllowedOriginsApi.set"
|
|
99
|
+
end
|
|
100
|
+
# resource path
|
|
101
|
+
local_var_path = '/api/server/v1/allowed-origins'
|
|
102
|
+
|
|
103
|
+
# query parameters
|
|
104
|
+
query_params = opts[:query_params] || {}
|
|
105
|
+
|
|
106
|
+
# header parameters
|
|
107
|
+
header_params = opts[:header_params] || {}
|
|
108
|
+
# HTTP header 'Accept' (if needed)
|
|
109
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
110
|
+
# HTTP header 'Content-Type'
|
|
111
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
|
112
|
+
if !content_type.nil?
|
|
113
|
+
header_params['Content-Type'] = content_type
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# form parameters
|
|
117
|
+
form_params = opts[:form_params] || {}
|
|
118
|
+
|
|
119
|
+
# http body (model)
|
|
120
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(set_allowed_origins_request)
|
|
121
|
+
|
|
122
|
+
# return_type
|
|
123
|
+
return_type = opts[:debug_return_type] || 'AllowedOriginsResponse'
|
|
124
|
+
|
|
125
|
+
# auth_names
|
|
126
|
+
auth_names = opts[:debug_auth_names] || ['bearerAuth']
|
|
127
|
+
|
|
128
|
+
new_options = opts.merge(
|
|
129
|
+
:operation => :"AllowedOriginsApi.set",
|
|
130
|
+
:header_params => header_params,
|
|
131
|
+
:query_params => query_params,
|
|
132
|
+
:form_params => form_params,
|
|
133
|
+
:body => post_body,
|
|
134
|
+
:auth_names => auth_names,
|
|
135
|
+
:return_type => return_type
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
|
|
139
|
+
if @api_client.config.debugging
|
|
140
|
+
@api_client.config.logger.debug "API called: AllowedOriginsApi#set\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
141
|
+
end
|
|
142
|
+
return data, status_code, headers
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
=begin
|
|
2
|
-
#
|
|
2
|
+
#Torii Backend API
|
|
3
3
|
|
|
4
|
-
#
|
|
4
|
+
#Server-to-server API (BAPI) for backend SDKs. Authenticated with a secret key (Bearer sk_live_* / sk_test_*).
|
|
5
5
|
|
|
6
|
-
The version of the OpenAPI document:
|
|
6
|
+
The version of the OpenAPI document: v1
|
|
7
7
|
|
|
8
8
|
Generated by: https://openapi-generator.tech
|
|
9
9
|
Generator version: 7.22.0
|
|
@@ -63,7 +63,7 @@ module ToriiBackendGenerated
|
|
|
63
63
|
return_type = opts[:debug_return_type] || 'Array<UserSessionResponse>'
|
|
64
64
|
|
|
65
65
|
# auth_names
|
|
66
|
-
auth_names = opts[:debug_auth_names] || []
|
|
66
|
+
auth_names = opts[:debug_auth_names] || ['bearerAuth']
|
|
67
67
|
|
|
68
68
|
new_options = opts.merge(
|
|
69
69
|
:operation => :"ServerSessionsApi.list_sessions",
|
|
@@ -126,7 +126,7 @@ module ToriiBackendGenerated
|
|
|
126
126
|
return_type = opts[:debug_return_type]
|
|
127
127
|
|
|
128
128
|
# auth_names
|
|
129
|
-
auth_names = opts[:debug_auth_names] || []
|
|
129
|
+
auth_names = opts[:debug_auth_names] || ['bearerAuth']
|
|
130
130
|
|
|
131
131
|
new_options = opts.merge(
|
|
132
132
|
:operation => :"ServerSessionsApi.revoke_all_sessions",
|
|
@@ -195,7 +195,7 @@ module ToriiBackendGenerated
|
|
|
195
195
|
return_type = opts[:debug_return_type]
|
|
196
196
|
|
|
197
197
|
# auth_names
|
|
198
|
-
auth_names = opts[:debug_auth_names] || []
|
|
198
|
+
auth_names = opts[:debug_auth_names] || ['bearerAuth']
|
|
199
199
|
|
|
200
200
|
new_options = opts.merge(
|
|
201
201
|
:operation => :"ServerSessionsApi.revoke_session",
|