Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions __tests__/gen/oauth2-verify_oauth_account_linking.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { oauth2, ApiError } from '../../src/index.js'

async function example() {
const response = await oauth2.verify_oauth_account_linking({
callback_url: 'string',
token: 'string',
})
return response
}

describe('Testing oauth2.verify_oauth_account_linking', () => {
it('should be truthy or throw', async () => {
try {
await example()
} catch (err) {
expect(err).toBeInstanceOf(ApiError)
}
})
})
8 changes: 8 additions & 0 deletions kittycad.ts.patch.json
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,14 @@
"libDocsLink": ""
}
},
{
"op": "add",
"path": "/paths/~1oauth2~1verify-account-linking/get/x-typescript",
"value": {
"example": "import { oauth2, ApiError } from '@kittycad/lib'\n\nasync function example() {\n const response = await oauth2.verify_oauth_account_linking({\n callback_url: 'string',\n token: 'string',\n })\n}\n\n// Error handling\ntry {\n const res = await example()\n} catch (e) {\n if (e instanceof ApiError) {\n console.error('status', e.status, 'code', e.body?.error_code)\n console.error('message', e.body?.message)\n console.error('request_id', e.body?.request_id)\n } else {\n throw e\n }\n}\n",
"libDocsLink": ""
}
},
{
"op": "add",
"path": "/paths/~1oauth2~1token~1revoke/post/x-typescript",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kittycad/lib",
"version": "3.1.43",
"version": "3.1.44",
"description": "Javascript library for KittyCAD API",
"type": "module",
"keywords": [
Expand Down
204 changes: 204 additions & 0 deletions spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -7768,6 +7768,198 @@
}
}
},
"/oauth2/verify-account-linking": {
"get": {
"tags": [
"oauth2"
],
"summary": "Verify OAuth account linking and complete the authentication.",
"description": "This endpoint is called when a user clicks the verification link sent to their email after attempting to log in with OAuth when an existing account with the same email was found. This endpoint validates the token, links the OAuth account to the user, and creates a session.",
"operationId": "verify_oauth_account_linking",
"parameters": [
{
"in": "query",
"name": "callback_url",
"description": "Optional callback URL to redirect to after verification",
"schema": {
"nullable": true,
"type": "string"
}
},
{
"in": "query",
"name": "token",
"description": "The verification token from the email",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"302": {
"description": "Temporary Redirect",
"headers": {
"Access-Control-Allow-Credentials": {
"description": "Access-Control-Allow-Credentials header.",
"style": "simple",
"schema": {
"nullable": true,
"type": "string"
}
},
"Access-Control-Allow-Headers": {
"description": "Access-Control-Allow-Headers header. This is a comma-separated list of headers.",
"style": "simple",
"schema": {
"nullable": true,
"type": "string"
}
},
"Access-Control-Allow-Methods": {
"description": "Access-Control-Allow-Methods header.",
"style": "simple",
"schema": {
"nullable": true,
"type": "string"
}
},
"Access-Control-Allow-Origin": {
"description": "Access-Control-Allow-Origin header.",
"style": "simple",
"schema": {
"nullable": true,
"type": "string"
}
},
"Content-Location": {
"description": "The Content-Location header for responses that are not the final destination. This is used to indicate where the resource can be found, when it is finished.",
"style": "simple",
"schema": {
"nullable": true,
"type": "string"
}
},
"Location": {
"description": "The location header for redirects and letting users know if there is a websocket they can listen to for status updates on their operation.",
"style": "simple",
"schema": {
"nullable": true,
"type": "string"
}
},
"Set-Cookie": {
"description": "Set-Cookie header.",
"style": "simple",
"schema": {
"nullable": true,
"type": "string"
}
},
"X-Api-Call-Id": {
"description": "ID for this request. We return it so that users can report this to us and help us debug their problems.",
"style": "simple",
"required": true,
"schema": {
"type": "string"
}
}
}
},
"4XX": {
"$ref": "#/components/responses/Error"
},
"5XX": {
"$ref": "#/components/responses/Error"
}
}
},
"options": {
"tags": [
"hidden"
],
"summary": "OPTIONS endpoint.",
"description": "This is necessary for some preflight requests, specifically POST, PUT, and DELETE.",
"operationId": "options_verify_oauth_account_linking",
"responses": {
"204": {
"description": "resource updated",
"headers": {
"Access-Control-Allow-Credentials": {
"description": "Access-Control-Allow-Credentials header.",
"style": "simple",
"schema": {
"nullable": true,
"type": "string"
}
},
"Access-Control-Allow-Headers": {
"description": "Access-Control-Allow-Headers header. This is a comma-separated list of headers.",
"style": "simple",
"schema": {
"nullable": true,
"type": "string"
}
},
"Access-Control-Allow-Methods": {
"description": "Access-Control-Allow-Methods header.",
"style": "simple",
"schema": {
"nullable": true,
"type": "string"
}
},
"Access-Control-Allow-Origin": {
"description": "Access-Control-Allow-Origin header.",
"style": "simple",
"schema": {
"nullable": true,
"type": "string"
}
},
"Content-Location": {
"description": "The Content-Location header for responses that are not the final destination. This is used to indicate where the resource can be found, when it is finished.",
"style": "simple",
"schema": {
"nullable": true,
"type": "string"
}
},
"Location": {
"description": "The location header for redirects and letting users know if there is a websocket they can listen to for status updates on their operation.",
"style": "simple",
"schema": {
"nullable": true,
"type": "string"
}
},
"Set-Cookie": {
"description": "Set-Cookie header.",
"style": "simple",
"schema": {
"nullable": true,
"type": "string"
}
},
"X-Api-Call-Id": {
"description": "ID for this request. We return it so that users can report this to us and help us debug their problems.",
"style": "simple",
"required": true,
"schema": {
"type": "string"
}
}
}
},
"4XX": {
"$ref": "#/components/responses/Error"
},
"5XX": {
"$ref": "#/components/responses/Error"
}
}
}
},
"/org": {
"get": {
"tags": [
Expand Down Expand Up @@ -25600,6 +25792,13 @@
"enum": [
"tencent"
]
},
{
"description": "Test provider for integration tests (only available during testing).",
"type": "string",
"enum": [
"test_provider"
]
}
]
},
Expand Down Expand Up @@ -33423,6 +33622,11 @@
}
]
},
"sketch_solve": {
"description": "To handle the transition period between sketch 1 and sketch_solve, set a flag for sketch_solve, True for sketch_solve, false for sketch 1. Defaults to false",
"default": false,
"type": "boolean"
},
"source_ranges": {
"description": "The source ranges the user suggested to change. If empty, the content (prompt) will be used and is required.",
"type": "array",
Expand Down
65 changes: 65 additions & 0 deletions src/api/oauth2/verify_oauth_account_linking.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { Client, buildQuery } from '../../client.js'
import { throwIfNotOk } from '../../errors.js'

import {} from '../../models.js'

interface VerifyOauthAccountLinkingInput {
client?: Client
callback_url?: string
token: string
}

type VerifyOauthAccountLinkingReturn = unknown

/**
* Verify OAuth account linking and complete the authentication.
*
* This endpoint is called when a user clicks the verification link sent to their email after attempting to log in with OAuth when an existing account with the same email was found. This endpoint validates the token, links the OAuth account to the user, and creates a session.
*
* Tags: oauth2
*
* @param params Function parameters.
* @property {Client} [client] Optional client with auth token.
* @property {string} callback_url Optional callback URL to redirect to after verification (query)
* @property {string} token The verification token from the email (query)
* @returns {Promise<VerifyOauthAccountLinkingReturn>} Temporary Redirect
*/
export default async function verify_oauth_account_linking({
client,
callback_url,
token,
}: VerifyOauthAccountLinkingInput): Promise<VerifyOauthAccountLinkingReturn> {
const path = `/oauth2/verify-account-linking`
const qs = buildQuery({ callback_url: callback_url, token: token })
const url = path + qs
// Backwards compatible for the BASE_URL env variable
// That used to exist in only this lib, ZOO_HOST exists in the all the other
// sdks and the CLI.
const urlBase =
client?.baseUrl ||
process?.env?.ZOO_HOST ||
process?.env?.BASE_URL ||
'https://api.zoo.dev'
const fullUrl = urlBase + url
// The other sdks use to use KITTYCAD_API_TOKEN, now they still do for
// backwards compatibility, but the new standard is ZOO_API_TOKEN.
// For some reason only this lib supported KITTYCAD_TOKEN, so we need to
// check for that as well.
const kittycadToken = client
? client.token || process.env.ZOO_API_TOKEN || ''
: process.env.KITTYCAD_TOKEN ||
process.env.KITTYCAD_API_TOKEN ||
process.env.ZOO_API_TOKEN ||
''
const headers: Record<string, string> = {}
if (kittycadToken) headers.Authorization = `Bearer ${kittycadToken}`
const fetchOptions: RequestInit = {
method: 'GET',
headers,
}
const _fetch = client?.fetch || fetch
const response = await _fetch(fullUrl, fetchOptions)
await throwIfNotOk(response)
const result = (await response.json()) as VerifyOauthAccountLinkingReturn
return result
}
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ import oauth2_provider_callback from './api/oauth2/oauth2_provider_callback.js'
import oauth2_provider_callback_post from './api/oauth2/oauth2_provider_callback_post.js'
import oauth2_provider_consent from './api/oauth2/oauth2_provider_consent.js'
import oauth2_token_revoke from './api/oauth2/oauth2_token_revoke.js'
import verify_oauth_account_linking from './api/oauth2/verify_oauth_account_linking.js'
export const oauth2 = {
device_access_token,
device_auth_confirm,
Expand All @@ -161,6 +162,7 @@ export const oauth2 = {
oauth2_provider_callback_post,
oauth2_provider_consent,
oauth2_token_revoke,
verify_oauth_account_linking,
}

import create_org from './api/orgs/create_org.js'
Expand Down
8 changes: 8 additions & 0 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type AccountProvider =
| 'microsoft'
| 'saml'
| 'tencent'
| 'test_provider'

export interface AddHoleFromOffset {
/**
Expand Down Expand Up @@ -3454,6 +3455,13 @@ export type MlCopilotClientMessage =
project_name?: string
/** nullable:true, description:Change the default or mode reasoning effort. */
reasoning_effort?: MlReasoningEffort
/**
* {
* "default": false,
* "description": "To handle the transition period between sketch 1 and sketch_solve, set a flag for sketch_solve, True for sketch_solve, false for sketch 1. Defaults to false"
* }
*/
sketch_solve?: boolean
/** The source ranges the user suggested to change. If empty, the content (prompt) will be used and is required. */
source_ranges?: SourceRangePrompt[]
type: 'user'
Expand Down
Loading